mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 07:19:41 +00:00
[General] Add and use Target struct in mwmp::Attack
This commit is contained in:
parent
9882ceedf3
commit
a650683bae
6 changed files with 20 additions and 10 deletions
|
@ -26,7 +26,7 @@ namespace mwmp
|
|||
|
||||
if (!player.creatureStats.mDead)
|
||||
{
|
||||
Player *target = Players::getPlayer(player.attack.targetGuid);
|
||||
Player *target = Players::getPlayer(player.attack.target.guid);
|
||||
|
||||
if (target == nullptr)
|
||||
target = &player;
|
||||
|
@ -46,7 +46,7 @@ namespace mwmp
|
|||
|
||||
//packet.Send(player, true);
|
||||
player.sendToLoaded(&packet);
|
||||
playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->RequestData(player.attack.targetGuid);
|
||||
playerController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->RequestData(player.attack.target.guid);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -629,7 +629,7 @@ namespace MWClass
|
|||
mwmp::Main::get().getLocalPlayer()->attack.success = true;
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(victim);
|
||||
if (dedicatedPlayer != nullptr)
|
||||
mwmp::Main::get().getLocalPlayer()->attack.targetGuid = dedicatedPlayer->guid;
|
||||
mwmp::Main::get().getLocalPlayer()->attack.target.guid = dedicatedPlayer->guid;
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -930,7 +930,7 @@ namespace MWClass
|
|||
{
|
||||
mwmp::Attack *attack = &mwmp::Main::get().getLocalPlayer()->attack;
|
||||
attack->damage = damage;
|
||||
attack->targetGuid = victimPlayer->guid;
|
||||
attack->target.guid = victimPlayer->guid;
|
||||
attack->knockdown = getCreatureStats(ptr).getKnockedDown();
|
||||
mwmp::Main::get().getLocalPlayer()->sendAttack(mwmp::Attack::MELEE); // todo: make this sensitive to different weapon types
|
||||
}
|
||||
|
|
|
@ -1195,7 +1195,7 @@ void LocalPlayer::prepareAttack(Attack::TYPE type, bool state)
|
|||
attack.type = type;
|
||||
attack.knockdown = false;
|
||||
attack.block = false;
|
||||
attack.targetGuid = RakNet::RakNetGUID();
|
||||
attack.target.guid = RakNet::RakNetGUID();
|
||||
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this);
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send();
|
||||
|
|
|
@ -48,10 +48,10 @@ void MechanicsHelper::processAttack(const MWWorld::Ptr& attacker, Attack attack)
|
|||
|
||||
MWWorld::Ptr victim;
|
||||
|
||||
if (attack.targetGuid == mwmp::Main::get().getLocalPlayer()->guid)
|
||||
if (attack.target.guid == mwmp::Main::get().getLocalPlayer()->guid)
|
||||
victim = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
else if (Players::getPlayer(attack.targetGuid) != 0)
|
||||
victim = Players::getPlayer(attack.targetGuid)->getPtr();
|
||||
else if (Players::getPlayer(attack.target.guid) != 0)
|
||||
victim = Players::getPlayer(attack.target.guid)->getPtr();
|
||||
|
||||
// Get the weapon used (if hand-to-hand, weapon = inv.end())
|
||||
if (attackerStats.getDrawState() == MWMechanics::DrawState_Weapon)
|
||||
|
|
|
@ -5,10 +5,20 @@
|
|||
|
||||
namespace mwmp
|
||||
{
|
||||
struct Target
|
||||
{
|
||||
std::string refId;
|
||||
int refNumIndex;
|
||||
int mpNum;
|
||||
|
||||
RakNet::RakNetGUID guid;
|
||||
};
|
||||
|
||||
class Attack
|
||||
{
|
||||
public:
|
||||
RakNet::RakNetGUID targetGuid;
|
||||
|
||||
Target target;
|
||||
|
||||
char type; // 0 - melee, 1 - magic, 2 - throwable
|
||||
enum TYPE
|
||||
|
|
|
@ -16,7 +16,7 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send)
|
|||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
RW(player->attack.targetGuid, send);
|
||||
RW(player->attack.target.guid, send);
|
||||
|
||||
RW(player->attack.spellId, send);
|
||||
RW(player->attack.type, send);
|
||||
|
|
Loading…
Reference in a new issue