Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuouswringclothes.c
Go to the documentation of this file.
2 {
3  protected float m_InitItemQuantity;
4  protected float m_SpentQuantityTotal;
5 
6  void CAContinuousWringClothes( float quantity_used_per_second, float time_to_repeat )
7  {
8  m_QuantityUsedPerSecond = quantity_used_per_second;
9  m_DefaultTimeToRepeat = time_to_repeat;
10  m_InitItemQuantity = -1;
11  }
12 
13  override void Setup( ActionData action_data )
14  {
15  super.Setup( action_data );
16 
17  if (m_InitItemQuantity < 0)
18  {
19  m_InitItemQuantity = action_data.m_MainItem.GetWet();
20  }
21  }
22 
23 
24  override int Execute( ActionData action_data )
25  {
26  if ( !action_data.m_Player )
27  {
28  return UA_ERROR;
29  }
30 
31  float wetness = action_data.m_MainItem.GetWet();
32  int trim_wetness = wetness * 100;
33  float rounded_wetness = trim_wetness/100;
34 
35  if ( rounded_wetness <= 0.25 )
36  {
37  return UA_FINISHED;
38  }
39  else
40  {
41  if ( m_SpentQuantityTotal < m_InitItemQuantity )
42  {
43  m_AdjustedQuantityUsedPerSecond = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( m_QuantityUsedPerSecond, m_Action.GetSpecialtyWeight(), true);
44  m_SpentQuantity += m_AdjustedQuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
45  m_TimeElpased += action_data.m_Player.GetDeltaT();
46 
47  if (m_TimeElpased > m_DefaultTimeToRepeat)
48  {
49  OnCompletePogress(action_data);
50  m_TimeElpased -= m_DefaultTimeToRepeat;
51  }
52 
53 
54  if ( GetGame().IsServer() )
55  {
56  if ( m_SpentUnits )
57  {
58  m_SpentUnits.param1 = m_SpentQuantity;
59  SetACData(m_SpentUnits);
60  }
61 
62  action_data.m_MainItem.AddWet(-m_SpentQuantity);
63  }
64 
65  m_SpentQuantityTotal += m_SpentQuantity;
66  m_SpentQuantity = 0;
67 
68  return UA_PROCESSING;
69  }
70  else
71  {
72  OnCompletePogress(action_data);
73  return UA_FINISHED;
74  }
75  }
76  }
77 
78  override float GetProgress()
79  {
80  return ((m_TimeElpased - m_DefaultTimeToRepeat) / m_DefaultTimeToRepeat) + 1;
81  }
82 };
GetGame
proto native CGame GetGame()
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
CAContinuousWringClothes
Definition: cacontinuouswringclothes.c:1
CAContinuousQuantityRepeat
Definition: cacontinuousquantityrepeat.c:1
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionData
Definition: actionbase.c:20
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
m_Action
enum ActionInputType m_Action