This commit is contained in:
parent
d4ad696784
commit
0b22ba26cd
@ -15,6 +15,14 @@
|
||||
#include "hazard\hbbarrel.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GAME_GAME_H__
|
||||
#include "game\game.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLAYER_PLAYER_H__
|
||||
#include "player\player.h"
|
||||
#endif
|
||||
|
||||
#ifndef __LAYER_COLLISION_H__
|
||||
#include "level\layercollision.h"
|
||||
#endif
|
||||
@ -39,6 +47,7 @@ void CNpcBouncingBarrelHazard::init()
|
||||
m_rotation = 0;
|
||||
m_rockRotation = 0;
|
||||
m_rockDir = true;
|
||||
m_hitPlayer = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -55,6 +64,31 @@ void CNpcBouncingBarrelHazard::processMovement( int _frames )
|
||||
|
||||
// deal with horizontal
|
||||
|
||||
if ( m_hitPlayer )
|
||||
{
|
||||
Pos.vy += m_speed * _frames;
|
||||
|
||||
if ( m_speed < 3 )
|
||||
{
|
||||
m_speed++;
|
||||
}
|
||||
|
||||
m_rotation += 64 * _frames;
|
||||
m_rotation &= 4095;
|
||||
|
||||
DVECTOR offset = CLevel::getCameraPos();
|
||||
|
||||
s32 yPos = Pos.vy - offset.vy;
|
||||
|
||||
if ( yPos > VidGetScrH() )
|
||||
{
|
||||
Pos = m_base;
|
||||
m_hitPlayer = false;
|
||||
m_npcPath.resetPath();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool pathComplete;
|
||||
|
||||
if ( m_npcPath.thinkFlat( Pos, &pathComplete, &waypointXDist, &waypointYDist, &waypointHeading, 1 ) )
|
||||
@ -62,13 +96,14 @@ void CNpcBouncingBarrelHazard::processMovement( int _frames )
|
||||
if ( pathComplete )
|
||||
{
|
||||
Pos = m_base;
|
||||
m_hitPlayer = false;
|
||||
m_npcPath.resetPath();
|
||||
}
|
||||
|
||||
m_lastWaypoint = Pos;
|
||||
}
|
||||
|
||||
moveX = 4 * _frames;
|
||||
moveX = 3 * _frames;
|
||||
|
||||
if ( moveX > abs( waypointXDist ) )
|
||||
{
|
||||
@ -134,6 +169,7 @@ void CNpcBouncingBarrelHazard::processMovement( int _frames )
|
||||
|
||||
Pos.vy = m_lastWaypoint.vy - ( ( abs( nextWaypoint.vy - m_lastWaypoint.vy ) * rsin( sineVal ) ) >> 12 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -174,3 +210,36 @@ const CRECT *CNpcBouncingBarrelHazard::getThinkBBox()
|
||||
|
||||
return &objThinkBox;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcBouncingBarrelHazard::collidedWith( CThing *_thisThing )
|
||||
{
|
||||
if ( m_isActive )
|
||||
{
|
||||
switch(_thisThing->getThingType())
|
||||
{
|
||||
case TYPE_PLAYER:
|
||||
{
|
||||
if ( !m_hitPlayer )
|
||||
{
|
||||
CPlayer *player = (CPlayer *) _thisThing;
|
||||
|
||||
if ( !player->isRecoveringFromHit() )
|
||||
{
|
||||
player->takeDamage( DAMAGE__HIT_ENEMY );
|
||||
}
|
||||
|
||||
m_hitPlayer = true;
|
||||
m_speed = -5;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,15 @@ public:
|
||||
virtual CRECT const *getThinkBBox();
|
||||
protected:
|
||||
void processMovement( int _frames );
|
||||
virtual void collidedWith(CThing *_thisThing);
|
||||
|
||||
DVECTOR m_lastWaypoint;
|
||||
|
||||
s16 m_rotation;
|
||||
s16 m_rockRotation;
|
||||
u8 m_rockDir;
|
||||
u8 m_hitPlayer;
|
||||
s32 m_speed;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user