2023-02-16 08:24:39 +01:00
|
|
|
#include "ActionIntegrityTask.h"
|
|
|
|
|
|
|
|
#include <Logging/Logger.h>
|
|
|
|
#include <Actor/Player.h>
|
|
|
|
#include <Actor/Chara.h>
|
|
|
|
#include <WorldServer.h>
|
|
|
|
#include <Service.h>
|
|
|
|
#include <Network/PacketWrappers/WarpPacket.h>
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
using namespace Sapphire::World;
|
|
|
|
using namespace Sapphire::World::Manager;
|
|
|
|
using namespace Sapphire::Network::Packets;
|
|
|
|
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
|
|
|
|
2023-03-10 17:32:52 +01:00
|
|
|
ActionIntegrityTask::ActionIntegrityTask( uint32_t resultId, Entity::CharaPtr pTarget, Action::ActionResultList& results, uint64_t delayTime ) : Task( delayTime )
|
2023-02-16 08:24:39 +01:00
|
|
|
{
|
2023-03-10 17:32:52 +01:00
|
|
|
Logger::debug( "Constructor called {} {} {}", resultId, pTarget->getId(), results.size() );
|
2023-02-16 08:24:39 +01:00
|
|
|
m_resultId = resultId;
|
|
|
|
m_pTarget = std::move( pTarget );
|
2023-03-10 17:32:52 +01:00
|
|
|
m_results = results;
|
2023-02-16 08:24:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionIntegrityTask::onQueue()
|
|
|
|
{
|
|
|
|
Logger::debug( { __FUNCTION__ } );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionIntegrityTask::execute()
|
|
|
|
{
|
2023-03-10 17:32:52 +01:00
|
|
|
if( !m_pTarget )
|
|
|
|
return;
|
|
|
|
|
2023-02-16 08:24:39 +01:00
|
|
|
auto& server = Common::Service< WorldServer >::ref();
|
|
|
|
|
|
|
|
auto inRangePlayers = m_pTarget->getInRangePlayerIds( true );
|
|
|
|
|
|
|
|
if( inRangePlayers.empty() )
|
|
|
|
return;
|
|
|
|
|
2023-03-10 17:32:52 +01:00
|
|
|
for( auto& actionResult : m_results )
|
|
|
|
{
|
|
|
|
if( actionResult && actionResult->getTarget() && actionResult->getTarget()->isAlive() )
|
|
|
|
actionResult->execute();
|
|
|
|
}
|
|
|
|
|
2023-02-16 08:24:39 +01:00
|
|
|
auto integrityPacket = makeZonePacket< FFXIVIpcActionIntegrity >( 0 );
|
|
|
|
auto& data = integrityPacket->data();
|
|
|
|
integrityPacket->setSourceActor( m_pTarget->getId() );
|
|
|
|
data.Hp = m_pTarget->getHp();
|
|
|
|
data.HpMax = m_pTarget->getMaxHp();
|
|
|
|
data.Mp = m_pTarget->getMp();
|
|
|
|
data.MpMax = m_pTarget->getMaxMp();
|
|
|
|
data.Tp = m_pTarget->getTp();
|
|
|
|
data.ResultId = m_resultId;
|
|
|
|
data.Target = m_pTarget->getId();
|
|
|
|
|
2023-02-17 15:34:51 +01:00
|
|
|
server.queueForPlayers( inRangePlayers, integrityPacket );
|
2023-02-16 08:24:39 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ActionIntegrityTask::toString()
|
|
|
|
{
|
2023-03-10 17:32:52 +01:00
|
|
|
return fmt::format( "ActionIntegrityTask: ResultId#{}, TargetId#{}, ElapsedTimeMs: {}", m_resultId, m_pTarget ? m_pTarget->getId() : 0, getDelayTimeMs() );
|
2023-02-16 08:24:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|