diff --git a/source/hazard/hfalling.cpp b/source/hazard/hfalling.cpp index 54f0f8bd2..0493f4e67 100644 --- a/source/hazard/hfalling.cpp +++ b/source/hazard/hfalling.cpp @@ -27,6 +27,10 @@ #include "system\vid.h" #endif +#ifndef __PLAYER_PLAYER_H__ +#include "player\player.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -38,6 +42,8 @@ void CNpcFallingHazard::init() m_respawnRate = 4; m_bounceFinish = false; + m_spinFinish = false; + m_rotation = 0; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -60,17 +66,23 @@ void CNpcFallingHazard::processMovement( int _frames ) Pos.vy += m_speed * _frames; - if ( Pos.vy > ( m_bouncePos.vy + 32 ) ) + /*if ( Pos.vy > ( m_bouncePos.vy + 32 ) ) { m_bounceFinish = false; } - else + else*/ { if ( m_speed < 3 ) { m_speed++; } } + + if ( m_spinFinish ) + { + m_rotation += 64 * _frames; + m_rotation &= 4095; + } } else { @@ -140,6 +152,8 @@ void CNpcFallingHazard::processTimer( int _frames ) Pos = m_base; m_movementTimer = 2 * GameState::getOneSecondInFrames(); m_bounceFinish = false; + m_spinFinish = false; + m_rotation = 0; } } @@ -147,7 +161,34 @@ void CNpcFallingHazard::processTimer( int _frames ) void CNpcFallingHazard::collidedWith( CThing *_thisThing ) { - if (m_movementTimer<=0) CNpcHazard::collidedWith(_thisThing); + if ( m_movementTimer <= 0 && m_isActive ) + { + switch(_thisThing->getThingType()) + { + case TYPE_PLAYER: + { + CPlayer *player = (CPlayer *) _thisThing; + + if ( !player->isRecoveringFromHit() ) + { + player->takeDamage( DAMAGE__HIT_ENEMY ); + } + + m_bounceFinish = true; + m_spinFinish = true; + m_speed = -5; + m_bounceDir = getRnd() % 2; + + m_bouncePos = Pos; + + break; + } + + default: + ASSERT(0); + break; + } + } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -199,3 +240,27 @@ void CNpcFallingHazard::setWaypoints( sThingHazard *ThisHazard ) } } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcFallingHazard::render() +{ + CHazardThing::render(); + + if (canRender()) + { + DVECTOR &renderPos=getRenderPos(); + + SVECTOR rotation; + rotation.vx = 0; + rotation.vy = 0; + rotation.vz = m_rotation; + + VECTOR scale; + scale.vx = ONE; + scale.vy = ONE; + scale.vz = ONE; + + m_modelGfx->Render(renderPos,&rotation,&scale); + } +} diff --git a/source/hazard/hfalling.h b/source/hazard/hfalling.h index 8b99fc22c..7bcf1410b 100644 --- a/source/hazard/hfalling.h +++ b/source/hazard/hfalling.h @@ -24,6 +24,7 @@ public: void init(); //virtual CRECT const *getThinkBBox(); virtual void setWaypoints( sThingHazard *ThisHazard ); + void render(); protected: void processMovement( int _frames ); void processTimer( int _frames ); @@ -31,9 +32,11 @@ protected: s32 m_movementTimer; u8 m_bounceFinish; + u8 m_spinFinish; s32 m_speed; u8 m_bounceDir; DVECTOR m_bouncePos; + s16 m_rotation; }; #endif \ No newline at end of file