Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiongetouttransport.c
Go to the documentation of this file.
2 {
3  Car m_Car;
4  vector m_StartLocation;
5  float m_CarSpeed;
6  bool m_WasJumpingOut = false;
7  float m_DmgTaken = 0.0; // Damage taken by the player when jumping out of vehicle
8  float m_ShockTaken = 0.0; // Shock inflicted to the player when jumping out of vehicle
9 }
10 
12 {
13  //For the two following variables -> The HIGHER the value, the LOWER the output
14  int m_DmgFactor = 60; //value used to translate impact strength into actual damage (impact strength -> velocity squared)
15  int m_ShockFactor = 15; //Value used to translate impact strength into actual shock
16 
17  //Variables used to determine the different speed levels for bleeding checks
18  const int LOW_SPEED_VALUE = 20;
19  const int HIGH_SPEED_VALUE = 30;
20 
21  private const int HEALTH_LOW_SPEED_VALUE = 30;
22  private const int HEALTH_HIGH_SPEED_VALUE = 70;
23 
25  {
26  m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
27  m_Text = "#leave_vehicle";
28  }
29 
31  {
33  return data;
34  }
35 
36 
37  override void CreateConditionComponents()
38  {
39  m_ConditionItem = new CCINone();
40  m_ConditionTarget = new CCTNone();
41  }
42 
43  override typename GetInputType()
44  {
46  }
47 
48  override bool HasProgress()
49  {
50  return false;
51  }
52 
53  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
54  {
55  HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
56  if (vehCommand)
57  {
58  Transport trans = vehCommand.GetTransport();
59  if (trans)
60  {
61  int crewIndex = trans.CrewMemberIndex(player);
62  return crewIndex >= 0 && trans.CrewCanGetThrough(crewIndex) && trans.IsAreaAtDoorFree(crewIndex);
63  }
64  }
65 
66  return false;
67  }
68 
69  void ProcessGetOutActionData(Car car, GetOutTransportActionData got_action_data)
70  {
71  got_action_data.m_StartLocation = got_action_data.m_Player.GetPosition();
72  got_action_data.m_Car = car;
73  float carSpeed = car.GetSpeedometerAbsolute();
74  got_action_data.m_CarSpeed = carSpeed;
75  got_action_data.m_DmgTaken = (carSpeed * carSpeed) / m_DmgFactor; //When using multiplications, wrong value is returned
76  got_action_data.m_ShockTaken = (carSpeed * carSpeed) / m_ShockFactor;
77  got_action_data.m_WasJumpingOut = carSpeed > 8.0;
78  }
79 
80  override void OnStart(ActionData action_data)
81  {
82  super.OnStart(action_data);
83 
84  HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
85  if (vehCommand)
86  {
87  Transport trans = vehCommand.GetTransport();
88  if (trans)
89  {
90  GetOutTransportActionData gotActionData = GetOutTransportActionData.Cast(action_data);
91 
92  Car car;
93  if (Class.CastTo(car, trans))
94  ProcessGetOutActionData(car, gotActionData);
95 
96  if (!gotActionData.m_WasJumpingOut)
97  vehCommand.GetOutVehicle();
98  else
99  vehCommand.JumpOutVehicle();
100 
101  if (car)
102  GetDayZGame().GetBacklit().OnLeaveCar();
103 
104  if (action_data.m_Player.GetInventory())
105  action_data.m_Player.GetInventory().LockInventory(LOCK_FROM_SCRIPT);
106  }
107  }
108  }
109 
110  override void OnStartServer(ActionData action_data)
111  {
112  HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
113  if (vehCommand)
114  {
115  Transport trans = vehCommand.GetTransport();
116  if (trans)
117  {
118  CarScript car;
119  if (Class.CastTo(car, trans))
120  car.ForceUpdateLightsStart();
121  }
122  }
123  }
124 
125  void Unhide(PlayerBase player);
126 
127  override void OnUpdate(ActionData action_data)
128  {
129  if (action_data.m_State == UA_START)
130  {
131  if (!action_data.m_Player.GetCommand_Vehicle())
132  End(action_data);
133  }
134  }
135 
136  override bool CanBeUsedInRestrain()
137  {
138  return true;
139  }
140 
141  override bool CanBeUsedInVehicle()
142  {
143  return true;
144  }
145 
146  override int GetActionCategory()
147  {
148  return AC_INTERACT;
149  }
150 
151  override void OnEnd(ActionData action_data)
152  {
153  if (action_data.m_Player.GetInventory())
154  action_data.m_Player.GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
155  }
156 
157  override void OnEndServer(ActionData action_data)
158  {
159  GetOutTransportActionData gotActionData = GetOutTransportActionData.Cast(action_data);
160 
161  if (gotActionData.m_WasJumpingOut)
162  {
163  float carSpeed = gotActionData.m_CarSpeed;
164  gotActionData.m_Player.OnJumpOutVehicleFinish(carSpeed);
165 
166  ApplyJumpOutDmg(action_data);
167 
168  vector posMS = gotActionData.m_Player.WorldToModel(gotActionData.m_Player.GetPosition());
169  gotActionData.m_Player.DamageAllLegs(gotActionData.m_DmgTaken); //Additionnal leg specific damage dealing
170 
171  float healthCoef = Math.InverseLerp(HEALTH_LOW_SPEED_VALUE, HEALTH_HIGH_SPEED_VALUE, carSpeed);
172  healthCoef = Math.Clamp(healthCoef, 0.0, 1.0);
173  gotActionData.m_Player.ProcessDirectDamage(DamageType.CUSTOM, gotActionData.m_Player, "", "FallDamageHealth", posMS, healthCoef);
174  }
175 
176  if (gotActionData.m_Car)
177  {
178  CarScript car;
179  if (Class.CastTo(car, gotActionData.m_Car))
180  car.ForceUpdateLightsEnd();
181  }
182  }
183 
184  //Manage all jumping out of vehicle damage logic
185  void ApplyJumpOutDmg(ActionData action_data)
186  {
187  GetOutTransportActionData gotActionData = GetOutTransportActionData.Cast(action_data);
188  PlayerBase player = gotActionData.m_Player;
189 
190  array<ClothingBase> equippedClothes = new array<ClothingBase>;
191  equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("LEGS")));
192  equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("BACK")));
193  equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("VEST")));
194  equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("HeadGear")));
195  equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("Mask")));
196  equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("BODY")));
197  equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("FEET")));
198  equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("GLOVES")));
199 
200  // -----------------------------------------------
201 
202  //Lower shock taken if player uses a helmet
203  ItemBase headGear = ClothingBase.Cast(player.GetItemOnHead());
204  HelmetBase helmet;
205  if (Class.CastTo(helmet, headGear))
206  gotActionData.m_ShockTaken *= 0.5;
207 
208  // -----------------------------------------------
209 
210  int randNum; //value used for probability evaluation
211  randNum = Math.RandomInt(0, 100);
212  if (gotActionData.m_CarSpeed < LOW_SPEED_VALUE)
213  {
214  if (randNum < 20)
215  player.GiveShock(-gotActionData.m_ShockTaken); //To inflict shock, a negative value must be passed
216 
217  randNum = Math.RandomIntInclusive(0, PlayerBase.m_BleedingSourcesLow.Count() - 1);
218 
219  player.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection(PlayerBase.m_BleedingSourcesLow[randNum]);
220  }
221  else if (gotActionData.m_CarSpeed >= LOW_SPEED_VALUE && gotActionData.m_CarSpeed < HIGH_SPEED_VALUE)
222  {
223  if (randNum < 50)
224  player.GiveShock(-gotActionData.m_ShockTaken);
225 
226  randNum = Math.RandomInt(0, PlayerBase.m_BleedingSourcesUp.Count() - 1);
227 
228  player.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection(PlayerBase.m_BleedingSourcesUp[randNum]);
229  }
230  else if (gotActionData.m_CarSpeed >= HIGH_SPEED_VALUE)
231  {
232  if (!headGear)
233  player.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection("Head");
234 
235  if (randNum < 75)
236  player.GiveShock(-gotActionData.m_ShockTaken);
237  }
238 
239  //Damage all currently equipped clothes
240  foreach (ClothingBase cloth : equippedClothes)
241  {
242  //If no item is equipped on slot, slot is ignored
243  if (cloth == null)
244  continue;
245 
246  cloth.DecreaseHealth(gotActionData.m_DmgTaken, false);
247  }
248  }
249 }
ItemBase
Definition: inventoryitem.c:730
End
void End()
called on surrender end request end
ApplyJumpOutDmg
void ApplyJumpOutDmg(ActionData action_data)
Definition: actiongetouttransport.c:185
Unhide
void Unhide(PlayerBase player)
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
ContinuousInteractActionInput
Definition: actioninput.c:521
CreateActionData
override ActionData CreateActionData()
Definition: actiongetouttransport.c:30
OnUpdate
override void OnUpdate(ActionData action_data)
Definition: actiongetouttransport.c:127
CCINone
Definition: ccinone.c:1
ClothingBase
Definition: dallasmask.c:1
AC_INTERACT
const int AC_INTERACT
Definition: _constants.c:4
CarScript
Definition: civiliansedan.c:1
HasProgress
override bool HasProgress()
Definition: actiongetouttransport.c:48
CCTNone
Definition: cctnone.c:1
HEALTH_LOW_SPEED_VALUE
const private int HEALTH_LOW_SPEED_VALUE
Definition: actiongetouttransport.c:21
OnStartServer
override void OnStartServer(ActionData action_data)
Definition: actiongetouttransport.c:110
OnEndServer
override void OnEndServer(ActionData action_data)
Definition: actiongetouttransport.c:157
LOW_SPEED_VALUE
const int LOW_SPEED_VALUE
Definition: actiongetouttransport.c:18
CreateConditionComponents
override void CreateConditionComponents()
Definition: actiongetouttransport.c:37
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
UA_START
const int UA_START
Definition: constants.c:439
ActionTarget
class ActionTargets ActionTarget
CanBeUsedInVehicle
override bool CanBeUsedInVehicle()
Definition: actiongetouttransport.c:141
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
DamageType
DamageType
exposed from C++ (do not change)
Definition: damagesystem.c:10
HEALTH_HIGH_SPEED_VALUE
const private int HEALTH_HIGH_SPEED_VALUE
Definition: actiongetouttransport.c:22
Transport
Base native class for all motorized wheeled vehicles.
Definition: car.c:79
HIGH_SPEED_VALUE
const int HIGH_SPEED_VALUE
Definition: actiongetouttransport.c:19
HumanCommandVehicle
Definition: human.c:689
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
ActionBase
void ActionBase()
Definition: actionbase.c:73
GetInputType
override GetInputType()
Definition: actiongetouttransport.c:43
HelmetBase
Definition: greathelm.c:1
OnStart
override void OnStart(ActionData action_data)
Definition: actiongetouttransport.c:80
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
m_DmgFactor
GetOutTransportActionData m_DmgFactor
ProcessGetOutActionData
void ProcessGetOutActionData(Car car, GetOutTransportActionData got_action_data)
Definition: actiongetouttransport.c:69
m_ShockFactor
int m_ShockFactor
Definition: actiongetouttransport.c:15
CanBeUsedInRestrain
override bool CanBeUsedInRestrain()
Definition: actiongetouttransport.c:136
Math
Definition: enmath.c:6
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
OnEnd
override void OnEnd(ActionData action_data)
Definition: actiongetouttransport.c:151
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
ActionGetOutTransport
void ActionGetOutTransport()
Definition: actiongetouttransport.c:24
GetOutTransportActionData
Definition: actiongetouttransport.c:1
ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition: actiongetouttransport.c:53
GetActionCategory
override int GetActionCategory()
Definition: actiongetouttransport.c:146