Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
hescobox.c
Go to the documentation of this file.
1
class
HescoBox
extends
Inventory_Base
2
{
3
static
const
int
FOLDED
= 0;
4
static
const
int
UNFOLDED
= 1;
5
static
const
int
FILLED
= 2;
6
static
const
int
PERCENTUAL_DAMAGE
= 1;
7
8
ref
Timer
m_Timer
;
9
10
protected
int
m_State
;
11
12
void
HescoBox
()
13
{
14
m_State
=
FOLDED
;
15
16
//synchronized variables
17
RegisterNetSyncVariableInt(
"m_State"
,
FOLDED
,
FILLED
);
18
}
19
20
override
bool
HasProxyParts
()
21
{
22
return
true
;
23
}
24
25
override
bool
CanPutIntoHands
(
EntityAI
parent )
26
{
27
if
( !super.CanPutIntoHands( parent ) )
28
{
29
return
false
;
30
}
31
return
CanBeManipulated
();
32
}
33
34
void
Synchronize
()
35
{
36
SetSynchDirty();
37
}
38
39
override
void
OnVariablesSynchronized
()
40
{
41
super.OnVariablesSynchronized();
42
43
//refresh visuals
44
RefreshVisuals
();
45
}
46
47
void
RefreshVisuals
()
48
{
49
}
50
51
int
GetState
()
52
{
53
return
m_State
;
54
}
55
56
void
SetState
(
int
state )
57
{
58
m_State
= state;
59
}
60
61
bool
CanBeFilledAtPosition
(
vector
position )
62
{
63
string
surface_type;
64
g_Game
.SurfaceGetType( position[0], position[2], surface_type );
65
66
return
g_Game
.IsSurfaceDigable(surface_type);
67
}
68
69
bool
CanBeManipulated
()
70
{
71
if
(
GetState
() ==
FOLDED
)
72
{
73
return
true
;
74
}
75
else
76
{
77
return
false
;
78
}
79
}
80
81
void
Fold
()
82
{
83
this.ShowSelection(
"inventory"
);
84
this.HideSelection(
"placing"
);
85
this.HideSelection(
"filled"
);
86
87
SetState
(
FOLDED
);
88
RefreshPhysics
();
89
90
if
(
g_Game
.IsServer() )
91
{
92
SetAllowDamage(
true
);
93
Synchronize
();
94
float
fold_damage = ( GetMaxHealth(
""
,
""
) / 100 ) *
PERCENTUAL_DAMAGE
;
95
DecreaseHealth(
""
,
""
, fold_damage );
96
}
97
}
98
99
void
Unfold
()
100
{
101
this.HideSelection(
"inventory"
);
102
this.ShowSelection(
"placing"
);
103
this.HideSelection(
"filled"
);
104
105
SetState
(
UNFOLDED
);
106
RefreshPhysics
();
107
108
if
(
g_Game
.IsServer() )
109
{
110
SetAllowDamage(
true
);
111
Synchronize
();
112
float
unfold_damage = ( GetMaxHealth(
""
,
""
) / 100 ) *
PERCENTUAL_DAMAGE
;
113
DecreaseHealth(
""
,
""
, unfold_damage );
114
}
115
}
116
117
override
void
EEItemLocationChanged
(notnull
InventoryLocation
oldLoc, notnull
InventoryLocation
newLoc)
118
{
119
super.EEItemLocationChanged (oldLoc, newLoc);
120
121
//RefreshPhysics();
122
}
123
124
override
void
RefreshPhysics
()
125
{
126
super.RefreshPhysics();
127
128
if
(
this
&& !ToDelete() )
129
{
130
RemoveProxyPhysics(
"inventory"
);
131
RemoveProxyPhysics(
"placing"
);
132
RemoveProxyPhysics(
"filled"
);
133
134
int
state =
GetState
();
135
136
switch
(state)
137
{
138
case
UNFOLDED
:
139
//ShowSelection( "placing" );
140
AddProxyPhysics(
"placing"
);
141
142
return
;
143
144
case
FOLDED
:
145
AddProxyPhysics(
"inventory"
);
146
return
;
147
148
case
FILLED
:
149
AddProxyPhysics(
"filled"
);
150
return
;
151
}
152
}
153
}
154
155
void
Fill
()
156
{
157
this.HideSelection(
"inventory"
);
158
this.HideSelection(
"placing"
);
159
this.ShowSelection(
"filled"
);
160
161
SetState
(
FILLED
);
162
RefreshPhysics
();
163
164
if
(
g_Game
.IsServer() )
165
{
166
Synchronize
();
167
DecreaseHealth(
""
,
""
, 5 );
//TODO Daniel implement soft skill bonus via useraction
168
SetAllowDamage(
false
);
169
}
170
}
171
172
override
void
OnStoreSave
(
ParamsWriteContext
ctx)
173
{
174
super.OnStoreSave(ctx);
175
176
// Save state
177
ctx.
Write
(
m_State
);
178
}
179
180
override
bool
OnStoreLoad
(
ParamsReadContext
ctx,
int
version)
181
{
182
if
( !super.OnStoreLoad(ctx, version) )
183
return
false
;
184
185
// Load folded/unfolded state
186
int
state =
FOLDED
;
187
if
( !ctx.
Read
(state) )
188
state =
FOLDED
;
189
190
switch
(state)
191
{
192
case
FOLDED
:
193
{
194
Fold
();
195
break
;
196
}
197
case
UNFOLDED
:
198
{
199
Unfold
();
200
break
;
201
}
202
case
FILLED
:
203
{
204
Fill
();
205
break
;
206
}
207
}
208
return
true
;
209
}
210
211
//================================================================
212
// ADVANCED PLACEMENT
213
//================================================================
214
215
override
void
OnPlacementComplete
( Man player,
vector
position =
"0 0 0"
,
vector
orientation =
"0 0 0"
)
216
{
217
super.OnPlacementComplete( player, position, orientation );
218
219
if
(
g_Game
.IsServer() )
220
{
221
Unfold
();
222
}
223
}
224
225
override
bool
IsDeployable
()
226
{
227
return
true
;
228
}
229
230
override
string
GetDeploySoundset
()
231
{
232
return
"placeHescoBox_SoundSet"
;
233
}
234
235
override
string
GetLoopDeploySoundset
()
236
{
237
return
"hescobox_deploy_SoundSet"
;
238
}
239
240
override
void
SetActions
()
241
{
242
super.SetActions();
243
244
AddAction
(
ActionTogglePlaceObject
);
245
AddAction
(
ActionFoldObject
);
246
AddAction
(
ActionDeployObject
);
247
}
248
250
protected
ref
EffectSound
m_DeployLoopSound
;
//DEPRECATED in favor of m_DeployLoopSoundEx
251
252
void
PlayDeployLoopSound
();
253
void
StopDeployLoopSound
();
254
}
ActionDeployObject
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Definition
actiondeployobject.c:9
AddAction
void AddAction(typename actionName)
Definition
advancedcommunication.c:220
ActionFoldObject
Definition
actionfoldobject.c:2
ActionTogglePlaceObject
Definition
actiontoggleplaceobject.c:2
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition
effectsound.c:5
EntityAI
Definition
inventoryitem.c:2
Inventory_Base
Definition
barbedbaseballbat.c:2
Inventory_Base::PERCENTUAL_DAMAGE
static const int PERCENTUAL_DAMAGE
Definition
hescobox.c:6
Inventory_Base::GetDeploySoundset
override string GetDeploySoundset()
Definition
hescobox.c:230
Inventory_Base::CanBeFilledAtPosition
bool CanBeFilledAtPosition(vector position)
Definition
hescobox.c:61
Inventory_Base::OnStoreSave
override void OnStoreSave(ParamsWriteContext ctx)
Definition
hescobox.c:172
Inventory_Base::RefreshVisuals
void RefreshVisuals()
Definition
hescobox.c:47
Inventory_Base::GetLoopDeploySoundset
override string GetLoopDeploySoundset()
Definition
hescobox.c:235
Inventory_Base::GetState
int GetState()
Definition
hescobox.c:51
Inventory_Base::PlayDeployLoopSound
void PlayDeployLoopSound()
Inventory_Base::StopDeployLoopSound
void StopDeployLoopSound()
DEPRECATED.
Inventory_Base::RefreshPhysics
override void RefreshPhysics()
Definition
hescobox.c:124
Inventory_Base::HescoBox
void HescoBox()
Definition
hescobox.c:12
Inventory_Base::OnPlacementComplete
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition
hescobox.c:215
Inventory_Base::m_DeployLoopSound
ref EffectSound m_DeployLoopSound
DEPRECATED.
Definition
hescobox.c:250
Inventory_Base::HasProxyParts
override bool HasProxyParts()
Definition
hescobox.c:20
Inventory_Base::CanPutIntoHands
override bool CanPutIntoHands(EntityAI parent)
Definition
hescobox.c:25
Inventory_Base::Synchronize
void Synchronize()
Definition
hescobox.c:34
Inventory_Base::CanBeManipulated
bool CanBeManipulated()
Definition
hescobox.c:69
Inventory_Base::EEItemLocationChanged
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition
hescobox.c:117
Inventory_Base::IsDeployable
override bool IsDeployable()
Definition
hescobox.c:225
Inventory_Base::OnStoreLoad
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition
hescobox.c:180
Inventory_Base::Unfold
void Unfold()
Definition
hescobox.c:99
Inventory_Base::UNFOLDED
static const int UNFOLDED
Definition
hescobox.c:4
Inventory_Base::OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition
hescobox.c:39
Inventory_Base::Fold
void Fold()
Definition
hescobox.c:81
Inventory_Base::m_Timer
ref Timer m_Timer
Definition
hescobox.c:8
Inventory_Base::FOLDED
static const int FOLDED
Definition
hescobox.c:3
Inventory_Base::FILLED
static const int FILLED
Definition
hescobox.c:5
Inventory_Base::Fill
void Fill()
Definition
hescobox.c:155
Inventory_Base::SetActions
override void SetActions()
Definition
hescobox.c:240
Inventory_Base::SetState
void SetState(int state)
Definition
hescobox.c:56
Inventory_Base::m_State
int m_State
Definition
hescobox.c:10
InventoryLocation
InventoryLocation.
Definition
inventorylocation.c:30
Serializer::Write
proto bool Write(void value_out)
Serializer::Read
proto bool Read(void value_in)
Timer
Definition
dayzplayerimplement.c:39
vector
Definition
enconvert.c:119
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ParamsReadContext
Serializer ParamsReadContext
Definition
gameplay.c:15
ParamsWriteContext
Serializer ParamsWriteContext
Definition
gameplay.c:16
Games
Dayz
scripts
4_world
entities
itembase
hescobox.c
Generated by
1.17.0