Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionrepairtentpart.c
Go to the documentation of this file.
1 class RepairTentPartActionReciveData : ActionReciveData
2 {
3  string m_DamageZoneRecived;
4 }
5 
6 class RepairTentPartActionData : ActionData
7 {
8  string m_DamageZone;
9 }
10 
12 {
13  override void CreateActionComponent()
14  {
15  m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.BASEBUILDING_REPAIR_FAST);
16  }
17 };
18 
20 {
21  typename m_LastValidType;
22  string m_CurrentDamageZone = "";
23  int m_LastValidComponentIndex = -1;
24 
26  {
27  m_CallbackClass = ActionRepairTentPartCB;
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 
36  override void CreateConditionComponents()
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 
131  override ActionData CreateActionData()
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 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
CAContinuousTime
Definition: cacontinuoustime.c:1
ActionRepairTentPart
Definition: actionrepairtentpart.c:19
UASoftSkillsWeight
Definition: actionconstants.c:118
m_DamageZone
RepairTentPartActionReciveData m_DamageZone
RepairTentPartActionReciveData
Definition: actionrepairtentpart.c:1
CCTCursorParent
Definition: cctcursorparent.c:1
UAMaxDistances
Definition: actionconstants.c:104
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
Object
Definition: objecttyped.c:1
ActionRepairTentPartCB
Definition: actionrepairtentpart.c:11
TentBase
Definition: cartent.c:1
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
array< string >
m_CurrentDamageZone
string m_CurrentDamageZone
Definition: actionrepaircarengine.c:22
m_Text
protected string m_Text
Definition: actionbase.c:49
GameConstants
Definition: constants.c:612
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
m_LastValidComponentIndex
int m_LastValidComponentIndex
Definition: actionrepaircarengine.c:23
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53