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 * 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
26struct VehicleSeatEntry;
27
29{
35 POWER_WRATH = 142
36};
37
39{
40 VEHICLE_FLAG_NO_STRAFE = 0x00000001, // Sets MOVEFLAG2_NO_STRAFE
41 VEHICLE_FLAG_NO_JUMPING = 0x00000002, // Sets MOVEFLAG2_NO_JUMPING
42 VEHICLE_FLAG_FULLSPEEDTURNING = 0x00000004, // Sets MOVEFLAG2_FULLSPEEDTURNING
43 VEHICLE_FLAG_ALLOW_PITCHING = 0x00000010, // Sets MOVEFLAG2_ALLOW_PITCHING
44 VEHICLE_FLAG_FULLSPEEDPITCHING = 0x00000020, // Sets MOVEFLAG2_FULLSPEEDPITCHING
45 VEHICLE_FLAG_CUSTOM_PITCH = 0x00000040, // If set use pitchMin and pitchMax from DBC, otherwise pitchMin = -pi/2, pitchMax = pi/2
46 VEHICLE_FLAG_ADJUST_AIM_ANGLE = 0x00000400, // Lua_IsVehicleAimAngleAdjustable
47 VEHICLE_FLAG_ADJUST_AIM_POWER = 0x00000800, // Lua_IsVehicleAimPowerAdjustable
48 VEHICLE_FLAG_FIXED_POSITION = 0x00200000 // Used for cannons, when they should be rooted
49};
50
52{
55};
56
58{
59 VehicleExitParamNone = 0, // provided parameters will be ignored
60 VehicleExitParamOffset = 1, // provided parameters will be used as offset values
61 VehicleExitParamDest = 2, // provided parameters will be used as absolute destination
63};
64
66{
69
70 void Reset()
71 {
72 Guid.Clear();
73 IsUninteractible = false;
74 }
75};
76
78{
80 VehicleSeatAddon(float orientatonOffset, float exitX, float exitY, float exitZ, float exitO, uint8 param) :
81 SeatOrientationOffset(orientatonOffset), ExitParameterX(exitX), ExitParameterY(exitY), ExitParameterZ(exitZ),
83
85 float ExitParameterX = 0.f;
86 float ExitParameterY = 0.f;
87 float ExitParameterZ = 0.f;
88 float ExitParameterO = 0.f;
90};
91
93{
94 explicit VehicleSeat(VehicleSeatEntry const* seatInfo, VehicleSeatAddon const* seatAddon) : SeatInfo(seatInfo), SeatAddon(seatAddon)
95 {
97 }
98
99 bool IsEmpty() const { return Passenger.Guid.IsEmpty(); }
100
104};
105
107{
108 VehicleAccessory(uint32 entry, int8 seatId, bool isMinion, uint8 summonType, uint32 summonTime) :
109 AccessoryEntry(entry), IsMinion(isMinion), SummonTime(summonTime), SeatId(seatId), SummonedType(summonType) { }
115};
116
118{
119 Milliseconds DespawnDelay = Milliseconds::zero();
120};
121
122typedef std::vector<VehicleAccessory> VehicleAccessoryList;
123typedef std::map<uint32, VehicleAccessoryList> VehicleAccessoryContainer;
124typedef std::map<int8, VehicleSeat> SeatMap;
125
127{
128protected:
130 virtual ~TransportBase() { }
131
132public:
134 virtual void CalculatePassengerPosition(float& x, float& y, float& z, float* o = nullptr) const = 0;
135
137 virtual void CalculatePassengerOffset(float& x, float& y, float& z, float* o = nullptr) const = 0;
138
139protected:
140 static void CalculatePassengerPosition(float& x, float& y, float& z, float* o, float transX, float transY, float transZ, float transO)
141 {
142 float inx = x, iny = y, inz = z;
143 if (o)
144 *o = Position::NormalizeOrientation(transO + *o);
145
146 x = transX + inx * std::cos(transO) - iny * std::sin(transO);
147 y = transY + iny * std::cos(transO) + inx * std::sin(transO);
148 z = transZ + inz;
149 }
150
151 static void CalculatePassengerOffset(float& x, float& y, float& z, float* o, float transX, float transY, float transZ, float transO)
152 {
153 if (o)
154 *o = Position::NormalizeOrientation(*o - transO);
155
156 z -= transZ;
157 y -= transY; // y = searchedY * std::cos(o) + searchedX * std::sin(o)
158 x -= transX; // x = searchedX * std::cos(o) + searchedY * std::sin(o + pi)
159 float inx = x, iny = y;
160 y = (iny - inx * std::tan(transO)) / (std::cos(transO) + std::sin(transO) * std::tan(transO));
161 x = (inx + iny * std::tan(transO)) / (std::cos(transO) + std::sin(transO) * std::tan(transO));
162 }
163};
164
165#endif
uint8_t uint8
Definition: Define.h:135
int8_t int8
Definition: Define.h:131
uint32_t uint32
Definition: Define.h:133
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:24
PowerType
@ POWER_STEAM
@ POWER_BLOOD
@ POWER_PYRITE
@ POWER_HEAT
@ POWER_WRATH
@ POWER_OOZE
std::map< int8, VehicleSeat > SeatMap
VehicleSpells
@ VEHICLE_SPELL_PARACHUTE
@ VEHICLE_SPELL_RIDE_HARDCODED
std::map< uint32, VehicleAccessoryList > VehicleAccessoryContainer
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
bool IsEmpty() const
Definition: ObjectGuid.h:174
void Clear()
Definition: ObjectGuid.h:151
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied transport offsets into global coordinates.
static void CalculatePassengerPosition(float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
virtual void CalculatePassengerOffset(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied global coordinates into local offsets.
static void CalculatePassengerOffset(float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
virtual ~TransportBase()
ObjectGuid Guid
static float NormalizeOrientation(float o)
Definition: Position.cpp:156
VehicleAccessory(uint32 entry, int8 seatId, bool isMinion, uint8 summonType, uint32 summonTime)
float SeatOrientationOffset
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