Commit 457c5310 authored by Gerstrong's avatar Gerstrong

slugs are now stunnable

parent af651999
......@@ -102,7 +102,10 @@ void CMapPlayGalaxy::process()
{
CObject *theOtherObj = m_ObjectPtr[j];
if( theOtherObj != p_Object )
p_Object->getTouchedBy(*theOtherObj);
{
if( p_Object->hitdetect(*theOtherObj) )
p_Object->getTouchedBy(*theOtherObj);
}
}
}
}
......
/*
* CBullets.cpp
*
* Created on: 01.12.2010
* Author: gerstrong
*/
#include "CBullets.h"
#include "sdl/sound/CSound.h"
namespace galaxy
{
const Uint32 speed = 10;
const Uint32 hittime = 100;
CBullets::CBullets(CMap *pmap, const Uint32 x, const Uint32 y, const direction_t dir) :
CObject(pmap, x, y, OBJ_RAY)
{
m_hDir = NONE;
m_vDir = NONE;
if(dir == LEFT || dir == RIGHT)
m_hDir = dir;
else if(dir == UP || dir == DOWN)
m_vDir = dir;
m_ActionBaseOffset = 0x1738;
setActionForce(A_KEENSHOT_MOVING);
setActionSprite();
calcBouncingBoxes();
playSound( SOUND_KEEN_FIRE );
}
void CBullets::process()
{
if( !getActionNumber(A_KEENSHOT_IMPACT) && (blockedd || blockedu || blockedl || blockedr || onslope) )
{
setAction(A_KEENSHOT_IMPACT);
playSound( SOUND_SHOT_HIT );
}
processActionRoutine();
}
}
/*
* CBullets.h
*
* Created on: 01.12.2010
* Author: gerstrong
*
* This handles the bullets that go over the place, whenever keen shoots one.
*/
#ifndef CBULLETS_H_
#define CBULLETS_H_
#include "common/CObject.h"
namespace galaxy
{
#define A_KEENSHOT_MOVING 0
#define A_KEENSHOT_IMPACT 4
/*ACTION keenshot_actions[] = {
//Shot moving routine
// AZ.1738
{ 174, 174, 1, 0,
0, 6, 64, 64,
I:0D6A, NULL, I:0E32,
&keenshot_actions[A_KEENSHOT_MOVING+1]
},
// AZ.1756
{ 175, 175, 1, 0,
0, 6, 64, 64,
I:0D6A, NULL, I:0E32,
&keenshot_actions[A_KEENSHOT_MOVING+2]
},
// AZ.1774
{ 176, 176, 1, 0,
0, 6, 64, 64,
I:0D6A, NULL, I:0E32,
&keenshot_actions[A_KEENSHOT_MOVING+3]
},
// AZ.1792
{ 177, 177, 1, 0,
0, 6, 64, 64,
I:0D6A, NULL, I:0E32,
&keenshot_actions[A_KEENSHOT_MOVING]
},
// Shot impact routine
// AZ.17B0
{ 178, 178, 0, 0,
0, 12, 0, 0,
NULL, NULL, G:176E,
&keenshot_actions[A_KEENSHOT_IMPACT+1]
},
// AZ.17CE
{ 179, 179, 0, 0,
0, 12, 0, 0,
NULL, NULL, G:176E,
NULL
}
};
*/
class CBullets : public CObject {
public:
CBullets(CMap *pmap, Uint32 x, Uint32 y, direction_t dir);
void process();
private:
Uint32 m_timer;
};
}
#endif /* CBULLETS_H_ */
......@@ -6,7 +6,7 @@
*/
#include "CPlayerLevel.h"
#include "CBullets.h"
#include "CBullet.h"
#include "common/CBehaviorEngine.h"
#include "platform/CPlatform.h"
#include "sdl/CInput.h"
......@@ -64,9 +64,12 @@ void CPlayerLevel::processMoveBitDown()
{
for( size_t i = 0 ; i<m_ObjectPtrs.size() ; i++ )
{
if( CPlatform *platform = dynamic_cast<CPlatform*>(m_ObjectPtrs[i]) )
if(m_ObjectPtrs[i]->hitdetect(*this))
{
platform->getTouchedBy(*this);
if( CPlatform *platform = dynamic_cast<CPlatform*>(m_ObjectPtrs[i]) )
{
platform->getTouchedBy(*this);
}
}
}
......@@ -94,7 +97,7 @@ void CPlayerLevel::tryToShoot( const VectorD2<int> &pos, const direction_t &dir
{
if(m_Inventory.Item.m_bullets > 0)
{
m_ObjectPtrs.push_back(new CBullets(mp_Map, pos.x, pos.y, dir));
m_ObjectPtrs.push_back(new CBullet(mp_Map, pos.x, pos.y, dir));
}
else
{
......@@ -1223,7 +1226,7 @@ void CPlayerLevel::processRunning()
const int newy = getYPosition()+(4<<STC);
if(m_Inventory.Item.m_bullets > 0)
{
m_ObjectPtrs.push_back(new CBullets(mp_Map, newx, newy, m_hDir));
m_ObjectPtrs.push_back(new CBullet(mp_Map, newx, newy, m_hDir));
}
else
{
......
......@@ -45,75 +45,72 @@ void CSpriteItem::process()
void CSpriteItem::getTouchedBy(CObject &theObject)
{
if(hitdetect(theObject))
{
exists = false;
exists = false;
if(theObject.m_type != OBJ_PLAYER)
return;
if(theObject.m_type != OBJ_PLAYER)
return;
CPlayerLevel *pPlayer = (CPlayerLevel*)(&theObject);
stItemGalaxy &Item = pPlayer->m_Inventory.Item;
CPlayerLevel *pPlayer = (CPlayerLevel*)(&theObject);
stItemGalaxy &Item = pPlayer->m_Inventory.Item;
/// Calculate the right animation.
// Point items
Uint32 newanimsprite = got_sprite_item_pics[0];
if( m_basesprite >= 103 && m_basesprite <= 116 )
/// Calculate the right animation.
// Point items
Uint32 newanimsprite = got_sprite_item_pics[0];
if( m_basesprite >= 103 && m_basesprite <= 116 )
{
newanimsprite = got_sprite_item_pics[4+(m_basesprite-103)/2];
switch(m_basesprite)
{
newanimsprite = got_sprite_item_pics[4+(m_basesprite-103)/2];
switch(m_basesprite)
{
case 103: Item.m_points += 100; break;
case 105: Item.m_points += 200; break;
case 107: Item.m_points += 500; break;
case 109: Item.m_points += 1000; break;
case 111: Item.m_points += 2000; break;
case 113: Item.m_points += 5000; break;
default: break;
}
g_pSound->playSound( SOUND_GET_BONUS );
case 103: Item.m_points += 100; break;
case 105: Item.m_points += 200; break;
case 107: Item.m_points += 500; break;
case 109: Item.m_points += 1000; break;
case 111: Item.m_points += 2000; break;
case 113: Item.m_points += 5000; break;
default: break;
}
g_pSound->playSound( SOUND_GET_BONUS );
}
// raygun
if( m_basesprite >= 127 && m_basesprite <= 128 )
{
Item.m_bullets += 5;
newanimsprite = got_sprite_item_pics[11];
g_pSound->playSound( SOUND_GET_AMMO );
}
// raygun
if( m_basesprite >= 127 && m_basesprite <= 128 )
{
Item.m_bullets += 5;
newanimsprite = got_sprite_item_pics[11];
g_pSound->playSound( SOUND_GET_AMMO );
}
m_ObjectPtrs.push_back(new CItemEffect(mp_Map, getXPosition(), getYPosition(), newanimsprite));
m_ObjectPtrs.push_back(new CItemEffect(mp_Map, getXPosition(), getYPosition(), newanimsprite));
// Now add the stuff to the inventory
// Now add the stuff to the inventory
if( m_basesprite >= 118 && m_basesprite <= 124 )
if( m_basesprite >= 118 && m_basesprite <= 124 )
{
switch(m_basesprite)
{
switch(m_basesprite)
{
case 118: case 119:
Item.m_gem.red++;
break;
case 120: case 121:
Item.m_gem.yellow++;
break;
case 122: case 123:
Item.m_gem.blue++;
break;
case 124: case 125:
Item.m_gem.green++;
break;
default:
break;
}
g_pSound->playSound( SOUND_GET_GEM );
case 118: case 119:
Item.m_gem.red++;
break;
case 120: case 121:
Item.m_gem.yellow++;
break;
case 122: case 123:
Item.m_gem.blue++;
break;
case 124: case 125:
Item.m_gem.green++;
break;
default:
break;
}
g_pSound->playSound( SOUND_GET_GEM );
}
if ( m_basesprite == 115 )
{
Item.m_lifes++;
g_pSound->playSound( SOUND_EXTRA_LIFE );
}
if ( m_basesprite == 115 )
{
Item.m_lifes++;
g_pSound->playSound( SOUND_EXTRA_LIFE );
}
}
......
......@@ -11,12 +11,31 @@
*/
#include "CStunnable.h"
#include "CBullet.h"
namespace galaxy
{
CStunnable::CStunnable( CMap *pmap,
Uint32 x,
Uint32 y,
object_t type ):
CObject(pmap, x, y, type)
{}
void CStunnable::getTouchedBy(CObject &theObject)
{
if( dynamic_cast<CBullet*>(&theObject) )
{
theObject.setAction(A_KEENSHOT_IMPACT);
theObject.playSound( SOUND_SHOT_HIT );
}
}
void CStunnable::processStunned()
{
}
};
......@@ -9,6 +9,10 @@
#define CSTUNNABLE_H_
#include "common/CObject.h"
#include "engine/galaxy/ai/CBullet.h"
namespace galaxy
{
class CStunnable: public CObject {
public:
......@@ -16,6 +20,22 @@ public:
Uint32 x,
Uint32 y,
object_t type );
/**
* This is the cycle which will animate the stars while the enemy is stunned
*/
void processStunned();
/**
* What happens when some objects gets touched, or normally shot
*/
virtual void getTouchedBy(CObject &theObject);
protected:
bool m_stunned;
void (CStunnable::*mp_processState)();
};
}
#endif /* CSTUNNABLE_H_ */
......@@ -113,39 +113,35 @@ void CCouncilMember::getTouchedBy(CObject &theObject)
if(rescued)
return;
if(hitdetect(theObject))
// When Keen touches the Council Member exit the level and add one to the council list
if(theObject.m_type == OBJ_PLAYER)
{
// When Keen touches the Council Member exit the level and add one to the council list
if(theObject.m_type == OBJ_PLAYER)
{
CPlayerLevel &Player = static_cast<CPlayerLevel&>(theObject);
int &rescuedelders = Player.m_Inventory.Item.m_special.ep4.elders;
CPlayerLevel &Player = static_cast<CPlayerLevel&>(theObject);
int &rescuedelders = Player.m_Inventory.Item.m_special.ep4.elders;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
// TODO: In this part we have to check which level we are and send the proper messages
// TODO: In this part we have to check which level we are and send the proper messages
g_pSound->playSound(SOUND_RESCUE_COUNCIL_MEMBER, PLAY_PAUSEALL);
EventContainer.add( new EventPlayTrack(5) );
g_pSound->playSound(SOUND_RESCUE_COUNCIL_MEMBER, PLAY_PAUSEALL);
EventContainer.add( new EventPlayTrack(5) );
std::string elder_text[2];
std::string elder_text[2];
elder_text[0] = g_pBehaviorEngine->getString("ELDERS_TEXT");
elder_text[1] = g_pBehaviorEngine->getString(answermap[rescuedelders]);
elder_text[0] = g_pBehaviorEngine->getString("ELDERS_TEXT");
elder_text[1] = g_pBehaviorEngine->getString(answermap[rescuedelders]);
EventContainer.add( new EventSendBitmapDialogMsg(104, elder_text[0], LEFT) );
EventContainer.add( new EventSendBitmapDialogMsg(106, elder_text[1], RIGHT) );
EventContainer.add( new EventSendBitmapDialogMsg(104, elder_text[0], LEFT) );
EventContainer.add( new EventSendBitmapDialogMsg(106, elder_text[1], RIGHT) );
if(rescuedelders == 7)
EventContainer.add( new EventSendBitmapDialogMsg(106, g_pBehaviorEngine->getString(answermap[8]), RIGHT) );
if(rescuedelders == 7)
EventContainer.add( new EventSendBitmapDialogMsg(106, g_pBehaviorEngine->getString(answermap[8]), RIGHT) );
EventContainer.add( new EventExitLevel(mp_Map->getLevel(), true) );
rescuedelders++;
EventContainer.add( new EventExitLevel(mp_Map->getLevel(), true) );
rescuedelders++;
rescued = true;
}
rescued = true;
}
}
}
......@@ -5,6 +5,7 @@
* Author: FCTW
*/
#include "CPoisonSlug.h"
#include "CSlugSlime.h"
#include "misc.h"
......@@ -17,13 +18,13 @@ const int SLUG_MOVE_TIMER = 10;
CPoisonSlug::CPoisonSlug(CMap *pmap, Uint32 x, Uint32 y,
std::vector<CObject*>&ObjectPtrs) :
CObject(pmap, x, y, OBJ_NONE),
CStunnable(pmap, x, y, OBJ_NONE),
m_ObjectPtrs(ObjectPtrs),
m_timer(0)
{
m_ActionBaseOffset = 0x2012;
setActionForce(A_SLUG_MOVE);
mp_processState = &CPoisonSlug::processCrawling;
mp_processState = (void (CStunnable::*)()) &CPoisonSlug::processCrawling;
m_hDir = LEFT;
processActionRoutine();
performCollisions();
......@@ -57,7 +58,7 @@ void CPoisonSlug::processCrawling()
if( getProbability(30) )
{
m_timer = 0;
mp_processState = &CPoisonSlug::processPooing;
mp_processState = (void (CStunnable::*)()) &CPoisonSlug::processPooing;
setAction( A_SLUG_POOING );
playSound( SOUND_SLUG_DEFECATE );
m_ObjectPtrs.push_back(new CSlugSlime(mp_Map, getXLeftPos(), getYDownPos()-(8<<STC)));
......@@ -81,12 +82,26 @@ void CPoisonSlug::processPooing()
if( getActionStatus(A_SLUG_MOVE) )
{
setAction(A_SLUG_MOVE);
mp_processState = &CPoisonSlug::processCrawling;
mp_processState = (void (CStunnable::*)()) &CPoisonSlug::processCrawling;
}
}
void CPoisonSlug::getTouchedBy(CObject &theObject)
{
if(dead)
return;
CStunnable::getTouchedBy(theObject);
// Was it a bullet? Than make it stunned.
if( dynamic_cast<CBullet*>(&theObject) )
{
mp_processState = &CStunnable::processStunned;
setAction( rand()%2 ? A_SLUG_STUNNED : A_SLUG_STUNNED_ALT );
dead = true;
}
}
......
......@@ -11,7 +11,7 @@
#define CPOISONSLUG_H_
#include <vector>
#include "common/CObject.h"
#include "engine/galaxy/ai/CStunnable.h"
namespace galaxy {
......@@ -20,7 +20,7 @@ namespace galaxy {
#define A_SLUG_STUNNED 3
#define A_SLUG_STUNNED_ALT 4
class CPoisonSlug : public CObject {
class CPoisonSlug : public CStunnable {
public:
CPoisonSlug(CMap *pmap, Uint32 x, Uint32 y,
std::vector<CObject*>&ObjectPtrs);
......@@ -36,12 +36,17 @@ public:
*/
void processPooing();
void process();
/**
* What happens if the slug gets touched by another object
*/
void getTouchedBy(CObject &theObject);
private:
std::vector<CObject*>& m_ObjectPtrs;
int m_timer;
void (CPoisonSlug::*mp_processState)();
};
}
......
......@@ -79,19 +79,16 @@ void CPlatform::process()
void CPlatform::getTouchedBy(CObject &theObject)
{
if(hitdetect(theObject))
if(theObject.m_type == OBJ_PLAYER)
{
if(theObject.m_type == OBJ_PLAYER)
CPlayerLevel &Player = static_cast<CPlayerLevel&>(theObject);
const int m_py2 = Player.getYDownPos();
const int m_y2 = getYUpPos()+(4<<STC);
if( m_py2 <= m_y2 && !Player.supportedbyobject && !Player.m_jumpdownfromobject )
{
CPlayerLevel &Player = static_cast<CPlayerLevel&>(theObject);
const int m_py2 = Player.getYDownPos();
const int m_y2 = getYUpPos()+(4<<STC);
if( m_py2 <= m_y2 && !Player.supportedbyobject && !Player.m_jumpdownfromobject )
{
mp_CarriedPlayer = &Player;
Player.supportedbyobject = true;
}
mp_CarriedPlayer = &Player;
Player.supportedbyobject = true;
}
}
}
......
......@@ -80,12 +80,9 @@ void CButler::process()
void CButler::getTouchedBy(CObject &theObject)
{ // push keen
if(hitdetect(theObject))
if( theObject.m_type == OBJ_PLAYER )
{
if( theObject.m_type == OBJ_PLAYER )
{
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
Player.bump( *this, movedir );
}
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
Player.bump( *this, movedir );
}
}
......@@ -207,13 +207,10 @@ void CFoob::process()
void CFoob::getTouchedBy(CObject &theObject)
{
if(hitdetect(theObject))
if(theObject.m_type == OBJ_PLAYER)
{
if(theObject.m_type == OBJ_PLAYER)
{
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
if(mp_Map->m_Difficulty>2)
Player.kill();
}
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
if(mp_Map->m_Difficulty>2)
Player.kill();
}
}
......@@ -99,17 +99,14 @@ void CPlatform::SetAllCanSupportPlayer(bool state)
void CPlatform::getTouchedBy(CObject &theObject)
{
if(hitdetect(theObject))
// push player horizontally
if( theObject.m_type == OBJ_PLAYER )
{
// push player horizontally
if( theObject.m_type == OBJ_PLAYER )
{
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
if(Player.pfalling or !Player.blockedd or !Player.supportedbyobject)
Player.push(*this);
else if( state == PLATFORM_MOVE )
Player.moveXDir( (movedir==LEFT) ? -PLATFORM_MOVE_SPD : PLATFORM_MOVE_SPD);
}
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
if(Player.pfalling or !Player.blockedd or !Player.supportedbyobject)
Player.push(*this);
else if( state == PLATFORM_MOVE )
Player.moveXDir( (movedir==LEFT) ? -PLATFORM_MOVE_SPD : PLATFORM_MOVE_SPD);
}
}
......@@ -133,16 +133,13 @@ void CPlatformVert::process()
void CPlatformVert::getTouchedBy(CObject &theObject)
{
if(hitdetect(theObject))
// push player horizontally
if( theObject.m_type == OBJ_PLAYER )
{
// push player horizontally
if( theObject.m_type == OBJ_PLAYER )
{
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
if(Player.pfalling or !Player.supportedbyobject)
Player.push(*this);
else if( state == PLATVERT_MOVE )
Player.moveYDir( (movedir==UP) ? -PLATVERT_MOVE_SPD : PLATVERT_MOVE_SPD);
}
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
if(Player.pfalling or !Player.supportedbyobject)
Player.push(*this);
else if( state == PLATVERT_MOVE )
Player.moveYDir( (movedir==UP) ? -PLATVERT_MOVE_SPD : PLATVERT_MOVE_SPD);
}
}
......@@ -164,7 +164,7 @@ void CRay::moveinAir()
void CRay::getTouchedBy(CObject &theObject)
{
if(hitdetect(theObject) && !theObject.dead && !theObject.dying)
if( !theObject.dead && !theObject.dying )
{
if(theObject.canbezapped && state == RAY_STATE_FLY )
{
......
......@@ -140,28 +140,25 @@ void CSectorEffector::process()
void CSectorEffector::getTouchedBy(CObject &theObject)
{
if(hitdetect(theObject))
{
bool it_is_mortimer_machine = false;
bool it_is_mortimer_machine = false;
it_is_mortimer_machine = (setype == SE_MORTIMER_LEG_LEFT)
|| (setype == SE_MORTIMER_LEG_RIGHT)
|| (setype == SE_MORTIMER_ARM)
|| (setype == SE_MORTIMER_SPARK);
it_is_mortimer_machine = (setype == SE_MORTIMER_LEG_LEFT)
|| (setype == SE_MORTIMER_LEG_RIGHT)
|| (setype == SE_MORTIMER_ARM)
|| (setype == SE_MORTIMER_SPARK);
if(it_is_mortimer_machine)
if(it_is_mortimer_machine)
{
if (theObject.m_type == OBJ_PLAYER)
{
if (theObject.m_type == OBJ_PLAYER)
{
theObject.kill();
}
theObject.kill();
}
}
if( ( setype == SE_MORTIMER_SPARK || setype == SE_MORTIMER_HEART ) &&
HealthPoints>0 && theObject.m_type == OBJ_RAY )
{
HealthPoints--;
}
if( ( setype == SE_MORTIMER_SPARK || setype == SE_MORTIMER_HEART ) &&
HealthPoints>0 && theObject.m_type == OBJ_RAY )
{
HealthPoints--;
}
}
......
......@@ -187,12 +187,9 @@ void CTank::process()
void CTank::getTouchedBy(CObject &theObject)
{ // push keen
if(hitdetect(theObject))
if( theObject.m_type == OBJ_PLAYER )
{
if( theObject.m_type == OBJ_PLAYER )
{
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
Player.bump( *this, movedir );
}
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
Player.bump( *this, movedir );
}
}
......@@ -251,7 +251,8 @@ void CVorticon::initiateJump() {
}