[Client] Add resetAttack() and getSpellSuccess() to MechanicsHelper

This commit is contained in:
David Cernat 2017-04-19 17:09:35 +03:00
parent f2e8e14665
commit 0ef9e014eb
2 changed files with 20 additions and 0 deletions

View file

@ -1,10 +1,13 @@
#include <components/openmw-mp/Log.hpp> #include <components/openmw-mp/Log.hpp>
#include <components/misc/rng.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwmechanics/combat.hpp" #include "../mwmechanics/combat.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/spellcasting.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.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) void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
{ {
if (attack.pressed == false) if (attack.pressed == false)

View file

@ -20,6 +20,9 @@ namespace mwmp
Attack *getDedicatedAttack(const MWWorld::Ptr& ptr); Attack *getDedicatedAttack(const MWWorld::Ptr& ptr);
void assignAttackTarget(Attack* attack, const MWWorld::Ptr& target); 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); void processAttack(Attack attack, const MWWorld::Ptr& attacker);
}; };