DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionRepairTentPart.c
Go to the documentation of this file.
1class RepairTentPartActionReciveData : ActionReciveData
2{
4}
5
6class RepairTentPartActionData : ActionData
7{
9}
10
12{
13 override void CreateActionComponent()
14 {
16 }
17};
18
20{
24
26 {
29
30 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
31 m_FullBody = true;
32 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
33 m_Text = "#repair";
34 }
35
37 {
38 m_ConditionItem = new CCINonRuined; //To change?
40 }
41
42 override bool IsUsingProxies()
43 {
44 return true;
45 }
46
47 override bool HasTarget()
48 {
49 return true;
50 }
51
52 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
53 {
54 //m_CurrentDamageZone = "";
55 Object targetObject = target.GetObject();
56 Object targetParent = target.GetParent();
57 if ( !targetParent || !targetParent.IsInherited(TentBase) )
58 return false;
59
60 if ( player && targetObject && targetParent )
61 {
62 array<string> selections = new array<string>;
63 PluginRepairing module_repairing;
64 Class.CastTo(module_repairing, GetPlugin(PluginRepairing));
65 targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections, "view");
66 TentBase tent = TentBase.Cast( targetParent );
67 if (m_LastValidType != targetObject.Type() || m_LastValidComponentIndex != target.GetComponentIndex() || m_CurrentDamageZone == "" || m_CurrentDamageZone == "Body")
68 {
69 string damageZone = "";
70
71 for (int s = 0; s < selections.Count(); s++)
72 {
73 if ( DamageSystem.GetDamageZoneFromComponentName(tent, selections[s], damageZone) ) //NOTE: relevant fire geometry and view geometry selection names MUST match in order to get a valid damage zone
74 {
75 //Print("#" + s + " damageZone: " + damageZone);
76 if (tent.GetHealthLevel("" + damageZone) == GameConstants.STATE_RUINED )
77 {
78 m_CurrentDamageZone = damageZone;
79 m_LastValidComponentIndex = target.GetComponentIndex();
80 break;
81 }else
82 continue;
83 }
84 }
85 if ( damageZone != "" && m_CurrentDamageZone != "Body" ) //This may seem like a duplicate but is required to work properly
86 {
87 m_CurrentDamageZone = damageZone;
88 m_LastValidComponentIndex = target.GetComponentIndex();
89 }
90 }
91
92 if ( m_CurrentDamageZone != "" && m_CurrentDamageZone != "Body" && tent.GetHealthLevel("" + damageZone) == GameConstants.STATE_RUINED )
93 {
94 return true;
95 }
96 }
97
98 return false;
99 }
100
101 override void OnFinishProgressServer( ActionData action_data )
102 {
103 Object targetParent = action_data.m_Target.GetParent();
104 ItemBase usedItem = action_data.m_MainItem;
105
106 string damageZone = RepairTentPartActionData.Cast(action_data).m_DamageZone;
107 if (!GetGame().IsMultiplayer())
108 damageZone = m_CurrentDamageZone;
109
110 if ( targetParent && targetParent.IsInherited(TentBase) && damageZone != "" )
111 {
112 TentBase tent = TentBase.Cast( targetParent );
113 float m_RepairedLevel = usedItem.GetHealthLevel();
114
115 tent.SetAllowDamage(true);
116 targetParent.SetHealth01("" + damageZone, "", targetParent.GetHealthLevelValue(m_RepairedLevel));
117 tent.ProcessInvulnerabilityCheck(tent.GetInvulnerabilityTypeString());
118
119 if (usedItem.GetQuantity() > 1)
120 {
121 //Not really clean, but will do for now
122 int val = usedItem.GetQuantity();
123 val--;
124 usedItem.SetQuantity(val);
125 }
126 else
127 usedItem.Delete();
128 }
129 }
130
132 {
133 RepairTentPartActionData action_data = new RepairTentPartActionData;
134 return action_data;
135 }
136
137 override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
138 {
139 super.WriteToContext(ctx, action_data);
140 RepairTentPartActionData repair_action_data;
141
142 if( HasTarget() && Class.CastTo(repair_action_data,action_data) )
143 {
144 repair_action_data.m_DamageZone = m_CurrentDamageZone;
145 ctx.Write(repair_action_data.m_DamageZone);
146 }
147 }
148
149 override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data )
150 {
151 if(!action_recive_data)
152 {
153 action_recive_data = new RepairTentPartActionReciveData;
154 }
155 super.ReadFromContext(ctx, action_recive_data);
156 RepairTentPartActionReciveData recive_data_repair = RepairTentPartActionReciveData.Cast(action_recive_data);
157
158 if( HasTarget() )
159 {
160 string zone;
161 if ( !ctx.Read(zone) )
162 return false;
163
164 recive_data_repair.m_DamageZoneRecived = zone;
165 }
166 return true;
167 }
168
169 override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
170 {
171 super.HandleReciveData(action_recive_data, action_data);
172
173 RepairTentPartActionReciveData recive_data_repair = RepairTentPartActionReciveData.Cast(action_recive_data);
174 RepairTentPartActionData.Cast(action_data).m_DamageZone = recive_data_repair.m_DamageZoneRecived;
175 }
176};
protected float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
protected string m_Text
Definition ActionBase.c:49
protected bool m_FullBody
Definition ActionBase.c:52
protected int m_StanceMask
Definition ActionBase.c:53
RepairCarChassisActionReciveData m_DamageZone
class ActionTargets ActionTarget
PluginBase GetPlugin(typename plugin_type)
protected ActionData m_ActionData
ItemBase m_MainItem
Definition ActionBase.c:28
ref CABase m_ActionComponent
Definition ActionBase.c:30
ref ActionTarget m_Target
Definition ActionBase.c:32
override void CreateActionComponent()
override void OnFinishProgressServer(ActionData action_data)
override ActionData CreateActionData()
override void CreateConditionComponents()
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
override bool IsUsingProxies()
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
const float DEFAULT
const float BASEBUILDING_REPAIR_FAST
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int STATE_RUINED
Definition constants.c:742