Commit 158a29c4 authored by gerstrong@gmail.com's avatar gerstrong@gmail.com

Korath patches for MoM Galaxy

parent 8361f67d
......@@ -166,6 +166,8 @@ bool CSpriteObject::loadPythonScripts(const std::string &scriptBaseName)
loadAiGetterBool(pModule, "isStunnableWithPogo", mPogoStunnable);
loadAiGetterBool(pModule, "isStunnableWithJump", mJumpStunnable);
loadAiGetterBool(pModule, "mayShoot", mMayShoot);
int health = mHealthPoints;
......
......@@ -408,6 +408,7 @@ class CSpriteObject
bool mRecoverFromStun = false; /** If foe get shot they might be able to recover at later time */
bool mNeverStop = false; /** This will make foe continue walking and never change actions (Keen 9 - Cybloog) */
bool mPogoStunnable = false; /** This will make foe continue walking and never change actions (Keen 9 - Cybloog) */
bool mJumpStunnable = false;
bool mMayShoot = false; /** If enemy if allowed to shoot. Not all of them are able to do that.*/
GameSound mWalkSound;
......
......@@ -61,7 +61,7 @@ void CStunnable::processGettingStunned()
{
yinertia = -30; // It gets a small impulse
mp_processState = (GASOFctr) &CStunnable::processStunned;
mp_processState = static_cast<GASOFctr>(&CStunnable::processStunned);
blockedd = false;
moveUp(8<<STC);
......@@ -81,60 +81,60 @@ void CStunnable::draw()
CGalaxySpriteObject::draw();
if(mIsDead && blockedd && yinertia == 0)
{
if(starTimer > 0)
{
starTimer--;
}
else
{
const unsigned char anim = m_animation_timer % STARRING_ANIMATION_TIME;
if(anim == 0)
{
if(starTimer > 0)
{
starSprite++;
if(starSprite > starSpriteBase+2)
{
starSprite = starSpriteBase;
m_animation_timer = 0;
}
starTimer--;
}
// Animation timer increasing all the time
m_animation_timer++;
GsSprite &StarSprite = gGraphics.getSprite(mSprVar, starSprite);
int yoffset = (StarSprite.getHeight()<<STC);
int xoffset = (StarSprite.getWidth()<<STC);
scrx = ((getXMidPos()-xoffset/2)>>STC)-mpMap->m_scrollx;
scry = ((m_Pos.y-(m_BBox.Height()/2)-yoffset)>>STC)-mpMap->m_scrolly;
SDL_Rect gameres = gVideoDriver.getGameResolution().SDLRect();
if( scrx < gameres.w && scry < gameres.h && exists )
else
{
int showX = scrx+StarSprite.getXOffset();
int showY = scry+StarSprite.getYOffset();
int w = StarSprite.getWidth();
int h = StarSprite.getHeight();
const unsigned char anim = m_animation_timer % STARRING_ANIMATION_TIME;
if(anim == 0)
{
starSprite++;
if(starSprite > starSpriteBase+2)
{
starSprite = starSpriteBase;
m_animation_timer = 0;
}
}
// Animation timer increasing all the time
m_animation_timer++;
GsSprite &StarSprite = gGraphics.getSprite(mSprVar, starSprite);
const auto visGA = gVideoDriver.mpVideoEngine->mRelativeVisGameArea;
int yoffset = (StarSprite.getHeight()<<STC);
int xoffset = (StarSprite.getWidth()<<STC);
if( showX+StarSprite.getWidth() < visGA.x || showX > visGA.x+visGA.w )
return;
scrx = ((getXMidPos()-xoffset/2)>>STC)-mpMap->m_scrollx;
scry = ((m_Pos.y-(m_BBox.Height()/2)-yoffset)>>STC)-mpMap->m_scrolly;
if( showY+StarSprite.getHeight() < visGA.y || showY > visGA.y+visGA.h )
return;
SDL_Rect gameres = gVideoDriver.getGameResolution().SDLRect();
StarSprite.drawSprite( showX, showY, w, h, (255-transluceny) );
if( scrx < gameres.w && scry < gameres.h && exists )
{
int showX = scrx+StarSprite.getXOffset();
int showY = scry+StarSprite.getYOffset();
int w = StarSprite.getWidth();
int h = StarSprite.getHeight();
const auto visGA = gVideoDriver.mpVideoEngine->mRelativeVisGameArea;
if( showX+StarSprite.getWidth() < visGA.x || showX > visGA.x+visGA.w )
return;
if( showY+StarSprite.getHeight() < visGA.y || showY > visGA.y+visGA.h )
return;
StarSprite.drawSprite( showX, showY, w, h, (255-transluceny) );
}
}
}
}
}
}
......
......@@ -38,7 +38,7 @@ public:
/**
* empty cycle which is processed when the object is stunned
*/
void processStunned();
virtual void processStunned();
/**
* This draw routine might show stars in case the enemies are stunned
......
......@@ -30,7 +30,7 @@ private:
void processHop();
void processLand();
void processBreathe();
void processStunned();
//void processStunned();
int m_timer = 0;
bool keenNear = false;
......
......@@ -31,10 +31,10 @@ A_KORATH_STUNNED = 5
constexpr int TIME_TO_SIT = 50;
constexpr int WALK_SPEED = 25;
constexpr int STUN_TIME = 240;
CKorath::CKorath(CMap *pmap, const Uint16 foeID, const Uint32 x, const Uint32 y) :
CStunnable(pmap, foeID, x, y),
mTimer(0)
CStunnable(pmap, foeID, x, y)
{
mActionMap[A_KORATH_WALK] = (GASOFctr) &CKorath::processWalking;
mActionMap[A_KORATH_SIT] = (GASOFctr) &CKorath::processSitting;
......@@ -88,6 +88,21 @@ void CKorath::processSitting()
}
}
void CKorath::processStunned()
{
if(mIsDead)
return;
mTimer++;
if( mTimer < STUN_TIME )
return;
mTimer = 0;
setAction(A_KORATH_SIT);
}
void CKorath::getTouchedBy(CSpriteObject &theObject)
......@@ -107,15 +122,29 @@ void CKorath::getTouchedBy(CSpriteObject &theObject)
if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
{
const bool jumpActive =
player->getActionStatus(A_KEEN_JUMP) ||
player->getActionStatus(A_KEEN_JUMP_DOWN);
const bool pogoActive =
player->getActionStatus(A_KEEN_POGO_START) ||
player->getActionStatus(A_KEEN_POGO_HIGH) ||
player->getActionStatus(A_KEEN_POGO_UP);
// Usually this is only possible with Keen 9 and my own speciality
// Usually this is only possible with Keen 9 and some special code
if(mPogoStunnable && pogoActive)
{
mIsDead = true;
if(!mRecoverFromStun)
mIsDead = true;
setAction(A_KORATH_STUNNED);
gSound.playSound(SOUND_FUSE_BREAK);
}
else if(mJumpStunnable && jumpActive)
{
if(!mRecoverFromStun)
mIsDead = true;
setAction(A_KORATH_STUNNED);
gSound.playSound(SOUND_FUSE_BREAK);
}
......@@ -141,15 +170,14 @@ void CKorath::process()
performGravityMid();
if(!mIsDead) // If we is dead, there is no way to continue moving or turning
if(!mIsDead) // If dead, there is no way to continue moving or turning
{
if( blockedl )
{
xDirection = RIGHT;
}
else if(blockedr)
{
{
xDirection = LEFT;
}
}
......
......@@ -25,7 +25,8 @@ public:
* Action functions
*/
void processWalking();
void processSitting();
void processSitting();
void processStunned() override;
int checkSolidD( int x1, int x2, int y2, const bool push_mode );
......@@ -38,7 +39,7 @@ public:
void getTouchedBy(CSpriteObject &theObject);
private:
int mTimer;
int mTimer = 0;
};
}
......
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