2008-10-02 16:23:55 -05:00
|
|
|
/*
|
2008-10-23 03:29:52 -05:00
|
|
|
* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
|
2008-10-14 11:57:03 -05:00
|
|
|
*
|
2008-10-23 03:29:52 -05:00
|
|
|
* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
|
2008-10-02 16:23:55 -05:00
|
|
|
*
|
|
|
|
|
* 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
|
2008-10-14 11:57:03 -05:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-10-02 16:23:55 -05:00
|
|
|
* 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
|
2008-10-14 11:57:03 -05:00
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2008-10-02 16:23:55 -05:00
|
|
|
*/
|
|
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
#ifndef TRINITY_MOTIONMASTER_H
|
|
|
|
|
#define TRINITY_MOTIONMASTER_H
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
#include <stack>
|
|
|
|
|
|
|
|
|
|
class MovementGenerator;
|
|
|
|
|
class Unit;
|
|
|
|
|
|
|
|
|
|
// Creature Entry ID used for waypoints show, visible only for GMs
|
|
|
|
|
#define VISUAL_WAYPOINT 1
|
|
|
|
|
|
|
|
|
|
// values 0 ... MAX_DB_MOTION_TYPE-1 used in DB
|
|
|
|
|
enum MovementGeneratorType
|
|
|
|
|
{
|
|
|
|
|
IDLE_MOTION_TYPE = 0, // IdleMovementGenerator.h
|
|
|
|
|
RANDOM_MOTION_TYPE = 1, // RandomMovementGenerator.h
|
|
|
|
|
WAYPOINT_MOTION_TYPE = 2, // WaypointMovementGenerator.h
|
|
|
|
|
MAX_DB_MOTION_TYPE = 3, // *** this and below motion types can't be set in DB.
|
|
|
|
|
ANIMAL_RANDOM_MOTION_TYPE = MAX_DB_MOTION_TYPE, // AnimalRandomMovementGenerator.h
|
|
|
|
|
CONFUSED_MOTION_TYPE = 4, // ConfusedMovementGenerator.h
|
|
|
|
|
TARGETED_MOTION_TYPE = 5, // TargetedMovementGenerator.h
|
|
|
|
|
HOME_MOTION_TYPE = 6, // HomeMovementGenerator.h
|
|
|
|
|
FLIGHT_MOTION_TYPE = 7, // WaypointMovementGenerator.h
|
|
|
|
|
POINT_MOTION_TYPE = 8, // PointMovementGenerator.h
|
|
|
|
|
FLEEING_MOTION_TYPE = 9, // FleeingMovementGenerator.h
|
|
|
|
|
DISTRACT_MOTION_TYPE = 10, // IdleMovementGenerator.h
|
|
|
|
|
};
|
|
|
|
|
|
2009-01-16 22:57:03 -06:00
|
|
|
enum MovementSlot
|
|
|
|
|
{
|
|
|
|
|
MOTION_SLOT_IDLE,
|
|
|
|
|
MOTION_SLOT_ACTIVE,
|
|
|
|
|
MOTION_SLOT_CONTROLLED,
|
|
|
|
|
MAX_MOTION_SLOT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TRINITY_DLL_SPEC MotionMaster //: private std::stack<MovementGenerator *>
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
|
|
|
|
private:
|
2009-01-16 22:57:03 -06:00
|
|
|
//typedef std::stack<MovementGenerator *> Impl;
|
|
|
|
|
typedef MovementGenerator* _Ty;
|
|
|
|
|
_Ty Impl[MAX_MOTION_SLOT];
|
|
|
|
|
int i_top;
|
|
|
|
|
|
|
|
|
|
bool empty() const { return i_top < 0; }
|
|
|
|
|
void pop() { Impl[i_top] = NULL; --i_top; }
|
|
|
|
|
void push(_Ty _Val) { ++i_top; Impl[i_top] = _Val; }
|
2008-10-02 16:23:55 -05:00
|
|
|
public:
|
|
|
|
|
|
2009-01-16 22:57:03 -06:00
|
|
|
explicit MotionMaster(Unit *unit) : i_owner(unit), i_top(-1) {}
|
2008-10-02 16:23:55 -05:00
|
|
|
~MotionMaster();
|
|
|
|
|
|
|
|
|
|
void Initialize();
|
|
|
|
|
|
2009-01-16 22:57:03 -06:00
|
|
|
//MovementGenerator* operator->(void) { return top(); }
|
2008-10-02 16:23:55 -05:00
|
|
|
|
2009-01-17 00:00:48 -06:00
|
|
|
int size() const { return i_top + 1; }
|
2009-01-16 22:57:03 -06:00
|
|
|
_Ty top() const { return Impl[i_top]; }
|
2009-01-17 00:00:48 -06:00
|
|
|
_Ty GetMotionSlot(int slot) { return Impl[slot]; }
|
2009-01-16 22:57:03 -06:00
|
|
|
/*using Impl::top;
|
2008-10-02 16:23:55 -05:00
|
|
|
using Impl::empty;
|
|
|
|
|
|
|
|
|
|
typedef Impl::container_type::const_iterator const_iterator;
|
|
|
|
|
const_iterator begin() const { return Impl::c.begin(); }
|
2009-01-16 22:57:03 -06:00
|
|
|
const_iterator end() const { return Impl::c.end(); }*/
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
void UpdateMotion(const uint32 &diff);
|
|
|
|
|
void Clear(bool reset = true);
|
|
|
|
|
void MovementExpired(bool reset = true);
|
|
|
|
|
|
2009-01-16 22:57:03 -06:00
|
|
|
void MoveIdle(MovementSlot slot = MOTION_SLOT_ACTIVE);
|
2008-10-02 16:23:55 -05:00
|
|
|
void MoveTargetedHome();
|
2008-12-19 00:37:40 +02:00
|
|
|
void MoveRandom(float spawndist = 0.0f);
|
|
|
|
|
void MoveFollow(Unit* target, float dist, float angle);
|
2008-10-02 16:23:55 -05:00
|
|
|
void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f);
|
|
|
|
|
void MoveConfused();
|
|
|
|
|
void MoveFleeing(Unit* enemy);
|
|
|
|
|
void MovePoint(uint32 id, float x,float y,float z);
|
|
|
|
|
void MoveTaxiFlight(uint32 path, uint32 pathnode);
|
|
|
|
|
void MoveDistract(uint32 time);
|
2008-12-10 06:34:35 +02:00
|
|
|
void MovePath(uint32 path_id, bool repeatable);
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
MovementGeneratorType GetCurrentMovementGeneratorType() const;
|
|
|
|
|
|
|
|
|
|
void propagateSpeedChange();
|
|
|
|
|
|
|
|
|
|
bool GetDestination(float &x, float &y, float &z);
|
|
|
|
|
private:
|
2009-01-16 22:57:03 -06:00
|
|
|
void Mutate(MovementGenerator *m, MovementSlot slot); // use Move* functions instead
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
Unit *i_owner;
|
|
|
|
|
};
|
|
|
|
|
#endif
|