diff --git a/source/pickups/pjlammo.cpp b/source/pickups/pjlammo.cpp index 811964930..7bf6dab72 100644 --- a/source/pickups/pjlammo.cpp +++ b/source/pickups/pjlammo.cpp @@ -25,6 +25,10 @@ #include "utils\mathtab.h" #endif +#ifndef __PLAYER_PLAYER_H__ +#include "player\player.h" +#endif + /* Std Lib ------- */ @@ -90,6 +94,7 @@ DVECTOR CJellyLauncherAmmoPickup::getSizeForPlacement() ---------------------------------------------------------------------- */ void CJellyLauncherAmmoPickup::collect(class CPlayer *_player) { + _player->giveJellyAmmo(); CBasePickup::collect(_player); } diff --git a/source/player/player.cpp b/source/player/player.cpp index 6539f8c8f..f97b7c04c 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -246,7 +246,7 @@ void CPlayer::init() s_playerModes[i]->initialise(this); } m_currentPlayerModeClass=NULL; - setMode(PLAYER_MODE_BASICUNARMED); //PKG + setMode(PLAYER_MODE_FULLUNARMED); //PKG m_animNo=0; m_animFrame=0; @@ -693,6 +693,7 @@ void CPlayer::respawn() m_squeakyBootsTimer=0; m_invinvibilityRingTimer=0; m_bubbleAmmo=0; + m_jellyAmmo=0; clearPlatform(); } diff --git a/source/player/player.h b/source/player/player.h index 1b49846c1..5463d08c8 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -253,12 +253,18 @@ public: void giveBubbleAmmo() {m_bubbleAmmo+=10;if(m_bubbleAmmo>99)m_bubbleAmmo=99;} void useOneBubble() {m_bubbleAmmo--;} int getBubbleAmmo() {return m_bubbleAmmo;} + + void giveJellyAmmo() {m_jellyAmmo+=6;if(m_jellyAmmo>99)m_jellyAmmo=99;} + void useOneJelly() {m_jellyAmmo--;} + int getJellyAmmo() {return m_jellyAmmo;} + private: int m_glassesFlag; int m_squeakyBootsTimer; int m_invinvibilityRingTimer; int m_divingHelmet; int m_bubbleAmmo; + int m_jellyAmmo; // Platforms public: diff --git a/source/player/pmjelly.cpp b/source/player/pmjelly.cpp index 6cd2d3b77..cc2e417a8 100644 --- a/source/player/pmjelly.cpp +++ b/source/player/pmjelly.cpp @@ -21,6 +21,18 @@ #include "gfx\sprbank.h" #endif +#ifndef __UTILS_HEADER__ +#include "utils\utils.h" +#endif + +#ifndef __PROJECTL_PROJECTL_H__ +#include "projectl\projectl.h" +#endif + +#ifndef __GFX_FONT_H__ +#include "gfx\font.h" +#endif + /* Std Lib ------- */ @@ -61,8 +73,8 @@ ---------------------------------------------------------------------- */ void CPlayerModeJellyLauncher::enter() { - m_netting=false; - m_netState=NET_STATE__EMPTY; + m_firingState=FIRING_STATE__NONE; + m_player->giveJellyAmmo(); } /*---------------------------------------------------------------------- @@ -71,50 +83,88 @@ void CPlayerModeJellyLauncher::enter() Params: Returns: ---------------------------------------------------------------------- */ -//int netstate; +DVECTOR jellyLaunchPos={20,-40}; void CPlayerModeJellyLauncher::think() { - // If we're netting then restore the 'real' anim number/frame before - // doing the think so that the rest of the code doesn't know what - // is going on ;) - if(m_netting) - { - setAnimNo(m_savedAnimNo); - setAnimFrame(m_savedAnimFrame); - } CPlayerModeBase::think(); - // Start to net? - if(!m_netting&&getPadInputDown()&PI_ACTION&&canSwingNetFromThisState()) + // Start to fire? + switch(m_firingState) { - m_netFrame=0; - m_netting=true; - switch(m_netState) - { - case NET_STATE__EMPTY: - m_netState=NET_STATE__FULL; - break; - case NET_STATE__FULL: - m_netState=NET_STATE__EMPTY; - break; - } - } + case FIRING_STATE__NONE: + if(getPadInputDown()&PI_ACTION&&m_player->getJellyAmmo()&&canFireFromThisState()) + { + m_firingFrame=0; + m_firingTime=0; + m_firingState=FIRING_STATE__POWERINGUP; + } + break; + case FIRING_STATE__POWERINGUP: + if(getPadInputHeld()&PI_ACTION) + { + if(m_firingTimesetAnimNo(ANIM_SPONGEBOB_FIRE); + } + else + { + m_firingState=FIRING_STATE__FIRING; + m_player->setAnimNo(ANIM_SPONGEBOB_FIRE); + } + break; + case FIRING_STATE__FIRING: + m_player->setAnimFrame(m_firingFrame++); + if(m_firingFrame>=m_player->getAnimFrameCount()) + { + int playerFacing; + DVECTOR launchPos; - // Netting? - if(m_netting) - { -//!!! m_player->setAnimNo(ANIM_SPONGEBOB_KARATE); - m_player->setAnimNo(ANIM_SPONGEBOB_FIRE); - m_player->setAnimFrame(m_netFrame); - m_netFrame++; - if(m_netFrame>=m_player->getAnimFrameCount()) - { - m_player->setAnimNo(m_savedAnimNo); - m_player->setAnimFrame(m_savedAnimFrame); - m_netting=false; - } + playerFacing=m_player->getFacing(); + launchPos=getPlayerPos(); + launchPos.vx+=playerFacing*jellyLaunchPos.vx; + launchPos.vy+=jellyLaunchPos.vy; + if(m_firingTime==TIMEOUT_FOR_BIG_SHOT&&m_player->getJellyAmmo()>=AMMO_AMOUNT_FOR_BIG_SHOT) + { + // Powered up, big shot + int fireHeading; + CPlayerProjectile *projectile; + int i; + + fireHeading=1024+(1024*playerFacing)-512; + for(i=0;i<3;i++) + { + projectile=new("JellyProjectile") CPlayerProjectile; + projectile->init(launchPos, + fireHeading, + CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE, + CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE, + 5*60); + fireHeading+=512; + m_player->useOneJelly(); + } + } + else + { + // Normal, small shot + int fireHeading; + CPlayerProjectile *projectile; + + fireHeading=1024+(1024*m_player->getFacing()); + projectile=new("JellyProjectile") CPlayerProjectile; + projectile->init(launchPos, + fireHeading, + CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE, + CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE, + 5*60); + m_player->useOneJelly(); + } + setState(STATE_IDLE); + m_firingState=FIRING_STATE__NONE; + } + break; } -// netstate=m_netState; } /*---------------------------------------------------------------------- @@ -127,17 +177,80 @@ void CPlayerModeJellyLauncher::renderModeUi() { SpriteBank *sb; sFrameHdr *fh; + FontBank *fb; + char buf[4]; sb=m_player->getSpriteBank(); - fh=sb->getFrameHeader(FRM__NET); - if(m_netState==NET_STATE__FULL) + fh=sb->getFrameHeader(FRM__BLOWER); + switch(m_firingState) { - // Net has a jellyfish inside - sb->printFT4Scaled(fh,CPlayer::POWERUPUI_ICONX-(fh->W/2),CPlayer::POWERUPUI_ICONY-(fh->H/2),0,0,CPlayer::POWERUPUI_OT,256+128); + case FIRING_STATE__NONE: + case FIRING_STATE__FIRING: + sb->printFT4(fh,CPlayer::POWERUPUI_ICONX-(fh->W/2),CPlayer::POWERUPUI_ICONY-(fh->H/2),0,0,CPlayer::POWERUPUI_OT); + break; + case FIRING_STATE__POWERINGUP: + { + int rotRange,scaleBase,scaleRange; + int xs,ys,rot; + rotRange=m_firingTime; + scaleBase=4096+(m_firingTime*10); + scaleRange=m_firingTime*2; + rot=(getRndRange(rotRange*2)-rotRange)&4095; + xs=scaleBase+getRndRange(scaleRange); + ys=scaleBase+getRndRange(scaleRange); + sb->printRotatedScaledSprite(fh,CPlayer::POWERUPUI_ICONX,CPlayer::POWERUPUI_ICONY,xs,ys,rot,CPlayer::POWERUPUI_OT); + } + break; + } + + fb=m_player->getFontBank(); + sprintf(buf,"x%d",m_player->getJellyAmmo()); + fb->print(CPlayer::POWERUPUI_TEXTX,CPlayer::POWERUPUI_TEXTY-(fb->getCharHeight()/2),buf); +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CPlayerModeJellyLauncher::setState(int _state) +{ + int allowChange; + + allowChange=true; + if(m_firingState!=FIRING_STATE__NONE) + { + switch(_state) + { + case STATE_FALL: + // Break out of firing state! + m_firingState=FIRING_STATE__NONE; + break; + + case STATE_IDLE: + case STATE_IDLETEETER: + case STATE_JUMP: + case STATE_RUN: + case STATE_FALLFAR: + case STATE_BUTTBOUNCE: + case STATE_BUTTFALL: + case STATE_BUTTLAND: + case STATE_DUCK: + case STATE_SOAKUP: + case STATE_GETUP: + allowChange=false; + break; + } + } + + if(allowChange) + { + return CPlayerModeBase::setState(_state); } else { - sb->printFT4(fh,CPlayer::POWERUPUI_ICONX-(fh->W/2),CPlayer::POWERUPUI_ICONY-(fh->H/2),0,0,CPlayer::POWERUPUI_OT); + return false; } } @@ -147,25 +260,7 @@ void CPlayerModeJellyLauncher::renderModeUi() Params: Returns: ---------------------------------------------------------------------- */ -void CPlayerModeJellyLauncher::setAnimNo(int _animNo) -{ - CPlayerModeBase::setAnimNo(_animNo); - m_savedAnimNo=_animNo; -} - -void CPlayerModeJellyLauncher::setAnimFrame(int _animFrame) -{ - CPlayerModeBase::setAnimFrame(_animFrame); - m_savedAnimFrame=_animFrame; -} - -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -int CPlayerModeJellyLauncher::canSwingNetFromThisState() +int CPlayerModeJellyLauncher::canFireFromThisState() { int ret=false; @@ -173,12 +268,12 @@ int CPlayerModeJellyLauncher::canSwingNetFromThisState() { case STATE_IDLE: case STATE_IDLETEETER: - case STATE_JUMP: - case STATE_RUN: - case STATE_FALL: ret=true; break; + case STATE_JUMP: + case STATE_RUN: + case STATE_FALL: case STATE_FALLFAR: case STATE_BUTTBOUNCE: case STATE_BUTTFALL: diff --git a/source/player/pmjelly.h b/source/player/pmjelly.h index ce7d50999..8c75cd9b3 100644 --- a/source/player/pmjelly.h +++ b/source/player/pmjelly.h @@ -41,22 +41,27 @@ public: virtual void think(); virtual void renderModeUi(); - virtual void setAnimNo(int _animNo); - virtual void setAnimFrame(int _animFrame); + virtual int setState(int _state); private: + enum + { + TIMEOUT_FOR_BIG_SHOT=60*4, + AMMO_AMOUNT_FOR_BIG_SHOT=3, + }; + typedef enum { - NET_STATE__EMPTY, - NET_STATE__FULL, - } NetState; + FIRING_STATE__NONE, + FIRING_STATE__POWERINGUP, + FIRING_STATE__FIRING, + }FIRING_STATE; - int canSwingNetFromThisState(); + int canFireFromThisState(); - int m_savedAnimNo,m_savedAnimFrame; - int m_netFrame; - int m_netting; - NetState m_netState; + int m_firingFrame; + FIRING_STATE m_firingState; + int m_firingTime; }; diff --git a/source/player/pmodes.h b/source/player/pmodes.h index dcec4caf3..32c2edd0e 100644 --- a/source/player/pmodes.h +++ b/source/player/pmodes.h @@ -122,7 +122,7 @@ public: virtual const struct PlayerMetrics *getPlayerMetrics(); - int setState(int _state); + virtual int setState(int _state); int getState() {return m_currentState;} // virtual void setMode(class CPlayer *_player,int _mode); int getFacing(); diff --git a/source/player/psrun.h b/source/player/psrun.h index 945d672ba..0a8b5efd6 100644 --- a/source/player/psrun.h +++ b/source/player/psrun.h @@ -56,7 +56,7 @@ class CPlayerStateWalk : public CPlayerStateRun { protected: virtual int getStartFrame() {return -1;} - virtual int getLoopFrame() {return ANIM_SPONGEBOB_WALK;} + virtual int getLoopFrame() {return ANIM_SPONGEBOB_RUN;} //{return ANIM_SPONGEBOB_WALK;} virtual int getEndFrame() {return -1;} };