DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
CAContinuousFertilizeGardenSlot.c
Go to the documentation of this file.
2{
3 protected float m_SlotFertilizerNeed;
4 protected float m_TimeToComplete;
5 protected float m_SpentQuantityTotal;
6 protected float m_StartQuantity;
7 protected Slot m_Slot;
8 protected string m_Selection;
9
10 void CAContinuousFertilizeGardenSlot( float quantity_used_per_second )
11 {
12 m_QuantityUsedPerSecond = quantity_used_per_second;
14 }
15
16 override void Setup( ActionData action_data )
17 {
18 GardenBase target_GB;
19 if ( Class.CastTo(target_GB, action_data.m_Target.GetObject() ) )
20 {
22 m_StartQuantity = action_data.m_MainItem.GetQuantity();
23
24 if ( !m_SpentUnits )
25 {
26 m_SpentUnits = new Param1<float>(0);
27 }
28 else
29 {
30 m_SpentUnits.param1 = 0;
31 }
32
33 if ( action_data.m_MainItem )
34 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
35
36 if ( target_GB )
37 {
38 /*string selection = target_GB.GetActionComponentName(action_data.m_Target.GetComponentIndex());
39
40 Slot slot = target_GB.GetSlotBySelection( selection );*/
41
42 array<string> selections = new array<string>;
43 target_GB.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
44
45 for (int s = 0; s < selections.Count(); s++)
46 {
47 //string selection = selections[s];
48 m_Selection = selections[s];
49 m_Slot = target_GB.GetSlotBySelection( m_Selection );
50 if (m_Slot)
51 break;
52 }
53
54
55 string item_type = action_data.m_MainItem.GetType();
56 float consumed_quantity = GetGame().ConfigGetFloat( "cfgVehicles " + item_type + " Horticulture ConsumedQuantity" );
57
58 float max = m_Slot.GetFertilizerQuantityMax();
59
60 m_SlotFertilizerNeed = max - consumed_quantity;
61 }
63 }
64 }
65
66
67 override int Execute( ActionData action_data )
68 {
69 if ( !action_data.m_Player )
70 {
71 return UA_ERROR;
72 }
73
75 {
76 return UA_FINISHED;
77 }
78 else
79 {
81 {
82 m_SpentQuantity += m_QuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
83 float val = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( m_SpentQuantity, m_Action.GetSpecialtyWeight(), true );
84 GardenBase garden_base;
85 Class.CastTo(garden_base, action_data.m_Target.GetObject() );
86 //string selection = garden_base.GetActionComponentName(action_data.m_Target.GetComponentIndex());
87
89
90 if (GetGame().IsServer())
91 {
92 action_data.m_MainItem.AddQuantity( -m_SpentQuantity );
93 }
94
95 garden_base.Fertilize( action_data.m_Player, action_data.m_MainItem, val, m_Selection );
96
97 return UA_PROCESSING;
98 }
99 else
100 {
101 CalcAndSetQuantity( action_data );
102 OnCompletePogress(action_data);
103 return UA_FINISHED;
104 }
105 }
106 }
107
108 override float GetProgress()
109 {
110 /*if ( m_TimeToComplete == 0) //Prevent division by 0 case
111 {
112 return -1;
113 }*/
115 //return (m_SpentQuantity)/m_ItemQuantity;///(m_TimeToComplete * m_QuantityUsedPerSecond)/m_ItemQuantity;
116 }
117};
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)
override int Execute(ActionData action_data)
void CAContinuousFertilizeGardenSlot(float quantity_used_per_second)
override void Setup(ActionData action_data)
protected float m_QuantityUsedPerSecond
protected ref Param1< float > m_SpentUnits
protected float m_ItemQuantity
protected float m_SpentQuantity
proto native float ConfigGetFloat(string path)
Get float value from config on path.
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
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 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