Dayz Explorer
1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pileofwoodenplanks.c
Go to the documentation of this file.
1
class
PileOfWoodenPlanks
extends
ItemBase
2
{
3
void
PileOfWoodenPlanks()
4
{
5
if
(
GetGame
().IsServer() )
6
{
7
SetAllowDamage(
false
);
8
}
9
}
10
11
// Shows/Hides selections. Call this in init or after every quantity change.
12
void
UpdateSelections()
13
{
14
RemoveProxyPhysics(
"stage_1"
);
15
RemoveProxyPhysics(
"stage_2"
);
16
RemoveProxyPhysics(
"stage_3"
);
17
18
// Show/Hide selections according to the current quantity
19
if
(
this
)
20
{
21
float
quantity =
GetQuantity
();
22
float
quantity_max =
GetQuantityMax
();
23
24
if
( quantity >
GetQuantityMax
() *0.66 )
25
{
26
// Show 3/3 amount of planks
27
ShowSelection (
"stage_3"
);
28
HideSelection (
"stage_2"
);
29
HideSelection (
"stage_1"
);
30
31
AddProxyPhysics(
"stage_3"
);
32
}
33
34
if
( quantity > quantity_max *0.33 && quantity <= quantity_max *0.66 )
35
{
36
// Show 2/3 amount of planks
37
HideSelection (
"stage_3"
);
38
ShowSelection (
"stage_2"
);
39
HideSelection (
"stage_1"
);
40
41
AddProxyPhysics(
"stage_2"
);
42
}
43
44
if
( quantity > 0 && quantity <= quantity_max *0.33 )
45
{
46
// Show 1/3 amount of planks
47
HideSelection (
"stage_3"
);
48
HideSelection (
"stage_2"
);
49
ShowSelection (
"stage_1"
);
50
51
AddProxyPhysics(
"stage_1"
);
52
}
53
54
if
( quantity == 0 )
55
{
56
// Show 0 planks. Object should be deleted now.
57
HideSelection (
"stage_3"
);
58
HideSelection (
"stage_2"
);
59
HideSelection (
"stage_1"
);
60
}
61
}
62
}
63
64
override
void
EEItemLocationChanged
(notnull
InventoryLocation
oldLoc, notnull
InventoryLocation
newLoc)
65
{
66
super.EEItemLocationChanged(oldLoc, newLoc);
67
UpdateSelections();
68
}
69
70
// Removes a number of long planks. Note that one (4m) long plank has the length of 3x normal planks!
71
// Returns the number of removed long planks
72
int
RemovePlanks(
int
needed_planks )
73
{
74
// Make sure to not give more long planks than we have available
75
int
available_planks = needed_planks;
76
if
( available_planks >
GetQuantity
() )
77
{
78
available_planks =
GetQuantity
();
79
}
80
81
// Remove long planks from this object
82
AddQuantity
( -available_planks,
true
);
// Autodelete enabled
83
84
// Visual feedback
85
UpdateSelections();
86
87
// Return the number of removed long planks
88
return
available_planks;
89
}
90
91
override
bool
CanPutIntoHands
(
EntityAI
parent )
92
{
93
return
false
;
94
}
95
96
override
bool
CanPutInCargo
(
EntityAI
parent)
97
{
98
// Uncomment this if you want to make it possible to put the pile into V3S Cargo
99
/*
100
if ( parent.IsKindOf("V3S_Cargo") )
101
return true;
102
else
103
return false;
104
*/
105
106
return
false
;
107
}
108
}
ItemBase
Definition:
inventoryitem.c:730
GetGame
proto native CGame GetGame()
EEItemLocationChanged
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition:
remotedetonator.c:72
InventoryLocation
InventoryLocation.
Definition:
inventorylocation.c:27
AddQuantity
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Definition:
itembase.c:3221
GetQuantityMax
override int GetQuantityMax()
Definition:
itembase.c:3262
GetQuantity
override float GetQuantity()
Definition:
itembase.c:3316
CanPutIntoHands
override bool CanPutIntoHands(EntityAI parent)
Definition:
explosivesbase.c:257
CanPutInCargo
override bool CanPutInCargo(EntityAI parent)
Definition:
explosivesbase.c:247
EntityAI
Definition:
building.c:5
DAYZ
scripts_v1.24.157551
scripts
world
entities
itembase
pileofwoodenplanks.c
Generated by
1.8.17