TrinityCore
VehicleDefines.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __TRINITY_VEHICLEDEFINES_H
19#define __TRINITY_VEHICLEDEFINES_H
20
21#include "Define.h"
22#include "Duration.h"
23#include <vector>
24#include <map>
25
26class Map;
27class WorldObject;
28struct VehicleSeatEntry;
29
31{
60};
61
63{
64 VEHICLE_FLAG_NO_STRAFE = 0x00000001, // Sets MOVEFLAG2_NO_STRAFE
65 VEHICLE_FLAG_NO_JUMPING = 0x00000002, // Sets MOVEFLAG2_NO_JUMPING
66 VEHICLE_FLAG_FULLSPEEDTURNING = 0x00000004, // Sets MOVEFLAG2_FULLSPEEDTURNING
67 VEHICLE_FLAG_ALLOW_PITCHING = 0x00000010, // Sets MOVEFLAG2_ALLOW_PITCHING
68 VEHICLE_FLAG_FULLSPEEDPITCHING = 0x00000020, // Sets MOVEFLAG2_FULLSPEEDPITCHING
69 VEHICLE_FLAG_CUSTOM_PITCH = 0x00000040, // If set use pitchMin and pitchMax from DBC, otherwise pitchMin = -pi/2, pitchMax = pi/2
70 VEHICLE_FLAG_ADJUST_AIM_ANGLE = 0x00000400, // Lua_IsVehicleAimAngleAdjustable
71 VEHICLE_FLAG_ADJUST_AIM_POWER = 0x00000800, // Lua_IsVehicleAimPowerAdjustable
72 VEHICLE_FLAG_FIXED_POSITION = 0x00200000 // Used for cannons, when they should be rooted
73};
74
76{
79};
80
82{
83 VehicleExitParamNone = 0, // provided parameters will be ignored
84 VehicleExitParamOffset = 1, // provided parameters will be used as offset values
85 VehicleExitParamDest = 2, // provided parameters will be used as absolute destination
87};
88
90{
94
95 void Reset()
96 {
97 Guid.Clear();
98 IsUninteractible = false;
99 IsGravityDisabled = false;
100 }
101};
102
104{
106 VehicleSeatAddon(float orientatonOffset, float exitX, float exitY, float exitZ, float exitO, uint8 param) :
107 SeatOrientationOffset(orientatonOffset), ExitParameterX(exitX), ExitParameterY(exitY), ExitParameterZ(exitZ),
109
111 float ExitParameterX = 0.f;
112 float ExitParameterY = 0.f;
113 float ExitParameterZ = 0.f;
114 float ExitParameterO = 0.f;
116};
117
119{
120 explicit VehicleSeat(VehicleSeatEntry const* seatInfo, VehicleSeatAddon const* seatAddon) : SeatInfo(seatInfo), SeatAddon(seatAddon)
121 {
123 }
124
125 bool IsEmpty() const { return Passenger.Guid.IsEmpty(); }
126
130};
131
133{
134 VehicleAccessory(uint32 entry, int8 seatId, bool isMinion, uint8 summonType, uint32 summonTime) :
135 AccessoryEntry(entry), IsMinion(isMinion), SummonTime(summonTime), SeatId(seatId), SummonedType(summonType) { }
141};
142
144{
145 Milliseconds DespawnDelay = Milliseconds::zero();
146};
147
148typedef std::vector<VehicleAccessory> VehicleAccessoryList;
149typedef std::map<ObjectGuid::LowType, VehicleAccessoryList> VehicleAccessoryContainer;
150typedef std::map<uint32, VehicleAccessoryList> VehicleAccessoryTemplateContainer;
151typedef std::map<int8, VehicleSeat> SeatMap;
152
154{
155protected:
157 virtual ~TransportBase() { }
158
159public:
160 virtual ObjectGuid GetTransportGUID() const = 0;
161
163 virtual void CalculatePassengerPosition(float& x, float& y, float& z, float* o = nullptr) const = 0;
164
166 virtual void CalculatePassengerOffset(float& x, float& y, float& z, float* o = nullptr) const = 0;
167
168 virtual float GetTransportOrientation() const = 0;
169
170 virtual void AddPassenger(WorldObject* passenger) = 0;
171
172 virtual TransportBase* RemovePassenger(WorldObject* passenger) = 0;
173
174 void UpdatePassengerPosition(Map* map, WorldObject* passenger, float x, float y, float z, float o, bool setHomePosition);
175
176 static void CalculatePassengerPosition(float& x, float& y, float& z, float* o, float transX, float transY, float transZ, float transO)
177 {
178 float inx = x, iny = y, inz = z;
179 if (o)
180 *o = Position::NormalizeOrientation(transO + *o);
181
182 x = transX + inx * std::cos(transO) - iny * std::sin(transO);
183 y = transY + iny * std::cos(transO) + inx * std::sin(transO);
184 z = transZ + inz;
185 }
186
187 static void CalculatePassengerOffset(float& x, float& y, float& z, float* o, float transX, float transY, float transZ, float transO)
188 {
189 if (o)
190 *o = Position::NormalizeOrientation(*o - transO);
191
192 z -= transZ;
193 y -= transY; // y = searchedY * std::cos(o) + searchedX * std::sin(o)
194 x -= transX; // x = searchedX * std::cos(o) + searchedY * std::sin(o + pi)
195 float inx = x, iny = y;
196 y = (iny - inx * std::tan(transO)) / (std::cos(transO) + std::sin(transO) * std::tan(transO));
197 x = (inx + iny * std::tan(transO)) / (std::cos(transO) + std::sin(transO) * std::tan(transO));
198 }
199
200 virtual int32 GetMapIdForSpawning() const = 0;
201};
202
203#endif
uint8_t uint8
Definition: Define.h:144
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
PowerType
@ POWER_PURPLE_POWER
@ POWER_VENOM
@ POWER_FUEL
@ POWER_LIFE_ENERGY
@ POWER_SUN_ENERGY
@ POWER_ARCANEENERGY
@ POWER_GREEN_POWER
@ POWER_ORANGE_POWER
@ POWER_FLASHFIRE
@ POWER_ORANGE_POWER_2
@ POWER_STEAM
@ POWER_BLOOD
@ POWER_SHADOWFLAME_ENERGY
@ POWER_PYRITE
@ POWER_HEAT
@ POWER_TWILIGHT_ENERGY
@ POWER_WRATH
@ POWER_OOZE
@ POWER_ARCANE_ENERGY
@ POWER_BLUE_POWER
@ POWER_ENERGY_2
@ POWER_WIND_POWER_1
@ POWER_SWING_VELOCITY
@ POWER_WIND_POWER_2
@ POWER_WIND_POWER_3
@ POWER_PYROCLASTIC_FRENZY
@ POWER_CONSUMING_FLAME
@ POWER_SUN_POWER
std::map< int8, VehicleSeat > SeatMap
std::map< ObjectGuid::LowType, VehicleAccessoryList > VehicleAccessoryContainer
VehicleSpells
@ VEHICLE_SPELL_PARACHUTE
@ VEHICLE_SPELL_RIDE_HARDCODED
VehicleFlags
@ VEHICLE_FLAG_NO_JUMPING
@ VEHICLE_FLAG_ADJUST_AIM_ANGLE
@ VEHICLE_FLAG_NO_STRAFE
@ VEHICLE_FLAG_FIXED_POSITION
@ VEHICLE_FLAG_FULLSPEEDTURNING
@ VEHICLE_FLAG_ALLOW_PITCHING
@ VEHICLE_FLAG_CUSTOM_PITCH
@ VEHICLE_FLAG_ADJUST_AIM_POWER
@ VEHICLE_FLAG_FULLSPEEDPITCHING
VehicleExitParameters
std::vector< VehicleAccessory > VehicleAccessoryList
std::map< uint32, VehicleAccessoryList > VehicleAccessoryTemplateContainer
Definition: Map.h:189
bool IsEmpty() const
Definition: ObjectGuid.h:319
void Clear()
Definition: ObjectGuid.h:286
virtual ObjectGuid GetTransportGUID() const =0
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied transport offsets into global coordinates.
void UpdatePassengerPosition(Map *map, WorldObject *passenger, float x, float y, float z, float o, bool setHomePosition)
Definition: Transport.cpp:39
virtual float GetTransportOrientation() const =0
static void CalculatePassengerPosition(float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
virtual int32 GetMapIdForSpawning() const =0
virtual TransportBase * RemovePassenger(WorldObject *passenger)=0
virtual void CalculatePassengerOffset(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied global coordinates into local offsets.
virtual void AddPassenger(WorldObject *passenger)=0
static void CalculatePassengerOffset(float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
virtual ~TransportBase()
bool IsGravityDisabled
ObjectGuid Guid
static float NormalizeOrientation(float o)
Definition: Position.cpp:135
VehicleAccessory(uint32 entry, int8 seatId, bool isMinion, uint8 summonType, uint32 summonTime)
VehicleSeatAddon(float orientatonOffset, float exitX, float exitY, float exitZ, float exitO, uint8 param)
VehicleExitParameters ExitParameter
VehicleSeatAddon const * SeatAddon
bool IsEmpty() const
PassengerInfo Passenger
VehicleSeat(VehicleSeatEntry const *seatInfo, VehicleSeatAddon const *seatAddon)
VehicleSeatEntry const * SeatInfo
Milliseconds DespawnDelay