Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionsawplanks.c
Go to the documentation of this file.
2 {
3  static const float TIME_SAW_HANDSAW = 1.5;
4  static const float TIME_SAW_HACKSAW = 3.0;
5  static const float TIME_AXES = 1.2;
6 
7  override void CreateActionComponent()
8  {
9  m_ActionData.m_ActionComponent = new CAContinuousRepeat(GetDefaultTime());
10  }
11 
12  float GetDefaultTime()
13  {
14  string item_type = m_ActionData.m_MainItem.GetType();
15 
16  switch(item_type)
17  {
18  case "Hacksaw":
19  return TIME_SAW_HACKSAW;
20  break;
21 
22  case "HandSaw":
23  return TIME_SAW_HANDSAW;
24  break;
25 
26  default: // axes
27  return TIME_AXES;
28  break
29  }
30  Print("ActionSawPlanksCB | Item detection error, assigning negative time");
31  return -1;
32  }
33 };
34 
36 {
37  static const int DECREASE_HEALTH_OF_TOOL_DEFAULT = 10; // this constant is not use anymore see ActionConstants.c UADamageApplied
38  //static const int DECREASE_HEALTH_OF_TOOL_AXE = 20; // axes
39  //static const int DECREASE_FUEL_OF_CHAINSAW = 20; // chainsaw fuel in ml
40 
41  static const int YIELD = 3;
42  ItemBase m_Planks;
43  ref InventoryLocation m_PlanksLocation = new InventoryLocation;
44 
45  void ActionSawPlanks()
46  {
47  m_CallbackClass = ActionSawPlanksCB;
48  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DISASSEMBLE;
49  m_FullBody = true;
50  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
52  m_Text = "#saw_planks";
53  m_LockTargetOnUse = false;
54  }
55 
56  override void CreateConditionComponents()
57  {
60  }
61 
62  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
63  {
64  Object target_O = target.GetObject();
65 
66  if ( item && target_O.IsInherited(PileOfWoodenPlanks))
67  {
68  string item_type = item.GetType();
69 
70  switch(item_type)
71  {
72  case "Chainsaw":
73  if ( item.HasEnergyManager() && item.GetCompEM().CanWork() )
74  {
75  return true;
76  }
77  else
78  {
79  return false;
80  }
81  break;
82  }
83 
84  return true;
85  }
86 
87  return false;
88  }
89 
90  override void OnFinishProgressServer( ActionData action_data )
91  {
92  PileOfWoodenPlanks item_POWP = PileOfWoodenPlanks.Cast( action_data.m_Target.GetObject() );
93  item_POWP.RemovePlanks(YIELD);
94 
95  vector pos = action_data.m_Player.GetPosition();
96 
97  InventoryLocation currentLoc = new InventoryLocation;
98  if (m_Planks)
99  m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
100 
101  if (!m_Planks || !currentLoc.CompareLocationOnly(m_PlanksLocation))
102  {
103  m_Planks = ItemBase.Cast( GetGame().CreateObjectEx("WoodenPlank", pos, ECE_PLACE_ON_SURFACE) );
104  m_Planks.SetQuantity(YIELD);
105 
106  m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
107  m_PlanksLocation.Copy(currentLoc);
108  }
109  else if ((m_Planks.GetQuantity() + YIELD) >= m_Planks.GetQuantityMax())
110  {
111  int remnant = m_Planks.GetQuantity() + YIELD - m_Planks.GetQuantityMax();
112  m_Planks.SetQuantity(m_Planks.GetQuantityMax());
113  if (remnant > 0)
114  {
115  m_Planks = ItemBase.Cast( GetGame().CreateObjectEx("WoodenPlank", pos, ECE_PLACE_ON_SURFACE) );
116  m_Planks.SetQuantity(remnant);
117 
118  m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
119  m_PlanksLocation.Copy(currentLoc);
120  }
121  }
122  else
123  {
124  m_Planks.AddQuantity(YIELD);
125  }
126 
127  ItemBase item = action_data.m_MainItem;
128 
129  string item_type = item.GetType();
130 
131  item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( UADamageApplied.SAW_PLANKS, GetSpecialtyWeight() ));
132  /*switch(item_type)
133  {
134  case "WoodAxe":
135  item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
136  break;
137 
138  case "FirefighterAxe":
139  item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
140  break;
141 
142  case "FirefighterAxe_Black":
143  item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
144  break;
145 
146  case "FirefighterAxe_Green":
147  item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
148  break;
149 
150  case "Hatchet":
151  item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
152  break;
153 
154  case "Chainsaw":
155  if ( item.HasEnergyManager() )
156  {
157  item.GetCompEM().ConsumeEnergy(DECREASE_FUEL_OF_CHAINSAW);
158  }
159  break;
160 
161  default: // Hacksaw and other
162  item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( UADamageApplied.SAW_PLANKS, GetSpecialtyWeight() ));
163  break;
164  }*/
165 
166  action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
167  }
168 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
GetSpecialtyWeight
float GetSpecialtyWeight()
Definition: actionbase.c:1044
CAContinuousRepeat
Definition: cacontinuousrepeat.c:1
UADamageApplied
Definition: actionconstants.c:130
UASoftSkillsWeight
Definition: actionconstants.c:118
Print
proto void Print(void var)
Prints content of variable to console/log.
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
UAMaxDistances
Definition: actionconstants.c:104
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
ActionSawPlanks
Definition: actionsawplanks.c:35
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CCTNonRuined
Definition: cctnonruined.c:1
Object
Definition: objecttyped.c:1
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
m_LockTargetOnUse
protected bool m_LockTargetOnUse
Definition: actionbase.c:51
ActionSawPlanksCB
Definition: actionsawplanks.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53