2 * Copyright (C) 2005-2008 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_TRAVELLER_H
20 #define MANGOS_TRAVELLER_H
22 #include "MapManager.h"
27 /** Traveller is a wrapper for units (creatures or players) that
28 * travel from point A to point B using the destination holder.
30 #define PLAYER_FLIGHT_SPEED 32.0f
33 struct MANGOS_DLL_DECL Traveller
36 Traveller(T
&t
) : i_traveller(t
) {}
37 Traveller(const Traveller
&obj
) : i_traveller(obj
) {}
38 Traveller
& operator=(const Traveller
&obj
)
41 new (this) Traveller(obj
);
45 operator T
&(void) { return i_traveller
; }
46 operator const T
&(void) { return i_traveller
; }
47 inline float GetPositionX() const { return i_traveller
.GetPositionX(); }
48 inline float GetPositionY() const { return i_traveller
.GetPositionY(); }
49 inline float GetPositionZ() const { return i_traveller
.GetPositionZ(); }
50 inline T
& GetTraveller(void) { return i_traveller
; }
52 float Speed(void) { assert(false); return 0.0f
; }
53 void Relocation(float x
, float y
, float z
, float orientation
) {}
54 void Relocation(float x
, float y
, float z
) { Relocation(x
, y
, z
, i_traveller
.GetOrientation()); }
55 void MoveTo(float x
, float y
, float z
, uint32 t
) {}
58 // specialization for creatures
60 inline float Traveller
<Creature
>::Speed()
62 return i_traveller
.GetSpeed( i_traveller
.HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE
) ? MOVE_WALK
: MOVE_RUN
);
66 inline void Traveller
<Creature
>::Relocation(float x
, float y
, float z
, float orientation
)
68 MapManager::Instance().GetMap(i_traveller
.GetMapId(), &i_traveller
)->CreatureRelocation(&i_traveller
, x
, y
, z
, orientation
);
72 inline void Traveller
<Creature
>::MoveTo(float x
, float y
, float z
, uint32 t
)
74 i_traveller
.AI_SendMoveToPacket(x
, y
, z
, t
, i_traveller
.GetUnitMovementFlags(), 0);
77 // specialization for players
79 inline float Traveller
<Player
>::Speed()
81 if (i_traveller
.isInFlight())
82 return PLAYER_FLIGHT_SPEED
;
84 return i_traveller
.GetSpeed(i_traveller
.HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE
) ? MOVE_WALK
: MOVE_RUN
);
88 inline void Traveller
<Player
>::Relocation(float x
, float y
, float z
, float orientation
)
90 MapManager::Instance().GetMap(i_traveller
.GetMapId(), &i_traveller
)->PlayerRelocation(&i_traveller
, x
, y
, z
, orientation
);
94 inline void Traveller
<Player
>::MoveTo(float x
, float y
, float z
, uint32 t
)
96 //Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags
97 i_traveller
.SendMonsterMove(x
, y
, z
, 0, MOVEMENTFLAG_WALK_MODE
, t
);
100 typedef Traveller
<Creature
> CreatureTraveller
;
101 typedef Traveller
<Player
> PlayerTraveller
;