diff --git a/source/friend/fgary.cpp b/source/friend/fgary.cpp index a0ac17a11..9f66c70c0 100644 --- a/source/friend/fgary.cpp +++ b/source/friend/fgary.cpp @@ -45,6 +45,7 @@ void CNpcGaryFriend::postInit() m_started = false; m_fallDeath = false; m_drawRotation = 0; + m_obstructed = false; m_soundId = (int) NOT_PLAYING; } @@ -216,7 +217,7 @@ void CNpcGaryFriend::think( int _frames ) m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_GARY_DE_SNAIL, true ); } - if ( !conveyorOverride ) + if ( !conveyorOverride && !m_obstructed ) { Pos.vx += multiplier * 2 * _frames; } @@ -248,7 +249,7 @@ void CNpcGaryFriend::think( int _frames ) m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_GARY_DE_SNAIL, true ); } - if ( !conveyorOverride ) + if ( !conveyorOverride && !m_obstructed ) { Pos.vx += multiplier * 2 * _frames; } @@ -261,6 +262,8 @@ void CNpcGaryFriend::think( int _frames ) } } } + + m_obstructed = false; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/friend/fgary.h b/source/friend/fgary.h index d6e22e54a..27472cc81 100644 --- a/source/friend/fgary.h +++ b/source/friend/fgary.h @@ -32,6 +32,7 @@ public: void startLeft(); void startRight(); void render(); + void setObstructed() {m_obstructed = true;} protected: DVECTOR m_triggerPos; @@ -40,6 +41,7 @@ protected: s16 m_speed; s16 m_drawRotation; int m_soundId; + u8 m_obstructed; }; #endif \ No newline at end of file diff --git a/source/friend/friend.h b/source/friend/friend.h index c9c894071..0067640ba 100644 --- a/source/friend/friend.h +++ b/source/friend/friend.h @@ -58,6 +58,7 @@ public: void setPlatform( CNpcPlatform *platform ) {m_platform = platform;} void clearPlatform() {m_platform = NULL;} virtual void setupWaypoints( sThingActor *ThisActor ); + virtual void setObstructed() {} static CNpcFriend *Create(sThingActor *ThisActor); static NPC_FRIEND_UNIT_TYPE getTypeFromMapEdit( u16 newType ); diff --git a/source/hazard/hazard.cpp b/source/hazard/hazard.cpp index 02b225744..05f2136b0 100644 --- a/source/hazard/hazard.cpp +++ b/source/hazard/hazard.cpp @@ -542,6 +542,9 @@ void CNpcHazard::collidedWith( CThing *_thisThing ) break; } + case TYPE_NPC: + break; + default: ASSERT(0); break; diff --git a/source/hazard/hrweight.cpp b/source/hazard/hrweight.cpp index 7c7e8746f..2305ebc39 100644 --- a/source/hazard/hrweight.cpp +++ b/source/hazard/hrweight.cpp @@ -27,6 +27,10 @@ #include "game\game.h" #endif +#ifndef __FRIEND_FRIEND_H__ +#include "friend\friend.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -216,3 +220,39 @@ void CNpcRisingWeightHazard::render() } } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRisingWeightHazard::collidedWith( CThing *_thisThing ) +{ + if ( m_isActive ) + { + switch(_thisThing->getThingType()) + { + case TYPE_PLAYER: + { + CPlayer *player = (CPlayer *) _thisThing; + + if ( !player->isRecoveringFromHit() ) + { + player->takeDamage( DAMAGE__HIT_ENEMY ); + } + + break; + } + + case TYPE_NPC: + { + CNpcFriend *npcFriend = (CNpcFriend *) _thisThing; + + npcFriend->setObstructed(); + + break; + } + + default: + ASSERT(0); + break; + } + } +} diff --git a/source/hazard/hrweight.h b/source/hazard/hrweight.h index bfe67defa..b9f1fa99a 100644 --- a/source/hazard/hrweight.h +++ b/source/hazard/hrweight.h @@ -27,6 +27,7 @@ public: void setTriggered() {m_triggered = true;} CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );} protected: + virtual void collidedWith(CThing *_thisThing); void setWaypoints( sThingHazard *ThisHazard ); void processMovement( int _frames ); diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index 52eaccbc9..b802913da 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -750,6 +750,26 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); thing1=thing1->m_nextCollisionThing; } + // gary collision with hazards + + thing2=s_CollisionLists[CThing::TYPE_NPC]; + while(thing2) + { + if ( thing2->getThingSubType() == CNpcFriend::NPC_FRIEND_GARY ) + { + thing1=s_CollisionLists[CThing::TYPE_HAZARD]; + while(thing1) + { + if(thing1->checkCollisionAgainst(thing2, _frames)) + { + thing1->collidedWith(thing2); + } + thing1=thing1->m_nextCollisionThing; + } + } + thing2=thing2->m_nextCollisionThing; + } + player->detectHazardousSurface(); } // Shut emm down, sh sh shut em down, we shutem down