DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Transport.c
Go to the documentation of this file.
1
4class Transport extends EntityAI
5{
9
10 void Transport()
11 {
12 }
13
14 override int GetMeleeTargetType()
15 {
16 return EMeleeTargetType.NONALIGNABLE;
17 }
18
19
21 proto native void Synchronize();
22
23
25 proto native int CrewSize();
26
29 proto native int CrewPositionIndex( int componentIdx );
30
33 proto native int CrewMemberIndex( Human player );
34
37 proto native Human CrewMember( int posIdx );
38
40 proto void CrewEntry( int posIdx, out vector pos, out vector dir );
41
43 proto void CrewEntryWS( int posIdx, out vector pos, out vector dir );
44
46 proto void CrewTransform( int posIdx, out vector mat[4] );
47
49 proto void CrewTransformWS( int posIdx, out vector mat[4] );
50
52 proto native void CrewGetIn( Human player, int posIdx );
53
55 proto native Human CrewGetOut( int posIdx );
56
58 proto native void CrewDeath( int posIdx );
59
60
61 override bool IsTransport()
62 {
63 return true;
64 }
65
67 {
68 return false;
69 }
70
71 override bool IsHealthVisible()
72 {
73 return true;
74 }
75
76 override bool ShowZonesHealth()
77 {
78 return true;
79 }
80
82 {
83 return 4.0;
84 }
85
87 {
88 return "0 1.3 0";
89 }
90
92 {
93#ifndef CFGMODS_DEFINE_TEST
94 Error("GetAnimInstance() not implemented");
95 return 0;
96#else
97 return 2;
98#endif
99 }
100
101 int GetSeatAnimationType( int posIdx )
102 {
103#ifndef CFGMODS_DEFINE_TEST
104 Error("GetSeatAnimationType() not implemented");
105#endif
106 return 0;
107 }
108
110 {
111#ifndef CFGMODS_DEFINE_TEST
112 Error("Get3rdPersonCameraType() not implemented");
113 return 0;
114#else
115 return 31;
116#endif
117 }
118
119 bool CrewCanGetThrough( int posIdx )
120 {
121#ifndef CFGMODS_DEFINE_TEST
122 return false;
123#else
124 return true;
125#endif
126 }
127
128 bool CanReachSeatFromSeat( int currentSeat, int nextSeat )
129 {
130#ifndef CFGMODS_DEFINE_TEST
131 return false;
132#else
133 return true;
134#endif
135 }
136
137 bool CanReachSeatFromDoors( string pSeatSelection, vector pFromPos, float pDistance = 1.0 )
138 {
139#ifndef CFGMODS_DEFINE_TEST
140 return false;
141#else
142 return true;
143#endif
144 }
145
146 bool CanReachDoorsFromSeat( string pDoorsSelection, int pCurrentSeat )
147 {
148#ifndef CFGMODS_DEFINE_TEST
149 return false;
150#else
151 return true;
152#endif
153 }
154
155 int GetSeatIndexFromDoor( string pDoorSelection )
156 {
157 //Potientially could be fixed some other way, currently follows the unfortunate pattern that CanReachDoorsFromSeat has created
158 switch (pDoorSelection)
159 {
160 case "DoorsDriver":
161 return 0;
162 break;
163 case "DoorsCoDriver":
164 return 1;
165 break;
166 case "DoorsCargo1":
167 return 2;
168 break;
169 case "DoorsCargo2":
170 return 3;
171 break;
172 }
173 return -1;
174 }
175
177 {
178 if (!o)
179 return false;
180
182 int layer = dBodyGetInteractionLayer(o);
183 bool interacts = dGetInteractionLayer(this, PhxInteractionLayers.CHARACTER, layer);
184 if (!interacts)
185 {
186 return true;
187 }
188
189 DayZPlayer player;
190 if (Class.CastTo(player, o))
191 {
193 HumanCommandVehicle hcv = player.GetCommand_Vehicle();
194 if (hcv && hcv.GetTransport() == this)
195 {
196 return true;
197 }
198 }
199
200 EntityAI e = EntityAI.Cast(o);
201 // CanBeSkinned means it is a dead entity which should not block the door
202 return ( ( e && (e.IsZombie() || e.IsHologram()) ) || o.CanBeSkinned() || o.IsBush() || o.IsTree() );
203 }
204
205 bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight, inout vector extents, out vector transform[4] )
206 {
207 GetTransform(transform);
208
209 vector crewPos;
210 vector crewDir;
211 CrewEntry( currentSeat, crewPos, crewDir );
212
213 vector entry[4];
214 entry[2] = crewDir;
215 entry[0] = vector.Up * crewDir;
216 entry[1] = entry[2] * entry[0];
217 entry[3] = crewPos;
218
219 Math3D.MatrixMultiply4( transform, entry, transform );
220
221 vector position = transform[3];
222 vector orientation = Math3D.MatrixToAngles(transform);
223
224 position[1] = position[1] + maxAllowedObjHeight + (extents[1] * 0.5);
225
226 array<Object> excluded = new array<Object>;
227 array<Object> collided = new array<Object>;
228
229 excluded.Insert(this);
230
231 GetGame().IsBoxColliding(position, orientation, extents, excluded, collided);
232
233 orientation.RotationMatrixFromAngles(transform);
234 transform[3] = position;
235
236 foreach (Object o : collided)
237 {
238 EntityAI e = EntityAI.Cast(o);
239 if (IsIgnoredObject(o))
240 continue;
241
242 vector minmax[2];
243 if (o.GetCollisionBox(minmax))
244 return false;
245 }
246
247 return true;
248 }
249
250 bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
251 {
252 vector transform[4];
253 vector extents;
254
255 extents[0] = horizontalExtents;
256 extents[1] = playerHeight;
257 extents[2] = horizontalExtents;
258
259 return IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform );
260 }
261
262 Shape DebugFreeAreaAtDoor( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
263 {
264 int color = ARGB(20, 0, 255, 0);
265
266 vector transform[4];
267 vector extents;
268
269 extents[0] = horizontalExtents;
270 extents[1] = playerHeight;
271 extents[2] = horizontalExtents;
272
273 if (!IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform ))
274 {
275 color = ARGB(20, 255, 0, 0);
276 }
277
278 Shape shape = Debug.DrawBox(-extents * 0.5, extents * 0.5, color);
279 shape.SetMatrix(transform);
280 return shape;
281 }
282};
PhxInteractionLayers
Definition DayZPhysics.c:2
EMeleeTargetType
ref TIntArray m_InteractActions
Definition ItemBase.c:4717
proto native bool IsBoxColliding(vector center, vector orientation, vector edgeLength, array< Object > excludeObjects, array< Object > collidedObjects=NULL)
Finds all objects that are in choosen oriented bounding box (OBB)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition Debug.c:14
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
Definition Debug.c:273
ref TIntArray m_SingleUseActions
Definition Transport.c:6
int GetSeatIndexFromDoor(string pDoorSelection)
Definition Transport.c:155
void Transport()
Definition Transport.c:10
bool IsIgnoredObject(Object o)
Definition Transport.c:176
bool IsAreaAtDoorFree(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Definition Transport.c:250
bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Definition Transport.c:146
proto void CrewTransformWS(int posIdx, out vector mat[4])
Returns crew transformation indside vehicle in world space.
override bool ShowZonesHealth()
Definition Transport.c:76
proto native void CrewGetIn(Human player, int posIdx)
Performs transfer of player from world into vehicle on given position.
proto native void Synchronize()
Synchronizes car's state in case the simulation is not running.
bool IsAreaAtDoorFree(int currentSeat, float maxAllowedObjHeight, inout vector extents, out vector transform[4])
Definition Transport.c:205
proto void CrewEntryWS(int posIdx, out vector pos, out vector dir)
Reads entry point and direction into vehicle on given position in world space.
ref TIntArray m_ContinuousActions
Definition Transport.c:7
proto void CrewTransform(int posIdx, out vector mat[4])
Returns crew transformation indside vehicle in model space.
override int GetMeleeTargetType()
Definition Transport.c:14
Shape DebugFreeAreaAtDoor(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Definition Transport.c:262
proto native Human CrewMember(int posIdx)
proto native int CrewSize()
Returns crew capacity of this vehicle.
proto native void CrewDeath(int posIdx)
Handles death of player in vehicle and awakes its physics if needed.
int Get3rdPersonCameraType()
Definition Transport.c:109
override bool IsHealthVisible()
Definition Transport.c:71
proto native int CrewPositionIndex(int componentIdx)
override bool IsIgnoredByConstruction()
Definition Transport.c:66
int GetSeatAnimationType(int posIdx)
Definition Transport.c:101
vector GetTransportCameraOffset()
Definition Transport.c:86
bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Definition Transport.c:128
float GetTransportCameraDistance()
Definition Transport.c:81
bool CrewCanGetThrough(int posIdx)
Definition Transport.c:119
override bool IsTransport()
Definition Transport.c:61
proto void CrewEntry(int posIdx, out vector pos, out vector dir)
Reads entry point and direction into vehicle on given position in model space.
int GetAnimInstance()
Definition Transport.c:91
proto native Human CrewGetOut(int posIdx)
Performs transfer of player from vehicle into world from given position.
proto native int CrewMemberIndex(Human player)
bool CanReachSeatFromDoors(string pSeatSelection, vector pFromPos, float pDistance=1.0)
Definition Transport.c:137
proto native Transport GetTransport()
Base native class for all motorized wheeled vehicles.
Definition Car.c:80
override bool IsAreaAtDoorFree(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Definition Car.c:93
static const vector Up
Definition EnConvert.c:107
proto void RotationMatrixFromAngles(out vector mat[3])
Creates rotation matrix from angles.
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto void MatrixMultiply4(vector mat0[4], vector mat1[4], out vector res[4])
Transforms matrix.
static proto vector MatrixToAngles(vector mat[3])
Returns angles of rotation matrix.
proto native bool dGetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2)
proto native int dBodyGetInteractionLayer(notnull IEntity ent)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322