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); };