mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-10 06:44:29 +00:00
Merge pull request #1596
This commit is contained in:
commit
4a96934f56
@ -182,29 +182,11 @@ namespace MWMechanics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float bestArrowRating = 0;
|
|
||||||
MWWorld::Ptr bestArrow;
|
MWWorld::Ptr bestArrow;
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
float bestArrowRating = rateAmmo(actor, enemy, bestArrow, ESM::Weapon::Arrow);
|
||||||
{
|
|
||||||
float rating = rateWeapon(*it, actor, enemy, ESM::Weapon::Arrow);
|
|
||||||
if (rating > bestArrowRating)
|
|
||||||
{
|
|
||||||
bestArrowRating = rating;
|
|
||||||
bestArrow = *it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float bestBoltRating = 0;
|
|
||||||
MWWorld::Ptr bestBolt;
|
MWWorld::Ptr bestBolt;
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
float bestBoltRating = rateAmmo(actor, enemy, bestBolt, ESM::Weapon::Bolt);
|
||||||
{
|
|
||||||
float rating = rateWeapon(*it, actor, enemy, ESM::Weapon::Bolt);
|
|
||||||
if (rating > bestBoltRating)
|
|
||||||
{
|
|
||||||
bestBoltRating = rating;
|
|
||||||
bestBolt = *it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -277,25 +259,9 @@ namespace MWMechanics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float bestArrowRating = 0;
|
float bestArrowRating = rateAmmo(actor, enemy, ESM::Weapon::Arrow);
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
|
||||||
{
|
|
||||||
float rating = rateWeapon(*it, actor, enemy, ESM::Weapon::Arrow);
|
|
||||||
if (rating > bestArrowRating)
|
|
||||||
{
|
|
||||||
bestArrowRating = rating;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float bestBoltRating = 0;
|
float bestBoltRating = rateAmmo(actor, enemy, ESM::Weapon::Bolt);
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
|
||||||
{
|
|
||||||
float rating = rateWeapon(*it, actor, enemy, ESM::Weapon::Bolt);
|
|
||||||
if (rating > bestBoltRating)
|
|
||||||
{
|
|
||||||
bestBoltRating = rating;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "spellpriority.hpp"
|
#include "spellpriority.hpp"
|
||||||
|
#include "weaponpriority.hpp"
|
||||||
|
|
||||||
#include <components/esm/loadench.hpp>
|
#include <components/esm/loadench.hpp>
|
||||||
#include <components/esm/loadmgef.hpp>
|
#include <components/esm/loadmgef.hpp>
|
||||||
@ -335,6 +336,12 @@ namespace MWMechanics
|
|||||||
return 0.f;
|
return 0.f;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ESM::MagicEffect::BoundLongbow:
|
||||||
|
// AI should not summon the bow if there is no suitable ammo.
|
||||||
|
if (rateAmmo(actor, enemy, ESM::Weapon::Arrow) <= 0.f)
|
||||||
|
return 0.f;
|
||||||
|
break;
|
||||||
|
|
||||||
case ESM::MagicEffect::RestoreHealth:
|
case ESM::MagicEffect::RestoreHealth:
|
||||||
case ESM::MagicEffect::RestoreMagicka:
|
case ESM::MagicEffect::RestoreMagicka:
|
||||||
case ESM::MagicEffect::RestoreFatigue:
|
case ESM::MagicEffect::RestoreFatigue:
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
|
||||||
#include "npcstats.hpp"
|
#include "npcstats.hpp"
|
||||||
#include "combat.hpp"
|
#include "combat.hpp"
|
||||||
@ -111,6 +112,33 @@ namespace MWMechanics
|
|||||||
return rating + bonus;
|
return rating + bonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float rateAmmo(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy, MWWorld::Ptr &bestAmmo, ESM::Weapon::Type ammoType)
|
||||||
|
{
|
||||||
|
float bestAmmoRating = 0.f;
|
||||||
|
if (!actor.getClass().hasInventoryStore(actor))
|
||||||
|
return bestAmmoRating;
|
||||||
|
|
||||||
|
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
||||||
|
|
||||||
|
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||||
|
{
|
||||||
|
float rating = rateWeapon(*it, actor, enemy, ammoType);
|
||||||
|
if (rating > bestAmmoRating)
|
||||||
|
{
|
||||||
|
bestAmmoRating = rating;
|
||||||
|
bestAmmo = *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestAmmoRating;
|
||||||
|
}
|
||||||
|
|
||||||
|
float rateAmmo(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy, ESM::Weapon::Type ammoType)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr emptyPtr;
|
||||||
|
return rateAmmo(actor, enemy, emptyPtr, ammoType);
|
||||||
|
}
|
||||||
|
|
||||||
float vanillaRateWeaponAndAmmo(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy)
|
float vanillaRateWeaponAndAmmo(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy)
|
||||||
{
|
{
|
||||||
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef OPENMW_WEAPON_PRIORITY_H
|
#ifndef OPENMW_WEAPON_PRIORITY_H
|
||||||
#define OPENMW_WEAPON_PRIORITY_H
|
#define OPENMW_WEAPON_PRIORITY_H
|
||||||
|
|
||||||
|
#include <components/esm/loadweap.hpp>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
@ -8,6 +10,9 @@ namespace MWMechanics
|
|||||||
float rateWeapon (const MWWorld::Ptr& item, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy,
|
float rateWeapon (const MWWorld::Ptr& item, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy,
|
||||||
int type=-1, float arrowRating=0.f, float boltRating=0.f);
|
int type=-1, float arrowRating=0.f, float boltRating=0.f);
|
||||||
|
|
||||||
|
float rateAmmo(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy, MWWorld::Ptr &bestAmmo, ESM::Weapon::Type ammoType);
|
||||||
|
float rateAmmo(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy, ESM::Weapon::Type ammoType);
|
||||||
|
|
||||||
float vanillaRateWeaponAndAmmo(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
|
float vanillaRateWeaponAndAmmo(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user