DayZ 1.24
Loading...
Searching...
No Matches
ActionRepairPart.c
Go to the documentation of this file.
1
2/*
3 TODO:
4 No pairing with part and tool similar to 'CanUseToolToBuildPart' exists here, since only one type of part is damage-able at this point.
5 This should be handled by adding "repair_action_type" array to basebuilding and tool configs, this would allow for independent pairing of repair action.
6*/
7
8class RepairPartActionReciveData : ActionReciveData
9{
11}
12
14{
16}
17
19{
25
27 {
28 /*switch( item.Type() )
29 {
30 case WoodAxe:
31 return UATimeSpent.BASEBUILDING_REPAIR_SLOW;
32 default:
33 return UATimeSpent.BASEBUILDING_REPAIR_FAST;
34 }*/
36 }
37};
38
40{
42 {
44 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ASSEMBLE;
45 m_FullBody = true;
46 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
47
49 m_Text = "#repair";
50 }
51
57
59 {
60 ConstructionActionData construction_action_data = player.GetConstructionActionData();
61 m_Text = "#repair " + construction_action_data.GetTargetPart().GetName();
62 }
63
64 override string GetText()
65 {
67 if (player)
68 {
69 ConstructionActionData construction_action_data = player.GetConstructionActionData();
71
73 return "#repair" + " " + constrution_part.GetName();
74 }
75
76 return "";
77 }
78
79 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
80 {
81 //Action not allowed if player has broken legs
82 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
83 return false;
84
85 return RepairCondition(player, target, item, true);
86 }
87
89 {
90 return RepairCondition(action_data.m_Player, action_data.m_Target, action_data.m_MainItem, false);
91 }
92
94 {
96 Construction construction = base_building.GetConstruction();
97
98 //repairing
99 string part_name = action_data.m_Target.GetObject().GetActionComponentName(RepairPartActionData.Cast(action_data).m_ComponentIndex);
100 string zone_name;
103
104 DamageSystem.GetDamageZoneFromComponentName(base_building, part_name, zone_name);
106
107 //consume materials
108 construction.TakeMaterialsServer(part_name, true);
109
110 //add damage to tool
111 action_data.m_MainItem.DecreaseHealth(UADamageApplied.REPAIR, false);
112
113 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
114 }
115
116 protected override void SetBuildingAnimation(ItemBase item)
117 {
118 switch (item.Type())
119 {
120 case Pickaxe:
121 case Shovel:
122 case FarmingHoe:
123 case FieldShovel:
124 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIG;
125 break;
126 case Pliers:
127 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
128 break;
129 default:
130 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ASSEMBLE;
131 break;
132 }
133 }
134
140
142 {
143 super.WriteToContext(ctx, action_data);
145
147 {
148 repair_action_data.m_ComponentIndex = action_data.m_Target.GetComponentIndex();
149 ctx.Write(repair_action_data.m_ComponentIndex);
150 }
151 }
152
154 {
158
159 super.ReadFromContext(ctx, action_recive_data);
160
161 if (HasTarget())
162 {
163 int component_index;
164 if (!ctx.Read(component_index))
165 return false;
166
167 recive_data_repair.m_ComponentIndexRecived = component_index;
168 }
169 return true;
170 }
171
173 {
174 super.HandleReciveData(action_recive_data, action_data);
175
177 RepairPartActionData.Cast(action_data).m_ComponentIndex = recive_data_repair.m_ComponentIndexRecived;
178 }
179
180 protected bool RepairCondition(PlayerBase player, ActionTarget target, ItemBase item, bool camera_check)
181 {
182 string zone_name;
183
184 Object target_object = target.GetObject();
185 if (target_object && target_object.CanUseConstruction())
186 {
187 string part_name = target_object.GetActionComponentName(target.GetComponentIndex());
188
190 Construction construction = base_building.GetConstruction();
192
194 {
195 //camera and position checks
196 if (!base_building.IsFacingPlayer(player, part_name) && !player.GetInputController().CameraIsFreeLook() && base_building.HasProperDistance(construction_part.GetMainPartName(), player))
197 {
198 //Camera check (client-only)
199 if (camera_check)
200 {
201 if (GetGame() && (!GetGame().IsDedicatedServer()))
202 {
203 if (base_building.IsFacingCamera(part_name))
204 return false;
205 }
206 }
207
208 //damage check
209 DamageSystem.GetDamageZoneFromComponentName(base_building, part_name, zone_name);
211 return false;
212
213 //materials check
214 if (!construction.HasMaterials(part_name, true))
215 return false;
216
217 ConstructionActionData construction_action_data = player.GetConstructionActionData();
219 return true;
220 }
221 }
222 }
223
224 return false;
225 }
226
228 {
229 return " repaired " + action_data.m_Target.GetObject().GetDisplayName() + " with " + action_data.m_MainItem.GetDisplayName();
230 }
231}
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
bool HasTarget()
Definition ActionBase.c:210
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 Construction(BaseBuildingBase parent)
eBrokenLegs
Definition EBrokenLegs.c:2
int m_ComponentIndex
PlayerBase GetPlayer()
PluginBase GetPlugin(typename plugin_type)
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
ItemBase m_MainItem
Definition ActionBase.c:28
float SetCallbackDuration(ItemBase item)
override void CreateActionComponent()
override void SetBuildingAnimation(ItemBase item)
override string GetText()
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
override string GetAdminLogMessage(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
override void OnFinishProgressServer(ActionData action_data)
override ActionData CreateActionData()
override bool ActionConditionContinue(ActionData action_data)
bool RepairCondition(PlayerBase player, ActionTarget target, ItemBase item, bool camera_check)
override void CreateConditionComponents()
Super root of all classes in Enforce script.
Definition EnScript.c:11
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
const float BASEBUILDING
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 int STATE_RUINED
Definition constants.c:757
const int STATE_WORN
Definition constants.c:760