DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
CAContinuousWaterSlot.c
Go to the documentation of this file.
2{
3 protected float m_PlantThirstyness;
4 protected float m_TimeToComplete;
5 protected float m_SpentQuantityTotal;
6 protected float m_StartQuantity;
7 protected Slot m_Slot;
8
9 void CAContinuousWaterSlot( 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 target_GB;
17
18 if ( Class.CastTo(target_GB, action_data.m_Target.GetObject()) )
19 {
21 m_StartQuantity = action_data.m_MainItem.GetQuantity();
22 if ( !m_SpentUnits )
23 {
24 m_SpentUnits = new Param1<float>(0);
25 }
26 else
27 {
28 m_SpentUnits.param1 = 0;
29 }
30
31 if ( action_data.m_MainItem )
32 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
33
34 if ( target_GB )
35 {
36 array<string> selections = new array<string>;
37 target_GB.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
38
39 for (int s = 0; s < selections.Count(); s++)
40 {
41 string selection = selections[s];
42 m_Slot = target_GB.GetSlotBySelection( selection );
43 if (m_Slot)
44 break;
45 }
46
47 m_PlantThirstyness = m_Slot.GetWaterUsage() - m_Slot.GetWater();
48 }
49
51
52 if (m_TimeToComplete <= 0.1) // Division by zero prevention
53 {
54 m_TimeToComplete = 0.1;
55 }
56 }
57 }
58
59 override int Execute( ActionData action_data )
60 {
61 GardenBase target_GB;
62 Class.CastTo(target_GB, action_data.m_Target.GetObject() );
63 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
64 m_ItemMaxQuantity = action_data.m_MainItem.GetQuantityMax();
65
66 if ( !action_data.m_Player )
67 {
68 return UA_ERROR;
69 }
70
71 if ( m_ItemQuantity <= 0 )
72 {
73 return UA_FINISHED;
74 }
75 else
76 {
78 {
79 m_SpentQuantity += m_QuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
80 float water = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( m_SpentQuantity, m_Action.GetSpecialtyWeight(), true );
81 m_Slot.GiveWater( water );
82
84 CalcAndSetQuantity( action_data );
85
87
88 return UA_PROCESSING;
89 }
90 else
91 {
92 CalcAndSetQuantity( action_data );
93 OnCompletePogress( action_data );
94
95 return UA_FINISHED;
96 }
97 }
98 }
99
100 override float GetProgress()
101 {
102 if ( m_ItemQuantity <= 0 )
103 return 1;
104 float progress = -(m_SpentQuantityTotal / m_StartQuantity);
105 return progress;
106 }
107};
protected void CalcAndSetQuantity()
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionTarget m_Target
Definition ActionBase.c:32
protected ActionBase m_Action
Definition CABase.c:3
void OnCompletePogress(ActionData action_data)
protected float m_ItemMaxQuantity
protected float m_QuantityUsedPerSecond
protected ref Param1< float > m_SpentUnits
protected float m_ItemQuantity
protected float m_SpentQuantity
protected float m_PlantThirstyness
void CAContinuousWaterSlot(float quantity_used_per_second)
protected float m_TimeToComplete
override int Execute(ActionData action_data)
protected float m_SpentQuantityTotal
protected float m_StartQuantity
override void Setup(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Min(float x, float y)
Returns smaller of two given values.
const int UA_FINISHED
Definition constants.c:420
const int UA_ERROR
Definition constants.c:439
const int UA_PROCESSING
Definition constants.c:418