DayZ 1.24
Loading...
Searching...
No Matches
ActionGetOutTransport.c
Go to the documentation of this file.
2{
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
11class ActionGetOutTransport : ActionBase
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
38 {
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
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
77 got_action_data.m_WasJumpingOut = carSpeed > 8.0;
78 }
79
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 {
91
92 Car car;
93 if (Class.CastTo(car, trans))
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
111 {
112 HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
113 if (vehCommand)
114 {
115 Transport trans = vehCommand.GetTransport();
116 if (trans)
117 {
119 if (Class.CastTo(car, trans))
120 car.ForceUpdateLightsStart();
121 }
122 }
123 }
124
126
128 {
129 if (action_data.m_State == UA_START)
130 {
131 if (!action_data.m_Player.GetCommand_Vehicle())
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
152 {
153 if (action_data.m_Player.GetInventory())
154 action_data.m_Player.GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
155 }
156
158 {
160
161 if (gotActionData.m_WasJumpingOut)
162 {
163 float carSpeed = gotActionData.m_CarSpeed;
164 gotActionData.m_Player.OnJumpOutVehicleFinish(carSpeed);
165
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
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 {
179 if (Class.CastTo(car, gotActionData.m_Car))
180 car.ForceUpdateLightsEnd();
181 }
182 }
183
184 //Manage all jumping out of vehicle damage logic
186 {
189
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());
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
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}
const int AC_INTERACT
Definition _constants.c:4
ActionData CreateActionData()
Definition ActionBase.c:191
string m_Text
Definition ActionBase.c:49
void CreateConditionComponents()
Definition ActionBase.c:196
void OnEndServer(ActionData action_data)
Definition ActionBase.c:962
int GetActionCategory()
Definition ActionBase.c:244
GetInputType()
Definition ActionBase.c:181
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
void OnStartServer(ActionData action_data)
Definition ActionBase.c:949
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition ActionBase.c:350
int m_StanceMask
Definition ActionBase.c:53
bool HasProgress()
For UI: hiding of progress bar.
Definition ActionBase.c:216
bool CanBeUsedInRestrain()
Definition ActionBase.c:284
bool CanBeUsedInVehicle()
Definition ActionBase.c:289
const int HEALTH_HIGH_SPEED_VALUE
int m_ShockFactor
GetOutTransportActionData m_DmgFactor
void ProcessGetOutActionData(Car car, GetOutTransportActionData got_action_data)
const int LOW_SPEED_VALUE
void ApplyJumpOutDmg(ActionData action_data)
void Unhide(PlayerBase player)
const int HEALTH_LOW_SPEED_VALUE
void ActionGetOutTransport()
const int HIGH_SPEED_VALUE
DamageType
exposed from C++ (do not change)
DayZGame GetDayZGame()
Definition DayZGame.c:3530
void End()
called on surrender end request end
override void OnEnd()
Definition JumpEvents.c:53
void OnStart(Param par=null)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
Base native class for all motorized wheeled vehicles.
Definition Car.c:75
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54
proto native void OnUpdate()
Definition tools.c:333
const int UA_START
Definition constants.c:439