[Client] Move item magic hook to correct location

Previously, synchronization for strike enchantments was partially broken because it triggered the sending of ITEM_MAGIC attack packets, which are only supposed to be sent when a spell is cast from a magical inventory item.
pull/473/head
David Cernat 6 years ago
parent c9ad411dd3
commit 7d221509cd

@ -938,25 +938,6 @@ namespace MWMechanics
else if (isProjectile || !mTarget.isEmpty()) else if (isProjectile || !mTarget.isEmpty())
inflict(mTarget, mCaster, enchantment->mEffects, ESM::RT_Target); inflict(mTarget, mCaster, enchantment->mEffects, ESM::RT_Target);
/*
Start of tes3mp addition
If this mCaster belongs to a LocalPlayer or LocalActor, get their Attack and prepare
it for sending
*/
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(mCaster);
if (localAttack)
{
MechanicsHelper::resetAttack(localAttack);
localAttack->type = mwmp::Attack::ITEM_MAGIC;
localAttack->itemId = item.getCellRef().getRefId();
localAttack->shouldSend = true;
}
/*
End of tes3mp addition
*/
return true; return true;
} }

@ -19,6 +19,7 @@
#include "../mwmp/DedicatedActor.hpp" #include "../mwmp/DedicatedActor.hpp"
#include "../mwmp/ObjectList.hpp" #include "../mwmp/ObjectList.hpp"
#include "../mwmp/CellController.hpp" #include "../mwmp/CellController.hpp"
#include "../mwmp/MechanicsHelper.hpp"
/* /*
End of tes3mp addition End of tes3mp addition
*/ */
@ -3260,7 +3261,28 @@ namespace MWWorld
{ {
MWWorld::InventoryStore& inv = actor.getClass().getInventoryStore(actor); MWWorld::InventoryStore& inv = actor.getClass().getInventoryStore(actor);
if (inv.getSelectedEnchantItem() != inv.end()) if (inv.getSelectedEnchantItem() != inv.end())
/*
Start of tes3mp change (minor)
If this actor is a LocalPlayer or LocalActor, get their Attack and prepare
it for sending
*/
{
cast.cast(*inv.getSelectedEnchantItem()); cast.cast(*inv.getSelectedEnchantItem());
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(actor);
if (localAttack)
{
MechanicsHelper::resetAttack(localAttack);
localAttack->type = mwmp::Attack::ITEM_MAGIC;
localAttack->itemId = inv.getSelectedEnchantItem()->getCellRef().getRefId();
localAttack->shouldSend = true;
}
}
/*
End of tes3mp addition
*/
} }
} }

Loading…
Cancel
Save