From 190c404b38df444693ec25cfe61925d81af6b162 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 2 Sep 2019 23:50:56 +0300 Subject: [PATCH] [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. --- apps/openmw/mwmechanics/spellcasting.cpp | 5 ++++- apps/openmw/mwmp/LocalActor.cpp | 9 --------- apps/openmw/mwmp/LocalPlayer.cpp | 8 -------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index c54601eec..a3a3b030a 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -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) || diff --git a/apps/openmw/mwmp/LocalActor.cpp b/apps/openmw/mwmp/LocalActor.cpp index adb532ea1..61133bd8f 100644 --- a/apps/openmw/mwmp/LocalActor.cpp +++ b/apps/openmw/mwmp/LocalActor.cpp @@ -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; } diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index ac15653c6..05fec23a8 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -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();