mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 21:42:13 +00:00
added Drop and DropSoulGem functions
This commit is contained in:
parent
5bfdb2449d
commit
3517635cfd
@ -311,4 +311,9 @@ op 0x20001f4: AddSoulGem, explicit reference
|
||||
op 0x20001f5: RemoveSoulGem
|
||||
op 0x20001f6: RemoveSoulGem, explicit reference
|
||||
op 0x20001f7: PlayBink
|
||||
opcodes 0x20001f8-0x3ffffff unused
|
||||
op 0x20001f8: Drop
|
||||
op 0x20001f9: Drop, explicit reference
|
||||
op 0x20001fa: DropSoulGem
|
||||
op 0x20001fb: DropSoulGem, explicit reference
|
||||
|
||||
opcodes 0x20001fa-0x3ffffff unused
|
||||
|
@ -383,6 +383,60 @@ namespace MWScript
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpDrop : 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::ContainerStore& store = MWWorld::Class::get (ptr).getContainerStore (ptr);
|
||||
|
||||
|
||||
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
|
||||
{
|
||||
if (::Misc::StringUtils::ciEqual(iter->getCellRef().mRefID, item))
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpDropSoulGem : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string soul = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::ContainerStore& store = MWWorld::Class::get (ptr).getContainerStore (ptr);
|
||||
|
||||
|
||||
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
|
||||
{
|
||||
if (::Misc::StringUtils::ciEqual(iter->getCellRef().mSoul, soul))
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class OpGetAttacked : public Interpreter::Opcode0
|
||||
{
|
||||
@ -495,6 +549,10 @@ namespace MWScript
|
||||
const int opcodeAddSoulGemExplicit = 0x20001f4;
|
||||
const int opcodeRemoveSoulGem = 0x20001f5;
|
||||
const int opcodeRemoveSoulGemExplicit = 0x20001f6;
|
||||
const int opcodeDrop = 0x20001f8;
|
||||
const int opcodeDropExplicit = 0x20001f9;
|
||||
const int opcodeDropSoulGem = 0x20001fa;
|
||||
const int opcodeDropSoulGemExplicit = 0x20001fb;
|
||||
const int opcodeGetAttacked = 0x20001d3;
|
||||
const int opcodeGetAttackedExplicit = 0x20001d4;
|
||||
const int opcodeGetWeaponDrawn = 0x20001d7;
|
||||
@ -538,6 +596,8 @@ namespace MWScript
|
||||
extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit);
|
||||
extensions.registerInstruction ("addsoulgem", "cc", opcodeAddSoulGem, opcodeAddSoulGemExplicit);
|
||||
extensions.registerInstruction ("removesoulgem", "c", opcodeRemoveSoulGem, opcodeRemoveSoulGemExplicit);
|
||||
extensions.registerInstruction ("drop", "c", opcodeDrop, opcodeDropExplicit);
|
||||
extensions.registerInstruction ("dropsoulgem", "c", opcodeDropSoulGem, opcodeDropSoulGemExplicit);
|
||||
extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit);
|
||||
extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit);
|
||||
extensions.registerFunction ("getspelleffects", 'l', "c", opcodeGetSpellEffects, opcodeGetSpellEffectsExplicit);
|
||||
@ -576,6 +636,10 @@ namespace MWScript
|
||||
interpreter.installSegment5 (opcodeAddSoulGemExplicit, new OpAddSoulGem<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRemoveSoulGem, new OpRemoveSoulGem<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRemoveSoulGemExplicit, new OpRemoveSoulGem<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeDrop, new OpDrop<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeDropExplicit, new OpDrop<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeDropSoulGem, new OpDropSoulGem<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeDropSoulGemExplicit, new OpDropSoulGem<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAttacked, new OpGetAttacked<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetWeaponDrawn, new OpGetWeaponDrawn<ImplicitRef>);
|
||||
|
@ -1288,10 +1288,10 @@ namespace MWWorld
|
||||
|
||||
void World::dropObjectOnGround (const Ptr& actor, const Ptr& object)
|
||||
{
|
||||
MWWorld::Ptr::CellStore* cell = getPlayer().getPlayer().getCell();
|
||||
MWWorld::Ptr::CellStore* cell = actor.getCell();
|
||||
|
||||
ESM::Position pos =
|
||||
getPlayer().getPlayer().getRefData().getPosition();
|
||||
actor.getRefData().getPosition();
|
||||
|
||||
Ogre::Vector3 orig =
|
||||
Ogre::Vector3(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
|
Loading…
Reference in New Issue
Block a user