Commit bba6fa4b authored by Gerhard Stein's avatar Gerhard Stein

Made some Action Format changes and added Treasure Eater.

parent 9058327f
......@@ -33,7 +33,8 @@ void CGalaxySpriteObject::setupGalaxyObjectOnMap(const size_t ActionBaseOffset,
performCollisions();
if((rSprite.m_bboxY2-rSprite.m_bboxY1) < 0)
processMove(0, (14<<STC)-(rSprite.m_bboxY2-rSprite.m_bboxY1));
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
/**
......@@ -208,8 +209,9 @@ void CGalaxySpriteObject::setActionSprite()
// This new function will setup the sprite based on the Action format
void CGalaxySpriteObject::processActionRoutine()
bool CGalaxySpriteObject::processActionRoutine()
{
bool endOfAction = true;
setActionSprite();
// Check the Movement Parameter
......@@ -245,7 +247,7 @@ void CGalaxySpriteObject::processActionRoutine()
if(m_Action.Next_action != 0)
m_Action.setNextActionFormat();
else
exists = false;
endOfAction = false;
}
m_ActionTicker = 0;
}
......@@ -253,4 +255,6 @@ void CGalaxySpriteObject::processActionRoutine()
{
m_ActionTicker += 2;
}
return endOfAction;
}
......@@ -29,7 +29,7 @@ public:
virtual void setActionForce(const size_t ActionNumber);
void setAction(size_t ActionNumber);
void setActionSprite();
void processActionRoutine();
bool processActionRoutine();
// This is used for action format only
uint16_t mFoeID;
......
......@@ -47,6 +47,7 @@
#include "engine/galaxy/ai/ep4/CBerkeloid.h"
#include "engine/galaxy/ai/ep4/CBlueBird.h"
#include "engine/galaxy/ai/ep4/CThunderCloud.h"
#include "engine/galaxy/ai/ep4/CTreasureEater.h"
// General stuff
......@@ -407,7 +408,7 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
case 1:
case 2:
// This is the player on the map in one level
p_newfoe = new galaxy::CPlayerLevel(&Map, foe, x, y-750, m_ObjectPtr,
p_newfoe = new galaxy::CPlayerLevel(&Map, foe, x, y, m_ObjectPtr,
(foe==1) ? RIGHT : LEFT, m_Inventory, m_Cheatmode);
break;
......@@ -458,11 +459,15 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
p_newfoe = new galaxy::CEgg(&Map, foe, x, y-(2<<CSF));
break;
case 18:
// This might be the treasure eater.
p_newfoe = new galaxy::CTreasureEater(&Map, foe, x, y);
break;
case 19:
//This is a Mimrock.
// TODO: Those relative coordinates are not a good sign. Try to remove them and make the Sprite substract them
p_newfoe = new galaxy::CMimrock(&Map, foe, x, y-(2<<CSF));
p_newfoe = new galaxy::CMimrock(&Map, foe, x, y);
break;
case 20:
......@@ -473,7 +478,7 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
case 21:
// This is a Mad Mushroom.
p_newfoe = new galaxy::CMadMushroom(&Map, foe, x, y-(2<<CSF));
p_newfoe = new galaxy::CMadMushroom(&Map, foe, x, y);
break;
......@@ -522,17 +527,23 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
RIGHT, m_Inventory, m_Cheatmode);
break;
case 47:
case 46:
// This is the Lick
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
break;
case 48: // I guess this happens in normal mode
case 47:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty > 1 )
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
break;
case 48:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty > 2 )
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
break;
case 50:
//This is the CBerkeloid
......
......@@ -39,7 +39,9 @@ void CBullet::process()
dead = true;
}
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
}
......@@ -57,7 +57,9 @@ void CEnemyShot::process()
exists = false;
}
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
} /* namespace galaxy */
......@@ -77,6 +77,12 @@ mPlacingGem(false)
m_hanging = false;
setupGalaxyObjectOnMap(0x98C, A_KEEN_STAND);
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
performCollisions();
processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
if(!processActionRoutine())
exists = false;
}
......@@ -1399,7 +1405,9 @@ void CPlayerLevel::process()
processLevelMiscFlagsCheck();
processActionRoutine();
if(!processActionRoutine())
exists = false;
if(!m_dying)
{
......
......@@ -23,7 +23,9 @@ CStunnable::CStunnable( CMap *pmap,
const Uint16 foeID,
Uint32 x,
Uint32 y ) :
CGalaxySpriteObject( pmap, foeID, x, y )
CGalaxySpriteObject( pmap, foeID, x, y ),
m_stunned(false),
mp_processState(NULL)
{
m_invincible = false;
}
......
......@@ -92,7 +92,8 @@ void CArachnut::process()
}
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
} /* namespace galaxy */
......@@ -125,7 +125,8 @@ void CBerkeloid::process()
else if(blockedr)
m_hDir = LEFT;
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
......@@ -209,7 +210,8 @@ void CBerkFlame::process()
(this->*mpProcessState)();
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
......
......@@ -175,7 +175,8 @@ void CBlueBird::process()
(this->*mpProcessState)();
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
} /* namespace galaxy */
......@@ -281,7 +281,8 @@ void CBounder::process()
}
}
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
......
......@@ -100,7 +100,8 @@ void CCouncilMember::process()
else if(blockedr)
m_hDir = LEFT;
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
......
......@@ -8,6 +8,7 @@
#include "CLick.h"
#include "engine/galaxy/ai/CPlayerBase.h"
#include "misc.h"
namespace galaxy {
......@@ -41,7 +42,8 @@ void CLick::process()
{
(this->*mp_processState)();
processActionRoutine();
if(!processActionRoutine())
exists = false;
processFalling();
}
......@@ -73,14 +75,18 @@ void CLick::getTouchedBy(CSpriteObject &theObject)
bool CLick::isNearby(CSpriteObject &theObject)
{
if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
{
const int dx = player->getXMidPos() - getXMidPos();
if( dx<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
m_hDir = LEFT;
else if( dx>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
m_hDir = RIGHT;
if( getProbability(80) )
{
if( dx<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
m_hDir = LEFT;
else if( dx>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
m_hDir = RIGHT;
}
if(getActionNumber(A_LICK_LAND))
{
......
......@@ -44,7 +44,8 @@ void CLindsey::process()
m_timer--;
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
void CLindsey::getTouchedBy(CSpriteObject &theObject)
......
......@@ -22,6 +22,11 @@ CGalaxySpriteObject(pmap, foeID, x, y),
jumpcounter(0)
{
setupGalaxyObjectOnMap(0x20E4, A_MUSHROOM_BOUNCE);
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
performCollisions();
processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
processActionRoutine();
}
......@@ -91,7 +96,8 @@ void CMadMushroom::process()
m_jumped = true;
}
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
} /* namespace galaxy */
......@@ -33,6 +33,11 @@ CStunnable(pmap, foeID, x, y)
setupGalaxyObjectOnMap(0x343A, A_MIMROCK_SIT);
m_hDir = NONE;
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
performCollisions();
processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
processActionRoutine();
}
......@@ -91,7 +96,8 @@ void CMimrock::process()
(this->*mp_processState)();
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
......
......@@ -151,7 +151,8 @@ void CPlayerDive::process()
processLevelMiscFlagsCheck();
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
}
......@@ -136,7 +136,8 @@ void CPoisonSlug::process()
else if(blockedr)
m_hDir = LEFT;
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
}
......@@ -113,9 +113,10 @@ void CSkypest::processFly()
void CSkypest::process()
{
processActionRoutine();
(this->*mp_processState)();
if(!processActionRoutine())
exists = false;
}
} /* namespace galaxy */
......@@ -33,7 +33,9 @@ void CSlugSlime::getTouchedBy(CSpriteObject &theObject)
void CSlugSlime::process()
{
processFalling();
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
};
......@@ -160,8 +160,10 @@ void CThunderCloud::process()
mTimer++;
if( getActionStatus(A_CLOUD_WAKING) || getActionStatus(A_CLOUD_STRIKING) )
/*if( getActionStatus(A_CLOUD_WAKING) || getActionStatus(A_CLOUD_STRIKING) )*/
{
processActionRoutine();
}
}
......@@ -193,7 +195,9 @@ void CThunderBolt::getTouchedBy(CSpriteObject &theObject)
void CThunderBolt::process()
{
performCollisions();
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
......
/*
* CTreasureEater.cpp
*
* Created on: 17.07.2012
* Author: gerstong
*/
#include "CTreasureEater.h"
#include "engine/galaxy/ai/CPlayerLevel.h"
#include "engine/galaxy/ai/CBullet.h"
#include "misc.h"
namespace galaxy {
const int A_SMIRKY_LOOK = 0;
const int A_SMIRKY_TELEPORT = 2;
const int A_SMIRKY_HOP = 10;
const int A_SMIRKY_STUNNED = 14;
CTreasureEater::CTreasureEater(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CStunnable(pmap, foeID, x, y)
{
mActionMap[A_SMIRKY_LOOK] = (void (CStunnable::*)()) &CTreasureEater::processLooking;
mActionMap[A_SMIRKY_TELEPORT] = (void (CStunnable::*)()) &CTreasureEater::processTeleporting;
mActionMap[A_SMIRKY_HOP] = (void (CStunnable::*)()) &CTreasureEater::processHopping;
mActionMap[A_SMIRKY_STUNNED] = &CStunnable::processGettingStunned;
setupGalaxyObjectOnMap( 0x31E2, A_SMIRKY_LOOK );
m_hDir = LEFT;
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
performCollisions();
processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
if(!processActionRoutine())
exists = false;
}
bool CTreasureEater::isNearby(CSpriteObject &theObject)
{
if( !getProbability(80) )
return false;
/*if( getActionNumber(A_SMIRKY_LOOK) )
{
}*/
// identify one item and try to get it!
/*if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
{
if( player->getXMidPos() < getXMidPos() )
m_hDir = LEFT;
else
m_hDir = RIGHT;
}*/
return true;
}
void CTreasureEater::getTouchedBy(CSpriteObject &theObject)
{
if(dead || theObject.dead )
return;
CStunnable::getTouchedBy(theObject);
// Was it a bullet? Than make it stunned.
if( dynamic_cast<CBullet*>(&theObject) )
{
setAction( A_SMIRKY_STUNNED );
dead = true;
theObject.dead = true;
}
// Here go the items
}
void CTreasureEater::processLooking()
{
if( getActionStatus(A_SMIRKY_HOP) )
{
setAction(A_SMIRKY_HOP);
}
if( getActionStatus(A_SMIRKY_TELEPORT) )
{
setAction(A_SMIRKY_TELEPORT);
}
}
void CTreasureEater::processTeleporting()
{
/*if( getActionStatus(A_SMIRKY_TELEPORT) )
setAction(A_SMIRKY_TELEPORT);*/
}
void CTreasureEater::processHopping()
{
if( getActionStatus(A_SMIRKY_LOOK) )
setAction(A_SMIRKY_LOOK);
}
void CTreasureEater::process()
{
performCollisions();
processFalling();
if( blockedl )
m_hDir = RIGHT;
else if( blockedr )
m_hDir = LEFT;
(this->*mp_processState)();
processActionRoutine();
}
} /* namespace galaxy */
/*
* CTreasureEater.h
*
* Created on: 17.07.2012
* Author: gerstong
*/
#ifndef CTREASUREEATER_H_
#define CTREASUREEATER_H_
#include "engine/galaxy/ai/CStunnable.h"
namespace galaxy {
class CTreasureEater: public CStunnable
{
public:
CTreasureEater(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y);
bool isNearby(CSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
void processLooking();
void processTeleporting();
void processHopping();
void process();
};
} /* namespace galaxy */
#endif /* CTREASUREEATER_H_ */
......@@ -106,7 +106,9 @@ void CWaterMine::process()
{
(this->*mp_processState)();
processActionRoutine();
if(!processActionRoutine())
exists = false;
}
} /* namespace galaxy */
......@@ -90,7 +90,8 @@ void CWormmouth::getTouchedBy(CSpriteObject &theObject)
setAction( A_WORMMOUTH_STUNNED );
dead = true;
theObject.dead = true;
processActionRoutine();
if(!processActionRoutine())
exists = false;
performCollisions();
processGettingStunned();
}
......
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