DayZ 1.24
Loading...
Searching...
No Matches
ActionRepairCarEngine.c
Go to the documentation of this file.
1class RepairCarEngineActionReciveData : ActionReciveData
2{
4}
5
7{
9}
10
18
20{
24
26 {
27 m_CallbackClass = ActionRepairTentPartCB;
29 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
30 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
31 m_FullBody = true;
32 m_LockTargetOnUse = false;
33 m_Text = "#repair";
34 }
35
41
42 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
43 {
44 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
45 return false;
46
47 Object targetObject = target.GetObject();
48 Object targetParent = target.GetParent();
51
52 if (!car || !player)
53 return false;
54
55 if (car.EngineIsOn())
56 return false;
57
58 if (GetGame().IsMultiplayer() && GetGame().IsServer())
59 return true;
60
61 if (m_LastValidType != target.Type() || m_LastValidComponentIndex != target.GetComponentIndex() || m_CurrentDamageZone == "")
62 {
63 string damageZone = "";
65 targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections, LOD.NAME_VIEW);
66
67 foreach (string selection : selections)
68 {
69 //NOTE: relevant fire geometry and view geometry selection names MUST match in order to get a valid damage zone
70 if (carEntity && DamageSystem.GetDamageZoneFromComponentName(carEntity, selection, damageZone))
71 {
72 if (damageZone == "Engine")
73 {
74 int zoneHP = car.GetHealthLevel(damageZone);
76 {
78 m_LastValidComponentIndex = target.GetComponentIndex();
79
80 return true;
81 }
82 }
83 }
84 }
85 }
86
87 return false;
88 }
89
91 {
92 Object tgObject = action_data.m_Target.GetObject();
93
94 string damageZone = RepairCarPartActionData.Cast(action_data).m_DamageZone;
95 if (!GetGame().IsMultiplayer())
97
98 if (tgObject && damageZone != "")
99 {
101 if (car)
102 {
104 float zoneMax = car.GetMaxHealth(damageZone, "");
105 float randomValue = Math.RandomFloatInclusive(zoneMax * 0.05, zoneMax * 0.15);
106
107 switch (newDmgLevel)
108 {
111 break;
112
115 break;
116
119 break;
120
121 default:
122 break;
123 }
124
125 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, UADamageApplied.BUILD);
126 }
127 }
128 }
129
135
137 {
138 super.WriteToContext(ctx, action_data);
140
142 {
144 ctx.Write(repairActionData.m_DamageZone);
145 }
146 }
147
149 {
152
153 super.ReadFromContext(ctx, action_recive_data);
155
156 if (HasTarget())
157 {
158 string zone;
159 if (!ctx.Read(zone))
160 return false;
161
162 reciveDataRepair.m_DamageZoneRecived = zone;
163 }
164
165 return true;
166 }
167
175}
ActionData CreateActionData()
Definition ActionBase.c:191
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
void CreateConditionComponents()
Definition ActionBase.c:196
bool HasTarget()
Definition ActionBase.c:210
bool m_LockTargetOnUse
Definition ActionBase.c:51
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
Definition ActionBase.c:485
RepairCarChassisActionReciveData m_DamageZone
int m_LastValidComponentIndex
ActionRepairCarEngineCB m_LastValidType
string m_CurrentDamageZone
void ActionRepairCarEngine()
eBrokenLegs
Definition EBrokenLegs.c:2
void ReadFromContext(ParamsReadContext ctx)
Definition Hand_Events.c:70
void WriteToContext(ParamsWriteContext ctx)
Definition Hand_Events.c:72
ActionData m_ActionData
void OnFinishProgressServer(ActionData action_data)
ref CABase m_ActionComponent
Definition ActionBase.c:30
override void CreateActionComponent()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Super root of all classes in Enforce script.
Definition EnScript.c:11
LOD class.
Definition gameplay.c:203
static const string NAME_VIEW
Definition gameplay.c:206
Definition EnMath.c:7
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
const float REPAIR
const float BASEBUILDING_REPAIR_FAST
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const float DAMAGE_BADLY_DAMAGED_VALUE
Definition constants.c:772
const float DAMAGE_RUINED_VALUE
Definition constants.c:773
const float DAMAGE_DAMAGED_VALUE
Definition constants.c:771
const int STATE_RUINED
Definition constants.c:757
const int STATE_WORN
Definition constants.c:760
const int STATE_DAMAGED
Definition constants.c:759
const int STATE_BADLY_DAMAGED
Definition constants.c:758
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106
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'.