DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
CAContinuousFillFuel.c
Go to the documentation of this file.
2{
3 protected float m_ItemQuantity;
4 protected float m_SpentQuantity;
5 protected float m_SpentQuantity_total;
6 protected float m_EmptySpace; //basically free capacity
7 protected float m_TimeElpased;
8 protected float m_QuantityUsedPerSecond;
10 protected float m_DefaultTimeStep;
11 protected ref Param1<float> m_SpentUnits;
12
14
15 void CAContinuousFillFuel( float quantity_used_per_second, float time_to_progress )
16 {
17 m_QuantityUsedPerSecond = quantity_used_per_second;
18 m_DefaultTimeStep = time_to_progress;
19 }
20
21 //---------------------------------------------------------------------------
22 override void Setup( ActionData action_data )
23 {
24 m_Player = action_data.m_Player;
25
26 Car car = Car.Cast(action_data.m_Target.GetObject());
27
28 m_TimeElpased = 0;
30
31 if ( !m_SpentUnits )
32 {
33 m_SpentUnits = new Param1<float>( 0 );
34 }
35 else
36 {
37 m_SpentUnits.param1 = 0;
38 }
39
40 m_QuantityUsedPerSecond *= Math.Min(action_data.m_MainItem.GetLiquidThroughputCoef(),car.GetLiquidThroughputCoef());
41
42 float fuelCapacity = car.GetFluidCapacity( CarFluid.FUEL );
43 float currentFuel = car.GetFluidFraction( CarFluid.FUEL );
44 currentFuel = currentFuel * fuelCapacity;
45
46 m_EmptySpace = (fuelCapacity - currentFuel) * 1000;
47 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
48
51
52 }
53
54 //---------------------------------------------------------------------------
55 override int Execute( ActionData action_data )
56 {
57 Car car = Car.Cast(action_data.m_Target.GetObject());
58
59 if ( !action_data.m_Player )
60 {
61 return UA_ERROR;
62 }
63
64 if ( m_ItemQuantity <= 0 )
65 {
66 return UA_FINISHED;
67 }
68 else
69 {
71 {
72 m_AdjustedQuantityUsedPerSecond = action_data.m_Player.GetSoftSkillsManager().SubtractSpecialtyBonus( m_QuantityUsedPerSecond, m_Action.GetSpecialtyWeight(), true);
73 m_SpentQuantity += m_AdjustedQuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
74 m_TimeElpased += action_data.m_Player.GetDeltaT();
75
77 {
78 CalcAndSetQuantity( action_data );
79 m_TimeElpased = 0;
80 //Setup(action_data); //reset data after repeat
81 }
82
83 return UA_PROCESSING;
84 }
85 else
86 {
87 CalcAndSetQuantity( action_data );
88 OnCompletePogress(action_data);
89 return UA_FINISHED;
90 }
91 }
92 }
93
94 //---------------------------------------------------------------------------
95 override int Cancel( ActionData action_data )
96 {
97 if ( !action_data.m_Player )
98 {
99 return UA_ERROR;
100 }
101
102 CalcAndSetQuantity( action_data );
103 return UA_INTERRUPT;
104 }
105
106 //---------------------------------------------------------------------------
107 override float GetProgress()
108 {
109 if ( m_ItemQuantity <= 0 )
110 return 1;
111
113 }
114
115 //---------------------------------------------------------------------------
116 void CalcAndSetQuantity( ActionData action_data )
117 {
118
120
121 if ( m_SpentUnits )
122 {
125 }
126
127
128 if ( GetGame().IsServer() )
129 {
130 Car car = Car.Cast(action_data.m_Target.GetObject());
131 action_data.m_MainItem.AddQuantity( -m_SpentQuantity );
132 car.Fill( CarFluid.FUEL, (m_SpentQuantity * 0.001) );
133 }
134
135 m_SpentQuantity = 0;
136 }
137}
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
Definition Car.c:19
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)
override int Cancel(ActionData action_data)
protected float m_DefaultTimeStep
protected float m_QuantityUsedPerSecond
override int Execute(ActionData action_data)
protected float m_SpentQuantity_total
protected float m_EmptySpace
protected PlayerBase m_Player
protected ref Param1< float > m_SpentUnits
protected float m_TimeElpased
void CalcAndSetQuantity(ActionData action_data)
protected float m_AdjustedQuantityUsedPerSecond
protected float m_ItemQuantity
void CAContinuousFillFuel(float quantity_used_per_second, float time_to_progress)
protected float m_SpentQuantity
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_INTERRUPT
Definition constants.c:422
const int UA_PROCESSING
Definition constants.c:418