DayZ 1.24
Loading...
Searching...
No Matches
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
13
15 {
17 ActionTarget target = action_data.m_Target;
18 if (Class.CastTo(garden_base, target.GetObject()))
19 {
20 Slot slot;
21
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 {
40 m_StartQuantity = action_data.m_MainItem.GetQuantity();
41 if (!m_SpentUnits)
43 else
44 m_SpentUnits.param1 = 0;
45 if (action_data.m_MainItem)
46 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
47 if (m_Plant)
48 m_PlantNeededSpraying = m_Plant.GetSprayUsage() - m_Plant.GetSprayQuantity();
49
51 }
52 }
53 }
54
55 /*PlantBase target_PB;
56 if (Class.CastTo(target_PB, action_data.m_Target.GetObject()))
57 {
58 m_SpentQuantity = 0;
59 m_StartQuantity = action_data.m_MainItem.GetQuantity();
60 if ( !m_SpentUnits )
61 {
62 m_SpentUnits = new Param1<float>(0);
63 }
64 else
65 {
66 m_SpentUnits.param1 = 0;
67 }
68 if ( action_data.m_MainItem )
69 {
70 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
71 }
72 if ( target_PB )
73 {
74 m_PlantNeededSpraying = target_PB.GetSprayUsage() - target_PB.GetSprayQuantity();
75 }
76
77 m_TimeToComplete = (Math.Min(m_PlantNeededSpraying,m_ItemQuantity))/m_QuantityUsedPerSecond;
78 }*/
79 }
80
82 {
83 Object targetObject = action_data.m_Target.GetObject();
84
85 if (!action_data.m_Player)
86 return UA_ERROR;
87
88 if (m_ItemQuantity <= 0)
89 return UA_FINISHED;
90 else
91 {
93 {
94 m_SpentQuantity += m_QuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
95 float transfered_spray = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus(m_SpentQuantity, m_Action.GetSpecialtyWeight(), true);
96
98
99 if (m_Action)
100 {
101 /*PlantBase plant;
102 Class.CastTo(plant, targetObject );*/
103 m_Plant.SprayPlant(transfered_spray);
104 //m_Action.SendMessageToClient(action_data.m_Player, plant.StopInfestation( transfered_spray ));
105 }
106
108
109 return UA_PROCESSING;
110 }
111 else
112 {
115 return UA_FINISHED;
116 }
117 }
118 }
119
120 override float GetProgress()
121 {
122 //return (m_SpentQuantity*m_QuantityUsedPerSecond)/m_TimeToComplete;
124 }
125};
void CalcAndSetQuantity()
ActionBase m_Action
Definition CABase.c:3
void OnCompletePogress(ActionData action_data)
override int Execute(ActionData action_data)
void CAContinuousDisinfectPlant(float quantity_used_per_second)
override void Setup(ActionData action_data)
ref Param1< float > m_SpentUnits
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
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:436
const int UA_ERROR
Definition constants.c:455
const int UA_PROCESSING
Definition constants.c:434