From 4807987d3772db53799b21f808aaa99207264f27 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 3 Apr 2001 18:32:24 +0000 Subject: [PATCH] --- makefile.gaz | 3 +- source/enemy/nbblob.cpp | 119 ++++++++++++++++++ source/enemy/npc.cpp | 9 +- source/enemy/npc.h | 5 + source/enemy/npcdata.cpp | 2 +- source/enemy/npcpath.cpp | 6 + .../spongebob project/spongebob project.dsp | 4 + 7 files changed, 145 insertions(+), 3 deletions(-) diff --git a/makefile.gaz b/makefile.gaz index 072c4460c..032740120 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -76,7 +76,8 @@ enemy_src := npc \ ngary \ nplatfrm \ nworm \ - nhcrab + nhcrab \ + nbblob projectl_src := projectl diff --git a/source/enemy/nbblob.cpp b/source/enemy/nbblob.cpp index 0feb71180..8b08a16a8 100644 --- a/source/enemy/nbblob.cpp +++ b/source/enemy/nbblob.cpp @@ -15,6 +15,125 @@ #include "enemy\npc.h" #endif +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + +#ifndef __ANIM_BALLBLOB_HEADER__ +#include +#endif + void CNpcEnemy::processBallBlobMovement( int _frames, s32 *moveX, s32 *moveY ) { + s32 waypointXDist; + s32 waypointYDist; + s32 waypointHeading; + + if ( !m_animPlaying && m_frame != 0 ) + { + m_animNo = ANIM_BALLBLOB_WOBBLE; + m_frame = 0; + } + else if ( m_animNo == ANIM_BALLBLOB_BOUNCE ) + { + *moveX = 0; + *moveY = 0; + + return; + } + + // deal with horizontal + + if ( m_npcPath.thinkFlat( Pos, &waypointXDist, &waypointYDist, &waypointHeading ) ) + { + // increment waypoint + + if ( waypointHeading == 0 ) + { + // head right + + if ( m_heading >= 1024 && m_heading <= 3072 ) + { + // currently heading in the wrong direction, reverse horizontal + + s32 headingDiff = m_heading - 2048; + + headingDiff = -headingDiff; + + headingDiff += 4096; + + m_heading = headingDiff % 4096; + + m_animPlaying = true; + m_animNo = ANIM_BALLBLOB_WOBBLE; + m_frame = 0; + } + } + else + { + // head left + + if ( m_heading < 1024 || m_heading > 3072 ) + { + // currently heading in the wrong direction, reverse horizontal + + s32 headingDiff = m_heading; + + headingDiff = -headingDiff; + + headingDiff += 6144; + + m_heading = headingDiff % 4096; + + m_animPlaying = true; + m_animNo = ANIM_BALLBLOB_WOBBLE; + m_frame = 0; + } + } + } + + s32 preShiftX = _frames * m_data[m_type].speed * rcos( m_heading ); + s32 preShiftY = _frames * m_data[m_type].speed * rsin( m_heading ); + + *moveX = preShiftX >> 12; + if ( !(*moveX) && preShiftX ) + { + *moveX = preShiftX / abs( preShiftX ); + } + + *moveY = preShiftY >> 12; + if ( !(*moveY) && preShiftY ) + { + *moveY = preShiftY / abs( preShiftY ); + } + + // deal with vertical + + if ( Pos.vy < 0 || m_layerCollision->Get( ( Pos.vx + *moveX ) >> 4, ( Pos.vy + *moveY ) >> 4 ) ) + { + // reflect heading in vertical + + m_heading = 4096 - m_heading; + + m_animPlaying = true; + m_animNo = ANIM_BALLBLOB_BOUNCE; + m_frame = 0; + + // get new movement values + + preShiftX = _frames * m_data[m_type].speed * rcos( m_heading ); + preShiftY = _frames * m_data[m_type].speed * rsin( m_heading ); + + *moveX = preShiftX >> 12; + if ( !(*moveX) && preShiftX ) + { + *moveX = preShiftX / abs( preShiftX ); + } + + *moveY = preShiftY >> 12; + if ( !(*moveY) && preShiftY ) + { + *moveY = preShiftY / abs( preShiftY ); + } + } } \ No newline at end of file diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 5c72c02c7..93d23fbae 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -235,7 +235,7 @@ void CNpcEnemy::init() m_animNo = m_data[m_type].initAnim; m_frame = 0; - m_heading = m_fireHeading = 0; + m_heading = m_fireHeading = 128; m_movementTimer = 0; m_timerTimer = 0; m_velocity = 0; @@ -1093,6 +1093,13 @@ void CNpcEnemy::processMovement(int _frames) break; } + case NPC_MOVEMENT_BALL_BLOB: + { + processBallBlobMovement( _frames, &moveX, &moveY ); + + break; + } + default: break; diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 08251612d..cc25d06c9 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -277,6 +277,7 @@ protected: NPC_MOVEMENT_PARASITIC_WORM, NPC_MOVEMENT_STATIC_CYCLE_ANIM, NPC_MOVEMENT_SHARK_MAN, + NPC_MOVEMENT_BALL_BLOB, }; enum NPC_MOVEMENT_MODIFIER_FUNC @@ -417,6 +418,10 @@ protected: void processFishFolkMovementModifier( int _frames, s32 distX, s32 distY ); + // ball blob functions + + void processBallBlobMovement( int _frames, s32 *moveX, s32 *moveY ); + // clam functions void processCloseClamJumpAttack( int _frames ); diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index b18be259f..d0cd13d37 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -906,7 +906,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = ANIM_BALLBLOB_WOBBLE, NPC_INIT_DEFAULT, NPC_SENSOR_NONE, - NPC_MOVEMENT_FIXED_PATH, + NPC_MOVEMENT_BALL_BLOB, NPC_MOVEMENT_MODIFIER_NONE, NPC_CLOSE_NONE, NPC_TIMER_NONE, diff --git a/source/enemy/npcpath.cpp b/source/enemy/npcpath.cpp index 0fd5bd315..560694369 100644 --- a/source/enemy/npcpath.cpp +++ b/source/enemy/npcpath.cpp @@ -224,6 +224,9 @@ s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChang { *pathComplete = incPath(); *waypointChange = true; + + xDist = currentWaypoint->pos.vx - currentPos.vx; + yDist = currentWaypoint->pos.vy - currentPos.vy; } s32 headingToTarget = ratan2( yDist, xDist ); @@ -256,6 +259,9 @@ bool CNpcPath::thinkFlat( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *headi incPath(); } + *distX = currentWaypoint->pos.vx - currentPos.vx; + *distY = currentWaypoint->pos.vy - currentPos.vy; + if ( *distX > 0 ) { *heading = 0; diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index c01a71966..fdfffd9d5 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -113,6 +113,10 @@ SOURCE=..\..\..\source\enemy\nanemone.cpp # End Source File # Begin Source File +SOURCE=..\..\..\source\enemy\nbblob.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\source\enemy\nbooger.cpp # End Source File # Begin Source File