2018-03-06 22:22:19 +01:00
|
|
|
#include <Util/Util.h>
|
|
|
|
#include <Exd/ExdDataGenerated.h>
|
|
|
|
#include <Logging/Logger.h>
|
2018-06-23 21:38:04 +02:00
|
|
|
#include <Network/CommonActorControl.h>
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
2018-03-02 07:22:25 -03:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Actor/Player.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
#include "ActionTeleport.h"
|
|
|
|
#include "Framework.h"
|
|
|
|
|
2017-08-08 13:53:47 +02:00
|
|
|
using namespace Core::Common;
|
|
|
|
using namespace Core::Network;
|
|
|
|
using namespace Core::Network::Packets;
|
|
|
|
using namespace Core::Network::Packets::Server;
|
2018-06-23 21:38:04 +02:00
|
|
|
using namespace Core::Network::ActorControl;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-03-09 00:06:44 +01:00
|
|
|
extern Core::Framework g_fw;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
Core::Action::ActionTeleport::ActionTeleport()
|
|
|
|
{
|
2017-12-08 15:38:25 +01:00
|
|
|
m_handleActionType = HandleActionType::Event;
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
2018-02-20 22:46:44 +01:00
|
|
|
Core::Action::ActionTeleport::ActionTeleport( Entity::CharaPtr pActor, uint16_t targetZone, uint16_t cost )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2018-03-09 00:06:44 +01:00
|
|
|
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
2017-08-08 13:53:47 +02:00
|
|
|
m_startTime = 0;
|
|
|
|
m_id = 5;
|
2017-09-05 00:37:22 -03:00
|
|
|
m_handleActionType = HandleActionType::Teleport;
|
2018-03-09 00:06:44 +01:00
|
|
|
m_castTime = pExdData->get< Core::Data::Action >( 5 )->cast100ms * 100; // TODO: Add security checks.
|
2017-08-08 13:53:47 +02:00
|
|
|
m_pSource = pActor;
|
|
|
|
m_bInterrupt = false;
|
|
|
|
m_targetAetheryte = targetZone;
|
|
|
|
m_cost = cost;
|
|
|
|
}
|
|
|
|
|
|
|
|
Core::Action::ActionTeleport::~ActionTeleport()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Core::Action::ActionTeleport::onStart()
|
|
|
|
{
|
|
|
|
if( !m_pSource )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_startTime = Util::getTimeMs();
|
|
|
|
|
2018-06-28 00:07:07 +02:00
|
|
|
auto castPacket = makeZonePacket< FFXIVIpcActorCast >( getId() );
|
|
|
|
castPacket->data().action_id = 5;
|
|
|
|
castPacket->data().unknown = 1;
|
|
|
|
castPacket->data().cast_time = 5.0f;
|
|
|
|
castPacket->data().target_id = m_pSource->getId();
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
m_pSource->sendToInRangeSet( castPacket, true );
|
|
|
|
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Core::Action::ActionTeleport::onFinish()
|
|
|
|
{
|
|
|
|
if( !m_pSource )
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto pPlayer = m_pSource->getAsPlayer();
|
|
|
|
|
|
|
|
// check we can finish teleporting
|
2018-07-20 22:39:10 +02:00
|
|
|
if( pPlayer->getCurrency( Common::CurrencyType::Gil ) < m_cost )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
onInterrupt();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-20 22:39:10 +02:00
|
|
|
pPlayer->removeCurrency( Common::CurrencyType::Gil, m_cost );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
pPlayer->unsetStateFlag( PlayerStateFlag::Casting );
|
|
|
|
|
|
|
|
// TODO: not sure if this ever gets sent
|
|
|
|
//auto control = Network::Packets::Server::ActorControlPacket142( m_pSource->getId(), Common::ActorControlType::TeleportDone );
|
|
|
|
//m_pSource->sendToInRangeSet( control, false );
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
pPlayer->setZoningType( ZoneingType::Teleport );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-06-28 00:07:07 +02:00
|
|
|
auto effectPacket = makeZonePacket< FFXIVIpcEffect >( getId() );
|
|
|
|
effectPacket->data().targetId = pPlayer->getId();
|
|
|
|
effectPacket->data().actionAnimationId = 5;
|
2017-08-08 13:53:47 +02:00
|
|
|
//effectPacket.data().unknown_3 = 1;
|
2018-06-28 00:07:07 +02:00
|
|
|
effectPacket->data().actionTextId = 5;
|
|
|
|
effectPacket->data().unknown_5 = 1;
|
|
|
|
effectPacket->data().numEffects = 1;
|
|
|
|
effectPacket->data().rotation = static_cast< uint16_t >( 0x8000 * ( ( pPlayer->getRot() + 3.1415926 ) ) / 3.1415926 );
|
2018-07-20 22:39:10 +02:00
|
|
|
effectPacket->data().effectTargetId = pPlayer->getId();
|
2017-08-08 13:53:47 +02:00
|
|
|
pPlayer->sendToInRangeSet( effectPacket, true );
|
|
|
|
|
|
|
|
pPlayer->teleport( m_targetAetheryte );
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Core::Action::ActionTeleport::onInterrupt()
|
|
|
|
{
|
|
|
|
if( !m_pSource )
|
|
|
|
return;
|
|
|
|
|
2017-08-30 18:45:34 +02:00
|
|
|
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-06-28 00:07:07 +02:00
|
|
|
auto control = boost::make_shared< ActorControlPacket142 >( m_pSource->getId(), ActorControlType::CastInterrupt,
|
|
|
|
0x219, 0x04, m_id, 0 );
|
2017-08-08 13:53:47 +02:00
|
|
|
m_pSource->sendToInRangeSet( control, true );
|
|
|
|
|
|
|
|
}
|