forked from mirror/openmw-tes3mp
[General] Fix ranged attack sync when using last throwing weapon or ammo
This commit is contained in:
parent
3f304866fd
commit
f100a660d4
4 changed files with 23 additions and 10 deletions
|
@ -320,6 +320,20 @@ void DedicatedPlayer::setEquipment()
|
|||
if (!Misc::StringUtils::ciEqual(ptrItemId, packetItemId)) // if other item is now equipped
|
||||
{
|
||||
MWWorld::ContainerStore &store = ptr.getClass().getContainerStore(ptr);
|
||||
|
||||
// Remove the items that are no longer equipped, except for throwing weapons and ranged weapon ammo that
|
||||
// have just run out but still need to be kept briefly so they can be used in attacks about to be released
|
||||
bool shouldRemove = true;
|
||||
|
||||
if (attack.type == mwmp::Attack::RANGED && packetItemId.empty() && !attack.pressed)
|
||||
{
|
||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight && Misc::StringUtils::ciEqual(ptrItemId, attack.rangedWeaponId))
|
||||
shouldRemove = false;
|
||||
else if (slot == MWWorld::InventoryStore::Slot_Ammunition && Misc::StringUtils::ciEqual(ptrItemId, attack.rangedAmmoId))
|
||||
shouldRemove = false;
|
||||
}
|
||||
|
||||
if (shouldRemove)
|
||||
store.remove(ptrItemId, store.count(ptrItemId), ptr);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -325,7 +325,6 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
|
|||
{
|
||||
MWMechanics::CastSpell cast(attacker, victim, isRanged);
|
||||
cast.mHitPosition = attack.hitPosition.asVec3();
|
||||
|
||||
cast.cast(weaponPtr, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,11 @@ void PacketActorAttack::Actor(BaseActor &actor, bool send)
|
|||
RW(actor.attack.isHit, send);
|
||||
|
||||
if (actor.attack.type == mwmp::Attack::RANGED)
|
||||
{
|
||||
RW(actor.attack.attackStrength, send);
|
||||
RW(actor.attack.rangedWeaponId, send);
|
||||
RW(actor.attack.rangedAmmoId, send);
|
||||
}
|
||||
|
||||
if (actor.attack.isHit)
|
||||
{
|
||||
|
@ -53,11 +57,7 @@ void PacketActorAttack::Actor(BaseActor &actor, bool send)
|
|||
RW(actor.attack.applyWeaponEnchantment, send);
|
||||
|
||||
if (actor.attack.type == mwmp::Attack::RANGED)
|
||||
{
|
||||
RW(actor.attack.applyAmmoEnchantment, send);
|
||||
RW(actor.attack.rangedWeaponId, send);
|
||||
RW(actor.attack.rangedAmmoId, send);
|
||||
}
|
||||
|
||||
RW(actor.attack.hitPosition.pos[0], send);
|
||||
RW(actor.attack.hitPosition.pos[1], send);
|
||||
|
|
|
@ -44,7 +44,11 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send)
|
|||
RW(player->attack.isHit, send);
|
||||
|
||||
if (player->attack.type == mwmp::Attack::RANGED)
|
||||
{
|
||||
RW(player->attack.attackStrength, send);
|
||||
RW(player->attack.rangedWeaponId, send);
|
||||
RW(player->attack.rangedAmmoId, send);
|
||||
}
|
||||
|
||||
if (player->attack.isHit)
|
||||
{
|
||||
|
@ -54,11 +58,7 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send)
|
|||
RW(player->attack.applyWeaponEnchantment, send);
|
||||
|
||||
if (player->attack.type == mwmp::Attack::RANGED)
|
||||
{
|
||||
RW(player->attack.applyAmmoEnchantment, send);
|
||||
RW(player->attack.rangedWeaponId, send);
|
||||
RW(player->attack.rangedAmmoId, send);
|
||||
}
|
||||
|
||||
RW(player->attack.hitPosition.pos[0], send);
|
||||
RW(player->attack.hitPosition.pos[1], send);
|
||||
|
|
Loading…
Reference in a new issue