diff --git a/source/friend/fgary.cpp b/source/friend/fgary.cpp index 43ffcdcb6..5ce73d7b7 100644 --- a/source/friend/fgary.cpp +++ b/source/friend/fgary.cpp @@ -39,6 +39,7 @@ u8 CNpcGaryFriend::m_garySpeech; +u8 CNpcGaryFriend::m_hasReachedDoor; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/friend/fgary.h b/source/friend/fgary.h index dd7ecc9fb..f90c3838c 100644 --- a/source/friend/fgary.h +++ b/source/friend/fgary.h @@ -33,6 +33,8 @@ public: void startRight(); void render(); void setObstructed() {m_obstructed = true;} + static void setReachedDoor() {m_hasReachedDoor = true;} + static bool hasReachedDoor() {return( m_hasReachedDoor );} protected: DVECTOR m_triggerPos; @@ -46,6 +48,7 @@ protected: u8 m_garySB; u8 m_garyMeow; static u8 m_garySpeech; + static u8 m_hasReachedDoor; }; #endif \ No newline at end of file diff --git a/source/triggers/tteleprt.cpp b/source/triggers/tteleprt.cpp index 92924e8fd..973a7e41e 100644 --- a/source/triggers/tteleprt.cpp +++ b/source/triggers/tteleprt.cpp @@ -18,10 +18,22 @@ #include "triggers\trigger.h" #include "triggers\tteleprt.h" +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + #ifndef __PLAYER_PLAYER_H__ #include "player\player.h" #endif +#ifndef __FRIEND_FRIEND_H__ +#include "friend\friend.h" +#endif + +#ifndef __FRIEND_FGARY_H__ +#include "friend\fgary.h" +#endif + /* Std Lib ------- */ @@ -54,15 +66,44 @@ ---------------------------------------------------------------------- */ void CTeleportTrigger::collidedWith(CThing *_thisThing) { + int chapter=GameScene.getChapterNumber(); + int level=GameScene.getLevelNumber(); + switch( _thisThing->getThingType() ) { case TYPE_PLAYER: { + if ( chapter == 1 && level == 5 ) + { + if ( !CNpcGaryFriend::hasReachedDoor() ) + { + // if we're on chapter 1, level 5, check Gary has reached the teleport point + // if he hasn't, don't let Spongey through + + return; + } + } + ((CPlayer*)_thisThing)->clearPlatform(); ((CPlayer*)_thisThing)->teleportTo(m_boxX1+8,m_boxY1+16); break; } + case TYPE_NPC: + { + if ( _thisThing->getThingSubType() == CNpcFriend::NPC_FRIEND_GARY ) + { + if ( chapter == 1 && level == 5 ) + { + // if Gary has touched a teleport on chapter 1, level 5, remember that he has done so + + CNpcGaryFriend::setReachedDoor(); + } + } + + break; + } + default: break; }