mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 09:23:53 +00:00
Merge remote-tracking branch 'wheybags/master'
This commit is contained in:
commit
274ff530dc
6 changed files with 104 additions and 7 deletions
|
@ -280,7 +280,7 @@ namespace MWBase
|
||||||
/// @param cursor Y (relative 0-1)
|
/// @param cursor Y (relative 0-1)
|
||||||
/// @return true if the object was placed, or false if it was rejected because the position is too far away
|
/// @return true if the object was placed, or false if it was rejected because the position is too far away
|
||||||
|
|
||||||
virtual void dropObjectOnGround (const MWWorld::Ptr& object) = 0;
|
virtual void dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object) = 0;
|
||||||
|
|
||||||
virtual bool canPlaceObject (float cursorX, float cursorY) = 0;
|
virtual bool canPlaceObject (float cursorX, float cursorY) = 0;
|
||||||
///< @return true if it is possible to place on object at specified cursor location
|
///< @return true if it is possible to place on object at specified cursor location
|
||||||
|
|
|
@ -220,7 +220,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
||||||
if (world->canPlaceObject(mouseX, mouseY))
|
if (world->canPlaceObject(mouseX, mouseY))
|
||||||
world->placeObject(object, mouseX, mouseY);
|
world->placeObject(object, mouseX, mouseY);
|
||||||
else
|
else
|
||||||
world->dropObjectOnGround(object);
|
world->dropObjectOnGround(world->getPlayer().getPlayer(), object);
|
||||||
|
|
||||||
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
||||||
|
|
||||||
|
|
|
@ -311,4 +311,9 @@ op 0x20001f4: AddSoulGem, explicit reference
|
||||||
op 0x20001f5: RemoveSoulGem
|
op 0x20001f5: RemoveSoulGem
|
||||||
op 0x20001f6: RemoveSoulGem, explicit reference
|
op 0x20001f6: RemoveSoulGem, explicit reference
|
||||||
op 0x20001f7: PlayBink
|
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,88 @@ 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();
|
||||||
|
|
||||||
|
Interpreter::Type_Integer amount = 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))
|
||||||
|
{
|
||||||
|
if(iter->getRefData().getCount() <= amount)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||||
|
iter->getRefData().setCount(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int original = iter->getRefData().getCount();
|
||||||
|
iter->getRefData().setCount(amount);
|
||||||
|
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||||
|
iter->getRefData().setCount(original - amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
|
||||||
|
if(iter->getRefData().getCount() <= 1)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||||
|
iter->getRefData().setCount(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int original = iter->getRefData().getCount();
|
||||||
|
iter->getRefData().setCount(1);
|
||||||
|
MWBase::Environment::get().getWorld()->dropObjectOnGround(ptr, *iter);
|
||||||
|
iter->getRefData().setCount(original - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <class R>
|
template <class R>
|
||||||
class OpGetAttacked : public Interpreter::Opcode0
|
class OpGetAttacked : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
|
@ -495,6 +577,10 @@ namespace MWScript
|
||||||
const int opcodeAddSoulGemExplicit = 0x20001f4;
|
const int opcodeAddSoulGemExplicit = 0x20001f4;
|
||||||
const int opcodeRemoveSoulGem = 0x20001f5;
|
const int opcodeRemoveSoulGem = 0x20001f5;
|
||||||
const int opcodeRemoveSoulGemExplicit = 0x20001f6;
|
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 opcodeGetAttacked = 0x20001d3;
|
||||||
const int opcodeGetAttackedExplicit = 0x20001d4;
|
const int opcodeGetAttackedExplicit = 0x20001d4;
|
||||||
const int opcodeGetWeaponDrawn = 0x20001d7;
|
const int opcodeGetWeaponDrawn = 0x20001d7;
|
||||||
|
@ -538,6 +624,8 @@ namespace MWScript
|
||||||
extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit);
|
extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit);
|
||||||
extensions.registerInstruction ("addsoulgem", "cc", opcodeAddSoulGem, opcodeAddSoulGemExplicit);
|
extensions.registerInstruction ("addsoulgem", "cc", opcodeAddSoulGem, opcodeAddSoulGemExplicit);
|
||||||
extensions.registerInstruction ("removesoulgem", "c", opcodeRemoveSoulGem, opcodeRemoveSoulGemExplicit);
|
extensions.registerInstruction ("removesoulgem", "c", opcodeRemoveSoulGem, opcodeRemoveSoulGemExplicit);
|
||||||
|
extensions.registerInstruction ("drop", "cl", opcodeDrop, opcodeDropExplicit);
|
||||||
|
extensions.registerInstruction ("dropsoulgem", "c", opcodeDropSoulGem, opcodeDropSoulGemExplicit);
|
||||||
extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit);
|
extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit);
|
||||||
extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit);
|
extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit);
|
||||||
extensions.registerFunction ("getspelleffects", 'l', "c", opcodeGetSpellEffects, opcodeGetSpellEffectsExplicit);
|
extensions.registerFunction ("getspelleffects", 'l', "c", opcodeGetSpellEffects, opcodeGetSpellEffectsExplicit);
|
||||||
|
@ -576,6 +664,10 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (opcodeAddSoulGemExplicit, new OpAddSoulGem<ExplicitRef>);
|
interpreter.installSegment5 (opcodeAddSoulGemExplicit, new OpAddSoulGem<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeRemoveSoulGem, new OpRemoveSoulGem<ImplicitRef>);
|
interpreter.installSegment5 (opcodeRemoveSoulGem, new OpRemoveSoulGem<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeRemoveSoulGemExplicit, new OpRemoveSoulGem<ExplicitRef>);
|
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 (opcodeGetAttacked, new OpGetAttacked<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked<ExplicitRef>);
|
interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetWeaponDrawn, new OpGetWeaponDrawn<ImplicitRef>);
|
interpreter.installSegment5 (opcodeGetWeaponDrawn, new OpGetWeaponDrawn<ImplicitRef>);
|
||||||
|
|
|
@ -1286,12 +1286,12 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::dropObjectOnGround (const Ptr& object)
|
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 =
|
ESM::Position pos =
|
||||||
getPlayer().getPlayer().getRefData().getPosition();
|
actor.getRefData().getPosition();
|
||||||
|
|
||||||
Ogre::Vector3 orig =
|
Ogre::Vector3 orig =
|
||||||
Ogre::Vector3(pos.pos[0], pos.pos[1], pos.pos[2]);
|
Ogre::Vector3(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||||
|
|
|
@ -311,7 +311,7 @@ namespace MWWorld
|
||||||
/// @param cursor Y (relative 0-1)
|
/// @param cursor Y (relative 0-1)
|
||||||
/// @return true if the object was placed, or false if it was rejected because the position is too far away
|
/// @return true if the object was placed, or false if it was rejected because the position is too far away
|
||||||
|
|
||||||
virtual void dropObjectOnGround (const Ptr& object);
|
virtual void dropObjectOnGround (const Ptr& actor, const Ptr& object);
|
||||||
|
|
||||||
virtual bool canPlaceObject(float cursorX, float cursorY);
|
virtual bool canPlaceObject(float cursorX, float cursorY);
|
||||||
///< @return true if it is possible to place on object at specified cursor location
|
///< @return true if it is possible to place on object at specified cursor location
|
||||||
|
|
Loading…
Reference in a new issue