DayZ 1.24
Loading...
Searching...
No Matches
ActionGetOutTransport.c File Reference

Go to the source code of this file.

Classes

class  GetOutTransportActionData
 

Functions

void ActionGetOutTransport ()
 
override ActionData CreateActionData ()
 
override void CreateConditionComponents ()
 
override GetInputType ()
 
override bool HasProgress ()
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
void ProcessGetOutActionData (Car car, GetOutTransportActionData got_action_data)
 
override void OnStart (ActionData action_data)
 
override void OnStartServer (ActionData action_data)
 
void Unhide (PlayerBase player)
 
override void OnUpdate (ActionData action_data)
 
override bool CanBeUsedInRestrain ()
 
override bool CanBeUsedInVehicle ()
 
override int GetActionCategory ()
 
override void OnEnd (ActionData action_data)
 
override void OnEndServer (ActionData action_data)
 
void ApplyJumpOutDmg (ActionData action_data)
 

Variables

GetOutTransportActionData m_DmgFactor = 60
 
int m_ShockFactor = 15
 
const int LOW_SPEED_VALUE = 20
 
const int HIGH_SPEED_VALUE = 30
 
const int HEALTH_LOW_SPEED_VALUE = 30
 
const int HEALTH_HIGH_SPEED_VALUE = 70
 

Function Documentation

◆ ActionCondition()

override bool ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )
private

Definition at line 53 of file ActionGetOutTransport.c.

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 }
Base native class for all motorized wheeled vehicles.
Definition Car.c:75

◆ ActionGetOutTransport()

void ActionGetOutTransport ( )
private

Definition at line 24 of file ActionGetOutTransport.c.

25 {
26 m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
27 m_Text = "#leave_vehicle";
28 }
string m_Text
Definition ActionBase.c:49
int m_StanceMask
Definition ActionBase.c:53
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597

References m_StanceMask, and m_Text.

Referenced by ActionConstructor::RegisterActions(), and ManBase::SetActions().

◆ ApplyJumpOutDmg()

void ApplyJumpOutDmg ( ActionData action_data)
private

Definition at line 185 of file ActionGetOutTransport.c.

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 }
const int LOW_SPEED_VALUE
const int HIGH_SPEED_VALUE
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
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

References Class::CastTo(), HIGH_SPEED_VALUE, LOW_SPEED_VALUE, Math::RandomInt(), and Math::RandomIntInclusive().

Referenced by OnEndServer().

◆ CanBeUsedInRestrain()

override bool CanBeUsedInRestrain ( )
private

Definition at line 136 of file ActionGetOutTransport.c.

137 {
138 return true;
139 }

◆ CanBeUsedInVehicle()

override bool CanBeUsedInVehicle ( )
private

Definition at line 141 of file ActionGetOutTransport.c.

142 {
143 return true;
144 }

◆ CreateActionData()

override ActionData CreateActionData ( )
private

Definition at line 30 of file ActionGetOutTransport.c.

31 {
33 return data;
34 }

◆ CreateConditionComponents()

override void CreateConditionComponents ( )
private

Definition at line 37 of file ActionGetOutTransport.c.

38 {
41 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56

References m_ConditionItem, and m_ConditionTarget.

◆ GetActionCategory()

override int GetActionCategory ( )
private

Definition at line 146 of file ActionGetOutTransport.c.

147 {
148 return AC_INTERACT;
149 }
const int AC_INTERACT
Definition _constants.c:4

References AC_INTERACT.

◆ GetInputType()

override GetInputType ( )
private

◆ HasProgress()

override bool HasProgress ( )
private

Definition at line 48 of file ActionGetOutTransport.c.

49 {
50 return false;
51 }

◆ OnEnd()

override void OnEnd ( ActionData action_data)
private

Definition at line 151 of file ActionGetOutTransport.c.

152 {
153 if (action_data.m_Player.GetInventory())
154 action_data.m_Player.GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
155 }

◆ OnEndServer()

override void OnEndServer ( ActionData action_data)
private

Definition at line 157 of file ActionGetOutTransport.c.

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 }
const int HEALTH_HIGH_SPEED_VALUE
void ApplyJumpOutDmg(ActionData action_data)
const int HEALTH_LOW_SPEED_VALUE
DamageType
exposed from C++ (do not change)
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,...

References ApplyJumpOutDmg(), Class::CastTo(), Math::Clamp(), HEALTH_HIGH_SPEED_VALUE, HEALTH_LOW_SPEED_VALUE, and Math::InverseLerp().

◆ OnStart()

override void OnStart ( ActionData action_data)
private

Definition at line 80 of file ActionGetOutTransport.c.

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 }
void ProcessGetOutActionData(Car car, GetOutTransportActionData got_action_data)
DayZGame GetDayZGame()
Definition DayZGame.c:3530

References Class::CastTo(), GetDayZGame(), and ProcessGetOutActionData().

◆ OnStartServer()

override void OnStartServer ( ActionData action_data)
private

Definition at line 110 of file ActionGetOutTransport.c.

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 }

References Class::CastTo().

◆ OnUpdate()

override void OnUpdate ( ActionData action_data)
private

Definition at line 127 of file ActionGetOutTransport.c.

128 {
129 if (action_data.m_State == UA_START)
130 {
131 if (!action_data.m_Player.GetCommand_Vehicle())
133 }
134 }
void End()
called on surrender end request end
const int UA_START
Definition constants.c:439

References End(), and UA_START.

◆ ProcessGetOutActionData()

void ProcessGetOutActionData ( Car car,
GetOutTransportActionData got_action_data )
private

Definition at line 69 of file ActionGetOutTransport.c.

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 }
int m_ShockFactor
GetOutTransportActionData m_DmgFactor

References m_DmgFactor, and m_ShockFactor.

Referenced by OnStart().

◆ Unhide()

void Unhide ( PlayerBase player)
private

Variable Documentation

◆ HEALTH_HIGH_SPEED_VALUE

const int HEALTH_HIGH_SPEED_VALUE = 70
private

Definition at line 22 of file ActionGetOutTransport.c.

Referenced by OnEndServer().

◆ HEALTH_LOW_SPEED_VALUE

const int HEALTH_LOW_SPEED_VALUE = 30
private

Definition at line 21 of file ActionGetOutTransport.c.

Referenced by OnEndServer().

◆ HIGH_SPEED_VALUE

const int HIGH_SPEED_VALUE = 30

Definition at line 19 of file ActionGetOutTransport.c.

Referenced by ApplyJumpOutDmg().

◆ LOW_SPEED_VALUE

const int LOW_SPEED_VALUE = 20

Definition at line 18 of file ActionGetOutTransport.c.

Referenced by ApplyJumpOutDmg().

◆ m_DmgFactor

GetOutTransportActionData m_DmgFactor = 60

Referenced by ProcessGetOutActionData().

◆ m_ShockFactor

int m_ShockFactor = 15

Definition at line 15 of file ActionGetOutTransport.c.

Referenced by ProcessGetOutActionData().