2018-03-06 22:22:19 +01:00
|
|
|
#include <Common.h>
|
|
|
|
#include <Util/Util.h>
|
|
|
|
#include <Util/UtilMath.h>
|
|
|
|
#include <Logging/Logger.h>
|
2018-06-23 21:38:04 +02:00
|
|
|
#include <Network/CommonActorControl.h>
|
2018-07-21 23:32:10 +10:00
|
|
|
#include <sapphire_zone/Network/PacketWrappers/EffectPacket.h>
|
2017-12-08 15:38:25 +01:00
|
|
|
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
2018-03-02 07:22:25 -03:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Actor/Player.h"
|
2018-03-02 07:22:25 -03:00
|
|
|
#include "Script/ScriptMgr.h"
|
|
|
|
|
|
|
|
#include "ActionMount.h"
|
|
|
|
#include "Framework.h"
|
2017-10-18 15:49:19 +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-10-18 15:49:19 +02:00
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
extern Core::Framework g_framework;
|
2017-10-18 15:49:19 +02:00
|
|
|
|
|
|
|
Core::Action::ActionMount::ActionMount()
|
|
|
|
{
|
2017-12-08 15:38:25 +01:00
|
|
|
m_handleActionType = HandleActionType::Event;
|
2017-10-18 15:49:19 +02:00
|
|
|
}
|
|
|
|
|
2018-02-20 22:46:44 +01:00
|
|
|
Core::Action::ActionMount::ActionMount( Entity::CharaPtr pActor, uint16_t mountId )
|
2017-10-18 15:49:19 +02:00
|
|
|
{
|
|
|
|
m_startTime = 0;
|
2017-10-18 17:54:17 +02:00
|
|
|
m_id = mountId;
|
2017-10-18 15:49:19 +02:00
|
|
|
m_handleActionType = HandleActionType::Spell;
|
|
|
|
m_castTime = 1000;
|
|
|
|
m_pSource = pActor;
|
|
|
|
m_bInterrupt = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Core::Action::ActionMount::~ActionMount()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Core::Action::ActionMount::onStart()
|
|
|
|
{
|
|
|
|
if( !m_pSource )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_pSource->getAsPlayer()->sendDebug( "ActionMount::onStart()" );
|
|
|
|
m_startTime = Util::getTimeMs();
|
|
|
|
|
2018-06-28 00:07:07 +02:00
|
|
|
auto castPacket = makeZonePacket< FFXIVIpcActorCast >( getId() );
|
|
|
|
castPacket->data().action_id = m_id;
|
|
|
|
castPacket->data().skillType = Common::SkillType::MountSkill;
|
|
|
|
castPacket->data().unknown_1 = m_id;
|
2017-11-28 17:43:00 +01:00
|
|
|
// This is used for the cast bar above the target bar of the caster.
|
2018-06-28 00:07:07 +02:00
|
|
|
castPacket->data().cast_time = static_cast< float >( m_castTime / 1000 );
|
|
|
|
castPacket->data().target_id = m_pSource->getAsPlayer()->getId();
|
2017-10-18 15:49:19 +02:00
|
|
|
|
|
|
|
m_pSource->sendToInRangeSet( castPacket, true );
|
|
|
|
m_pSource->getAsPlayer()->setStateFlag( PlayerStateFlag::Casting );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Core::Action::ActionMount::onFinish()
|
|
|
|
{
|
|
|
|
if( !m_pSource )
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto pPlayer = m_pSource->getAsPlayer();
|
|
|
|
pPlayer->sendDebug( "ActionMount::onFinish()" );
|
|
|
|
|
|
|
|
pPlayer->unsetStateFlag( PlayerStateFlag::Casting );
|
|
|
|
|
2018-07-21 23:32:10 +10:00
|
|
|
auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 4 );
|
|
|
|
effectPacket->setRotation( Math::Util::floatToUInt16Rot( pPlayer->getRot() ) );
|
|
|
|
|
|
|
|
Server::EffectEntry effectEntry{};
|
|
|
|
effectEntry.effectType = ActionEffectType::Mount;
|
|
|
|
effectEntry.hitSeverity = ActionHitSeverityType::CritDamage;
|
|
|
|
effectEntry.value = m_id;
|
|
|
|
|
|
|
|
effectPacket->addEffect( effectEntry );
|
2017-10-18 15:49:19 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
pPlayer->sendToInRangeSet( effectPacket, true );
|
2017-10-18 15:49:19 +02:00
|
|
|
|
|
|
|
pPlayer->mount( m_id );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Core::Action::ActionMount::onInterrupt()
|
|
|
|
{
|
|
|
|
if( !m_pSource )
|
|
|
|
return;
|
|
|
|
|
2018-02-15 23:50:28 +01:00
|
|
|
//m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Occupied1 );
|
2017-10-18 15:49:19 +02:00
|
|
|
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::Casting );
|
|
|
|
|
2018-06-28 00:07:07 +02:00
|
|
|
auto control = boost::make_shared< ActorControlPacket142 >( m_pSource->getId(), ActorControlType::CastInterrupt,
|
|
|
|
0x219, 1, m_id, 0 );
|
2017-10-18 15:49:19 +02:00
|
|
|
|
|
|
|
// Note: When cast interrupt from taking too much damage, set the last value to 1. This enables the cast interrupt effect. Example:
|
|
|
|
// auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 1, m_id, 0 );
|
|
|
|
|
|
|
|
m_pSource->sendToInRangeSet( control, true );
|
|
|
|
|
|
|
|
}
|