Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuousdisinfectplant.c
Go to the documentation of this file.
2 {
3  protected float m_PlantNeededSpraying;
4  protected float m_TimeToComplete;
5  protected float m_SpentQuantityTotal;
6  protected float m_StartQuantity;
7  protected PlantBase m_Plant;
8 
9  void CAContinuousDisinfectPlant( float quantity_used_per_second )
10  {
11  m_QuantityUsedPerSecond = quantity_used_per_second;
12  }
13 
14  override void Setup( ActionData action_data )
15  {
16  GardenBase garden_base;
17  ActionTarget target = action_data.m_Target;
18  if ( Class.CastTo(garden_base, target.GetObject()))
19  {
20  Slot slot;
21 
22  array<string> selections = new array<string>;
23  garden_base.GetActionComponentNameList(target.GetComponentIndex(), selections);
24  string selection;
25 
26  for (int s = 0; s < selections.Count(); s++)
27  {
28  selection = selections[s];
29  slot = garden_base.GetSlotBySelection( selection );
30  if (slot)
31  break;
32  }
33 
34  if ( slot && slot.GetPlant() )
35  {
36  m_Plant = PlantBase.Cast(slot.GetPlant());
37  if ( m_Plant )
38  {
39  m_SpentQuantity = 0;
40  m_StartQuantity = action_data.m_MainItem.GetQuantity();
41  if ( !m_SpentUnits )
42  {
43  m_SpentUnits = new Param1<float>(0);
44  }
45  else
46  {
47  m_SpentUnits.param1 = 0;
48  }
49  if ( action_data.m_MainItem )
50  {
51  m_ItemQuantity = action_data.m_MainItem.GetQuantity();
52  }
53  if ( m_Plant )
54  {
55  m_PlantNeededSpraying = m_Plant.GetSprayUsage() - m_Plant.GetSprayQuantity();
56  }
57 
58  m_TimeToComplete = (Math.Min(m_PlantNeededSpraying,m_ItemQuantity))/m_QuantityUsedPerSecond;
59  }
60  }
61  }
62 
63  /*PlantBase target_PB;
64  if (Class.CastTo(target_PB, action_data.m_Target.GetObject()))
65  {
66  m_SpentQuantity = 0;
67  m_StartQuantity = action_data.m_MainItem.GetQuantity();
68  if ( !m_SpentUnits )
69  {
70  m_SpentUnits = new Param1<float>(0);
71  }
72  else
73  {
74  m_SpentUnits.param1 = 0;
75  }
76  if ( action_data.m_MainItem )
77  {
78  m_ItemQuantity = action_data.m_MainItem.GetQuantity();
79  }
80  if ( target_PB )
81  {
82  m_PlantNeededSpraying = target_PB.GetSprayUsage() - target_PB.GetSprayQuantity();
83  }
84 
85  m_TimeToComplete = (Math.Min(m_PlantNeededSpraying,m_ItemQuantity))/m_QuantityUsedPerSecond;
86  }*/
87  }
88 
89  override int Execute( ActionData action_data )
90  {
91  Object targetObject = action_data.m_Target.GetObject();
92 
93  if ( !action_data.m_Player )
94  {
95  return UA_ERROR;
96  }
97 
98  if ( m_ItemQuantity <= 0 )
99  {
100  return UA_FINISHED;
101  }
102  else
103  {
104  if ( m_SpentQuantity < m_ItemQuantity && m_SpentQuantity < m_PlantNeededSpraying )
105  {
106  m_SpentQuantity += m_QuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
107  float transfered_spray = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( m_SpentQuantity, m_Action.GetSpecialtyWeight(), true );
108 
109  m_SpentQuantityTotal += m_SpentQuantity;
110 
111  if ( m_Action )
112  {
113  /*PlantBase plant;
114  Class.CastTo(plant, targetObject );*/
115  m_Plant.SprayPlant(transfered_spray);
116  //m_Action.SendMessageToClient(action_data.m_Player, plant.StopInfestation( transfered_spray ));
117  }
118 
119  CalcAndSetQuantity( action_data );
120 
121  return UA_PROCESSING;
122  }
123  else
124  {
125  CalcAndSetQuantity( action_data );
126  OnCompletePogress(action_data);
127  return UA_FINISHED;
128  }
129  }
130  }
131 
132  override float GetProgress()
133  {
134  //return (m_SpentQuantity*m_QuantityUsedPerSecond)/m_TimeToComplete;
135  return -(m_SpentQuantityTotal / m_StartQuantity);
136  }
137 };
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
CAContinuousQuantity
Definition: cacontinuousquantity.c:1
CAContinuousDisinfectPlant
Definition: cacontinuousdisinfectplant.c:1
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
Object
Definition: objecttyped.c:1
CalcAndSetQuantity
protected void CalcAndSetQuantity()
Definition: fireplacebase.c:2622
array< string >
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
Math
Definition: enmath.c:6
GardenBase
Definition: gardenplot.c:1
m_Action
enum ActionInputType m_Action
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10