mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-03 17:54:06 +00:00
Move AiSetting out of MWMechanics::CreatureStats
To replace creaturestats.hpp include in mwworld/class.hpp with forward declaration reducing total size of preprocessed code.
This commit is contained in:
parent
2ef2e93a46
commit
49f8445f87
@ -3,7 +3,10 @@
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "../mwmechanics/magiceffects.hpp"
|
||||
|
||||
#include <components/esm3/loadmgef.hpp>
|
||||
#include <components/esm3/loadskil.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "../mwmechanics/creaturecustomdataresetter.hpp"
|
||||
#include "../mwmechanics/aisetting.hpp"
|
||||
#include "../mwmechanics/inventory.hpp"
|
||||
#include "../mwmechanics/setbaseaisetting.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/mechanicsmanager.hpp"
|
||||
@ -143,10 +144,10 @@ namespace MWClass
|
||||
|
||||
data->mCreatureStats.getAiSequence().fill(ref->mBase->mAiPackage);
|
||||
|
||||
data->mCreatureStats.setAiSetting (MWMechanics::CreatureStats::AI_Hello, ref->mBase->mAiData.mHello);
|
||||
data->mCreatureStats.setAiSetting (MWMechanics::CreatureStats::AI_Fight, ref->mBase->mAiData.mFight);
|
||||
data->mCreatureStats.setAiSetting (MWMechanics::CreatureStats::AI_Flee, ref->mBase->mAiData.mFlee);
|
||||
data->mCreatureStats.setAiSetting (MWMechanics::CreatureStats::AI_Alarm, ref->mBase->mAiData.mAlarm);
|
||||
data->mCreatureStats.setAiSetting(MWMechanics::AiSetting::Hello, ref->mBase->mAiData.mHello);
|
||||
data->mCreatureStats.setAiSetting(MWMechanics::AiSetting::Fight, ref->mBase->mAiData.mFight);
|
||||
data->mCreatureStats.setAiSetting(MWMechanics::AiSetting::Flee, ref->mBase->mAiData.mFlee);
|
||||
data->mCreatureStats.setAiSetting(MWMechanics::AiSetting::Alarm, ref->mBase->mAiData.mAlarm);
|
||||
|
||||
// Persistent actors with 0 health do not play death animation
|
||||
if (data->mCreatureStats.isDead())
|
||||
@ -863,7 +864,7 @@ namespace MWClass
|
||||
scale *= ref->mBase->mScale;
|
||||
}
|
||||
|
||||
void Creature::setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value) const
|
||||
void Creature::setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const
|
||||
{
|
||||
MWMechanics::setBaseAISetting<ESM::Creature>(id, setting, value);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ namespace MWClass
|
||||
void adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const override;
|
||||
/// @param rendering Indicates if the scale to adjust is for the rendering mesh, or for the collision mesh
|
||||
|
||||
void setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value) const override;
|
||||
void setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const override;
|
||||
|
||||
void modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) const override;
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "../mwmechanics/creaturecustomdataresetter.hpp"
|
||||
#include "../mwmechanics/inventory.hpp"
|
||||
#include "../mwmechanics/aisetting.hpp"
|
||||
#include "../mwmechanics/setbaseaisetting.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontalk.hpp"
|
||||
@ -390,10 +391,10 @@ namespace MWClass
|
||||
|
||||
data->mNpcStats.getAiSequence().fill(ref->mBase->mAiPackage);
|
||||
|
||||
data->mNpcStats.setAiSetting (MWMechanics::CreatureStats::AI_Hello, ref->mBase->mAiData.mHello);
|
||||
data->mNpcStats.setAiSetting (MWMechanics::CreatureStats::AI_Fight, ref->mBase->mAiData.mFight);
|
||||
data->mNpcStats.setAiSetting (MWMechanics::CreatureStats::AI_Flee, ref->mBase->mAiData.mFlee);
|
||||
data->mNpcStats.setAiSetting (MWMechanics::CreatureStats::AI_Alarm, ref->mBase->mAiData.mAlarm);
|
||||
data->mNpcStats.setAiSetting(MWMechanics::AiSetting::Hello, ref->mBase->mAiData.mHello);
|
||||
data->mNpcStats.setAiSetting(MWMechanics::AiSetting::Fight, ref->mBase->mAiData.mFight);
|
||||
data->mNpcStats.setAiSetting(MWMechanics::AiSetting::Flee, ref->mBase->mAiData.mFlee);
|
||||
data->mNpcStats.setAiSetting(MWMechanics::AiSetting::Alarm, ref->mBase->mAiData.mAlarm);
|
||||
|
||||
// spells
|
||||
if (!spellsInitialised)
|
||||
@ -1452,7 +1453,7 @@ namespace MWClass
|
||||
return ref->mBase->getFactionRank();
|
||||
}
|
||||
|
||||
void Npc::setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value) const
|
||||
void Npc::setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const
|
||||
{
|
||||
MWMechanics::setBaseAISetting<ESM::NPC>(id, setting, value);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ namespace MWClass
|
||||
std::string getPrimaryFaction(const MWWorld::ConstPtr &ptr) const override;
|
||||
int getPrimaryFactionRank(const MWWorld::ConstPtr &ptr) const override;
|
||||
|
||||
void setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value) const override;
|
||||
void setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const override;
|
||||
|
||||
void modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) const override;
|
||||
|
||||
|
@ -309,7 +309,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||
case SelectWrapper::Function_AiSetting:
|
||||
|
||||
return mActor.getClass().getCreatureStats (mActor).getAiSetting (
|
||||
(MWMechanics::CreatureStats::AiSetting)select.getArgument()).getModified(false);
|
||||
(MWMechanics::AiSetting)select.getArgument()).getModified(false);
|
||||
|
||||
case SelectWrapper::Function_PcAttribute:
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
#include "../mwmechanics/actorutil.hpp"
|
||||
#include "../mwmechanics/spells.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "../mwmechanics/spellutil.hpp"
|
||||
#include "../mwmechanics/actorutil.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "tooltips.hpp"
|
||||
#include "class.hpp"
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
#include "../mwmechanics/actorutil.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "../mwmechanics/aitravel.hpp"
|
||||
#include "../mwmechanics/aiwander.hpp"
|
||||
#include "../mwmechanics/aipackage.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "luamanagerimp.hpp"
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "eventqueue.hpp"
|
||||
#include "luamanagerimp.hpp"
|
||||
#include "types/types.hpp"
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <components/lua/luastate.hpp>
|
||||
|
||||
#include <apps/openmw/mwmechanics/drawstate.hpp>
|
||||
#include <apps/openmw/mwmechanics/creaturestats.hpp>
|
||||
#include <apps/openmw/mwworld/inventorystore.hpp>
|
||||
#include <apps/openmw/mwworld/class.hpp>
|
||||
|
||||
|
@ -372,7 +372,7 @@ namespace MWMechanics
|
||||
return;
|
||||
|
||||
const CreatureStats &stats = actor.getClass().getCreatureStats(actor);
|
||||
if (stats.getAiSetting(CreatureStats::AI_Hello).getModified() == 0)
|
||||
if (stats.getAiSetting(AiSetting::Hello).getModified() == 0)
|
||||
return;
|
||||
|
||||
const MWMechanics::AiSequence& seq = stats.getAiSequence();
|
||||
@ -463,7 +463,7 @@ namespace MWMechanics
|
||||
static const int iGreetDistanceMultiplier = MWBase::Environment::get().getWorld()->getStore()
|
||||
.get<ESM::GameSetting>().find("iGreetDistanceMultiplier")->mValue.getInteger();
|
||||
|
||||
const float helloDistance = static_cast<float>(actorStats.getAiSetting(CreatureStats::AI_Hello).getModified() * iGreetDistanceMultiplier);
|
||||
const float helloDistance = static_cast<float>(actorStats.getAiSetting(AiSetting::Hello).getModified() * iGreetDistanceMultiplier);
|
||||
const auto& playerStats = player.getClass().getCreatureStats(player);
|
||||
|
||||
int greetingTimer = actorState.getGreetingTimer();
|
||||
@ -1089,7 +1089,7 @@ namespace MWMechanics
|
||||
// Reset factors to attack
|
||||
creatureStats.setAttacked(false);
|
||||
creatureStats.setAlarmed(false);
|
||||
creatureStats.setAiSetting(CreatureStats::AI_Fight, ptr.getClass().getBaseFightRating(ptr));
|
||||
creatureStats.setAiSetting(AiSetting::Fight, ptr.getClass().getBaseFightRating(ptr));
|
||||
|
||||
// Update witness crime id
|
||||
npcStats.setCrimeId(-1);
|
||||
|
@ -6,6 +6,9 @@
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "../mwmechanics/magiceffects.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include <components/esm3/loadmgef.hpp>
|
||||
|
||||
namespace MWMechanics
|
||||
|
@ -468,7 +468,7 @@ namespace MWMechanics
|
||||
const CreatureStats& stats = actor.getClass().getCreatureStats(actor);
|
||||
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
|
||||
int flee = stats.getAiSetting(CreatureStats::AI_Flee).getModified();
|
||||
const int flee = stats.getAiSetting(AiSetting::Flee).getModified();
|
||||
if (flee >= 100)
|
||||
return flee;
|
||||
|
||||
|
@ -1,40 +1,15 @@
|
||||
#ifndef OPENMW_MWMECHANICS_AISETTING_H
|
||||
#define OPENMW_MWMECHANICS_AISETTING_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
#include "creaturestats.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
template<class T>
|
||||
void setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value)
|
||||
enum class AiSetting
|
||||
{
|
||||
T copy = *MWBase::Environment::get().getWorld()->getStore().get<T>().find(id);
|
||||
switch (setting)
|
||||
{
|
||||
case MWMechanics::CreatureStats::AiSetting::AI_Hello:
|
||||
copy.mAiData.mHello = value;
|
||||
break;
|
||||
case MWMechanics::CreatureStats::AiSetting::AI_Fight:
|
||||
copy.mAiData.mFight = value;
|
||||
break;
|
||||
case MWMechanics::CreatureStats::AiSetting::AI_Flee:
|
||||
copy.mAiData.mFlee = value;
|
||||
break;
|
||||
case MWMechanics::CreatureStats::AiSetting::AI_Alarm:
|
||||
copy.mAiData.mAlarm = value;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
MWBase::Environment::get().getWorld()->createOverrideRecord(copy);
|
||||
}
|
||||
Hello = 0,
|
||||
Fight = 1,
|
||||
Flee = 2,
|
||||
Alarm = 3
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "creaturestats.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
#include <components/esm3/creaturestats.hpp>
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
@ -99,7 +100,7 @@ namespace MWMechanics
|
||||
|
||||
Stat<int> CreatureStats::getAiSetting (AiSetting index) const
|
||||
{
|
||||
return mAiSettings[index];
|
||||
return mAiSettings[static_cast<std::underlying_type_t<AiSetting>>(index)];
|
||||
}
|
||||
|
||||
const DynamicStat<float> &CreatureStats::getDynamic(int index) const
|
||||
@ -212,7 +213,7 @@ namespace MWMechanics
|
||||
|
||||
void CreatureStats::setAiSetting (AiSetting index, Stat<int> value)
|
||||
{
|
||||
mAiSettings[index] = value;
|
||||
mAiSettings[static_cast<std::underlying_type_t<AiSetting>>(index)] = value;
|
||||
}
|
||||
|
||||
void CreatureStats::setAiSetting (AiSetting index, int base)
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "activespells.hpp"
|
||||
#include "aisequence.hpp"
|
||||
#include "drawstate.hpp"
|
||||
#include "aisetting.hpp"
|
||||
|
||||
#include <components/esm/attr.hpp>
|
||||
#include <components/esm3/magiceffects.hpp>
|
||||
@ -154,13 +155,6 @@ namespace MWMechanics
|
||||
|
||||
void setLevel(int level);
|
||||
|
||||
enum AiSetting
|
||||
{
|
||||
AI_Hello = 0,
|
||||
AI_Fight = 1,
|
||||
AI_Flee = 2,
|
||||
AI_Alarm = 3
|
||||
};
|
||||
void setAiSetting (AiSetting index, Stat<int> value);
|
||||
void setAiSetting (AiSetting index, int base);
|
||||
Stat<int> getAiSetting (AiSetting index) const;
|
||||
|
@ -678,11 +678,11 @@ namespace MWMechanics
|
||||
{
|
||||
float s = floor(r * fPerDieRollMult * fPerTempMult);
|
||||
|
||||
int flee = npcStats.getAiSetting(MWMechanics::CreatureStats::AI_Flee).getBase();
|
||||
int fight = npcStats.getAiSetting(MWMechanics::CreatureStats::AI_Fight).getBase();
|
||||
npcStats.setAiSetting (MWMechanics::CreatureStats::AI_Flee,
|
||||
const int flee = npcStats.getAiSetting(MWMechanics::AiSetting::Flee).getBase();
|
||||
const int fight = npcStats.getAiSetting(MWMechanics::AiSetting::Fight).getBase();
|
||||
npcStats.setAiSetting (MWMechanics::AiSetting::Flee,
|
||||
std::clamp(flee + int(std::max(iPerMinChange, s)), 0, 100));
|
||||
npcStats.setAiSetting (MWMechanics::CreatureStats::AI_Fight,
|
||||
npcStats.setAiSetting (MWMechanics::AiSetting::Fight,
|
||||
std::clamp(fight + int(std::min(-iPerMinChange, -s)), 0, 100));
|
||||
}
|
||||
|
||||
@ -719,11 +719,11 @@ namespace MWMechanics
|
||||
if (success)
|
||||
{
|
||||
float s = c * fPerDieRollMult * fPerTempMult;
|
||||
int flee = npcStats.getAiSetting (CreatureStats::AI_Flee).getBase();
|
||||
int fight = npcStats.getAiSetting (CreatureStats::AI_Fight).getBase();
|
||||
npcStats.setAiSetting(CreatureStats::AI_Flee,
|
||||
const int flee = npcStats.getAiSetting(AiSetting::Flee).getBase();
|
||||
const int fight = npcStats.getAiSetting(AiSetting::Fight).getBase();
|
||||
npcStats.setAiSetting(AiSetting::Flee,
|
||||
std::clamp(flee + std::min(-int(iPerMinChange), int(-s)), 0, 100));
|
||||
npcStats.setAiSetting(CreatureStats::AI_Fight,
|
||||
npcStats.setAiSetting(AiSetting::Fight,
|
||||
std::clamp(fight + std::max(int(iPerMinChange), int(s)), 0, 100));
|
||||
}
|
||||
x = floor(-c * fPerDieRollMult);
|
||||
@ -1297,7 +1297,7 @@ namespace MWMechanics
|
||||
continue;
|
||||
|
||||
// Will the witness report the crime?
|
||||
if (actor.getClass().getCreatureStats(actor).getAiSetting(CreatureStats::AI_Alarm).getBase() >= 100)
|
||||
if (actor.getClass().getCreatureStats(actor).getAiSetting(AiSetting::Alarm).getBase() >= 100)
|
||||
{
|
||||
reported = true;
|
||||
|
||||
@ -1329,7 +1329,7 @@ namespace MWMechanics
|
||||
{
|
||||
float dispTerm = (actor == victim) ? dispVictim : disp;
|
||||
|
||||
float alarmTerm = 0.01f * actor.getClass().getCreatureStats(actor).getAiSetting(CreatureStats::AI_Alarm).getBase();
|
||||
float alarmTerm = 0.01f * actor.getClass().getCreatureStats(actor).getAiSetting(AiSetting::Alarm).getBase();
|
||||
if (type == OT_Pickpocket && alarmTerm <= 0)
|
||||
alarmTerm = 1.0;
|
||||
|
||||
@ -1341,7 +1341,7 @@ namespace MWMechanics
|
||||
fightTerm += getFightDistanceBias(actor, player);
|
||||
fightTerm *= alarmTerm;
|
||||
|
||||
int observerFightRating = actor.getClass().getCreatureStats(actor).getAiSetting(CreatureStats::AI_Fight).getBase();
|
||||
const int observerFightRating = actor.getClass().getCreatureStats(actor).getAiSetting(AiSetting::Fight).getBase();
|
||||
if (observerFightRating + fightTerm > 100)
|
||||
fightTerm = static_cast<float>(100 - observerFightRating);
|
||||
fightTerm = std::max(0.f, fightTerm);
|
||||
@ -1353,7 +1353,7 @@ namespace MWMechanics
|
||||
NpcStats& observerStats = actor.getClass().getNpcStats(actor);
|
||||
// Apply aggression value to the base Fight rating, so that the actor can continue fighting
|
||||
// after a Calm spell wears off
|
||||
observerStats.setAiSetting(CreatureStats::AI_Fight, observerFightRating + static_cast<int>(fightTerm));
|
||||
observerStats.setAiSetting(AiSetting::Fight, observerFightRating + static_cast<int>(fightTerm));
|
||||
|
||||
observerStats.setBaseDisposition(observerStats.getBaseDisposition() + static_cast<int>(dispTerm));
|
||||
|
||||
@ -1452,7 +1452,7 @@ namespace MWMechanics
|
||||
std::string script = target.getClass().getScript(target);
|
||||
if (!script.empty() && target.getRefData().getLocals().hasVar(script, "onpchitme") && attacker == player)
|
||||
{
|
||||
int fight = target.getClass().getCreatureStats(target).getAiSetting(CreatureStats::AI_Fight).getModified();
|
||||
const int fight = target.getClass().getCreatureStats(target).getAiSetting(AiSetting::Fight).getModified();
|
||||
peaceful = (fight == 0);
|
||||
}
|
||||
|
||||
@ -1736,7 +1736,7 @@ namespace MWMechanics
|
||||
if (ptr.getClass().isNpc())
|
||||
disposition = getDerivedDisposition(ptr);
|
||||
|
||||
int fight = ptr.getClass().getCreatureStats(ptr).getAiSetting(CreatureStats::AI_Fight).getModified()
|
||||
int fight = ptr.getClass().getCreatureStats(ptr).getAiSetting(AiSetting::Fight).getModified()
|
||||
+ static_cast<int>(getFightDistanceBias(ptr, target) + getFightDispositionBias(static_cast<float>(disposition)));
|
||||
|
||||
if (ptr.getClass().isNpc() && target.getClass().isNpc())
|
||||
@ -1851,7 +1851,7 @@ namespace MWMechanics
|
||||
if (MWBase::Environment::get().getWorld()->getLOS(neighbor, actor) && awarenessCheck(actor, neighbor))
|
||||
{
|
||||
detected = true;
|
||||
if (neighbor.getClass().getCreatureStats(neighbor).getAiSetting(MWMechanics::CreatureStats::AI_Alarm).getModified() > 0)
|
||||
if (neighbor.getClass().getCreatureStats(neighbor).getAiSetting(MWMechanics::AiSetting::Alarm).getModified() > 0)
|
||||
{
|
||||
reported = true;
|
||||
break;
|
||||
|
41
apps/openmw/mwmechanics/setbaseaisetting.hpp
Normal file
41
apps/openmw/mwmechanics/setbaseaisetting.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef OPENMW_MWMECHANICS_SETBASEAISETTING_H
|
||||
#define OPENMW_MWMECHANICS_SETBASEAISETTING_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
#include "aisetting.hpp"
|
||||
#include "creaturestats.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
template<class T>
|
||||
void setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value)
|
||||
{
|
||||
T copy = *MWBase::Environment::get().getWorld()->getStore().get<T>().find(id);
|
||||
switch (setting)
|
||||
{
|
||||
case MWMechanics::AiSetting::Hello:
|
||||
copy.mAiData.mHello = value;
|
||||
break;
|
||||
case MWMechanics::AiSetting::Fight:
|
||||
copy.mAiData.mFight = value;
|
||||
break;
|
||||
case MWMechanics::AiSetting::Flee:
|
||||
copy.mAiData.mFlee = value;
|
||||
break;
|
||||
case MWMechanics::AiSetting::Alarm:
|
||||
copy.mAiData.mAlarm = value;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
MWBase::Environment::get().getWorld()->createOverrideRecord(copy);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -40,7 +40,7 @@ namespace
|
||||
return effect.mMinMagnitude + Misc::Rng::rollDice(effect.mMaxMagnitude - effect.mMinMagnitude + 1, prng);
|
||||
}
|
||||
|
||||
void modifyAiSetting(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, ESM::MagicEffect::Effects creatureEffect, MWMechanics::CreatureStats::AiSetting setting, float magnitude, bool& invalid)
|
||||
void modifyAiSetting(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, ESM::MagicEffect::Effects creatureEffect, MWMechanics::AiSetting setting, float magnitude, bool& invalid)
|
||||
{
|
||||
if(target == MWMechanics::getPlayer() || (effect.mEffectId == creatureEffect) == target.getClass().isNpc())
|
||||
invalid = true;
|
||||
@ -501,18 +501,18 @@ void applyMagicEffect(const MWWorld::Ptr& target, const MWWorld::Ptr& caster, co
|
||||
else
|
||||
{
|
||||
auto& creatureStats = target.getClass().getCreatureStats(target);
|
||||
Stat<int> stat = creatureStats.getAiSetting(CreatureStats::AI_Flee);
|
||||
Stat<int> stat = creatureStats.getAiSetting(AiSetting::Flee);
|
||||
stat.setModifier(static_cast<int>(stat.getModifier() + effect.mMagnitude));
|
||||
creatureStats.setAiSetting(CreatureStats::AI_Flee, stat);
|
||||
creatureStats.setAiSetting(AiSetting::Flee, stat);
|
||||
}
|
||||
break;
|
||||
case ESM::MagicEffect::FrenzyCreature:
|
||||
case ESM::MagicEffect::FrenzyHumanoid:
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::FrenzyCreature, CreatureStats::AI_Fight, effect.mMagnitude, invalid);
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::FrenzyCreature, AiSetting::Fight, effect.mMagnitude, invalid);
|
||||
break;
|
||||
case ESM::MagicEffect::CalmCreature:
|
||||
case ESM::MagicEffect::CalmHumanoid:
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::CalmCreature, CreatureStats::AI_Fight, -effect.mMagnitude, invalid);
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::CalmCreature, AiSetting::Fight, -effect.mMagnitude, invalid);
|
||||
if(!invalid && effect.mMagnitude > 0)
|
||||
{
|
||||
auto& creatureStats = target.getClass().getCreatureStats(target);
|
||||
@ -521,11 +521,11 @@ void applyMagicEffect(const MWWorld::Ptr& target, const MWWorld::Ptr& caster, co
|
||||
break;
|
||||
case ESM::MagicEffect::DemoralizeCreature:
|
||||
case ESM::MagicEffect::DemoralizeHumanoid:
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::DemoralizeCreature, CreatureStats::AI_Flee, effect.mMagnitude, invalid);
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::DemoralizeCreature, AiSetting::Flee, effect.mMagnitude, invalid);
|
||||
break;
|
||||
case ESM::MagicEffect::RallyCreature:
|
||||
case ESM::MagicEffect::RallyHumanoid:
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::RallyCreature, CreatureStats::AI_Flee, -effect.mMagnitude, invalid);
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::RallyCreature, AiSetting::Flee, -effect.mMagnitude, invalid);
|
||||
break;
|
||||
case ESM::MagicEffect::SummonScamp:
|
||||
case ESM::MagicEffect::SummonClannfear:
|
||||
@ -1006,26 +1006,26 @@ void removeMagicEffect(const MWWorld::Ptr& target, ActiveSpells::ActiveSpellPara
|
||||
case ESM::MagicEffect::TurnUndead:
|
||||
{
|
||||
auto& creatureStats = target.getClass().getCreatureStats(target);
|
||||
Stat<int> stat = creatureStats.getAiSetting(CreatureStats::AI_Flee);
|
||||
Stat<int> stat = creatureStats.getAiSetting(AiSetting::Flee);
|
||||
stat.setModifier(static_cast<int>(stat.getModifier() - effect.mMagnitude));
|
||||
creatureStats.setAiSetting(CreatureStats::AI_Flee, stat);
|
||||
creatureStats.setAiSetting(AiSetting::Flee, stat);
|
||||
}
|
||||
break;
|
||||
case ESM::MagicEffect::FrenzyCreature:
|
||||
case ESM::MagicEffect::FrenzyHumanoid:
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::FrenzyCreature, CreatureStats::AI_Fight, -effect.mMagnitude, invalid);
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::FrenzyCreature, AiSetting::Fight, -effect.mMagnitude, invalid);
|
||||
break;
|
||||
case ESM::MagicEffect::CalmCreature:
|
||||
case ESM::MagicEffect::CalmHumanoid:
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::CalmCreature, CreatureStats::AI_Fight, effect.mMagnitude, invalid);
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::CalmCreature, AiSetting::Fight, effect.mMagnitude, invalid);
|
||||
break;
|
||||
case ESM::MagicEffect::DemoralizeCreature:
|
||||
case ESM::MagicEffect::DemoralizeHumanoid:
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::DemoralizeCreature, CreatureStats::AI_Flee, -effect.mMagnitude, invalid);
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::DemoralizeCreature, AiSetting::Flee, -effect.mMagnitude, invalid);
|
||||
break;
|
||||
case ESM::MagicEffect::RallyCreature:
|
||||
case ESM::MagicEffect::RallyHumanoid:
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::RallyCreature, CreatureStats::AI_Flee, effect.mMagnitude, invalid);
|
||||
modifyAiSetting(target, effect, ESM::MagicEffect::RallyCreature, AiSetting::Flee, effect.mMagnitude, invalid);
|
||||
break;
|
||||
case ESM::MagicEffect::SummonScamp:
|
||||
case ESM::MagicEffect::SummonClannfear:
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "weapontype.hpp"
|
||||
|
||||
#include "drawstate.hpp"
|
||||
#include "creaturestats.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
|
@ -16,7 +16,10 @@
|
||||
|
||||
#include "../mwmechanics/actorutil.hpp"
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "../mwrender/bulletdebugdraw.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
#include "../mwmechanics/actorutil.hpp"
|
||||
#include "../mwmechanics/weapontype.hpp"
|
||||
#include "../mwmechanics/drawstate.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "vismask.hpp"
|
||||
|
||||
|
@ -255,9 +255,9 @@ namespace MWScript
|
||||
template<class R>
|
||||
class OpGetAiSetting : public Interpreter::Opcode0
|
||||
{
|
||||
MWMechanics::CreatureStats::AiSetting mIndex;
|
||||
MWMechanics::AiSetting mIndex;
|
||||
public:
|
||||
OpGetAiSetting(MWMechanics::CreatureStats::AiSetting index) : mIndex(index) {}
|
||||
OpGetAiSetting(MWMechanics::AiSetting index) : mIndex(index) {}
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
@ -272,9 +272,9 @@ namespace MWScript
|
||||
template<class R>
|
||||
class OpModAiSetting : public Interpreter::Opcode0
|
||||
{
|
||||
MWMechanics::CreatureStats::AiSetting mIndex;
|
||||
MWMechanics::AiSetting mIndex;
|
||||
public:
|
||||
OpModAiSetting(MWMechanics::CreatureStats::AiSetting index) : mIndex(index) {}
|
||||
OpModAiSetting(MWMechanics::AiSetting index) : mIndex(index) {}
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
@ -294,9 +294,9 @@ namespace MWScript
|
||||
template<class R>
|
||||
class OpSetAiSetting : public Interpreter::Opcode0
|
||||
{
|
||||
MWMechanics::CreatureStats::AiSetting mIndex;
|
||||
MWMechanics::AiSetting mIndex;
|
||||
public:
|
||||
OpSetAiSetting(MWMechanics::CreatureStats::AiSetting index) : mIndex(index) {}
|
||||
OpSetAiSetting(MWMechanics::AiSetting index) : mIndex(index) {}
|
||||
|
||||
void execute (Interpreter::Runtime& runtime) override
|
||||
{
|
||||
@ -586,32 +586,32 @@ namespace MWScript
|
||||
interpreter.installSegment5<OpStopCombat<ExplicitRef>>(Compiler::Ai::opcodeStopCombatExplicit);
|
||||
interpreter.installSegment5<OpToggleAI>(Compiler::Ai::opcodeToggleAI);
|
||||
|
||||
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeSetHello, MWMechanics::CreatureStats::AiSetting::AI_Hello);
|
||||
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeSetHelloExplicit, MWMechanics::CreatureStats::AiSetting::AI_Hello);
|
||||
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeSetFight, MWMechanics::CreatureStats::AiSetting::AI_Fight);
|
||||
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeSetFightExplicit, MWMechanics::CreatureStats::AiSetting::AI_Fight);
|
||||
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeSetFlee, MWMechanics::CreatureStats::AiSetting::AI_Flee);
|
||||
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeSetFleeExplicit, MWMechanics::CreatureStats::AiSetting::AI_Flee);
|
||||
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeSetAlarm, MWMechanics::CreatureStats::AiSetting::AI_Alarm);
|
||||
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeSetAlarmExplicit, MWMechanics::CreatureStats::AiSetting::AI_Alarm);
|
||||
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeSetHello, MWMechanics::AiSetting::Hello);
|
||||
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeSetHelloExplicit, MWMechanics::AiSetting::Hello);
|
||||
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeSetFight, MWMechanics::AiSetting::Fight);
|
||||
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeSetFightExplicit, MWMechanics::AiSetting::Fight);
|
||||
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeSetFlee, MWMechanics::AiSetting::Flee);
|
||||
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeSetFleeExplicit, MWMechanics::AiSetting::Flee);
|
||||
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeSetAlarm, MWMechanics::AiSetting::Alarm);
|
||||
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeSetAlarmExplicit, MWMechanics::AiSetting::Alarm);
|
||||
|
||||
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(Compiler::Ai::opcodeModHello, MWMechanics::CreatureStats::AiSetting::AI_Hello);
|
||||
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(Compiler::Ai::opcodeModHelloExplicit, MWMechanics::CreatureStats::AiSetting::AI_Hello);
|
||||
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(Compiler::Ai::opcodeModFight, MWMechanics::CreatureStats::AiSetting::AI_Fight);
|
||||
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(Compiler::Ai::opcodeModFightExplicit, MWMechanics::CreatureStats::AiSetting::AI_Fight);
|
||||
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(Compiler::Ai::opcodeModFlee, MWMechanics::CreatureStats::AiSetting::AI_Flee);
|
||||
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(Compiler::Ai::opcodeModFleeExplicit, MWMechanics::CreatureStats::AiSetting::AI_Flee);
|
||||
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(Compiler::Ai::opcodeModAlarm, MWMechanics::CreatureStats::AiSetting::AI_Alarm);
|
||||
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(Compiler::Ai::opcodeModAlarmExplicit, MWMechanics::CreatureStats::AiSetting::AI_Alarm);
|
||||
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(Compiler::Ai::opcodeModHello, MWMechanics::AiSetting::Hello);
|
||||
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(Compiler::Ai::opcodeModHelloExplicit, MWMechanics::AiSetting::Hello);
|
||||
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(Compiler::Ai::opcodeModFight, MWMechanics::AiSetting::Fight);
|
||||
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(Compiler::Ai::opcodeModFightExplicit, MWMechanics::AiSetting::Fight);
|
||||
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(Compiler::Ai::opcodeModFlee, MWMechanics::AiSetting::Flee);
|
||||
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(Compiler::Ai::opcodeModFleeExplicit, MWMechanics::AiSetting::Flee);
|
||||
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(Compiler::Ai::opcodeModAlarm, MWMechanics::AiSetting::Alarm);
|
||||
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(Compiler::Ai::opcodeModAlarmExplicit, MWMechanics::AiSetting::Alarm);
|
||||
|
||||
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeGetHello, MWMechanics::CreatureStats::AiSetting::AI_Hello);
|
||||
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeGetHelloExplicit, MWMechanics::CreatureStats::AiSetting::AI_Hello);
|
||||
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeGetFight, MWMechanics::CreatureStats::AiSetting::AI_Fight);
|
||||
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeGetFightExplicit, MWMechanics::CreatureStats::AiSetting::AI_Fight);
|
||||
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeGetFlee, MWMechanics::CreatureStats::AiSetting::AI_Flee);
|
||||
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeGetFleeExplicit, MWMechanics::CreatureStats::AiSetting::AI_Flee);
|
||||
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeGetAlarm, MWMechanics::CreatureStats::AiSetting::AI_Alarm);
|
||||
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeGetAlarmExplicit, MWMechanics::CreatureStats::AiSetting::AI_Alarm);
|
||||
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeGetHello, MWMechanics::AiSetting::Hello);
|
||||
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeGetHelloExplicit, MWMechanics::AiSetting::Hello);
|
||||
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeGetFight, MWMechanics::AiSetting::Fight);
|
||||
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeGetFightExplicit, MWMechanics::AiSetting::Fight);
|
||||
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeGetFlee, MWMechanics::AiSetting::Flee);
|
||||
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeGetFleeExplicit, MWMechanics::AiSetting::Flee);
|
||||
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(Compiler::Ai::opcodeGetAlarm, MWMechanics::AiSetting::Alarm);
|
||||
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(Compiler::Ai::opcodeGetAlarmExplicit, MWMechanics::AiSetting::Alarm);
|
||||
|
||||
interpreter.installSegment5<OpFace<ImplicitRef>>(Compiler::Ai::opcodeFace);
|
||||
interpreter.installSegment5<OpFace<ExplicitRef>>(Compiler::Ai::opcodeFaceExplicit);
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
||||
|
@ -521,7 +521,7 @@ namespace MWWorld
|
||||
return result;
|
||||
}
|
||||
|
||||
void Class::setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value) const
|
||||
void Class::setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have creature stats");
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
#include "ptr.hpp"
|
||||
#include "doorstate.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "../mwmechanics/aisetting.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
@ -32,6 +33,7 @@ namespace MWMechanics
|
||||
{
|
||||
class NpcStats;
|
||||
struct Movement;
|
||||
class CreatureStats;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
@ -361,7 +363,7 @@ namespace MWWorld
|
||||
|
||||
virtual osg::Vec4f getEnchantmentColor(const MWWorld::ConstPtr& item) const;
|
||||
|
||||
virtual void setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value) const;
|
||||
virtual void setBaseAISetting(const std::string& id, MWMechanics::AiSetting setting, int value) const;
|
||||
|
||||
virtual void modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount) const;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user