DayZ 1.24
Loading...
Searching...
No Matches
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
11
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;
44
46 {
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
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 return true;
75 else
76 return false;
77 break;
78 }
79
80 return true;
81 }
82
83 return false;
84 }
85
87 {
88 PileOfWoodenPlanks item_POWP = PileOfWoodenPlanks.Cast(action_data.m_Target.GetObject());
89 item_POWP.RemovePlanks(YIELD);
90
91 vector pos = action_data.m_Player.GetPosition();
92
94 if (m_Planks)
95 m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
96
97 if (!m_Planks || !currentLoc.CompareLocationOnly(m_PlanksLocation))
98 {
99 m_Planks = ItemBase.Cast(GetGame().CreateObjectEx("WoodenPlank", pos, ECE_PLACE_ON_SURFACE));
100 m_Planks.SetQuantity(YIELD);
101
102 m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
104 }
105 else if ((m_Planks.GetQuantity() + YIELD) >= m_Planks.GetQuantityMax())
106 {
107 int remnant = m_Planks.GetQuantity() + YIELD - m_Planks.GetQuantityMax();
108 m_Planks.SetQuantity(m_Planks.GetQuantityMax());
109 if (remnant > 0)
110 {
111 m_Planks = ItemBase.Cast(GetGame().CreateObjectEx("WoodenPlank", pos, ECE_PLACE_ON_SURFACE));
112 m_Planks.SetQuantity(remnant);
113
114 m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
116 }
117 }
118 else
119 m_Planks.AddQuantity(YIELD);
120
121 ItemBase item = action_data.m_MainItem;
122
123 string item_type = item.GetType();
124
125 item.DecreaseHealth("", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus(UADamageApplied.SAW_PLANKS, GetSpecialtyWeight()));
126 /*switch(item_type)
127 {
128 case "WoodAxe":
129 item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
130 break;
131
132 case "FirefighterAxe":
133 item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
134 break;
135
136 case "FirefighterAxe_Black":
137 item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
138 break;
139
140 case "FirefighterAxe_Green":
141 item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
142 break;
143
144 case "Hatchet":
145 item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
146 break;
147
148 case "Chainsaw":
149 if ( item.HasEnergyManager() )
150 {
151 item.GetCompEM().ConsumeEnergy(DECREASE_FUEL_OF_CHAINSAW);
152 }
153 break;
154
155 default: // Hacksaw and other
156 item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( UADamageApplied.SAW_PLANKS, GetSpecialtyWeight() ));
157 break;
158 }*/
159
160 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
161 }
162};
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
float GetSpecialtyWeight()
Definition ActionBase.c:967
bool m_LockTargetOnUse
Definition ActionBase.c:51
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
const int ECE_PLACE_ON_SURFACE
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
ItemBase m_MainItem
Definition ActionBase.c:28
static const float TIME_AXES
static const float TIME_SAW_HANDSAW
static const float TIME_SAW_HACKSAW
override void CreateActionComponent()
static const int YIELD
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void CreateConditionComponents()
static const int DECREASE_HEALTH_OF_TOOL_DEFAULT
override void OnFinishProgressServer(ActionData action_data)
ref InventoryLocation m_PlanksLocation
InventoryLocation.
const float SAW_PLANKS
const float DEFAULT
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.