This commit is contained in:
Charles 2001-08-08 15:43:07 +00:00
parent 4caddd162d
commit 45435136f8
10 changed files with 153 additions and 18 deletions

View File

@ -157,7 +157,6 @@ hazard_src := hazard \
hrrock \ hrrock \
hflytrap \ hflytrap \
hrweight \ hrweight \
hrwheel \
hpswitch \ hpswitch \
hrckshrd \ hrckshrd \
hinert \ hinert \

View File

@ -99,10 +99,6 @@
#include "hazard\hrweight.h" #include "hazard\hrweight.h"
#endif #endif
#ifndef __HAZARD_HRWHEEL_H__
#include "hazard\hrwheel.h"
#endif
#ifndef __HAZARD_HPSWITCH_H__ #ifndef __HAZARD_HPSWITCH_H__
#include "hazard\hpswitch.h" #include "hazard\hpswitch.h"
#endif #endif

View File

@ -121,7 +121,7 @@ void CNpcRisingWeightHazard::processMovement( int _frames )
if ( m_triggered ) if ( m_triggered )
{ {
m_triggered = false; m_triggered = false;
m_extension += ( 3 * _frames ) << 8; m_extension += ( 16 * _frames ) << 8;
if ( m_extension > m_maxExtension ) if ( m_extension > m_maxExtension )
{ {
m_extension = m_maxExtension; m_extension = m_maxExtension;
@ -148,6 +148,8 @@ void CNpcRisingWeightHazard::processMovement( int _frames )
{ {
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_PULLEY, true, true ); m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_PULLEY, true, true );
} }
m_wheel->weightDrop();
} }
} }
@ -272,3 +274,121 @@ void CNpcRisingWeightHazard::collidedWith( CThing *_thisThing )
} }
} }
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingWeightWheelHazard::init()
{
CNpcHazard::init();
m_rotation = 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingWeightWheelHazard::setWaypoints( sThingHazard *ThisHazard )
{
u16 *PntList=(u16*)MakePtr(ThisHazard,sizeof(sThingHazard));
u16 newXPos, newYPos;
// get init pos
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
startPos.vx = ( newXPos << 4 ) + 8;
startPos.vy = ( newYPos << 4 ) + 16;
Pos = startPos;
m_base = Pos;
m_wheelPos.vx = newXPos;
m_wheelPos.vy = newYPos;
s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX );
m_npcPath.getPathYExtents( &minY, &maxY );
m_thinkArea.x1 = minX;
m_thinkArea.x2 = maxX;
m_thinkArea.y1 = minY;
m_thinkArea.y2 = maxY;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingWeightWheelHazard::collidedWith( CThing *_thisThing )
{
if ( m_isActive )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
CPlayer *player = (CPlayer *) _thisThing;
ATTACK_STATE playerState = player->getAttackState();
if ( playerState == ATTACK_STATE__BUTT_BOUNCE )
{
m_weight->setTriggered();
m_rotation += 256;
m_rotation &= 4095;
}
break;
}
case TYPE_PLAYERPROJECTILE:
{
m_weight->setTriggered();
m_rotation += 256;
m_rotation &= 4095;
_thisThing->setToShutdown();
}
default:
break;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingWeightWheelHazard::weightDrop()
{
m_rotation -= 128;
m_rotation &= 4095;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingWeightWheelHazard::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);
}
}

View File

@ -18,6 +18,8 @@
#include "hazard\hazard.h" #include "hazard\hazard.h"
#endif #endif
class CNpcRisingWeightWheelHazard;
class CNpcRisingWeightHazard : public CNpcHazard class CNpcRisingWeightHazard : public CNpcHazard
{ {
public: public:
@ -26,15 +28,35 @@ public:
DVECTOR const &getWheelPos() {return( m_wheelPos );} DVECTOR const &getWheelPos() {return( m_wheelPos );}
void setTriggered() {m_triggered = true;} void setTriggered() {m_triggered = true;}
bool alwaysThink() {return(true);} bool alwaysThink() {return(true);}
void linkToWheel( CNpcRisingWeightWheelHazard *wheel ) {m_wheel = wheel;}
protected: protected:
virtual void collidedWith(CThing *_thisThing); virtual void collidedWith(CThing *_thisThing);
void setWaypoints( sThingHazard *ThisHazard ); void setWaypoints( sThingHazard *ThisHazard );
void processMovement( int _frames ); void processMovement( int _frames );
CNpcRisingWeightWheelHazard *m_wheel;
s32 m_maxExtension; s32 m_maxExtension;
DVECTOR m_wheelPos; DVECTOR m_wheelPos;
DVECTOR m_pulleyPos; DVECTOR m_pulleyPos;
u8 m_triggered; u8 m_triggered;
}; };
class CNpcRisingWeightWheelHazard : public CNpcHazard
{
public:
void init();
DVECTOR const &getWheelPos() {return( m_wheelPos );}
void linkToWeight( CNpcRisingWeightHazard *weight ) {m_weight = weight;}
void render();
bool alwaysThink() {return(true);}
void weightDrop();
protected:
void setWaypoints( sThingHazard *ThisHazard );
void collidedWith(CThing *_thisThing);
DVECTOR m_wheelPos;
CNpcRisingWeightHazard *m_weight;
s16 m_rotation;
};
#endif #endif

View File

@ -112,6 +112,14 @@ void CNpcRisingWeightWheelHazard::collidedWith( CThing *_thisThing )
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingWeightWheelHazard::weightDrop()
{
m_rotation -= 128;
m_rotation &= 4095;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingWeightWheelHazard::render() void CNpcRisingWeightWheelHazard::render()
{ {
CHazardThing::render(); CHazardThing::render();

View File

@ -30,6 +30,7 @@ public:
void linkToWeight( CNpcRisingWeightHazard *weight ) {m_weight = weight;} void linkToWeight( CNpcRisingWeightHazard *weight ) {m_weight = weight;}
void render(); void render();
bool alwaysThink() {return(true);} bool alwaysThink() {return(true);}
void weightDrop();
protected: protected:
void setWaypoints( sThingHazard *ThisHazard ); void setWaypoints( sThingHazard *ThisHazard );
void collidedWith(CThing *_thisThing); void collidedWith(CThing *_thisThing);

View File

@ -54,10 +54,6 @@
#include "hazard\hrweight.h" #include "hazard\hrweight.h"
#endif #endif
#ifndef __HAZARD_HRWHEEL_H__
#include "hazard\hrwheel.h"
#endif
#ifndef __HAZARD_HPSWITCH_H__ #ifndef __HAZARD_HPSWITCH_H__
#include "hazard\hpswitch.h" #include "hazard\hpswitch.h"
#endif #endif
@ -321,6 +317,7 @@ void CThingManager::matchWheelsAndWeights()
if ( testPos.vx == wheelPos.vx && testPos.vy == wheelPos.vy ) if ( testPos.vx == wheelPos.vx && testPos.vy == wheelPos.vy )
{ {
wheel->linkToWeight( weight ); wheel->linkToWeight( weight );
weight->linkToWheel( wheel );
} }
} }

View File

@ -1137,14 +1137,6 @@ SOURCE=..\..\..\source\hazard\hrweight.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\..\source\hazard\hrwheel.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\hazard\hrwheel.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\hazard\hsaw.cpp SOURCE=..\..\..\source\hazard\hsaw.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File