From c7e46d02eff57f6af16efde1414dd956639c75c3 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 29 May 2001 22:07:28 +0000 Subject: [PATCH] --- source/enemy/nanemone.cpp | 21 +-- source/enemy/nclam.cpp | 32 ++--- source/enemy/neyeball.cpp | 17 +-- source/enemy/nffolk.cpp | 4 +- source/enemy/ngen.cpp | 18 +-- source/enemy/nhcrab.cpp | 29 ++-- source/enemy/nmjfish.cpp | 18 +-- source/enemy/npbug.cpp | 29 ++-- source/enemy/npc.cpp | 62 ++++---- source/enemy/npc.h | 5 +- source/enemy/npcdata.cpp | 78 +++++----- source/enemy/npcpath.cpp | 271 ++++++++++++++++++----------------- source/enemy/npcpath.h | 24 ++-- source/enemy/nworm.cpp | 21 +-- source/hazard/hazard.cpp | 32 +---- source/hazard/hazard.h | 3 +- source/hazard/hfalling.cpp | 18 +-- source/hazard/hfirebal.cpp | 22 +-- source/hazard/hsaw.cpp | 2 +- source/platform/pbgeyser.cpp | 12 +- source/platform/pconveyr.cpp | 23 +-- source/platform/pfgen.cpp | 18 ++- source/platform/platform.cpp | 35 ++--- source/platform/platform.h | 3 +- 24 files changed, 328 insertions(+), 469 deletions(-) diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp index 4f6ee17ea..6ccf0b018 100644 --- a/source/enemy/nanemone.cpp +++ b/source/enemy/nanemone.cpp @@ -267,26 +267,19 @@ void CNpcAnemone2Enemy::processShot( int _frames ) { case NPC_GENERIC_HIT_CHECK_HEALTH: { - if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) + m_health -= 5; + + if ( m_health < 0 ) { m_state = NPC_GENERIC_HIT_DEATH_START; } else { - m_health -= 5; + m_state = NPC_GENERIC_HIT_RECOIL; - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - } - else - { - m_state = NPC_GENERIC_HIT_RECOIL; - - m_animPlaying = true; - m_animNo = m_data[m_type].recoilAnim; - m_frame = 0; - } + m_animPlaying = true; + m_animNo = m_data[m_type].recoilAnim; + m_frame = 0; } break; diff --git a/source/enemy/nclam.cpp b/source/enemy/nclam.cpp index 5726bde43..df8b6e4d2 100644 --- a/source/enemy/nclam.cpp +++ b/source/enemy/nclam.cpp @@ -105,40 +105,34 @@ void CNpcJumpingClamEnemy::setupWaypoints( sThingActor *ThisActor ) u16 newXPos, newYPos; u16 startXPos, startYPos, endXPos, endYPos; + m_npcPath.setWaypointCount( ThisActor->PointCount - 1 ); + startXPos = newXPos = (u16) *PntList; + setWaypointPtr( PntList ); PntList++; startYPos = newYPos = (u16) *PntList; PntList++; setStartPos( newXPos, newYPos ); - addWaypoint( newXPos, newYPos ); m_maxExtension = 10; if ( ThisActor->PointCount > 1 ) { - for (int pointNum = 1 ; pointNum < ThisActor->PointCount ; pointNum++ ) - { - newXPos = (u16) *PntList; - PntList++; - newYPos = (u16) *PntList; - PntList++; + newXPos = (u16) *PntList; + PntList++; + newYPos = (u16) *PntList; + PntList++; - addWaypoint( newXPos, newYPos ); + endXPos = newXPos; + endYPos = newYPos; - if ( pointNum == 1 ) - { - endXPos = newXPos; - endYPos = newYPos; + setHeading( newXPos, newYPos ); - setHeading( newXPos, newYPos ); + s32 xDist = ( endXPos - startXPos ) << 4; + s32 yDist = ( endYPos - startYPos ) << 4; - s32 xDist = ( endXPos - startXPos ) << 4; - s32 yDist = ( endYPos - startYPos ) << 4; - - m_maxExtension = isqrt2( ( xDist * xDist ) + ( yDist * yDist ) ); - } - } + m_maxExtension = isqrt2( ( xDist * xDist ) + ( yDist * yDist ) ); } } diff --git a/source/enemy/neyeball.cpp b/source/enemy/neyeball.cpp index ff77c14dc..8003e120d 100644 --- a/source/enemy/neyeball.cpp +++ b/source/enemy/neyeball.cpp @@ -236,23 +236,16 @@ void CNpcEyeballEnemy::processShot( int _frames ) { case NPC_GENERIC_HIT_CHECK_HEALTH: { - if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) + m_health -= 5; + + if ( m_health < 0 ) { m_state = NPC_GENERIC_HIT_DEATH_START; } else { - m_health -= 5; - - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - } - else - { - m_state = 0; - m_controlFunc = NPC_CONTROL_MOVEMENT; - } + m_state = 0; + m_controlFunc = NPC_CONTROL_MOVEMENT; } break; diff --git a/source/enemy/nffolk.cpp b/source/enemy/nffolk.cpp index f64e6ef90..a552e8dd8 100644 --- a/source/enemy/nffolk.cpp +++ b/source/enemy/nffolk.cpp @@ -37,12 +37,12 @@ void CNpcFishFolk::postInit() newPos.vx = 200; newPos.vy = 400; - m_npcPath.addWaypoint( newPos ); + //m_npcPath.addWaypoint( newPos ); newPos.vx = 500; newPos.vy = 400; - m_npcPath.addWaypoint( newPos ); + //m_npcPath.addWaypoint( newPos ); m_npcPath.setPathType( CNpcPath::PONG_PATH ); } diff --git a/source/enemy/ngen.cpp b/source/enemy/ngen.cpp index 1ecc48144..4da9333da 100644 --- a/source/enemy/ngen.cpp +++ b/source/enemy/ngen.cpp @@ -54,20 +54,14 @@ void CNpcEnemyGenerator::think(int _frames) enemy->init(); enemy->setStartPos( Pos.vx >> 4, Pos.vy >> 4 ); - CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); + u16 *waypointPtr = m_npcPath.getWaypointPtr(); - if ( sourceWaypoint ) - { - // skip first waypoint + // skip first waypoint + waypointPtr++; + waypointPtr++; - sourceWaypoint = sourceWaypoint->nextWaypoint; - - while( sourceWaypoint ) - { - enemy->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 ); - sourceWaypoint = sourceWaypoint->nextWaypoint; - } - } + enemy->setWaypointCount( m_npcPath.getWaypointCount() - 1 ); + enemy->setWaypointPtr( waypointPtr ); enemy->setPathType( m_npcPath.getPathType() ); diff --git a/source/enemy/nhcrab.cpp b/source/enemy/nhcrab.cpp index 092d17f83..65037870a 100644 --- a/source/enemy/nhcrab.cpp +++ b/source/enemy/nhcrab.cpp @@ -283,30 +283,23 @@ void CNpcHermitCrabEnemy::processShot( int _frames ) { case NPC_GENERIC_HIT_CHECK_HEALTH: { - if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) + m_health -= 5; + + if ( m_health < 0 ) { m_state = NPC_GENERIC_HIT_DEATH_START; + + m_animPlaying = true; + m_animNo = m_data[m_type].dieAnim; + m_frame = 0; } else { - m_health -= 5; + m_state = NPC_GENERIC_HIT_RECOIL; - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - - m_animPlaying = true; - m_animNo = m_data[m_type].dieAnim; - m_frame = 0; - } - else - { - m_state = NPC_GENERIC_HIT_RECOIL; - - m_animPlaying = true; - m_animNo = m_data[m_type].recoilAnim; - m_frame = 0; - } + m_animPlaying = true; + m_animNo = m_data[m_type].recoilAnim; + m_frame = 0; } break; diff --git a/source/enemy/nmjfish.cpp b/source/enemy/nmjfish.cpp index 3a477a841..7c2b1c259 100644 --- a/source/enemy/nmjfish.cpp +++ b/source/enemy/nmjfish.cpp @@ -70,13 +70,15 @@ void CNpcMotherJellyfishEnemy::setupWaypoints( sThingActor *ThisActor ) s32 startX = 0; + m_npcPath.setWaypointCount( ThisActor->PointCount - 1 ); + newXPos = (u16) *PntList; + setWaypointPtr( PntList ); PntList++; newYPos = (u16) *PntList; PntList++; setStartPos( newXPos, newYPos ); - addWaypoint( newXPos, newYPos ); startX = newXPos << 4; @@ -89,8 +91,6 @@ void CNpcMotherJellyfishEnemy::setupWaypoints( sThingActor *ThisActor ) newYPos = (u16) *PntList; PntList++; - addWaypoint( newXPos, newYPos ); - if ( pointNum == 1 ) { setHeading( newXPos, newYPos ); @@ -337,16 +337,8 @@ void CNpcMotherJellyfishEnemy::spawnJellyfish( int _frames ) enemy->init(); enemy->setStartPos( Pos.vx >> 4, ( Pos.vy + 20 ) >> 4 ); - CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); - - if ( sourceWaypoint ) - { - while( sourceWaypoint ) - { - enemy->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 ); - sourceWaypoint = sourceWaypoint->nextWaypoint; - } - } + enemy->setWaypointCount( m_npcPath.getWaypointCount() ); + enemy->setWaypointPtr( m_npcPath.getWaypointPtr() ); enemy->setPathType( CNpcPath::PONG_PATH ); enemy->postInit(); diff --git a/source/enemy/npbug.cpp b/source/enemy/npbug.cpp index 8dd45db2d..fd7ffece0 100644 --- a/source/enemy/npbug.cpp +++ b/source/enemy/npbug.cpp @@ -64,30 +64,23 @@ void CNpcPricklyBugEnemy::processShot( int _frames ) { case NPC_GENERIC_HIT_CHECK_HEALTH: { - if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) + m_health -= 5; + + if ( m_health < 0 ) { m_state = NPC_GENERIC_HIT_DEATH_START; + + m_animPlaying = true; + m_animNo = m_data[m_type].dieAnim; + m_frame = 0; } else { - m_health -= 5; + m_state = NPC_GENERIC_HIT_RECOIL; - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - - m_animPlaying = true; - m_animNo = m_data[m_type].dieAnim; - m_frame = 0; - } - else - { - m_state = NPC_GENERIC_HIT_RECOIL; - - m_animPlaying = true; - m_animNo = m_data[m_type].recoilAnim; - m_frame = 0; - } + m_animPlaying = true; + m_animNo = m_data[m_type].recoilAnim; + m_frame = 0; } break; diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 347ce8a2c..45d201a95 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -468,47 +468,43 @@ void CNpcEnemy::setupWaypoints( sThingActor *ThisActor ) u16 newXPos, newYPos; + m_npcPath.setWaypointCount( ThisActor->PointCount - 1 ); + newXPos = (u16) *PntList; + setWaypointPtr( PntList ); PntList++; newYPos = (u16) *PntList; PntList++; setStartPos( newXPos, newYPos ); - addWaypoint( newXPos, newYPos ); if ( ThisActor->PointCount > 1 ) { - for (int pointNum = 1 ; pointNum < ThisActor->PointCount ; pointNum++ ) - { - newXPos = (u16) *PntList; - PntList++; - newYPos = (u16) *PntList; - PntList++; + newXPos = (u16) *PntList; + PntList++; + newYPos = (u16) *PntList; + PntList++; - addWaypoint( newXPos, newYPos ); - - if ( pointNum == 1 ) - { - setHeading( newXPos, newYPos ); - } - } + setHeading( newXPos, newYPos ); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcEnemy::addWaypoint( s32 xPos, s32 yPos ) +/*void CNpcEnemy::addWaypoint( u16 *ptr ) { - DVECTOR newPos; - - newPos.vx = xPos << 4; - newPos.vy = yPos << 4; - - m_npcPath.addWaypoint( newPos ); + m_npcPath.addWaypoint( ptr ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcEnemy::addWaypoint( u16 *ptrX, u16 *ptrY ) +{ + m_npcPath.addWaypoint( ptrX, ptrY ); +}*/ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcEnemy::setStartPos( s32 xPos, s32 yPos ) { Pos.vx = xPos << 4; @@ -552,7 +548,6 @@ void CNpcEnemy::init() m_isDying = false; m_health = m_data[this->m_type].initHealth; - m_health = 1; m_extendDir = EXTEND_RIGHT; @@ -615,7 +610,7 @@ void CNpcEnemy::reinit() void CNpcEnemy::shutdown() { - m_npcPath.removeAllWaypoints(); + //m_npcPath.removeAllWaypoints(); if (m_actorGfx) delete m_actorGfx; @@ -1088,26 +1083,19 @@ void CNpcEnemy::processShot( int _frames ) { case NPC_GENERIC_HIT_CHECK_HEALTH: { - if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) + m_health -= 5; + + if ( m_health < 0 ) { m_state = NPC_GENERIC_HIT_DEATH_START; } else { - m_health -= 5; + m_state = NPC_GENERIC_HIT_RECOIL; - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - } - else - { - m_state = NPC_GENERIC_HIT_RECOIL; - - m_animPlaying = true; - m_animNo = m_data[m_type].recoilAnim; - m_frame = 0; - } + m_animPlaying = true; + m_animNo = m_data[m_type].recoilAnim; + m_frame = 0; } break; diff --git a/source/enemy/npc.h b/source/enemy/npc.h index c719c6ea0..1426a031e 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -104,7 +104,10 @@ public: static NPC_UNIT_TYPE getTypeFromMapEdit( u16 newType ); void setHeading( s32 newHeading ) {m_heading = newHeading;} void setHeading( s32 xPos, s32 yPos ); - void addWaypoint( s32 xPos, s32 yPos ); + //void addWaypoint( u16 *ptr ); + //void addWaypoint( u16 *ptrX, u16 *ptrY ); + void setWaypointPtr( u16 *newPtr ) {m_npcPath.setWaypointPtr( newPtr );} + void setWaypointCount( u8 newCount ) {m_npcPath.setWaypointCount( newCount );} void setPathType( u8 newType ) {m_npcPath.setPathType( newType );} void setStartPos( s32 xPos, s32 yPos ); virtual u8 hasBeenAttacked(); diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 5c1b2f4eb..b742d715e 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -125,7 +125,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_NO_COLLISION, DAMAGE__NONE, - 0, + 1, ANIM_DUSTDEVIL_TWIST, NPC_SHOT_GENERIC, 0, @@ -150,7 +150,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__SHOCK_ENEMY, - 16, + 1, FRM_JELLYFISH1_SWIM1, NPC_SHOT_GENERIC, 0, @@ -175,7 +175,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__SHOCK_ENEMY, - 32, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -200,7 +200,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 16, DETECT_NO_COLLISION, DAMAGE__NONE, - 16, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -225,7 +225,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_NO_COLLISION, DAMAGE__NONE, - 32, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -250,7 +250,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 16, DETECT_NO_COLLISION, DAMAGE__NONE, - 48, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -275,7 +275,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_ALL_COLLISION, DAMAGE__BITE_ENEMY, - 0, + 1, ANIM_SKELETALFISH_SWIM, NPC_SHOT_GENERIC, 0, @@ -300,7 +300,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ATTACK_COLLISION_GENERIC, DAMAGE__HIT_ENEMY, - 0, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -325,7 +325,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_NO_COLLISION, DAMAGE__HIT_ENEMY, - 0, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -350,7 +350,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 14, + 1, FRM_SQUIDDART_SWIM0001, NPC_SHOT_GENERIC, 0, @@ -375,7 +375,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_NO_COLLISION, DAMAGE__NONE, - 0, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -400,7 +400,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__POISON_ENEMY, - 9, + 1, ANIM_CATERPILLAR_CRAWL, NPC_SHOT_GENERIC, ANIM_CATERPILLAR_DIE, @@ -425,7 +425,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 256, DETECT_ATTACK_COLLISION_GENERIC, DAMAGE__SHOCK_ENEMY, - 56, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -450,7 +450,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 64, + 1, ANIM_PUFFAFISH_SWIM, NPC_SHOT_GENERIC, 0, @@ -475,7 +475,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_NO_COLLISION, DAMAGE__NONE, - 0, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -500,7 +500,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ATTACK_COLLISION_GENERIC, DAMAGE__HIT_ENEMY, - 14, + 1, ANIM_HERMITCRAB_SCUTTLE, NPC_SHOT_GENERIC, 0, @@ -525,7 +525,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 0, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -550,7 +550,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ATTACK_COLLISION_GENERIC, DAMAGE__BITE_ENEMY, - 0, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -575,7 +575,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_ATTACK_COLLISION_GENERIC, DAMAGE__PINCH_ENEMY, - 0, + 1, ANIM_SPIDERCRAB_RUN, NPC_SHOT_GENERIC, 0, @@ -600,7 +600,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_NO_COLLISION, DAMAGE__PINCH_ENEMY, - 0, + 1, ANIM_SPIDERCRAB_RUN, NPC_SHOT_NONE, 0, @@ -625,7 +625,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_NO_COLLISION, DAMAGE__HIT_ENEMY, - 32, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -650,7 +650,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 512, DETECT_ATTACK_COLLISION_GENERIC, DAMAGE__HIT_ENEMY, - 32, + 1, ANIM_BABYOCTOPUS_SWIM, NPC_SHOT_GENERIC, 0, @@ -675,7 +675,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 16, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -700,7 +700,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 64, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 16, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -725,7 +725,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 0, + 1, ANIM_GHOST_MOVE, NPC_SHOT_GENERIC, 0, @@ -750,7 +750,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 160, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -775,7 +775,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__BURN_ENEMY, - 16, + 1, ANIM_FLAMINGSKULL_MOVE, NPC_SHOT_GENERIC, 0, @@ -800,7 +800,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_ALL_COLLISION, DAMAGE__BITE_ENEMY, - 16, + 1, ANIM_SHARKMAN_RUN, NPC_SHOT_GENERIC, 0, @@ -825,7 +825,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 64, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 0, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -850,7 +850,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_ALL_COLLISION, DAMAGE__SQUASH_ENEMY, - 0, + 1, ANIM_STOMPER_CRUSH, NPC_SHOT_GENERIC, 0, @@ -925,7 +925,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 256, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -1000,7 +1000,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2048, DETECT_ALL_COLLISION, DAMAGE__HIT_ENEMY, - 256, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -1025,7 +1025,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__BURN_ENEMY, - 16, + 1, ANIM_BALLBLOB_IDLE, NPC_SHOT_GENERIC, 0, @@ -1050,7 +1050,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_NO_COLLISION, DAMAGE__BURN_ENEMY, - 16, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -1075,7 +1075,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__SHOCK_ENEMY, - 16, + 1, FRM_JELLYFISH1_SWIM1, NPC_SHOT_GENERIC, 0, @@ -1100,7 +1100,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_NO_COLLISION, DAMAGE__SHOCK_ENEMY, - 256, + 1, 0, NPC_SHOT_GENERIC, 0, @@ -1125,7 +1125,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_NO_COLLISION, DAMAGE__NONE, - 16, + 1, FRM_JELLYFISH1_SWIM1, NPC_SHOT_GENERIC, 0, @@ -1150,7 +1150,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_ALL_COLLISION, DAMAGE__SHOCK_ENEMY, - 16, + 1, FRM_JELLYFISH1_SWIM1, NPC_SHOT_GENERIC, 0, @@ -1175,7 +1175,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, DETECT_NO_COLLISION, DAMAGE__NONE, - 16, + 1, FRM_JELLYFISH1_SWIM1, NPC_SHOT_GENERIC, 0, diff --git a/source/enemy/npcpath.cpp b/source/enemy/npcpath.cpp index de757c9d9..dd406fd62 100644 --- a/source/enemy/npcpath.cpp +++ b/source/enemy/npcpath.cpp @@ -15,14 +15,22 @@ #include "enemy\npcpath.h" #endif -bool CNpcWaypoint::isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist ) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +bool CNpcPath::isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist ) { s32 xDistSqr, yDistSqr; - *xDist = this->pos.vx - testPos.vx; + u16 *waypoint = waypointPtr; + waypoint += 2 * currentWaypoint; + + *xDist = ( *waypoint << 4 ) - testPos.vx; xDistSqr = (*xDist) * (*xDist); - *yDist = this->pos.vy - testPos.vy; + waypoint++; + + *yDist = ( *waypoint << 4 ) - testPos.vy; yDistSqr = (*yDist) * (*yDist); if ( xDistSqr + yDistSqr < 100 ) @@ -35,83 +43,29 @@ bool CNpcWaypoint::isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist ) } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcPath::initPath() { - waypoint = NULL; + //waypoint = NULL; pathType = SINGLE_USE_PATH; - currentWaypoint = NULL; - lastWaypoint = NULL; + currentWaypoint = 0; + lastWaypoint = 0; waypointCount = 0; reversePath = false; minX = maxX = minY = maxY = 0; + waypointPtr = NULL; + } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcPath::resetPath() { - currentWaypoint = waypoint; - lastWaypoint = NULL; + lastWaypoint = currentWaypoint = 0; } -void CNpcPath::addWaypoint( DVECTOR newPos ) -{ - CNpcWaypoint *testWaypoint; - CNpcWaypoint *newWaypoint; - - testWaypoint = this->waypoint; - - if ( testWaypoint ) - { - // find end of path - - while ( testWaypoint->nextWaypoint ) - { - testWaypoint = testWaypoint->nextWaypoint; - } - - newWaypoint = new( "waypoint" ) CNpcWaypoint; - newWaypoint->pos = newPos; - newWaypoint->nextWaypoint = NULL; - newWaypoint->prevWaypoint = testWaypoint; - - testWaypoint->nextWaypoint = newWaypoint; - waypointCount++; - - if ( newPos.vx < minX ) - { - minX = newPos.vx; - } - else if ( newPos.vx > maxX ) - { - maxX = newPos.vx; - } - - if ( newPos.vy < minY ) - { - minY = newPos.vy; - } - else if ( newPos.vy > maxY ) - { - maxY = newPos.vy; - } - } - else - { - // no waypoints exist in this path, create - - newWaypoint = new( "waypoint" ) CNpcWaypoint; - newWaypoint->pos = newPos; - newWaypoint->nextWaypoint = NULL; - newWaypoint->prevWaypoint = NULL; - - this->waypoint = newWaypoint; - waypointCount++; - - currentWaypoint = this->waypoint; - - minX = maxX = newPos.vx; - minY = maxY = newPos.vy; - } -} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcPath::getPathXExtents( s32 *minExtent, s32 *maxExtent ) { @@ -119,48 +73,93 @@ void CNpcPath::getPathXExtents( s32 *minExtent, s32 *maxExtent ) *maxExtent = maxX; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcPath::getPathYExtents( s32 *minExtent, s32 *maxExtent ) { *minExtent = minY; *maxExtent = maxY; } -void CNpcPath::removeAllWaypoints() -{ - CNpcWaypoint *testWaypoint; - CNpcWaypoint *lastWaypoint; - - testWaypoint = this->waypoint; - - while ( testWaypoint ) - { - lastWaypoint = testWaypoint; - testWaypoint = testWaypoint->nextWaypoint; - - delete lastWaypoint; - } - - this->waypoint = NULL; -} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcPath::setPathType( u8 newPathType ) { pathType = (NPC_PATH_TYPE) newPathType; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + u8 CNpcPath::getPathType() { return( pathType ); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcPath::setWaypointPtr( u16 *newPtr ) +{ + waypointPtr = newPtr; + + setPathExtents(); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcPath::setPathExtents() +{ + u8 tempWaypoint; + u16 *tempPtr = waypointPtr; + DVECTOR mapPos; + + if ( tempPtr ) + { + mapPos.vx = *tempPtr << 4; + *tempPtr++; + mapPos.vy = *tempPtr << 4; + *tempPtr++; + + minX = maxX = mapPos.vx; + minY = maxY = mapPos.vy; + + for ( tempWaypoint = 1 ; tempWaypoint <= waypointCount ; tempWaypoint++ ) + { + mapPos.vx = *tempPtr << 4; + *tempPtr++; + mapPos.vy = *tempPtr << 4; + *tempPtr++; + + if ( mapPos.vx < minX ) + { + minX = mapPos.vx; + } + else if ( mapPos.vx > maxX ) + { + maxX = mapPos.vx; + } + + if ( mapPos.vy < minY ) + { + minY = mapPos.vy; + } + else if ( mapPos.vy > maxY ) + { + maxY = mapPos.vy; + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool CNpcPath::incPath() { if ( !reversePath ) { - if ( currentWaypoint->nextWaypoint ) + if ( currentWaypoint < waypointCount ) { lastWaypoint = currentWaypoint; - currentWaypoint = currentWaypoint->nextWaypoint; + currentWaypoint++; } else { @@ -175,7 +174,7 @@ bool CNpcPath::incPath() // go back to start lastWaypoint = currentWaypoint; - currentWaypoint = this->waypoint; + currentWaypoint = 0; break; @@ -184,10 +183,10 @@ bool CNpcPath::incPath() reversePath = !reversePath; - if ( currentWaypoint->prevWaypoint ) + if ( currentWaypoint > 0 ) { lastWaypoint = currentWaypoint; - currentWaypoint = currentWaypoint->prevWaypoint; + currentWaypoint--; } break; @@ -198,19 +197,19 @@ bool CNpcPath::incPath() { // must be pong path if reversed - if ( currentWaypoint->prevWaypoint ) + if ( currentWaypoint > 0 ) { lastWaypoint = currentWaypoint; - currentWaypoint = currentWaypoint->prevWaypoint; + currentWaypoint--; } else { reversePath = !reversePath; - if ( currentWaypoint->nextWaypoint ) + if ( currentWaypoint < waypointCount ) { lastWaypoint = currentWaypoint; - currentWaypoint = currentWaypoint->nextWaypoint; + currentWaypoint++; } } } @@ -218,11 +217,13 @@ bool CNpcPath::incPath() return( false ); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcPath::reversePathDir() { if ( lastWaypoint ) { - CNpcWaypoint *tempWaypoint; + u8 tempWaypoint; tempWaypoint = currentWaypoint; currentWaypoint = lastWaypoint; @@ -235,35 +236,36 @@ void CNpcPath::reversePathDir() } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool CNpcPath::getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ) { - return( currentWaypoint->isPointNear( currentPos, distX, distY ) ); + return( isPointNear( currentPos, distX, distY ) ); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY ) { - if ( !this->waypoint ) + if ( !waypointPtr ) { return( 0 ); } - if ( !currentWaypoint ) - { - // if no currentWaypoint set, start it off - - currentWaypoint = this->waypoint; - } - *pathComplete = false; *waypointChange = false; - if ( currentWaypoint->isPointNear( currentPos, distX, distY ) ) + if ( isPointNear( currentPos, distX, distY ) ) { *pathComplete = incPath(); *waypointChange = true; - *distX = currentWaypoint->pos.vx - currentPos.vx; - *distY = currentWaypoint->pos.vy - currentPos.vy; + u16 *waypoint = waypointPtr; + waypoint += 2 * currentWaypoint; + + *distX = ( *waypoint << 4 ) - currentPos.vx; + waypoint++; + *distY = ( *waypoint << 4 ) - currentPos.vy; } s32 headingToTarget = ratan2( *distY, *distX ); @@ -271,26 +273,25 @@ s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChang return( headingToTarget ); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading, u8 waypointDist ) { bool pointChange = false; *pathComplete = false; - if ( !this->waypoint ) + if ( !waypointPtr ) { return( true ); } - if ( !currentWaypoint ) - { - // if no currentWaypoint set, start it off + u16 *waypoint = waypointPtr; + waypoint += 2 * currentWaypoint; - currentWaypoint = this->waypoint; - } - - *distX = currentWaypoint->pos.vx - currentPos.vx; - *distY = currentWaypoint->pos.vy - currentPos.vy; + *distX = ( *waypoint << 4 ) - currentPos.vx; + waypoint++; + *distY = ( *waypoint << 4 ) - currentPos.vy; if ( abs( *distX ) < waypointDist ) { @@ -298,8 +299,12 @@ bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s3 *pathComplete = incPath(); } - *distX = currentWaypoint->pos.vx - currentPos.vx; - *distY = currentWaypoint->pos.vy - currentPos.vy; + waypoint = waypointPtr; + waypoint += 2 * currentWaypoint; + + *distX = ( *waypoint << 4 ) - currentPos.vx; + waypoint++; + *distY = ( *waypoint << 4 ) - currentPos.vy; if ( *distX > 0 ) { @@ -313,26 +318,25 @@ bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s3 return( pointChange ); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ) { bool pointChange = false; *pathComplete = false; - if ( !this->waypoint ) + if ( !waypointPtr ) { return( true ); } - if ( !currentWaypoint ) - { - // if no currentWaypoint set, start it off + u16 *waypoint = waypointPtr; + waypoint += 2 * currentWaypoint; - currentWaypoint = this->waypoint; - } - - *distX = currentWaypoint->pos.vx - currentPos.vx; - *distY = currentWaypoint->pos.vy - currentPos.vy; + *distX = ( *waypoint << 4 ) - currentPos.vx; + waypoint++; + *distY = ( *waypoint << 4 ) - currentPos.vy; if ( abs( *distY ) < 10 ) { @@ -340,8 +344,12 @@ bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX *pathComplete = incPath(); } - *distX = currentWaypoint->pos.vx - currentPos.vx; - *distY = currentWaypoint->pos.vy - currentPos.vy; + waypoint = waypointPtr; + waypoint += 2 * currentWaypoint; + + *distX = ( *waypoint << 4 ) - currentPos.vx; + waypoint++; + *distY = ( *waypoint << 4 ) - currentPos.vy; if ( *distY > 0 ) { @@ -354,8 +362,3 @@ bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX return( pointChange ); } - -CNpcWaypoint *CNpcPath::getWaypointList() -{ - return( waypoint ); -} diff --git a/source/enemy/npcpath.h b/source/enemy/npcpath.h index ce55b0a8f..368132f55 100644 --- a/source/enemy/npcpath.h +++ b/source/enemy/npcpath.h @@ -16,16 +16,6 @@ #include "system\global.h" -class CNpcWaypoint -{ -public: - DVECTOR pos; - CNpcWaypoint *nextWaypoint; - CNpcWaypoint *prevWaypoint; - - bool isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist ); -}; - class CNpcPath { public: @@ -37,7 +27,6 @@ public: }; void initPath(); - void addWaypoint( DVECTOR newPos ); void removeAllWaypoints(); void setPathType( u8 newPathType ); u8 getPathType(); @@ -51,17 +40,22 @@ public: void getPathXExtents( s32 *minExtent, s32 *maxExtent ); void getPathYExtents( s32 *minExtent, s32 *maxExtent ); u8 getWaypointCount() { return( waypointCount ); } - CNpcWaypoint *getWaypointList(); + void setWaypointCount( u8 newCount ) { waypointCount = newCount; } + void setWaypointPtr( u16 *newPtr ); + void setPathExtents(); + u16 *getWaypointPtr() { return( waypointPtr ); } + bool isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist ); private: - CNpcWaypoint *waypoint; NPC_PATH_TYPE pathType; u8 waypointCount; bool reversePath; - CNpcWaypoint *currentWaypoint; - CNpcWaypoint *lastWaypoint; + u8 currentWaypoint; + u8 lastWaypoint; s32 minX, maxX; s32 minY, maxY; + + u16 *waypointPtr; }; #endif \ No newline at end of file diff --git a/source/enemy/nworm.cpp b/source/enemy/nworm.cpp index a8503118d..ff658b7c0 100644 --- a/source/enemy/nworm.cpp +++ b/source/enemy/nworm.cpp @@ -673,26 +673,19 @@ void CNpcParasiticWormEnemy::processShot( int _frames ) { case NPC_GENERIC_HIT_CHECK_HEALTH: { - if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) + m_health -= 5; + + if ( m_health < 0 ) { m_state = NPC_GENERIC_HIT_DEATH_START; } else { - m_health -= 5; + m_state = NPC_GENERIC_HIT_RECOIL; - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - } - else - { - m_state = NPC_GENERIC_HIT_RECOIL; - - m_animPlaying = true; - m_animNo = m_data[m_type].recoilAnim; - m_frame = 0; - } + m_animPlaying = true; + m_animNo = m_data[m_type].recoilAnim; + m_frame = 0; } break; diff --git a/source/hazard/hazard.cpp b/source/hazard/hazard.cpp index 4118da789..dc722e938 100644 --- a/source/hazard/hazard.cpp +++ b/source/hazard/hazard.cpp @@ -306,7 +306,10 @@ void CNpcHazard::setWaypoints( sThingHazard *ThisHazard ) u16 newXPos, newYPos; + m_npcPath.setWaypointCount( ThisHazard->PointCount - 1 ); + newXPos = (u16) *PntList; + setWaypointPtr( PntList ); PntList++; newYPos = (u16) *PntList; PntList++; @@ -317,33 +320,6 @@ void CNpcHazard::setWaypoints( sThingHazard *ThisHazard ) Pos = startPos; m_base = Pos; - - addWaypoint( newXPos, newYPos ); - - if ( ThisHazard->PointCount > 1 ) - { - for ( pointNum = 1 ; pointNum < ThisHazard->PointCount ; pointNum++ ) - { - newXPos = (u16) *PntList; - PntList++; - newYPos = (u16) *PntList; - PntList++; - - addWaypoint( newXPos, newYPos ); - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcHazard::addWaypoint( s32 xPos, s32 yPos ) -{ - DVECTOR newPos; - - newPos.vx = xPos << 4; - newPos.vy = yPos << 4; - - m_npcPath.addWaypoint( newPos ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -391,7 +367,7 @@ void CNpcHazard::shutdown() delete m_modelGfx; // remove waypoints - m_npcPath.removeAllWaypoints(); + //m_npcPath.removeAllWaypoints(); //if (m_actorGfx) delete m_actorGfx; diff --git a/source/hazard/hazard.h b/source/hazard/hazard.h index 978237b83..168604aab 100644 --- a/source/hazard/hazard.h +++ b/source/hazard/hazard.h @@ -70,7 +70,8 @@ public: void think(int _frames); virtual void render(); virtual void setWaypoints( sThingHazard *ThisHazard ); - void addWaypoint( s32 xPos, s32 yPos ); + void setWaypointPtr( u16 *newPtr ) {m_npcPath.setWaypointPtr( newPtr );} + void setWaypointCount( u8 newCount ) {m_npcPath.setWaypointCount( newCount );} virtual void setRespawnRate( s16 newRespawnRate ) {m_respawnRate=newRespawnRate;} static NPC_HAZARD_UNIT_TYPE getTypeFromMapEdit( u16 newType ); diff --git a/source/hazard/hfalling.cpp b/source/hazard/hfalling.cpp index 0493f4e67..e6d3e755e 100644 --- a/source/hazard/hfalling.cpp +++ b/source/hazard/hfalling.cpp @@ -213,7 +213,10 @@ void CNpcFallingHazard::setWaypoints( sThingHazard *ThisHazard ) u16 newXPos, newYPos; + m_npcPath.setWaypointCount( ThisHazard->PointCount - 1 ); + newXPos = (u16) *PntList; + setWaypointPtr( PntList ); PntList++; newYPos = (u16) *PntList; PntList++; @@ -224,21 +227,6 @@ void CNpcFallingHazard::setWaypoints( sThingHazard *ThisHazard ) Pos = startPos; m_base = Pos; - - addWaypoint( newXPos, newYPos ); - - if ( ThisHazard->PointCount > 1 ) - { - for ( pointNum = 1 ; pointNum < ThisHazard->PointCount ; pointNum++ ) - { - newXPos = (u16) *PntList; - PntList++; - newYPos = (u16) *PntList; - PntList++; - - addWaypoint( newXPos, newYPos ); - } - } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/hazard/hfirebal.cpp b/source/hazard/hfirebal.cpp index cb9685bf0..0c2439e46 100644 --- a/source/hazard/hfirebal.cpp +++ b/source/hazard/hfirebal.cpp @@ -47,13 +47,14 @@ void CNpcFireballHazard::setWaypoints( sThingHazard *ThisHazard ) u16 newXPos, newYPos; + m_npcPath.setWaypointCount( ThisHazard->PointCount - 1 ); + newXPos = (u16) *PntList; + setWaypointPtr( PntList ); PntList++; newYPos = (u16) *PntList; PntList++; - addWaypoint( newXPos, newYPos ); - DVECTOR startPos; startPos.vx = newXPos << 4; startPos.vy = newYPos << 4; @@ -61,23 +62,6 @@ void CNpcFireballHazard::setWaypoints( sThingHazard *ThisHazard ) Pos = startPos; m_base = Pos; - if ( ThisHazard->PointCount > 1 ) - { - for ( pointNum = 1 ; pointNum < ThisHazard->PointCount ; pointNum++ ) - { - newXPos = (u16) *PntList; - PntList++; - newYPos = (u16) *PntList; - PntList++; - - addWaypoint( newXPos, newYPos ); - } - } - else - { - addWaypoint( newXPos, newYPos ); - } - s32 minX, maxX, minY, maxY; m_npcPath.getPathXExtents( &minX, &maxX ); diff --git a/source/hazard/hsaw.cpp b/source/hazard/hsaw.cpp index b78574c87..acb19ad9e 100644 --- a/source/hazard/hsaw.cpp +++ b/source/hazard/hsaw.cpp @@ -30,7 +30,7 @@ void CNpcSawbladeHazard::init() newPos.vx = 300; newPos.vy = 100; - m_npcPath.addWaypoint( newPos ); + //m_npcPath.addWaypoint( newPos ); m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH ); } diff --git a/source/platform/pbgeyser.cpp b/source/platform/pbgeyser.cpp index cb9d3c370..66613f90b 100644 --- a/source/platform/pbgeyser.cpp +++ b/source/platform/pbgeyser.cpp @@ -82,16 +82,8 @@ void CNpcGeyserPlatformGenerator::think( int _frames ) startPos.vx += ( -5 + ( getRnd() % 11 ) ); newPlatform->init( startPos ); - CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); - - if ( sourceWaypoint ) - { - while( sourceWaypoint ) - { - newPlatform->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 ); - sourceWaypoint = sourceWaypoint->nextWaypoint; - } - } + newPlatform->setWaypointCount( m_npcPath.getWaypointCount() ); + newPlatform->setWaypointPtr( m_npcPath.getWaypointPtr() ); newPlatform->setTiltable( false ); newPlatform->postInit(); diff --git a/source/platform/pconveyr.cpp b/source/platform/pconveyr.cpp index dc3f440d3..1a2806bea 100644 --- a/source/platform/pconveyr.cpp +++ b/source/platform/pconveyr.cpp @@ -59,7 +59,7 @@ void CNpcConveyorPlatformGenerator::think( int _frames ) //m_timer = ( 3 * GameState::getOneSecondInFrames() ) + ( getRnd() % ( ( m_data[m_type].initTimer - 1 ) * GameState::getOneSecondInFrames() ) ); - // generate new falling platform + // generate new conveyor platform CNpcPlatform *newPlatform = NULL; newPlatform = CNpcPlatform::Create( NPC_CONVEYOR_PLATFORM ); @@ -69,24 +69,11 @@ void CNpcConveyorPlatformGenerator::think( int _frames ) newPlatform->setThingSubType( NPC_CONVEYOR_PLATFORM ); newPlatform->setGraphic( m_graphicNum ); - CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); + DVECTOR startPos = Pos; + newPlatform->init( startPos ); - if ( sourceWaypoint ) - { - DVECTOR startPos; - startPos.vx = sourceWaypoint->pos.vx; - startPos.vy = sourceWaypoint->pos.vy; - //startPos.vx = 100; - //startPos.vy = 100; - - newPlatform->init( startPos ); - - while( sourceWaypoint ) - { - newPlatform->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 ); - sourceWaypoint = sourceWaypoint->nextWaypoint; - } - } + newPlatform->setWaypointCount( m_npcPath.getWaypointCount() ); + newPlatform->setWaypointPtr( m_npcPath.getWaypointPtr() ); newPlatform->setTiltable( false ); newPlatform->postInit(); diff --git a/source/platform/pfgen.cpp b/source/platform/pfgen.cpp index a9a2a9efd..54c066eb8 100644 --- a/source/platform/pfgen.cpp +++ b/source/platform/pfgen.cpp @@ -87,24 +87,28 @@ void CNpcFallingPlatformGenerator::think( int _frames ) newPlatform->setThingSubType( m_targetType ); newPlatform->setGraphic( m_graphicNum ); - CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); + DVECTOR startPos = Pos; + newPlatform->init( startPos ); + + newPlatform->setWaypointCount( m_npcPath.getWaypointCount() ); + newPlatform->setWaypointPtr( m_npcPath.getWaypointPtr() ); + + /*CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); if ( sourceWaypoint ) { DVECTOR startPos; - startPos.vx = sourceWaypoint->pos.vx; - startPos.vy = sourceWaypoint->pos.vy; - //startPos.vx = 100; - //startPos.vy = 100; + startPos.vx = *sourceWaypoint->posX << 4; + startPos.vy = *sourceWaypoint->posY << 4; newPlatform->init( startPos ); while( sourceWaypoint ) { - newPlatform->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 ); + newPlatform->addWaypoint( sourceWaypoint->posX, sourceWaypoint->posY ); sourceWaypoint = sourceWaypoint->nextWaypoint; } - } + }*/ newPlatform->setTiltable( false ); newPlatform->postInit(); diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 6a41e5cdf..6156fe5fb 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -449,10 +449,12 @@ void CNpcPlatform::setWaypoints( sThingPlatform *ThisPlatform ) int pointNum; u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform)); + u16 *waypoints; u16 newXPos, newYPos; newXPos = (u16) *PntList; + waypoints = PntList; PntList++; newYPos = (u16) *PntList; PntList++; @@ -463,20 +465,9 @@ void CNpcPlatform::setWaypoints( sThingPlatform *ThisPlatform ) init( startPos ); - addWaypoint( newXPos, newYPos ); + setWaypointCount( ThisPlatform->PointCount - 1 ); - if ( ThisPlatform->PointCount > 1 ) - { - for ( pointNum = 1 ; pointNum < ThisPlatform->PointCount ; pointNum++ ) - { - newXPos = (u16) *PntList; - PntList++; - newYPos = (u16) *PntList; - PntList++; - - addWaypoint( newXPos, newYPos ); - } - } + setWaypointPtr( waypoints ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -605,7 +596,7 @@ void CNpcPlatform::postInit() void CNpcPlatform::shutdown() { delete m_modelGfx; - m_npcPath.removeAllWaypoints(); + //m_npcPath.removeAllWaypoints(); // temporary CPlatformThing::shutdown(); @@ -1191,18 +1182,20 @@ int CNpcPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, in //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcPlatform::addWaypoint( s32 xPos, s32 yPos ) +/*void CNpcPlatform::addWaypoint( u16 *ptr ) { - DVECTOR newPos; - - newPos.vx = xPos << 4; - newPos.vy = yPos << 4; - - m_npcPath.addWaypoint( newPos ); + m_npcPath.addWaypoint( ptr ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcPlatform::addWaypoint( u16 *ptrX, u16 *ptrY ) +{ + m_npcPath.addWaypoint( ptrX, ptrY ); +}*/ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcPlatform::setTypeFromMapEdit( u16 newType ) { int Type= mapEditConvertTable[newType]; diff --git a/source/platform/platform.h b/source/platform/platform.h index db9cf052a..b77810c40 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -108,7 +108,8 @@ public: virtual u8 checkCollisionDelta( CThing *_thisThing, int threshold, CRECT collisionArea ); virtual int getHeightFromPlatformAtPosition(int _x,int _y, int offsetX = 0, int offsetY = 0); void setTiltable( bool isTiltable ); - void addWaypoint( s32 xPos, s32 yPos ); + void setWaypointPtr( u16 *newPtr ) {m_npcPath.setWaypointPtr( newPtr );} + void setWaypointCount( u8 newCount ) {m_npcPath.setWaypointCount( newCount );} void setGraphic( sThingPlatform *ThisPlatform ); void setGraphic( u8 graphicNum ); virtual void setWaypoints( sThingPlatform *ThisPlatform );