diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 51cd35c45..1663a49b9 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -1072,6 +1072,13 @@ void CNpcEnemy::processMovement(int _frames) break; } + case NPC_MOVEMENT_SHARK_MAN: + { + processSharkManMovement( _frames, &moveX, &moveY ); + + break; + } + default: break; @@ -1310,8 +1317,8 @@ void CNpcEnemy::render() int W=m_actorGfx->getFrameWidth(m_animNo,m_frame); int H=m_actorGfx->getFrameHeight(m_animNo,m_frame); - renderPos.vx = Pos.vx - offset.vx /*+ ( scrnWidth >> 1 )*/ - ( W >> 1 ); - renderPos.vy = Pos.vy - offset.vy /*+ ( scrnHeight >> 1 )*/ - ( H >> 1 ); + renderPos.vx = Pos.vx - offset.vx; + renderPos.vy = Pos.vy - offset.vy - H; m_actorGfx->Render(renderPos,m_animNo,m_frame,m_reversed); } diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 6803fecec..7c3c9efaa 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -274,6 +274,7 @@ protected: NPC_MOVEMENT_CLAM_RETRACT, NPC_MOVEMENT_PARASITIC_WORM, NPC_MOVEMENT_STATIC_CYCLE_ANIM, + NPC_MOVEMENT_SHARK_MAN, }; enum NPC_MOVEMENT_MODIFIER_FUNC @@ -432,6 +433,7 @@ protected: // shark man functions + void processSharkManMovement( int _frames, s32 *moveX, s32 *moveY ); void processCloseSharkManAttack( int _frames ); // anemone functions diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 8df6083a7..97acddc62 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -740,7 +740,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = ANIM_SHARKMAN_IDLE1_, NPC_INIT_DEFAULT, NPC_SENSOR_GENERIC_USER_VISIBLE, - NPC_MOVEMENT_FIXED_PATH_WALK, + NPC_MOVEMENT_SHARK_MAN, NPC_MOVEMENT_MODIFIER_NONE, NPC_CLOSE_SHARK_MAN_ATTACK, NPC_TIMER_NONE, diff --git a/source/enemy/nshrkman.cpp b/source/enemy/nshrkman.cpp index df721cbfe..9d026c9aa 100644 --- a/source/enemy/nshrkman.cpp +++ b/source/enemy/nshrkman.cpp @@ -23,11 +23,96 @@ #include "player\player.h" #endif +#ifndef __UTILS_HEADER__ +#include "utils\utils.h" +#endif + #ifndef __ANIM_SHARKMAN_HEADER__ #include #endif +void CNpcEnemy::processSharkManMovement( int _frames, s32 *moveX, s32 *moveY ) +{ + if ( m_movementTimer > 0 ) + { + m_movementTimer -= _frames; + + if ( m_animNo == m_data[m_type].moveAnim ) + { + processGenericFixedPathWalk( _frames, moveX, moveY ); + } + + if ( !m_animPlaying ) + { + m_animPlaying = true; + m_frame = 0; + } + } + else + { + // change anim + + if ( m_animNo == m_data[m_type].moveAnim ) + { + u8 newAction = getRnd() % 5; + + switch( newAction ) + { + case 0: + { + m_movementTimer = GameState::getOneSecondInFrames() * 3; + m_animNo = ANIM_SHARKMAN_IDLE1_; + + break; + } + + case 1: + { + m_movementTimer = GameState::getOneSecondInFrames() * 8; + m_animNo = m_data[m_type].moveAnim; + + break; + } + + case 2: + { + m_movementTimer = GameState::getOneSecondInFrames() * 1; + m_animNo = ANIM_SHARKMAN_IDLE2_; + + break; + } + + case 3: + { + m_movementTimer = GameState::getOneSecondInFrames() >> 1; + m_animNo = ANIM_SHARKMAN_KICK_SAND; + + break; + } + + case 4: + { + m_movementTimer = GameState::getOneSecondInFrames() * 3; + m_animNo = ANIM_SHARKMAN_PUSHUPS; + + break; + } + } + } + else + { + // return to move anim + + m_movementTimer = GameState::getOneSecondInFrames() * 8; + m_animNo = m_data[m_type].moveAnim; + } + + m_animPlaying = true; + m_frame = 0; + } +} + void CNpcEnemy::processCloseSharkManAttack( int _frames ) { s32 moveX = 0, moveY = 0; @@ -95,6 +180,7 @@ void CNpcEnemy::processCloseSharkManAttack( int _frames ) m_timerFunc = NPC_TIMER_ATTACK_DONE; m_timerTimer = GameState::getOneSecondInFrames(); m_sensorFunc = NPC_SENSOR_NONE; + m_animNo = m_data[m_type].moveAnim; } else { @@ -123,5 +209,6 @@ void CNpcEnemy::processCloseSharkManAttack( int _frames ) else { m_controlFunc = NPC_CONTROL_MOVEMENT; + m_animNo = m_data[m_type].moveAnim; } }