mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Combat AI: avoid enemy hits when casting Self-ranged spells (fixes #3922)
This commit is contained in:
parent
12871dd8da
commit
98f161c7fd
1 changed files with 11 additions and 12 deletions
|
@ -45,20 +45,18 @@ int getRangeTypes (const ESM::EffectList& effects)
|
||||||
|
|
||||||
float suggestCombatRange(int rangeTypes)
|
float suggestCombatRange(int rangeTypes)
|
||||||
{
|
{
|
||||||
|
static const float fCombatDistance = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fCombatDistance")->getFloat();
|
||||||
|
static float fHandToHandReach = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fHandToHandReach")->getFloat();
|
||||||
|
|
||||||
|
// This distance is a possible distance of melee attack
|
||||||
|
static float distance = fCombatDistance * std::max(2.f, fHandToHandReach);
|
||||||
|
|
||||||
if (rangeTypes & Touch)
|
if (rangeTypes & Touch)
|
||||||
{
|
{
|
||||||
static const float fCombatDistance = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fCombatDistance")->getFloat();
|
|
||||||
return fCombatDistance;
|
return fCombatDistance;
|
||||||
}
|
}
|
||||||
else if (rangeTypes & Target)
|
|
||||||
{
|
return distance * 4;
|
||||||
return 1000.f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// For Self spells, distance doesn't matter, so back away slightly to avoid enemy hits
|
|
||||||
return 600.f;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int numEffectsToDispel (const MWWorld::Ptr& actor, int effectFilter=-1, bool negative = true)
|
int numEffectsToDispel (const MWWorld::Ptr& actor, int effectFilter=-1, bool negative = true)
|
||||||
|
@ -640,7 +638,7 @@ namespace MWMechanics
|
||||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(mSpellId);
|
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(mSpellId);
|
||||||
int types = getRangeTypes(spell->mEffects);
|
int types = getRangeTypes(spell->mEffects);
|
||||||
|
|
||||||
isRanged = (types & Target);
|
isRanged = (types & Target) | (types & Self);
|
||||||
return suggestCombatRange(types);
|
return suggestCombatRange(types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,7 +658,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
float ActionPotion::getCombatRange(bool& isRanged) const
|
float ActionPotion::getCombatRange(bool& isRanged) const
|
||||||
{
|
{
|
||||||
// distance doesn't matter, so back away slightly to avoid enemy hits
|
// Distance doesn't matter since this action has no animation
|
||||||
|
// If we want to back away slightly to avoid enemy hits, we should set isRanged to "true"
|
||||||
return 600.f;
|
return 600.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue