From 4a1605fe92f4938315dd3d17b294525d4aa4b15a Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 4 May 2001 13:45:55 +0000 Subject: [PATCH] --- Graphics/characters/SeaSnake/AnimList.Txt | 2 + data/DataCache.scr | 3 +- makefile.gfx | 2 +- source/enemy/npcdata.cpp | 19 +- source/enemy/nworm.cpp | 235 +++++++++++++++--- source/enemy/nworm.h | 10 +- tools/MapEdit/actor.ini | 32 +-- .../spongebob project/spongebob project.dsp | 4 + 8 files changed, 242 insertions(+), 65 deletions(-) diff --git a/Graphics/characters/SeaSnake/AnimList.Txt b/Graphics/characters/SeaSnake/AnimList.Txt index e69de29bb..8a29b5cbd 100644 --- a/Graphics/characters/SeaSnake/AnimList.Txt +++ b/Graphics/characters/SeaSnake/AnimList.Txt @@ -0,0 +1,2 @@ +bodystatic +headstatic \ No newline at end of file diff --git a/data/DataCache.scr b/data/DataCache.scr index ae259707b..4bc414f2b 100644 --- a/data/DataCache.scr +++ b/data/DataCache.scr @@ -188,4 +188,5 @@ actors/SPIKEYANENOME.SBK actors/STOMPER.SBK actors/SHARKSUB.SBK -actors/MOTHERJELLYFISH.SBK \ No newline at end of file +actors/MOTHERJELLYFISH.SBK +actors/SEASNAKE.SBK \ No newline at end of file diff --git a/makefile.gfx b/makefile.gfx index de8568971..2023b168f 100644 --- a/makefile.gfx +++ b/makefile.gfx @@ -113,7 +113,7 @@ ACTOR_NPC := BarnacleBoy Krusty Squidward Gary Sandy Patrick MermaidMan ACTOR_ENEMY := Anenome BabyOctopus Ballblob Caterpillar clam Dustdevil Eyeball \ Flamingskull FlyingDutchman Ghost HermitCrab IronDogFish Lrgjellyfish \ PuffaFish Sharkman Skeletalfish SpiderCrab SpikeyAnenome Stomper \ - SharkSub Motherjellyfish + SharkSub Motherjellyfish SeaSnake # Boogermonster GiantWorm Jellyfish2 Motherjellyfish Nautilus Neptune SeaSnake SharkSub diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index dbaa4e9bb..57ebce3a9 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -107,6 +107,10 @@ #include #endif +#ifndef __ANIM_SEASNAKE_HEADER__ +#include +#endif + CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = { @@ -815,8 +819,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = }, { // NPC_PARASITIC_WORM - ACTORS_CLAM_SBK, - ANIM_CLAM_SIDESNAP, + ACTORS_SEASNAKE_SBK, + ANIM_SEASNAKE_HEADSTATIC, NPC_SENSOR_USER_CLOSE, NPC_MOVEMENT_STATIC, NPC_CLOSE_NONE, @@ -881,8 +885,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = }, { // NPC_PARASITIC_WORM_SEGMENT - ACTORS_CLAM_SBK, - ANIM_CLAM_SIDESNAP, + ACTORS_SEASNAKE_SBK, + ANIM_SEASNAKE_BODYSTATIC, NPC_SENSOR_NONE, NPC_MOVEMENT_STATIC, NPC_CLOSE_NONE, @@ -979,11 +983,8 @@ CNpcEnemy::NPC_UNIT_TYPE CNpcEnemy::mapEditConvertTable[NPC_UNIT_TYPE_MAX] = NPC_DUST_DEVIL, NPC_SPIDER_CRAB_SPAWNER, NPC_SHELL, - //NPC_FALLING_ITEM, - //NPC_FISH_HOOK, - //NPC_PENDULUM, - //NPC_FIREBALL, - //NPC_SAW_BLADE, + + // NPC_FISH_FOLK, NPC_ANGLER_FISH, NPC_MINE, diff --git a/source/enemy/nworm.cpp b/source/enemy/nworm.cpp index de836a963..6db752d49 100644 --- a/source/enemy/nworm.cpp +++ b/source/enemy/nworm.cpp @@ -27,35 +27,15 @@ #include "player\player.h" #endif +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcParasiticWormEnemy::postInit() { - DVECTOR newPos; - - newPos.vx = 100; - //newPos.vy = 10; - newPos.vy = 100; - - m_npcPath.addWaypoint( newPos ); - - newPos.vx = 500; - //newPos.vy = 10; - newPos.vy = 100; - - m_npcPath.addWaypoint( newPos ); - - newPos.vx = 500; - //newPos.vy = 100; - newPos.vy = 300; - - m_npcPath.addWaypoint( newPos ); - - newPos.vx = 100; - //newPos.vy = 100; - newPos.vy = 300; - - m_npcPath.addWaypoint( newPos ); - - m_npcPath.setPathType( CNpcPath::PONG_PATH ); + m_npcPath.setPathType( CNpcPath::REPEATING_PATH ); // create start of list CNpcPositionHistory *newPosition; @@ -83,14 +63,39 @@ void CNpcParasiticWormEnemy::postInit() currentPosition->next = m_positionHistory; m_positionHistory->prev = currentPosition; + u16 segScale; + int initLength = NPC_PARASITIC_WORM_LENGTH / 3; + int remLength = NPC_PARASITIC_WORM_LENGTH - initLength; + for ( int segCount = 0 ; segCount < NPC_PARASITIC_WORM_LENGTH ; segCount++ ) { CNpcEnemy *segment; - segment = new ("segment") CNpcParasiticWormSegment; - segment->setType( CNpcEnemy::NPC_PARASITIC_WORM_SEGMENT ); - segment->init(); - segment->setLayerCollision( m_layerCollision ); - segment->postInit(); + CNpcParasiticWormSegment *wormSegment; + wormSegment = new ("segment") CNpcParasiticWormSegment; + wormSegment->setType( CNpcEnemy::NPC_PARASITIC_WORM_SEGMENT ); + wormSegment->init(); + wormSegment->setLayerCollision( m_layerCollision ); + wormSegment->postInit(); + + if ( segCount < initLength ) + { + u16 sum = ONE; + u16 start = ONE >> 1; + u16 end = sum - start; + + segScale = start + ( ( end * segCount ) / initLength ); + } + else + { + u16 sum = ONE; + u16 start = ONE >> 3; + u16 end = sum - start; + + segScale = start + ( ( end * ( NPC_PARASITIC_WORM_LENGTH - segCount ) ) / remLength ); + } + + wormSegment->setScale( segScale ); + segment = wormSegment; this->addChild( segment ); } @@ -98,19 +103,31 @@ void CNpcParasiticWormEnemy::postInit() m_movementTimer = 2 * GameState::getOneSecondInFrames(); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcParasiticWormEnemy::shutdown() { deleteAllChild(); CNpcEnemy::shutdown(); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcParasiticWormSegment::think( int _frames ) +{ +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcParasiticWormSegment::postInit() { } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool CNpcParasiticWormEnemy::processSensor() { - if ( playerXDistSqr + playerYDistSqr < 40000 ) + /*if ( playerXDistSqr + playerYDistSqr < 40000 ) { m_controlFunc = NPC_CONTROL_CLOSE; @@ -119,9 +136,13 @@ bool CNpcParasiticWormEnemy::processSensor() else { return( false ); - } + }*/ + + return( false ); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcParasiticWormEnemy::processMovement( int _frames ) { s32 moveX = 0, moveY = 0; @@ -177,17 +198,17 @@ void CNpcParasiticWormEnemy::processMovement( int _frames ) s16 headingToTarget = ratan2( yDist, xDist ); - segment->setHeading( headingToTarget ); + //segment->setHeading( headingToTarget ); DVECTOR sinPos; sinPos = newPos->pos; - s32 diff = ( ( ( 10 >> downShift ) * rsin( extension ) ) >> 12 ) >> timeShift; + s32 diff = ( ( ( 5 >> downShift ) * rsin( extension ) ) >> 12 ) >> timeShift; sinPos.vx += ( diff * rcos( headingToTarget + 1024 ) ) >> 12; sinPos.vy += ( diff * rsin( headingToTarget + 1024 ) ) >> 12; List->setPos( sinPos ); - oldPos = newPos->pos; + oldPos = sinPos; List = List->getNext(); @@ -207,8 +228,68 @@ void CNpcParasiticWormEnemy::processMovement( int _frames ) downShift--; } } + + List=Next; + + oldPos = Pos; + + while( List ) + { + CNpcEnemy *segment = (CNpcEnemy *) List; + DVECTOR currentPos = segment->getPos(); + + s32 xDist = oldPos.vx - currentPos.vx; + s32 yDist = oldPos.vy - currentPos.vy; + + s16 headingToPrev = ratan2( yDist, xDist ); + s16 headingFromNext; + s16 heading = headingToPrev; + + oldPos = currentPos; + + List = List->getNext(); + + if ( List ) + { + DVECTOR nextPos = List->getPos(); + xDist = currentPos.vx - nextPos.vx; + yDist = currentPos.vy - nextPos.vy; + headingFromNext = ratan2( yDist, xDist ); + + s16 decDir, incDir, moveDist; + + decDir = headingFromNext - headingToPrev; + + if ( decDir < 0 ) + { + decDir += ONE; + } + + incDir = headingToPrev - headingFromNext; + + if ( incDir < 0 ) + { + incDir += ONE; + } + + if ( decDir < incDir ) + { + moveDist = -decDir; + } + else + { + moveDist = incDir; + } + + heading -= moveDist >> 1; + } + + segment->setHeading( heading ); + } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcParasiticWormEnemy::resetParasiticWormHeadToTail() { DVECTOR startPos; @@ -281,6 +362,8 @@ void CNpcParasiticWormEnemy::resetParasiticWormHeadToTail() } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcParasiticWormEnemy::processClose( int _frames ) { resetParasiticWormHeadToTail(); @@ -293,3 +376,81 @@ void CNpcParasiticWormEnemy::processClose( int _frames ) m_sensorFunc = NPC_SENSOR_NONE; } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcParasiticWormEnemy::processEnemyCollision( CThing *thisThing ) +{ + // do nothing +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcParasiticWormSegment::processEnemyCollision( CThing *thisThing ) +{ + // do nothing +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcParasiticWormEnemy::render() +{ + SprFrame = NULL; + + if ( m_isActive ) + { + CEnemyThing::render(); + + // Render + DVECTOR renderPos; + DVECTOR offset = CLevel::getCameraPos(); + + renderPos.vx = Pos.vx - offset.vx; + renderPos.vy = Pos.vy - offset.vy; + + if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() ) + { + if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() ) + { + SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); + m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, 4096 ); + + sBBox boundingBox = m_actorGfx->GetBBox(); + setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) ); + setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 ); + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcParasiticWormSegment::render() +{ + SprFrame = NULL; + + if ( m_isActive ) + { + CEnemyThing::render(); + + // Render + DVECTOR renderPos; + DVECTOR offset = CLevel::getCameraPos(); + + renderPos.vx = Pos.vx - offset.vx; + renderPos.vy = Pos.vy - offset.vy; + + if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() ) + { + if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() ) + { + SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); + m_actorGfx->RotateScale( SprFrame, renderPos, m_heading, 4096, m_scale ); + + sBBox boundingBox = m_actorGfx->GetBBox(); + setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) ); + setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 ); + } + } + } +} diff --git a/source/enemy/nworm.h b/source/enemy/nworm.h index 4e426fdaf..719752842 100644 --- a/source/enemy/nworm.h +++ b/source/enemy/nworm.h @@ -19,15 +19,17 @@ class CNpcParasiticWormEnemy : public CNpcEnemy public: virtual void postInit(); virtual void shutdown(); + virtual void render(); protected: virtual bool processSensor(); virtual void processClose( int _frames ); virtual void processMovement( int _frames ); void resetParasiticWormHeadToTail(); + virtual void processEnemyCollision( CThing *thisThing ); enum { - NPC_PARASITIC_WORM_SPACING = 6, + NPC_PARASITIC_WORM_SPACING = 4, NPC_PARASITIC_WORM_LENGTH = 10, }; }; @@ -35,7 +37,13 @@ protected: class CNpcParasiticWormSegment : public CNpcParasiticWormEnemy { public: + virtual void render(); + virtual void think( int _frames ); virtual void postInit(); + virtual void processEnemyCollision( CThing *thisThing ); + virtual void setScale( u16 scale ) {m_scale = scale;} + + u16 m_scale; }; #endif \ No newline at end of file diff --git a/tools/MapEdit/actor.ini b/tools/MapEdit/actor.ini index 90693b4c4..ed15659d6 100644 --- a/tools/MapEdit/actor.ini +++ b/tools/MapEdit/actor.ini @@ -243,14 +243,14 @@ Collision=0 Health=0 AttackStrength=20 -#[GiantWorm] -#Gfx=..\..\graphics\characters\ -#WayPoints=16 -#Speed=3 -#TurnRate=128 -#Collision=0 -#Health=256 -#AttackStrength=0 +[GiantWorm] +Gfx=..\..\graphics\characters\seasnake\render\psx\seasnake_headstatic0000.bmp +WayPoints=16 +Speed=3 +TurnRate=128 +Collision=0 +Health=256 +AttackStrength=0 [HermitCrab] Gfx=..\..\graphics\characters\hermitcrab\render\psx\hermitcrab_idle0001.bmp @@ -280,14 +280,14 @@ Collision=0 Health=64 AttackStrength=20 -#[SeaSnake] -#Gfx=..\..\graphics\characters\seasnake\render\psx\seasnake_headstatic0000.bmp -#WayPoints=16 -#Speed=3 -#TurnRate=256 -#Collision=0 -#Health=56 -#AttackStrength=20 +[SeaSnake] +Gfx=..\..\graphics\characters\seasnake\render\psx\seasnake_headstatic0000.bmp +WayPoints=16 +Speed=3 +TurnRate=256 +Collision=0 +Health=56 +AttackStrength=20 [Sharkman] Gfx=..\..\graphics\characters\sharkman\render\psx\SharkMan_Idle1_0001.bmp diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index 7f60c616c..937aa5adb 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -1928,6 +1928,10 @@ SOURCE=..\..\..\out\USA\include\ACTOR_SANDY_Anim.h # End Source File # Begin Source File +SOURCE=..\..\..\out\USA\include\ACTOR_SEASNAKE_Anim.h +# End Source File +# Begin Source File + SOURCE=..\..\..\out\USA\include\ACTOR_SHARKMAN_Anim.h # End Source File # Begin Source File