diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index d4b63819d..d8467873b 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -55,6 +55,8 @@ #include "projectl\prnpc.h" #endif +#include "fx\fx.h" + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef __ENEMY_NSJFISH_H__ @@ -757,6 +759,46 @@ void CNpcEnemy::processAttackCollision() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcEnemy::drawAttackEffect() +{ + CRECT rect; + rect = getCollisionArea(); + + DVECTOR thwakPos; + + s32 xDist; + + CPlayer *player = GameScene.getPlayer(); + DVECTOR playerPos = player->getPos(); + + xDist = playerPos.vx - this->Pos.vx; + + if ( xDist > 0 ) + { + thwakPos.vx = rect.x2; + + if ( rect.x1 > thwakPos.vx ) + { + thwakPos.vx = rect.x1; + } + } + else + { + thwakPos.vx = rect.x1; + + if ( rect.x2 < thwakPos.vx ) + { + thwakPos.vx = rect.x2; + } + } + + thwakPos.vy = ( rect.y1 + rect.y2 ) >> 1; + + CFX::Create( CFX::FX_TYPE_THWACK, thwakPos ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcEnemy::collidedWith( CThing *_thisThing ) { if ( m_isActive && !m_isCaught && !m_isDying ) @@ -814,6 +856,8 @@ void CNpcEnemy::collidedWith( CThing *_thisThing ) } m_controlFunc = NPC_CONTROL_SHOT; m_state = NPC_GENERIC_HIT_CHECK_HEALTH; + + drawAttackEffect(); } } @@ -1076,6 +1120,7 @@ void CNpcEnemy::processShot( int _frames ) case NPC_SHOT_NONE: { // do nothing + m_controlFunc = m_oldControlFunc; break; } diff --git a/source/enemy/npc.h b/source/enemy/npc.h index debef9c25..535fcc822 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -270,6 +270,8 @@ protected: void processCoralBlower( int _frames ); bool processCoralBlowerMovement( int _frames, s32 xDist, s32 yDist, u8 destroyAtTarget ); + void drawAttackEffect(); + // data static NPC_DATA m_data[NPC_UNIT_TYPE_MAX]; diff --git a/source/enemy/nsstomp.cpp b/source/enemy/nsstomp.cpp index 204f21a32..253a6941b 100644 --- a/source/enemy/nsstomp.cpp +++ b/source/enemy/nsstomp.cpp @@ -164,3 +164,44 @@ const CRECT *CNpcSkullStomperEnemy::getThinkBBox() return &objThinkBox; } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcSkullStomperEnemy::collidedWith( CThing *_thisThing ) +{ + if ( m_isActive && !m_isCaught && !m_isDying ) + { + switch(_thisThing->getThingType()) + { + case TYPE_PLAYER: + { + CPlayer *player = (CPlayer *) _thisThing; + + ATTACK_STATE playerState = player->getAttackState(); + + if(playerState==ATTACK_STATE__NONE) + { + if ( !player->isRecoveringFromHit() ) + { + CPlayer *player = GameScene.getPlayer(); + + player->takeDamage( m_data[m_type].damageToUserType,REACT__GET_DIRECTION_FROM_THING,(CThing*)this ); + } + } + else + { + drawAttackEffect(); + } + + break; + } + + case TYPE_ENEMY: + break; + + default: + ASSERT(0); + break; + } + } +} \ No newline at end of file diff --git a/source/enemy/nsstomp.h b/source/enemy/nsstomp.h index d02017e70..de93a9650 100644 --- a/source/enemy/nsstomp.h +++ b/source/enemy/nsstomp.h @@ -23,6 +23,7 @@ protected: virtual void processEnemyCollision( CThing *thisThing ); virtual bool processSensor(); virtual void processClose( int _frames ); + virtual void collidedWith(CThing *_thisThing); }; #endif \ No newline at end of file