3 protected float m_TimeElpased;
4 protected float m_AdjustedTimeBetweenMaterialDrops;
5 protected float m_CycleTimeOverride;
6 protected float m_TimeBetweenMaterialDrops;
7 protected float m_DamageToMiningItemEachDrop;
8 protected float m_AdjustedDamageToMiningItemEachDrop;
9 protected int m_AmountOfDrops;
10 protected int m_CurrentAssumedDrops;
12 protected float m_TimeToComplete;
13 protected ref Param1<float> m_SpentUnits;
14 protected bool m_DataLoaded =
false;
15 protected const int MINEDITEM_MAX = 5;
16 protected ItemBase m_MinedItem[MINEDITEM_MAX];
21 m_TimeBetweenMaterialDrops = time_between_drops;
22 m_CycleTimeOverride = -1.0;
30 m_SpentUnits =
new Param1<float>(0);
34 m_SpentUnits.param1 = 0;
37 m_DataLoaded = GetMiningData(action_data);
39 if (m_CycleTimeOverride > -1.0)
41 m_TimeBetweenMaterialDrops = m_CycleTimeOverride;
42 if (!action_data.m_MainItem)
43 m_TimeBetweenMaterialDrops = m_TimeBetweenMaterialDrops * 3;
45 m_AdjustedTimeBetweenMaterialDrops = action_data.m_Player.GetSoftSkillsManager().SubtractSpecialtyBonus( m_TimeBetweenMaterialDrops,
m_Action.GetSpecialtyWeight(),
true );
46 m_TimeToComplete = m_AmountOfDrops * m_AdjustedTimeBetweenMaterialDrops;
52 Class.CastTo(targetObject, action_data.m_Target.GetObject());
53 if ( !action_data.m_Player || !m_DataLoaded )
58 if ( (action_data.m_MainItem && action_data.m_MainItem.IsDamageDestroyed()) || targetObject.IsDamageDestroyed() )
64 if ( m_TimeElpased < m_AdjustedTimeBetweenMaterialDrops )
66 m_TimeElpased += action_data.m_Player.GetDeltaT();
73 if (m_AmountOfDrops > 0)
74 damage = (1 / m_AmountOfDrops) * 100;
76 targetObject.DecreaseHealth(
"",
"", damage, targetObject.CanBeAutoDeleted());
77 CreatePrimaryItems(action_data);
78 if (action_data.m_MainItem)
79 action_data.m_MainItem.DecreaseHealth(
"",
"", m_AdjustedDamageToMiningItemEachDrop );
82 DamagePlayersHands(action_data.m_Player);
85 if ( targetObject.IsDamageDestroyed() )
89 m_SpentUnits.param1 = m_TimeElpased;
90 SetACData(m_SpentUnits);
97 if (target_woodbase.GetSecondaryOutput() !=
"")
98 CreateSecondaryItems(action_data,target_woodbase.GetSecondaryOutput(),target_woodbase.GetSecondaryDropsAmount());
101 if (action_data.m_MainItem)
103 targetObject.OnTreeCutDown( action_data.m_MainItem );
107 targetObject.OnTreeCutDown( action_data.m_Player );
112 m_CurrentAssumedDrops++;
113 if (m_AmountOfDrops > 0 && m_CurrentAssumedDrops >= m_AmountOfDrops)
115 OnCompletePogress(action_data);
119 m_TimeElpased = m_TimeElpased - m_AdjustedTimeBetweenMaterialDrops;
120 OnCompletePogress(action_data);
126 override float GetProgress()
128 return m_TimeElpased/m_AdjustedTimeBetweenMaterialDrops;
137 if (
Class.CastTo(ntarget, action_data.m_Target.GetObject()) )
139 m_AmountOfDrops = ntarget.GetAmountOfDropsEx(action_data.m_MainItem,adata.m_HarvestType);
140 m_CurrentAssumedDrops = 0;
141 m_CycleTimeOverride = ntarget.GetCycleTimeOverride();
142 ntarget.GetMaterialAndQuantityMapEx(action_data.m_MainItem,m_MaterialAndQuantityMap, adata.m_HarvestType);
143 m_DamageToMiningItemEachDrop = ntarget.GetDamageToMiningItemEachDropEx(action_data.m_MainItem, adata.m_HarvestType );
144 m_AdjustedDamageToMiningItemEachDrop = action_data.m_Player.GetSoftSkillsManager().SubtractSpecialtyBonus( m_DamageToMiningItemEachDrop,
m_Action.GetSpecialtyWeight(),
true );
150 void CreatePrimaryItems(
ActionData action_data)
154 for (
int i = 0; i < m_MaterialAndQuantityMap.Count(); i++)
156 material = m_MaterialAndQuantityMap.GetKey(i);
160 increment = m_MaterialAndQuantityMap.GetElement(i);
162 if ( !m_MinedItem[i] )
165 m_MinedItem[i].SetQuantity(increment);
171 int stack_max = m_MinedItem[i].GetQuantityMax();
173 increment -= stack_max - m_MinedItem[i].GetQuantity();
174 if (increment >= 1.0)
177 m_MinedItem[i].SetQuantity(increment,
false);
182 m_MinedItem[i].AddQuantity(increment,
false);
193 void CreateSecondaryItems(
ActionData action_data,
string material_secondary =
"",
int quantity_secondary = -1)
195 if (material_secondary ==
"" || quantity_secondary <= 0)
201 if ( !m_SecondaryItem.HasQuantity() )
203 CreateSecondaryItems(action_data,material_secondary,quantity_secondary - 1);
207 int increment = quantity_secondary;
208 int stack_max = m_SecondaryItem.GetQuantityMax();
211 stacks_amount =
Math.Ceil(increment/stack_max);
213 for (
int i = 0; i < stacks_amount; i++)
215 if (increment > stack_max)
217 m_SecondaryItem.SetQuantity(stack_max);
218 increment -= stack_max;
223 m_SecondaryItem.SetQuantity(increment);
231 if ( gloves && !gloves.IsDamageDestroyed() )
233 gloves.DecreaseHealth(
"",
"",m_AdjustedDamageToMiningItemEachDrop);
237 int rand =
Math.RandomIntInclusive(0,9);
240 rand =
Math.RandomIntInclusive(0,1);
241 if ( rand == 0 && !player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection(
"LeftForeArmRoll") )
243 player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection(
"RightForeArmRoll");
245 else if ( rand == 1 && !player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection(
"RightForeArmRoll") )
247 player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection(
"LeftForeArmRoll");