diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 7c28dd216..5b94c4938 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -1,6 +1,5 @@ #include "aiescort.hpp" -#include "character.hpp" #include "movement.hpp" #include "../mwworld/class.hpp" @@ -10,16 +9,12 @@ #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" -#include -#include -#include "boost/tuple/tuple.hpp" - namespace { float sgn(float a) { - if(a>0) return 1.; - else return -1.; + if(a > 0) return 1.0; + else return -1.0; } } @@ -77,11 +72,8 @@ bool MWMechanics::AiEscort::execute (const MWWorld::Ptr& actor) { MWWorld::TimeStamp current = MWBase::Environment::get().getWorld()->getTimeStamp(); unsigned int currentSecond = ((current.getHour() - int(current.getHour())) * 100); - std::cout << "AiEscort: " << currentSecond << " time: " << currentSecond - mStartingSecond << std::endl; if(currentSecond - mStartingSecond >= mDuration) - { return true; - } } ESM::Position pos = actor.getRefData().getPosition(); @@ -91,28 +83,28 @@ bool MWMechanics::AiEscort::execute (const MWWorld::Ptr& actor) MWBase::Environment::get().getWorld()->getStore().get().search(*actor.getCell()->mCell); - if(actor.getCell()->mCell->mData.mX != player.getCell()->mCell->mData.mX) + if(actor.getCell()->mCell->mData.mX != player.getCell()->mCell->mData.mX) + { + int sideX = sgn(actor.getCell()->mCell->mData.mX - player.getCell()->mCell->mData.mX); + // Check if actor is near the border of an inactive cell. If so, disable AiEscort. + // FIXME: This *should* pause the AiEscort package instead of terminating it. + if(sideX*(pos.pos[0] - actor.getCell()->mCell->mData.mX * ESM::Land::REAL_SIZE) > sideX * (ESM::Land::REAL_SIZE / 2. - 200)) { - int sideX = sgn(actor.getCell()->mCell->mData.mX - player.getCell()->mCell->mData.mX); - // Check if actor is near the border of an inactive cell. If so, disable AiEscort. - // FIXME: This *should* pause the AiEscort package instead of terminating it. - if(sideX*(pos.pos[0] - actor.getCell()->mCell->mData.mX * ESM::Land::REAL_SIZE) > sideX*(ESM::Land::REAL_SIZE/2. - 200)) - { - MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; - return true; - } + MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; + return true; } - if(actor.getCell()->mCell->mData.mY != player.getCell()->mCell->mData.mY) + } + if(actor.getCell()->mCell->mData.mY != player.getCell()->mCell->mData.mY) + { + int sideY = sgn(actor.getCell()->mCell->mData.mY - player.getCell()->mCell->mData.mY); + // Check if actor is near the border of an inactive cell. If so, disable AiEscort. + // FIXME: This *should* pause the AiEscort package instead of terminating it. + if(sideY*(pos.pos[1] - actor.getCell()->mCell->mData.mY * ESM::Land::REAL_SIZE) > sideY * (ESM::Land::REAL_SIZE / 2. - 200)) { - int sideY = sgn(actor.getCell()->mCell->mData.mY - player.getCell()->mCell->mData.mY); - // Check if actor is near the border of an inactive cell. If so, disable AiEscort. - // FIXME: This *should* pause the AiEscort package instead of terminating it. - if(sideY*(pos.pos[1] - actor.getCell()->mCell->mData.mY * ESM::Land::REAL_SIZE) > sideY*(ESM::Land::REAL_SIZE/2. - 200)) - { - MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; - return true; - } + MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; + return true; } + } if(!mPathFinder.isPathConstructed() || cellChange) diff --git a/apps/openmw/mwmechanics/aiescort.hpp b/apps/openmw/mwmechanics/aiescort.hpp index 667b88e31..3ae604035 100644 --- a/apps/openmw/mwmechanics/aiescort.hpp +++ b/apps/openmw/mwmechanics/aiescort.hpp @@ -2,30 +2,9 @@ #define GAME_MWMECHANICS_AIESCORT_H #include "aipackage.hpp" -#include "pathfinding.hpp" #include -/* From CS: -Escort - -Makes the actor escort another actor to a location or for a specified period of time. During this time the actor will also protect the actor it is escorting. - -If you are not doing this package with the player as the target, you’ll want to also put a follow package on the target Actor, since escorting an actor makes the escorter wait for the other actor. If the Target does not know they are supposed to follow, the escorter will most likely just stand there. - -Target: The ActorID to Escort. Remember that since all ActorIDs share the same AI packages, putting this on an Actor with multiple references will cause ALL references of that actor to attempt to escort the same actor. Thus, this type of AI should only be placed on specific or unique sets of Actors. - -Duration: The duration the actor should escort for. Trumped by providing a location. - -Escort to: Check this to use location data for the escort. - -Cell: The Cell to escort to. - -XYZ: Like Travel, specify the XYZ location to escort to. - -View Location: A red X will appear in the render window that you can move around with the standard render window object controls. Place the X on the escort destination. - - -*/ +#include "pathfinding.hpp" namespace MWMechanics {