2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOS_MOTIONMASTER_H
20 #define MANGOS_MOTIONMASTER_H
26 class MovementGenerator
;
29 // Creature Entry ID used for waypoints show, visible only for GMs
30 #define VISUAL_WAYPOINT 1
32 // values 0 ... MAX_DB_MOTION_TYPE-1 used in DB
33 enum MovementGeneratorType
35 IDLE_MOTION_TYPE
= 0, // IdleMovementGenerator.h
36 RANDOM_MOTION_TYPE
= 1, // RandomMovementGenerator.h
37 WAYPOINT_MOTION_TYPE
= 2, // WaypointMovementGenerator.h
38 MAX_DB_MOTION_TYPE
= 3, // *** this and below motion types can't be set in DB.
39 ANIMAL_RANDOM_MOTION_TYPE
= MAX_DB_MOTION_TYPE
, // AnimalRandomMovementGenerator.h
40 CONFUSED_MOTION_TYPE
= 4, // ConfusedMovementGenerator.h
41 TARGETED_MOTION_TYPE
= 5, // TargetedMovementGenerator.h
42 HOME_MOTION_TYPE
= 6, // HomeMovementGenerator.h
43 FLIGHT_MOTION_TYPE
= 7, // WaypointMovementGenerator.h
44 POINT_MOTION_TYPE
= 8, // PointMovementGenerator.h
45 FLEEING_MOTION_TYPE
= 9, // FleeingMovementGenerator.h
46 DISTRACT_MOTION_TYPE
= 10, // IdleMovementGenerator.h
52 MMCF_UPDATE
= 1, // Clear or Expire called from update
53 MMCF_RESET
= 2 // Flag if need top()->Reset()
56 class MANGOS_DLL_SPEC MotionMaster
: private std::stack
<MovementGenerator
*>
59 typedef std::stack
<MovementGenerator
*> Impl
;
60 typedef std::vector
<MovementGenerator
*> ExpireList
;
63 explicit MotionMaster(Unit
*unit
) : i_owner(unit
), m_expList(NULL
), m_cleanFlag(MMCF_NONE
) {}
68 MovementGenerator
* operator->(void) { return top(); }
73 typedef Impl::container_type::const_iterator const_iterator
;
74 const_iterator
begin() const { return Impl::c
.begin(); }
75 const_iterator
end() const { return Impl::c
.end(); }
77 void UpdateMotion(uint32 diff
);
78 void Clear(bool reset
= true)
80 if (m_cleanFlag
& MMCF_UPDATE
)
83 m_cleanFlag
|= MMCF_RESET
;
85 m_cleanFlag
&= ~MMCF_RESET
;
91 void MovementExpired(bool reset
= true)
93 if (m_cleanFlag
& MMCF_UPDATE
)
96 m_cleanFlag
|= MMCF_RESET
;
98 m_cleanFlag
&= ~MMCF_RESET
;
106 void MoveTargetedHome();
107 void MoveFollow(Unit
* target
, float dist
, float angle
);
108 void MoveChase(Unit
* target
, float dist
= 0.0f
, float angle
= 0.0f
);
110 void MoveFleeing(Unit
* enemy
);
111 void MovePoint(uint32 id
, float x
,float y
,float z
);
112 void MoveTaxiFlight(uint32 path
, uint32 pathnode
);
113 void MoveDistract(uint32 time
);
115 MovementGeneratorType
GetCurrentMovementGeneratorType() const;
117 void propagateSpeedChange();
119 bool GetDestination(float &x
, float &y
, float &z
);
121 void Mutate(MovementGenerator
*m
); // use Move* functions instead
123 void DirectClean(bool reset
);
126 void DirectExpire(bool reset
);
127 void DelayedExpire();
130 ExpireList
*m_expList
;