Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuouswaterplant.c
Go to the documentation of this file.
2 {
3  protected float m_PlantThirstyness;
4  protected float m_TimeToComplete;
5 
6  void CAContinuousWaterPlant( float quantity_used_per_second )
7  {
8  m_QuantityUsedPerSecond = quantity_used_per_second;
9  }
10 
11  override void Setup( ActionData action_data )
12  {
13  PlantBase target_PB;
14  if (Class.CastTo(target_PB, action_data.m_Target.GetObject()))
15  {
16  m_SpentQuantity = 0;
17  if ( !m_SpentUnits )
18  {
19  m_SpentUnits = new Param1<float>(0);
20  }
21  else
22  {
23  m_SpentUnits.param1 = 0;
24  }
25  if ( action_data.m_MainItem )
26  {
27  m_ItemQuantity = action_data.m_MainItem.GetQuantity();
28  }
29  if ( target_PB )
30  {
31  m_PlantThirstyness = target_PB.GetWaterMax() - target_PB.GetWater();
32  }
33 
34  m_TimeToComplete = (Math.Min(m_PlantThirstyness,m_ItemQuantity))/m_QuantityUsedPerSecond;
35  }
36  }
37 
38  override int Execute( ActionData action_data )
39  {
40  if ( !action_data.m_Player )
41  {
42  return UA_ERROR;
43  }
44 
45  if ( m_ItemQuantity <= 0 )
46  {
47  return UA_FINISHED;
48  }
49  else
50  {
51  if ( m_SpentQuantity < m_ItemQuantity && m_SpentQuantity < m_PlantThirstyness )
52  {
53  m_AdjustedQuantityUsedPerSecond = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( m_QuantityUsedPerSecond, m_Action.GetSpecialtyWeight(), true);
54  m_SpentQuantity += m_QuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
55 
56  if ( m_Action )
57  {
58  PlantBase plant;
59  Class.CastTo(plant, action_data.m_Target.GetObject() );
60  Slot slot = plant.GetSlot();
61  slot.GiveWater( m_SpentQuantity );
62  }
63  return UA_PROCESSING;
64  }
65  else
66  {
67  CalcAndSetQuantity( action_data );
68  OnCompletePogress(action_data);
69  return UA_FINISHED;
70  }
71  }
72  }
73 
74  override float GetProgress()
75  {
76  //float progress = (m_SpentQuantity*m_QuantityUsedPerSecond)/m_TimeToComplete;
77  return (m_SpentQuantity*m_QuantityUsedPerSecond)/m_TimeToComplete;
78  }
79 };
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
CAContinuousQuantity
Definition: cacontinuousquantity.c:1
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionData
Definition: actionbase.c:20
CalcAndSetQuantity
protected void CalcAndSetQuantity()
Definition: fireplacebase.c:2622
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
Math
Definition: enmath.c:6
m_Action
enum ActionInputType m_Action
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
CAContinuousWaterPlant
Definition: cacontinuouswaterplant.c:1