2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
2017-02-05 07:01:33 +00:00
|
|
|
#include "PacketPlayerAttack.hpp"
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-02-05 07:01:33 +00:00
|
|
|
PacketPlayerAttack::PacketPlayerAttack(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-02-05 07:01:33 +00:00
|
|
|
packetID = ID_PLAYER_ATTACK;
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 08:17:33 +00:00
|
|
|
void PacketPlayerAttack::Packet(RakNet::BitStream *newBitstream, bool send)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2019-12-04 08:17:33 +00:00
|
|
|
PlayerPacket::Packet(newBitstream, send);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2018-04-05 09:48:53 +00:00
|
|
|
RW(player->attack.target.isPlayer, send);
|
|
|
|
|
|
|
|
if (player->attack.target.isPlayer)
|
|
|
|
{
|
|
|
|
RW(player->attack.target.guid, send);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-02 18:50:21 +00:00
|
|
|
RW(player->attack.target.refId, send, true);
|
2018-07-13 01:12:03 +00:00
|
|
|
RW(player->attack.target.refNum, send);
|
2018-04-05 09:48:53 +00:00
|
|
|
RW(player->attack.target.mpNum, send);
|
|
|
|
}
|
2017-04-17 14:24:11 +00:00
|
|
|
|
2017-01-25 15:06:15 +00:00
|
|
|
RW(player->attack.type, send);
|
2017-04-18 07:03:58 +00:00
|
|
|
|
2019-08-25 06:35:23 +00:00
|
|
|
RW(player->attack.pressed, send);
|
|
|
|
RW(player->attack.success, send);
|
2018-07-21 11:41:27 +00:00
|
|
|
|
2019-08-25 06:35:23 +00:00
|
|
|
RW(player->attack.isHit, send);
|
2018-09-17 22:13:48 +00:00
|
|
|
|
2019-11-29 08:39:57 +00:00
|
|
|
if (player->attack.type == mwmp::Attack::MELEE)
|
|
|
|
{
|
2019-11-29 09:19:24 +00:00
|
|
|
RW(player->attack.attackAnimation, send, true);
|
2019-11-29 08:39:57 +00:00
|
|
|
}
|
|
|
|
else if (player->attack.type == mwmp::Attack::RANGED)
|
2019-08-25 06:35:23 +00:00
|
|
|
{
|
|
|
|
RW(player->attack.attackStrength, send);
|
2019-11-29 09:19:24 +00:00
|
|
|
RW(player->attack.rangedWeaponId, send, true);
|
|
|
|
RW(player->attack.rangedAmmoId, send, true);
|
2019-08-25 06:35:23 +00:00
|
|
|
}
|
2018-09-11 08:56:45 +00:00
|
|
|
|
2019-08-25 06:35:23 +00:00
|
|
|
if (player->attack.isHit)
|
|
|
|
{
|
|
|
|
RW(player->attack.damage, send);
|
|
|
|
RW(player->attack.block, send);
|
|
|
|
RW(player->attack.knockdown, send);
|
|
|
|
RW(player->attack.applyWeaponEnchantment, send);
|
2018-09-22 23:30:31 +00:00
|
|
|
|
2019-08-25 06:35:23 +00:00
|
|
|
if (player->attack.type == mwmp::Attack::RANGED)
|
|
|
|
RW(player->attack.applyAmmoEnchantment, send);
|
2018-09-22 23:30:31 +00:00
|
|
|
|
2019-08-25 06:35:23 +00:00
|
|
|
RW(player->attack.hitPosition.pos[0], send);
|
|
|
|
RW(player->attack.hitPosition.pos[1], send);
|
|
|
|
RW(player->attack.hitPosition.pos[2], send);
|
2018-07-21 11:41:27 +00:00
|
|
|
}
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|