diff --git a/source/player/player.cpp b/source/player/player.cpp index ce76ba648..c0eb614fb 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -184,32 +184,33 @@ void CPlayer::init() TPLoadTex(ACTORS_SPONGEBOB_TEX); m_skel.setAnimDatabase(CAnimDB::GetPlayerAnimBank()); + +#ifdef __USER_paul__ + m_respawnPos.vx=23*16; + m_respawnPos.vy=10*16; +#else + m_respawnPos.vx=10; + m_respawnPos.vy=10; +#endif + + m_animNo=0; m_animFrame=0; m_currentMode=PLAYER_MODE_BASICUNARMED; - setState(STATE_IDLE); m_moveVel.vx=0; m_moveVel.vy=0; setFacing(FACING_RIGHT); + respawn(); m_lives=CGameSlotManager::getSlotData().m_lives; - m_invincibleFrameCount=INVIBCIBLE_FRAMES__START; -#ifdef __USER_paul__ - Pos.vx=23*16; - Pos.vy=10*16; -#else - Pos.vx=10; - Pos.vy=10; -#endif m_cameraOffset.vx=0; m_cameraOffset.vy=0; m_lastPadInput=m_padInput=PI_NONE; - s_health=5; s_screenPos=128; m_skel.setAng(512); @@ -932,6 +933,29 @@ void CPlayer::fall() } + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayer::respawn() +{ + setState(STATE_IDLE); + + // Strip any items that the player might be holding + if(m_currentMode!=PLAYER_MODE_BASICUNARMED) + { + setMode(PLAYER_MODE_FULLUNARMED); + } + + s_health=5; + m_invincibleFrameCount=INVIBCIBLE_FRAMES__START; + Pos=m_respawnPos; +} + + /*---------------------------------------------------------------------- Function: Purpose: @@ -939,7 +963,7 @@ void CPlayer::fall() Returns: ---------------------------------------------------------------------- */ #ifdef __VERSION_DEBUG__ -int invincibleSponge=false; // NB: This is for debugging purposes only +int invincibleSponge=false; // NB: This is for debugging purposes only so don't try and use it for a permenant cheat mode.. #endif void CPlayer::takeDamage(DAMAGE_TYPE _damage) { diff --git a/source/player/player.h b/source/player/player.h index d9470bdda..598d9c8a5 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -195,6 +195,8 @@ protected: void jump(); void fall(); + void respawn(); + void takeDamage(DAMAGE_TYPE _damage); friend class CPlayerState; @@ -263,6 +265,7 @@ private: // Various info about the current map class CLayerCollision *m_layerCollision; DVECTOR m_mapCameraEdges; + DVECTOR m_respawnPos; }; diff --git a/source/player/psdead.cpp b/source/player/psdead.cpp index 097099ce4..1450348ba 100644 --- a/source/player/psdead.cpp +++ b/source/player/psdead.cpp @@ -22,6 +22,10 @@ #include "player\player.h" #endif +#ifndef __SYSTEM_GSTATE_H__ +#include "system\gstate.h" +#endif + /* Std Lib ------- */ @@ -59,6 +63,8 @@ void CPlayerStateDead::enter(CPlayer *_player) { setAnimNo(_player,ANIM_PLAYER_ANIM_DEATHSPIN); + + m_deadCounter=0; } @@ -70,11 +76,22 @@ void CPlayerStateDead::enter(CPlayer *_player) ---------------------------------------------------------------------- */ void CPlayerStateDead::think(CPlayer *_player) { - if(advanceAnimFrameAndCheckForEndOfAnim(_player)) + if(!m_deadCounter) { - setState(_player,STATE_IDLE); + if(advanceAnimFrameAndCheckForEndOfAnim(_player)) + { + retreatAnimFrameAndCheckForEndOfAnim(_player); + m_deadCounter=1; + } + } + else + { + if(++m_deadCounter>10*GameState::getOneSecondInFrames()|| + getPadInputDown(_player)&PI_ACTION) + { + respawn(_player); + } } - } diff --git a/source/player/psdead.h b/source/player/psdead.h index f4f168f52..1280f74a6 100644 --- a/source/player/psdead.h +++ b/source/player/psdead.h @@ -38,6 +38,9 @@ public: virtual void enter(class CPlayer *_player); virtual void think(class CPlayer *_player); + +private: + int m_deadCounter; }; diff --git a/source/player/pstates.cpp b/source/player/pstates.cpp index 11564341c..c35b0db1a 100644 --- a/source/player/pstates.cpp +++ b/source/player/pstates.cpp @@ -310,5 +310,17 @@ void CPlayerState::fall(CPlayer *_player) } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayerState::respawn(CPlayer *_player) +{ + _player->respawn(); +} + + /*=========================================================================== end */ diff --git a/source/player/pstates.h b/source/player/pstates.h index bd344a06a..f0a13ff2c 100644 --- a/source/player/pstates.h +++ b/source/player/pstates.h @@ -68,6 +68,8 @@ protected: void jump(class CPlayer *_player); void fall(class CPlayer *_player); + void respawn(class CPlayer *_player); + };