DayZ 1.24
Loading...
Searching...
No Matches
CAContinuousMineWood.c
Go to the documentation of this file.
2{
3 protected float m_TimeElpased;
5 protected float m_CycleTimeOverride;
9 protected int m_AmountOfDrops;
10 protected int m_CurrentAssumedDrops;
12 protected float m_TimeToComplete;
14 protected bool m_DataLoaded = false;
15 protected const int MINEDITEM_MAX = 5;
18
24
26 {
27 m_TimeElpased = 0;
28 if (!m_SpentUnits)
30 else
31 m_SpentUnits.param1 = 0;
34
35 if (m_CycleTimeOverride > -1.0)
36 {
38 if (!action_data.m_MainItem) //hand action
40 }
41 m_AdjustedTimeBetweenMaterialDrops = action_data.m_Player.GetSoftSkillsManager().SubtractSpecialtyBonus(m_TimeBetweenMaterialDrops, m_Action.GetSpecialtyWeight(), true);
43 }
44
46 {
48 Class.CastTo(targetObject, action_data.m_Target.GetObject());
49 if (!action_data.m_Player || !m_DataLoaded)
50 return UA_ERROR;
51
52 if ((action_data.m_MainItem && action_data.m_MainItem.IsDamageDestroyed()) || targetObject.IsDamageDestroyed())
53 return UA_FINISHED;
54 else
55 {
57 m_TimeElpased += action_data.m_Player.GetDeltaT();
58 else
59 {
60 if (GetGame().IsServer())
61 {
62 float damage = 0;
63 if (m_AmountOfDrops > 0)
64 damage = (1 / m_AmountOfDrops) * 100;
65
66 targetObject.DecreaseHealth("", "", damage, targetObject.CanBeAutoDeleted());
68 if (action_data.m_MainItem)
69 action_data.m_MainItem.DecreaseHealth("", "", m_AdjustedDamageToMiningItemEachDrop);
70 else
72
73 if (targetObject.IsDamageDestroyed()) //client does not know the target is destroyed yet, happens on the next Execute!
74 {
75 if (m_SpentUnits)
76 {
79 }
80
81 if (WoodBase.Cast(targetObject))
82 {
84
85 if (target_woodbase.GetSecondaryOutput() != "")
86 CreateSecondaryItems(action_data, target_woodbase.GetSecondaryOutput(), target_woodbase.GetSecondaryDropsAmount());
87 }
88
89 if (action_data.m_MainItem)
90 targetObject.OnTreeCutDown(action_data.m_MainItem);
91 else
92 targetObject.OnTreeCutDown(action_data.m_Player);
93 }
94 }
95
97 if (m_AmountOfDrops > 0 && m_CurrentAssumedDrops >= m_AmountOfDrops) //assumed end, client does not know the target is destroyed yet
98 {
100 return UA_FINISHED;
101 }
102
105 }
106 return UA_PROCESSING;
107 }
108 }
109
110 override float GetProgress()
111 {
113 }
114
115 //---------------------------------------------------------------------------
116
118 {
121 if (Class.CastTo(ntarget, action_data.m_Target.GetObject()))
122 {
123 m_AmountOfDrops = ntarget.GetAmountOfDropsEx(action_data.m_MainItem, adata.m_HarvestType);
125 m_CycleTimeOverride = ntarget.GetCycleTimeOverride(); //TODO
126 ntarget.GetMaterialAndQuantityMapEx(action_data.m_MainItem, m_MaterialAndQuantityMap, adata.m_HarvestType);
127 m_DamageToMiningItemEachDrop = ntarget.GetDamageToMiningItemEachDropEx(action_data.m_MainItem, adata.m_HarvestType);
128 m_AdjustedDamageToMiningItemEachDrop = action_data.m_Player.GetSoftSkillsManager().SubtractSpecialtyBonus(m_DamageToMiningItemEachDrop, m_Action.GetSpecialtyWeight(), true);
129 return true;
130 }
131 return false;
132 }
133
135 {
136 string material;
137 int increment;
138 for (int i = 0; i < m_MaterialAndQuantityMap.Count(); i++)
139 {
141
142 if (material != "")
143 {
145
146 if (!m_MinedItem[i])
147 {
148 m_MinedItem[i] = ItemBase.Cast(GetGame().CreateObjectEx(material, action_data.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
149 m_MinedItem[i].SetQuantity(increment);
150 }
151 else if (m_MinedItem[i].HasQuantity())
152 {
154 {
155 int stack_max = m_MinedItem[i].GetQuantityMax();
156
157 increment -= stack_max - m_MinedItem[i].GetQuantity();
158 if (increment >= 1.0)
159 {
160 m_MinedItem[i] = ItemBase.Cast(GetGame().CreateObjectEx(material, action_data.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
161 m_MinedItem[i].SetQuantity(increment, false);
162 }
163 }
164 else
165 m_MinedItem[i].AddQuantity(increment, false);
166 }
167 else
168 m_MinedItem[i] = ItemBase.Cast(GetGame().CreateObjectEx(material, action_data.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
169 }
170 }
171 }
172
174 {
175 if (material_secondary == "" || quantity_secondary <= 0)
176 return;
177
178 m_SecondaryItem = ItemBase.Cast(GetGame().CreateObjectEx(material_secondary, action_data.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
179 if (!m_SecondaryItem.HasQuantity())
180 {
182 return;
183 }
184
186 int stack_max = m_SecondaryItem.GetQuantityMax();
187 int stacks_amount;
188
190
191 for (int i = 0; i < stacks_amount; i++)
192 {
193 if (increment > stack_max)
194 {
195 m_SecondaryItem.SetQuantity(stack_max);
197 m_SecondaryItem = ItemBase.Cast(GetGame().CreateObjectEx(material_secondary, action_data.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
198 }
199 else
200 m_SecondaryItem.SetQuantity(increment);
201 }
202 }
203
205 {
206 ItemBase gloves = ItemBase.Cast(player.FindAttachmentBySlotName("Gloves"));
207 if (gloves && !gloves.IsDamageDestroyed())
208 gloves.DecreaseHealth("", "", m_AdjustedDamageToMiningItemEachDrop);
209 else
210 {
211 int rand = Math.RandomIntInclusive(0, 9);
212 if (rand == 0)
213 {
215 if (rand == 0 && !player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll"))
216 player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("RightForeArmRoll");
217 else if (rand == 1 && !player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("RightForeArmRoll"))
218 player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll");
219 }
220 }
221 }
222};
const int ECE_PLACE_ON_SURFACE
bool HasQuantity()
Definition ItemBase.c:7990
bool IsFullQuantity()
Definition ItemBase.c:8000
void WoodBase()
Definition WoodBase.c:30
void SetACData(Param units)
Definition CABase.c:38
ActionBase m_Action
Definition CABase.c:3
void OnCompletePogress(ActionData action_data)
void CreateSecondaryItems(ActionData action_data, string material_secondary="", int quantity_secondary=-1)
override int Execute(ActionData action_data)
void DamagePlayersHands(PlayerBase player)
void CAContinuousMineWood(float time_between_drops)
override void Setup(ActionData action_data)
ref Param1< float > m_SpentUnits
bool GetMiningData(ActionData action_data)
void CreatePrimaryItems(ActionData action_data)
ref map< string, int > m_MaterialAndQuantityMap
ItemBase m_MinedItem[MINEDITEM_MAX]
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Ceil(float f)
Returns ceil of value.
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54
const int UA_FINISHED
Definition constants.c:436
const int UA_ERROR
Definition constants.c:455
const int UA_PROCESSING
Definition constants.c:434