diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 75813d4c96..6daa8ea011 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -153,7 +153,6 @@ namespace MWMechanics updateFleeing(actor, target, duration, characterController.getSupportedMovementDirections(), storage); } storage.mActionCooldown -= duration; - storage.mHealCooldown -= duration; if (storage.mReaction.update(duration) == Misc::TimerStatus::Waiting) return false; @@ -177,7 +176,6 @@ namespace MWMechanics storage.stopAttack(); actor.getClass().getCreatureStats(actor).setAttackingOrSpell(false); storage.mActionCooldown = 0.f; - storage.mHealCooldown = 0.f; // Continue combat if target is player or player follower/escorter and an attack has been attempted const auto& playerFollowersAndEscorters = MWBase::Environment::get().getMechanicsManager()->getActorsSidingWith(MWMechanics::getPlayer()); @@ -198,7 +196,6 @@ namespace MWMechanics actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true); float& actionCooldown = storage.mActionCooldown; - float& healCooldown = storage.mHealCooldown; std::unique_ptr& currentAction = storage.mCurrentAction; if (!forceFlee) @@ -208,16 +205,14 @@ namespace MWMechanics if (characterController.readyToPrepareAttack()) { - currentAction = prepareNextAction(actor, target, healCooldown <= 0.f); + currentAction = prepareNextAction(actor, target); actionCooldown = currentAction->getActionCooldown(); - healCooldown = currentAction->getHealCooldown(); } } else { currentAction = std::make_unique(); actionCooldown = currentAction->getActionCooldown(); - healCooldown = currentAction->getHealCooldown(); } if (!currentAction) @@ -322,7 +317,6 @@ namespace MWMechanics actor.getClass().getCreatureStats(actor).setAttackingOrSpell(false); currentAction = std::make_unique(); actionCooldown = currentAction->getActionCooldown(); - healCooldown = currentAction->getHealCooldown(); storage.startFleeing(); MWBase::Environment::get().getDialogueManager()->say(actor, ESM::RefId::stringRefId("flee")); } @@ -514,7 +508,6 @@ namespace MWMechanics , mCell(nullptr) , mCurrentAction() , mActionCooldown(0.0f) - , mHealCooldown(0.f) , mStrength() , mForceNoShortcut(false) , mShortcutFailPos() diff --git a/apps/openmw/mwmechanics/aicombat.hpp b/apps/openmw/mwmechanics/aicombat.hpp index c9308cdf0d..92d380dbd8 100644 --- a/apps/openmw/mwmechanics/aicombat.hpp +++ b/apps/openmw/mwmechanics/aicombat.hpp @@ -36,7 +36,6 @@ namespace MWMechanics const MWWorld::CellStore* mCell; std::unique_ptr mCurrentAction; float mActionCooldown; - float mHealCooldown; float mStrength; bool mForceNoShortcut; ESM::Position mShortcutFailPos; diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index c38f51076d..a7bcd1a0df 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -162,7 +162,7 @@ namespace MWMechanics return mWeapon.get()->mBase; } - std::unique_ptr prepareNextAction(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool allowHealing) + std::unique_ptr prepareNextAction(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) { Spells& spells = actor.getClass().getCreatureStats(actor).getSpells(); @@ -182,24 +182,23 @@ namespace MWMechanics for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) { - bool isPureHealing = false; if (it->getType() == ESM::Potion::sRecordId) { - float rating = ratePotion(*it, actor, isPureHealing); - if (rating > bestActionRating && (!isPureHealing || allowHealing)) + float rating = ratePotion(*it, actor); + if (rating > bestActionRating) { bestActionRating = rating; - bestAction = std::make_unique(*it, isPureHealing); + bestAction = std::make_unique(*it); antiFleeRating = std::numeric_limits::max(); } } else if (!it->getClass().getEnchantment(*it).empty()) { - float rating = rateMagicItem(*it, actor, enemy, isPureHealing); - if (rating > bestActionRating && (!isPureHealing || allowHealing)) + float rating = rateMagicItem(*it, actor, enemy); + if (rating > bestActionRating) { bestActionRating = rating; - bestAction = std::make_unique(it, isPureHealing); + bestAction = std::make_unique(it); antiFleeRating = std::numeric_limits::max(); } } @@ -237,11 +236,8 @@ namespace MWMechanics float rating = rateSpell(spell, actor, enemy); if (rating > bestActionRating) { - bool isPureHealingSpell = isPureHealing(spell->mEffects); - if (isPureHealingSpell && !allowHealing) - continue; bestActionRating = rating; - bestAction = std::make_unique(spell->mId, isPureHealingSpell); + bestAction = std::make_unique(spell->mId); antiFleeRating = vanillaRateSpell(spell, actor, enemy); } } @@ -270,10 +266,9 @@ namespace MWMechanics { MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor); - bool pureHealing; for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) { - float rating = rateMagicItem(*it, actor, enemy, pureHealing); + float rating = rateMagicItem(*it, actor, enemy); if (rating > bestActionRating) { bestActionRating = rating; diff --git a/apps/openmw/mwmechanics/aicombataction.hpp b/apps/openmw/mwmechanics/aicombataction.hpp index 171ed7fdff..05d2a18e25 100644 --- a/apps/openmw/mwmechanics/aicombataction.hpp +++ b/apps/openmw/mwmechanics/aicombataction.hpp @@ -10,18 +10,11 @@ namespace MWMechanics { class Action { - float mHealCooldown; - public: - Action(bool healing) - : mHealCooldown(healing ? 5.f : 0.f) - { - } virtual ~Action() {} virtual void prepare(const MWWorld::Ptr& actor) = 0; virtual float getCombatRange(bool& isRanged) const = 0; virtual float getActionCooldown() const { return 0.f; } - virtual float getHealCooldown() const { return mHealCooldown; } virtual const ESM::Weapon* getWeapon() const { return nullptr; } virtual bool isAttackingOrSpell() const { return true; } virtual bool isFleeing() const { return false; } @@ -30,10 +23,7 @@ namespace MWMechanics class ActionFlee : public Action { public: - ActionFlee() - : Action(false) - { - } + ActionFlee() {} void prepare(const MWWorld::Ptr& actor) override {} float getCombatRange(bool& isRanged) const override { return 0.0f; } float getActionCooldown() const override { return 3.0f; } @@ -44,9 +34,8 @@ namespace MWMechanics class ActionSpell : public Action { public: - ActionSpell(const ESM::RefId& spellId, bool healing = false) - : Action(healing) - , mSpellId(spellId) + ActionSpell(const ESM::RefId& spellId) + : mSpellId(spellId) { } ESM::RefId mSpellId; @@ -59,9 +48,8 @@ namespace MWMechanics class ActionEnchantedItem : public Action { public: - ActionEnchantedItem(const MWWorld::ContainerStoreIterator& item, bool healing) - : Action(healing) - , mItem(item) + ActionEnchantedItem(const MWWorld::ContainerStoreIterator& item) + : mItem(item) { } MWWorld::ContainerStoreIterator mItem; @@ -76,9 +64,8 @@ namespace MWMechanics class ActionPotion : public Action { public: - ActionPotion(const MWWorld::Ptr& potion, bool healing) - : Action(healing) - , mPotion(potion) + ActionPotion(const MWWorld::Ptr& potion) + : mPotion(potion) { } MWWorld::Ptr mPotion; @@ -100,8 +87,7 @@ namespace MWMechanics public: /// \a weapon may be empty for hand-to-hand combat ActionWeapon(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo = MWWorld::Ptr()) - : Action(false) - , mAmmunition(ammo) + : mAmmunition(ammo) , mWeapon(weapon) { } @@ -111,7 +97,7 @@ namespace MWMechanics const ESM::Weapon* getWeapon() const override; }; - std::unique_ptr prepareNextAction(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool allowHealing); + std::unique_ptr prepareNextAction(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); float getBestActionRating(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); float getDistanceMinusHalfExtents(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool minusZDist = false); diff --git a/apps/openmw/mwmechanics/spellpriority.cpp b/apps/openmw/mwmechanics/spellpriority.cpp index c444269db6..94f24800a2 100644 --- a/apps/openmw/mwmechanics/spellpriority.cpp +++ b/apps/openmw/mwmechanics/spellpriority.cpp @@ -122,13 +122,12 @@ namespace MWMechanics return types; } - float ratePotion(const MWWorld::Ptr& item, const MWWorld::Ptr& actor, bool& pureHealing) + float ratePotion(const MWWorld::Ptr& item, const MWWorld::Ptr& actor) { if (item.getType() != ESM::Potion::sRecordId) return 0.f; const ESM::Potion* potion = item.get()->mBase; - pureHealing = isPureHealing(potion->mEffects); return rateEffects(potion->mEffects, actor, MWWorld::Ptr()); } @@ -160,15 +159,13 @@ namespace MWMechanics return rateEffects(spell->mEffects, actor, enemy) * (successChance / 100.f); } - float rateMagicItem( - const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool& pureHealing) + float rateMagicItem(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) { if (ptr.getClass().getEnchantment(ptr).empty()) return 0.f; const ESM::Enchantment* enchantment = MWBase::Environment::get().getESMStore()->get().find( ptr.getClass().getEnchantment(ptr)); - pureHealing = isPureHealing(enchantment->mEffects); // Spells don't stack, so early out if the spell is still active on the target int types = getRangeTypes(enchantment->mEffects); diff --git a/apps/openmw/mwmechanics/spellpriority.hpp b/apps/openmw/mwmechanics/spellpriority.hpp index faad90bb37..e853e4fd28 100644 --- a/apps/openmw/mwmechanics/spellpriority.hpp +++ b/apps/openmw/mwmechanics/spellpriority.hpp @@ -27,9 +27,8 @@ namespace MWMechanics float rateSpell( const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool checkMagicka = true); - float rateMagicItem( - const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool& pureHealing); - float ratePotion(const MWWorld::Ptr& item, const MWWorld::Ptr& actor, bool& pureHealing); + float rateMagicItem(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); + float ratePotion(const MWWorld::Ptr& item, const MWWorld::Ptr& actor); /// @note target may be empty float rateEffect(const ESM::ENAMstruct& effect, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); diff --git a/apps/openmw/mwmechanics/spellutil.cpp b/apps/openmw/mwmechanics/spellutil.cpp index d2fb51c4df..2a63a3a444 100644 --- a/apps/openmw/mwmechanics/spellutil.cpp +++ b/apps/openmw/mwmechanics/spellutil.cpp @@ -257,13 +257,4 @@ namespace MWMechanics const auto spell = MWBase::Environment::get().getESMStore()->get().search(spellId); return spell && spellIncreasesSkill(spell); } - - bool isPureHealing(const ESM::EffectList& list) - { - auto nonHealing = std::find_if(list.mList.begin(), list.mList.end(), [](const auto& effect) { - return effect.mEffectID < ESM::MagicEffect::RestoreAttribute - || effect.mEffectID > ESM::MagicEffect::RestoreSkill; - }); - return nonHealing == list.mList.end(); - } } diff --git a/apps/openmw/mwmechanics/spellutil.hpp b/apps/openmw/mwmechanics/spellutil.hpp index d38a6fe793..a332a231e6 100644 --- a/apps/openmw/mwmechanics/spellutil.hpp +++ b/apps/openmw/mwmechanics/spellutil.hpp @@ -5,7 +5,6 @@ namespace ESM { - struct EffectList; struct ENAMstruct; struct Enchantment; struct MagicEffect; @@ -55,8 +54,6 @@ namespace MWMechanics /// Get whether or not the given spell contributes to skill progress. bool spellIncreasesSkill(const ESM::Spell* spell); bool spellIncreasesSkill(const ESM::RefId& spellId); - - bool isPureHealing(const ESM::EffectList& list); } #endif