DayZ 1.24
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
27
28 override bool HasProxyParts()
29 {
30 return true;
31 }
32
33 override bool CanPutIntoHands(EntityAI parent)
34 {
35 if (!super.CanPutIntoHands(parent))
36 return false;
37 return CanBeManipulated();
38 }
39
41 {
42 SetSynchDirty();
43 }
44
46 {
47 super.OnVariablesSynchronized();
48
49 //refresh visuals
51
52 if (IsDeploySound())
54
57
60 }
61
63 {
64 }
65
67 {
68 return m_State;
69 }
70
71 void SetState(int state)
72 {
73 m_State = state;
74 }
75
77 {
78 string surface_type;
79 GetGame().SurfaceGetType(position[0], position[2], surface_type);
80
81 return GetGame().IsSurfaceDigable(surface_type);
82 }
83
85 {
86 if (GetState() == FOLDED)
87 return true;
88 else
89 return false;
90 }
91
92 void Fold()
93 {
94 this.ShowSelection("inventory");
95 this.HideSelection("placing");
96 this.HideSelection("filled");
97
100
101 if (GetGame().IsServer())
102 {
103 SetAllowDamage(true);
104 Synchronize();
105 float fold_damage = (GetMaxHealth("", "") / 100) * PERCENTUAL_DAMAGE;
106 DecreaseHealth("", "", fold_damage);
107 }
108 }
109
110 void Unfold()
111 {
112 this.HideSelection("inventory");
113 this.ShowSelection("placing");
114 this.HideSelection("filled");
115
116 SetState(UNFOLDED);
118
119 if (GetGame().IsServer())
120 {
121 SetAllowDamage(true);
122 Synchronize();
123 float unfold_damage = (GetMaxHealth("", "") / 100) * PERCENTUAL_DAMAGE;
124 DecreaseHealth("", "", unfold_damage);
125 }
126 }
127
129 {
130 super.EEItemLocationChanged(oldLoc, newLoc);
131
132 //RefreshPhysics();
133 }
134
135 override void RefreshPhysics()
136 {
137 super.RefreshPhysics();
138
139 if (this && !ToDelete())
140 {
141 RemoveProxyPhysics("inventory");
142 RemoveProxyPhysics("placing");
143 RemoveProxyPhysics("filled");
144
145 int state = GetState();
146
147 switch (state)
148 {
149 case UNFOLDED:
150 //ShowSelection( "placing" );
151 AddProxyPhysics("placing");
152
153 return;
154
155 case FOLDED:
156 AddProxyPhysics("inventory");
157 return;
158
159 case FILLED:
160 AddProxyPhysics("filled");
161 return;
162 }
163 }
164 }
165
166 void Fill()
167 {
168 this.HideSelection("inventory");
169 this.HideSelection("placing");
170 this.ShowSelection("filled");
171
172 SetState(FILLED);
174
175 if (GetGame().IsServer())
176 {
177 Synchronize();
178 DecreaseHealth("", "", 5); //TODO Daniel implement soft skill bonus via useraction
179 SetAllowDamage(false);
180 }
181 }
182
184 {
185 super.OnStoreSave(ctx);
186
187 // Save state
188 ctx.Write(m_State);
189 }
190
191 override bool OnStoreLoad(ParamsReadContext ctx, int version)
192 {
193 if (!super.OnStoreLoad(ctx, version))
194 return false;
195
196 // Load folded/unfolded state
197 int state = FOLDED;
198 if (!ctx.Read(state))
199 state = FOLDED;
200
201 switch (state)
202 {
203 case FOLDED:
204 {
205 Fold();
206 break;
207 }
208 case UNFOLDED:
209 {
210 Unfold();
211 break;
212 }
213 case FILLED:
214 {
215 Fill();
216 break;
217 }
218 }
219 return true;
220 }
221
222 //================================================================
223 // ADVANCED PLACEMENT
224 //================================================================
225
226 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
227 {
228 super.OnPlacementComplete(player, position, orientation);
229
230 if (GetGame().IsServer())
231 {
232 Unfold();
233
234 SetIsDeploySound(true);
235 }
236 }
237
238 override bool IsDeployable()
239 {
240 return true;
241 }
242
243 override string GetDeploySoundset()
244 {
245 return "placeHescoBox_SoundSet";
246 }
247
248 override string GetLoopDeploySoundset()
249 {
250 return "hescobox_deploy_SoundSet";
251 }
252
254 {
255 if (!GetGame().IsDedicatedServer())
256 {
257 if (!m_DeployLoopSound || !m_DeployLoopSound.IsSoundPlaying())
259 }
260 }
261
263 {
264 if (!GetGame().IsDedicatedServer())
265 {
266 m_DeployLoopSound.SetSoundFadeOut(0.5);
267 m_DeployLoopSound.SoundStop();
268 }
269 }
270
271 override void SetActions()
272 {
273 super.SetActions();
274
277 AddAction(ActionDeployObject);
278 }
279}
void AddAction(typename actionName)
void SetIsDeploySound(bool is_deploy_sound)
Definition ItemBase.c:8972
bool CanPlayDeployLoopSound()
Definition ItemBase.c:9039
void PlayDeploySound()
Definition ItemBase.c:9003
bool IsDeploySound()
Definition ItemBase.c:8977
bool m_State
enum eWireMaterial FOLDED
ref EffectSound m_DeployLoopSound
Definition TrapBase.c:47
class JsonUndergroundAreaTriggerData GetPosition
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
override bool HasProxyParts()
Definition HescoBox.c:28
void ~HescoBox()
Definition HescoBox.c:23
void SetState(int state)
Definition HescoBox.c:71
bool CanBeFilledAtPosition(vector position)
Definition HescoBox.c:76
void PlayDeployLoopSound()
Definition HescoBox.c:253
void Fold()
Definition HescoBox.c:92
bool CanBeManipulated()
Definition HescoBox.c:84
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition HescoBox.c:226
void StopDeployLoopSound()
Definition HescoBox.c:262
override bool IsDeployable()
Definition HescoBox.c:238
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition HescoBox.c:191
ref Timer m_Timer
Definition HescoBox.c:8
override bool CanPutIntoHands(EntityAI parent)
Definition HescoBox.c:33
void Unfold()
Definition HescoBox.c:110
void HescoBox()
Definition HescoBox.c:13
static const int UNFOLDED
Definition HescoBox.c:4
static const int FOLDED
Definition HescoBox.c:3
void Synchronize()
Definition HescoBox.c:40
override void RefreshPhysics()
Definition HescoBox.c:135
override void OnVariablesSynchronized()
Definition HescoBox.c:45
override void OnStoreSave(ParamsWriteContext ctx)
Definition HescoBox.c:183
override string GetDeploySoundset()
Definition HescoBox.c:243
void RefreshVisuals()
Definition HescoBox.c:62
int GetState()
Definition HescoBox.c:66
static const int FILLED
Definition HescoBox.c:5
EffectSound m_DeployLoopSound
Definition HescoBox.c:9
override void SetActions()
Definition HescoBox.c:271
override string GetLoopDeploySoundset()
Definition HescoBox.c:248
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition HescoBox.c:128
InventoryLocation.
Manager class for managing Effect (EffectParticle, EffectSound)
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.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto native CGame GetGame()