Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actionsawplanks.c
Go to the documentation of this file.
1
class
SawPlanksActionData
:
ActionData
2
{
3
ItemBase
m_LastPlanksPile
;
//locally used on server only
4
}
5
6
class
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
17
float
GetDefaultTime
()
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
40
class
ActionSawPlanks
:
ActionContinuousBase
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
48
void
ActionSawPlanks
()
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
59
override
void
CreateConditionComponents
()
60
{
61
m_ConditionTarget
=
new
CCTNonRuined
(
UAMaxDistances
.
DEFAULT
);
62
m_ConditionItem
=
new
CCINonRuined
;
63
}
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
93
override
ActionData
CreateActionData
()
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!
135
ItemBase
m_Planks
;
136
ref
InventoryLocation
m_PlanksLocation
=
new
InventoryLocation
;
137
};
ActionData
ActionBase ActionData
Definition
actionbase.c:30
TIME_AXES
static const float TIME_AXES
Definition
actionsawplanks.c:10
TIME_SAW_HANDSAW
SawPlanksActionData TIME_SAW_HANDSAW
TIME_SAW_HACKSAW
static const float TIME_SAW_HACKSAW
Definition
actionsawplanks.c:9
GetDefaultTime
float GetDefaultTime()
Definition
actionsawplanks.c:17
ActionTarget
class ActionTargets ActionTarget
ActionBaseCB::CreateActionComponent
void CreateActionComponent()
Definition
animatedactionbase.c:61
ActionBase::m_FullBody
bool m_FullBody
Definition
actionbase.c:67
ActionBase::m_Text
string m_Text
Definition
actionbase.c:64
ActionBase::m_LockTargetOnUse
bool m_LockTargetOnUse
Definition
actionbase.c:66
ActionBase::m_ConditionItem
ref CCIBase m_ConditionItem
Definition
actionbase.c:70
ActionBase::m_SpecialtyWeight
float m_SpecialtyWeight
Definition
actionbase.c:83
ActionBase::m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition
actionbase.c:71
ActionBase::m_StanceMask
int m_StanceMask
Definition
actionbase.c:68
ActionContinuousBaseCB
Definition
actioncontinuousbase.c:2
ActionContinuousBase::ActionContinuousBase
void ActionContinuousBase()
Definition
actioncontinuousbase.c:124
ActionSawPlanks::OnFinishProgressServer
override void OnFinishProgressServer(ActionData action_data)
Definition
actionsawplanks.c:99
ActionSawPlanks::DECREASE_HEALTH_OF_TOOL_DEFAULT
static const int DECREASE_HEALTH_OF_TOOL_DEFAULT
Definition
actionsawplanks.c:42
ActionSawPlanks::ActionSawPlanks
void ActionSawPlanks()
Definition
actionsawplanks.c:48
ActionSawPlanks::CreateActionData
override ActionData CreateActionData()
Definition
actionsawplanks.c:93
ActionSawPlanks::CreateConditionComponents
override void CreateConditionComponents()
Definition
actionsawplanks.c:59
ActionSawPlanks::YIELD
static const int YIELD
Definition
actionsawplanks.c:46
ActionSawPlanks::m_PlanksLocation
ref InventoryLocation m_PlanksLocation
Definition
actionsawplanks.c:136
ActionSawPlanks::m_Planks
ItemBase m_Planks
Definition
actionsawplanks.c:135
ActionSawPlanks::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actionsawplanks.c:65
ActionSawPlanks::SpawnNewPlankPile
void SpawnNewPlankPile(SawPlanksActionData data, float quantity)
Definition
actionsawplanks.c:126
AnimatedActionBase::m_CommandUID
int m_CommandUID
Definition
animatedactionbase.c:143
AnimatedActionBase::m_CallbackClass
m_CallbackClass
Definition
animatedactionbase.c:145
CAContinuousRepeat
Definition
cacontinuousrepeat.c:2
CCINonRuined
Definition
ccinonruined.c:2
CCTNonRuined
Definition
cctnonruined.c:2
Debug
Definition
debug.c:2
Debug::Log
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
InventoryLocation.
Definition
inventorylocation.c:30
ItemBase
Definition
inventoryitem.c:742
ItemBase::SetQuantity
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Definition
pileofwoodenplanks.c:88
Object
Definition
objecttyped.c:2
PlayerBase
Definition
playerbaseclient.c:2
SawPlanksActionData
Definition
actionsawplanks.c:2
SawPlanksActionData::m_LastPlanksPile
ItemBase m_LastPlanksPile
Definition
actionsawplanks.c:3
UADamageApplied
Definition
actionconstants.c:147
UADamageApplied::SAW_PLANKS
const float SAW_PLANKS
Definition
actionconstants.c:154
UAItemsSpreadRadius
Definition
actionconstants.c:124
UAItemsSpreadRadius::VERY_NARROW
const float VERY_NARROW
Definition
actionconstants.c:126
UAMaxDistances
Definition
actionconstants.c:110
UAMaxDistances::DEFAULT
const float DEFAULT
Definition
actionconstants.c:112
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition
dayzplayer.c:602
Games
Dayz
scripts
4_world
classes
useractionscomponent
actions
continuous
actionsawplanks.c
Generated by
1.17.0