1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-29 07:37:45 +00:00
sapphire/src/servers/sapphire_zone/Action/ActionMount.cpp

112 lines
3.5 KiB
C++
Raw Normal View History

2018-03-06 22:22:19 +01:00
#include <Common.h>
#include <Util/Util.h>
#include <Util/UtilMath.h>
#include <Logging/Logger.h>
#include <Network/CommonActorControl.h>
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include "Actor/Player.h"
#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;
using namespace Core::Network::ActorControl;
2017-10-18 15:49:19 +02:00
extern Core::Framework g_framework;
2017-10-18 15:49:19 +02:00
Core::Action::ActionMount::ActionMount()
{
m_handleActionType = HandleActionType::Event;
2017-10-18 15:49:19 +02: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 15:54:37 +10:00
auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() );
2018-06-28 00:07:07 +02:00
2018-07-21 15:54:37 +10:00
effectPacket->data().animationTargetId = pPlayer->getId();
2018-06-28 00:07:07 +02:00
effectPacket->data().actionAnimationId = m_id;
// Affects displaying action name next to number in floating text
//effectPacket->data().unknown_62 = 13;
2018-07-21 15:54:37 +10:00
effectPacket->data().actionAnimationId = 4;
2018-06-28 00:07:07 +02:00
effectPacket->data().numEffects = 1;
effectPacket->data().rotation = Math::Util::floatToUInt16Rot( pPlayer->getRot() );
//effectPacket->data().effectTarget = INVALID_GAME_OBJECT_ID;
2018-06-28 00:07:07 +02:00
effectPacket->data().effects[0].effectType = ActionEffectType::Mount;
effectPacket->data().effects[0].hitSeverity = ActionHitSeverityType::CritDamage;
effectPacket->data().effects[0].value = m_id;
2017-10-18 15:49:19 +02: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;
//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 );
}