This commit is contained in:
parent
7b93d41657
commit
c0b9dcf1aa
8 changed files with 181 additions and 68 deletions
|
@ -122,9 +122,12 @@ void CNpcEnemy::processCloseHermitCrabAttack( int _frames )
|
||||||
|
|
||||||
moveX = 6 * _frames;
|
moveX = 6 * _frames;
|
||||||
|
|
||||||
|
m_heading = 0;
|
||||||
|
|
||||||
if ( m_extendDir == EXTEND_LEFT )
|
if ( m_extendDir == EXTEND_LEFT )
|
||||||
{
|
{
|
||||||
moveX = -moveX;
|
moveX = -moveX;
|
||||||
|
m_heading = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
||||||
|
|
|
@ -196,6 +196,33 @@ s32 CNpcEnemy::playerYDistSqr;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcEnemy::setTypeFromMapEdit( u16 newType )
|
||||||
|
{
|
||||||
|
m_type = mapEditConvertTable[newType - NPC_ENEMY_MAPEDIT_OFFSET];
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcEnemy::addWaypoint( s32 xPos, s32 yPos )
|
||||||
|
{
|
||||||
|
DVECTOR newPos;
|
||||||
|
|
||||||
|
newPos.vx = xPos << 4;
|
||||||
|
newPos.vy = yPos << 4;
|
||||||
|
|
||||||
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcEnemy::setStartPos( s32 xPos, s32 yPos )
|
||||||
|
{
|
||||||
|
Pos.vx = xPos << 4;
|
||||||
|
Pos.vy = yPos << 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcEnemy::init()
|
void CNpcEnemy::init()
|
||||||
{
|
{
|
||||||
CEnemyThing::init();
|
CEnemyThing::init();
|
||||||
|
@ -219,11 +246,6 @@ void CNpcEnemy::init()
|
||||||
|
|
||||||
m_extendDir = EXTEND_RIGHT;
|
m_extendDir = EXTEND_RIGHT;
|
||||||
|
|
||||||
//Pos.vx = 400;
|
|
||||||
//Pos.vy = 400;
|
|
||||||
Pos.vx = 100;
|
|
||||||
Pos.vy = 100;
|
|
||||||
|
|
||||||
m_base = Pos;
|
m_base = Pos;
|
||||||
|
|
||||||
m_timerFunc = m_data[this->m_type].timerFunc;
|
m_timerFunc = m_data[this->m_type].timerFunc;
|
||||||
|
@ -246,33 +268,7 @@ void CNpcEnemy::init()
|
||||||
{
|
{
|
||||||
case NPC_INIT_DEFAULT:
|
case NPC_INIT_DEFAULT:
|
||||||
{
|
{
|
||||||
DVECTOR newPos;
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
||||||
|
|
||||||
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( PONG_PATH );
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +289,7 @@ void CNpcEnemy::init()
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
|
||||||
m_npcPath.setPathType( PONG_PATH );
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
||||||
|
|
||||||
m_state = HERMIT_CRAB_NO_ATTACK;
|
m_state = HERMIT_CRAB_NO_ATTACK;
|
||||||
|
|
||||||
|
@ -355,7 +351,7 @@ void CNpcEnemy::init()
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
|
||||||
m_npcPath.setPathType( SINGLE_USE_PATH );
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -377,7 +373,7 @@ void CNpcEnemy::init()
|
||||||
newPos.vy = 100;
|
newPos.vy = 100;
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
m_npcPath.setPathType( SINGLE_USE_PATH );
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
||||||
|
|
||||||
m_extension = 0;
|
m_extension = 0;
|
||||||
m_velocity = m_data[m_type].speed;
|
m_velocity = m_data[m_type].speed;
|
||||||
|
@ -400,7 +396,7 @@ void CNpcEnemy::init()
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
|
||||||
m_npcPath.setPathType( SINGLE_USE_PATH );
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -421,7 +417,7 @@ void CNpcEnemy::init()
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
|
||||||
m_npcPath.setPathType( PONG_PATH );
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +470,7 @@ void CNpcEnemy::init()
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
|
||||||
m_npcPath.setPathType( PONG_PATH );
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
||||||
|
|
||||||
// create head of list
|
// create head of list
|
||||||
CNpcPositionHistory *newPosition;
|
CNpcPositionHistory *newPosition;
|
||||||
|
|
|
@ -154,6 +154,7 @@ public:
|
||||||
NPC_FLYING_DUTCHMAN,
|
NPC_FLYING_DUTCHMAN,
|
||||||
NPC_IRON_DOGFISH,
|
NPC_IRON_DOGFISH,
|
||||||
NPC_PARASITIC_WORM_SEGMENT,
|
NPC_PARASITIC_WORM_SEGMENT,
|
||||||
|
NPC_BALL_BLOB,
|
||||||
NPC_UNIT_TYPE_MAX,
|
NPC_UNIT_TYPE_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -164,7 +165,11 @@ public:
|
||||||
void processEvent( GAME_EVENT evt, CThing *sourceThing );
|
void processEvent( GAME_EVENT evt, CThing *sourceThing );
|
||||||
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
|
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
|
||||||
void setType( NPC_UNIT_TYPE newType ) {m_type = newType;}
|
void setType( NPC_UNIT_TYPE newType ) {m_type = newType;}
|
||||||
|
void setTypeFromMapEdit( u16 newType );
|
||||||
void setHeading( s32 newHeading ) {m_heading = newHeading;}
|
void setHeading( s32 newHeading ) {m_heading = newHeading;}
|
||||||
|
void addWaypoint( s32 xPos, s32 yPos );
|
||||||
|
void setPathType( u8 newType ) {m_npcPath.setPathType( newType );}
|
||||||
|
void setStartPos( s32 xPos, s32 yPos );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -349,6 +354,8 @@ protected:
|
||||||
EXTEND_LEFT = false,
|
EXTEND_LEFT = false,
|
||||||
EXTEND_CLOCKWISE = true,
|
EXTEND_CLOCKWISE = true,
|
||||||
EXTEND_ANTICLOCKWISE = false,
|
EXTEND_ANTICLOCKWISE = false,
|
||||||
|
|
||||||
|
NPC_ENEMY_MAPEDIT_OFFSET = 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -373,6 +380,8 @@ protected:
|
||||||
}
|
}
|
||||||
NPC_DATA;
|
NPC_DATA;
|
||||||
|
|
||||||
|
static NPC_UNIT_TYPE mapEditConvertTable[NPC_UNIT_TYPE_MAX];
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
|
|
||||||
bool processSensor();
|
bool processSensor();
|
||||||
|
|
|
@ -896,4 +896,67 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
|
||||||
256,
|
256,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
};
|
|
||||||
|
{ // NPC_BALL_BLOB
|
||||||
|
ACTORS_FLAMINGSKULL_SBK,
|
||||||
|
ANIM_FLAMINGSKULL_MOVE,
|
||||||
|
NPC_INIT_FLAMING_SKULL,
|
||||||
|
NPC_SENSOR_FLAMING_SKULL_USER_CLOSE,
|
||||||
|
NPC_MOVEMENT_STATIC_CYCLE_ANIM,
|
||||||
|
NPC_MOVEMENT_MODIFIER_NONE,
|
||||||
|
NPC_CLOSE_FLAMING_SKULL_ATTACK,
|
||||||
|
NPC_TIMER_NONE,
|
||||||
|
false,
|
||||||
|
3,
|
||||||
|
128,
|
||||||
|
false,
|
||||||
|
DAMAGE__BURN_ENEMY,
|
||||||
|
16,
|
||||||
|
ANIM_FLAMINGSKULL_MOVE,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
CNpcEnemy::NPC_UNIT_TYPE CNpcEnemy::mapEditConvertTable[NPC_UNIT_TYPE_MAX] =
|
||||||
|
{
|
||||||
|
NPC_SMALL_JELLYFISH_1,
|
||||||
|
NPC_SMALL_JELLYFISH_2,
|
||||||
|
NPC_MOTHER_JELLYFISH,
|
||||||
|
NPC_ANEMONE_1,
|
||||||
|
NPC_ANEMONE_2,
|
||||||
|
NPC_ANEMONE_3,
|
||||||
|
NPC_BABY_OCTOPUS,
|
||||||
|
NPC_BALL_BLOB,
|
||||||
|
NPC_BOOGER_MONSTER,
|
||||||
|
NPC_PRICKLY_BUG,
|
||||||
|
NPC_CLAM_JUMP,
|
||||||
|
NPC_CLAM_STATIC,
|
||||||
|
NPC_EYEBALL,
|
||||||
|
NPC_FLAMING_SKULL,
|
||||||
|
NPC_FLYING_DUTCHMAN,
|
||||||
|
NPC_GHOST,
|
||||||
|
NPC_PARASITIC_WORM,
|
||||||
|
NPC_HERMIT_CRAB,
|
||||||
|
NPC_IRON_DOGFISH,
|
||||||
|
NPC_PUFFA_FISH,
|
||||||
|
NPC_SEA_SNAKE,
|
||||||
|
NPC_SHARK_MAN,
|
||||||
|
NPC_SUB_SHARK,
|
||||||
|
NPC_SKELETAL_FISH,
|
||||||
|
NPC_SPIDER_CRAB,
|
||||||
|
NPC_SQUID_DART,
|
||||||
|
NPC_SKULL_STOMPER,
|
||||||
|
NPC_DUST_DEVIL,
|
||||||
|
NPC_FALLING_ITEM,
|
||||||
|
NPC_FISH_HOOK,
|
||||||
|
NPC_PENDULUM,
|
||||||
|
NPC_FIREBALL,
|
||||||
|
NPC_SAW_BLADE,
|
||||||
|
NPC_FISH_FOLK,
|
||||||
|
NPC_ANGLER_FISH,
|
||||||
|
NPC_MINE,
|
||||||
|
NPC_ZOMBIE_FISH_FOLK,
|
||||||
|
NPC_NINJA_STARFISH,
|
||||||
|
NPC_GHOST_PIRATE,
|
||||||
|
NPC_OIL_BLOB,
|
||||||
|
NPC_PARASITIC_WORM_SEGMENT,
|
||||||
|
};
|
||||||
|
|
|
@ -109,9 +109,9 @@ void CNpcPath::removeAllWaypoints()
|
||||||
this->waypoint = NULL;
|
this->waypoint = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNpcPath::setPathType( NPC_PATH_TYPE newPathType )
|
void CNpcPath::setPathType( u8 newPathType )
|
||||||
{
|
{
|
||||||
pathType = newPathType;
|
pathType = (NPC_PATH_TYPE) newPathType;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNpcPath::incPath()
|
bool CNpcPath::incPath()
|
||||||
|
|
|
@ -26,15 +26,27 @@ public:
|
||||||
bool isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist );
|
bool isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist );
|
||||||
};
|
};
|
||||||
|
|
||||||
enum NPC_PATH_TYPE
|
|
||||||
{
|
|
||||||
SINGLE_USE_PATH = 0,
|
|
||||||
REPEATING_PATH = 1,
|
|
||||||
PONG_PATH = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
class CNpcPath
|
class CNpcPath
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
enum NPC_PATH_TYPE
|
||||||
|
{
|
||||||
|
SINGLE_USE_PATH = 0,
|
||||||
|
REPEATING_PATH = 1,
|
||||||
|
PONG_PATH = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
void initPath();
|
||||||
|
void addWaypoint( DVECTOR newPos );
|
||||||
|
void removeAllWaypoints();
|
||||||
|
void setPathType( u8 newPathType );
|
||||||
|
bool incPath();
|
||||||
|
void resetPath();
|
||||||
|
void reversePathDir();
|
||||||
|
s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange );
|
||||||
|
bool thinkFlat( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *heading );
|
||||||
|
bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CNpcWaypoint *waypoint;
|
CNpcWaypoint *waypoint;
|
||||||
NPC_PATH_TYPE pathType;
|
NPC_PATH_TYPE pathType;
|
||||||
|
@ -42,18 +54,6 @@ private:
|
||||||
bool reversePath;
|
bool reversePath;
|
||||||
CNpcWaypoint *currentWaypoint;
|
CNpcWaypoint *currentWaypoint;
|
||||||
CNpcWaypoint *lastWaypoint;
|
CNpcWaypoint *lastWaypoint;
|
||||||
|
|
||||||
public:
|
|
||||||
void initPath();
|
|
||||||
void addWaypoint( DVECTOR newPos );
|
|
||||||
void removeAllWaypoints();
|
|
||||||
void setPathType( NPC_PATH_TYPE newPathType );
|
|
||||||
bool incPath();
|
|
||||||
void resetPath();
|
|
||||||
void reversePathDir();
|
|
||||||
s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange );
|
|
||||||
bool thinkFlat( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *heading );
|
|
||||||
bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -241,14 +241,6 @@ void CGameScene::initLevel()
|
||||||
CConversation::init();
|
CConversation::init();
|
||||||
CConversation::registerConversationScript(SCRIPTS_SPEECHTEST_DAT); // Register one script for testing..
|
CConversation::registerConversationScript(SCRIPTS_SPEECHTEST_DAT); // Register one script for testing..
|
||||||
|
|
||||||
#ifdef __USER_charles__
|
|
||||||
CNpcEnemy *enemy;
|
|
||||||
enemy=new ("test enemy") CNpcEnemy;
|
|
||||||
enemy->setType( CNpcEnemy::NPC_PARASITIC_WORM );
|
|
||||||
enemy->init();
|
|
||||||
enemy->setLayerCollision( Level.getCollisionLayer() );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __USER_paul__
|
#ifdef __USER_paul__
|
||||||
DVECTOR pos={16*10,16*10};
|
DVECTOR pos={16*10,16*10};
|
||||||
createPickup(PICKUP__BIG_HEALTH,&pos);
|
createPickup(PICKUP__BIG_HEALTH,&pos);
|
||||||
|
@ -282,6 +274,54 @@ void CGameScene::initLevel()
|
||||||
m_player->setLayerCollision(Level.getCollisionLayer());
|
m_player->setLayerCollision(Level.getCollisionLayer());
|
||||||
m_player->setMapSize(Level.getMapSize());
|
m_player->setMapSize(Level.getMapSize());
|
||||||
|
|
||||||
|
#ifdef __USER_charles__
|
||||||
|
/*CNpcEnemy *enemy;
|
||||||
|
enemy=new ("test enemy") CNpcEnemy;
|
||||||
|
enemy->setType( CNpcEnemy::NPC_PARASITIC_WORM );
|
||||||
|
enemy->init();
|
||||||
|
enemy->setLayerCollision( Level.getCollisionLayer() );*/
|
||||||
|
|
||||||
|
int actorNum;
|
||||||
|
sThingActor **actorList = Level.getActorList();
|
||||||
|
|
||||||
|
for ( actorNum = 0 ; actorNum < Level.getActorCount() ; actorNum++ )
|
||||||
|
{
|
||||||
|
CNpcEnemy *enemy;
|
||||||
|
enemy = new ("npc enemy") CNpcEnemy;
|
||||||
|
enemy->setTypeFromMapEdit( actorList[actorNum]->Type );
|
||||||
|
enemy->init();
|
||||||
|
enemy->setLayerCollision( Level.getCollisionLayer() );
|
||||||
|
|
||||||
|
int pointNum;
|
||||||
|
u16 *PntList=(u16*)MakePtr(actorList[actorNum],sizeof(sThingActor));
|
||||||
|
|
||||||
|
u16 newXPos, newYPos;
|
||||||
|
|
||||||
|
newXPos = (u16) *PntList;
|
||||||
|
PntList++;
|
||||||
|
newYPos = (u16) *PntList;
|
||||||
|
PntList++;
|
||||||
|
|
||||||
|
enemy->setStartPos( newXPos, newYPos );
|
||||||
|
enemy->addWaypoint( newXPos, newYPos );
|
||||||
|
|
||||||
|
if ( actorList[actorNum]->PointCount > 1 )
|
||||||
|
{
|
||||||
|
for ( pointNum = 1 ; pointNum < actorList[actorNum]->PointCount ; pointNum++ )
|
||||||
|
{
|
||||||
|
newXPos = (u16) *PntList;
|
||||||
|
PntList++;
|
||||||
|
newYPos = (u16) *PntList;
|
||||||
|
PntList++;
|
||||||
|
|
||||||
|
enemy->addWaypoint( newXPos, newYPos );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//u16 *PntList=(u16*)MakePtr(ThisThing,sizeof(sActorThing);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Song is loaded/dumped by the level, and played from here. This just gives some
|
// Song is loaded/dumped by the level, and played from here. This just gives some
|
||||||
// better timing over when it starts (pkg)
|
// better timing over when it starts (pkg)
|
||||||
CSoundMediator::playSong();
|
CSoundMediator::playSong();
|
||||||
|
|
|
@ -23,6 +23,8 @@ public:
|
||||||
void setCameraCentre(DVECTOR _pos) {MapPos=_pos;}
|
void setCameraCentre(DVECTOR _pos) {MapPos=_pos;}
|
||||||
static DVECTOR getCameraPos() {return MapPos;}
|
static DVECTOR getCameraPos() {return MapPos;}
|
||||||
static DVECTOR getPlayerSpawnPos() {return s_playerSpawnPos;}
|
static DVECTOR getPlayerSpawnPos() {return s_playerSpawnPos;}
|
||||||
|
int getActorCount() {return ActorCount;}
|
||||||
|
sThingActor **getActorList() {return ActorList;}
|
||||||
CLayerCollision *getCollisionLayer() {return CollisionLayer;}
|
CLayerCollision *getCollisionLayer() {return CollisionLayer;}
|
||||||
DVECTOR getMapSize();
|
DVECTOR getMapSize();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue