From a315d5cc2b501d7c8b766ad7a603f80ce2366507 Mon Sep 17 00:00:00 2001 From: gus Date: Fri, 14 Feb 2014 12:55:14 +0100 Subject: [PATCH] aiactivate works. Bug when you try to use it on a reference that doesn't exist. Need to clran up door.cpp --- apps/openmw/mwclass/door.cpp | 8 ++++---- apps/openmw/mwmechanics/aiactivate.cpp | 19 +++++++------------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index f99cffe04..a846a8492 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -117,19 +117,19 @@ namespace MWClass { // teleport door /// \todo remove this if clause once ActionTeleport can also support other actors - if (MWBase::Environment::get().getWorld()->getPlayerPtr()==actor) - { + //if (MWBase::Environment::get().getWorld()->getPlayerPtr()==actor) + //{ boost::shared_ptr action(new MWWorld::ActionTeleport (ref->mRef.mDestCell, ref->mRef.mDoorDest)); action->setSound(openSound); return action; - } + /*} else { // another NPC or a creature is using the door return boost::shared_ptr (new MWWorld::FailedAction); - } + }*/ } else { diff --git a/apps/openmw/mwmechanics/aiactivate.cpp b/apps/openmw/mwmechanics/aiactivate.cpp index e751140c0..667ebea88 100644 --- a/apps/openmw/mwmechanics/aiactivate.cpp +++ b/apps/openmw/mwmechanics/aiactivate.cpp @@ -6,6 +6,7 @@ #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" #include "../mwworld/class.hpp" +#include "../mwworld/action.hpp" namespace { @@ -64,19 +65,11 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration) { mCellX = cell->mData.mX; mCellY = cell->mData.mY; - float xCell = 0; - float yCell = 0; - - if(cell->isExterior()) - { - xCell = cell->mData.mX * ESM::Land::REAL_SIZE; - yCell = cell->mData.mY * ESM::Land::REAL_SIZE; - } ESM::Pathgrid::Point dest; dest.mX = targetPos.pos[0]; - dest.mY = targetPos.pos[0]; - dest.mZ = targetPos.pos[0]; + dest.mY = targetPos.pos[1]; + dest.mZ = targetPos.pos[2]; ESM::Pathgrid::Point start; start.mX = pos.pos[0]; @@ -92,7 +85,8 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration) { movement.mPosition[1] = 0; MWWorld::Ptr target = world->getPtr(mObjectId,false); - MWWorld::Class::get(target).activate(target,actor); + MWWorld::Class::get(target).activate(target,actor).get()->execute(actor); + std::cout << "activated"; return true; } @@ -100,7 +94,8 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration) { movement.mPosition[1] = 0; MWWorld::Ptr target = world->getPtr(mObjectId,false); - MWWorld::Class::get(target).activate(target,actor); + MWWorld::Class::get(target).activate(target,actor).get()->execute(actor); + std::cout << "activated"; return true; }