Commit 52a4e84d authored by Gerhard Stein's avatar Gerhard Stein

small AI changes

parent 4b3762c9
......@@ -197,7 +197,6 @@ void CHUD::render()
headdstrect.y = 19;
CSprite &KeenGunSprite = g_pGfxEngine->getSprite(108);
SDL_BlitSurface( KeenGunSprite.getSDLSurface(), &headsrcrect, blitsurface, &headdstrect);
SDL_BlitSurface( KeenGunSprite.getSDLSurface(), &headsrcrect, blitsurface, &headdstrect);
CFont &Font = g_pGfxEngine->getFont(0);
Font.setFGColour(blitsurface->format, 0x000000);
......
......@@ -204,7 +204,7 @@ bool CObject::checkforScenario()
onscreen = true;
if (hasbeenonscreen ||
m_type==OBJ_RAY ||
m_type==OBJ_RAY || m_type==OBJ_ROPE ||
m_type==OBJ_ICECHUNK || m_type==OBJ_PLATFORM ||
m_type==OBJ_PLATVERT || m_type==OBJ_YORP ||
m_type==OBJ_FOOB || m_type==OBJ_SCRUB)
......
......@@ -107,7 +107,7 @@ public:
virtual void process() { }
bool hitdetect(CObject &hitobject);
void kill();
virtual void kill();
void blink(Uint16 frametime);
// Collision parts
......
......@@ -876,6 +876,7 @@ bool CPlayer::drawStatusScreen()
else return true;
}
///
// Cleanup Part
///
......
......@@ -58,7 +58,8 @@ public:
void processInLevel(const bool &platextending);
void touchedExit(int mpx);
void walkbehindexitdoor();
void kill(bool force=false);
void kill(bool force);
void kill();
void dieanim();
void setDir();
void getgoodies();
......
......@@ -127,6 +127,11 @@ void CPlayer::walkbehindexitdoor()
}
}
void CPlayer::kill()
{
kill(false);
}
void CPlayer::kill(bool force)
{
if(!force) // force can happens for example, when player leaves the map to the most lower-side
......@@ -963,4 +968,3 @@ void CPlayer::getShotByRay()
if(!godmode)
CObject::getShotByRay();
}
......@@ -34,6 +34,7 @@ void CObjectAI::process()
for( size_t i=0 ; i < m_Objvect.size() ; i++ )
{
CObject &object = *m_Objvect.at(i);
if( object.checkforScenario() )
{
object.processFalling();
......@@ -51,7 +52,6 @@ void CObjectAI::process()
object.touchPlayer = true;
object.touchedBy = it_player->m_index;
break;
}
}
......
......@@ -19,14 +19,42 @@ CObject(p_map, x, y, OBJ_ROPE)
inhibitfall = 1;
sprite = OBJ_ROPE_DEFSPRITE;
needinit = false;
droptimer = 0;
}
void CRope::process()
{
switch(state)
{
case ROPE_IDLE:
if (HealthPoints >= 0)
case ROPE_DROPSTONE:
if (!droptimer)
{
droptimer = STONE_DROP_RATE;
rope_movestone();
g_pGfxEngine->pushEffectPtr(new CVibrate(400));
//theObject.blockedd = false;
// check if we've hit the ground yet
for(int x=2;x<STONE_WIDTH-2;x++)
{
if (g_pBehaviorEngine->getTileProperties().at(mp_Map->at(stoneX+x, stoneY+2)).bup)
{
exists=false;
return;
}
}
}
else droptimer--;
default: break;
}
}
void CRope::getShotByRay()
{
if(state == ROPE_IDLE)
{
if ( exists && canbezapped )
{
int x, y;
// rope got broke! time to drop the stone
......@@ -42,33 +70,31 @@ void CRope::process()
// get color of background
bgtile = mp_Map->at(x, y);
}
break;
default: break;
}
}
void CRope::rope_movestone(CObject &theObject)
void CRope::rope_movestone()
{
int xa,ya;
int x,y;
xa = stoneX;
ya = stoneY;
// move the stone down one space and kill anything in it's path!
for(y=STONE_HEIGHT;y>0;y--)
for(int y=STONE_HEIGHT;y>0;y--)
{
for(x=0;x<STONE_WIDTH;x++)
for(int x=0;x<STONE_WIDTH;x++)
{
mp_Map->setTile(x+xa,y+ya, mp_Map->at(x+xa, y+ya-1), true);
// if the stone hits any enemies, kill them
kill_intersecting_tile(x+xa, y+ya, theObject);
//kill_intersecting_tile(x+xa, y+ya, theObject);
}
}
// clear the space at the top
for(x=0;x<STONE_WIDTH;x++)
for(int x=0;x<STONE_WIDTH;x++)
mp_Map->setTile(x+xa,ya,bgtile, true);
stoneY++;
......@@ -76,26 +102,21 @@ void CRope::rope_movestone(CObject &theObject)
void CRope::getTouchedBy(CObject &theObject)
{
if(state == ROPE_DROPSTONE)
if(state == ROPE_DROPSTONE && m_type==OBJ_ROPE)
{
if (!droptimer)
{
droptimer = STONE_DROP_RATE;
rope_movestone(theObject);
g_pGfxEngine->pushEffectPtr(new CVibrate(400));
int xa,ya;
theObject.blockedd = false;
xa = stoneX;
ya = stoneY;
// check if we've hit the ground yet
for(x=2;x<STONE_WIDTH-2;x++)
// move the stone down one space and kill anything in it's path!
for(int y=STONE_HEIGHT;y>0;y--)
{
if (g_pBehaviorEngine->getTileProperties().at(mp_Map->at(stoneX+x, stoneY+2)).bup)
for(int x=0;x<STONE_WIDTH;x++)
{
exists=false;
return;
// if the stone hits any enemies, kill them
kill_intersecting_tile(x+xa, y+ya, theObject);
}
}
}
else droptimer--;
}
}
......@@ -19,7 +19,8 @@ class CRope : public CObject
public:
CRope(CMap *p_map, Uint32 x, Uint32 y);
void process();
void rope_movestone(CObject &theObject);
void getShotByRay();
void rope_movestone();
void getTouchedBy(CObject &theObject);
private:
......
......@@ -20,6 +20,7 @@ m_Player(m_vec_Player)
timer = 0;
dist_traveled = VORT_TRAPPED_DIST+1;
HealthPoints = hp;
canbezapped = true;
short Episode = g_pBehaviorEngine->getEpisode();
// copy in animation frame indexes for the current ep
......@@ -291,3 +292,14 @@ void CVorticon::initiateJump()
inhibitfall = true;
state = VORT_JUMP;
}
void CVorticon::getTouchedBy(CObject &theObject)
{
if(theObject.m_type == OBJ_PLAYER)
{
if( state != VORT_DYING and
state != VORT_DEAD and
state != VORT2_DYING )
theObject.kill();
}
}
......@@ -64,6 +64,7 @@ public:
Uint32 x, Uint32 y, char hp=1, object_t objtype=OBJ_VORT);
void process();
void initiateJump();
void getTouchedBy(CObject &theObject);
protected:
int m_Level;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment