DayZ 1.24
Loading...
Searching...
No Matches
ActionRepairCarChassis.c
Go to the documentation of this file.
1class RepairCarChassisActionReciveData : ActionReciveData
2{
4}
5
7{
9}
10
18
20{
21 protected typename m_LastValidType;
22 protected string m_CurrentDamageZone;
24
37
43
44 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
45 {
46 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
47 return false;
48
49 CarScript car = CarScript.Cast(target.GetObject());
50 if (!car || !player)
51 return false;
52
53 if (GetGame().IsMultiplayer() && GetGame().IsServer())
54 return true;
55
56 if (m_LastValidType != target.Type() || m_LastValidComponentIndex != target.GetComponentIndex() || m_CurrentDamageZone == "")
57 {
58 string damageZone = "";
60 car.GetActionComponentNameList(target.GetComponentIndex(), selections);
61
62 foreach (string selection : selections)
63 {
64 //NOTE: relevant fire geometry and view geometry selection names MUST match in order to get a valid damage zone
65 if (car && DamageSystem.GetDamageZoneFromComponentName(car, selection, damageZone))
66 {
67 if (damageZone == "Engine")
68 continue;
69
70 int zoneHP = car.GetHealthLevel(damageZone);
72 {
74 m_LastValidComponentIndex = target.GetComponentIndex();
75
76 //Determine if using a "Special" item for repairing
78 Fabric tarp = Fabric.Cast(item);
79
80 //Prevent planks and tarp from repairing non related areas
81 if ((tarp || plank) && (damageZone != "BackWood" && damageZone != "BackTarp"))
82 return false;
83
84 return true;
85 }
86 }
87 }
88 }
89
90 return false;
91 }
92
94 {
95 Object tgObject = action_data.m_Target.GetObject();
96
97 string damageZone = RepairCarPartActionData.Cast(action_data).m_DamageZone;
98 if (!GetGame().IsMultiplayer())
100
101 if (tgObject && damageZone != "")
102 {
104 if (car)
105 {
107 float zoneMax = car.GetMaxHealth(damageZone, "");
108 float randomValue = Math.RandomFloatInclusive(zoneMax * 0.05, zoneMax * 0.15);
109
110 switch (newDmgLevel)
111 {
114 break;
117 break;
120 break;
121 }
122
123 if (action_data.m_MainItem.HasQuantity())
124 {
125 if (action_data.m_MainItem.GetQuantity() > 1)
126 {
127 int qnt = action_data.m_MainItem.GetQuantity();
128 Fabric usedTarp = Fabric.Cast(action_data.m_MainItem);
129 WoodenPlank usedPlank = WoodenPlank.Cast(action_data.m_MainItem);
130 if (usedTarp || usedPlank)
131 qnt -= 1;
132 else
133 qnt -= action_data.m_MainItem.GetQuantityMax() * 0.25;
134
135 action_data.m_MainItem.SetQuantity(qnt);
136 }
137 else
138 action_data.m_MainItem.Delete();
139 }
140 }
141 }
142 }
143
149
151 {
152 super.WriteToContext(ctx, action_data);
154
156 {
158 ctx.Write(repairActionData.m_DamageZone);
159 }
160 }
161
163 {
166
167 super.ReadFromContext(ctx, action_recive_data);
169
170 if (HasTarget())
171 {
172 string zone;
173 if (!ctx.Read(zone))
174 return false;
175
176 recieveDataRepair.m_DamageZoneRecived = zone;
177 }
178
179 return true;
180 }
181
189};
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
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
RepairCarChassisActionReciveData m_DamageZone
eBrokenLegs
Definition EBrokenLegs.c:2
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
override ActionData CreateActionData()
override void CreateConditionComponents()
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
override void OnFinishProgressServer(ActionData action_data)
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Super root of all classes in Enforce script.
Definition EnScript.c:11
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'.