From c0983f9bfbad7eb9ab465f6ff5361c5dd7cc985a Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 8 May 2001 16:58:07 +0000 Subject: [PATCH] --- makefile.gaz | 3 ++- source/game/game.cpp | 4 ---- source/level/level.cpp | 12 +++++++++++ source/player/player.cpp | 20 ++++++++++--------- source/player/player.h | 16 +++++---------- source/triggers/twater.cpp | 4 ++-- .../spongebob project/spongebob project.dsp | 8 ++++++++ 7 files changed, 40 insertions(+), 27 deletions(-) diff --git a/makefile.gaz b/makefile.gaz index 1cc193d73..b9df1da3c 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -258,7 +258,8 @@ triggers_src := tcamlock \ tlevexit \ tlook \ trestart \ - tteleprt + tteleprt \ + twater utils_src := utils \ sincos \ diff --git a/source/game/game.cpp b/source/game/game.cpp index 2a7560cf8..c29a841d2 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -315,10 +315,6 @@ void CGameScene::initLevel() DVECTOR mapSize=Level.getMapSize(); CPlayer::CameraBox camBox={0,0,mapSize.vx<<4,mapSize.vy<<4}; m_player->setCameraBox(camBox); - if(s_globalLevelSelectThing==1) - { - m_player->setHealthType(CPlayer::HEALTH_TYPE__OUT_OF_WATER); - } // Song is loaded/dumped by the level, and played from here. This just gives some // better timing over when it starts (pkg) diff --git a/source/level/level.cpp b/source/level/level.cpp index 958330537..415959bcb 100644 --- a/source/level/level.cpp +++ b/source/level/level.cpp @@ -35,6 +35,10 @@ #include "triggers\tcamlock.h" #endif +#ifndef __TRIGGERS_TWATER_H__ +#include "triggers\twater.h" +#endif + #ifndef __PICKUPS_PICKUP_H__ #include "pickups\pickup.h" #endif @@ -390,6 +394,14 @@ void CLevel::initThings(int _respawningLevel) case 3: trigger=NULL; break; + + // In/Out of water triggers + case 4: + trigger=(CInWaterTrigger*)new ("InWaterTrigger") CInWaterTrigger(); + break; + case 5: + trigger=(COutOfWaterTrigger*)new ("OutOfWaterTrigger") COutOfWaterTrigger(); + break; } if(trigger) { diff --git a/source/player/player.cpp b/source/player/player.cpp index 9f1df5a0f..073231463 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -486,6 +486,7 @@ m_animFrame=0; resetPlayerCollisionSizeToBase(); m_divingHelmet=false; + setIsInWater(true); //#ifdef __USER_paul__ registerAddon(PLAYER_ADDON_NET); @@ -494,9 +495,6 @@ registerAddon(PLAYER_ADDON_JELLYLAUNCHER); registerAddon(PLAYER_ADDON_GLASSES); registerAddon(PLAYER_ADDON_BUBBLEWAND); //#endif - - - setHealthType(HEALTH_TYPE__NORMAL); } /*---------------------------------------------------------------------- @@ -546,7 +544,10 @@ void CPlayer::think(int _frames) { int i; - if(m_healthType==HEALTH_TYPE__OUT_OF_WATER&&m_currentMode!=PLAYER_MODE_DEAD&&m_currentMode!=PLAYER_MODE_FLY) + ASSERT(!(getIsInWater()==false&&isWearingDivingHelmet()==false)); + + if(isWearingDivingHelmet()&&getIsInWater()==false&& + m_currentMode!=PLAYER_MODE_DEAD&&m_currentMode!=PLAYER_MODE_FLY) { m_healthWaterLevel-=waterDrainSpeed*_frames; if(m_healthWaterLevel<=0) @@ -871,7 +872,7 @@ for(int i=0;iprintFT4(fh,x-2,y-2,0,0,0); itemX+=COLLECTEDITEM_GAP; } - if(isWearingHelmet()) + if(isWearingDivingHelmet()) { sFrameHdr *fh=m_spriteBank->getFrameHeader(FRM__HELMET); m_spriteBank->printFT4(fh,itemX-(fh->W/2),COLLECTEDITEM_BASEY-(fh->H/2),0,0,0); itemX+=COLLECTEDITEM_GAP; } + } @@ -1030,7 +1032,7 @@ int CPlayer::getHeightFromGroundNoPlatform(int _x,int _y,int _maxHeight=32) ---------------------------------------------------------------------- */ void CPlayer::addHealth(int _health) { - if(m_healthType==HEALTH_TYPE__NORMAL) + if(!isWearingDivingHelmet()) { m_health+=_health; if(m_health>MAX_HEALTH) @@ -1389,7 +1391,7 @@ int CPlayer::canDoLookAround() ---------------------------------------------------------------------- */ void CPlayer::inSoakUpState() { - if(m_healthType==HEALTH_TYPE__OUT_OF_WATER&& + if(isWearingDivingHelmet()&& (m_layerCollision->getCollisionBlock(Pos.vx,Pos.vy)&COLLISION_TYPE_MASK)==COLLISION_TYPE_FLAG_WATER) { m_healthWaterLevel+=waterSoakUpSpeed; @@ -1446,7 +1448,7 @@ void CPlayer::takeDamage(DAMAGE_TYPE _damage) { int died=false; if(invincibleSponge){m_invincibleFrameCount=INVINCIBLE_FRAMES__HIT;return;} - if(m_healthType==HEALTH_TYPE__NORMAL) + if(!isWearingDivingHelmet()) { m_health--; if(m_health<0) diff --git a/source/player/player.h b/source/player/player.h index 5733d73b0..c7f340014 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -285,18 +285,8 @@ private: int m_currentMode; -public: - typedef enum - { - HEALTH_TYPE__NORMAL, - HEALTH_TYPE__OUT_OF_WATER, - } HEALTH_TYPE; - - void setHealthType(HEALTH_TYPE _healthType) {m_healthType=_healthType;} - private: int m_lives; - HEALTH_TYPE m_healthType; int m_health; int m_healthWaterLevel; int m_healthReactFrames; @@ -333,9 +323,9 @@ public: int isWearingGlasses() {return m_glassesFlag;} void giveSqueakyBoots() {m_squeakyBootsTimer=SQUEAKY_BOOTS_TIME;} int isWearingBoots() {return m_squeakyBootsTimer;} - int isWearingHelmet() {return false;} void giveInvincibilityRing() {m_invincibilityRingTimer=INVINCIBILITY_RING_TIME;} void giveDivingHelmet() {m_divingHelmet=true;} + int isWearingDivingHelmet() {return m_divingHelmet;} void giveBubbleAmmo() {m_bubbleAmmo+=10;if(m_bubbleAmmo>99)m_bubbleAmmo=99;} void useOneBubble() {m_bubbleAmmo--;} @@ -345,6 +335,9 @@ public: void useOneJelly() {m_jellyAmmo--;} int getJellyAmmo() {return m_jellyAmmo;} + void setIsInWater(int _in) {m_isInWater=_in;} + int getIsInWater() {return m_isInWater;} + private: int m_glassesFlag; int m_squeakyBootsTimer; @@ -352,6 +345,7 @@ private: int m_divingHelmet; int m_bubbleAmmo; int m_jellyAmmo; + int m_isInWater; // Platforms public: diff --git a/source/triggers/twater.cpp b/source/triggers/twater.cpp index 01c32d6a7..4a9d33c1b 100644 --- a/source/triggers/twater.cpp +++ b/source/triggers/twater.cpp @@ -55,7 +55,7 @@ void CInWaterTrigger::collidedWith(CThing *_thisThing) { if(_thisThing->getThingType()==TYPE_PLAYER) { -// ((CPlayer*)_thisThing)->setCameraBox(camBox); + ((CPlayer*)_thisThing)->setIsInWater(true); } } @@ -69,7 +69,7 @@ void COutOfWaterTrigger::collidedWith(CThing *_thisThing) { if(_thisThing->getThingType()==TYPE_PLAYER) { -// ((CPlayer*)_thisThing)->setCameraBox(camBox); + ((CPlayer*)_thisThing)->setIsInWater(false); } } diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index f34a9e830..d521fe61a 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -1771,6 +1771,14 @@ SOURCE=..\..\..\source\triggers\tteleprt.cpp SOURCE=..\..\..\source\triggers\tteleprt.h # End Source File +# Begin Source File + +SOURCE=..\..\..\source\triggers\twater.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\triggers\twater.h +# End Source File # End Group # Begin Group "utils"