1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-15 15:07:45 +00:00
sapphire/src/world/Network/PacketWrappers/EffectPacket.h

102 lines
2.8 KiB
C
Raw Normal View History

#ifndef SAPPHIRE_EFFECTPACKET_H
#define SAPPHIRE_EFFECTPACKET_H
2019-03-08 15:34:38 +01:00
#include <Network/GamePacket.h>
#include <Network/PacketDef/Zone/ServerZoneDef.h>
#include "Forwards.h"
2018-10-26 14:11:02 +02:00
#include <string>
#include <cstring>
#include <cassert>
namespace Sapphire::Network::Packets::WorldPackets::Server
{
class EffectPacket : public ZoneChannelPacket< FFXIVIpcActionResult >
{
2018-10-28 21:53:21 +01:00
public:
EffectPacket( uint64_t sourceId, uint32_t actionId ) :
ZoneChannelPacket< FFXIVIpcActionResult >( static_cast< uint32_t >( sourceId ) )
2018-10-28 21:53:21 +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
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
m_data.TargetCount = 0;
2020-01-05 17:09:27 +09:00
std::memset( m_data.CalcResult, 0, sizeof( Common::CalcResult ) * 16 );
2018-10-28 21:53:21 +01:00
}
void addTargetEffect( const Common::CalcResultParam& effect, uint64_t targetId = Common::INVALID_GAME_OBJECT_ID64 )
2018-10-28 21:53:21 +01: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
m_data.Target[ m_data.TargetCount ] = targetId;
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 )
{
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 )
{
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 )
{
m_data.Flag = effectFlags;
2018-10-28 21:53:21 +01:00
}
void setRotation( uint16_t rotation )
{
m_data.DirTarget = rotation;
2018-10-28 21:53:21 +01:00
}
void setTargetActor( const uint32_t targetId )
{
m_data.MainTarget = static_cast< uint64_t >( targetId );
2018-10-28 21:53:21 +01:00
FFXIVPacketBase::setTargetActor( targetId );
}
2019-07-26 21:58:13 +10:00
void setSequence( uint32_t sequence, uint16_t sourceSequence = 0 )
{
m_data.RequestId = static_cast< uint32_t >( sourceSequence );
m_data.ResultId = static_cast< uint32_t>( sequence );
}
private:
uint8_t m_targetEffectCount{ 0 };
uint8_t m_sourceEffectCount{ 0 };
2018-10-28 21:53:21 +01:00
};
}
#endif //SAPPHIRE_EFFECTPACKET_H