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

pull/176/merge
David Cernat 8 years ago
parent f2e8e14665
commit 0ef9e014eb

@ -1,10 +1,13 @@
#include <components/openmw-mp/Log.hpp>
#include <components/misc/rng.hpp>
#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)

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

Loading…
Cancel
Save