DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
HescoBox.c
Go to the documentation of this file.
1class 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
10
11 protected int m_State;
12
13 void HescoBox()
14 {
16
17 //synchronized variables
18 RegisterNetSyncVariableInt( "m_State", FOLDED, FILLED );
19 RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
20 RegisterNetSyncVariableBool("m_IsDeploySound");
21 }
22
23 void ~HescoBox()
24 {
26 }
27
28 override bool HasProxyParts()
29 {
30 return true;
31 }
32
33 override bool CanPutIntoHands( EntityAI parent )
34 {
35 if( !super.CanPutIntoHands( parent ) )
36 {
37 return false;
38 }
39 return CanBeManipulated();
40 }
41
43 {
44 SetSynchDirty();
45 }
46
48 {
49 super.OnVariablesSynchronized();
50
51 //refresh visuals
53
54 if ( IsDeploySound() )
55 {
57 }
58
60 {
62 }
63
65 {
67 }
68 }
69
71 {
72 }
73
75 {
76 return m_State;
77 }
78
79 void SetState( int state )
80 {
81 m_State = state;
82 }
83
85 {
86 string surface_type;
87 GetGame().SurfaceGetType( position[0], position[2], surface_type );
88
89 return GetGame().IsSurfaceDigable(surface_type);
90 }
91
93 {
94 if ( GetState() == FOLDED )
95 {
96 return true;
97 }
98 else
99 {
100 return false;
101 }
102 }
103
104 void Fold()
105 {
106 this.ShowSelection( "inventory" );
107 this.HideSelection( "placing" );
108 this.HideSelection( "filled" );
109
110 SetState( FOLDED );
112
113 if ( GetGame().IsServer() )
114 {
115 SetAllowDamage(true);
116 Synchronize();
117 float fold_damage = ( GetMaxHealth( "", "" ) / 100 ) * PERCENTUAL_DAMAGE;
118 DecreaseHealth( "", "", fold_damage );
119 }
120 }
121
122 void Unfold()
123 {
124 this.HideSelection( "inventory" );
125 this.ShowSelection( "placing" );
126 this.HideSelection( "filled" );
127
128 SetState( UNFOLDED );
130
131 if ( GetGame().IsServer() )
132 {
133 SetAllowDamage(true);
134 Synchronize();
135 float unfold_damage = ( GetMaxHealth( "", "" ) / 100 ) * PERCENTUAL_DAMAGE;
136 DecreaseHealth( "", "", unfold_damage );
137 }
138 }
139
140 override void EEItemLocationChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
141 {
142 super.EEItemLocationChanged (oldLoc, newLoc);
143
144 //RefreshPhysics();
145 }
146
147 override void RefreshPhysics()
148 {
149 super.RefreshPhysics();
150
151 if ( this && !ToDelete() )
152 {
153 RemoveProxyPhysics( "inventory" );
154 RemoveProxyPhysics( "placing" );
155 RemoveProxyPhysics( "filled" );
156
157 int state = GetState();
158
159 switch (state)
160 {
161 case UNFOLDED:
162 //ShowSelection( "placing" );
163 AddProxyPhysics( "placing" );
164
165 return;
166
167 case FOLDED:
168 AddProxyPhysics( "inventory" );
169 return;
170
171 case FILLED:
172 AddProxyPhysics( "filled" );
173 return;
174 }
175 }
176 }
177
178 void Fill()
179 {
180 this.HideSelection( "inventory" );
181 this.HideSelection( "placing" );
182 this.ShowSelection( "filled" );
183
184 SetState( FILLED );
186
187 if ( GetGame().IsServer() )
188 {
189 Synchronize();
190 DecreaseHealth( "", "", 5 ); //TODO Daniel implement soft skill bonus via useraction
191 SetAllowDamage(false);
192 }
193 }
194
196 {
197 super.OnStoreSave(ctx);
198
199 // Save state
200 ctx.Write( m_State );
201 }
202
203 override bool OnStoreLoad(ParamsReadContext ctx, int version)
204 {
205 if ( !super.OnStoreLoad(ctx, version) )
206 return false;
207
208 // Load folded/unfolded state
209 int state = FOLDED;
210 if ( !ctx.Read(state) )
211 state = FOLDED;
212
213 switch (state)
214 {
215 case FOLDED:
216 {
217 Fold();
218 break;
219 }
220 case UNFOLDED:
221 {
222 Unfold();
223 break;
224 }
225 case FILLED:
226 {
227 Fill();
228 break;
229 }
230 }
231 return true;
232 }
233
234 //================================================================
235 // ADVANCED PLACEMENT
236 //================================================================
237
238 override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
239 {
240 super.OnPlacementComplete( player, position, orientation );
241
242 if ( GetGame().IsServer() )
243 {
244 Unfold();
245
246 SetIsDeploySound( true );
247 }
248 }
249
250 override bool IsDeployable()
251 {
252 return true;
253 }
254
255 override string GetDeploySoundset()
256 {
257 return "placeHescoBox_SoundSet";
258 }
259
260 override string GetLoopDeploySoundset()
261 {
262 return "hescobox_deploy_SoundSet";
263 }
264
266 {
267 if ( !GetGame().IsDedicatedServer() )
268 {
270 {
272 }
273 }
274 }
275
277 {
278 if ( !GetGame().IsDedicatedServer() )
279 {
282 }
283 }
284
285 override void SetActions()
286 {
287 super.SetActions();
288
292 }
293}
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
void AddAction(typename actionName)
void PlayDeploySound()
Definition ItemBase.c:8920
void SetIsDeploySound(bool is_deploy_sound)
Definition ItemBase.c:8910
bool IsDeploySound()
Definition ItemBase.c:8915
bool CanPlayDeployLoopSound()
Definition ItemBase.c:8947
protected float m_DrainThreshold protected bool m_State
enum eWireMaterial FOLDED
protected ref EffectSound m_DeployLoopSound
Definition TrapBase.c:47
class JsonUndergroundAreaTriggerData GetPosition
proto void SurfaceGetType(float x, float z, out string type)
bool IsSurfaceDigable(string surface)
Checks if the surface is digable.
Definition Game.c:1087
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
void SetSoundFadeOut(float fade_out)
Set the sound fade out duration.
void SoundStop()
Stops sound.
protected int m_State
Definition HescoBox.c:11
override string GetDeploySoundset()
Definition HescoBox.c:255
bool CanBeFilledAtPosition(vector position)
Definition HescoBox.c:84
override void OnStoreSave(ParamsWriteContext ctx)
Definition HescoBox.c:195
void RefreshVisuals()
Definition HescoBox.c:70
override string GetLoopDeploySoundset()
Definition HescoBox.c:260
int GetState()
Definition HescoBox.c:74
void PlayDeployLoopSound()
Definition HescoBox.c:265
void StopDeployLoopSound()
Definition HescoBox.c:276
override void RefreshPhysics()
Definition HescoBox.c:147
void HescoBox()
Definition HescoBox.c:13
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition HescoBox.c:238
override bool HasProxyParts()
Definition HescoBox.c:28
override bool CanPutIntoHands(EntityAI parent)
Definition HescoBox.c:33
void Synchronize()
Definition HescoBox.c:42
bool CanBeManipulated()
Definition HescoBox.c:92
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition HescoBox.c:140
override bool IsDeployable()
Definition HescoBox.c:250
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition HescoBox.c:203
ref protected EffectSound m_DeployLoopSound
Definition HescoBox.c:9
void Unfold()
Definition HescoBox.c:122
static const int UNFOLDED
Definition HescoBox.c:4
void ~HescoBox()
Definition HescoBox.c:23
override void OnVariablesSynchronized()
Definition HescoBox.c:47
ref Timer m_Timer
Definition HescoBox.c:8
static const int FOLDED
Definition HescoBox.c:3
static const int FILLED
Definition HescoBox.c:5
override void SetActions()
Definition HescoBox.c:285
void SetState(int state)
Definition HescoBox.c:79
InventoryLocation.
Manager class for managing Effect (EffectParticle, EffectSound)
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
proto native CGame GetGame()