2018-03-06 22:22:19 +01:00
|
|
|
#include <Common.h>
|
2021-11-27 00:53:57 +01:00
|
|
|
#include <Exd/ExdData.h>
|
2019-03-08 15:34:38 +01:00
|
|
|
#include <Network/GamePacket.h>
|
2018-07-06 22:43:49 +10:00
|
|
|
#include <Network/PacketDef/Zone/ClientZoneDef.h>
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2019-02-09 14:45:22 +11:00
|
|
|
#include <Actor/Player.h>
|
2020-03-01 01:00:57 +11:00
|
|
|
#include <Service.h>
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2019-02-09 14:45:22 +11:00
|
|
|
#include "Network/GameConnection.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2019-02-03 19:57:04 +11:00
|
|
|
#include "Manager/ActionMgr.h"
|
2021-11-27 00:53:57 +01:00
|
|
|
#include "Manager/PlayerMgr.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
using namespace Sapphire::Common;
|
2021-11-27 00:53:57 +01:00
|
|
|
using namespace Sapphire::World::Manager;
|
2018-11-29 16:55:48 +01:00
|
|
|
using namespace Sapphire::Network::Packets;
|
2021-11-27 00:53:57 +01:00
|
|
|
using namespace Sapphire::Network::Packets::WorldPackets::Client;
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
void Sapphire::Network::GameConnection::actionRequest( 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
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
const auto packet = ZoneChannelPacket< FFXIVIpcActionRequest >( inPacket );
|
2018-06-28 00:07:07 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
const auto type = packet.data().ActionKind;
|
|
|
|
const auto actionId = packet.data().ActionKey;
|
|
|
|
const auto sequence = packet.data().RequestId;
|
|
|
|
const auto targetId = packet.data().Target;
|
|
|
|
const auto itemSourceSlot = packet.data().Arg & 0xFFFF0000;
|
|
|
|
const auto itemSourceContainer = packet.data().Arg & 0x0000FFFF;
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
PlayerMgr::sendDebug( player, "Skill type: {0}, sequence: {1}, actionId: {2}, targetId: {3}", type, sequence, actionId, targetId );
|
2019-02-09 19:26:31 +11:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
auto& exdData = Common::Service< Data::ExdData >::ref();
|
2020-03-01 01:00:57 +11:00
|
|
|
auto& actionMgr = Common::Service< World::Manager::ActionMgr >::ref();
|
2019-02-09 21:48:42 +11:00
|
|
|
|
2019-02-09 19:26:31 +11:00
|
|
|
switch( type )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
PlayerMgr::sendDebug( player, "Skill type {0} not supported. Defaulting to normal action", type );
|
2019-02-09 19:26:31 +11:00
|
|
|
}
|
|
|
|
case Common::SkillType::Normal:
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto action = exdData.getRow< Component::Excel::Action >( actionId );
|
2019-02-09 19:26:31 +11:00
|
|
|
|
|
|
|
// ignore invalid actions
|
|
|
|
if( !action )
|
|
|
|
return;
|
|
|
|
|
2020-03-01 01:00:57 +11:00
|
|
|
actionMgr.handleTargetedPlayerAction( player, actionId, action, targetId, sequence );
|
2019-02-09 19:26:31 +11:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Common::SkillType::ItemAction:
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto item = exdData.getRow< Component::Excel::Item >( actionId );
|
2019-02-09 19:26:31 +11:00
|
|
|
if( !item )
|
|
|
|
return;
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
if( item->data().Action == 0 )
|
2019-02-09 19:26:31 +11:00
|
|
|
return;
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
auto itemAction = exdData.getRow< Component::Excel::ItemAction >( item->data().Action );
|
2019-02-09 21:48:42 +11:00
|
|
|
if( !itemAction )
|
|
|
|
return;
|
|
|
|
|
2020-03-01 01:00:57 +11:00
|
|
|
actionMgr.handleItemAction( player, actionId, itemAction, itemSourceSlot, itemSourceContainer );
|
2019-02-09 19:26:31 +11:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Common::SkillType::MountSkill:
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto action = exdData.getRow< Component::Excel::Action >( 4 );
|
2020-01-23 22:36:01 +09:00
|
|
|
assert( action );
|
2020-03-01 01:00:57 +11:00
|
|
|
actionMgr.handleMountAction( player, static_cast< uint16_t >( actionId ), action, targetId, sequence );
|
2019-02-09 19:26:31 +11:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-02-09 14:45:22 +11:00
|
|
|
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2019-02-09 14:45:22 +11:00
|
|
|
|
2019-02-03 19:57:04 +11:00
|
|
|
}
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
void Sapphire::Network::GameConnection::selectGroundActionRequest( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
2019-04-28 23:34:43 +02:00
|
|
|
Entity::Player& player )
|
2019-02-03 19:57:04 +11:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
const auto packet = ZoneChannelPacket< FFXIVIpcSelectGroundActionRequest >( inPacket );
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
const auto type = packet.data().ActionKind;
|
|
|
|
const auto actionId = packet.data().ActionKey;
|
|
|
|
const auto sequence = packet.data().RequestId;
|
|
|
|
const auto pos = packet.data().Pos;
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2019-02-09 19:26:31 +11:00
|
|
|
// todo: find out if there are any other action types which actually use this handler
|
|
|
|
if( type != Common::SkillType::Normal )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
PlayerMgr::sendDebug( player, "Skill type {0} not supported by aoe action handler!", type );
|
2019-02-09 19:26:31 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
PlayerMgr::sendDebug( player, "Skill type: {0}, sequence: {1}, actionId: {2}, x:{3}, y:{4}, z:{5}",
|
2019-04-28 23:34:43 +02:00
|
|
|
type, sequence, actionId, pos.x, pos.y, pos.z );
|
2019-02-09 19:26:31 +11:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
auto& exdData = Common::Service< Data::ExdData >::ref();
|
2019-02-09 14:45:22 +11:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
auto action = exdData.getRow< Component::Excel::Action >( actionId );
|
2019-02-09 14:45:22 +11:00
|
|
|
|
|
|
|
// ignore invalid actions
|
|
|
|
if( !action )
|
|
|
|
return;
|
|
|
|
|
2020-03-01 01:00:57 +11:00
|
|
|
auto& actionMgr = Common::Service< World::Manager::ActionMgr >::ref();
|
|
|
|
actionMgr.handlePlacedPlayerAction( player, actionId, action, pos, sequence );
|
2017-12-08 11:46:47 +01:00
|
|
|
}
|