DayZ 1.24
Loading...
Searching...
No Matches
PileOfWoodenPlanks.c
Go to the documentation of this file.
1class PileOfWoodenPlanks extends ItemBase
2{
4 {
5 if (GetGame().IsServer())
6 SetAllowDamage(false);
7 }
8
9 // Shows/Hides selections. Call this in init or after every quantity change.
11 {
12 RemoveProxyPhysics("stage_1");
13 RemoveProxyPhysics("stage_2");
14 RemoveProxyPhysics("stage_3");
15
16 // Show/Hide selections according to the current quantity
17 if (this)
18 {
19 float quantity = GetQuantity();
21
22 if (quantity > GetQuantityMax() * 0.66)
23 {
24 // Show 3/3 amount of planks
25 ShowSelection("stage_3");
26 HideSelection("stage_2");
27 HideSelection("stage_1");
28
29 AddProxyPhysics("stage_3");
30 }
31
32 if (quantity > quantity_max * 0.33 && quantity <= quantity_max * 0.66)
33 {
34 // Show 2/3 amount of planks
35 HideSelection("stage_3");
36 ShowSelection("stage_2");
37 HideSelection("stage_1");
38
39 AddProxyPhysics("stage_2");
40 }
41
42 if (quantity > 0 && quantity <= quantity_max * 0.33)
43 {
44 // Show 1/3 amount of planks
45 HideSelection("stage_3");
46 HideSelection("stage_2");
47 ShowSelection("stage_1");
48
49 AddProxyPhysics("stage_1");
50 }
51
52 if (quantity == 0)
53 {
54 // Show 0 planks. Object should be deleted now.
55 HideSelection("stage_3");
56 HideSelection("stage_2");
57 HideSelection("stage_1");
58 }
59 }
60 }
61
67
68 // Removes a number of long planks. Note that one (4m) long plank has the length of 3x normal planks!
69 // Returns the number of removed long planks
71 {
72 // Make sure to not give more long planks than we have available
76
77 // Remove long planks from this object
78 AddQuantity(-available_planks, true); // Autodelete enabled
79
80 // Visual feedback
82
83 // Return the number of removed long planks
84 return available_planks;
85 }
86
87 override bool CanPutIntoHands(EntityAI parent)
88 {
89 return false;
90 }
91
92 override bool CanPutInCargo(EntityAI parent)
93 {
94 // Uncomment this if you want to make it possible to put the pile into V3S Cargo
95 /*
96 if ( parent.IsKindOf("V3S_Cargo") )
97 return true;
98 else
99 return false;
100 */
101
102 return false;
103 }
104}
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:7900
override float GetQuantity()
Definition ItemBase.c:7995
override int GetQuantityMax()
Definition ItemBase.c:7941
InventoryLocation.
override bool CanPutIntoHands(EntityAI parent)
void PileOfWoodenPlanks()
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
void UpdateSelections()
override bool CanPutInCargo(EntityAI parent)
int RemovePlanks(int needed_planks)
proto native CGame GetGame()