From 0ef9e014eb19de6d4ea189ed081b43a15a3f0f67 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 19 Apr 2017 17:09:35 +0300 Subject: [PATCH] [Client] Add resetAttack() and getSpellSuccess() to MechanicsHelper --- apps/openmw/mwmp/MechanicsHelper.cpp | 17 +++++++++++++++++ apps/openmw/mwmp/MechanicsHelper.hpp | 3 +++ 2 files changed, 20 insertions(+) diff --git a/apps/openmw/mwmp/MechanicsHelper.cpp b/apps/openmw/mwmp/MechanicsHelper.cpp index ca1be954c..4667035b6 100644 --- a/apps/openmw/mwmp/MechanicsHelper.cpp +++ b/apps/openmw/mwmp/MechanicsHelper.cpp @@ -1,10 +1,13 @@ #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwmechanics/combat.hpp" #include "../mwmechanics/npcstats.hpp" +#include "../mwmechanics/spellcasting.hpp" #include "../mwworld/class.hpp" #include "../mwworld/inventorystore.hpp" @@ -71,6 +74,20 @@ void MechanicsHelper::assignAttackTarget(Attack* attack, const MWWorld::Ptr& tar } } +void MechanicsHelper::resetAttack(Attack* attack) +{ + attack->success = false; + attack->knockdown = false; + attack->block = false; + attack->target.guid = RakNet::RakNetGUID(); + attack->target.refId.clear(); +} + +bool MechanicsHelper::getSpellSuccess(std::string spellId, const MWWorld::Ptr& caster) +{ + return Misc::Rng::roll0to99() < MWMechanics::getSpellSuccessChance(spellId, caster); +} + void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker) { if (attack.pressed == false) diff --git a/apps/openmw/mwmp/MechanicsHelper.hpp b/apps/openmw/mwmp/MechanicsHelper.hpp index 63aa94ecc..9b534e51e 100644 --- a/apps/openmw/mwmp/MechanicsHelper.hpp +++ b/apps/openmw/mwmp/MechanicsHelper.hpp @@ -20,6 +20,9 @@ namespace mwmp Attack *getDedicatedAttack(const MWWorld::Ptr& ptr); void assignAttackTarget(Attack* attack, const MWWorld::Ptr& target); + void resetAttack(Attack* attack); + + bool getSpellSuccess(std::string spellId, const MWWorld::Ptr& caster); void processAttack(Attack attack, const MWWorld::Ptr& attacker); };