2010-08-22 14:49:25 +02:00
|
|
|
#include "aiextensions.hpp"
|
|
|
|
|
2015-12-06 23:40:03 +01:00
|
|
|
#include <stdexcept>
|
2018-08-14 23:05:43 +04:00
|
|
|
|
|
|
|
#include <components/debug/debuglog.hpp>
|
2015-12-06 23:40:03 +01:00
|
|
|
|
2010-08-22 14:49:25 +02:00
|
|
|
#include <components/compiler/extensions.hpp>
|
2013-08-06 20:38:41 -04:00
|
|
|
#include <components/compiler/opcodes.hpp>
|
2010-08-22 14:49:25 +02:00
|
|
|
|
|
|
|
#include <components/interpreter/interpreter.hpp>
|
|
|
|
#include <components/interpreter/opcodes.hpp>
|
|
|
|
#include <components/interpreter/runtime.hpp>
|
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
#include "../mwworld/class.hpp"
|
2015-12-06 23:40:03 +01:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
2012-11-30 02:16:16 +02:00
|
|
|
#include "../mwmechanics/aiactivate.hpp"
|
|
|
|
#include "../mwmechanics/aiescort.hpp"
|
2016-07-09 02:16:47 +02:00
|
|
|
#include "../mwmechanics/aiface.hpp"
|
2012-11-30 02:16:16 +02:00
|
|
|
#include "../mwmechanics/aifollow.hpp"
|
|
|
|
#include "../mwmechanics/aitravel.hpp"
|
|
|
|
#include "../mwmechanics/aiwander.hpp"
|
2016-07-09 02:16:47 +02:00
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
2012-06-16 16:31:32 +02:00
|
|
|
|
2013-09-10 16:16:13 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2015-12-06 23:40:03 +01:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2020-01-19 14:54:50 +03:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
2013-09-10 16:16:13 +02:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2010-08-22 14:49:25 +02:00
|
|
|
#include "interpretercontext.hpp"
|
2010-12-31 19:09:25 +01:00
|
|
|
#include "ref.hpp"
|
2010-08-22 14:49:25 +02:00
|
|
|
|
|
|
|
namespace MWScript
|
|
|
|
{
|
|
|
|
namespace Ai
|
|
|
|
{
|
2013-01-03 02:34:31 +01:00
|
|
|
template <class R>
|
|
|
|
class OpAiActivate : public Interpreter::Opcode1
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-01-03 02:34:31 +01:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2012-11-30 02:16:16 +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 objectID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2013-01-03 02:34:31 +01:00
|
|
|
runtime.pop();
|
2012-11-30 02:16:16 +02:00
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
// The value of the reset argument doesn't actually matter
|
2021-11-16 22:04:04 +01:00
|
|
|
bool repeat = arg0;
|
2022-05-21 01:21:55 +02:00
|
|
|
for (unsigned int i = 0; i < arg0; ++i)
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!ptr.getClass().isActor() || ptr == MWMechanics::getPlayer())
|
|
|
|
return;
|
|
|
|
|
2021-11-16 22:04:04 +01:00
|
|
|
MWMechanics::AiActivate activatePackage(objectID, repeat);
|
2014-05-22 20:37:22 +02:00
|
|
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(activatePackage, ptr);
|
2018-08-14 23:05:43 +04:00
|
|
|
Log(Debug::Info) << "AiActivate";
|
2013-01-03 02:34:31 +01:00
|
|
|
}
|
|
|
|
};
|
2012-11-30 02:16:16 +02:00
|
|
|
|
2010-12-31 19:09:25 +01:00
|
|
|
template <class R>
|
2010-08-22 14:49:25 +02:00
|
|
|
class OpAiTravel : public Interpreter::Opcode1
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2010-12-31 19:09:25 +01:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2010-08-22 14:49:25 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
Interpreter::Type_Float x = runtime[0].mFloat;
|
2010-12-31 19:09:25 +01:00
|
|
|
runtime.pop();
|
2010-08-22 14:49:25 +02:00
|
|
|
|
2011-11-21 14:16:20 +01:00
|
|
|
Interpreter::Type_Float y = runtime[0].mFloat;
|
2010-08-22 14:49:25 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2011-11-21 14:16:20 +01:00
|
|
|
Interpreter::Type_Float z = runtime[0].mFloat;
|
2010-08-22 14:49:25 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2011-11-21 14:16:20 +01:00
|
|
|
// The value of the reset argument doesn't actually matter
|
|
|
|
bool repeat = arg0;
|
|
|
|
for (unsigned int i = 0; i < arg0; ++i)
|
2010-08-22 14:49:25 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!ptr.getClass().isActor() || ptr == MWMechanics::getPlayer())
|
|
|
|
return;
|
|
|
|
|
2021-11-16 22:04:04 +01:00
|
|
|
MWMechanics::AiTravel travelPackage(x, y, z, repeat);
|
2014-05-22 20:37:22 +02:00
|
|
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(travelPackage, ptr);
|
2012-11-30 02:16:16 +02:00
|
|
|
|
2018-08-14 23:05:43 +04:00
|
|
|
Log(Debug::Info) << "AiTravel: " << x << ", " << y << ", " << z;
|
2010-08-22 14:49:25 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-12-31 19:09:25 +01:00
|
|
|
template <class R>
|
2010-08-22 14:49:25 +02:00
|
|
|
class OpAiEscort : public Interpreter::Opcode1
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2010-12-31 19:09:25 +01:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2010-08-22 14:49:25 +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 actorID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2010-12-31 19:09:25 +01:00
|
|
|
runtime.pop();
|
2010-08-22 14:49:25 +02:00
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
Interpreter::Type_Float duration = runtime[0].mFloat;
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float x = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float y = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float z = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
// The value of the reset argument doesn't actually matter
|
|
|
|
bool repeat = arg0;
|
|
|
|
for (unsigned int i = 0; i < arg0; ++i)
|
|
|
|
runtime.pop();
|
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!ptr.getClass().isActor() || ptr == MWMechanics::getPlayer())
|
|
|
|
return;
|
|
|
|
|
2021-11-16 22:04:04 +01:00
|
|
|
MWMechanics::AiEscort escortPackage(actorID, static_cast<int>(duration), x, y, z, repeat);
|
2014-05-22 20:37:22 +02:00
|
|
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(escortPackage, ptr);
|
2012-11-30 02:16:16 +02:00
|
|
|
|
2018-08-14 23:05:43 +04:00
|
|
|
Log(Debug::Info) << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration;
|
2012-11-30 02:16:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R>
|
|
|
|
class OpAiEscortCell : public Interpreter::Opcode1
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-11-30 02:16:16 +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 actorID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2023-01-19 17:31:45 +01:00
|
|
|
std::string_view cellID = runtime.getStringLiteral(runtime[0].mInteger);
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
Interpreter::Type_Float duration = runtime[0].mFloat;
|
2010-08-22 14:49:25 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2011-11-21 14:16:20 +01:00
|
|
|
Interpreter::Type_Float x = runtime[0].mFloat;
|
2010-08-22 14:49:25 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2011-11-21 14:16:20 +01:00
|
|
|
Interpreter::Type_Float y = runtime[0].mFloat;
|
2010-08-22 14:49:25 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2011-11-21 14:16:20 +01:00
|
|
|
Interpreter::Type_Float z = runtime[0].mFloat;
|
2010-08-22 14:49:25 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2011-11-21 14:16:20 +01:00
|
|
|
// The value of the reset argument doesn't actually matter
|
|
|
|
bool repeat = arg0;
|
|
|
|
for (unsigned int i = 0; i < arg0; ++i)
|
2010-08-22 14:49:25 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!ptr.getClass().isActor() || ptr == MWMechanics::getPlayer())
|
|
|
|
return;
|
|
|
|
|
2015-12-06 23:40:03 +01:00
|
|
|
if (cellID.empty())
|
2021-11-20 02:59:57 +03:00
|
|
|
return;
|
2015-12-06 23:40:03 +01:00
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
if (!MWBase::Environment::get().getESMStore()->get<ESM::Cell>().search(cellID))
|
2021-11-20 02:59:57 +03:00
|
|
|
return;
|
2015-12-06 23:40:03 +01:00
|
|
|
|
2021-11-16 22:04:04 +01:00
|
|
|
MWMechanics::AiEscort escortPackage(actorID, cellID, static_cast<int>(duration), x, y, z, repeat);
|
2014-05-22 20:37:22 +02:00
|
|
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(escortPackage, ptr);
|
2012-11-30 02:16:16 +02:00
|
|
|
|
2018-08-14 23:05:43 +04:00
|
|
|
Log(Debug::Info) << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration;
|
2010-08-22 14:49:25 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-12-31 19:09:25 +01:00
|
|
|
template <class R>
|
2010-08-22 14:49:25 +02:00
|
|
|
class OpGetAiPackageDone : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2010-08-22 14:49:25 +02:00
|
|
|
{
|
2010-12-31 19:09:25 +01:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2010-08-22 14:49:25 +02:00
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
bool done = false;
|
|
|
|
if (ptr.getClass().isActor())
|
|
|
|
done = ptr.getClass().getCreatureStats(ptr).getAiSequence().isPackageDone();
|
2010-08-22 14:49:25 +02:00
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
runtime.push(done);
|
2010-08-22 14:49:25 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-06-16 16:06:15 +02:00
|
|
|
template <class R>
|
|
|
|
class OpAiWander : public Interpreter::Opcode1
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-06-16 16:06:15 +02:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
Interpreter::Type_Integer range = static_cast<Interpreter::Type_Integer>(runtime[0].mFloat);
|
2012-06-16 16:06:15 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2015-03-08 13:07:29 +13:00
|
|
|
Interpreter::Type_Integer duration = static_cast<Interpreter::Type_Integer>(runtime[0].mFloat);
|
2012-06-16 16:06:15 +02:00
|
|
|
runtime.pop();
|
2010-08-22 14:49:25 +02:00
|
|
|
|
2015-03-08 13:07:29 +13:00
|
|
|
Interpreter::Type_Integer time = static_cast<Interpreter::Type_Integer>(runtime[0].mFloat);
|
2012-06-16 16:06:15 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2015-03-08 13:07:29 +13:00
|
|
|
// Chance for Idle is unused
|
2018-06-16 22:11:10 +04:00
|
|
|
if (arg0)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2015-03-08 13:07:29 +13:00
|
|
|
--arg0;
|
2012-06-16 16:06:15 +02:00
|
|
|
runtime.pop();
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2012-06-16 16:06:15 +02:00
|
|
|
|
2014-06-12 23:27:04 +02:00
|
|
|
std::vector<unsigned char> idleList;
|
2013-05-24 04:49:20 -07:00
|
|
|
bool repeat = false;
|
2013-01-15 12:40:44 +01:00
|
|
|
|
2018-06-16 22:11:10 +04:00
|
|
|
// Chances for Idle2-Idle9
|
|
|
|
for (int i = 2; i <= 9 && arg0; ++i)
|
2013-01-15 12:40:44 +01:00
|
|
|
{
|
2013-05-24 04:49:20 -07:00
|
|
|
if (!repeat)
|
|
|
|
repeat = true;
|
2021-11-06 07:30:28 +03:00
|
|
|
Interpreter::Type_Integer idleValue = std::clamp(runtime[0].mInteger, 0, 255);
|
2013-01-03 02:34:31 +01:00
|
|
|
idleList.push_back(idleValue);
|
|
|
|
runtime.pop();
|
2013-01-15 12:40:44 +01:00
|
|
|
--arg0;
|
2012-11-30 02:16:16 +02:00
|
|
|
}
|
|
|
|
|
2013-05-24 04:49:20 -07:00
|
|
|
if (arg0)
|
|
|
|
{
|
2013-05-24 15:03:46 +02:00
|
|
|
repeat = runtime[0].mInteger != 0;
|
2013-05-24 04:49:20 -07:00
|
|
|
runtime.pop();
|
|
|
|
--arg0;
|
|
|
|
}
|
|
|
|
|
2021-11-16 22:04:04 +01:00
|
|
|
// discard additional arguments, because we have no idea what they mean.
|
2012-06-16 16:06:15 +02:00
|
|
|
for (unsigned int i = 0; i < arg0; ++i)
|
|
|
|
runtime.pop();
|
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!ptr.getClass().isActor() || ptr == MWMechanics::getPlayer())
|
|
|
|
return;
|
|
|
|
|
2013-05-24 04:49:20 -07:00
|
|
|
MWMechanics::AiWander wanderPackage(range, duration, time, idleList, repeat);
|
2014-05-22 20:37:22 +02:00
|
|
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(wanderPackage, ptr);
|
2012-06-16 16:06:15 +02:00
|
|
|
}
|
|
|
|
};
|
2010-08-22 14:49:25 +02:00
|
|
|
|
2012-06-16 16:31:32 +02:00
|
|
|
template <class R>
|
2012-11-23 21:14:32 +01:00
|
|
|
class OpGetAiSetting : public Interpreter::Opcode0
|
2012-06-16 16:31:32 +02:00
|
|
|
{
|
2022-07-16 16:37:31 +02:00
|
|
|
MWMechanics::AiSetting mIndex;
|
2012-06-16 16:31:32 +02:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
OpGetAiSetting(MWMechanics::AiSetting index)
|
|
|
|
: mIndex(index)
|
2012-06-16 16:31:32 +02:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2012-06-16 16:31:32 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-06-16 16:31:32 +02:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
Interpreter::Type_Integer value = 0;
|
|
|
|
if (ptr.getClass().isActor())
|
|
|
|
value = ptr.getClass().getCreatureStats(ptr).getAiSetting(mIndex).getModified(false);
|
|
|
|
runtime.push(value);
|
2012-06-16 16:31:32 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
template <class R>
|
2012-11-23 21:14:32 +01:00
|
|
|
class OpModAiSetting : public Interpreter::Opcode0
|
2012-06-16 16:31:32 +02:00
|
|
|
{
|
2022-07-16 16:37:31 +02:00
|
|
|
MWMechanics::AiSetting mIndex;
|
2012-06-16 16:31:32 +02:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
OpModAiSetting(MWMechanics::AiSetting index)
|
2012-06-16 16:31:32 +02:00
|
|
|
: mIndex(index)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
|
|
|
}
|
2012-06-16 16:31:32 +02:00
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2021-11-20 02:59:57 +03:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
2012-06-16 16:31:32 +02:00
|
|
|
runtime.pop();
|
2021-11-20 02:59:57 +03:00
|
|
|
|
2020-06-02 21:59:37 +02:00
|
|
|
if (!ptr.getClass().isActor())
|
|
|
|
return;
|
|
|
|
|
|
|
|
int modified = ptr.getClass().getCreatureStats(ptr).getAiSetting(mIndex).getBase() + value;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-06-02 21:59:37 +02:00
|
|
|
ptr.getClass().getCreatureStats(ptr).setAiSetting(mIndex, modified);
|
|
|
|
ptr.getClass().setBaseAISetting(ptr.getCellRef().getRefId(), mIndex, modified);
|
2012-06-16 16:31:32 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
template <class R>
|
2012-11-23 21:14:32 +01:00
|
|
|
class OpSetAiSetting : public Interpreter::Opcode0
|
2012-06-16 16:31:32 +02:00
|
|
|
{
|
2022-07-16 16:37:31 +02:00
|
|
|
MWMechanics::AiSetting mIndex;
|
2012-06-16 16:31:32 +02:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
public:
|
2022-07-16 16:37:31 +02:00
|
|
|
OpSetAiSetting(MWMechanics::AiSetting index)
|
|
|
|
: mIndex(index)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-11-30 02:16:16 +02:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
2020-10-16 22:18:54 +04:00
|
|
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
2020-10-16 22:18:54 +04:00
|
|
|
if (ptr.getClass().isActor())
|
2012-06-16 16:31:32 +02:00
|
|
|
{
|
2021-02-13 20:54:31 +01:00
|
|
|
ptr.getClass().getCreatureStats(ptr).setAiSetting(mIndex, value);
|
|
|
|
ptr.getClass().setBaseAISetting(ptr.getCellRef().getRefId(), mIndex, value);
|
2012-06-16 16:31:32 +02:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2012-06-16 16:31:32 +02:00
|
|
|
};
|
|
|
|
|
2012-11-30 02:16:16 +02:00
|
|
|
template <class R>
|
|
|
|
class OpAiFollow : public Interpreter::Opcode1
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-11-30 02:16:16 +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 actorID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
Interpreter::Type_Float duration = runtime[0].mFloat;
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float x = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float y = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float z = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
// The value of the reset argument doesn't actually matter
|
|
|
|
bool repeat = arg0;
|
|
|
|
for (unsigned int i = 0; i < arg0; ++i)
|
|
|
|
runtime.pop();
|
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!ptr.getClass().isActor() || ptr == MWMechanics::getPlayer())
|
|
|
|
return;
|
|
|
|
|
2021-11-16 22:04:04 +01:00
|
|
|
MWMechanics::AiFollow followPackage(actorID, duration, x, y, z, repeat);
|
2014-05-22 20:37:22 +02:00
|
|
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(followPackage, ptr);
|
2012-11-30 02:16:16 +02:00
|
|
|
|
2023-03-06 22:19:29 +01:00
|
|
|
Log(Debug::Info) << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration;
|
2012-11-30 02:16:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R>
|
|
|
|
class OpAiFollowCell : public Interpreter::Opcode1
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime, unsigned int arg0) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-11-30 02:16:16 +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 actorID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2023-01-19 17:31:45 +01:00
|
|
|
std::string_view cellID = runtime.getStringLiteral(runtime[0].mInteger);
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
Interpreter::Type_Float duration = runtime[0].mFloat;
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float x = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float y = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float z = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
// The value of the reset argument doesn't actually matter
|
|
|
|
bool repeat = arg0;
|
|
|
|
for (unsigned int i = 0; i < arg0; ++i)
|
|
|
|
runtime.pop();
|
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!ptr.getClass().isActor() || ptr == MWMechanics::getPlayer())
|
|
|
|
return;
|
|
|
|
|
2021-11-16 22:04:04 +01:00
|
|
|
MWMechanics::AiFollow followPackage(actorID, cellID, duration, x, y, z, repeat);
|
2014-05-22 20:37:22 +02:00
|
|
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(followPackage, ptr);
|
2023-03-06 22:19:29 +01:00
|
|
|
Log(Debug::Info) << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration;
|
2012-11-30 02:16:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R>
|
|
|
|
class OpGetCurrentAIPackage : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-11-30 02:16:16 +02:00
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
Interpreter::Type_Integer value = -1;
|
|
|
|
if (ptr.getClass().isActor())
|
2012-11-30 02:16:16 +02:00
|
|
|
{
|
2021-09-16 16:56:13 +02:00
|
|
|
const auto& stats = ptr.getClass().getCreatureStats(ptr);
|
|
|
|
if (!stats.isDead() || !stats.isDeathAnimationFinished())
|
|
|
|
{
|
|
|
|
value = static_cast<Interpreter::Type_Integer>(stats.getAiSequence().getLastRunTypeId());
|
|
|
|
}
|
2012-11-30 02:16:16 +02:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.push(value);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2012-11-30 02:16:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class R>
|
2014-01-07 00:51:09 +01:00
|
|
|
class OpGetDetected : public Interpreter::Opcode0
|
2012-11-30 02:16:16 +02:00
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2012-11-30 02:16:16 +02:00
|
|
|
{
|
2017-09-18 21:46:57 +04:00
|
|
|
MWWorld::Ptr observer = R()(runtime, false); // required=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 actorID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2012-11-30 02:16:16 +02:00
|
|
|
runtime.pop();
|
|
|
|
|
2019-12-01 14:00:24 +03:00
|
|
|
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->searchPtr(actorID, true, false);
|
2012-11-30 02:16:16 +02:00
|
|
|
|
2019-12-01 14:00:24 +03:00
|
|
|
Interpreter::Type_Integer value = 0;
|
|
|
|
if (!actor.isEmpty())
|
|
|
|
value = MWBase::Environment::get().getMechanicsManager()->isActorDetected(actor, observer);
|
2012-11-30 02:16:16 +02:00
|
|
|
|
|
|
|
runtime.push(value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-10 16:16:13 +02:00
|
|
|
template <class R>
|
|
|
|
class OpGetLineOfSight : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2013-09-10 16:16:13 +02:00
|
|
|
{
|
|
|
|
|
2022-05-21 01:21:55 +02:00
|
|
|
MWWorld::Ptr source = R()(runtime);
|
2013-09-10 16:16:13 +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 actorID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2013-09-10 16:16:13 +02:00
|
|
|
runtime.pop();
|
2014-06-19 04:53:25 +02:00
|
|
|
|
2019-12-01 14:00:24 +03:00
|
|
|
MWWorld::Ptr dest = MWBase::Environment::get().getWorld()->searchPtr(actorID, true, false);
|
2013-09-10 16:16:13 +02:00
|
|
|
bool value = false;
|
2019-12-01 14:00:24 +03:00
|
|
|
if (!dest.isEmpty() && source.getClass().isActor() && dest.getClass().isActor())
|
2013-09-10 16:16:13 +02:00
|
|
|
{
|
|
|
|
value = MWBase::Environment::get().getWorld()->getLOS(source, dest);
|
|
|
|
}
|
|
|
|
runtime.push(value);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-09-10 16:16:13 +02:00
|
|
|
};
|
2012-06-16 16:31:32 +02:00
|
|
|
|
2014-01-07 04:12:37 +04:00
|
|
|
template <class R>
|
|
|
|
class OpGetTarget : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2014-01-07 04:12:37 +04:00
|
|
|
{
|
|
|
|
MWWorld::Ptr actor = 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 testedTargetId = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2014-01-07 04:12:37 +04:00
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
bool targetsAreEqual = false;
|
2021-11-20 02:59:57 +03:00
|
|
|
if (actor.getClass().isActor())
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2021-11-20 02:59:57 +03:00
|
|
|
const MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
|
|
|
MWWorld::Ptr targetPtr;
|
|
|
|
if (creatureStats.getAiSequence().getCombatTarget(targetPtr))
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!targetPtr.isEmpty() && targetPtr.getCellRef().getRefId() == testedTargetId)
|
|
|
|
targetsAreEqual = true;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2022-10-18 09:26:55 +02:00
|
|
|
else if (testedTargetId == "Player") // Currently the player ID is hardcoded
|
2014-01-07 04:12:37 +04:00
|
|
|
{
|
2021-11-20 02:59:57 +03:00
|
|
|
MWBase::MechanicsManager* mechMgr = MWBase::Environment::get().getMechanicsManager();
|
|
|
|
bool greeting = mechMgr->getGreetingState(actor) == MWMechanics::Greet_InProgress;
|
|
|
|
bool sayActive = MWBase::Environment::get().getSoundManager()->sayActive(actor);
|
|
|
|
targetsAreEqual = (greeting && sayActive) || mechMgr->isTurningToPlayer(actor);
|
2020-01-19 14:54:50 +03:00
|
|
|
}
|
2014-01-07 04:12:37 +04:00
|
|
|
}
|
2021-11-20 02:59:57 +03:00
|
|
|
runtime.push(targetsAreEqual);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2014-01-07 04:12:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class R>
|
|
|
|
class OpStartCombat : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2014-01-07 04:12:37 +04:00
|
|
|
{
|
|
|
|
MWWorld::Ptr actor = 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 targetID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger));
|
2014-01-07 04:12:37 +04:00
|
|
|
runtime.pop();
|
|
|
|
|
2019-12-01 14:00:24 +03:00
|
|
|
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(targetID, true, false);
|
2024-01-29 22:08:00 +01:00
|
|
|
if (!target.isEmpty() && !target.getBase()->isDeleted()
|
|
|
|
&& !target.getClass().getCreatureStats(target).isDead())
|
2024-01-25 19:36:41 +01:00
|
|
|
MWBase::Environment::get().getMechanicsManager()->startCombat(actor, target, nullptr);
|
2014-01-07 04:12:37 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R>
|
|
|
|
class OpStopCombat : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2014-01-07 04:12:37 +04:00
|
|
|
{
|
|
|
|
MWWorld::Ptr actor = R()(runtime);
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!actor.getClass().isActor())
|
|
|
|
return;
|
2021-11-25 22:00:52 +01:00
|
|
|
MWBase::Environment::get().getMechanicsManager()->stopCombat(actor);
|
2014-01-07 04:12:37 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-11-18 23:03:44 +01:00
|
|
|
class OpToggleAI : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2013-11-18 23:03:44 +01:00
|
|
|
{
|
2014-03-26 19:55:52 +01:00
|
|
|
bool enabled = MWBase::Environment::get().getMechanicsManager()->toggleAI();
|
|
|
|
|
2015-03-03 23:46:53 +01:00
|
|
|
runtime.getContext().report(enabled ? "AI -> On" : "AI -> Off");
|
2013-11-18 23:03:44 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-06-24 15:09:13 +02:00
|
|
|
template <class R>
|
|
|
|
class OpFace : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2020-10-16 22:18:54 +04:00
|
|
|
void execute(Interpreter::Runtime& runtime) override
|
2014-06-24 15:09:13 +02:00
|
|
|
{
|
2016-07-09 02:16:47 +02:00
|
|
|
MWWorld::Ptr actor = R()(runtime);
|
|
|
|
|
|
|
|
Interpreter::Type_Float x = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
Interpreter::Type_Float y = runtime[0].mFloat;
|
|
|
|
runtime.pop();
|
|
|
|
|
2021-11-20 02:59:57 +03:00
|
|
|
if (!actor.getClass().isActor() || actor == MWMechanics::getPlayer())
|
|
|
|
return;
|
|
|
|
|
2016-07-09 02:16:47 +02:00
|
|
|
MWMechanics::AiFace facePackage(x, y);
|
|
|
|
actor.getClass().getCreatureStats(actor).getAiSequence().stack(facePackage, actor);
|
2014-06-24 15:09:13 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-01-27 19:18:57 +00:00
|
|
|
void installOpcodes(Interpreter::Interpreter& interpreter)
|
2010-08-22 14:49:25 +02:00
|
|
|
{
|
2022-01-27 19:18:57 +00:00
|
|
|
interpreter.installSegment3<OpAiActivate<ImplicitRef>>(Compiler::Ai::opcodeAIActivate);
|
|
|
|
interpreter.installSegment3<OpAiActivate<ExplicitRef>>(Compiler::Ai::opcodeAIActivateExplicit);
|
|
|
|
interpreter.installSegment3<OpAiTravel<ImplicitRef>>(Compiler::Ai::opcodeAiTravel);
|
|
|
|
interpreter.installSegment3<OpAiTravel<ExplicitRef>>(Compiler::Ai::opcodeAiTravelExplicit);
|
|
|
|
interpreter.installSegment3<OpAiEscort<ImplicitRef>>(Compiler::Ai::opcodeAiEscort);
|
|
|
|
interpreter.installSegment3<OpAiEscort<ExplicitRef>>(Compiler::Ai::opcodeAiEscortExplicit);
|
|
|
|
interpreter.installSegment3<OpAiEscortCell<ImplicitRef>>(Compiler::Ai::opcodeAiEscortCell);
|
|
|
|
interpreter.installSegment3<OpAiEscortCell<ExplicitRef>>(Compiler::Ai::opcodeAiEscortCellExplicit);
|
|
|
|
interpreter.installSegment3<OpAiWander<ImplicitRef>>(Compiler::Ai::opcodeAiWander);
|
|
|
|
interpreter.installSegment3<OpAiWander<ExplicitRef>>(Compiler::Ai::opcodeAiWanderExplicit);
|
|
|
|
interpreter.installSegment3<OpAiFollow<ImplicitRef>>(Compiler::Ai::opcodeAiFollow);
|
|
|
|
interpreter.installSegment3<OpAiFollow<ExplicitRef>>(Compiler::Ai::opcodeAiFollowExplicit);
|
|
|
|
interpreter.installSegment3<OpAiFollowCell<ImplicitRef>>(Compiler::Ai::opcodeAiFollowCell);
|
|
|
|
interpreter.installSegment3<OpAiFollowCell<ExplicitRef>>(Compiler::Ai::opcodeAiFollowCellExplicit);
|
|
|
|
interpreter.installSegment5<OpGetAiPackageDone<ImplicitRef>>(Compiler::Ai::opcodeGetAiPackageDone);
|
|
|
|
|
|
|
|
interpreter.installSegment5<OpGetAiPackageDone<ExplicitRef>>(Compiler::Ai::opcodeGetAiPackageDoneExplicit);
|
|
|
|
interpreter.installSegment5<OpGetCurrentAIPackage<ImplicitRef>>(Compiler::Ai::opcodeGetCurrentAiPackage);
|
|
|
|
interpreter.installSegment5<OpGetCurrentAIPackage<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeGetCurrentAiPackageExplicit);
|
|
|
|
interpreter.installSegment5<OpGetDetected<ImplicitRef>>(Compiler::Ai::opcodeGetDetected);
|
|
|
|
interpreter.installSegment5<OpGetDetected<ExplicitRef>>(Compiler::Ai::opcodeGetDetectedExplicit);
|
|
|
|
interpreter.installSegment5<OpGetLineOfSight<ImplicitRef>>(Compiler::Ai::opcodeGetLineOfSight);
|
|
|
|
interpreter.installSegment5<OpGetLineOfSight<ExplicitRef>>(Compiler::Ai::opcodeGetLineOfSightExplicit);
|
|
|
|
interpreter.installSegment5<OpGetTarget<ImplicitRef>>(Compiler::Ai::opcodeGetTarget);
|
|
|
|
interpreter.installSegment5<OpGetTarget<ExplicitRef>>(Compiler::Ai::opcodeGetTargetExplicit);
|
|
|
|
interpreter.installSegment5<OpStartCombat<ImplicitRef>>(Compiler::Ai::opcodeStartCombat);
|
|
|
|
interpreter.installSegment5<OpStartCombat<ExplicitRef>>(Compiler::Ai::opcodeStartCombatExplicit);
|
|
|
|
interpreter.installSegment5<OpStopCombat<ImplicitRef>>(Compiler::Ai::opcodeStopCombat);
|
|
|
|
interpreter.installSegment5<OpStopCombat<ExplicitRef>>(Compiler::Ai::opcodeStopCombatExplicit);
|
|
|
|
interpreter.installSegment5<OpToggleAI>(Compiler::Ai::opcodeToggleAI);
|
|
|
|
|
2022-07-16 16:37:31 +02:00
|
|
|
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeSetHello, MWMechanics::AiSetting::Hello);
|
|
|
|
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeSetHelloExplicit, MWMechanics::AiSetting::Hello);
|
|
|
|
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeSetFight, MWMechanics::AiSetting::Fight);
|
|
|
|
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeSetFightExplicit, MWMechanics::AiSetting::Fight);
|
|
|
|
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeSetFlee, MWMechanics::AiSetting::Flee);
|
|
|
|
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeSetFleeExplicit, MWMechanics::AiSetting::Flee);
|
|
|
|
interpreter.installSegment5<OpSetAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeSetAlarm, MWMechanics::AiSetting::Alarm);
|
|
|
|
interpreter.installSegment5<OpSetAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeSetAlarmExplicit, MWMechanics::AiSetting::Alarm);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2022-07-16 16:37:31 +02:00
|
|
|
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeModHello, MWMechanics::AiSetting::Hello);
|
|
|
|
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeModHelloExplicit, MWMechanics::AiSetting::Hello);
|
|
|
|
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeModFight, MWMechanics::AiSetting::Fight);
|
|
|
|
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeModFightExplicit, MWMechanics::AiSetting::Fight);
|
|
|
|
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeModFlee, MWMechanics::AiSetting::Flee);
|
|
|
|
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeModFleeExplicit, MWMechanics::AiSetting::Flee);
|
|
|
|
interpreter.installSegment5<OpModAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeModAlarm, MWMechanics::AiSetting::Alarm);
|
|
|
|
interpreter.installSegment5<OpModAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeModAlarmExplicit, MWMechanics::AiSetting::Alarm);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2022-07-16 16:37:31 +02:00
|
|
|
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeGetHello, MWMechanics::AiSetting::Hello);
|
|
|
|
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeGetHelloExplicit, MWMechanics::AiSetting::Hello);
|
|
|
|
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeGetFight, MWMechanics::AiSetting::Fight);
|
|
|
|
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeGetFightExplicit, MWMechanics::AiSetting::Fight);
|
|
|
|
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeGetFlee, MWMechanics::AiSetting::Flee);
|
|
|
|
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeGetFleeExplicit, MWMechanics::AiSetting::Flee);
|
|
|
|
interpreter.installSegment5<OpGetAiSetting<ImplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeGetAlarm, MWMechanics::AiSetting::Alarm);
|
|
|
|
interpreter.installSegment5<OpGetAiSetting<ExplicitRef>>(
|
|
|
|
Compiler::Ai::opcodeGetAlarmExplicit, MWMechanics::AiSetting::Alarm);
|
2022-01-27 19:18:57 +00:00
|
|
|
|
|
|
|
interpreter.installSegment5<OpFace<ImplicitRef>>(Compiler::Ai::opcodeFace);
|
|
|
|
interpreter.installSegment5<OpFace<ExplicitRef>>(Compiler::Ai::opcodeFaceExplicit);
|
2010-08-22 14:49:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|