diff --git a/makefile.gaz b/makefile.gaz index af990d45e..8dcfda0d5 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -294,7 +294,8 @@ triggers_src := trigger \ trestart \ tteleprt \ twater \ - tplatfrm + tplatfrm \ + tgarygo utils_src := utils \ sincos \ diff --git a/source/friend/fgary.cpp b/source/friend/fgary.cpp index e8bfc0555..04b2d4cda 100644 --- a/source/friend/fgary.cpp +++ b/source/friend/fgary.cpp @@ -19,6 +19,21 @@ #include "game\game.h" #endif +#ifndef __UTILS_HEADER__ +#include "utils\utils.h" +#endif + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcGaryFriend::postInit() +{ + CNpcFriend::postInit(); + + m_started = false; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcGaryFriend::think( int _frames ) { @@ -65,7 +80,10 @@ void CNpcGaryFriend::think( int _frames ) Pos.vy += groundHeight; - Pos.vx += multiplier * _frames; + if ( m_started ) + { + Pos.vx += multiplier * _frames; + } } } else @@ -86,7 +104,10 @@ void CNpcGaryFriend::think( int _frames ) } else { - Pos.vx += multiplier * _frames; + if ( m_started ) + { + Pos.vx += multiplier * _frames; + } } } else @@ -94,4 +115,31 @@ void CNpcGaryFriend::think( int _frames ) Pos.vy += yMovement; } } -} \ No newline at end of file +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcGaryFriend::setupWaypoints( sThingActor *ThisActor ) +{ + if ( ThisActor->PointCount > 1 ) + { + u16 *PntList=(u16*)MakePtr(ThisActor,sizeof(sThingActor)); + + u16 newXPos, newYPos; + + // skip first waypoint + + PntList++; + PntList++; + + // get trigger position + + newXPos = (u16) *PntList; + PntList++; + newYPos = (u16) *PntList; + PntList++; + + m_triggerPos.vx = newXPos; + m_triggerPos.vy = newYPos; + } +} diff --git a/source/friend/fgary.h b/source/friend/fgary.h index 4ec036d98..56898916f 100644 --- a/source/friend/fgary.h +++ b/source/friend/fgary.h @@ -21,7 +21,15 @@ class CNpcGaryFriend : public CNpcFriend { public: - virtual void think( int _frames ); + virtual void postInit(); + virtual void think( int _frames ); + virtual void setupWaypoints( sThingActor *ThisActor ); + DVECTOR const &getTriggerPos() {return( m_triggerPos );} + void start() {m_started = true;} + +protected: + DVECTOR m_triggerPos; + u8 m_started; }; #endif \ No newline at end of file diff --git a/source/friend/friend.cpp b/source/friend/friend.cpp index 798d9a6ab..b0a83b963 100644 --- a/source/friend/friend.cpp +++ b/source/friend/friend.cpp @@ -353,4 +353,11 @@ void CNpcFriend::collidedWith( CThing *_thisThing ) void CNpcFriend::startConderversation() { // I am 'avin a fayg -} \ No newline at end of file +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcFriend::setupWaypoints( sThingActor *ThisActor ) +{ + // do nothing +} diff --git a/source/friend/friend.h b/source/friend/friend.h index 9b53b894c..c9c894071 100644 --- a/source/friend/friend.h +++ b/source/friend/friend.h @@ -57,6 +57,7 @@ public: void setType( NPC_FRIEND_UNIT_TYPE newType ) {m_type = newType;} void setPlatform( CNpcPlatform *platform ) {m_platform = platform;} void clearPlatform() {m_platform = NULL;} + virtual void setupWaypoints( sThingActor *ThisActor ); static CNpcFriend *Create(sThingActor *ThisActor); static NPC_FRIEND_UNIT_TYPE getTypeFromMapEdit( u16 newType ); diff --git a/source/level/level.cpp b/source/level/level.cpp index e37f21b98..928efe782 100644 --- a/source/level/level.cpp +++ b/source/level/level.cpp @@ -486,6 +486,7 @@ void CLevel::initThings(int _respawningLevel) { CNpcFriend *friendNpc; friendNpc=CNpcFriend::Create(ThisActor); + friendNpc->setupWaypoints( ThisActor ); friendNpc->postInit(); } break; @@ -534,6 +535,7 @@ void CLevel::initThings(int _respawningLevel) CThingManager::initAllThings(); CThingManager::matchWheelsAndWeights(); CThingManager::matchPressureSwitches(); + CThingManager::matchGaryTriggers(); } diff --git a/source/platform/pbubble.cpp b/source/platform/pbubble.cpp index 8f779b50b..447873936 100644 --- a/source/platform/pbubble.cpp +++ b/source/platform/pbubble.cpp @@ -23,7 +23,7 @@ void CNpcBubblePlatform::processMovement( int _frames ) { Pos.vy -= m_speed * _frames; - if ( m_npcPath.getWaypointCount() > 1 ) + if ( m_npcPath.getWaypointCount() ) { s32 minY, maxY; diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index 6e054f254..ba9040e9f 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -45,6 +45,10 @@ #include "friend\friend.h" #endif +#ifndef __FRIEND_FGARY_H__ +#include "friend\fgary.h" +#endif + #ifndef __HAZARD_HRWEIGHT_H__ #include "hazard\hrweight.h" #endif @@ -57,6 +61,10 @@ #include "hazard\hpswitch.h" #endif +#ifndef __TRIGGERS_TGARYGO_H__ +#include "triggers\tgarygo.h" +#endif + /* Std Lib ------- */ @@ -322,6 +330,55 @@ void CThingManager::matchWheelsAndWeights() } } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ + +void CThingManager::matchGaryTriggers() +{ + CNpcFriend *friendNpc; + + friendNpc = (CNpcFriend *) s_thingLists[CThing::TYPE_NPC]; + + while( friendNpc ) + { + if ( friendNpc->getThingSubType() == CNpcFriend::NPC_FRIEND_GARY ) + { + CNpcGaryFriend *gary = (CNpcGaryFriend *) friendNpc; + + DVECTOR triggerPos = gary->getTriggerPos(); + + CTrigger *trigger; + + trigger = (CTrigger *) s_thingLists[CThing::TYPE_TRIGGER]; + + while( trigger ) + { + if ( trigger->getThingSubType() == CTrigger::TRIGGER_GARYSTART ) + { + CGaryStartTrigger *garyTrigger = (CGaryStartTrigger *) trigger; + + DVECTOR testPos = garyTrigger->getPos(); + testPos.vx >>= 4; + testPos.vy >>= 4; + + if ( testPos.vx == triggerPos.vx && testPos.vy == triggerPos.vy ) + { + garyTrigger->setGary( gary ); + } + } + + trigger = (CTrigger *) trigger->m_nextListThing; + } + } + + friendNpc = (CNpcFriend *) friendNpc->m_nextListThing; + } +} + /*---------------------------------------------------------------------- Function: Purpose: diff --git a/source/thing/thing.h b/source/thing/thing.h index 35350629a..88e9c0d2d 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -64,6 +64,7 @@ public: static void initCollision(); static void matchWheelsAndWeights(); static void matchPressureSwitches(); + static void matchGaryTriggers(); static sBBox &getRenderBBox() {return(m_RenderBBox);} static sBBox &getThinkBBox() {return(m_ThinkBBox);} diff --git a/source/triggers/trigger.cpp b/source/triggers/trigger.cpp index 2d28d1653..604bec18c 100644 --- a/source/triggers/trigger.cpp +++ b/source/triggers/trigger.cpp @@ -39,6 +39,10 @@ #include "triggers\tplatfrm.h" #endif +#ifndef __TRIGGERS_TGARYGO_H__ +#include "triggers\tgarygo.h" +#endif + #ifndef __GAME_GAME_H__ #include "game\game.h" #endif @@ -81,6 +85,11 @@ CTrigger *trigger; trigger=(COutOfWaterTrigger*)new ("OutOfWaterTrigger") COutOfWaterTrigger(); break; + // Gary start trigger + case TRIGGER_GARYSTART: + trigger=(CGaryStartTrigger*)new( "GaryStartTrigger") CGaryStartTrigger(); + break; + case TRIGGER_PLATFORM: trigger = (CPlatformTrigger*)new ("PlatformTrigger") CPlatformTrigger(); break; diff --git a/source/triggers/trigger.h b/source/triggers/trigger.h index 61659bbe1..31df2792d 100644 --- a/source/triggers/trigger.h +++ b/source/triggers/trigger.h @@ -29,6 +29,7 @@ enum TRIGGER_TYPE TRIGGER_CAMLOCK, TRIGGER_INWATER, TRIGGER_OUTWATER, + TRIGGER_GARYSTART, // Code based triggers TRIGGER_PLATFORM, diff --git a/tools/Data/bin/MkLevel.ini b/tools/Data/bin/MkLevel.ini index 9efc204df..362160e44 100644 --- a/tools/Data/bin/MkLevel.ini +++ b/tools/Data/bin/MkLevel.ini @@ -130,6 +130,7 @@ Teleport=2 CameraLock=3 InWater=4 OutOfWater=5 +GaryStart=6 ################################################ # FX diff --git a/tools/MapEdit/trigger.ini b/tools/MapEdit/trigger.ini index b4cad7b42..08cfdb3cb 100644 --- a/tools/MapEdit/trigger.ini +++ b/tools/MapEdit/trigger.ini @@ -18,3 +18,5 @@ HasBox=1 [InWater] [OutOfWater] + +[GaryStart] \ No newline at end of file diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index 2de20ef2c..5fc89755a 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -1905,6 +1905,14 @@ SOURCE=..\..\..\source\triggers\tcamlock.h # End Source File # Begin Source File +SOURCE=..\..\..\source\triggers\tgarygo.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\triggers\tgarygo.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\triggers\tlevexit.cpp # End Source File # Begin Source File @@ -1937,6 +1945,14 @@ SOURCE=..\..\..\source\triggers\trestart.h # End Source File # Begin Source File +SOURCE=..\..\..\source\triggers\trigger.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\triggers\trigger.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\triggers\tteleprt.cpp # End Source File # Begin Source File