DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
CAContinuousFillPowerGenerator.c
Go to the documentation of this file.
2{
3 void CAContinuousFillPowerGenerator( float quantity_filled_per_second , int liquid_type )
4 {
5 m_QuantityFilledPerSecond = quantity_filled_per_second;
6 m_liquid_type = liquid_type;
7 }
8
9 override void Setup( ActionData action_data )
10 {
11 m_TimeElpased = 0;
12
13 if ( !m_SpentUnits )
14 {
15 m_SpentUnits = new Param1<float>(0);
16 }
17 else
18 {
19 m_SpentUnits.param1 = 0;
20 }
21
22 EntityAI pg = EntityAI.Cast(action_data.m_Target.GetObject()); // get power generator
23 m_QuantityFilledPerSecond *= Math.Min(action_data.m_MainItem.GetLiquidThroughputCoef(),pg.GetLiquidThroughputCoef());
24
25 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
26 m_TargetUnits = pg.GetCompEM().GetEnergyMax() - pg.GetCompEM().GetEnergy();
27 m_AdjustedQuantityFilledPerSecond = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( m_QuantityFilledPerSecond, m_Action.GetSpecialtyWeight(), true );
28 }
29
30 override int Execute( ActionData action_data )
31 {
32 if ( !action_data.m_Player )
33 {
34 return UA_ERROR;
35 }
36
37 PowerGenerator pg = PowerGenerator.Cast(action_data.m_Target.GetObject()); // get power generator
38
39 if ( pg.GetFuel() >= pg.GetMaxFuel() )
40 {
41 return UA_FINISHED;
42 }
43 else
44 {
46 {
48 m_TimeElpased += action_data.m_Player.GetDeltaT();
49
51 {
52 CalcAndSetQuantity( action_data );
53 m_TimeElpased = 0;
54 //Setup(action_data); //reset data after repeat
55 }
56 return UA_PROCESSING;
57 }
58 else
59 {
60 CalcAndSetQuantity( action_data );
61 OnCompletePogress(action_data);
62 return UA_FINISHED;
63 }
64 }
65 }
66
67 override void CalcAndSetQuantity( ActionData action_data )
68 {
70
71 if ( m_SpentUnits )
72 {
75 }
76
77
78 if ( GetGame().IsServer() )
79 {
80 PowerGenerator pg = PowerGenerator.Cast(action_data.m_Target.GetObject()); // get power generator
81 int consumed_fuel = pg.AddFuel( m_SpentQuantity );
82 action_data.m_MainItem.AddQuantity( -consumed_fuel );
83 }
84
86 }
87};
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
void SetACData(Param units)
Definition CABase.c:40
protected ActionBase m_Action
Definition CABase.c:3
void OnCompletePogress(ActionData action_data)
protected float m_QuantityFilledPerSecond
protected float m_DefaultTimeStep
protected float m_SpentQuantity_total
protected ref Param1< float > m_SpentUnits
protected float m_TimeElpased
protected int m_liquid_type
protected float m_ItemQuantity
protected float m_AdjustedQuantityFilledPerSecond
protected float m_TargetUnits
protected float m_SpentQuantity
override int Execute(ActionData action_data)
void CAContinuousFillPowerGenerator(float quantity_filled_per_second, int liquid_type)
override void CalcAndSetQuantity(ActionData action_data)
override void Setup(ActionData action_data)
override float GetLiquidThroughputCoef()
Definition EnMath.c:7
proto native CGame GetGame()
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