SBSPSS/source/enemy/npc.h

329 lines
7.9 KiB
C
Raw Normal View History

2001-01-16 22:56:29 +01:00
/*=========================================================================
npc.h
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
2001-01-16 20:35:34 +01:00
2001-01-18 20:18:39 +01:00
#ifndef __ENEMY_NPC_H__
#define __ENEMY_NPC_H__
2001-01-16 20:35:34 +01:00
//#include <dstructs.h>
2001-02-27 17:59:50 +01:00
#ifndef __THING_THING_H__
#include "thing/thing.h"
#endif
2001-04-01 22:22:49 +02:00
//#include "Gfx/Skel.h"
2001-01-16 20:35:34 +01:00
2001-01-18 20:18:39 +01:00
#ifndef __ENEMY_NPCPATH_H__
#include "enemy\npcpath.h"
#endif
2001-01-16 20:35:34 +01:00
2001-02-07 17:42:13 +01:00
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
2001-02-27 22:25:22 +01:00
#ifndef __GFX_SPRBANK_H__
#include "gfx\sprbank.h"
#endif
2001-01-16 20:35:34 +01:00
/*****************************************************************************/
2001-02-27 22:25:22 +01:00
class CNpcEnemy : public CEnemyThing
2001-01-16 20:35:34 +01:00
{
public:
enum NPC_UNIT_TYPE
{
2001-04-24 17:01:42 +02:00
NPC_DUST_DEVIL = 0,
NPC_SMALL_JELLYFISH_1 = 1,
2001-01-19 16:07:53 +01:00
NPC_SMALL_JELLYFISH_2,
2001-01-18 22:19:43 +01:00
NPC_ANEMONE_1,
2001-01-22 17:02:38 +01:00
NPC_ANEMONE_2,
2001-02-08 16:34:18 +01:00
NPC_ANEMONE_3,
2001-02-12 16:37:31 +01:00
NPC_SKELETAL_FISH,
2001-03-01 17:48:45 +01:00
NPC_CLAM_JUMP,
NPC_CLAM_STATIC,
2001-01-19 16:07:53 +01:00
NPC_SQUID_DART,
NPC_FISH_FOLK,
NPC_PRICKLY_BUG,
2001-03-26 18:44:45 +02:00
NPC_SEA_SNAKE,
2001-01-19 22:46:30 +01:00
NPC_PUFFA_FISH,
NPC_ANGLER_FISH,
NPC_HERMIT_CRAB,
NPC_BOOGER_MONSTER,
NPC_SPIDER_CRAB,
2001-04-19 01:12:24 +02:00
NPC_SPIDER_CRAB_SPAWNER,
2001-01-19 22:46:30 +01:00
NPC_EYEBALL,
NPC_BABY_OCTOPUS,
NPC_ZOMBIE_FISH_FOLK,
NPC_GHOST,
NPC_FLAMING_SKULL,
NPC_SHARK_MAN,
2001-01-23 18:03:27 +01:00
NPC_SKULL_STOMPER,
2001-01-25 16:45:15 +01:00
NPC_MOTHER_JELLYFISH,
2001-01-25 18:20:08 +01:00
NPC_SUB_SHARK,
2001-03-26 18:44:45 +02:00
NPC_PARASITIC_WORM,
2001-01-25 16:45:15 +01:00
NPC_FLYING_DUTCHMAN,
2001-01-25 20:57:29 +01:00
NPC_IRON_DOGFISH,
2001-04-02 21:21:46 +02:00
NPC_BALL_BLOB,
2001-04-27 23:12:31 +02:00
NPC_SHELL,
2001-05-04 22:11:44 +02:00
NPC_PROJECTILE_JELLYFISH,
2001-05-10 16:09:06 +02:00
NPC_SMALL_JELLYFISH_BACKGROUND,
2001-05-10 23:30:17 +02:00
NPC_SMALL_JELLYFISH_2_BACKGROUND,
2001-05-11 00:19:55 +02:00
NPC_BUTTERFLY_BACKGROUND,
2001-01-16 20:35:34 +01:00
NPC_UNIT_TYPE_MAX,
};
2001-05-25 20:43:47 +02:00
enum
{ // For Dynamic ThingCache
MAX_SUBTYPE =NPC_UNIT_TYPE_MAX,
};
2001-01-16 20:35:34 +01:00
2001-01-22 23:24:53 +01:00
void init();
2001-04-20 16:48:15 +02:00
virtual void postInit();
2001-04-26 23:29:44 +02:00
virtual void shutdown();
virtual u8 canCollideWithEnemy() {return( true );}
2001-04-20 00:09:59 +02:00
virtual void think(int _frames);
virtual void render();
2001-05-17 17:27:03 +02:00
virtual void processEvent( GAME_EVENT evt, CThing *sourceThing );
2001-05-25 20:43:47 +02:00
void setType( NPC_UNIT_TYPE newType ) {m_type = newType; setThingSubType(newType);}
2001-04-26 23:29:44 +02:00
NPC_UNIT_TYPE getType() {return( m_type );}
2001-04-20 00:09:59 +02:00
static NPC_UNIT_TYPE getTypeFromMapEdit( u16 newType );
2001-03-26 18:44:45 +02:00
void setHeading( s32 newHeading ) {m_heading = newHeading;}
2001-06-04 22:02:27 +02:00
virtual void setHeading( s32 xPos, s32 yPos );
2001-05-30 00:07:28 +02:00
void setWaypointPtr( u16 *newPtr ) {m_npcPath.setWaypointPtr( newPtr );}
void setWaypointCount( u8 newCount ) {m_npcPath.setWaypointCount( newCount );}
2001-04-02 21:21:46 +02:00
void setPathType( u8 newType ) {m_npcPath.setPathType( newType );}
void setStartPos( s32 xPos, s32 yPos );
2001-06-28 21:31:56 +02:00
void setStartPosHighRes( s32 xPos, s32 yPos );
2001-05-15 22:21:05 +02:00
virtual u8 hasBeenAttacked();
2001-06-06 15:27:46 +02:00
virtual void hasBeenSteamed( DVECTOR &steamPos ) {hasBeenAttacked();}
2001-05-15 22:34:37 +02:00
virtual u8 canBeCaughtByNet();
2001-06-12 20:12:34 +02:00
virtual void caughtWithNet();
2001-04-20 18:13:23 +02:00
virtual int getFrameCount();
2001-05-16 23:15:50 +02:00
virtual int getFrame() {return( m_frame );}
2001-07-16 16:59:22 +02:00
void setSpeed( s16 newSpeed );
2001-05-17 23:07:43 +02:00
virtual u32 getRGB() {return( m_RGB );}
2001-06-18 21:06:43 +02:00
virtual void leftThinkZone(int _frames);
2001-01-22 23:24:53 +01:00
2001-05-25 22:03:00 +02:00
static CNpcEnemy *Create(int enemyType);
2001-04-20 17:43:35 +02:00
static CNpcEnemy *Create(sThingActor *ThisActor);
2001-05-10 21:27:57 +02:00
virtual void setupWaypoints( sThingActor *ThisActor );
2001-04-20 17:43:35 +02:00
2001-04-24 21:03:06 +02:00
virtual int canCollide();
2001-06-19 22:07:57 +02:00
virtual CRECT const *getThinkBBox() {return &m_thinkArea;}
2001-06-26 21:23:55 +02:00
void setThinkArea();
2001-04-24 21:03:06 +02:00
2001-04-30 20:55:38 +02:00
bool canBeSuckedUp();
2001-04-30 17:42:07 +02:00
bool suckUp( DVECTOR *suckPos, int _frames );
2001-04-20 17:43:35 +02:00
2001-05-31 00:05:41 +02:00
int getHealth() {return(m_health);}
2001-01-22 23:24:53 +01:00
protected:
// NPC data structure definitions //
2001-01-16 20:35:34 +01:00
enum NPC_CONTROL_FUNC
{
2001-01-29 17:55:11 +01:00
NPC_CONTROL_NONE,
2001-01-16 20:35:34 +01:00
NPC_CONTROL_MOVEMENT,
NPC_CONTROL_SHOT,
NPC_CONTROL_CLOSE,
NPC_CONTROL_COLLISION,
};
enum NPC_SENSOR_FUNC
{
NPC_SENSOR_NONE = 0,
2001-04-20 00:09:59 +02:00
NPC_SENSOR_USER_CLOSE = 1,
2001-04-20 22:22:16 +02:00
NPC_SENSOR_GENERIC_USER_CLOSE,
2001-02-12 16:37:31 +01:00
NPC_SENSOR_GENERIC_USER_VISIBLE,
2001-01-16 20:35:34 +01:00
};
2001-01-18 20:18:39 +01:00
enum NPC_CLOSE_FUNC
{
2001-01-18 22:19:43 +01:00
NPC_CLOSE_NONE = 0,
2001-04-20 16:48:15 +02:00
NPC_CLOSE_GENERIC_USER_SEEK = 1,
2001-01-18 20:18:39 +01:00
};
2001-01-16 20:35:34 +01:00
enum NPC_MOVEMENT_FUNC
{
NPC_MOVEMENT_STATIC = 0,
NPC_MOVEMENT_FIXED_PATH = 1,
2001-02-22 16:39:38 +01:00
NPC_MOVEMENT_FIXED_PATH_WALK,
2001-04-02 17:52:09 +02:00
NPC_MOVEMENT_STATIC_CYCLE_ANIM,
2001-01-16 20:35:34 +01:00
};
2001-01-18 20:18:39 +01:00
enum NPC_TIMER_FUNC
{
NPC_TIMER_NONE = 0,
NPC_TIMER_EVADE_DONE = 1,
2001-01-18 22:19:43 +01:00
NPC_TIMER_ATTACK_DONE,
2001-04-07 00:21:01 +02:00
NPC_TIMER_RESPAWN,
2001-01-18 22:19:43 +01:00
};
2001-04-05 21:03:55 +02:00
enum NPC_SHOT_FUNC
{
NPC_SHOT_NONE = 0,
2001-04-05 21:36:04 +02:00
NPC_SHOT_GENERIC = 1,
2001-04-05 21:03:55 +02:00
};
2001-04-05 21:36:04 +02:00
enum NPC_GENERIC_HIT_STATE
2001-04-05 21:03:55 +02:00
{
2001-04-05 21:36:04 +02:00
NPC_GENERIC_HIT_CHECK_HEALTH = 100,
NPC_GENERIC_HIT_RECOIL = 101,
NPC_GENERIC_HIT_DEATH_START,
NPC_GENERIC_HIT_DEATH_END,
2001-04-05 21:03:55 +02:00
};
2001-04-28 19:39:24 +02:00
enum NPC_CORAL_BLOWER_STATE
{
NPC_CORAL_BLOWER_SUCK = 200,
NPC_CORAL_BLOWER_RETURN = 201,
};
2001-01-18 22:19:43 +01:00
enum
{
2001-01-19 22:46:30 +01:00
EXTEND_UP = true,
EXTEND_DOWN = false,
EXTEND_RIGHT = true,
EXTEND_LEFT = false,
2001-02-23 22:35:11 +01:00
EXTEND_CLOCKWISE = true,
EXTEND_ANTICLOCKWISE = false,
2001-04-02 21:21:46 +02:00
NPC_ENEMY_MAPEDIT_OFFSET = 10,
2001-01-16 20:35:34 +01:00
};
2001-04-05 22:44:30 +02:00
enum DETECT_TYPE
{
DETECT_NO_COLLISION = 0,
DETECT_ALL_COLLISION = 1,
DETECT_ATTACK_COLLISION_GENERIC,
};
2001-01-16 20:35:34 +01:00
typedef struct NPC_DATA_TYPE
{
2001-04-20 17:43:35 +02:00
int skelType;
2001-03-05 21:16:35 +01:00
// FileEquate animData;
2001-02-28 22:05:39 +01:00
u16 initAnim;
2001-01-16 20:35:34 +01:00
NPC_SENSOR_FUNC sensorFunc;
NPC_MOVEMENT_FUNC movementFunc;
2001-01-18 20:18:39 +01:00
NPC_CLOSE_FUNC closeFunc;
NPC_TIMER_FUNC timerFunc;
2001-04-30 20:55:38 +02:00
u8 canTalk;
2001-01-19 16:07:53 +01:00
u8 speed;
u16 turnSpeed;
2001-04-05 22:44:30 +02:00
DETECT_TYPE detectCollision;
2001-02-07 17:42:13 +01:00
DAMAGE_TYPE damageToUserType;
2001-03-05 22:29:44 +01:00
u16 initHealth;
2001-04-02 17:52:09 +02:00
u16 moveAnim;
2001-04-05 21:03:55 +02:00
NPC_SHOT_FUNC shotFunc;
u16 dieAnim;
2001-04-05 21:36:04 +02:00
u16 recoilAnim;
2001-04-30 20:55:38 +02:00
u8 canBeNetted;
u8 respawning;
u8 canBeSuckedUp;
2001-05-10 16:09:06 +02:00
u8 canCollideWithEnemy;
2001-05-21 23:16:42 +02:00
CSoundMediator::SFXID deathSfx;
CSoundMediator::SFXID moveSfx;
2001-06-01 21:53:49 +02:00
u8 playDeathAnim;
2001-01-16 20:35:34 +01:00
}
NPC_DATA;
2001-04-02 21:21:46 +02:00
static NPC_UNIT_TYPE mapEditConvertTable[NPC_UNIT_TYPE_MAX];
2001-01-18 22:19:43 +01:00
// functions
2001-04-20 00:09:59 +02:00
virtual bool processSensor();
virtual void processMovement( int _frames );
virtual void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange );
2001-05-09 23:50:09 +02:00
virtual void processShot( int _frames );
2001-06-28 22:29:14 +02:00
virtual void processShotRecoil( int _frames );
virtual void processShotDeathStart( int _frames );
virtual void processShotDeathEnd( int _frames );
2001-04-20 00:09:59 +02:00
virtual void processClose( int _frames );
virtual void processCollision();
2001-05-04 20:54:27 +02:00
virtual void processAttackCollision();
2001-05-04 22:11:44 +02:00
virtual void processGraphicFlipping();
2001-05-21 23:16:42 +02:00
virtual void processAnimFrames( int _frames );
2001-06-06 15:27:46 +02:00
virtual void processTimer( int _frames );
2001-02-12 18:52:04 +01:00
bool isCollisionWithGround();
2001-06-30 17:39:43 +02:00
virtual void addHealthMeter() {}
2001-01-18 22:19:43 +01:00
2001-01-25 16:45:15 +01:00
void processGenericGotoTarget( int _frames, s32 xDist, s32 yDist, s32 speed );
2001-02-06 20:29:35 +01:00
void processGenericGetUserDist( int _frames, s32 *distX, s32 *distY );
2001-06-21 22:10:19 +02:00
u8 processGenericFixedPathMove( int _frames, s32 *moveX, s32 *moveY, s32 *moveVel, s32 *moveDist );
2001-02-22 22:00:56 +01:00
void processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY );
bool processGroundCollisionReverse( s32 *moveX, s32 *moveY );
2001-04-24 21:03:06 +02:00
virtual void processEnemyCollision( CThing *thisThing );
2001-05-10 01:14:35 +02:00
virtual void processUserCollision( CThing *thisThing );
2001-05-15 00:59:31 +02:00
virtual s32 getFrameShift( int _frames );
2001-01-22 15:23:11 +01:00
2001-04-07 00:21:01 +02:00
void reinit();
2001-04-28 19:39:24 +02:00
void processCoralBlower( int _frames );
2001-05-09 22:46:22 +02:00
bool processCoralBlowerMovement( int _frames, s32 xDist, s32 yDist, u8 destroyAtTarget );
2001-04-28 19:39:24 +02:00
2001-06-12 23:47:22 +02:00
void drawAttackEffect();
2001-01-18 22:19:43 +01:00
// data
2001-01-16 20:35:34 +01:00
static NPC_DATA m_data[NPC_UNIT_TYPE_MAX];
2001-01-18 20:18:39 +01:00
2001-02-07 17:42:13 +01:00
static s32 playerXDist;
static s32 playerYDist;
static s32 playerXDistSqr;
static s32 playerYDistSqr;
2001-01-18 20:18:39 +01:00
// internal variables
NPC_UNIT_TYPE m_type;
NPC_CONTROL_FUNC m_controlFunc;
2001-02-07 18:40:56 +01:00
NPC_CONTROL_FUNC m_oldControlFunc;
2001-01-18 20:18:39 +01:00
NPC_TIMER_FUNC m_timerFunc;
NPC_SENSOR_FUNC m_sensorFunc;
2001-04-19 01:12:24 +02:00
NPC_MOVEMENT_FUNC m_movementFunc;
2001-01-18 20:18:39 +01:00
CNpcPath m_npcPath;
s32 m_heading;
s32 m_velocity;
2001-01-22 23:24:53 +01:00
s32 m_movementTimer;
2001-01-18 20:18:39 +01:00
s32 m_timerTimer;
2001-01-18 22:19:43 +01:00
s32 m_extension;
2001-01-19 22:46:30 +01:00
bool m_extendDir;
2001-01-25 16:45:15 +01:00
DVECTOR m_base;
2001-04-07 00:21:01 +02:00
DVECTOR m_initPos;
2001-01-25 16:45:15 +01:00
u8 m_state;
2001-04-28 19:39:24 +02:00
u8 m_oldState;
2001-02-28 22:05:39 +01:00
bool m_animPlaying;
bool m_reversed;
2001-03-05 22:29:44 +01:00
s32 m_health;
2001-04-07 00:21:01 +02:00
bool m_isActive;
2001-04-28 19:39:24 +02:00
u8 m_isCaught;
2001-04-30 17:36:26 +02:00
u8 m_isBlowerOn;
2001-04-28 19:39:24 +02:00
DVECTOR m_caughtPos;
2001-05-09 23:27:23 +02:00
s16 m_speed;
2001-05-10 18:47:35 +02:00
u8 m_isDying;
2001-05-17 23:07:43 +02:00
u32 m_RGB;
2001-06-18 21:06:43 +02:00
int m_soundId;
2001-06-19 22:07:57 +02:00
CRECT m_thinkArea;
2001-02-27 22:25:22 +01:00
2001-04-05 17:54:40 +02:00
s32 m_frame;
2001-02-27 22:25:22 +01:00
int m_animNo;
2001-04-01 22:22:49 +02:00
CActorGfx *m_actorGfx;
2001-05-25 20:43:47 +02:00
2001-04-20 00:09:59 +02:00
POLY_FT4 *SprFrame;
2001-03-05 22:11:51 +01:00
virtual void collidedWith(CThing *_thisThing);
2001-04-26 17:20:21 +02:00
s16 m_drawRotation;
2001-01-16 20:35:34 +01:00
};
/*****************************************************************************/
#endif