1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-27 01:09:41 +00:00

[Client] Calculate spell success in more appropriate place

Previously, creatures with fast spellcasting animations would cast their spells before their success had actually been calculated, causing them to fail.
This commit is contained in:
David Cernat 2019-09-02 23:50:56 +03:00
parent 95967ea289
commit 190c404b38
3 changed files with 4 additions and 18 deletions

View file

@ -1057,7 +1057,7 @@ namespace MWMechanics
Start of tes3mp change (major)
Make spell casting fail based on the attack success rated determined
in LocalPlayer and LocalActor's updateAttack()
in LocalPlayer and LocalActor's updateAttackOrCast()
*/
mwmp::Cast *localCast = NULL;
mwmp::Cast *dedicatedCast = MechanicsHelper::getDedicatedCast(mCaster);
@ -1065,7 +1065,10 @@ namespace MWMechanics
if (dedicatedCast)
dedicatedCast->pressed = false;
else
{
localCast = MechanicsHelper::getLocalCast(mCaster);
localCast->success = MechanicsHelper::getSpellSuccess(mId, mCaster);
}
// Check success
if ((localCast && localCast->success == false) ||

View file

@ -265,15 +265,6 @@ void LocalActor::updateAttackOrCast()
}
else if (cast.shouldSend)
{
if (cast.type == Cast::REGULAR)
{
MWMechanics::CreatureStats &casterStats = ptr.getClass().getCreatureStats(ptr);
cast.spellId = casterStats.getSpells().getSelectedSpell();
if (cast.pressed)
cast.success = MechanicsHelper::getSpellSuccess(cast.spellId, ptr);
}
mwmp::Main::get().getNetworking()->getActorList()->addCastActor(*this);
cast.shouldSend = false;
}

View file

@ -609,14 +609,6 @@ void LocalPlayer::updateAttackOrCast()
}
else if (cast.shouldSend)
{
if (cast.type == Cast::REGULAR)
{
cast.spellId = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
if (cast.pressed)
cast.success = MechanicsHelper::getSpellSuccess(cast.spellId, getPlayerPtr());
}
getNetworking()->getPlayerPacket(ID_PLAYER_CAST)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_CAST)->Send();