Example #1
0
void OMW::Engine::activate()
{
    if (MWBase::Environment::get().getWindowManager()->isGuiMode())
        return;

    std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();

    if (handle.empty())
        return;

    MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaHandle (handle);

    if (ptr.isEmpty())
        return;

    MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);

    boost::shared_ptr<MWWorld::Action> action =
        MWWorld::Class::get (ptr).activate (ptr, MWBase::Environment::get().getWorld()->getPlayer().getPlayer());

    interpreterContext.activate (ptr, action);

    std::string script = MWWorld::Class::get (ptr).getScript (ptr);

    if (!script.empty())
    {
        MWBase::Environment::get().getWorld()->getLocalScripts().setIgnore (ptr);
        MWBase::Environment::get().getScriptManager()->run (script, interpreterContext);
    }

    if (!interpreterContext.hasActivationBeenHandled())
    {
        interpreterContext.executeActivation();
    }
}
Example #2
0
void OMW::Engine::activate()
{
    std::string handle = mEnvironment.mWorld->getFacedHandle();

    if (handle.empty())
        return;

    MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);

    if (ptr.isEmpty())
        return;

    MWScript::InterpreterContext interpreterContext (mEnvironment,
        &ptr.getRefData().getLocals(), ptr);

    boost::shared_ptr<MWWorld::Action> action =
        MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(),
        mEnvironment);

    interpreterContext.activate (ptr, action);

    std::string script = MWWorld::Class::get (ptr).getScript (ptr);

    if (!script.empty())
    {
        mEnvironment.mWorld->getLocalScripts().setIgnore (ptr);
        mScriptManager->run (script, interpreterContext);
    }

    if (!interpreterContext.hasActivationBeenHandled())
    {
        interpreterContext.executeActivation();
    }
}
Example #3
0
void OMW::Engine::activate()
{
    if (MWBase::Environment::get().getWindowManager()->isGuiMode())
        return;

    MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getFacedObject();

    if (ptr.isEmpty())
        return;

    if (ptr.getClass().getName(ptr) == "") // objects without name presented to user can never be activated
        return;

    MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);

    interpreterContext.activate (ptr);

    std::string script = ptr.getClass().getScript (ptr);

    MWBase::Environment::get().getWorld()->breakInvisibility(MWBase::Environment::get().getWorld()->getPlayerPtr());

    if (!script.empty())
    {
        MWBase::Environment::get().getWorld()->getLocalScripts().setIgnore (ptr);
        MWBase::Environment::get().getScriptManager()->run (script, interpreterContext);
    }

    if (!interpreterContext.hasActivationBeenHandled())
    {
        interpreterContext.executeActivation(ptr);
    }
}
Example #4
0
void OMW::Engine::activate()
{
    if (MWBase::Environment::get().getWindowManager()->getMode()!=MWGui::GM_Game)
        return;

    std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();

    if (handle.empty())
        return;

    // the faced handle is not updated immediately, so on a cell change it might
    // point to an object that doesn't exist anymore
    // therefore, we are catching the "Unknown Ogre handle" exception that occurs in this case
    MWWorld::Ptr ptr;
    try
    {
        ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle);

        if (ptr.isEmpty())
            return;
    }
    catch (std::runtime_error&)
    {
        return;
    }

    MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);

    boost::shared_ptr<MWWorld::Action> action =
        MWWorld::Class::get (ptr).activate (ptr, MWBase::Environment::get().getWorld()->getPlayer().getPlayer());

    interpreterContext.activate (ptr, action);

    std::string script = MWWorld::Class::get (ptr).getScript (ptr);

    if (!script.empty())
    {
        MWBase::Environment::get().getWorld()->getLocalScripts().setIgnore (ptr);
        MWBase::Environment::get().getScriptManager()->run (script, interpreterContext);
    }

    if (!interpreterContext.hasActivationBeenHandled())
    {
        interpreterContext.executeActivation();
    }
}
Example #5
0
void OMW::Engine::activate()
{
    // TODO: This is only a workaround. The input dispatcher should catch any exceptions thrown inside
    // the input handling functions. Looks like this will require an OpenEngine modification.
    try
    {
        std::string handle = mEnvironment.mWorld->getFacedHandle();

        if (handle.empty())
            return;

        MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);

        if (ptr.isEmpty())
            return;

        MWScript::InterpreterContext interpreterContext (mEnvironment,
            &ptr.getRefData().getLocals(), ptr);

        boost::shared_ptr<MWWorld::Action> action =
            MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(),
            mEnvironment);

        interpreterContext.activate (ptr, action);

        std::string script = MWWorld::Class::get (ptr).getScript (ptr);

        if (!script.empty())
        {
            mIgnoreLocalPtr = ptr;
            mScriptManager->run (script, interpreterContext);
        }

        if (!interpreterContext.hasActivationBeenHandled())
        {
            interpreterContext.executeActivation();
        }
    }
    catch (const std::exception& e)
    {
        std::cerr << "Activation failed: " << e.what() << std::endl;
    }
}