mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 07:32:00 -04:00
Merge remote-tracking branch 'scrawl/master'
This commit is contained in:
commit
f112c78858
@ -491,10 +491,7 @@ void OMW::Engine::activate()
|
|||||||
|
|
||||||
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
|
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> action =
|
interpreterContext.activate (ptr);
|
||||||
ptr.getClass().activate (ptr, MWBase::Environment::get().getWorld()->getPlayerPtr());
|
|
||||||
|
|
||||||
interpreterContext.activate (ptr, action);
|
|
||||||
|
|
||||||
std::string script = ptr.getClass().getScript (ptr);
|
std::string script = ptr.getClass().getScript (ptr);
|
||||||
|
|
||||||
@ -508,7 +505,7 @@ void OMW::Engine::activate()
|
|||||||
|
|
||||||
if (!interpreterContext.hasActivationBeenHandled())
|
if (!interpreterContext.hasActivationBeenHandled())
|
||||||
{
|
{
|
||||||
interpreterContext.executeActivation();
|
interpreterContext.executeActivation(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,12 +1019,13 @@ namespace MWMechanics
|
|||||||
|
|
||||||
void MechanicsManager::startCombat(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
|
void MechanicsManager::startCombat(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
|
||||||
{
|
{
|
||||||
if (ptr.getClass().isNpc())
|
|
||||||
MWBase::Environment::get().getDialogueManager()->say(ptr, "attack");
|
|
||||||
|
|
||||||
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
||||||
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
ptr.getClass().getCreatureStats(ptr).setHostile(true);
|
ptr.getClass().getCreatureStats(ptr).setHostile(true);
|
||||||
|
|
||||||
|
// Must be done after the target is set up, so that CreatureTargetted dialogue filter works properly
|
||||||
|
if (ptr.getClass().isNpc())
|
||||||
|
MWBase::Environment::get().getDialogueManager()->say(ptr, "attack");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::getObjectsInRange(const Ogre::Vector3 &position, float radius, std::vector<MWWorld::Ptr> &objects)
|
void MechanicsManager::getObjectsInRange(const Ogre::Vector3 &position, float radius, std::vector<MWWorld::Ptr> &objects)
|
||||||
|
@ -392,5 +392,6 @@ op 0x2000240: onKnockout
|
|||||||
op 0x2000241: onKnockoutExplicit
|
op 0x2000241: onKnockoutExplicit
|
||||||
op 0x2000242: ModFactionReaction
|
op 0x2000242: ModFactionReaction
|
||||||
op 0x2000243: GetFactionReaction
|
op 0x2000243: GetFactionReaction
|
||||||
|
op 0x2000244: Activate, explicit
|
||||||
|
|
||||||
opcodes 0x2000244-0x3ffffff unused
|
opcodes 0x2000245-0x3ffffff unused
|
||||||
|
@ -413,28 +413,25 @@ namespace MWScript
|
|||||||
return mActivationHandled;
|
return mActivationHandled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpreterContext::activate (const MWWorld::Ptr& ptr,
|
void InterpreterContext::activate (const MWWorld::Ptr& ptr)
|
||||||
boost::shared_ptr<MWWorld::Action> action)
|
|
||||||
{
|
{
|
||||||
mActivated = ptr;
|
mActivated = ptr;
|
||||||
mActivationHandled = false;
|
mActivationHandled = false;
|
||||||
mAction = action;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpreterContext::executeActivation()
|
void InterpreterContext::executeActivation(MWWorld::Ptr ptr)
|
||||||
{
|
{
|
||||||
if (!mAction.get())
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
throw std::runtime_error ("activation failed, because no action to perform");
|
boost::shared_ptr<MWWorld::Action> action = (ptr.getClass().activate(ptr, player));
|
||||||
|
action->execute (player);
|
||||||
mAction->execute (MWBase::Environment::get().getWorld()->getPlayerPtr());
|
if (mActivated == ptr)
|
||||||
mActivationHandled = true;
|
mActivationHandled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpreterContext::clearActivation()
|
void InterpreterContext::clearActivation()
|
||||||
{
|
{
|
||||||
mActivated = MWWorld::Ptr();
|
mActivated = MWWorld::Ptr();
|
||||||
mActivationHandled = false;
|
mActivationHandled = false;
|
||||||
mAction.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float InterpreterContext::getSecondsPassed() const
|
float InterpreterContext::getSecondsPassed() const
|
||||||
|
@ -31,7 +31,6 @@ namespace MWScript
|
|||||||
|
|
||||||
MWWorld::Ptr mActivated;
|
MWWorld::Ptr mActivated;
|
||||||
bool mActivationHandled;
|
bool mActivationHandled;
|
||||||
boost::shared_ptr<MWWorld::Action> mAction;
|
|
||||||
|
|
||||||
MWWorld::Ptr getReference (const std::string& id, bool activeOnly, bool doThrow=true);
|
MWWorld::Ptr getReference (const std::string& id, bool activeOnly, bool doThrow=true);
|
||||||
|
|
||||||
@ -126,12 +125,12 @@ namespace MWScript
|
|||||||
|
|
||||||
bool hasActivationBeenHandled() const;
|
bool hasActivationBeenHandled() const;
|
||||||
|
|
||||||
void activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> action);
|
void activate (const MWWorld::Ptr& ptr);
|
||||||
///< Store reference acted upon and action. The actual execution of the action does not
|
///< Store reference acted upon. The actual execution of the action does not
|
||||||
/// take place here.
|
/// take place here.
|
||||||
|
|
||||||
void executeActivation();
|
void executeActivation(MWWorld::Ptr ptr);
|
||||||
///< Execute the action defined by the last activate call.
|
///< Execute the activation action for this ptr. If ptr is mActivated, mark activation as handled.
|
||||||
|
|
||||||
void clearActivation();
|
void clearActivation();
|
||||||
///< Discard the action defined by the last activate call.
|
///< Discard the action defined by the last activate call.
|
||||||
|
@ -109,6 +109,7 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class R>
|
||||||
class OpActivate : public Interpreter::Opcode0
|
class OpActivate : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -118,7 +119,9 @@ namespace MWScript
|
|||||||
InterpreterContext& context =
|
InterpreterContext& context =
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
context.executeActivation();
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
|
context.executeActivation(ptr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -860,7 +863,8 @@ namespace MWScript
|
|||||||
{
|
{
|
||||||
interpreter.installSegment5 (Compiler::Misc::opcodeXBox, new OpXBox);
|
interpreter.installSegment5 (Compiler::Misc::opcodeXBox, new OpXBox);
|
||||||
interpreter.installSegment5 (Compiler::Misc::opcodeOnActivate, new OpOnActivate);
|
interpreter.installSegment5 (Compiler::Misc::opcodeOnActivate, new OpOnActivate);
|
||||||
interpreter.installSegment5 (Compiler::Misc::opcodeActivate, new OpActivate);
|
interpreter.installSegment5 (Compiler::Misc::opcodeActivate, new OpActivate<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (Compiler::Misc::opcodeActivateExplicit, new OpActivate<ExplicitRef>);
|
||||||
interpreter.installSegment3 (Compiler::Misc::opcodeLock, new OpLock<ImplicitRef>);
|
interpreter.installSegment3 (Compiler::Misc::opcodeLock, new OpLock<ImplicitRef>);
|
||||||
interpreter.installSegment3 (Compiler::Misc::opcodeLockExplicit, new OpLock<ExplicitRef>);
|
interpreter.installSegment3 (Compiler::Misc::opcodeLockExplicit, new OpLock<ExplicitRef>);
|
||||||
interpreter.installSegment5 (Compiler::Misc::opcodeUnlock, new OpUnlock<ImplicitRef>);
|
interpreter.installSegment5 (Compiler::Misc::opcodeUnlock, new OpUnlock<ImplicitRef>);
|
||||||
|
@ -229,22 +229,26 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr
|
|||||||
std::string script = item.getClass().getScript(item);
|
std::string script = item.getClass().getScript(item);
|
||||||
if(script != "")
|
if(script != "")
|
||||||
{
|
{
|
||||||
CellStore *cell;
|
if (actorPtr == player)
|
||||||
|
{
|
||||||
|
// Items in player's inventory have cell set to 0, so their scripts will never be removed
|
||||||
|
item.mCell = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Set mCell to the cell of the container/actor, so that the scripts are removed properly when
|
||||||
|
// the cell of the container/actor goes inactive
|
||||||
|
item.mCell = actorPtr.getCell();
|
||||||
|
}
|
||||||
|
|
||||||
|
item.mContainerStore = 0;
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, item);
|
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, item);
|
||||||
|
|
||||||
if(&(player.getClass().getContainerStore (player)) == this)
|
// Set OnPCAdd special variable, if it is declared
|
||||||
{
|
// Make sure to do this *after* we have added the script to LocalScripts
|
||||||
cell = 0; // Items in player's inventory have cell set to 0, so their scripts will never be removed
|
if (actorPtr == player)
|
||||||
|
|
||||||
// Set OnPCAdd special variable, if it is declared
|
|
||||||
item.getRefData().getLocals().setVarByInt(script, "onpcadd", 1);
|
item.getRefData().getLocals().setVarByInt(script, "onpcadd", 1);
|
||||||
}
|
|
||||||
else
|
|
||||||
cell = player.getCell();
|
|
||||||
|
|
||||||
item.mCell = cell;
|
|
||||||
item.mContainerStore = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return it;
|
return it;
|
||||||
|
@ -224,7 +224,7 @@ namespace Compiler
|
|||||||
{
|
{
|
||||||
extensions.registerFunction ("xbox", 'l', "", opcodeXBox);
|
extensions.registerFunction ("xbox", 'l', "", opcodeXBox);
|
||||||
extensions.registerFunction ("onactivate", 'l', "", opcodeOnActivate);
|
extensions.registerFunction ("onactivate", 'l', "", opcodeOnActivate);
|
||||||
extensions.registerInstruction ("activate", "", opcodeActivate);
|
extensions.registerInstruction ("activate", "", opcodeActivate, opcodeActivateExplicit);
|
||||||
extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit);
|
extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit);
|
||||||
extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit);
|
extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit);
|
||||||
extensions.registerInstruction ("cast", "SS", opcodeCast, opcodeCastExplicit);
|
extensions.registerInstruction ("cast", "SS", opcodeCast, opcodeCastExplicit);
|
||||||
|
@ -182,6 +182,7 @@ namespace Compiler
|
|||||||
const int opcodeXBox = 0x200000c;
|
const int opcodeXBox = 0x200000c;
|
||||||
const int opcodeOnActivate = 0x200000d;
|
const int opcodeOnActivate = 0x200000d;
|
||||||
const int opcodeActivate = 0x2000075;
|
const int opcodeActivate = 0x2000075;
|
||||||
|
const int opcodeActivateExplicit = 0x2000244;
|
||||||
const int opcodeLock = 0x20004;
|
const int opcodeLock = 0x20004;
|
||||||
const int opcodeLockExplicit = 0x20005;
|
const int opcodeLockExplicit = 0x20005;
|
||||||
const int opcodeUnlock = 0x200008c;
|
const int opcodeUnlock = 0x200008c;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user