diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp index 13922ecc1..9f5cdd6be 100644 --- a/source/enemy/nanemone.cpp +++ b/source/enemy/nanemone.cpp @@ -114,11 +114,11 @@ void CNpcEnemy::processCloseAnemone1Attack( int _frames ) m_heading += moveDist; - m_heading = m_heading % ONE; + m_heading &= 4095; if ( withinRange ) { - // can fire + // can fire, start firing anim if ( m_timerTimer <= 0 && !m_animPlaying ) { @@ -128,22 +128,40 @@ void CNpcEnemy::processCloseAnemone1Attack( int _frames ) m_animNo = ANIM_ANENOMELVL1_FIRE; m_frame = 0; } - else - { - CProjectile *projectile; - projectile = new( "test projectile" ) CProjectile; - projectile->init( Pos, m_heading ); - projectile->setLayerCollision( m_layerCollision ); + } + } + } + else + { + if ( !m_animPlaying || m_animNo != ANIM_ANENOMELVL1_BEND ) + { + m_animPlaying = true; + m_animNo = ANIM_ANENOMELVL1_BEND; + m_frame = 0; + } + } - m_controlFunc = NPC_CONTROL_MOVEMENT; - m_timerTimer = GameState::getOneSecondInFrames(); - m_timerFunc = NPC_TIMER_ATTACK_DONE; - m_sensorFunc = NPC_SENSOR_NONE; + if ( withinRange ) + { + if ( m_timerTimer <= 0 && !m_animPlaying ) + { + if ( m_animNo == ANIM_ANENOMELVL1_FIRE ) + { + // if firing anim is complete and user is still in range, fire projectile - m_animPlaying = true; - m_animNo = ANIM_ANENOMELVL1_BEND; - m_frame = 0; - } + CProjectile *projectile; + projectile = new( "test projectile" ) CProjectile; + projectile->init( Pos, m_heading ); + projectile->setLayerCollision( m_layerCollision ); + + m_controlFunc = NPC_CONTROL_MOVEMENT; + m_timerTimer = GameState::getOneSecondInFrames(); + m_timerFunc = NPC_TIMER_ATTACK_DONE; + m_sensorFunc = NPC_SENSOR_NONE; + + m_animPlaying = true; + m_animNo = ANIM_ANENOMELVL1_BEND; + m_frame = 0; } } } diff --git a/source/enemy/nbblob.cpp b/source/enemy/nbblob.cpp index 8b08a16a8..137582666 100644 --- a/source/enemy/nbblob.cpp +++ b/source/enemy/nbblob.cpp @@ -43,8 +43,10 @@ void CNpcEnemy::processBallBlobMovement( int _frames, s32 *moveX, s32 *moveY ) } // deal with horizontal + + bool pathComplete; - if ( m_npcPath.thinkFlat( Pos, &waypointXDist, &waypointYDist, &waypointHeading ) ) + if ( m_npcPath.thinkFlat( Pos, &pathComplete, &waypointXDist, &waypointYDist, &waypointHeading ) ) { // increment waypoint diff --git a/source/enemy/ngeneric.cpp b/source/enemy/ngeneric.cpp index 486482afd..81e7d9a36 100644 --- a/source/enemy/ngeneric.cpp +++ b/source/enemy/ngeneric.cpp @@ -240,7 +240,9 @@ void CNpcEnemy::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY // ignore y component of waypoint, since we are stuck to the ground - if ( m_npcPath.thinkFlat( Pos, &distX, &distY, &m_heading ) ) + bool pathComplete; + + if ( m_npcPath.thinkFlat( Pos, &pathComplete, &distX, &distY, &m_heading ) ) { // path has finished, waypoint has changed, or there are no waypoints - do not move horizontally diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 2dde1fd51..e1c61ee8e 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -1259,6 +1259,13 @@ void CNpcEnemy::processMovement(int _frames) break; } + case NPC_MOVEMENT_RETURNING_HAZARD_GROUND: + { + processReturningHazardMovementGround( _frames ); + + break; + } + case NPC_MOVEMENT_SHARK_MAN: { processSharkManMovement( _frames, &moveX, &moveY ); diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 7b7b24978..4492d8d29 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -291,6 +291,7 @@ protected: NPC_MOVEMENT_STATIC_CYCLE_ANIM, NPC_MOVEMENT_SHARK_MAN, NPC_MOVEMENT_BALL_BLOB, + NPC_MOVEMENT_RETURNING_HAZARD_GROUND, }; enum NPC_MOVEMENT_MODIFIER_FUNC @@ -566,6 +567,7 @@ protected: void processPendulumMovement( int _frames ); void processFireballMovement( int _frames ); void processReturningHazardMovement( int _frames ); + void processReturningHazardMovementGround( int _frames ); // data diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 571d74e0f..5c81af565 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -368,7 +368,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = ANIM_DUSTDEVIL_TWIST, NPC_INIT_RETURNING_HAZARD, NPC_SENSOR_NONE, - NPC_MOVEMENT_RETURNING_HAZARD, + NPC_MOVEMENT_RETURNING_HAZARD_GROUND, NPC_MOVEMENT_MODIFIER_NONE, NPC_CLOSE_NONE, NPC_TIMER_NONE, @@ -469,7 +469,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = NPC_CLOSE_JELLYFISH_EVADE, NPC_TIMER_NONE, false, - 3, + 2, 128, DETECT_ALL_COLLISION, DAMAGE__SHOCK_ENEMY, @@ -661,8 +661,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = NPC_CLOSE_NONE, NPC_TIMER_NONE, false, - 5, - 256, + 3, + 2048, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, 16, diff --git a/source/enemy/npcpath.cpp b/source/enemy/npcpath.cpp index d4d884006..e52d630e7 100644 --- a/source/enemy/npcpath.cpp +++ b/source/enemy/npcpath.cpp @@ -267,10 +267,12 @@ s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChang return( headingToTarget ); } -bool CNpcPath::thinkFlat( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *heading ) +bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ) { bool pointChange = false; + *pathComplete = false; + if ( !this->waypoint ) { return( true ); @@ -289,7 +291,7 @@ bool CNpcPath::thinkFlat( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *headi if ( abs( *distX ) < 10 ) { pointChange = true; - incPath(); + *pathComplete = incPath(); } *distX = currentWaypoint->pos.vx - currentPos.vx; @@ -311,6 +313,8 @@ bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX { bool pointChange = false; + *pathComplete = false; + if ( !this->waypoint ) { return( true ); @@ -326,8 +330,6 @@ bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX *distX = currentWaypoint->pos.vx - currentPos.vx; *distY = currentWaypoint->pos.vy - currentPos.vy; - *pathComplete = false; - if ( abs( *distY ) < 10 ) { pointChange = true; diff --git a/source/enemy/npcpath.h b/source/enemy/npcpath.h index d44d044cd..9242d357a 100644 --- a/source/enemy/npcpath.h +++ b/source/enemy/npcpath.h @@ -44,7 +44,7 @@ public: void resetPath(); void reversePathDir(); s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange ); - bool thinkFlat( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *heading ); + bool thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ); bool thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ); bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ); void getPathXExtents( s32 *minExtent, s32 *maxExtent ); diff --git a/source/enemy/nscrab.cpp b/source/enemy/nscrab.cpp index a54120faa..aa2dbcda4 100644 --- a/source/enemy/nscrab.cpp +++ b/source/enemy/nscrab.cpp @@ -122,7 +122,7 @@ void CNpcEnemy::processSpiderCrabCollision() { CPlayer *player = GameScene.getPlayer(); - //player->takeDamage( m_data[m_type].damageToUserType ); + player->takeDamage( m_data[m_type].damageToUserType ); m_animNo = ANIM_SPIDERCRAB_BITE; m_animPlaying = true; @@ -142,7 +142,7 @@ void CNpcEnemy::processSpiderCrabCollision() { CPlayer *player = GameScene.getPlayer(); - //player->takeDamage( m_data[m_type].damageToUserType ); + player->takeDamage( m_data[m_type].damageToUserType ); m_controlFunc = m_oldControlFunc; } diff --git a/source/enemy/nsjfish.cpp b/source/enemy/nsjfish.cpp index 7715b13cd..70a328bde 100644 --- a/source/enemy/nsjfish.cpp +++ b/source/enemy/nsjfish.cpp @@ -225,7 +225,7 @@ void CNpcEnemy::processCloseSmallJellyfishEvade( int _frames ) m_heading += moveDist; - m_heading = m_heading % ONE; + m_heading &= 4095; moveX = ( _frames * 3 * rcos( m_heading ) ) >> 12; moveY = ( _frames * 3 * rsin( m_heading ) ) >> 12; diff --git a/source/enemy/nsstomp.cpp b/source/enemy/nsstomp.cpp index 0dc915449..a4f4a5ce7 100644 --- a/source/enemy/nsstomp.cpp +++ b/source/enemy/nsstomp.cpp @@ -60,7 +60,7 @@ void CNpcEnemy::processCloseSkullStomperAttack( int _frames ) // pause and change direction - m_timerTimer = GameState::getOneSecondInFrames(); + m_timerTimer = 3 * GameState::getOneSecondInFrames(); m_extendDir = EXTEND_UP; } else