DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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
7 override void CreateActionComponent()
8 {
10 }
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
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};
float GetSpecialtyWeight()
protected float m_SpecialtyWeight
Definition ActionBase.c:68
protected bool m_LockTargetOnUse
Definition ActionBase.c:51
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
protected string m_Text
Definition ActionBase.c:49
protected bool m_FullBody
Definition ActionBase.c:52
protected int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
const int ECE_PLACE_ON_SURFACE
protected ActionData m_ActionData
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
ref CABase m_ActionComponent
Definition ActionBase.c:30
ref ActionTarget m_Target
Definition ActionBase.c:32
static const float TIME_SAW_HANDSAW
static const float TIME_AXES
static const float TIME_SAW_HACKSAW
override void CreateActionComponent()
override void OnFinishProgressServer(ActionData action_data)
static const int DECREASE_HEALTH_OF_TOOL_DEFAULT
override void CreateConditionComponents()
static const int YIELD
ref InventoryLocation m_PlanksLocation
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
InventoryLocation.
proto native bool CompareLocationOnly(notnull InventoryLocation other)
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
const float SAW_PLANKS
const float DEFAULT
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.