Index: src/game/AggressorAI.cpp =================================================================== --- src/game/AggressorAI.cpp (revision 5609) +++ src/game/AggressorAI.cpp (working copy) @@ -21,6 +21,7 @@ #include "Creature.h" #include "Player.h" #include "TargetedMovementGenerator.h" +#include "PointMovementGenerator.h" #include "ObjectAccessor.h" #include "VMapFactory.h" #include "World.h" Index: src/game/CreatureAI.h =================================================================== --- src/game/CreatureAI.h (revision 5609) +++ src/game/CreatureAI.h (working copy) @@ -81,6 +81,8 @@ // Called when creature is spawned or respawned (for reseting variables) virtual void JustRespawned() {} + + virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {} }; struct SelectableAI : public FactoryHolder, public Permissible Index: src/game/MotionMaster.h =================================================================== --- src/game/MotionMaster.h (revision 5609) +++ src/game/MotionMaster.h (working copy) @@ -38,7 +38,8 @@ CONFUSED_MOTION_TYPE = 4, // ConfusedMovementGenerator.h TARGETED_MOTION_TYPE = 5, // TargetedMovementGenerator.h HOME_MOTION_TYPE = 6, // HomeMovementGenerator.h - FLIGHT_MOTION_TYPE = 7 // WaypointMovementGenerator.h + FLIGHT_MOTION_TYPE = 7, // WaypointMovementGenerator.h + POINT_MOTION_TYPE = 8, // PointMovementGenerator.h }; class MANGOS_DLL_SPEC MotionMaster : private std::stack Index: src/game/PointMovementGenerator.cpp =================================================================== --- src/game/PointMovementGenerator.cpp (revision 0) +++ src/game/PointMovementGenerator.cpp (revision 0) @@ -0,0 +1,96 @@ +/* +* Copyright (C) 2005-2008 MaNGOS +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "PointMovementGenerator.h" +#include "Errors.h" +#include "Creature.h" +#include "CreatureAI.h" +#include "MapManager.h" +#include "DestinationHolderImp.h" + +//----- Point Movement Generator +template +bool PointMovementGenerator::Update(T &unit, const uint32 &diff) +{ + if(!&unit) + return false; + + if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED)) + return true; + + Traveller traveller(unit); + + i_destinationHolder.UpdateTraveller(traveller, diff, false); + + if(i_destinationHolder.HasArrived()) + { + unit.StopMoving(); + MovementInform(unit); + return false; + } + + return true; +} + +template +void PointMovementGenerator::Initialize(T &unit) +{ + unit.StopMoving(); + Traveller traveller(unit); + i_destinationHolder.SetDestination(traveller,x,y,z); +} + +template +void PointMovementGenerator::MovementInform(T &unit) +{ + +} + +void PointMovementGenerator::MovementInform(Creature &unit) +{ + unit.AI()->MovementInform(POINT_MOTION_TYPE, id); +} + +bool PointMovementGenerator::Update(Creature &unit, const uint32 &diff) +{ + if(!&unit) + return false; + + if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED)) + return true; + + Traveller traveller(unit); + + i_destinationHolder.UpdateTraveller(traveller, diff, false); + + if(i_destinationHolder.HasArrived()) + { + unit.StopMoving(); + MovementInform(unit); + return false; + } + + return true; +} + +void PointMovementGenerator::Initialize(Creature &unit) +{ + unit.StopMoving(); + Traveller traveller(unit); + i_destinationHolder.SetDestination(traveller,x,y,z); +} \ No newline at end of file Index: src/game/PointMovementGenerator.h =================================================================== --- src/game/PointMovementGenerator.h (revision 0) +++ src/game/PointMovementGenerator.h (revision 0) @@ -0,0 +1,50 @@ +/* +* Copyright (C) 2005-2008 MaNGOS +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef MANGOS_POINTMOVEMENTGENERATOR_H +#define MANGOS_POINTMOVEMENTGENERATOR_H + +#include "MovementGenerator.h" +#include "DestinationHolder.h" +#include "Traveller.h" +#include "FollowerReference.h" + +template +class MANGOS_DLL_SPEC PointMovementGenerator + : public MovementGeneratorMedium< T, PointMovementGenerator > +{ +public: + PointMovementGenerator(uint32 _id, float _x, float _y, float _z) : id(_id), + x(_x), y(_y), z(_z), i_nextMoveTime(0) {} + + void Initialize(T &); + void Finalize(T &) {} + void Reset(T &unit) { unit.StopMoving(); } + bool Update(T &, const uint32 &diff); + + void MovementInform(T &); + + MovementGeneratorType GetMovementGeneratorType() { return POINT_MOTION_TYPE; } + +private: + TimeTracker i_nextMoveTime; + float x,y,z; + uint32 id; + DestinationHolder< Traveller > i_destinationHolder; +}; +#endif Index: win/VC90/game.vcproj =================================================================== --- win/VC90/game.vcproj (revision 5609) +++ win/VC90/game.vcproj (working copy) @@ -1,7 +1,7 @@ + + + +