|
|
|
@ -9,6 +9,13 @@
|
|
|
|
|
#include "aifollow.hpp"
|
|
|
|
|
#include "aiactivate.hpp"
|
|
|
|
|
|
|
|
|
|
#include "..\mwworld\class.hpp"
|
|
|
|
|
#include "creaturestats.hpp"
|
|
|
|
|
#include "npcstats.hpp"
|
|
|
|
|
#include "..\mwbase\environment.hpp"
|
|
|
|
|
#include "..\mwbase\world.hpp"
|
|
|
|
|
#include "..\mwworld\player.hpp"
|
|
|
|
|
|
|
|
|
|
void MWMechanics::AiSequence::copy (const AiSequence& sequence)
|
|
|
|
|
{
|
|
|
|
|
for (std::list<AiPackage *>::const_iterator iter (sequence.mPackages.begin());
|
|
|
|
@ -54,6 +61,50 @@ bool MWMechanics::AiSequence::isPackageDone() const
|
|
|
|
|
|
|
|
|
|
void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor)
|
|
|
|
|
{
|
|
|
|
|
/*if(actor != MWBase::Environment::get().getWorld()->getPlayer().getPlayer())
|
|
|
|
|
{
|
|
|
|
|
MWMechanics::DrawState_ state = MWWorld::Class::get(actor).getNpcStats(actor).getDrawState();
|
|
|
|
|
if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing)
|
|
|
|
|
MWWorld::Class::get(actor).getNpcStats(actor).setDrawState(MWMechanics::DrawState_Weapon);
|
|
|
|
|
MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(true);
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
|
|
|
ESM::Position pos = actor.getRefData().getPosition();
|
|
|
|
|
const ESM::Pathgrid *pathgrid =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*actor.getCell()->mCell);
|
|
|
|
|
|
|
|
|
|
int cellX = actor.getCell()->mCell->mData.mX;
|
|
|
|
|
int cellY = actor.getCell()->mCell->mData.mY;
|
|
|
|
|
float xCell = 0;
|
|
|
|
|
float yCell = 0;
|
|
|
|
|
|
|
|
|
|
if (actor.getCell()->mCell->isExterior())
|
|
|
|
|
{
|
|
|
|
|
xCell = actor.getCell()->mCell->mData.mX * ESM::Land::REAL_SIZE;
|
|
|
|
|
yCell = actor.getCell()->mCell->mData.mY * ESM::Land::REAL_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ESM::Pathgrid::Point dest;
|
|
|
|
|
dest.mX = player.getRefData().getPosition().pos[0];
|
|
|
|
|
dest.mY = player.getRefData().getPosition().pos[1];
|
|
|
|
|
dest.mZ = player.getRefData().getPosition().pos[2];
|
|
|
|
|
|
|
|
|
|
ESM::Pathgrid::Point start;
|
|
|
|
|
start.mX = pos.pos[0];
|
|
|
|
|
start.mY = pos.pos[1];
|
|
|
|
|
start.mZ = pos.pos[2];
|
|
|
|
|
|
|
|
|
|
PathFinder mPathFinder;
|
|
|
|
|
mPathFinder.buildPath(start, dest, pathgrid, xCell, yCell, true);
|
|
|
|
|
float zAngle = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]);
|
|
|
|
|
MWBase::Environment::get().getWorld()->rotateObject(actor, 0, 0, zAngle, false);
|
|
|
|
|
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 1;
|
|
|
|
|
|
|
|
|
|
if(dest.mX - start.mX < 100)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(false);
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
if (!mPackages.empty())
|
|
|
|
|
{
|
|
|
|
|
if (mPackages.front()->execute (actor))
|
|
|
|
|