2018-07-21 23:32:10 +10:00
|
|
|
#ifndef SAPPHIRE_EFFECTPACKET_H
|
|
|
|
#define SAPPHIRE_EFFECTPACKET_H
|
|
|
|
|
2019-03-08 15:34:38 +01:00
|
|
|
#include <Network/GamePacket.h>
|
2018-07-21 23:32:10 +10:00
|
|
|
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
|
|
|
#include "Forwards.h"
|
2018-10-26 14:11:02 +02:00
|
|
|
#include <string>
|
|
|
|
#include <cstring>
|
|
|
|
#include <cassert>
|
2018-07-21 23:32:10 +10:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
namespace Sapphire::Network::Packets::WorldPackets::Server
|
2018-07-21 23:32:10 +10:00
|
|
|
{
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
class EffectPacket : public ZoneChannelPacket< FFXIVIpcActionResult >
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
2018-10-28 21:53:21 +01:00
|
|
|
public:
|
2022-01-10 19:31:21 -03:00
|
|
|
EffectPacket( uint64_t sourceId, uint32_t actionId ) :
|
|
|
|
ZoneChannelPacket< FFXIVIpcActionResult >( static_cast< uint32_t >( sourceId ) )
|
2018-10-28 21:53:21 +01:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
m_data.Flag = 0;
|
|
|
|
m_data.ActionKey = actionId;
|
|
|
|
m_data.Action = static_cast< uint16_t >( actionId );
|
2022-01-02 22:32:17 +01:00
|
|
|
m_data.ActionKind = 1;
|
2018-10-28 21:53:21 +01:00
|
|
|
|
2022-01-10 19:31:21 -03:00
|
|
|
m_data.MainTarget = Common::INVALID_GAME_OBJECT_ID;
|
|
|
|
m_data.BallistaEntityId = Common::INVALID_GAME_OBJECT_ID;
|
|
|
|
|
2022-01-02 22:32:17 +01:00
|
|
|
m_data.LockTime = 0.6f;
|
2018-10-28 21:53:21 +01:00
|
|
|
|
2022-01-10 19:31:21 -03:00
|
|
|
m_data.TargetCount = 0;
|
2020-01-05 17:09:27 +09:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
std::memset( m_data.CalcResult, 0, sizeof( Common::CalcResult ) * 16 );
|
2018-10-28 21:53:21 +01:00
|
|
|
}
|
|
|
|
|
2022-01-10 19:31:21 -03:00
|
|
|
void addTargetEffect( const Common::CalcResultParam& effect, uint64_t targetId = Common::INVALID_GAME_OBJECT_ID64 )
|
2018-10-28 21:53:21 +01:00
|
|
|
{
|
2022-01-10 19:31:21 -03:00
|
|
|
std::memcpy( &m_data.CalcResult[ m_data.TargetCount ].CalcResultTg[ m_targetEffectCount++ ], &effect, sizeof( Common::CalcResultParam ) );
|
|
|
|
|
|
|
|
// iterate and see if we already have this target added
|
|
|
|
bool targetAlreadyAdded = false;
|
|
|
|
for( int i = 0; i < sizeof( m_data.Target ) / sizeof( uint64_t ); ++i )
|
|
|
|
{
|
|
|
|
if( m_data.Target[ i ] == targetId )
|
|
|
|
{
|
|
|
|
targetAlreadyAdded = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-10-28 21:53:21 +01:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
m_data.Target[ m_data.TargetCount ] = targetId;
|
2022-01-10 19:31:21 -03:00
|
|
|
|
|
|
|
if( !targetAlreadyAdded )
|
|
|
|
m_data.TargetCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void addSourceEffect( const Common::CalcResultParam& effect )
|
|
|
|
{
|
|
|
|
// we associate the source effect with the current target index set
|
|
|
|
std::memcpy( &m_data.CalcResult[ m_data.TargetCount - 1 ].CalcResultCt[ m_sourceEffectCount++ ], &effect, sizeof( Common::CalcResultParam ) );
|
2018-10-28 21:53:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void setAnimationId( uint16_t animationId )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
m_data.Action = animationId;
|
2018-10-28 21:53:21 +01:00
|
|
|
}
|
|
|
|
|
2019-02-09 21:48:42 +11:00
|
|
|
void setDisplayType( Common::ActionEffectDisplayType displayType )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
m_data.ActionArg = displayType;
|
2019-02-09 21:48:42 +11:00
|
|
|
}
|
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
void setEffectFlags( uint32_t effectFlags )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
m_data.Flag = effectFlags;
|
2018-10-28 21:53:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void setRotation( uint16_t rotation )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
m_data.DirTarget = rotation;
|
2018-10-28 21:53:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void setTargetActor( const uint32_t targetId )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
m_data.MainTarget = static_cast< uint64_t >( targetId );
|
2018-10-28 21:53:21 +01:00
|
|
|
|
|
|
|
FFXIVPacketBase::setTargetActor( targetId );
|
|
|
|
}
|
2019-02-11 11:47:04 +11:00
|
|
|
|
2019-07-26 21:58:13 +10:00
|
|
|
void setSequence( uint32_t sequence, uint16_t sourceSequence = 0 )
|
2019-02-11 11:47:04 +11:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
m_data.RequestId = static_cast< uint32_t >( sourceSequence );
|
|
|
|
m_data.ResultId = static_cast< uint32_t>( sequence );
|
2019-02-11 11:47:04 +11:00
|
|
|
}
|
2022-01-10 19:31:21 -03:00
|
|
|
private:
|
|
|
|
uint8_t m_targetEffectCount{ 0 };
|
|
|
|
uint8_t m_sourceEffectCount{ 0 };
|
2018-10-28 21:53:21 +01:00
|
|
|
};
|
2018-07-21 23:32:10 +10:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //SAPPHIRE_EFFECTPACKET_H
|