Skip to content

Commit

Permalink
Fix for BNpcs positions not being updated properly through timelines …
Browse files Browse the repository at this point in the history
…and removal of unnused code
  • Loading branch information
SapphireMordred committed Jan 15, 2025
1 parent 866103c commit e3b53b5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
12 changes: 11 additions & 1 deletion src/world/Actor/BNpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,4 +1091,14 @@ const Common::FFXIVARR_POSITION3& BNpc::getRoamTargetPos() const
const Common::FFXIVARR_POSITION3& BNpc::getSpawnPos() const
{
return m_spawnPos;
}
}

void BNpc::setPos( float x, float y, float z, bool broadcastUpdate )
{
Chara::setPos( x, y, z, broadcastUpdate );
}

void BNpc::setPos( const FFXIVARR_POSITION3& pos, bool broadcastUpdate )
{
setPos( pos.x, pos.y, pos.z, broadcastUpdate );
}
3 changes: 3 additions & 0 deletions src/world/Actor/BNpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ namespace Sapphire::Entity
uint32_t getTimeOfDeath() const;
void setTimeOfDeath( uint32_t timeOfDeath );

void setPos( const Common::FFXIVARR_POSITION3& pos, bool broadcastUpdate = true ) override;
void setPos( float x, float y, float z, bool broadcastUpdate = true ) override;

void restHp();

void checkAggro();
Expand Down
21 changes: 0 additions & 21 deletions src/world/Encounter/InstanceContent/IfritNormal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ namespace Sapphire

void init() override
{
m_status = EncounterFightStatus::IDLE;
m_startTime = 0;

m_stateStack = std::make_shared< EncounterState::StateStack >();

// todo: i don't like this
auto boss = m_pInstance->createBNpcFromLayoutId( NPC_IFRIT, VAL_IFRIT_HP, Common::BNpcType::Enemy );
boss->init();
Expand All @@ -33,7 +30,6 @@ namespace Sapphire
void start() override
{

m_status = EncounterFightStatus::ACTIVE;
}

void reset() override
Expand All @@ -51,24 +47,7 @@ namespace Sapphire

void update( uint64_t deltaTime ) override
{
// todo: better way to start fights here..
// this probably doesn't need to be overriden either

auto ifrit = getBNpc( NPC_IFRIT );

if( ifrit; ifrit->hateListGetHighestValue() != 0 && m_status == EncounterFightStatus::IDLE )
{
m_startTime = deltaTime;
start();
}

if( m_status == EncounterFightStatus::ACTIVE && ifrit && ( !ifrit->hateListGetHighest() || !ifrit->hateListGetHighest()->isAlive() ) )
{
m_status = EncounterFightStatus::FAIL;
}

m_pInstance->getEncounterTimeline().update( getInstance(), deltaTime );

}
};
}// namespace Sapphire
22 changes: 19 additions & 3 deletions src/world/Encounter/Timepoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@

#include <Event/Director.h>

#include <Manager/TerritoryMgr.h>
#include <Manager/ActionMgr.h>
#include <Manager/PlayerMgr.h>
#include <Service.h>


#include <Territory/Territory.h>
#include <Territory/QuestBattle.h>
#include <Territory/InstanceContent.h>
#include <Util/UtilMath.h>

#include <Network/CommonActorControl.h>
#include <Network/Util/PacketUtil.h>

#include <Navi/NaviProvider.h>

namespace Sapphire::Encounter
{
const TimepointDataPtr Timepoint::getData() const
Expand Down Expand Up @@ -58,7 +63,7 @@ namespace Sapphire::Encounter
{ "idle", TimepointDataType::Idle },
{ "castAction", TimepointDataType::CastAction },
{ "setPos", TimepointDataType::SetPos },
{ "playActionTimeLine", TimepointDataType::ActionTimeLine },
{ "actionTimeline", TimepointDataType::ActionTimeLine },

{ "logMessage", TimepointDataType::LogMessage },
{ "battleTalk", TimepointDataType::BattleTalk },
Expand Down Expand Up @@ -156,7 +161,7 @@ namespace Sapphire::Encounter
case TimepointDataType::ActionTimeLine:
{
auto& dataJ = json.at( "data" );
auto action = dataJ.at( "action" ).get< uint32_t >();
auto action = dataJ.at( "actionTimelineId" ).get< uint32_t >();
auto actorRef = dataJ.at( "actorName" ).get< std::string >();

m_pData = std::make_shared< TimepointDataActionTimeLine >( actorRef, action );
Expand All @@ -179,10 +184,11 @@ namespace Sapphire::Encounter
auto pBattleTalkData = std::make_shared< TimepointDataBattleTalk >( params );

pBattleTalkData->m_battleTalkId = dataJ.at( "battleTalkId" ).get< uint32_t >();
pBattleTalkData->m_handlerRef = dataJ.at( "handlerActorName" ).get< std::string >();

pBattleTalkData->m_kind = dataJ.at( "kind" ).get< uint32_t >();
pBattleTalkData->m_nameId = dataJ.at( "nameId" ).get< uint32_t >();
pBattleTalkData->m_talkerRef = dataJ.at( "talkerActorName" ).get< std::string >();
pBattleTalkData->m_handlerRef = pBattleTalkData->m_talkerRef;

m_pData = pBattleTalkData;
}
Expand Down Expand Up @@ -456,6 +462,16 @@ namespace Sapphire::Encounter
{
pBNpc->setRot( pSetPosData->m_rot );
pBNpc->setPos( pSetPosData->m_x, pSetPosData->m_y, pSetPosData->m_z, true );
auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref();
auto pZone = teriMgr.getTerritoryByGuId( pBNpc->getTerritoryId() );

auto pNaviProvider = pZone->getNaviProvider();

if( pNaviProvider )
{
pNaviProvider->updateAgentPosition( *pBNpc );
}
pBNpc->sendPositionUpdate();
}
}
break;
Expand Down

0 comments on commit e3b53b5

Please sign in to comment.