From 02eafd0a4653ae597026669aa4b1ddf99aa5c71c Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 27 Apr 2001 15:09:10 +0000 Subject: [PATCH] --- Graphics/characters/Squidward/AnimList.Txt | 3 + data/DataCache.scr | 2 + makefile.gaz | 5 +- makefile.gfx | 2 +- source/enemy/npc.cpp | 128 +----------------- source/enemy/npc.h | 71 ---------- source/enemy/npcdata.cpp | 31 ----- source/friend/fdata.cpp | 18 ++- source/friend/fgary.cpp | 8 +- source/friend/friend.cpp | 63 +++++++-- source/friend/friend.h | 13 +- source/friend/fsquid.h | 25 ++++ source/game/game.cpp | 12 ++ tools/MapEdit/actor.ini | 16 +-- .../spongebob project/spongebob project.dsp | 36 ++++- 15 files changed, 160 insertions(+), 273 deletions(-) create mode 100644 source/friend/fsquid.h diff --git a/Graphics/characters/Squidward/AnimList.Txt b/Graphics/characters/Squidward/AnimList.Txt index e69de29bb..c24eec988 100644 --- a/Graphics/characters/Squidward/AnimList.Txt +++ b/Graphics/characters/Squidward/AnimList.Txt @@ -0,0 +1,3 @@ +idlebreathe +idleShakeHead +idleTap \ No newline at end of file diff --git a/data/DataCache.scr b/data/DataCache.scr index e22b96f2c..bedb6a7b2 100644 --- a/data/DataCache.scr +++ b/data/DataCache.scr @@ -143,6 +143,8 @@ LEVELS/FMA_SHADYEXTERIOR.Tex actors/SPONGEBOB.SBK +actors/SQUIDWARD.SBK + actors/ANENOME.SBK actors/BABYOCTOPUS.SBK actors/BALLBLOB.SBK diff --git a/makefile.gaz b/makefile.gaz index 2f36beb2e..1a42a4ea6 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -72,7 +72,6 @@ enemy_src := npc \ nocto \ nfskull \ nsklfish \ - ngary \ nworm \ nhcrab \ nbblob \ @@ -82,6 +81,10 @@ enemy_src := npc \ ndustdev \ npbug +friend_src := friend \ + fdata \ + fgary + platform_src := platform \ platdata \ plinear \ diff --git a/makefile.gfx b/makefile.gfx index 182dbc1dc..440836c20 100644 --- a/makefile.gfx +++ b/makefile.gfx @@ -107,7 +107,7 @@ ACTOR_MAKEFILE_DIR := $(TEMP_BUILD_DIR)/actor ACTOR_DIRS_TO_MAKE := $(ACTOR_MAKEFILE_DIR) $(ACTOR_OUT_DIR) ACTOR_SPONGEBOB := SPONGEBOB -ACTOR_NPC := +ACTOR_NPC := Squidward # BarnacleBoy Gary Krusty MermaidMan Patrick Plankton Sandy Squidward ACTOR_ENEMY := Anenome BabyOctopus Ballblob Caterpillar clam Dustdevil Eyeball \ diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index deddad135..8a47a2f3e 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -41,7 +41,6 @@ #include "game\convo.h" #endif - #include "Gfx\actor.h" #ifndef __VID_HEADER_ @@ -179,131 +178,6 @@ #endif -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Friend NPCs -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcFriend::init() -{ - CNpcThing::init(); - - Pos.vx = 100; - Pos.vy = 100; - - m_extension = EXTEND_RIGHT; - - // temporary - m_actorGfx=CActorPool::GetActor(ACTORS_CLAM_SBK); - - //m_animPlaying = true; - m_animNo = 0; - m_frame = 0; - m_reversed = false; - - DVECTOR ofs = getCollisionSize(); - - m_drawOffset.vx = 0; - m_drawOffset.vy = -( ofs.vy >> 1 ); - - setCollisionCentreOffset( 0, -( ofs.vy >> 1 ) ); - - //m_spriteBank=new ("enemy sprites") SpriteBank(); - //m_spriteBank->load(UI_UIGFX_SPR); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcFriend::shutdown() -{ - //m_spriteBank->dump(); delete m_spriteBank; - - delete m_actorGfx; - CNpcThing::shutdown(); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcFriend::think(int _frames) -{ - CNpcThing::think(_frames); - - switch( m_data[m_type].movementFunc ) - { - case NPC_FRIEND_MOVEMENT_GARY: - processGaryMovement( _frames ); - - break; - - case NPC_FRIEND_MOVEMENT_STATIC: - default: - break; - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcFriend::render() -{ - CNpcThing::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() ) - { - m_actorGfx->Render(renderPos,m_animNo,m_frame,m_reversed); - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcFriend::processEvent( GAME_EVENT evt, CThing *sourceThing ) -{ - switch( evt ) - { - case USER_REQUEST_TALK_EVENT: - { - if ( m_data[this->m_type].canTalk ) - { - DVECTOR sourcePos; - s32 xDiffSqr, yDiffSqr; - - // check talk distance - - sourcePos = sourceThing->getPos(); - - xDiffSqr = this->Pos.vx - sourcePos.vx; - xDiffSqr *= xDiffSqr; - - yDiffSqr = this->Pos.vy - sourcePos.vy; - yDiffSqr *= yDiffSqr; - - if ( xDiffSqr + yDiffSqr < 10000 ) - { - if( !CConversation::isActive() ) - { - CConversation::trigger( SCRIPTS_SPEECHTEST_DAT ); - } - } - } - - break; - } - - default: - // ignore - - break; - } -} - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Enemy NPCs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -313,7 +187,6 @@ s32 CNpcEnemy::playerYDist; s32 CNpcEnemy::playerXDistSqr; s32 CNpcEnemy::playerYDistSqr; -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// CNpcEnemy::NPC_UNIT_TYPE CNpcEnemy::getTypeFromMapEdit( u16 newType ) @@ -322,6 +195,7 @@ CNpcEnemy::NPC_UNIT_TYPE CNpcEnemy::getTypeFromMapEdit( u16 newType ) } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + CNpcEnemy *CNpcEnemy::Create(sThingActor *ThisActor) { CNpcEnemy *enemy; diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 754a7d140..139187370 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -37,77 +37,6 @@ /*****************************************************************************/ -class CNpcFriend : public CNpcThing -{ -public: - enum NPC_FRIEND_UNIT_TYPE - { - NPC_FRIEND_SANDY_CHEEKS = 0, - NPC_FRIEND_GARY = 1, - NPC_FRIEND_UNIT_TYPE_MAX, - }; - - void init(); - void shutdown(); - void think(int _frames); - void render(); - void processEvent( GAME_EVENT evt, CThing *sourceThing ); - void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} - void setType( NPC_FRIEND_UNIT_TYPE newType ) {m_type = newType;} - -private: - class CLayerCollision *m_layerCollision; - -protected: - enum NPC_FRIEND_MOVEMENT_FUNC - { - NPC_FRIEND_MOVEMENT_STATIC = 0, - NPC_FRIEND_MOVEMENT_GARY = 1, - }; - - typedef struct NPC_FRIEND_DATA_TYPE - { - //NPC_FRIEND_INIT_FUNC initFunc; - //NPC_FRIEND_SENSOR_FUNC sensorFunc; - NPC_FRIEND_MOVEMENT_FUNC movementFunc; - //NPC_FRIEND_CLOSE_FUNC closeFunc; - //NPC_FRIEND_TIMER_FUNC timerFunc; - bool canTalk; - u8 speed; - u16 turnSpeed; - bool detectCollision; - DAMAGE_TYPE damageToUserType; - } - NPC_FRIEND_DATA; - - // gary functions - - void processGaryMovement( int _frames ); - - // data - - static NPC_FRIEND_DATA m_data[NPC_FRIEND_UNIT_TYPE_MAX]; - -// class SpriteBank *m_spriteBank; - - enum - { - EXTEND_RIGHT = true, - EXTEND_LEFT = false, - }; - - // internal variables - - NPC_FRIEND_UNIT_TYPE m_type; - s32 m_extension; - - int m_frame; - int m_animNo; - CActorGfx *m_actorGfx; - DVECTOR m_drawOffset; - bool m_reversed; -}; - class CNpcEnemy : public CEnemyThing { public: diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index cf9a8acf9..ec4d7db09 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -108,37 +108,6 @@ //#endif -CNpcFriend::NPC_FRIEND_DATA CNpcFriend::m_data[NPC_FRIEND_UNIT_TYPE_MAX] = -{ - { // NPC_SANDY_CHEEKS - //NPC_FRIEND_INIT_DEFAULT, - //NPC_FRIEND_SENSOR_NONE, - NPC_FRIEND_MOVEMENT_STATIC, - //NPC_FRIEND_MOVEMENT_MODIFIER_NONE, - //NPC_FRIEND_CLOSE_NONE, - //NPC_FRIEND_TIMER_NONE, - true, - 3, - 128, - false, - DAMAGE__HIT_ENEMY, - }, - - { // NPC_GARY - //NPC_FRIEND_INIT_DEFAULT, - //NPC_FRIEND_SENSOR_NONE, - NPC_FRIEND_MOVEMENT_GARY, - //NPC_FRIEND_MOVEMENT_MODIFIER_NONE, - //NPC_FRIEND_CLOSE_NONE, - //NPC_FRIEND_TIMER_NONE, - false, - 3, - 2048, - false, - DAMAGE__HIT_ENEMY, - }, -}; - CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = { /*{ // NPC_FALLING_ITEM diff --git a/source/friend/fdata.cpp b/source/friend/fdata.cpp index a0148ea83..a544c80db 100644 --- a/source/friend/fdata.cpp +++ b/source/friend/fdata.cpp @@ -15,76 +15,80 @@ #include "friend\friend.h" #endif +#ifndef __ANIM_SQUIDWARD_HEADER__ +#include +#endif + CNpcFriend::NPC_FRIEND_DATA CNpcFriend::m_data[NPC_FRIEND_UNIT_TYPE_MAX] = { { // NPC_FRIEND_BARNACLE_BOY ACTORS_CLAM_SBK, - NPC_FRIEND_MOVEMENT_STATIC, true, 3, 128, false, DAMAGE__HIT_ENEMY, + 0, }, { // NPC_FRIEND_GARY ACTORS_CLAM_SBK, - NPC_FRIEND_MOVEMENT_STATIC, true, 3, 128, false, DAMAGE__HIT_ENEMY, + 0, }, { // NPC_FRIEND_KRUSTY ACTORS_CLAM_SBK, - NPC_FRIEND_MOVEMENT_STATIC, true, 3, 128, false, DAMAGE__HIT_ENEMY, + 0, }, { // NPC_FRIEND_MERMAID_MAN ACTORS_CLAM_SBK, - NPC_FRIEND_MOVEMENT_STATIC, true, 3, 128, false, DAMAGE__HIT_ENEMY, + 0, }, { // NPC_FRIEND_PATRICK ACTORS_CLAM_SBK, - NPC_FRIEND_MOVEMENT_STATIC, true, 3, 128, false, DAMAGE__HIT_ENEMY, + 0, }, { // NPC_FRIEND_SANDY_CHEEKS ACTORS_CLAM_SBK, - NPC_FRIEND_MOVEMENT_STATIC, true, 3, 128, false, DAMAGE__HIT_ENEMY, + 0, }, { // NPC_FRIEND_SQUIDWARD ACTORS_SQUIDWARD_SBK, - NPC_FRIEND_MOVEMENT_STATIC, true, 3, 128, false, DAMAGE__HIT_ENEMY, + ANIM_SQUIDWARD_IDLEBREATHE, }, }; diff --git a/source/friend/fgary.cpp b/source/friend/fgary.cpp index 41628fdea..0fe729dc7 100644 --- a/source/friend/fgary.cpp +++ b/source/friend/fgary.cpp @@ -11,8 +11,8 @@ ===========================================================================*/ -#ifndef __FRIEND_FRIEND_H__ -#include "friend\friend.h" +#ifndef __FRIEND_FGARY_H__ +#include "friend\fgary.h" #endif #ifndef __GAME_GAME_H__ @@ -20,8 +20,10 @@ #endif -void CNpcFriend::processGaryMovement( int _frames ) +void CNpcGaryFriend::think( int _frames ) { + CNpcThing::think(_frames); + s8 multiplier = -1 + ( 2 * m_extension ); s32 maxHeight = 20; s32 fallSpeed = 3; diff --git a/source/friend/friend.cpp b/source/friend/friend.cpp index 316422ee8..7b8475938 100644 --- a/source/friend/friend.cpp +++ b/source/friend/friend.cpp @@ -31,6 +31,10 @@ #include "utils\utils.h" #endif +#ifndef __FRIEND_FSQUID_H__ +#include "friend\fsquid.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Friend NPCs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -45,7 +49,7 @@ CNpcFriend *CNpcFriend::Create(sThingActor *ThisActor) { case CNpcFriend::NPC_FRIEND_SQUIDWARD: { - friendNpc = new ("squidward") CNpcFriend; + friendNpc = new ("squidward") CNpcSquidwardFriend; break; } @@ -97,8 +101,8 @@ void CNpcFriend::init() m_actorGfx = CActorPool::GetActor( (FileEquate) m_data[m_type].skelType ); - //m_animPlaying = true; - m_animNo = 0; + m_animPlaying = true; + m_animNo = m_data[m_type].idleAnim; m_frame = 0; m_reversed = false; @@ -134,16 +138,53 @@ void CNpcFriend::think(int _frames) { CNpcThing::think(_frames); - switch( m_data[m_type].movementFunc ) + if ( m_animPlaying ) { - case NPC_FRIEND_MOVEMENT_GARY: - processGaryMovement( _frames ); + s32 frameCount; - break; + frameCount = m_actorGfx->getFrameCount( m_animNo ); - case NPC_FRIEND_MOVEMENT_STATIC: - default: - break; + s32 frameShift = ( _frames << 8 ) >> 1; + + if ( ( frameCount << 8 ) - m_frame > frameShift ) + { + m_frame += frameShift; + } + else + { + m_frame = ( frameCount - 1 ) << 8; + m_animPlaying = false; + } + } + + s32 fallSpeed = 3; + s8 yMovement = fallSpeed * _frames; + s8 groundHeight; + + // check vertical collision + + groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + + if ( groundHeight <= 0 ) + { + // make sure we are on the ground, not below it + + Pos.vy += groundHeight; + } + else + { + // above ground + + if ( groundHeight < yMovement ) + { + // colliding with ground + + Pos.vy += groundHeight; + } + else + { + Pos.vy += yMovement; + } } } @@ -164,7 +205,7 @@ void CNpcFriend::render() { if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() ) { - m_actorGfx->Render(renderPos,m_animNo,m_frame,m_reversed); + m_actorGfx->Render(renderPos,m_animNo,(m_frame>>8),m_reversed); } } } diff --git a/source/friend/friend.h b/source/friend/friend.h index fcdb7a616..a91dbe837 100644 --- a/source/friend/friend.h +++ b/source/friend/friend.h @@ -40,7 +40,7 @@ public: void init(); void init( DVECTOR initPos ); void shutdown(); - void think(int _frames); + virtual void think(int _frames); void render(); void processEvent( GAME_EVENT evt, CThing *sourceThing ); void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} @@ -49,25 +49,19 @@ public: static CNpcFriend *Create(sThingActor *ThisActor); static NPC_FRIEND_UNIT_TYPE getTypeFromMapEdit( u16 newType ); -private: +protected: class CLayerCollision *m_layerCollision; protected: - enum NPC_FRIEND_MOVEMENT_FUNC - { - NPC_FRIEND_MOVEMENT_STATIC = 0, - NPC_FRIEND_MOVEMENT_GARY = 1, - }; - typedef struct NPC_FRIEND_DATA_TYPE { int skelType; - NPC_FRIEND_MOVEMENT_FUNC movementFunc; bool canTalk; u8 speed; u16 turnSpeed; bool detectCollision; DAMAGE_TYPE damageToUserType; + u16 idleAnim; } NPC_FRIEND_DATA; @@ -96,6 +90,7 @@ protected: int m_frame; int m_animNo; + u8 m_animPlaying; CActorGfx *m_actorGfx; DVECTOR m_drawOffset; bool m_reversed; diff --git a/source/friend/fsquid.h b/source/friend/fsquid.h new file mode 100644 index 000000000..02bbb3100 --- /dev/null +++ b/source/friend/fsquid.h @@ -0,0 +1,25 @@ +/*========================================================================= + + fsquid.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + +#ifndef __FRIEND_FSQUID_H__ +#define __FRIEND_FSQUID_H__ + +#ifndef __FRIEND_FRIEND_H__ +#include "friend\friend.h" +#endif + +class CNpcSquidwardFriend : public CNpcFriend +{ +}; + +#endif \ No newline at end of file diff --git a/source/game/game.cpp b/source/game/game.cpp index f93803bba..8aca96793 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -27,6 +27,10 @@ #include "enemy\npc.h" #endif +#ifndef __FRIEND_FRIEND_H__ +#include "friend\friend.h" +#endif + #ifndef __PLATFORM_PLATFORM_H__ #include "platform\platform.h" #endif @@ -322,6 +326,14 @@ void CGameScene::initLevel() } break; + case CGameScene::ACTOR_FRIEND_NPC: + { + CNpcFriend *friendNpc; + friendNpc=CNpcFriend::Create(ThisActor); + friendNpc->setLayerCollision( Level.getCollisionLayer() ); + } + break; + default: break; } diff --git a/tools/MapEdit/actor.ini b/tools/MapEdit/actor.ini index 63b38e3dc..22815e9e9 100644 --- a/tools/MapEdit/actor.ini +++ b/tools/MapEdit/actor.ini @@ -75,14 +75,14 @@ Player=1 #Health=0 #AttackStrength=0 -#[Squidward] -#Gfx=..\..\graphics\characters\ -#WayPoints=0 -#Speed=0 -#TurnRate=0 -#Collision=0 -#Health=0 -#AttackStrength=0 +[Squidward] +Gfx=..\..\graphics\characters\Squidward\render\psx\Squidward_idlebreathe0000.bmp +WayPoints=0 +Speed=0 +TurnRate=0 +Collision=0 +Health=0 +AttackStrength=0 #[Plankton] #Gfx=..\..\graphics\characters\ diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index 218b63918..58db81575 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -193,10 +193,6 @@ SOURCE=..\..\..\source\enemy\nfskull.h # End Source File # Begin Source File -SOURCE=..\..\..\source\enemy\ngary.cpp -# End Source File -# Begin Source File - SOURCE=..\..\..\source\enemy\ngen.cpp # End Source File # Begin Source File @@ -1544,6 +1540,34 @@ SOURCE=..\..\..\source\map\map.cpp SOURCE=..\..\..\source\map\map.h # End Source File # End Group +# Begin Group "friend" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\..\source\friend\fdata.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\friend\fgary.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\friend\fgary.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\friend\friend.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\friend\friend.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\friend\fsquid.h +# End Source File +# End Group # End Group # Begin Group "makefiles" @@ -1708,6 +1732,10 @@ SOURCE=..\..\..\out\USA\include\ACTOR_SQUIDDART_Anim.h # End Source File # Begin Source File +SOURCE=..\..\..\out\USA\include\ACTOR_SQUIDWARD_Anim.h +# End Source File +# Begin Source File + SOURCE=..\..\..\out\USA\include\ACTOR_STOMPER_Anim.h # End Source File # Begin Source File