diff --git a/makefile.gaz b/makefile.gaz index e28f3d7c9..c35e62553 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -316,7 +316,8 @@ triggers_src := trigger \ tbgeyser \ thazwalk \ tsemit \ - tsswitch + tsswitch \ + tgbowl utils_src := utils \ sincos \ diff --git a/source/platform/plift.cpp b/source/platform/plift.cpp index 20052f4b2..c8b011f49 100644 --- a/source/platform/plift.cpp +++ b/source/platform/plift.cpp @@ -23,6 +23,10 @@ #include "game\game.h" #endif +#ifndef __FRIEND_FRIEND_H__ +#include "friend\friend.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -134,3 +138,105 @@ void CNpcLiftPlatform::processTimer( int _frames ) m_timer -= _frames; } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcLiftPlatform::collidedWith( CThing *_thisThing ) +{ + switch(_thisThing->getThingType()) + { + case TYPE_PLAYER: + { + CPlayer *player; + DVECTOR playerPos; + CRECT collisionArea; + + // Only interested in SBs feet colliding with the box (pkg) + player=(CPlayer*)_thisThing; + playerPos=player->getPos(); + collisionArea=getCollisionArea(); + + s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); + + if ( threshold > 16 ) + { + threshold = 16; + } + + if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + { + if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) ) + { + player->setPlatform( this ); + + m_contact = true; + } + else + { + if( playerPos.vy >= collisionArea.y1 && playerPos.vy <= collisionArea.y2 ) + { + int height = getHeightFromPlatformAtPosition( playerPos.vx, playerPos.vy ); + + if ( height >= -threshold && height < 1 ) + { + player->setPlatform( this ); + + m_contact = true; + } + } + } + } + + break; + } + + case TYPE_NPC: + { + CNpcFriend *friendNpc; + DVECTOR friendPos; + CRECT collisionArea; + + friendNpc = (CNpcFriend*) _thisThing; + friendPos = friendNpc->getPos(); + collisionArea=getCollisionArea(); + + s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); + + if ( threshold > 16 ) + { + threshold = 16; + } + + if( friendPos.vx >= collisionArea.x1 && friendPos.vx <= collisionArea.x2 ) + { + if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) ) + { + int height = getHeightFromPlatformAtPosition( friendPos.vx, friendPos.vy ); + + friendNpc->setPlatform( this ); + } + else + { + if( friendPos.vy >= collisionArea.y1 && friendPos.vy <= collisionArea.y2 ) + { + int height = getHeightFromPlatformAtPosition( friendPos.vx, friendPos.vy ); + + if ( height >= -threshold && height < 1 ) + { + friendNpc->setPlatform( this ); + } + } + } + } + + break; + } + + case TYPE_HAZARD: + break; + + default: + ASSERT(0); + break; + } +} diff --git a/source/platform/plift.h b/source/platform/plift.h index 5d2558485..9993acf75 100644 --- a/source/platform/plift.h +++ b/source/platform/plift.h @@ -24,6 +24,7 @@ public: virtual void postInit(); virtual void setWaypoints( sThingPlatform *ThisPlatform ); protected: + virtual void collidedWith(CThing *_thisThing); virtual void processMovement( int _frames ); virtual void processTimer( int _frames ); diff --git a/source/triggers/trigger.cpp b/source/triggers/trigger.cpp index 139445325..d4fea73cd 100644 --- a/source/triggers/trigger.cpp +++ b/source/triggers/trigger.cpp @@ -87,6 +87,10 @@ #include "triggers\tsswitch.h" #endif +#ifndef __TRIGGERS_TGBOWL_H__ +#include "triggers\tgbowl.h" +#endif + #ifndef __GAME_GAME_H__ #include "game\game.h" #endif @@ -149,6 +153,11 @@ CTrigger *trigger; trigger=(CGaryGoRightTrigger*)new("GaryGoRightTrigger") CGaryGoRightTrigger(); break; + // Gary bowl trigger + case TRIGGER_GARY_BOWL: + trigger=(CGaryBowlTrigger*)new("GaryBowlTrigger") CGaryBowlTrigger(); + break; + // Flame emitter case TRIGGER_FLAME_EMITTER: trigger=(CFlameEmitterTrigger*)new( "FlameEmitterTrigger") CFlameEmitterTrigger(); diff --git a/source/triggers/trigger.h b/source/triggers/trigger.h index 243001344..a8dc19a8e 100644 --- a/source/triggers/trigger.h +++ b/source/triggers/trigger.h @@ -40,6 +40,7 @@ enum TRIGGER_TYPE TRIGGER_INTERMITTENT_DOWN_FLAME_EMITTER, TRIGGER_BUBBLE_GEYSER_EMITTER, TRIGGER_STEAM_EMITTER, + TRIGGER_GARY_BOWL, // Code based triggers TRIGGER_PLATFORM, diff --git a/tools/Data/bin/MkLevel.ini b/tools/Data/bin/MkLevel.ini index b8eec7f2b..62686b417 100644 --- a/tools/Data/bin/MkLevel.ini +++ b/tools/Data/bin/MkLevel.ini @@ -145,6 +145,7 @@ IntermittentLeftFlameEmitter=13 IntermittentDownFlameEmitter=14 StreamGeyser=15 SteamEmitter=16 +GaryBowl=17 ################################################ # FX diff --git a/tools/MapEdit/trigger.ini b/tools/MapEdit/trigger.ini index 91cf5f7f6..76d4112a0 100644 --- a/tools/MapEdit/trigger.ini +++ b/tools/MapEdit/trigger.ini @@ -39,4 +39,6 @@ HasBox=1 [GaryGoLeft] -[GaryGoRight] \ No newline at end of file +[GaryGoRight] + +[GaryBowl] \ 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 d154160a8..088b7af97 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -2109,6 +2109,14 @@ SOURCE=..\..\..\source\triggers\tgarygo.h # End Source File # Begin Source File +SOURCE=..\..\..\source\triggers\tgbowl.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\triggers\tgbowl.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\triggers\tggleft.cpp # End Source File # Begin Source File