DayZ 1.24
Loading...
Searching...
No Matches
ActionRepairCarPart.c
Go to the documentation of this file.
1class RepairCarPartActionReciveData : ActionReciveData
2{
4}
5
7{
9}
10
18
20{
24
26 {
27 m_CallbackClass = ActionRepairCarPartCB;
29
30 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
31 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
32 m_FullBody = true;
33 m_LockTargetOnUse = false;
34 m_Text = "#repair";
35 }
36
42
43 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
44 {
45 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
46 return false;
47
48 Object targetObject = target.GetObject();
49 Object targetParent = target.GetParent();
51
52 if (!carDoor || !player)
53 return false;
54
55 if (GetGame().IsMultiplayer() && GetGame().IsServer())
56 return true;
57
58 if (carDoor)
59 {
60 //Check if item is attached to car -> If so, block repair if door is closed
61 if (targetParent != null)
62 {
64 bool isPresent = carDoor.GetInventory().GetCurrentInventoryLocation(loc);
65
66 if (!isPresent || loc.GetSlot() == -1)
67 return false;
68
69 string slotName = InventorySlots.GetSlotName(loc.GetSlot());
71 return false;
72 }
73
74 //Check health level of door
75 int zoneHP = carDoor.GetHealthLevel("");
77 }
78
79 return false;
80 }
81
83 {
84 Object tgObject = action_data.m_Target.GetObject();
85
86 string damageZone = RepairCarPartActionData.Cast(action_data).m_DamageZone;
87 if (!GetGame().IsMultiplayer())
89
90 if (tgObject)
91 {
93 if (carDoor)
94 {
96 float zoneMax = carDoor.GetMaxHealth("", "");
97 float randomValue = Math.RandomFloatInclusive(zoneMax * 0.05, zoneMax * 0.15);
98
99 switch (newDmgLevel)
100 {
103 break;
104
107 break;
108
111 break;
112
113 default:
114 break;
115 }
116
117 if (action_data.m_MainItem.HasQuantity())
118 {
119 if (action_data.m_MainItem.GetQuantity() > 1)
120 {
121 int qnt = action_data.m_MainItem.GetQuantity();
122 qnt -= action_data.m_MainItem.GetQuantityMax() * 0.25;
123 action_data.m_MainItem.SetQuantity(qnt);
124 }
125 else
126 action_data.m_MainItem.Delete();
127 }
128 }
129 }
130 }
131
137
139 {
140 super.WriteToContext(ctx, action_data);
142
144 {
146 ctx.Write(repairActionData.m_DamageZone);
147 }
148 }
149
151 {
154
155 super.ReadFromContext(ctx, action_recive_data);
157
158 if (HasTarget())
159 {
160 string zone;
161 if (!ctx.Read(zone))
162 return false;
163
164 reciveDataRepair.m_DamageZoneRecived = zone;
165 }
166
167 return true;
168 }
169
177}
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 ActionRepairCarPart()
CarDoorState
Definition CarScript.c:2
PlayerSpawnPreset slotName
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)
override int GetCarDoorsState(string slotType)
Super root of all classes in Enforce script.
Definition EnScript.c:11
InventoryLocation.
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
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'.