Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
transport.c
Go to the documentation of this file.
1 
4 class 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  override bool IsTransport()
61  {
62  return true;
63  }
64 
65  override bool IsIgnoredByConstruction()
66  {
67  return false;
68  }
69 
70  override bool IsHealthVisible()
71  {
72  return true;
73  }
74 
75  override bool ShowZonesHealth()
76  {
77  return true;
78  }
79 
80  bool IsAnyCrewPresent()
81  {
82  for (int index = 0; index < CrewSize(); ++index)
83  {
84  if (CrewMember(index) != null)
85  return true;
86  }
87 
88  return false;
89  }
90 
92  {
93  return 4.0;
94  }
95 
96  void MarkCrewMemberUnconscious(int crewMemberIndex);
97  void MarkCrewMemberDead(int crewMemberIndex);
98  protected void HandleByCrewMemberState(ECrewMemberState state);
99 
100  vector GetTransportCameraOffset()
101  {
102  return "0 1.3 0";
103  }
104 
105  int GetAnimInstance()
106  {
107 #ifndef CFGMODS_DEFINE_TEST
108  Error("GetAnimInstance() not implemented");
109  return 0;
110 #else
111  return 2;
112 #endif
113  }
114 
115  int GetSeatAnimationType( int posIdx )
116  {
117 #ifndef CFGMODS_DEFINE_TEST
118  Error("GetSeatAnimationType() not implemented");
119 #endif
120  return 0;
121  }
122 
124  {
125 #ifndef CFGMODS_DEFINE_TEST
126  Error("Get3rdPersonCameraType() not implemented");
127  return 0;
128 #else
129  return 31;
130 #endif
131  }
132 
133  bool CrewCanGetThrough( int posIdx )
134  {
135 #ifndef CFGMODS_DEFINE_TEST
136  return false;
137 #else
138  return true;
139 #endif
140  }
141 
142  bool CanReachSeatFromSeat( int currentSeat, int nextSeat )
143  {
144 #ifndef CFGMODS_DEFINE_TEST
145  return false;
146 #else
147  return true;
148 #endif
149  }
150 
151  bool CanReachSeatFromDoors( string pSeatSelection, vector pFromPos, float pDistance = 1.0 )
152  {
153 #ifndef CFGMODS_DEFINE_TEST
154  return false;
155 #else
156  return true;
157 #endif
158  }
159 
160  bool CanReachDoorsFromSeat( string pDoorsSelection, int pCurrentSeat )
161  {
162 #ifndef CFGMODS_DEFINE_TEST
163  return false;
164 #else
165  return true;
166 #endif
167  }
168 
169  int GetSeatIndexFromDoor( string pDoorSelection )
170  {
171  //Potientially could be fixed some other way, currently follows the unfortunate pattern that CanReachDoorsFromSeat has created
172  switch (pDoorSelection)
173  {
174  case "DoorsDriver":
175  return 0;
176  break;
177  case "DoorsCoDriver":
178  return 1;
179  break;
180  case "DoorsCargo1":
181  return 2;
182  break;
183  case "DoorsCargo2":
184  return 3;
185  break;
186  }
187  return -1;
188  }
189 
190  bool IsIgnoredObject( Object o )
191  {
192  if (!o)
193  return false;
194 
196  int layer = dBodyGetInteractionLayer(o);
197  bool interacts = dGetInteractionLayer(this, PhxInteractionLayers.CHARACTER, layer);
198  if (!interacts)
199  {
200  return true;
201  }
202 
203  DayZPlayer player;
204  if (Class.CastTo(player, o))
205  {
207  HumanCommandVehicle hcv = player.GetCommand_Vehicle();
208  if (hcv && hcv.GetTransport() == this)
209  {
210  return true;
211  }
212  }
213 
214  EntityAI e = EntityAI.Cast(o);
215  // CanBeSkinned means it is a dead entity which should not block the door
216  return ( ( e && (e.IsZombie() || e.IsHologram()) ) || o.CanBeSkinned() || o.IsBush() || o.IsTree() );
217  }
218 
219  bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight, inout vector extents, out vector transform[4] )
220  {
221  GetTransform(transform);
222 
223  vector crewPos;
224  vector crewDir;
225  CrewEntry( currentSeat, crewPos, crewDir );
226 
227  vector entry[4];
228  entry[2] = crewDir;
229  entry[0] = vector.Up * crewDir;
230  entry[1] = entry[2] * entry[0];
231  entry[3] = crewPos;
232 
233  Math3D.MatrixMultiply4( transform, entry, transform );
234 
235  vector position = transform[3];
236  vector orientation = Math3D.MatrixToAngles(transform);
237 
238  position[1] = position[1] + maxAllowedObjHeight + (extents[1] * 0.5);
239 
240  array<Object> excluded = new array<Object>;
241  array<Object> collided = new array<Object>;
242 
243  excluded.Insert(this);
244 
245  GetGame().IsBoxColliding(position, orientation, extents, excluded, collided);
246 
247  orientation.RotationMatrixFromAngles(transform);
248  transform[3] = position;
249 
250  foreach (Object o : collided)
251  {
252  EntityAI e = EntityAI.Cast(o);
253  if (IsIgnoredObject(o))
254  continue;
255 
256  vector minmax[2];
257  if (o.GetCollisionBox(minmax))
258  return false;
259  }
260 
261  return true;
262  }
263 
264  bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
265  {
266  vector transform[4];
267  vector extents;
268 
269  extents[0] = horizontalExtents;
270  extents[1] = playerHeight;
271  extents[2] = horizontalExtents;
272 
273  return IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform );
274  }
275 
276  Shape DebugFreeAreaAtDoor( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
277  {
278  int color = ARGB(20, 0, 255, 0);
279 
280  vector transform[4];
281  vector extents;
282 
283  extents[0] = horizontalExtents;
284  extents[1] = playerHeight;
285  extents[2] = horizontalExtents;
286 
287  if (!IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform ))
288  {
289  color = ARGB(20, 255, 0, 0);
290  }
291 
292  Shape shape = Debug.DrawBox(-extents * 0.5, extents * 0.5, color);
293  shape.SetMatrix(transform);
294  return shape;
295  }
296 };
GetGame
proto native CGame GetGame()
dBodyGetInteractionLayer
proto native int dBodyGetInteractionLayer(notnull IEntity ent)
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
Synchronize
void Synchronize(eInjuryHandlerLevels level)
Definition: injuryhandler.c:173
CrewCanGetThrough
override bool CrewCanGetThrough(int posIdx)
Definition: civiliansedan.c:204
MarkCrewMemberUnconscious
override void MarkCrewMemberUnconscious(int crewMemberIndex)
Definition: carscript.c:1458
GetAnimInstance
override int GetAnimInstance()
Definition: civiliansedan.c:75
ECrewMemberState
ECrewMemberState
Definition: ecrewmemberstate.c:1
ShowZonesHealth
override bool ShowZonesHealth()
Definition: basebuildingbase.c:916
m_InteractActions
ref TIntArray m_InteractActions
Definition: itembase.c:85
DayZPlayer
Definition: dayzplayerimplement.c:72
GetTransportCameraDistance
override float GetTransportCameraDistance()
Definition: civiliansedan.c:80
IsTransport
protected bool IsTransport(ActionTarget target)
Definition: actionbase.c:923
m_SingleUseActions
ref TIntArray m_SingleUseActions
Definition: itembase.c:83
GetSeatIndexFromDoor
override int GetSeatIndexFromDoor(string pDoorSelection)
Definition: offroadhatchback.c:427
vector
Definition: enconvert.c:105
HandleByCrewMemberState
override void HandleByCrewMemberState(ECrewMemberState state)
Definition: carscript.c:1476
Object
Definition: objecttyped.c:1
Transport
Base native class for all motorized wheeled vehicles.
Definition: car.c:79
m_ContinuousActions
ref TIntArray m_ContinuousActions
Definition: itembase.c:84
MarkCrewMemberDead
override void MarkCrewMemberDead(int crewMemberIndex)
Definition: carscript.c:1467
HumanCommandVehicle
Definition: human.c:689
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
Get3rdPersonCameraType
override int Get3rdPersonCameraType()
camera type
Definition: carscript.c:2320
CanReachDoorsFromSeat
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Definition: civiliansedan.c:378
dGetInteractionLayer
proto native bool dGetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2)
GetSeatAnimationType
override int GetSeatAnimationType(int posIdx)
Definition: civiliansedan.c:85
Debug
Definition: debug.c:13
CanReachSeatFromSeat
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Definition: civiliansedan.c:358
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
EntityAI
Definition: building.c:5
ARGB
int ARGB(int a, int r, int g, int b)
Definition: proto.c:322
PhxInteractionLayers
PhxInteractionLayers
Definition: dayzphysics.c:1
Math3D
Definition: enmath3d.c:27
IsIgnoredByConstruction
override bool IsIgnoredByConstruction()
Definition: dayzanimal.c:65
Shape
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
CanReachSeatFromDoors
override bool CanReachSeatFromDoors(string pSeatSelection, vector pFromPos, float pDistance=1.0)
Definition: carscript.c:2240
EMeleeTargetType
EMeleeTargetType
Definition: emeleetargettype.c:1