1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 12:32:36 +00:00
OpenMW/apps/openmw/mwscript/statsextensions.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

1523 lines
60 KiB
C++
Raw Normal View History

#include "statsextensions.hpp"
#include <cmath>
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadnpc.hpp>
2012-10-01 19:17:04 +04:00
#include "../mwworld/esmstore.hpp"
2012-07-03 15:53:42 +02:00
#include <components/compiler/opcodes.hpp>
2018-08-14 23:05:43 +04:00
#include <components/debug/debuglog.hpp>
#include <components/esm3/loadfact.hpp>
#include <components/interpreter/interpreter.hpp>
#include <components/interpreter/opcodes.hpp>
#include <components/interpreter/runtime.hpp>
#include <components/esm3/loadmgef.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
2018-07-26 19:54:08 +03:00
#include "../mwbase/statemanager.hpp"
2014-02-11 16:34:23 +01:00
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/player.hpp"
2015-08-21 21:12:39 +12:00
#include "../mwmechanics/actorutil.hpp"
2010-08-03 13:32:37 +02:00
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"
2010-08-03 13:32:37 +02:00
#include "ref.hpp"
2012-11-10 14:31:58 +01:00
namespace
{
ESM::RefId getDialogueActorFaction(const MWWorld::ConstPtr& actor)
2012-11-10 14:31:58 +01:00
{
ESM::RefId factionId = actor.getClass().getPrimaryFaction(actor);
2015-01-27 17:32:21 +01:00
if (factionId.empty())
2012-11-10 14:31:58 +01:00
throw std::runtime_error("failed to determine dialogue actors faction (because actor is factionless)");
2012-11-13 16:11:03 +01:00
2015-01-27 17:32:21 +01:00
return factionId;
2012-11-10 14:31:58 +01:00
}
void modStat(MWMechanics::AttributeValue& stat, float amount)
{
2022-07-12 19:59:18 +02:00
const float base = stat.getBase();
const float modifier = stat.getModifier() - stat.getDamage();
const float modified = base + modifier;
// Clamp to 100 unless base < 100 and we have a fortification going
if ((modifier <= 0.f || base >= 100.f) && amount > 0.f)
amount = std::clamp(100.f - modified, 0.f, amount);
2022-07-12 19:59:18 +02:00
// Clamp the modified value in a way that doesn't properly account for negative numbers
float newModified = modified + amount;
if (newModified < 0.f)
{
if (modified >= 0.f)
newModified = 0.f;
else if (newModified < modified)
newModified = modified;
}
// Calculate damage/fortification based on the clamped base value
stat.setBase(std::clamp(base + amount, 0.f, 100.f), true);
stat.setModifier(newModified - stat.getBase());
}
template <class T>
void updateBaseRecord(MWWorld::Ptr& ptr)
{
2023-04-20 21:07:53 +02:00
const auto& store = *MWBase::Environment::get().getESMStore();
const T* base = store.get<T>().find(ptr.getCellRef().getRefId());
ptr.get<T>()->mBase = base;
}
2012-11-10 14:31:58 +01:00
}
namespace MWScript
{
namespace Stats
{
2012-09-15 17:12:42 +02:00
template <class R>
class OpGetLevel : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
2012-09-15 17:12:42 +02:00
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value = ptr.getClass().getCreatureStats(ptr).getLevel();
runtime.push(value);
}
};
template <class R>
class OpSetLevel : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
2012-09-15 17:12:42 +02:00
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value = runtime[0].mInteger;
runtime.pop();
ptr.getClass().getCreatureStats(ptr).setLevel(value);
}
};
template <class R>
class OpGetAttribute : public Interpreter::Opcode0
{
int mIndex;
public:
OpGetAttribute(int index)
: mIndex(index)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Float value = ptr.getClass().getCreatureStats(ptr).getAttribute(mIndex).getModified();
runtime.push(value);
}
};
template <class R>
class OpSetAttribute : public Interpreter::Opcode0
{
int mIndex;
public:
OpSetAttribute(int index)
: mIndex(index)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Float value = runtime[0].mFloat;
runtime.pop();
MWMechanics::AttributeValue attribute = ptr.getClass().getCreatureStats(ptr).getAttribute(mIndex);
attribute.setBase(value, true);
ptr.getClass().getCreatureStats(ptr).setAttribute(mIndex, attribute);
}
};
template <class R>
class OpModAttribute : public Interpreter::Opcode0
{
int mIndex;
public:
OpModAttribute(int index)
: mIndex(index)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Float value = runtime[0].mFloat;
runtime.pop();
MWMechanics::AttributeValue attribute = ptr.getClass().getCreatureStats(ptr).getAttribute(mIndex);
modStat(attribute, value);
ptr.getClass().getCreatureStats(ptr).setAttribute(mIndex, attribute);
}
};
template <class R>
class OpGetDynamic : public Interpreter::Opcode0
{
int mIndex;
public:
OpGetDynamic(int index)
: mIndex(index)
2022-09-22 21:26:05 +03:00
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Float value;
if (mIndex == 0 && ptr.getClass().hasItemHealth(ptr))
{
// health is a special case
value = static_cast<Interpreter::Type_Float>(ptr.getClass().getItemMaxHealth(ptr));
2012-07-22 18:29:54 +04:00
}
else
{
value = ptr.getClass().getCreatureStats(ptr).getDynamic(mIndex).getCurrent();
// GetMagicka shouldn't return negative values
if (mIndex == 1 && value < 0)
value = 0;
}
runtime.push(value);
2022-09-22 21:26:05 +03:00
}
};
template <class R>
class OpSetDynamic : public Interpreter::Opcode0
{
int mIndex;
public:
OpSetDynamic(int index)
: mIndex(index)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Float value = runtime[0].mFloat;
runtime.pop();
MWMechanics::DynamicStat<float> stat(ptr.getClass().getCreatureStats(ptr).getDynamic(mIndex));
stat.setBase(value);
stat.setCurrent(stat.getModified(false), true, true);
2012-11-13 16:11:03 +01:00
ptr.getClass().getCreatureStats(ptr).setDynamic(mIndex, stat);
}
};
template <class R>
class OpModDynamic : public Interpreter::Opcode0
{
int mIndex;
public:
OpModDynamic(int index)
: mIndex(index)
2022-09-22 21:26:05 +03:00
{
}
void execute(Interpreter::Runtime& runtime) override
{
int peek = R::implicit ? 0 : runtime[0].mInteger;
2014-10-15 16:27:03 +02:00
MWWorld::Ptr ptr = R()(runtime);
2014-10-15 16:12:57 +02:00
Interpreter::Type_Float diff = runtime[0].mFloat;
runtime.pop();
// workaround broken endgame scripts that kill dagoth ur
if (!R::implicit && ptr.getCellRef().getRefId() == "dagoth_ur_1")
2022-09-22 21:26:05 +03:00
{
runtime.push(peek);
2015-09-24 15:21:42 +02:00
if (R()(runtime, false, true).isEmpty())
2014-10-15 16:12:57 +02:00
{
Log(Debug::Warning) << "Warning: Compensating for broken script in Morrowind.esm by "
<< "ignoring remote access to dagoth_ur_1";
return;
}
2022-09-22 21:26:05 +03:00
}
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
MWMechanics::DynamicStat<float> stat = stats.getDynamic(mIndex);
float current = stat.getCurrent();
float base = diff + stat.getBase();
if (mIndex != 2)
base = std::max(base, 0.f);
stat.setBase(base);
stat.setCurrent(diff + current, true, true);
stats.setDynamic(mIndex, stat);
}
};
template <class R>
class OpModCurrentDynamic : public Interpreter::Opcode0
{
int mIndex;
2022-09-22 21:26:05 +03:00
public:
OpModCurrentDynamic(int index)
: mIndex(index)
{
2022-09-22 21:26:05 +03:00
}
void execute(Interpreter::Runtime& runtime) override
2022-09-22 21:26:05 +03:00
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Float diff = runtime[0].mFloat;
runtime.pop();
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
Interpreter::Type_Float current = stats.getDynamic(mIndex).getCurrent();
MWMechanics::DynamicStat<float> stat(ptr.getClass().getCreatureStats(ptr).getDynamic(mIndex));
bool allowDecreaseBelowZero = false;
if (mIndex == 2) // Fatigue-specific logic
2022-09-22 21:26:05 +03:00
{
// For fatigue, a negative current value is allowed and means the actor will be knocked down
allowDecreaseBelowZero = true;
// Knock down the actor immediately if a non-positive new value is the case
if (diff + current <= 0.f)
ptr.getClass().getCreatureStats(ptr).setKnockedDown(true);
}
stat.setCurrent(diff + current, allowDecreaseBelowZero);
2022-09-22 21:26:05 +03:00
2022-02-10 22:10:46 +01:00
ptr.getClass().getCreatureStats(ptr).setDynamic(mIndex, stat);
2022-09-22 21:26:05 +03:00
}
};
template <class R>
2010-07-28 19:12:50 +02:00
class OpGetDynamicGetRatio : public Interpreter::Opcode0
{
int mIndex;
public:
OpGetDynamicGetRatio(int index)
: mIndex(index)
{
}
void execute(Interpreter::Runtime& runtime) override
2010-07-28 19:12:50 +02:00
{
MWWorld::Ptr ptr = R()(runtime);
2022-02-10 22:10:46 +01:00
const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
2022-02-10 22:10:46 +01:00
runtime.push(stats.getDynamic(mIndex).getRatio());
2010-07-28 19:12:50 +02:00
}
};
template <class R>
class OpGetSkill : public Interpreter::Opcode0
{
2023-06-05 21:21:30 +02:00
ESM::RefId mId;
public:
2023-06-05 21:21:30 +02:00
OpGetSkill(ESM::RefId id)
: mId(id)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
2023-06-05 21:21:30 +02:00
Interpreter::Type_Float value = ptr.getClass().getSkill(ptr, mId);
runtime.push(value);
}
};
template <class R>
class OpSetSkill : public Interpreter::Opcode0
{
2023-06-05 21:21:30 +02:00
ESM::RefId mId;
public:
2023-06-05 21:21:30 +02:00
OpSetSkill(ESM::RefId id)
: mId(id)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Float value = runtime[0].mFloat;
runtime.pop();
MWMechanics::NpcStats& stats = ptr.getClass().getNpcStats(ptr);
2023-06-05 21:21:30 +02:00
stats.getSkill(mId).setBase(value, true);
}
};
template <class R>
class OpModSkill : public Interpreter::Opcode0
{
2023-06-05 21:21:30 +02:00
ESM::RefId mId;
public:
2023-06-05 21:21:30 +02:00
OpModSkill(ESM::RefId id)
: mId(id)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Float value = runtime[0].mFloat;
runtime.pop();
2023-06-05 21:21:30 +02:00
MWMechanics::SkillValue& skill = ptr.getClass().getNpcStats(ptr).getSkill(mId);
modStat(skill, value);
}
};
class OpGetPCCrimeLevel : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWBase::World* world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr();
runtime.push(static_cast<Interpreter::Type_Float>(player.getClass().getNpcStats(player).getBounty()));
}
};
class OpSetPCCrimeLevel : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWBase::World* world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr();
int bounty = static_cast<int>(runtime[0].mFloat);
runtime.pop();
player.getClass().getNpcStats(player).setBounty(bounty);
if (bounty == 0)
MWBase::Environment::get().getWorld()->getPlayer().recordCrimeId();
}
};
class OpModPCCrimeLevel : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWBase::World* world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr();
player.getClass().getNpcStats(player).setBounty(
static_cast<int>(runtime[0].mFloat) + player.getClass().getNpcStats(player).getBounty());
runtime.pop();
}
};
template <class R>
class OpAddSpell : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId id = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
runtime.pop();
2023-04-20 21:07:53 +02:00
const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(id);
MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
creatureStats.getSpells().add(spell);
ESM::Spell::SpellType type = static_cast<ESM::Spell::SpellType>(spell->mData.mType);
if (type != ESM::Spell::ST_Spell && type != ESM::Spell::ST_Power)
{
// Add spell effect to *this actor's* queue immediately
creatureStats.getActiveSpells().addSpell(spell, ptr);
// Apply looping particles immediately for constant effects
MWBase::Environment::get().getWorld()->applyLoopingParticles(ptr);
}
2022-09-22 21:26:05 +03:00
}
};
template <class R>
class OpRemoveSpell : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId id = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
runtime.pop();
MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
2022-05-22 09:29:03 +02:00
creatureStats.getSpells().remove(id);
2014-02-11 16:34:23 +01:00
MWBase::WindowManager* wm = MWBase::Environment::get().getWindowManager();
2015-08-21 21:12:39 +12:00
if (ptr == MWMechanics::getPlayer() && id == wm->getSelectedSpell())
2014-02-11 16:34:23 +01:00
{
wm->unsetSelectedSpell();
}
2022-09-22 21:26:05 +03:00
}
};
template <class R>
class OpRemoveSpellEffects : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId spellid = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
runtime.pop();
ptr.getClass().getCreatureStats(ptr).getActiveSpells().removeEffects(ptr, spellid);
}
};
2014-01-03 05:19:10 +01:00
template <class R>
class OpRemoveEffects : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
2014-01-03 05:19:10 +01:00
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer effectId = runtime[0].mInteger;
runtime.pop();
ptr.getClass().getCreatureStats(ptr).getActiveSpells().purgeEffect(ptr, effectId);
2014-01-03 05:19:10 +01:00
}
};
2012-04-13 13:17:57 +02:00
template <class R>
class OpGetSpell : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
2012-04-13 13:17:57 +02:00
{
2012-04-13 13:17:57 +02:00
MWWorld::Ptr ptr = R()(runtime);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId id = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
2012-04-13 13:17:57 +02:00
runtime.pop();
Interpreter::Type_Integer value = 0;
2022-05-22 09:29:03 +02:00
if (ptr.getClass().isActor() && ptr.getClass().getCreatureStats(ptr).getSpells().hasSpell(id))
2015-05-10 13:09:22 +02:00
value = 1;
2012-04-13 13:17:57 +02:00
runtime.push(value);
}
};
template <class R>
2012-04-09 14:30:42 +02:00
class OpPCJoinFaction : public Interpreter::Opcode1
2012-03-28 11:45:46 +02:00
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2012-03-28 11:45:46 +02:00
{
MWWorld::ConstPtr actor = R()(runtime, false);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionID;
2012-04-09 14:30:42 +02:00
if (arg0 == 0)
{
factionID = getDialogueActorFaction(actor);
2012-04-09 14:30:42 +02:00
}
else
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
2012-04-09 14:30:42 +02:00
runtime.pop();
}
// Make sure this faction exists
2023-04-20 21:07:53 +02:00
MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionID);
if (!factionID.empty())
2012-04-09 14:30:42 +02:00
{
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
player.getClass().getNpcStats(player).joinFaction(factionID);
2012-03-28 11:45:46 +02:00
}
2022-09-22 21:26:05 +03:00
}
2012-03-28 11:45:46 +02:00
};
template <class R>
class OpPCRaiseRank : public Interpreter::Opcode1
2012-03-28 11:45:46 +02:00
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2022-09-22 21:26:05 +03:00
{
MWWorld::ConstPtr actor = R()(runtime, false);
2012-03-28 11:45:46 +02:00
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionID;
2012-11-13 16:11:03 +01:00
if (arg0 == 0)
2022-09-22 21:26:05 +03:00
{
factionID = getDialogueActorFaction(actor);
2022-09-22 21:26:05 +03:00
}
else
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
runtime.pop();
2022-09-22 21:26:05 +03:00
}
// Make sure this faction exists
2023-04-20 21:07:53 +02:00
MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionID);
if (!factionID.empty())
2022-09-22 21:26:05 +03:00
{
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
if (!player.getClass().getNpcStats(player).isInFaction(factionID))
{
player.getClass().getNpcStats(player).joinFaction(factionID);
}
else
{
2023-06-14 03:38:22 +08:00
int currentRank = player.getClass().getNpcStats(player).getFactionRank(factionID);
player.getClass().getNpcStats(player).setFactionRank(factionID, currentRank + 1);
}
2012-03-28 11:45:46 +02:00
}
2022-09-22 21:26:05 +03:00
}
2012-03-28 11:45:46 +02:00
};
template <class R>
2012-04-09 14:26:53 +02:00
class OpPCLowerRank : public Interpreter::Opcode1
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2012-04-09 14:26:53 +02:00
{
MWWorld::ConstPtr actor = R()(runtime, false);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionID;
2012-04-09 14:26:53 +02:00
if (arg0 == 0)
{
factionID = getDialogueActorFaction(actor);
2012-04-09 14:26:53 +02:00
}
else
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
2012-04-09 14:26:53 +02:00
runtime.pop();
}
// Make sure this faction exists
2023-04-20 21:07:53 +02:00
MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionID);
if (!factionID.empty())
2012-04-09 14:26:53 +02:00
{
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
2023-06-14 03:38:22 +08:00
int currentRank = player.getClass().getNpcStats(player).getFactionRank(factionID);
player.getClass().getNpcStats(player).setFactionRank(factionID, currentRank - 1);
2012-04-09 14:26:53 +02:00
}
2022-09-22 21:26:05 +03:00
}
2012-04-09 14:26:53 +02:00
};
template <class R>
class OpGetPCRank : public Interpreter::Opcode1
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2022-09-22 21:26:05 +03:00
{
MWWorld::ConstPtr ptr = R()(runtime, false);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionID;
if (arg0 > 0)
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
runtime.pop();
}
else
{
2015-01-27 17:32:21 +01:00
factionID = ptr.getClass().getPrimaryFaction(ptr);
}
// Make sure this faction exists
2023-04-20 21:07:53 +02:00
MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionID);
if (!factionID.empty())
{
MWWorld::Ptr player = MWMechanics::getPlayer();
runtime.push(player.getClass().getNpcStats(player).getFactionRank(factionID));
}
else
{
runtime.push(-1);
}
2022-09-22 21:26:05 +03:00
}
};
2012-04-13 14:54:13 +02:00
template <class R>
class OpModDisposition : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
2012-04-13 14:54:13 +02:00
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value = runtime[0].mInteger;
2012-04-13 14:54:13 +02:00
runtime.pop();
if (ptr.getClass().isNpc())
ptr.getClass().getNpcStats(ptr).setBaseDisposition(
ptr.getClass().getNpcStats(ptr).getBaseDisposition() + value);
// else: must not throw exception (used by an Almalexia dialogue script)
}
};
template <class R>
class OpSetDisposition : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value = runtime[0].mInteger;
runtime.pop();
if (ptr.getClass().isNpc())
ptr.getClass().getNpcStats(ptr).setBaseDisposition(value);
}
2012-11-13 16:11:03 +01:00
};
template <class R>
class OpGetDisposition : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
if (!ptr.getClass().isNpc())
runtime.push(0);
else
runtime.push(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(ptr));
}
2012-11-13 16:11:03 +01:00
};
class OpGetDeadCount : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId id = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
2022-05-22 09:29:03 +02:00
runtime[0].mInteger = MWBase::Environment::get().getMechanicsManager()->countDeaths(id);
}
2012-11-13 16:11:03 +01:00
};
template <class R>
class OpGetPCFacRep : public Interpreter::Opcode1
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2012-11-13 16:11:03 +01:00
{
MWWorld::ConstPtr ptr = R()(runtime, false);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionId;
2012-11-13 16:11:03 +01:00
if (arg0 == 1)
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionId = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
2012-11-13 16:11:03 +01:00
runtime.pop();
}
else
{
2015-01-27 17:32:21 +01:00
factionId = getDialogueActorFaction(ptr);
2012-11-13 16:11:03 +01:00
}
if (factionId.empty())
throw std::runtime_error("failed to determine faction");
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
runtime.push(player.getClass().getNpcStats(player).getFactionReputation(factionId));
2012-11-13 16:11:03 +01:00
}
};
template <class R>
class OpSetPCFacRep : public Interpreter::Opcode1
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2012-11-13 16:11:03 +01:00
{
MWWorld::ConstPtr ptr = R()(runtime, false);
2012-11-13 16:11:03 +01:00
Interpreter::Type_Integer value = runtime[0].mInteger;
runtime.pop();
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionId;
2012-11-13 16:11:03 +01:00
if (arg0 == 1)
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionId = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
2012-11-13 16:11:03 +01:00
runtime.pop();
}
else
{
2015-01-27 17:32:21 +01:00
factionId = getDialogueActorFaction(ptr);
2012-11-13 16:11:03 +01:00
}
if (factionId.empty())
throw std::runtime_error("failed to determine faction");
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
player.getClass().getNpcStats(player).setFactionReputation(factionId, value);
2012-11-13 16:11:03 +01:00
}
};
template <class R>
class OpModPCFacRep : public Interpreter::Opcode1
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2012-11-13 16:11:03 +01:00
{
MWWorld::ConstPtr ptr = R()(runtime, false);
2012-11-13 16:11:03 +01:00
Interpreter::Type_Integer value = runtime[0].mInteger;
runtime.pop();
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionId;
2012-11-13 16:11:03 +01:00
if (arg0 == 1)
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionId = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
2012-11-13 16:11:03 +01:00
runtime.pop();
}
else
{
2015-01-27 17:32:21 +01:00
factionId = getDialogueActorFaction(ptr);
2012-11-13 16:11:03 +01:00
}
if (factionId.empty())
throw std::runtime_error("failed to determine faction");
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
player.getClass().getNpcStats(player).setFactionReputation(
factionId, player.getClass().getNpcStats(player).getFactionReputation(factionId) + value);
2012-11-13 16:11:03 +01:00
}
};
template <class R>
class OpGetCommonDisease : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
runtime.push(ptr.getClass().getCreatureStats(ptr).hasCommonDisease());
}
};
template <class R>
class OpGetBlightDisease : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
runtime.push(ptr.getClass().getCreatureStats(ptr).hasBlightDisease());
}
};
2012-11-25 01:26:29 +01:00
template <class R>
class OpGetRace : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
2012-11-25 01:26:29 +01:00
{
MWWorld::ConstPtr ptr = R()(runtime);
2012-11-25 01:26:29 +01:00
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId race = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
2012-11-25 01:26:29 +01:00
runtime.pop();
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
const ESM::RefId& npcRace = ptr.get<ESM::NPC>()->mBase->mRace;
2012-11-25 01:26:29 +01:00
runtime.push(race == npcRace);
2012-11-25 01:26:29 +01:00
}
};
class OpGetWerewolfKills : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr();
runtime.push(ptr.getClass().getNpcStats(ptr).getWerewolfKills());
}
};
template <class R>
class OpPcExpelled : public Interpreter::Opcode1
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2022-09-22 21:26:05 +03:00
{
MWWorld::ConstPtr ptr = R()(runtime, false);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionID;
if (arg0 > 0)
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
runtime.pop();
}
2022-09-22 21:26:05 +03:00
else
{
2015-01-27 17:32:21 +01:00
factionID = ptr.getClass().getPrimaryFaction(ptr);
2022-09-22 21:26:05 +03:00
}
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
if (!factionID.empty())
2022-09-22 21:26:05 +03:00
{
runtime.push(player.getClass().getNpcStats(player).getExpelled(factionID));
2022-09-22 21:26:05 +03:00
}
else
{
runtime.push(0);
2022-09-22 21:26:05 +03:00
}
}
};
template <class R>
class OpPcExpell : public Interpreter::Opcode1
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2022-09-22 21:26:05 +03:00
{
MWWorld::ConstPtr ptr = R()(runtime, false);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionID;
if (arg0 > 0)
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
runtime.pop();
}
else
{
2015-01-27 17:32:21 +01:00
factionID = ptr.getClass().getPrimaryFaction(ptr);
}
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
if (!factionID.empty())
{
player.getClass().getNpcStats(player).expell(factionID);
}
2022-09-22 21:26:05 +03:00
}
};
template <class R>
class OpPcClearExpelled : public Interpreter::Opcode1
{
public:
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
2022-09-22 21:26:05 +03:00
{
MWWorld::ConstPtr ptr = R()(runtime, false);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId factionID;
if (arg0 > 0)
{
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
factionID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
runtime.pop();
}
2022-09-22 21:26:05 +03:00
else
{
2015-01-27 17:32:21 +01:00
factionID = ptr.getClass().getPrimaryFaction(ptr);
2022-09-22 21:26:05 +03:00
}
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
if (!factionID.empty())
player.getClass().getNpcStats(player).clearExpelled(factionID);
2022-09-22 21:26:05 +03:00
}
};
template <class R>
class OpRaiseRank : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
const ESM::RefId& factionID = ptr.getClass().getPrimaryFaction(ptr);
2015-01-27 17:32:21 +01:00
if (factionID.empty())
return;
2015-01-27 17:32:21 +01:00
2015-08-21 21:12:39 +12:00
MWWorld::Ptr player = MWMechanics::getPlayer();
// no-op when executed on the player
if (ptr == player)
return;
// If we already changed rank for this NPC, modify current rank in the NPC stats.
// Otherwise take rank from base NPC record, increase it and put it to NPC data.
int currentRank = ptr.getClass().getNpcStats(ptr).getFactionRank(factionID);
if (currentRank >= 0)
2023-06-14 03:38:22 +08:00
ptr.getClass().getNpcStats(ptr).setFactionRank(factionID, currentRank + 1);
2022-09-22 21:26:05 +03:00
else
{
int rank = ptr.getClass().getPrimaryFactionRank(ptr);
ptr.getClass().getNpcStats(ptr).joinFaction(factionID);
2023-06-14 03:38:22 +08:00
ptr.getClass().getNpcStats(ptr).setFactionRank(factionID, rank + 1);
}
2022-09-22 21:26:05 +03:00
}
};
template <class R>
class OpLowerRank : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
2015-01-27 17:32:21 +01:00
const ESM::RefId& factionID = ptr.getClass().getPrimaryFaction(ptr);
2015-01-27 17:32:21 +01:00
if (factionID.empty())
2022-09-22 21:26:05 +03:00
return;
MWWorld::Ptr player = MWMechanics::getPlayer();
// no-op when executed on the player
2015-08-21 21:12:39 +12:00
if (ptr == player)
2022-09-22 21:26:05 +03:00
return;
// If we already changed rank for this NPC, modify current rank in the NPC stats.
// Otherwise take rank from base NPC record, decrease it and put it to NPC data.
int currentRank = ptr.getClass().getNpcStats(ptr).getFactionRank(factionID);
if (currentRank == 0)
return;
else if (currentRank > 0)
2023-06-14 03:38:22 +08:00
ptr.getClass().getNpcStats(ptr).setFactionRank(factionID, currentRank - 1);
else
{
int rank = ptr.getClass().getPrimaryFactionRank(ptr);
ptr.getClass().getNpcStats(ptr).joinFaction(factionID);
2023-06-14 03:38:22 +08:00
ptr.getClass().getNpcStats(ptr).setFactionRank(factionID, std::max(0, rank - 1));
}
2022-09-22 21:26:05 +03:00
}
};
template <class R>
2013-03-18 11:04:47 +01:00
class OpOnDeath : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
2013-03-18 11:04:47 +01:00
{
MWWorld::Ptr ptr = R()(runtime);
2013-03-18 11:04:47 +01:00
Interpreter::Type_Integer value = ptr.getClass().getCreatureStats(ptr).hasDied();
2013-03-18 11:04:47 +01:00
if (value)
ptr.getClass().getCreatureStats(ptr).clearHasDied();
2013-03-18 11:04:47 +01:00
runtime.push(value);
}
};
template <class R>
class OpOnMurder : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value = ptr.getClass().getCreatureStats(ptr).hasBeenMurdered();
if (value)
ptr.getClass().getCreatureStats(ptr).clearHasBeenMurdered();
runtime.push(value);
}
};
2014-04-27 20:54:22 -04:00
template <class R>
class OpOnKnockout : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
2014-04-27 20:54:22 -04:00
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value = ptr.getClass().getCreatureStats(ptr).getKnockedDownOneFrame();
2014-04-27 20:54:22 -04:00
runtime.push(value);
}
};
2013-03-30 13:20:51 -07:00
template <class R>
class OpIsWerewolf : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
2013-03-30 13:20:51 -07:00
{
MWWorld::Ptr ptr = R()(runtime);
runtime.push(ptr.getClass().getNpcStats(ptr).isWerewolf());
2013-03-30 13:20:51 -07:00
}
};
template <class R, bool set>
class OpSetWerewolf : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
MWBase::Environment::get().getMechanicsManager()->setWerewolf(ptr, set);
}
};
2013-08-09 05:37:56 -07:00
template <class R>
class OpSetWerewolfAcrobatics : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
2013-08-09 05:37:56 -07:00
{
MWWorld::Ptr ptr = R()(runtime);
MWBase::Environment::get().getMechanicsManager()->applyWerewolfAcrobatics(ptr);
2013-08-09 05:37:56 -07:00
}
};
2014-01-03 15:54:23 +01:00
template <class R>
class OpResurrect : public Interpreter::Opcode0
{
public:
2022-09-05 20:21:19 +02:00
void execute(Interpreter::Runtime& runtime) override
2022-09-22 21:26:05 +03:00
{
2014-01-03 15:54:23 +01:00
MWWorld::Ptr ptr = R()(runtime);
if (ptr == MWMechanics::getPlayer())
2014-01-03 15:54:23 +01:00
{
MWBase::Environment::get().getMechanicsManager()->resurrect(ptr);
2015-08-21 21:12:39 +12:00
if (MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_Ended)
2018-07-26 19:54:08 +03:00
MWBase::Environment::get().getStateManager()->resumeGame();
2022-09-22 21:26:05 +03:00
}
2015-08-21 21:12:39 +12:00
else if (ptr.getClass().getCreatureStats(ptr).isDead())
2022-09-22 21:26:05 +03:00
{
bool wasEnabled = ptr.getRefData().isEnabled();
MWBase::Environment::get().getWorld()->undeleteObject(ptr);
2015-08-21 21:12:39 +12:00
auto windowManager = MWBase::Environment::get().getWindowManager();
bool wasOpen = windowManager->containsMode(MWGui::GM_Container);
2015-08-21 21:12:39 +12:00
windowManager->onDeleteCustomData(ptr);
// HACK: disable/enable object to re-add it to the scene properly (need a new Animation).
MWBase::Environment::get().getWorld()->disable(ptr);
// The actor's base record may have changed after this specific reference was created.
// So we need to update to the current version
if (ptr.getClass().isNpc())
updateBaseRecord<ESM::NPC>(ptr);
else
updateBaseRecord<ESM::Creature>(ptr);
if (wasOpen && !windowManager->containsMode(MWGui::GM_Container))
2018-07-26 19:54:08 +03:00
{
// Reopen the loot GUI if it was closed because we resurrected the actor we were looting
2019-09-21 20:22:45 +04:00
MWBase::Environment::get().getMechanicsManager()->resurrect(ptr);
2018-07-26 19:54:08 +03:00
windowManager->forceLootMode(ptr);
}
else
{
MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
// resets runtime state such as inventory, stats and AI. does not reset position in the world
ptr.getRefData().setCustomData(nullptr);
}
if (wasEnabled)
MWBase::Environment::get().getWorld()->enable(ptr);
2014-01-03 15:54:23 +01:00
}
2022-09-22 21:26:05 +03:00
}
2014-01-03 15:54:23 +01:00
};
template <class R>
class OpGetStat : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
// dummy
2022-04-30 16:45:45 +02:00
runtime.pop();
runtime.push(0);
}
};
template <class R>
class OpGetMagicEffect : public Interpreter::Opcode0
{
int mPositiveEffect;
int mNegativeEffect;
public:
OpGetMagicEffect(int positiveEffect, int negativeEffect)
: mPositiveEffect(positiveEffect)
, mNegativeEffect(negativeEffect)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
2015-08-20 18:17:02 +12:00
const MWMechanics::MagicEffects& effects = ptr.getClass().getCreatureStats(ptr).getMagicEffects();
2023-05-23 19:06:08 +02:00
float currentValue = effects.getOrDefault(mPositiveEffect).getMagnitude();
if (mNegativeEffect != -1)
2023-05-23 19:06:08 +02:00
currentValue -= effects.getOrDefault(mNegativeEffect).getMagnitude();
// GetResist* should take in account elemental shields
if (mPositiveEffect == ESM::MagicEffect::ResistFire)
2023-05-23 19:06:08 +02:00
currentValue += effects.getOrDefault(ESM::MagicEffect::FireShield).getMagnitude();
if (mPositiveEffect == ESM::MagicEffect::ResistShock)
2023-05-23 19:06:08 +02:00
currentValue += effects.getOrDefault(ESM::MagicEffect::LightningShield).getMagnitude();
if (mPositiveEffect == ESM::MagicEffect::ResistFrost)
2023-05-23 19:06:08 +02:00
currentValue += effects.getOrDefault(ESM::MagicEffect::FrostShield).getMagnitude();
int ret = static_cast<int>(currentValue);
runtime.push(ret);
}
};
template <class R>
class OpSetMagicEffect : public Interpreter::Opcode0
{
int mPositiveEffect;
int mNegativeEffect;
public:
OpSetMagicEffect(int positiveEffect, int negativeEffect)
: mPositiveEffect(positiveEffect)
, mNegativeEffect(negativeEffect)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
2015-08-20 18:17:02 +12:00
MWMechanics::MagicEffects& effects = ptr.getClass().getCreatureStats(ptr).getMagicEffects();
2023-05-23 19:06:08 +02:00
float currentValue = effects.getOrDefault(mPositiveEffect).getMagnitude();
if (mNegativeEffect != -1)
2023-05-23 19:06:08 +02:00
currentValue -= effects.getOrDefault(mNegativeEffect).getMagnitude();
// SetResist* should take in account elemental shields
if (mPositiveEffect == ESM::MagicEffect::ResistFire)
2023-05-23 19:06:08 +02:00
currentValue += effects.getOrDefault(ESM::MagicEffect::FireShield).getMagnitude();
if (mPositiveEffect == ESM::MagicEffect::ResistShock)
2023-05-23 19:06:08 +02:00
currentValue += effects.getOrDefault(ESM::MagicEffect::LightningShield).getMagnitude();
if (mPositiveEffect == ESM::MagicEffect::ResistFrost)
2023-05-23 19:06:08 +02:00
currentValue += effects.getOrDefault(ESM::MagicEffect::FrostShield).getMagnitude();
int arg = runtime[0].mInteger;
runtime.pop();
2015-08-20 18:17:02 +12:00
effects.modifyBase(mPositiveEffect, (arg - static_cast<int>(currentValue)));
}
};
template <class R>
class OpModMagicEffect : public Interpreter::Opcode0
{
int mPositiveEffect;
int mNegativeEffect;
public:
OpModMagicEffect(int positiveEffect, int negativeEffect)
: mPositiveEffect(positiveEffect)
, mNegativeEffect(negativeEffect)
{
}
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
int arg = runtime[0].mInteger;
runtime.pop();
stats.getMagicEffects().modifyBase(mPositiveEffect, arg);
}
};
2022-09-05 20:21:19 +02:00
class OpGetPCVisionBonus : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
MWWorld::Ptr player = MWMechanics::getPlayer();
MWMechanics::EffectParam nightEye
2023-05-23 19:06:08 +02:00
= player.getClass().getCreatureStats(player).getMagicEffects().getOrDefault(
ESM::MagicEffect::NightEye);
2022-09-05 20:21:19 +02:00
runtime.push(std::clamp(nightEye.getMagnitude() / 100.f, 0.f, 1.f));
}
};
class OpSetPCVisionBonus : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
float arg = runtime[0].mFloat;
runtime.pop();
MWWorld::Ptr player = MWMechanics::getPlayer();
auto& effects = player.getClass().getCreatureStats(player).getMagicEffects();
2023-05-23 19:06:08 +02:00
float delta = std::clamp(arg * 100.f, 0.f, 100.f)
- effects.getOrDefault(ESM::MagicEffect::NightEye).getMagnitude();
2022-09-05 20:21:19 +02:00
effects.modifyBase(ESM::MagicEffect::NightEye, static_cast<int>(delta));
}
};
class OpModPCVisionBonus : public Interpreter::Opcode0
{
public:
void execute(Interpreter::Runtime& runtime) override
{
float arg = runtime[0].mFloat;
runtime.pop();
MWWorld::Ptr player = MWMechanics::getPlayer();
auto& effects = player.getClass().getCreatureStats(player).getMagicEffects();
2023-05-23 19:06:08 +02:00
const MWMechanics::EffectParam nightEye = effects.getOrDefault(ESM::MagicEffect::NightEye);
2022-09-05 20:21:19 +02:00
float newBase = std::clamp(nightEye.getMagnitude() + arg * 100.f, 0.f, 100.f);
newBase -= nightEye.getModifier();
float delta = std::clamp(newBase, 0.f, 100.f) - nightEye.getMagnitude();
effects.modifyBase(ESM::MagicEffect::NightEye, static_cast<int>(delta));
}
};
struct MagicEffect
{
int mPositiveEffect;
int mNegativeEffect;
};
void installOpcodes(Interpreter::Interpreter& interpreter)
{
for (int i = 0; i < Compiler::Stats::numberOfAttributes; ++i)
{
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpGetAttribute<ImplicitRef>>(Compiler::Stats::opcodeGetAttribute + i, i);
interpreter.installSegment5<OpGetAttribute<ExplicitRef>>(
Compiler::Stats::opcodeGetAttributeExplicit + i, i);
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpSetAttribute<ImplicitRef>>(Compiler::Stats::opcodeSetAttribute + i, i);
interpreter.installSegment5<OpSetAttribute<ExplicitRef>>(
Compiler::Stats::opcodeSetAttributeExplicit + i, i);
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpModAttribute<ImplicitRef>>(Compiler::Stats::opcodeModAttribute + i, i);
interpreter.installSegment5<OpModAttribute<ExplicitRef>>(
Compiler::Stats::opcodeModAttributeExplicit + i, i);
}
for (int i = 0; i < Compiler::Stats::numberOfDynamics; ++i)
{
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpGetDynamic<ImplicitRef>>(Compiler::Stats::opcodeGetDynamic + i, i);
interpreter.installSegment5<OpGetDynamic<ExplicitRef>>(
Compiler::Stats::opcodeGetDynamicExplicit + i, i);
interpreter.installSegment5<OpSetDynamic<ImplicitRef>>(Compiler::Stats::opcodeSetDynamic + i, i);
interpreter.installSegment5<OpSetDynamic<ExplicitRef>>(
Compiler::Stats::opcodeSetDynamicExplicit + i, i);
interpreter.installSegment5<OpModDynamic<ImplicitRef>>(Compiler::Stats::opcodeModDynamic + i, i);
interpreter.installSegment5<OpModDynamic<ExplicitRef>>(
Compiler::Stats::opcodeModDynamicExplicit + i, i);
2022-09-22 21:26:05 +03:00
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpModCurrentDynamic<ImplicitRef>>(
Compiler::Stats::opcodeModCurrentDynamic + i, i);
interpreter.installSegment5<OpModCurrentDynamic<ExplicitRef>>(
Compiler::Stats::opcodeModCurrentDynamicExplicit + i, i);
2022-09-22 21:26:05 +03:00
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpGetDynamicGetRatio<ImplicitRef>>(
Compiler::Stats::opcodeGetDynamicGetRatio + i, i);
interpreter.installSegment5<OpGetDynamicGetRatio<ExplicitRef>>(
Compiler::Stats::opcodeGetDynamicGetRatioExplicit + i, i);
}
for (int i = 0; i < Compiler::Stats::numberOfSkills; ++i)
{
2023-06-05 21:21:30 +02:00
ESM::RefId id = ESM::Skill::indexToRefId(i);
interpreter.installSegment5<OpGetSkill<ImplicitRef>>(Compiler::Stats::opcodeGetSkill + i, id);
interpreter.installSegment5<OpGetSkill<ExplicitRef>>(Compiler::Stats::opcodeGetSkillExplicit + i, id);
2023-06-05 21:21:30 +02:00
interpreter.installSegment5<OpSetSkill<ImplicitRef>>(Compiler::Stats::opcodeSetSkill + i, id);
interpreter.installSegment5<OpSetSkill<ExplicitRef>>(Compiler::Stats::opcodeSetSkillExplicit + i, id);
2023-06-05 21:21:30 +02:00
interpreter.installSegment5<OpModSkill<ImplicitRef>>(Compiler::Stats::opcodeModSkill + i, id);
interpreter.installSegment5<OpModSkill<ExplicitRef>>(Compiler::Stats::opcodeModSkillExplicit + i, id);
}
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpGetPCCrimeLevel>(Compiler::Stats::opcodeGetPCCrimeLevel);
interpreter.installSegment5<OpSetPCCrimeLevel>(Compiler::Stats::opcodeSetPCCrimeLevel);
interpreter.installSegment5<OpModPCCrimeLevel>(Compiler::Stats::opcodeModPCCrimeLevel);
interpreter.installSegment5<OpAddSpell<ImplicitRef>>(Compiler::Stats::opcodeAddSpell);
interpreter.installSegment5<OpAddSpell<ExplicitRef>>(Compiler::Stats::opcodeAddSpellExplicit);
interpreter.installSegment5<OpRemoveSpell<ImplicitRef>>(Compiler::Stats::opcodeRemoveSpell);
interpreter.installSegment5<OpRemoveSpell<ExplicitRef>>(Compiler::Stats::opcodeRemoveSpellExplicit);
interpreter.installSegment5<OpRemoveSpellEffects<ImplicitRef>>(Compiler::Stats::opcodeRemoveSpellEffects);
interpreter.installSegment5<OpRemoveSpellEffects<ExplicitRef>>(
Compiler::Stats::opcodeRemoveSpellEffectsExplicit);
interpreter.installSegment5<OpResurrect<ImplicitRef>>(Compiler::Stats::opcodeResurrect);
interpreter.installSegment5<OpResurrect<ExplicitRef>>(Compiler::Stats::opcodeResurrectExplicit);
interpreter.installSegment5<OpRemoveEffects<ImplicitRef>>(Compiler::Stats::opcodeRemoveEffects);
interpreter.installSegment5<OpRemoveEffects<ExplicitRef>>(Compiler::Stats::opcodeRemoveEffectsExplicit);
interpreter.installSegment5<OpGetSpell<ImplicitRef>>(Compiler::Stats::opcodeGetSpell);
interpreter.installSegment5<OpGetSpell<ExplicitRef>>(Compiler::Stats::opcodeGetSpellExplicit);
interpreter.installSegment3<OpPCRaiseRank<ImplicitRef>>(Compiler::Stats::opcodePCRaiseRank);
interpreter.installSegment3<OpPCLowerRank<ImplicitRef>>(Compiler::Stats::opcodePCLowerRank);
interpreter.installSegment3<OpPCJoinFaction<ImplicitRef>>(Compiler::Stats::opcodePCJoinFaction);
interpreter.installSegment3<OpPCRaiseRank<ExplicitRef>>(Compiler::Stats::opcodePCRaiseRankExplicit);
interpreter.installSegment3<OpPCLowerRank<ExplicitRef>>(Compiler::Stats::opcodePCLowerRankExplicit);
interpreter.installSegment3<OpPCJoinFaction<ExplicitRef>>(Compiler::Stats::opcodePCJoinFactionExplicit);
interpreter.installSegment3<OpGetPCRank<ImplicitRef>>(Compiler::Stats::opcodeGetPCRank);
interpreter.installSegment3<OpGetPCRank<ExplicitRef>>(Compiler::Stats::opcodeGetPCRankExplicit);
interpreter.installSegment5<OpModDisposition<ImplicitRef>>(Compiler::Stats::opcodeModDisposition);
interpreter.installSegment5<OpModDisposition<ExplicitRef>>(Compiler::Stats::opcodeModDispositionExplicit);
interpreter.installSegment5<OpSetDisposition<ImplicitRef>>(Compiler::Stats::opcodeSetDisposition);
interpreter.installSegment5<OpSetDisposition<ExplicitRef>>(Compiler::Stats::opcodeSetDispositionExplicit);
interpreter.installSegment5<OpGetDisposition<ImplicitRef>>(Compiler::Stats::opcodeGetDisposition);
interpreter.installSegment5<OpGetDisposition<ExplicitRef>>(Compiler::Stats::opcodeGetDispositionExplicit);
interpreter.installSegment5<OpGetLevel<ImplicitRef>>(Compiler::Stats::opcodeGetLevel);
interpreter.installSegment5<OpGetLevel<ExplicitRef>>(Compiler::Stats::opcodeGetLevelExplicit);
interpreter.installSegment5<OpSetLevel<ImplicitRef>>(Compiler::Stats::opcodeSetLevel);
interpreter.installSegment5<OpSetLevel<ExplicitRef>>(Compiler::Stats::opcodeSetLevelExplicit);
interpreter.installSegment5<OpGetDeadCount>(Compiler::Stats::opcodeGetDeadCount);
interpreter.installSegment3<OpGetPCFacRep<ImplicitRef>>(Compiler::Stats::opcodeGetPCFacRep);
interpreter.installSegment3<OpGetPCFacRep<ExplicitRef>>(Compiler::Stats::opcodeGetPCFacRepExplicit);
interpreter.installSegment3<OpSetPCFacRep<ImplicitRef>>(Compiler::Stats::opcodeSetPCFacRep);
interpreter.installSegment3<OpSetPCFacRep<ExplicitRef>>(Compiler::Stats::opcodeSetPCFacRepExplicit);
interpreter.installSegment3<OpModPCFacRep<ImplicitRef>>(Compiler::Stats::opcodeModPCFacRep);
interpreter.installSegment3<OpModPCFacRep<ExplicitRef>>(Compiler::Stats::opcodeModPCFacRepExplicit);
interpreter.installSegment5<OpGetCommonDisease<ImplicitRef>>(Compiler::Stats::opcodeGetCommonDisease);
interpreter.installSegment5<OpGetCommonDisease<ExplicitRef>>(
Compiler::Stats::opcodeGetCommonDiseaseExplicit);
interpreter.installSegment5<OpGetBlightDisease<ImplicitRef>>(Compiler::Stats::opcodeGetBlightDisease);
interpreter.installSegment5<OpGetBlightDisease<ExplicitRef>>(
Compiler::Stats::opcodeGetBlightDiseaseExplicit);
interpreter.installSegment5<OpGetRace<ImplicitRef>>(Compiler::Stats::opcodeGetRace);
interpreter.installSegment5<OpGetRace<ExplicitRef>>(Compiler::Stats::opcodeGetRaceExplicit);
interpreter.installSegment5<OpGetWerewolfKills>(Compiler::Stats::opcodeGetWerewolfKills);
interpreter.installSegment3<OpPcExpelled<ImplicitRef>>(Compiler::Stats::opcodePcExpelled);
interpreter.installSegment3<OpPcExpelled<ExplicitRef>>(Compiler::Stats::opcodePcExpelledExplicit);
interpreter.installSegment3<OpPcExpell<ImplicitRef>>(Compiler::Stats::opcodePcExpell);
interpreter.installSegment3<OpPcExpell<ExplicitRef>>(Compiler::Stats::opcodePcExpellExplicit);
interpreter.installSegment3<OpPcClearExpelled<ImplicitRef>>(Compiler::Stats::opcodePcClearExpelled);
interpreter.installSegment3<OpPcClearExpelled<ExplicitRef>>(Compiler::Stats::opcodePcClearExpelledExplicit);
interpreter.installSegment5<OpRaiseRank<ImplicitRef>>(Compiler::Stats::opcodeRaiseRank);
interpreter.installSegment5<OpRaiseRank<ExplicitRef>>(Compiler::Stats::opcodeRaiseRankExplicit);
interpreter.installSegment5<OpLowerRank<ImplicitRef>>(Compiler::Stats::opcodeLowerRank);
interpreter.installSegment5<OpLowerRank<ExplicitRef>>(Compiler::Stats::opcodeLowerRankExplicit);
interpreter.installSegment5<OpOnDeath<ImplicitRef>>(Compiler::Stats::opcodeOnDeath);
interpreter.installSegment5<OpOnDeath<ExplicitRef>>(Compiler::Stats::opcodeOnDeathExplicit);
interpreter.installSegment5<OpOnMurder<ImplicitRef>>(Compiler::Stats::opcodeOnMurder);
interpreter.installSegment5<OpOnMurder<ExplicitRef>>(Compiler::Stats::opcodeOnMurderExplicit);
interpreter.installSegment5<OpOnKnockout<ImplicitRef>>(Compiler::Stats::opcodeOnKnockout);
interpreter.installSegment5<OpOnKnockout<ExplicitRef>>(Compiler::Stats::opcodeOnKnockoutExplicit);
interpreter.installSegment5<OpIsWerewolf<ImplicitRef>>(Compiler::Stats::opcodeIsWerewolf);
interpreter.installSegment5<OpIsWerewolf<ExplicitRef>>(Compiler::Stats::opcodeIsWerewolfExplicit);
interpreter.installSegment5<OpSetWerewolf<ImplicitRef, true>>(Compiler::Stats::opcodeBecomeWerewolf);
interpreter.installSegment5<OpSetWerewolf<ExplicitRef, true>>(
Compiler::Stats::opcodeBecomeWerewolfExplicit);
interpreter.installSegment5<OpSetWerewolf<ImplicitRef, false>>(Compiler::Stats::opcodeUndoWerewolf);
interpreter.installSegment5<OpSetWerewolf<ExplicitRef, false>>(Compiler::Stats::opcodeUndoWerewolfExplicit);
interpreter.installSegment5<OpSetWerewolfAcrobatics<ImplicitRef>>(
Compiler::Stats::opcodeSetWerewolfAcrobatics);
interpreter.installSegment5<OpSetWerewolfAcrobatics<ExplicitRef>>(
Compiler::Stats::opcodeSetWerewolfAcrobaticsExplicit);
interpreter.installSegment5<OpGetStat<ImplicitRef>>(Compiler::Stats::opcodeGetStat);
interpreter.installSegment5<OpGetStat<ExplicitRef>>(Compiler::Stats::opcodeGetStatExplicit);
static const MagicEffect sMagicEffects[] = {
{ ESM::MagicEffect::ResistMagicka, ESM::MagicEffect::WeaknessToMagicka },
{ ESM::MagicEffect::ResistFire, ESM::MagicEffect::WeaknessToFire },
{ ESM::MagicEffect::ResistFrost, ESM::MagicEffect::WeaknessToFrost },
{ ESM::MagicEffect::ResistShock, ESM::MagicEffect::WeaknessToShock },
{ ESM::MagicEffect::ResistCommonDisease, ESM::MagicEffect::WeaknessToCommonDisease },
{ ESM::MagicEffect::ResistBlightDisease, ESM::MagicEffect::WeaknessToBlightDisease },
{ ESM::MagicEffect::ResistCorprusDisease, ESM::MagicEffect::WeaknessToCorprusDisease },
{ ESM::MagicEffect::ResistPoison, ESM::MagicEffect::WeaknessToPoison },
{ ESM::MagicEffect::ResistParalysis, -1 },
{ ESM::MagicEffect::ResistNormalWeapons, ESM::MagicEffect::WeaknessToNormalWeapons },
{ ESM::MagicEffect::WaterBreathing, -1 },
{ ESM::MagicEffect::Chameleon, -1 },
{ ESM::MagicEffect::WaterWalking, -1 },
{ ESM::MagicEffect::SwiftSwim, -1 },
{ ESM::MagicEffect::Jump, -1 },
{ ESM::MagicEffect::Levitate, -1 },
{ ESM::MagicEffect::Shield, -1 },
{ ESM::MagicEffect::Sound, -1 },
{ ESM::MagicEffect::Silence, -1 },
{ ESM::MagicEffect::Blind, -1 },
{ ESM::MagicEffect::Paralyze, -1 },
{ ESM::MagicEffect::Invisibility, -1 },
{ ESM::MagicEffect::FortifyAttack, -1 },
{ ESM::MagicEffect::Sanctuary, -1 },
};
for (int i = 0; i < 24; ++i)
{
int positive = sMagicEffects[i].mPositiveEffect;
int negative = sMagicEffects[i].mNegativeEffect;
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpGetMagicEffect<ImplicitRef>>(
Compiler::Stats::opcodeGetMagicEffect + i, positive, negative);
interpreter.installSegment5<OpGetMagicEffect<ExplicitRef>>(
Compiler::Stats::opcodeGetMagicEffectExplicit + i, positive, negative);
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpSetMagicEffect<ImplicitRef>>(
Compiler::Stats::opcodeSetMagicEffect + i, positive, negative);
interpreter.installSegment5<OpSetMagicEffect<ExplicitRef>>(
Compiler::Stats::opcodeSetMagicEffectExplicit + i, positive, negative);
2022-01-27 19:18:57 +00:00
interpreter.installSegment5<OpModMagicEffect<ImplicitRef>>(
Compiler::Stats::opcodeModMagicEffect + i, positive, negative);
interpreter.installSegment5<OpModMagicEffect<ExplicitRef>>(
Compiler::Stats::opcodeModMagicEffectExplicit + i, positive, negative);
}
2022-09-05 20:21:19 +02:00
interpreter.installSegment5<OpGetPCVisionBonus>(Compiler::Stats::opcodeGetPCVisionBonus);
interpreter.installSegment5<OpSetPCVisionBonus>(Compiler::Stats::opcodeSetPCVisionBonus);
interpreter.installSegment5<OpModPCVisionBonus>(Compiler::Stats::opcodeModPCVisionBonus);
}
}
}