From 77ce05b7d6fa73b49aa8b2a4bc8c83c0461d87f9 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 6 Aug 2017 00:11:54 +0300 Subject: [PATCH] [Client] Fix spell casting probability synchronization --- apps/openmw/mwmechanics/spellcasting.cpp | 20 ++------------------ apps/openmw/mwmp/LocalActor.cpp | 4 +++- apps/openmw/mwmp/LocalPlayer.cpp | 4 +++- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index bf93ccd8b..d93290302 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -917,14 +917,8 @@ namespace MWMechanics /* Start of tes3mp change (major) - Instead of checking whether the caster is a player or an NPC, - first check whether it's the LocalPlayer or a DedicatedPlayer and calculate - calculate the success chance in clients' LocalPlayer::prepareAttack() - - TODO: Make this make sense for NPCs too - - TODO: See if LocalPlayer being the target and having godmode on - can be accounted for like it is in OpenMW's corresponding code + Make spell casting fail based on the attack success rated determined + in LocalPlayer and LocalActor's updateAttack() */ mwmp::Attack *localAttack = NULL; mwmp::Attack *dedicatedAttack = MechanicsHelper::getDedicatedAttack(mCaster); @@ -944,19 +938,9 @@ namespace MWMechanics } fail = true; } - else if (!(mCaster == getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState())) /* End of tes3mp change (major) */ - { - float successChance = getSpellSuccessChance(spell, mCaster); - if (Misc::Rng::roll0to99() >= successChance) - { - if (mCaster == getPlayer()) - MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}"); - fail = true; - } - } if (fail) { diff --git a/apps/openmw/mwmp/LocalActor.cpp b/apps/openmw/mwmp/LocalActor.cpp index e2bc97150..7c4143517 100644 --- a/apps/openmw/mwmp/LocalActor.cpp +++ b/apps/openmw/mwmp/LocalActor.cpp @@ -241,7 +241,9 @@ void LocalActor::updateAttack() { MWMechanics::CreatureStats &attackerStats = ptr.getClass().getCreatureStats(ptr); attack.spellId = attackerStats.getSpells().getSelectedSpell(); - attack.success = MechanicsHelper::getSpellSuccess(attack.spellId, ptr); + + if (attack.pressed) + attack.success = MechanicsHelper::getSpellSuccess(attack.spellId, ptr); } mwmp::Main::get().getNetworking()->getActorList()->addAttackActor(*this); diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index f3c1ec6c6..06fcc18b1 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -525,7 +525,9 @@ void LocalPlayer::updateAttack() if (attack.type == Attack::MAGIC) { attack.spellId = MWBase::Environment::get().getWindowManager()->getSelectedSpell(); - attack.success = MechanicsHelper::getSpellSuccess(attack.spellId, getPlayerPtr()); + + if (attack.pressed) + attack.success = MechanicsHelper::getSpellSuccess(attack.spellId, getPlayerPtr()); } getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this);