root/trunk/src/game/MotionMaster.h @ 52

Revision 44, 3.6 kB (checked in by yumileroy, 17 years ago)

[svn] * Merge Temp dev SVN with Assembla.
* Changes include:

  • Implementation of w12x's Outdoor PvP and Game Event Systems.
  • Temporary removal of IRC Chat Bot (until infinite loop when disabled is fixed).
  • All mangos -> trinity (to convert your mangos_string table, please run mangos_string_to_trinity_string.sql).
  • Improved Config cleanup.
  • And many more changes.

Original author: Seline
Date: 2008-10-14 11:57:03-05:00

Line 
1/*
2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
3 *
4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef TRINITY_MOTIONMASTER_H
22#define TRINITY_MOTIONMASTER_H
23
24#include "Common.h"
25#include <stack>
26
27class MovementGenerator;
28class Unit;
29
30// Creature Entry ID used for waypoints show, visible only for GMs
31#define VISUAL_WAYPOINT 1
32
33// values 0 ... MAX_DB_MOTION_TYPE-1 used in DB
34enum MovementGeneratorType
35{
36    IDLE_MOTION_TYPE      = 0,                              // IdleMovementGenerator.h
37    RANDOM_MOTION_TYPE    = 1,                              // RandomMovementGenerator.h
38    WAYPOINT_MOTION_TYPE  = 2,                              // WaypointMovementGenerator.h
39    MAX_DB_MOTION_TYPE    = 3,                              // *** this and below motion types can't be set in DB.
40    ANIMAL_RANDOM_MOTION_TYPE = MAX_DB_MOTION_TYPE,         // AnimalRandomMovementGenerator.h
41    CONFUSED_MOTION_TYPE  = 4,                              // ConfusedMovementGenerator.h
42    TARGETED_MOTION_TYPE  = 5,                              // TargetedMovementGenerator.h
43    HOME_MOTION_TYPE      = 6,                              // HomeMovementGenerator.h
44    FLIGHT_MOTION_TYPE    = 7,                              // WaypointMovementGenerator.h
45    POINT_MOTION_TYPE     = 8,                              // PointMovementGenerator.h
46    FLEEING_MOTION_TYPE   = 9,                              // FleeingMovementGenerator.h
47    DISTRACT_MOTION_TYPE  = 10,                             // IdleMovementGenerator.h
48};
49
50class TRINITY_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *>
51{
52    private:
53        typedef std::stack<MovementGenerator *> Impl;
54    public:
55
56        explicit MotionMaster(Unit *unit) : i_owner(unit) {}
57        ~MotionMaster();
58
59        void Initialize();
60
61        MovementGenerator* operator->(void) { return top(); }
62
63        using Impl::top;
64        using Impl::empty;
65
66        typedef Impl::container_type::const_iterator const_iterator;
67        const_iterator begin() const { return Impl::c.begin(); }
68        const_iterator end() const { return Impl::c.end(); }
69
70        void UpdateMotion(const uint32 &diff);
71        void Clear(bool reset = true);
72        void MovementExpired(bool reset = true);
73
74        void MoveIdle();
75        void MoveTargetedHome();
76        void MoveFollow(Unit* target, float dist, float angle);
77        void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f);
78        void MoveConfused();
79        void MoveFleeing(Unit* enemy);
80        void MovePoint(uint32 id, float x,float y,float z);
81        void MoveTaxiFlight(uint32 path, uint32 pathnode);
82        void MoveDistract(uint32 time);
83
84        MovementGeneratorType GetCurrentMovementGeneratorType() const;
85
86        void propagateSpeedChange();
87
88        bool GetDestination(float &x, float &y, float &z);
89    private:
90        void Mutate(MovementGenerator *m);                  // use Move* functions instead
91
92        Unit *i_owner;
93};
94#endif
Note: See TracBrowser for help on using the browser.