2018-03-06 22:22:19 +01:00
|
|
|
#include <Common.h>
|
|
|
|
#include <Network/CommonNetwork.h>
|
|
|
|
#include <Exd/ExdDataGenerated.h>
|
|
|
|
#include <Network/GamePacketNew.h>
|
|
|
|
#include <Network/PacketContainer.h>
|
2018-06-23 21:38:04 +02:00
|
|
|
#include <Network/CommonActorControl.h>
|
2018-07-06 22:43:49 +10:00
|
|
|
#include <Network/PacketDef/Zone/ClientZoneDef.h>
|
2018-03-06 22:22:19 +01:00
|
|
|
#include <Logging/Logger.h>
|
2018-10-26 08:25:20 +02:00
|
|
|
#include <Util/Util.h>
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/GameConnection.h"
|
|
|
|
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
|
|
|
#include "Network/PacketWrappers/MoveActorPacket.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2018-12-22 22:25:03 +01:00
|
|
|
#include "Manager/DebugCommandMgr.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Action/Action.h"
|
|
|
|
#include "Action/ActionCast.h"
|
|
|
|
#include "Action/ActionMount.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
#include "Script/ScriptMgr.h"
|
|
|
|
|
|
|
|
#include "Session.h"
|
|
|
|
#include "Framework.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
using namespace Sapphire::Common;
|
|
|
|
using namespace Sapphire::Network::Packets;
|
|
|
|
using namespace Sapphire::Network::Packets::Server;
|
|
|
|
using namespace Sapphire::Network::ActorControl;
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2018-12-23 03:53:08 +01:00
|
|
|
void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw,
|
|
|
|
const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
2018-11-29 16:55:48 +01:00
|
|
|
Entity::Player& player )
|
2017-08-17 00:00:41 +02:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
const auto packet = ZoneChannelPacket< Client::FFXIVIpcSkillHandler >( inPacket );
|
2018-06-28 00:07:07 +02:00
|
|
|
|
2018-10-14 23:31:52 +11:00
|
|
|
const auto type = packet.data().type;
|
|
|
|
const auto action = packet.data().actionId;
|
|
|
|
const auto useCount = packet.data().useCount;
|
|
|
|
const auto targetId = packet.data().targetId;
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2019-01-05 12:32:10 +01:00
|
|
|
player.sendDebug( "Skill type: {0}", type );
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-12-23 03:53:08 +01:00
|
|
|
auto pExdData = pFw->get< Data::ExdDataGenerated >();
|
|
|
|
auto pScriptMgr = pFw->get< Scripting::ScriptMgr >();
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
switch( type )
|
|
|
|
{
|
|
|
|
case Common::SkillType::Normal:
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
if( action < 1000000 ) // normal action
|
2018-06-18 23:03:39 +02:00
|
|
|
{
|
2018-10-26 08:25:20 +02:00
|
|
|
std::string actionIdStr = Util::intToHexString( action, 4 );
|
2018-08-29 21:40:59 +02:00
|
|
|
player.sendDebug( "---------------------------------------" );
|
2019-01-05 12:32:10 +01:00
|
|
|
player.sendDebug( "ActionHandler ( {0} | {1} | {2} )",
|
|
|
|
actionIdStr, pExdData->get< Sapphire::Data::Action >( action )->name, targetId );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
player.queuePacket( makeActorControl142( player.getId(), ActorControlType::ActionStart, 0x01, action ) );
|
|
|
|
|
|
|
|
if( action == 5 )
|
|
|
|
{
|
|
|
|
auto currentAction = player.getCurrentAction();
|
|
|
|
|
|
|
|
// we should always have an action here, if not there is a bug
|
|
|
|
assert( currentAction );
|
|
|
|
currentAction->onStart();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-29 16:55:48 +01:00
|
|
|
Sapphire::Entity::ActorPtr targetActor = player.getAsPlayer();
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
if( targetId != player.getId() )
|
|
|
|
{
|
|
|
|
targetActor = player.lookupTargetById( targetId );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if we actually have an actor
|
|
|
|
if( !targetActor )
|
|
|
|
{
|
2018-06-18 23:03:39 +02:00
|
|
|
// todo: interrupt a cast.
|
|
|
|
player.sendDebug( "Invalid target." );
|
|
|
|
return;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
if( !player.actionHasCastTime( action ) )
|
|
|
|
{
|
2018-06-18 23:03:39 +02:00
|
|
|
pScriptMgr->onCastFinish( player, targetActor->getAsChara(), action );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-29 00:53:52 +01:00
|
|
|
auto pActionCast = Action::make_ActionCast( player.getAsPlayer(), targetActor->getAsChara(), action, m_pFw );
|
2018-06-18 23:03:39 +02:00
|
|
|
player.setCurrentAction( pActionCast );
|
|
|
|
player.sendDebug( "setCurrentAction()" );
|
|
|
|
player.getCurrentAction()->onStart();
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
}
|
2018-06-18 23:03:39 +02:00
|
|
|
}
|
2018-08-29 21:40:59 +02:00
|
|
|
else if( action < 2000000 ) // craft action
|
|
|
|
{
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
else if( action < 3000000 ) // item action
|
|
|
|
{
|
2018-11-29 16:55:48 +01:00
|
|
|
auto info = pExdData->get< Sapphire::Data::EventItem >( action );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( info )
|
|
|
|
{
|
|
|
|
pScriptMgr->onEventItem( player, action, info->quest, info->castTime, targetId );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( action > 3000000 ) // unknown
|
|
|
|
{
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
break;
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
case Common::SkillType::MountSkill:
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2019-01-05 12:32:10 +01:00
|
|
|
player.sendDebug( "Request mount {0}", action );
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
auto pActionMount = Action::make_ActionMount( player.getAsPlayer(), action );
|
|
|
|
player.setCurrentAction( pActionMount );
|
|
|
|
player.sendDebug( "setCurrentAction()" );
|
|
|
|
player.getCurrentAction()->onStart();
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
break;
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-10-17 21:31:00 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
}
|