mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Merge branch 'scripting' of github.com:scrawl/openmw into scripting
This commit is contained in:
commit
4b830e5c7a
8 changed files with 441 additions and 41 deletions
|
@ -332,6 +332,8 @@ void RenderingManager::update (float duration, bool paused)
|
|||
}
|
||||
mOcclusionQuery->update(duration);
|
||||
|
||||
mRendering.update(duration);
|
||||
|
||||
if(paused)
|
||||
{
|
||||
Ogre::ControllerManager::getSingleton().setTimeFactor(0.f);
|
||||
|
@ -350,8 +352,6 @@ void RenderingManager::update (float duration, bool paused)
|
|||
|
||||
mSkyManager->setGlare(mOcclusionQuery->getSunVisibility());
|
||||
|
||||
mRendering.update(duration);
|
||||
|
||||
MWWorld::RefData &data =
|
||||
MWBase::Environment::get()
|
||||
.getWorld()
|
||||
|
|
|
@ -114,71 +114,56 @@ namespace MWScript
|
|||
// discard additional arguments (reset), because we have no idea what they mean.
|
||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
||||
|
||||
std::cout << "AiWanter" << std::endl;
|
||||
std::cout << "AiWander" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetHello : public Interpreter::Opcode0
|
||||
class OpGetAiSetting : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
public:
|
||||
OpGetAiSetting(int index) : mIndex(index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (0, value);
|
||||
runtime.push(MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSetting (mIndex));
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetFight : public Interpreter::Opcode0
|
||||
class OpModAiSetting : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
public:
|
||||
OpModAiSetting(int index) : mIndex(index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (1, value);
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (mIndex,
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSetting (mIndex) + value);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetFlee : public Interpreter::Opcode0
|
||||
class OpSetAiSetting : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
public:
|
||||
OpSetAiSetting(int index) : mIndex(index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (2, value);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetAlarm : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (3, value);
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (mIndex,
|
||||
value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -199,6 +184,22 @@ namespace MWScript
|
|||
const int opcodeSetFleeExplicit = 0x2000161;
|
||||
const int opcodeSetAlarm = 0x2000162;
|
||||
const int opcodeSetAlarmExplicit = 0x2000163;
|
||||
const int opcodeModHello = 0x20001b7;
|
||||
const int opcodeModHelloExplicit = 0x20001b8;
|
||||
const int opcodeModFight = 0x20001b9;
|
||||
const int opcodeModFightExplicit = 0x20001ba;
|
||||
const int opcodeModFlee = 0x20001bb;
|
||||
const int opcodeModFleeExplicit = 0x20001bc;
|
||||
const int opcodeModAlarm = 0x20001bd;
|
||||
const int opcodeModAlarmExplicit = 0x20001be;
|
||||
const int opcodeGetHello = 0x20001bf;
|
||||
const int opcodeGetHelloExplicit = 0x20001c0;
|
||||
const int opcodeGetFight = 0x20001c1;
|
||||
const int opcodeGetFightExplicit = 0x20001c2;
|
||||
const int opcodeGetFlee = 0x20001c3;
|
||||
const int opcodeGetFleeExplicit = 0x20001c4;
|
||||
const int opcodeGetAlarm = 0x20001c5;
|
||||
const int opcodeGetAlarmExplicit = 0x20001c6;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -216,6 +217,14 @@ namespace MWScript
|
|||
extensions.registerInstruction ("setfight", "l", opcodeSetFight, opcodeSetFightExplicit);
|
||||
extensions.registerInstruction ("setflee", "l", opcodeSetFlee, opcodeSetFleeExplicit);
|
||||
extensions.registerInstruction ("setalarm", "l", opcodeSetAlarm, opcodeSetAlarmExplicit);
|
||||
extensions.registerInstruction ("modhello", "l", opcodeModHello, opcodeModHelloExplicit);
|
||||
extensions.registerInstruction ("modfight", "l", opcodeModFight, opcodeModFightExplicit);
|
||||
extensions.registerInstruction ("modflee", "l", opcodeModFlee, opcodeModFleeExplicit);
|
||||
extensions.registerInstruction ("modalarm", "l", opcodeModAlarm, opcodeModAlarmExplicit);
|
||||
extensions.registerFunction ("gethello", 'l', "", opcodeGetHello, opcodeGetHelloExplicit);
|
||||
extensions.registerFunction ("getfight", 'l', "", opcodeGetFight, opcodeGetFightExplicit);
|
||||
extensions.registerFunction ("getflee", 'l', "", opcodeGetFlee, opcodeGetFleeExplicit);
|
||||
extensions.registerFunction ("getalarm", 'l', "", opcodeGetAlarm, opcodeGetAlarmExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -229,14 +238,32 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit,
|
||||
new OpGetAiPackageDone<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetHello, new OpSetHello<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetHelloExplicit, new OpSetHello<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetFight, new OpSetFight<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetFightExplicit, new OpSetFight<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetFlee, new OpSetFlee<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetFleeExplicit, new OpSetFlee<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetAlarm, new OpSetAlarm<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetAlarmExplicit, new OpSetAlarm<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetHello, new OpSetAiSetting<ImplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeSetHelloExplicit, new OpSetAiSetting<ExplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeSetFight, new OpSetAiSetting<ImplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeSetFightExplicit, new OpSetAiSetting<ExplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeSetFlee, new OpSetAiSetting<ImplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeSetFleeExplicit, new OpSetAiSetting<ExplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeSetAlarm, new OpSetAiSetting<ImplicitRef>(3));
|
||||
interpreter.installSegment5 (opcodeSetAlarmExplicit, new OpSetAiSetting<ExplicitRef>(3));
|
||||
|
||||
interpreter.installSegment5 (opcodeModHello, new OpModAiSetting<ImplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeModHelloExplicit, new OpModAiSetting<ExplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeModFight, new OpModAiSetting<ImplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeModFightExplicit, new OpModAiSetting<ExplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeModFlee, new OpModAiSetting<ImplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeModFleeExplicit, new OpModAiSetting<ExplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeModAlarm, new OpModAiSetting<ImplicitRef>(3));
|
||||
interpreter.installSegment5 (opcodeModAlarmExplicit, new OpModAiSetting<ExplicitRef>(3));
|
||||
|
||||
interpreter.installSegment5 (opcodeGetHello, new OpGetAiSetting<ImplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeGetHelloExplicit, new OpGetAiSetting<ExplicitRef>(0));
|
||||
interpreter.installSegment5 (opcodeGetFight, new OpGetAiSetting<ImplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeGetFightExplicit, new OpGetAiSetting<ExplicitRef>(1));
|
||||
interpreter.installSegment5 (opcodeGetFlee, new OpGetAiSetting<ImplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeGetFleeExplicit, new OpGetAiSetting<ExplicitRef>(2));
|
||||
interpreter.installSegment5 (opcodeGetAlarm, new OpGetAiSetting<ImplicitRef>(3));
|
||||
interpreter.installSegment5 (opcodeGetAlarmExplicit, new OpGetAiSetting<ExplicitRef>(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "../mwworld/manualref.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
#include "../mwworld/actionequip.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
@ -128,12 +130,144 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpEquip : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute(Interpreter::Runtime &runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
|
||||
MWWorld::ContainerStoreIterator it = invStore.begin();
|
||||
for (; it != invStore.end(); ++it)
|
||||
{
|
||||
if (toLower(it->getCellRef().mRefID) == toLower(item))
|
||||
break;
|
||||
}
|
||||
if (it == invStore.end())
|
||||
throw std::runtime_error("Item to equip not found");
|
||||
|
||||
MWWorld::ActionEquip action (*it);
|
||||
action.execute(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetArmorType : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute(Interpreter::Runtime &runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer location = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
int slot;
|
||||
switch (location)
|
||||
{
|
||||
case 0:
|
||||
slot = MWWorld::InventoryStore::Slot_Helmet;
|
||||
break;
|
||||
case 1:
|
||||
slot = MWWorld::InventoryStore::Slot_Cuirass;
|
||||
break;
|
||||
case 2:
|
||||
slot = MWWorld::InventoryStore::Slot_LeftPauldron;
|
||||
break;
|
||||
case 3:
|
||||
slot = MWWorld::InventoryStore::Slot_RightPauldron;
|
||||
break;
|
||||
case 4:
|
||||
slot = MWWorld::InventoryStore::Slot_Greaves;
|
||||
break;
|
||||
case 5:
|
||||
slot = MWWorld::InventoryStore::Slot_Boots;
|
||||
break;
|
||||
case 6:
|
||||
slot = MWWorld::InventoryStore::Slot_LeftGauntlet;
|
||||
break;
|
||||
case 7:
|
||||
slot = MWWorld::InventoryStore::Slot_RightGauntlet;
|
||||
break;
|
||||
case 8:
|
||||
slot = MWWorld::InventoryStore::Slot_CarriedLeft; // shield
|
||||
break;
|
||||
case 9:
|
||||
slot = MWWorld::InventoryStore::Slot_LeftGauntlet;
|
||||
break;
|
||||
case 10:
|
||||
slot = MWWorld::InventoryStore::Slot_RightGauntlet;
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error ("armor index out of range");
|
||||
}
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
|
||||
|
||||
MWWorld::ContainerStoreIterator it = invStore.getSlot (slot);
|
||||
if (it == invStore.end())
|
||||
{
|
||||
runtime.push(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
int skill = MWWorld::Class::get(*it).getEquipmentSkill (*it) ;
|
||||
if (skill == ESM::Skill::HeavyArmor)
|
||||
runtime.push(2);
|
||||
else if (skill == ESM::Skill::MediumArmor)
|
||||
runtime.push(1);
|
||||
else if (skill == ESM::Skill::LightArmor)
|
||||
runtime.push(0);
|
||||
else
|
||||
runtime.push(-1);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpHasItemEquipped : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute(Interpreter::Runtime &runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
|
||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator it = invStore.getSlot (slot);
|
||||
if (it != invStore.end() && toLower(it->getCellRef().mRefID) == toLower(item))
|
||||
{
|
||||
runtime.push(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
runtime.push(0);
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeAddItem = 0x2000076;
|
||||
const int opcodeAddItemExplicit = 0x2000077;
|
||||
const int opcodeGetItemCount = 0x2000078;
|
||||
const int opcodeGetItemCountExplicit = 0x2000079;
|
||||
const int opcodeRemoveItem = 0x200007a;
|
||||
const int opcodeRemoveItemExplicit = 0x200007b;
|
||||
const int opcodeEquip = 0x20001b3;
|
||||
const int opcodeEquipExplicit = 0x20001b4;
|
||||
const int opcodeGetArmorType = 0x20001d1;
|
||||
const int opcodeGetArmorTypeExplicit = 0x20001d2;
|
||||
const int opcodeHasItemEquipped = 0x20001d5;
|
||||
const int opcodeHasItemEquippedExplicit = 0x20001d6;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -142,6 +276,9 @@ namespace MWScript
|
|||
opcodeGetItemCountExplicit);
|
||||
extensions.registerInstruction ("removeitem", "cl", opcodeRemoveItem,
|
||||
opcodeRemoveItemExplicit);
|
||||
extensions.registerInstruction ("equip", "c", opcodeEquip, opcodeEquipExplicit);
|
||||
extensions.registerFunction ("getarmortype", 'l', "l", opcodeGetArmorType, opcodeGetArmorTypeExplicit);
|
||||
extensions.registerFunction ("hasitemequipped", 'l', "c", opcodeHasItemEquipped, opcodeHasItemEquippedExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -152,6 +289,13 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCount<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItem<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeEquip, new OpEquip<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeEquipExplicit, new OpEquip<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetArmorType, new OpGetArmorType<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetArmorTypeExplicit, new OpGetArmorType<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeHasItemEquipped, new OpHasItemEquipped<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeHasItemEquippedExplicit, new OpHasItemEquipped<ExplicitRef>);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,58 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetForceRun : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr);
|
||||
|
||||
runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceRun));
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetForceSneak : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr);
|
||||
|
||||
runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak));
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetPcRunning : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer();
|
||||
runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Run));
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetPcSneaking : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer();
|
||||
runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Sneak));
|
||||
}
|
||||
};
|
||||
|
||||
const int numberOfControls = 7;
|
||||
|
||||
const int opcodeEnable = 0x200007e;
|
||||
|
@ -120,6 +172,12 @@ namespace MWScript
|
|||
const int opcodeForceSneak = 0x200015a;
|
||||
const int opcodeForceSneakExplicit = 0x200015b;
|
||||
const int opcodeGetDisabled = 0x2000175;
|
||||
const int opcodeGetPcRunning = 0x20001c9;
|
||||
const int opcodeGetPcSneaking = 0x20001ca;
|
||||
const int opcodeGetForceRun = 0x20001cb;
|
||||
const int opcodeGetForceSneak = 0x20001cc;
|
||||
const int opcodeGetForceRunExplicit = 0x20001cd;
|
||||
const int opcodeGetForceSneakExplicit = 0x20001ce;
|
||||
|
||||
const char *controls[numberOfControls] =
|
||||
{
|
||||
|
@ -151,6 +209,10 @@ namespace MWScript
|
|||
opcodeClearForceSneakExplicit);
|
||||
extensions.registerInstruction ("forcesneak", "", opcodeForceSneak,
|
||||
opcodeForceSneakExplicit);
|
||||
extensions.registerFunction ("getpcrunning", 'l', "", opcodeGetPcRunning);
|
||||
extensions.registerFunction ("getpcsneaking", 'l', "", opcodeGetPcSneaking);
|
||||
extensions.registerFunction ("getforcerun", 'l', "", opcodeGetForceRun, opcodeGetForceRunExplicit);
|
||||
extensions.registerFunction ("getforcesneak", 'l', "", opcodeGetForceSneak, opcodeGetForceSneakExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -181,6 +243,12 @@ namespace MWScript
|
|||
new OpClearMovementFlag<ExplicitRef> (MWMechanics::NpcStats::Flag_ForceSneak));
|
||||
interpreter.installSegment5 (opcodeForceSneakExplicit,
|
||||
new OpSetMovementFlag<ExplicitRef> (MWMechanics::NpcStats::Flag_ForceSneak));
|
||||
interpreter.installSegment5 (opcodeGetPcRunning, new OpGetPcRunning);
|
||||
interpreter.installSegment5 (opcodeGetPcSneaking, new OpGetPcSneaking);
|
||||
interpreter.installSegment5 (opcodeGetForceRun, new OpGetForceRun<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetForceRunExplicit, new OpGetForceRun<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetForceSneak, new OpGetForceSneak<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetForceSneakExplicit, new OpGetForceSneak<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../mwbase/journal.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
@ -159,6 +160,33 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetReputation : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push (MWWorld::Class::get(ptr).getNpcStats (ptr).getReputation ());
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSameFaction : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer();
|
||||
|
||||
runtime.push (MWWorld::Class::get(ptr).getNpcStats (ptr).isSameFaction (MWWorld::Class::get(player).getNpcStats (player)));
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeJournal = 0x2000133;
|
||||
const int opcodeSetJournalIndex = 0x2000134;
|
||||
|
@ -172,6 +200,10 @@ namespace MWScript
|
|||
const int opcodeModReputation = 0x20001ae;
|
||||
const int opcodeSetReputationExplicit = 0x20001af;
|
||||
const int opcodeModReputationExplicit = 0x20001b0;
|
||||
const int opcodeGetReputation = 0x20001b1;
|
||||
const int opcodeGetReputationExplicit = 0x20001b2;
|
||||
const int opcodeSameFaction = 0x20001b5;
|
||||
const int opcodeSameFactionExplicit = 0x20001b6;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -188,6 +220,10 @@ namespace MWScript
|
|||
opcodeSetReputationExplicit);
|
||||
extensions.registerInstruction("modreputation", "l", opcodeModReputation,
|
||||
opcodeModReputationExplicit);
|
||||
extensions.registerFunction("getreputation", 'l', "", opcodeGetReputation,
|
||||
opcodeGetReputationExplicit);
|
||||
extensions.registerFunction("samefaction", 'l', "", opcodeSameFaction,
|
||||
opcodeSameFactionExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -200,10 +236,14 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeForceGreeting, new OpForceGreeting<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeForceGreetingExplicit, new OpForceGreeting<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGoodbye, new OpGoodbye);
|
||||
interpreter.installSegment5 (opcodeGetReputation, new OpGetReputation<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetReputation, new OpSetReputation<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeModReputation, new OpModReputation<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSetReputationExplicit, new OpSetReputation<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeModReputationExplicit, new OpModReputation<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetReputationExplicit, new OpGetReputation<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSameFaction, new OpSameFaction<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSameFactionExplicit, new OpSameFaction<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,5 +226,45 @@ op 0x20001ad: SetReputation
|
|||
op 0x20001ae: ModReputation
|
||||
op 0x20001af: SetReputation, explicit
|
||||
op 0x20001b0: ModReputation, explicit
|
||||
opcodes 0x20001b1-0x3ffffff unused
|
||||
op 0x20001b1: GetReputation
|
||||
op 0x20001b2: GetReputation, explicit
|
||||
op 0x20001b3: Equip
|
||||
op 0x20001b4: Equip, explicit
|
||||
op 0x20001b5: SameFaction
|
||||
op 0x20001b6: SameFaction, explicit
|
||||
op 0x20001b7: ModHello
|
||||
op 0x20001b8: ModHello, explicit reference
|
||||
op 0x20001b9: ModFight
|
||||
op 0x20001ba: ModFight, explicit reference
|
||||
op 0x20001bb: ModFlee
|
||||
op 0x20001bc: ModFlee, explicit reference
|
||||
op 0x20001bd: ModAlarm
|
||||
op 0x20001be: ModAlarm, explicit reference
|
||||
op 0x20001bf: GetHello
|
||||
op 0x20001c0: GetHello, explicit reference
|
||||
op 0x20001c1: GetFight
|
||||
op 0x20001c2: GetFight, explicit reference
|
||||
op 0x20001c3: GetFlee
|
||||
op 0x20001c4: GetFlee, explicit reference
|
||||
op 0x20001c5: GetAlarm
|
||||
op 0x20001c6: GetAlarm, explicit reference
|
||||
op 0x20001c7: GetLocked
|
||||
op 0x20001c8: GetLocked, explicit reference
|
||||
op 0x20001c9: GetPcRunning
|
||||
op 0x20001ca: GetPcSneaking
|
||||
op 0x20001cb: GetForceRun
|
||||
op 0x20001cc: GetForceSneak
|
||||
op 0x20001cd: GetForceRun, explicit
|
||||
op 0x20001ce: GetForceSneak, explicit
|
||||
op 0x20001cf: GetEffect
|
||||
op 0x20001d0: GetEffect, explicit
|
||||
op 0x20001d1: GetArmorType
|
||||
op 0x20001d2: GetArmorType, explicit
|
||||
op 0x20001d3: GetAttacked
|
||||
op 0x20001d4: GetAttacked, explicit
|
||||
op 0x20001d5: HasItemEquipped
|
||||
op 0x20001d6: HasItemEquipped, explicit
|
||||
op 0x20001d7: GetWeaponDrawn
|
||||
op 0x20001d8: GetWeaponDrawn, explicit
|
||||
opcodes 0x20001d9-0x3ffffff unused
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
@ -272,6 +276,62 @@ namespace MWScript
|
|||
};
|
||||
bool OpToggleVanityMode::sActivate = true;
|
||||
|
||||
template <class R>
|
||||
class OpGetLocked : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push (ptr.getCellRef ().mLockLevel > 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetEffect : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
int key = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
runtime.push (MWWorld::Class::get(ptr).getCreatureStats (ptr).getMagicEffects ().get (
|
||||
MWMechanics::EffectKey(key)).mMagnitude > 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetAttacked : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push(MWWorld::Class::get(ptr).getCreatureStats (ptr).getAttacked ());
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetWeaponDrawn : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push(MWWorld::Class::get(ptr).getNpcStats (ptr).getDrawState () == MWMechanics::DrawState_Weapon);
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeXBox = 0x200000c;
|
||||
const int opcodeOnActivate = 0x200000d;
|
||||
const int opcodeActivate = 0x2000075;
|
||||
|
@ -291,6 +351,14 @@ namespace MWScript
|
|||
const int opcodeToggleVanityMode = 0x2000174;
|
||||
const int opcodeGetPcSleep = 0x200019f;
|
||||
const int opcodeWakeUpPc = 0x20001a2;
|
||||
const int opcodeGetLocked = 0x20001c7;
|
||||
const int opcodeGetLockedExplicit = 0x20001c8;
|
||||
const int opcodeGetEffect = 0x20001cf;
|
||||
const int opcodeGetEffectExplicit = 0x20001d0;
|
||||
const int opcodeGetAttacked = 0x20001d3;
|
||||
const int opcodeGetAttackedExplicit = 0x20001d4;
|
||||
const int opcodeGetWeaponDrawn = 0x20001d7;
|
||||
const int opcodeGetWeaponDrawnExplicit = 0x20001d8;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -317,6 +385,10 @@ namespace MWScript
|
|||
extensions.registerInstruction ("tvm", "", opcodeToggleVanityMode);
|
||||
extensions.registerFunction ("getpcsleep", 'l', "", opcodeGetPcSleep);
|
||||
extensions.registerInstruction ("wakeuppc", "", opcodeWakeUpPc);
|
||||
extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit);
|
||||
extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit);
|
||||
extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit);
|
||||
extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -340,6 +412,14 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeToggleVanityMode, new OpToggleVanityMode);
|
||||
interpreter.installSegment5 (opcodeGetPcSleep, new OpGetPcSleep);
|
||||
interpreter.installSegment5 (opcodeWakeUpPc, new OpWakeUpPc);
|
||||
interpreter.installSegment5 (opcodeGetLocked, new OpGetLocked<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetLockedExplicit, new OpGetLocked<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetEffect, new OpGetEffect<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAttacked, new OpGetAttacked<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ namespace MWWorld
|
|||
void setUpDown(int value);
|
||||
|
||||
void toggleRunning();
|
||||
void getRunning();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue