Commit f49d58ab authored by Gerhard Stein's avatar Gerhard Stein

Action Format improvements and Treasure Eater really eat treasures now, although he is unfinished

parent bba6fa4b
......@@ -14,7 +14,8 @@ m_ActionTicker(0),
m_ActionNumber(0),
m_ActionBaseOffset(0x0),
m_climbing(false),
m_jumpdown(false)
m_jumpdown(false),
mEndOfAction(false)
{}
void CGalaxySpriteObject::setupGalaxyObjectOnMap(const size_t ActionBaseOffset,
......@@ -188,6 +189,7 @@ int16_t CGalaxySpriteObject::getActionNumber()
void CGalaxySpriteObject::setActionForce(const size_t ActionNumber)
{
mEndOfAction = false;
m_ActionNumber = ActionNumber;
m_Action.setActionFormat(m_ActionBaseOffset + 30*m_ActionNumber);
}
......@@ -211,7 +213,7 @@ void CGalaxySpriteObject::setActionSprite()
// This new function will setup the sprite based on the Action format
bool CGalaxySpriteObject::processActionRoutine()
{
bool endOfAction = true;
mEndOfAction = false;
setActionSprite();
// Check the Movement Parameter
......@@ -240,6 +242,9 @@ bool CGalaxySpriteObject::processActionRoutine()
moveDown( m_Action.V_anim_move_amount<<1 );
}
if(mEndOfAction)
return false;
if( m_ActionTicker > m_Action.Delay )
{
if( m_Action.Delay != 0 )
......@@ -247,7 +252,7 @@ bool CGalaxySpriteObject::processActionRoutine()
if(m_Action.Next_action != 0)
m_Action.setNextActionFormat();
else
endOfAction = false;
mEndOfAction = true;
}
m_ActionTicker = 0;
}
......@@ -256,5 +261,5 @@ bool CGalaxySpriteObject::processActionRoutine()
m_ActionTicker += 2;
}
return endOfAction;
return !mEndOfAction;
}
......@@ -39,6 +39,7 @@ public:
bool m_jumped;
bool m_climbing;
bool m_jumpdown;
bool mEndOfAction;
};
#endif /* CGALAXYSPRITEOBJECT_H_ */
......@@ -18,9 +18,15 @@ const int A_SMIRKY_TELEPORT = 2;
const int A_SMIRKY_HOP = 10;
const int A_SMIRKY_STUNNED = 14;
const int HOP_INERTIA = 120;
const int SMIRLY_HOP_TIMER = 10;
CTreasureEater::CTreasureEater(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CStunnable(pmap, foeID, x, y)
CStunnable(pmap, foeID, x, y),
mTimer(0),
mTeleported(false),
mStolen(false)
{
mActionMap[A_SMIRKY_LOOK] = (void (CStunnable::*)()) &CTreasureEater::processLooking;
mActionMap[A_SMIRKY_TELEPORT] = (void (CStunnable::*)()) &CTreasureEater::processTeleporting;
......@@ -74,46 +80,108 @@ void CTreasureEater::getTouchedBy(CSpriteObject &theObject)
if( dynamic_cast<CBullet*>(&theObject) )
{
setAction( A_SMIRKY_STUNNED );
setActionSprite();
dead = true;
theObject.dead = true;
}
// Here go the items
}
void CTreasureEater::processLooking()
{
if( getActionStatus(A_SMIRKY_HOP) )
if( mTimer < SMIRLY_HOP_TIMER )
{
setAction(A_SMIRKY_HOP);
mTimer++;
return;
}
if( getActionStatus(A_SMIRKY_TELEPORT) )
else
{
setAction(A_SMIRKY_TELEPORT);
mTimer = 0;
}
if(mEndOfAction)
{
if( getProbability(800) )
{
setAction(A_SMIRKY_HOP);
yinertia = -HOP_INERTIA;
inhibitfall = false;
}
else
{
setActionForce(A_SMIRKY_LOOK);
inhibitfall = true;
}
}
}
void CTreasureEater::processTeleporting()
{
/*if( getActionStatus(A_SMIRKY_TELEPORT) )
setAction(A_SMIRKY_TELEPORT);*/
if( getActionStatus(A_SMIRKY_HOP) )
{
setAction(A_SMIRKY_HOP);
mStolen = false;
}
}
void CTreasureEater::processHopping()
{
if( getActionStatus(A_SMIRKY_LOOK) )
setAction(A_SMIRKY_LOOK);
if(yinertia >= 0)
{
if(blockedd || onslope)
{
if(mStolen)
{
setAction( A_SMIRKY_TELEPORT );
mTeleported = true;
}
else
{
setAction( A_SMIRKY_LOOK );
}
inhibitfall = true;
return;
}
}
}
void CTreasureEater::checkForItem()
{
int l_x = getXLeftPos();
int l_y = getYUpPos();
int l_w = getXRightPos() - getXLeftPos();
int l_h = getYDownPos() - getYUpPos();
// So far we have tile item support only!
// TODO: Need Sprite Item support and also this one should should be able to steal gems
for( Uint32 i=21 ; i<=27 ; i++ )
{
if(hitdetectWithTilePropertyRect(i, l_x, l_y, l_w, l_h, 1<<STC))
{
const int lc_x = l_x>>CSF;
const int lc_y = l_y>>CSF;
mp_Map->setTile( lc_x, lc_y, 0, true, 1 );
mStolen = true;
}
}
}
void CTreasureEater::process()
{
performCollisions();
processFalling();
checkForItem();
if( blockedl )
m_hDir = RIGHT;
else if( blockedr )
......@@ -121,7 +189,14 @@ void CTreasureEater::process()
(this->*mp_processState)();
processActionRoutine();
if( !getActionNumber(A_SMIRKY_STUNNED) )
{
processActionRoutine();
}
else // TODO: This a workaround, because the last known action doesn't seem to be triggered
{
sprite = 231;
}
}
......
......@@ -24,7 +24,14 @@ public:
void processTeleporting();
void processHopping();
void checkForItem();
void process();
private:
int mTimer;
bool mTeleported;
bool mStolen;
};
} /* namespace galaxy */
......
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