Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
actionsawplanks.c
Go to the documentation of this file.
2{
3 ItemBase m_LastPlanksPile; //locally used on server only
4}
5
6class ActionSawPlanksCB : ActionContinuousBaseCB
7{
8 static const float TIME_SAW_HANDSAW = 1.5;
9 static const float TIME_SAW_HACKSAW = 3.0;
10 static const float TIME_AXES = 1.2;
11
12 override void CreateActionComponent()
13 {
14 m_ActionData.m_ActionComponent = new CAContinuousRepeat(GetDefaultTime());
15 }
16
18 {
19 string item_type = m_ActionData.m_MainItem.GetType();
20
21 switch(item_type)
22 {
23 case "Hacksaw":
24 return TIME_SAW_HACKSAW;
25 break;
26
27 case "HandSaw":
28 return TIME_SAW_HANDSAW;
29 break;
30
31 default: // axes
32 return TIME_AXES;
33 break
34 }
35 Debug.Log("ActionSawPlanksCB | Item detection error, assigning negative time","recipes");
36 return -1;
37 }
38};
39
41{
42 static const int DECREASE_HEALTH_OF_TOOL_DEFAULT = 10; // this constant is not use anymore see ActionConstants.c UADamageApplied
43 //static const int DECREASE_HEALTH_OF_TOOL_AXE = 20; // axes
44 //static const int DECREASE_FUEL_OF_CHAINSAW = 20; // chainsaw fuel in ml
45
46 static const int YIELD = 3;
47
49 {
50 m_CallbackClass = ActionSawPlanksCB;
51 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DISASSEMBLE;
52 m_FullBody = true;
53 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
54 m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_MEDIUM;
55 m_Text = "#saw_planks";
56 m_LockTargetOnUse = false;
57 }
58
64
65 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
66 {
67 Object target_O = target.GetObject();
68
69 if ( item && target_O.IsInherited(PileOfWoodenPlanks))
70 {
71 string item_type = item.GetType();
72
73 switch(item_type)
74 {
75 case "Chainsaw":
76 if ( item.HasEnergyManager() && item.GetCompEM().CanWork() )
77 {
78 return true;
79 }
80 else
81 {
82 return false;
83 }
84 break;
85 }
86
87 return true;
88 }
89
90 return false;
91 }
92
94 {
95 SawPlanksActionData action_data = new SawPlanksActionData();
96 return action_data;
97 }
98
99 override void OnFinishProgressServer( ActionData action_data )
100 {
101 SawPlanksActionData sawPlanksData = SawPlanksActionData.Cast(action_data);
102
103 PileOfWoodenPlanks item_POWP = PileOfWoodenPlanks.Cast( sawPlanksData.m_Target.GetObject() );
104 item_POWP.RemovePlanks(YIELD);
105
106 if (!sawPlanksData.m_LastPlanksPile)
107 {
108 SpawnNewPlankPile(sawPlanksData,YIELD);
109 }
110 else if ((sawPlanksData.m_LastPlanksPile.GetQuantity() + YIELD) >= sawPlanksData.m_LastPlanksPile.GetQuantityMax())
111 {
112 int remnant = sawPlanksData.m_LastPlanksPile.GetQuantity() + YIELD - sawPlanksData.m_LastPlanksPile.GetQuantityMax();
113 sawPlanksData.m_LastPlanksPile.SetQuantity(sawPlanksData.m_LastPlanksPile.GetQuantityMax());
114
115 if (remnant > 0)
116 SpawnNewPlankPile(sawPlanksData,remnant);
117 }
118 else
119 {
120 sawPlanksData.m_LastPlanksPile.AddQuantity(YIELD);
121 }
122
123 sawPlanksData.m_MainItem.DecreaseHealth("", "", UADamageApplied.SAW_PLANKS);
124 }
125
126 protected void SpawnNewPlankPile(SawPlanksActionData data, float quantity)
127 {
128 ItemBase planksNewResult = ItemBase.Cast(data.m_Player.SpawnEntityOnGroundRaycastDispersed("WoodenPlank",0.3,UAItemsSpreadRadius.VERY_NARROW));
129 planksNewResult.SetQuantity(quantity);
130 data.m_LastPlanksPile = planksNewResult;
131 }
132
134 //DEPREDATED; do NOT store anything on the shared server action directly!
137};
ActionBase ActionData
Definition actionbase.c:30
static const float TIME_AXES
SawPlanksActionData TIME_SAW_HANDSAW
static const float TIME_SAW_HACKSAW
float GetDefaultTime()
class ActionTargets ActionTarget
void CreateActionComponent()
bool m_FullBody
Definition actionbase.c:67
string m_Text
Definition actionbase.c:64
bool m_LockTargetOnUse
Definition actionbase.c:66
ref CCIBase m_ConditionItem
Definition actionbase.c:70
float m_SpecialtyWeight
Definition actionbase.c:83
ref CCTBase m_ConditionTarget
Definition actionbase.c:71
int m_StanceMask
Definition actionbase.c:68
override void OnFinishProgressServer(ActionData action_data)
static const int DECREASE_HEALTH_OF_TOOL_DEFAULT
override ActionData CreateActionData()
override void CreateConditionComponents()
static const int YIELD
ref InventoryLocation m_PlanksLocation
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
void SpawnNewPlankPile(SawPlanksActionData data, float quantity)
Definition debug.c:2
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition debug.c:182
InventoryLocation.
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
const float SAW_PLANKS
const float DEFAULT
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602