Commit 2dc2ee77 authored by Gerhard Stein's avatar Gerhard Stein

Flags and Signs now use action format also. This was missing for a long time

parent 2469531b
...@@ -10,8 +10,33 @@ ...@@ -10,8 +10,33 @@
#include "common/CBehaviorEngine.h" #include "common/CBehaviorEngine.h"
/*
$15EEW #Keen K flag waving 1
$160CW #Keen K flag waving 2
$162AW #Keen K flag waving 3
$1648W #Keen K flag waving 4
$1666W #Keen flag flips into holder 1
$1684W #Keen flag flips into holder 2
$16A2W #Keen flag flips into holder 3
$16C0W #Keen flag flips into holder 4
$16DEW #Keen flag flips into holder 5
$16FCW #Keen flag flips into holder 6
$171AW #Keen flag flips into holder 7
*/
namespace galaxy { namespace galaxy {
enum FLAGACTIONS
{
A_FLAG_WAVE = 0,
A_FLAG_FLIP = 4
};
const Uint16 FLYING_BASEFRAME_EP4 = 174; const Uint16 FLYING_BASEFRAME_EP4 = 174;
const Uint16 FLYING_BASEFRAME_EP5 = 173; const Uint16 FLYING_BASEFRAME_EP5 = 173;
...@@ -23,59 +48,71 @@ CFlag::CFlag(CMap *pmap, const VectorD2<Uint32> &Location, ...@@ -23,59 +48,71 @@ CFlag::CFlag(CMap *pmap, const VectorD2<Uint32> &Location,
CGalaxySpriteObject(pmap, FOE_ID, Location.x, Location.y), CGalaxySpriteObject(pmap, FOE_ID, Location.x, Location.y),
m_location(Location), m_location(Location),
m_destination(Destination), m_destination(Destination),
m_baseframe(FLYING_BASEFRAME_EP4), m_baseframe(0)
processState(&CFlag::processFlying)
{ {
solid = false; solid = false;
honorPriority = false; honorPriority = false;
sprite = WAVING_BASEFRAME;
alignToTile(); mActionMap[A_FLAG_WAVE] = &CFlag::processWaving;
mActionMap[A_FLAG_FLIP] = &CFlag::processFlipping;
if(g_pBehaviorEngine->getEpisode() == 5) const auto episode = g_pBehaviorEngine->getEpisode();
if(episode == 6)
{
setupGalaxyObjectOnMap(0x13F4, A_FLAG_FLIP);
}
else if(episode == 5)
{ {
// In Episode 5 the sign is not thrown! It just appears in the holder // In Episode 5 the sign is not thrown! It just appears in the holder. Move it there!
//m_location = m_destination;
moveTo(m_destination); moveTo(m_destination);
processState = &CFlag::processRotation; setupGalaxyObjectOnMap(0x148A, A_FLAG_WAVE);
m_baseframe = FLYING_BASEFRAME_EP5; }
sprite = m_baseframe; else
{
setupGalaxyObjectOnMap(0x15EE, A_FLAG_FLIP);
} }
alignToTile();
} }
void CFlag::getTouchedBy(CSpriteObject &theObject) void CFlag::getTouchedBy(CSpriteObject &theObject)
{ {
if(m_baseframe != WAVING_BASEFRAME) if( getActionNumber(A_FLAG_FLIP) )
return; return;
// In case another flag is sitting in the pole, make that one non existent
if( CFlag *flag = dynamic_cast<CFlag*>(&theObject) ) if( CFlag *flag = dynamic_cast<CFlag*>(&theObject) )
{ {
flag->exists = false; flag->exists = false;
} }
} }
void CFlag::setActionForce(const size_t ActionNumber)
{
CGalaxySpriteObject::setActionForce(ActionNumber);
if( mActionMap.find(ActionNumber) != mActionMap.end() )
processState = mActionMap[ActionNumber];
else
CGalaxySpriteObject::setActionForce(0); // This might happen, when the action-map is incomplete
}
/** /**
* Main process cycle * Main process cycle
*/ */
void CFlag::process() void CFlag::process()
{ {
processActionRoutine();
(this->*processState)(); (this->*processState)();
} }
/** /**
* Called when Flag is flying to the pole * Called when Flag is flying to the pole
*/ */
void CFlag::processFlying() void CFlag::processFlipping()
{ {
if(mp_Map->getAnimtiletimer()%ANIMATION_TIME == 0)
{
if(sprite-m_baseframe >= 4)
sprite = m_baseframe;
else
sprite++;
}
if(m_destination != m_location) if(m_destination != m_location)
{ {
VectorD2<int> dir = m_destination - m_location; VectorD2<int> dir = m_destination - m_location;
...@@ -94,8 +131,7 @@ void CFlag::processFlying() ...@@ -94,8 +131,7 @@ void CFlag::processFlying()
} }
else else
{ {
processState = &CFlag::processWaving; setAction(A_FLAG_WAVE);
m_baseframe = WAVING_BASEFRAME;
g_pSound->playSound( SOUND_FLAG_LAND ); g_pSound->playSound( SOUND_FLAG_LAND );
} }
} }
...@@ -104,15 +140,7 @@ void CFlag::processFlying() ...@@ -104,15 +140,7 @@ void CFlag::processFlying()
* Called when flag is in the pole. Keen 4 or 6 * Called when flag is in the pole. Keen 4 or 6
*/ */
void CFlag::processWaving() void CFlag::processWaving()
{ {}
if(mp_Map->getAnimtiletimer()%ANIMATION_TIME == 0)
{
if(sprite-m_baseframe >= 3)
sprite = m_baseframe;
else
sprite++;
}
}
/* /*
* Called when sign is in the holder. Keen 5 normally * Called when sign is in the holder. Keen 5 normally
......
...@@ -31,16 +31,19 @@ public: ...@@ -31,16 +31,19 @@ public:
// The flag is flying when player throws it. // The flag is flying when player throws it.
// It's waving all the time being stuck on the pole. // It's waving all the time being stuck on the pole.
void process(); void process();
void processFlying(); void processFlipping();
void processWaving(); void processWaving();
void processRotation(); void processRotation();
void setActionForce(const size_t ActionNumber);
private: private:
// Where the flag/sign will pop in // Where the flag/sign will pop in
VectorD2<Uint32> m_location; VectorD2<Uint32> m_location;
VectorD2<Uint32> m_destination; VectorD2<Uint32> m_destination;
Uint16 m_baseframe; Uint16 m_baseframe;
void (CFlag::*processState)(); void (CFlag::*processState)();
std::map< size_t, void (CFlag::*)() > mActionMap;
}; };
......
...@@ -818,6 +818,7 @@ void CPlayerWM::finishLevel(Uint16 object) ...@@ -818,6 +818,7 @@ void CPlayerWM::finishLevel(Uint16 object)
if(mp_Map->findTile(flag_dest, &x, &y, 2)) if(mp_Map->findTile(flag_dest, &x, &y, 2))
{ {
// spawn the flag // spawn the flag
const auto episode = g_pBehaviorEngine->getEpisode();
VectorD2<Uint32> src(getXPosition(), getYPosition()); VectorD2<Uint32> src(getXPosition(), getYPosition());
// Here we move the coordinates in order get it positioned correctly in the pole // Here we move the coordinates in order get it positioned correctly in the pole
...@@ -827,12 +828,16 @@ void CPlayerWM::finishLevel(Uint16 object) ...@@ -827,12 +828,16 @@ void CPlayerWM::finishLevel(Uint16 object)
unsigned int csfY = (y<<CSF); unsigned int csfY = (y<<CSF);
csfX += (6<<STC); csfX += (6<<STC);
if(episode != 5)
csfY -= FlagSprite.m_bboxY2; csfY -= FlagSprite.m_bboxY2;
csfY += (2<<STC); csfY += (2<<STC);
if(g_pBehaviorEngine->getEpisode() == 5) if(g_pBehaviorEngine->getEpisode() == 5)
{ {
csfX -= (14<<STC); csfX -= (14<<STC);
if(episode != 5)
csfY -= (1<<CSF); csfY -= (1<<CSF);
} }
else else
......
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