TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
VehicleDefines.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __TRINITY_VEHICLEDEFINES_H
20 #define __TRINITY_VEHICLEDEFINES_H
21 
22 #include "Define.h"
23 #include <vector>
24 #include <map>
25 
26 struct VehicleSeatEntry;
27 
29 {
32  POWER_HEAT = 101,
33  POWER_OOZE = 121,
34  POWER_BLOOD = 141,
35  POWER_WRATH = 142,
50  POWER_FUEL = 165,
53  POWER_VENOM = 174,
58 };
59 
61 {
62  VEHICLE_FLAG_NO_STRAFE = 0x00000001, // Sets MOVEFLAG2_NO_STRAFE
63  VEHICLE_FLAG_NO_JUMPING = 0x00000002, // Sets MOVEFLAG2_NO_JUMPING
64  VEHICLE_FLAG_FULLSPEEDTURNING = 0x00000004, // Sets MOVEFLAG2_FULLSPEEDTURNING
65  VEHICLE_FLAG_ALLOW_PITCHING = 0x00000010, // Sets MOVEFLAG2_ALLOW_PITCHING
66  VEHICLE_FLAG_FULLSPEEDPITCHING = 0x00000020, // Sets MOVEFLAG2_FULLSPEEDPITCHING
67  VEHICLE_FLAG_CUSTOM_PITCH = 0x00000040, // If set use pitchMin and pitchMax from DBC, otherwise pitchMin = -pi/2, pitchMax = pi/2
68  VEHICLE_FLAG_ADJUST_AIM_ANGLE = 0x00000400, // Lua_IsVehicleAimAngleAdjustable
69  VEHICLE_FLAG_ADJUST_AIM_POWER = 0x00000800 // Lua_IsVehicleAimPowerAdjustable
70 };
71 
73 {
76 };
77 
79 {
82 
83  void Reset()
84  {
85  Guid.Clear();
86  IsUnselectable = false;
87  }
88 };
89 
91 {
92  explicit VehicleSeat(VehicleSeatEntry const* seatInfo) : SeatInfo(seatInfo)
93  {
94  Passenger.Reset();
95  }
96 
97  bool IsEmpty() const { return Passenger.Guid.IsEmpty(); }
98 
101 };
102 
104 {
105  VehicleAccessory(uint32 entry, int8 seatId, bool isMinion, uint8 summonType, uint32 summonTime) :
106  AccessoryEntry(entry), IsMinion(isMinion), SummonTime(summonTime), SeatId(seatId), SummonedType(summonType) { }
108  bool IsMinion;
112 };
113 
114 typedef std::vector<VehicleAccessory> VehicleAccessoryList;
115 typedef std::map<ObjectGuid::LowType, VehicleAccessoryList> VehicleAccessoryContainer;
116 typedef std::map<uint32, VehicleAccessoryList> VehicleAccessoryTemplateContainer;
117 typedef std::map<int8, VehicleSeat> SeatMap;
118 
120 {
121 protected:
123  virtual ~TransportBase() { }
124 
125 public:
127  virtual void CalculatePassengerPosition(float& x, float& y, float& z, float* o = NULL) const = 0;
128 
130  virtual void CalculatePassengerOffset(float& x, float& y, float& z, float* o = NULL) const = 0;
131 
132  static void CalculatePassengerPosition(float& x, float& y, float& z, float* o, float transX, float transY, float transZ, float transO)
133  {
134  float inx = x, iny = y, inz = z;
135  if (o)
136  *o = Position::NormalizeOrientation(transO + *o);
137 
138  x = transX + inx * std::cos(transO) - iny * std::sin(transO);
139  y = transY + iny * std::cos(transO) + inx * std::sin(transO);
140  z = transZ + inz;
141  }
142 
143  static void CalculatePassengerOffset(float& x, float& y, float& z, float* o, float transX, float transY, float transZ, float transO)
144  {
145  if (o)
146  *o = Position::NormalizeOrientation(*o - transO);
147 
148  z -= transZ;
149  y -= transY; // y = searchedY * std::cos(o) + searchedX * std::sin(o)
150  x -= transX; // x = searchedX * std::cos(o) + searchedY * std::sin(o + pi)
151  float inx = x, iny = y;
152  y = (iny - inx * std::tan(transO)) / (std::cos(transO) + std::sin(transO) * std::tan(transO));
153  x = (inx + iny * std::tan(transO)) / (std::cos(transO) + std::sin(transO) * std::tan(transO));
154  }
155 };
156 
157 #endif
Definition: DBCStructure.h:1305
Definition: VehicleDefines.h:66
std::vector< VehicleAccessory > VehicleAccessoryList
Definition: VehicleDefines.h:114
Definition: VehicleDefines.h:48
VehicleSeat(VehicleSeatEntry const *seatInfo)
Definition: VehicleDefines.h:92
int8_t int8
Definition: Define.h:148
Definition: VehicleDefines.h:37
VehicleSpells
Definition: VehicleDefines.h:72
uint32 SummonTime
Definition: VehicleDefines.h:109
Definition: VehicleDefines.h:30
Definition: VehicleDefines.h:103
Definition: VehicleDefines.h:57
Definition: VehicleDefines.h:42
Definition: VehicleDefines.h:34
std::map< ObjectGuid::LowType, VehicleAccessoryList > VehicleAccessoryContainer
Definition: VehicleDefines.h:115
Definition: VehicleDefines.h:50
arena_t NULL
Definition: jemalloc_internal.h:624
virtual void CalculatePassengerOffset(float &x, float &y, float &z, float *o=NULL) const =0
This method transforms supplied global coordinates into local offsets.
Definition: VehicleDefines.h:78
Definition: VehicleDefines.h:74
uint32 AccessoryEntry
Definition: VehicleDefines.h:107
static float NormalizeOrientation(float o)
Definition: Position.h:211
Definition: VehicleDefines.h:47
Definition: VehicleDefines.h:119
Definition: VehicleDefines.h:38
Definition: VehicleDefines.h:41
TransportBase()
Definition: VehicleDefines.h:122
Definition: VehicleDefines.h:32
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=NULL) const =0
This method transforms supplied transport offsets into global coordinates.
Definition: VehicleDefines.h:31
int8 SeatId
Definition: VehicleDefines.h:110
Definition: VehicleDefines.h:49
Definition: VehicleDefines.h:68
Definition: VehicleDefines.h:64
Definition: VehicleDefines.h:55
virtual ~TransportBase()
Definition: VehicleDefines.h:123
std::map< int8, VehicleSeat > SeatMap
Definition: VehicleDefines.h:117
Definition: VehicleDefines.h:67
Definition: VehicleDefines.h:53
Definition: VehicleDefines.h:65
Definition: VehicleDefines.h:33
VehicleSeatEntry const * SeatInfo
Definition: VehicleDefines.h:99
Definition: VehicleDefines.h:35
G3D::int16 z
Definition: Vector3int16.h:46
std::map< uint32, VehicleAccessoryList > VehicleAccessoryTemplateContainer
Definition: VehicleDefines.h:116
bool IsMinion
Definition: VehicleDefines.h:108
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
uint8 SummonedType
Definition: VehicleDefines.h:111
Definition: VehicleDefines.h:36
Definition: VehicleDefines.h:43
Definition: VehicleDefines.h:54
PassengerInfo Passenger
Definition: VehicleDefines.h:100
Definition: VehicleDefines.h:39
void Clear()
Definition: ObjectGuid.h:215
bool IsUnselectable
Definition: VehicleDefines.h:81
Definition: VehicleDefines.h:40
void Reset()
Definition: VehicleDefines.h:83
Definition: VehicleDefines.h:75
VehicleFlags
Definition: VehicleDefines.h:60
ObjectGuid Guid
Definition: VehicleDefines.h:80
Definition: VehicleDefines.h:63
Definition: VehicleDefines.h:45
uint8_t uint8
Definition: Define.h:152
Definition: VehicleDefines.h:46
Definition: VehicleDefines.h:51
Definition: VehicleDefines.h:90
Definition: ObjectGuid.h:189
VehicleAccessory(uint32 entry, int8 seatId, bool isMinion, uint8 summonType, uint32 summonTime)
Definition: VehicleDefines.h:105
G3D::int16 x
Definition: Vector2int16.h:37
static void CalculatePassengerPosition(float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
Definition: VehicleDefines.h:132
Definition: VehicleDefines.h:44
Definition: VehicleDefines.h:52
bool IsEmpty() const
Definition: VehicleDefines.h:97
Definition: VehicleDefines.h:56
bool IsEmpty() const
Definition: ObjectGuid.h:242
PowerType
Definition: VehicleDefines.h:28
Definition: VehicleDefines.h:62
Definition: VehicleDefines.h:69
static void CalculatePassengerOffset(float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
Definition: VehicleDefines.h:143