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
47 ASSISTANCE_MOTION_TYPE
= 11, // PointMovementGenerator.h (first part of flee for assistance)
48 ASSISTANCE_DISTRACT_MOTION_TYPE
= 12, // IdleMovementGenerator.h (second part of flee for assistance)
49 TIMED_FLEEING_MOTION_TYPE
= 13, // FleeingMovementGenerator.h (alt.second part of flee for assistance)
55 MMCF_UPDATE
= 1, // Clear or Expire called from update
56 MMCF_RESET
= 2 // Flag if need top()->Reset()
59 class MANGOS_DLL_SPEC MotionMaster
: private std::stack
<MovementGenerator
*>
62 typedef std::stack
<MovementGenerator
*> Impl
;
63 typedef std::vector
<MovementGenerator
*> ExpireList
;
66 explicit MotionMaster(Unit
*unit
) : i_owner(unit
), m_expList(NULL
), m_cleanFlag(MMCF_NONE
) {}
71 MovementGenerator
* operator->(void) { return top(); }
76 typedef Impl::container_type::const_iterator const_iterator
;
77 const_iterator
begin() const { return Impl::c
.begin(); }
78 const_iterator
end() const { return Impl::c
.end(); }
80 void UpdateMotion(uint32 diff
);
81 void Clear(bool reset
= true)
83 if (m_cleanFlag
& MMCF_UPDATE
)
86 m_cleanFlag
|= MMCF_RESET
;
88 m_cleanFlag
&= ~MMCF_RESET
;
94 void MovementExpired(bool reset
= true)
96 if (m_cleanFlag
& MMCF_UPDATE
)
99 m_cleanFlag
|= MMCF_RESET
;
101 m_cleanFlag
&= ~MMCF_RESET
;
109 void MoveTargetedHome();
110 void MoveFollow(Unit
* target
, float dist
, float angle
);
111 void MoveChase(Unit
* target
, float dist
= 0.0f
, float angle
= 0.0f
);
113 void MoveFleeing(Unit
* enemy
, uint32 time
= 0);
114 void MovePoint(uint32 id
, float x
,float y
,float z
);
115 void MoveSeekAssistance(float x
,float y
,float z
);
116 void MoveSeekAssistanceDistract(uint32 timer
);
117 void MoveTaxiFlight(uint32 path
, uint32 pathnode
);
118 void MoveDistract(uint32 time
);
120 MovementGeneratorType
GetCurrentMovementGeneratorType() const;
122 void propagateSpeedChange();
124 bool GetDestination(float &x
, float &y
, float &z
);
126 void Mutate(MovementGenerator
*m
); // use Move* functions instead
128 void DirectClean(bool reset
);
131 void DirectExpire(bool reset
);
132 void DelayedExpire();
135 ExpireList
*m_expList
;