DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
BarrelHoles_ColorBase.c
Go to the documentation of this file.
2{
3 //Visual animations
4 const string ANIMATION_OPENED = "LidOff";
5 const string ANIMATION_CLOSED = "LidOn";
6
7 protected bool m_IsOpenedClient = false;
8
10
12 {
13 //Particles - default for FireplaceBase
21
22 m_Openable = new OpenableBehaviour(false);
23
24 //synchronized variables
25 RegisterNetSyncVariableBool("m_Openable.m_IsOpened");
26
27 ProcessInvulnerabilityCheck(GetInvulnerabilityTypeString());
28
29 m_LightDistance = 50;
30 }
31
33 {
34 return 110;
35 }
36
38 {
39 return "disableContainerDamage";
40 }
41
42 override void OnWasAttached( EntityAI parent, int slot_id)
43 {
44 super.OnWasAttached(parent, slot_id);
45
46 Open();
47 }
48
49 override void OnWasDetached(EntityAI parent, int slot_id)
50 {
51 super.OnWasDetached(parent, slot_id);
52
53 Close();
54 }
55
56 override bool CanDetachAttachment( EntityAI parent )
57 {
58 return GetNumberOfItems() == 0;
59 }
60
61
62 override void OnStoreSave( ParamsWriteContext ctx )
63 {
64 super.OnStoreSave( ctx );
65
66 ctx.Write( m_Openable.IsOpened() );
67 }
68
69 override bool OnStoreLoad( ParamsReadContext ctx, int version )
70 {
71 if ( !super.OnStoreLoad( ctx, version ) )
72 return false;
73
74 bool opened;
75 if ( version >= 110 && !ctx.Read( opened ) )
76 {
77 return false;
78 }
79
80 if ( opened )
81 {
82 OpenLoad();
83 }
84 else
85 {
86 CloseLoad();
87 }
88
89 return true;
90 }
91
92 override bool IsBarrelWithHoles()
93 {
94 return true;
95 }
96
98 {
99 super.OnVariablesSynchronized();
100
101 if ( !IsBeingPlaced() )
102 {
103 //Refresh particles and sounds
105
106 //sound sync
108 {
109 if ( IsOpen() )
110 {
111 SoundBarrelOpenPlay();
112 }
113
114 if ( !IsOpen() )
115 {
116 SoundBarrelClosePlay();
117 }
118 }
119
120 }
121
122 UpdateVisualState();
123 }
124
125 //ATTACHMENTS
126 override bool CanReceiveAttachment( EntityAI attachment, int slotId )
127 {
128 ItemBase item = ItemBase.Cast( attachment );
129
130 if ( GetHealthLevel() == GameConstants.STATE_RUINED || GetHierarchyRootPlayer() != null )
131 return false;
132
133 //direct cooking slots
134 if ( !IsOpen() )
135 {
136 if ( ( item.Type() == ATTACHMENT_CAULDRON ) || ( item.Type() == ATTACHMENT_COOKING_POT ) || ( item.Type() == ATTACHMENT_FRYING_PAN ) || ( item.IsKindOf( "Edible_Base" ) ) )
137 {
138 return super.CanReceiveAttachment(attachment, slotId);
139 }
140 }
141 else
142 {
143 if ( IsKindling( item ) || IsFuel( item ) )
144 {
145 return super.CanReceiveAttachment(attachment, slotId);
146 }
147 }
148
149 return false;
150 }
151
152 override bool CanLoadAttachment( EntityAI attachment )
153 {
154 ItemBase item = ItemBase.Cast( attachment );
155
156 if ( GetHealthLevel() == GameConstants.STATE_RUINED )
157 return false;
158
159 return super.CanLoadAttachment(attachment);
160 }
161
162 override void EEItemAttached(EntityAI item, string slot_name)
163 {
164 super.EEItemAttached(item, slot_name);
165
166 ItemBase item_base = ItemBase.Cast(item);
167
168 if (IsKindling(item_base) || IsFuel(item_base))
169 {
170 AddToFireConsumables(item_base);
171 }
172
173 // direct cooking/smoking slots
174 bool edible_base_attached = false;
175 switch (slot_name)
176 {
177 case "DirectCookingA":
178 m_DirectCookingSlots[0] = item_base;
179 edible_base_attached = true;
180 break;
181 case "DirectCookingB":
182 m_DirectCookingSlots[1] = item_base;
183 edible_base_attached = true;
184 break;
185 case "DirectCookingC":
186 m_DirectCookingSlots[2] = item_base;
187 edible_base_attached = true;
188 break;
189
190 case "SmokingA":
191 m_SmokingSlots[0] = item_base;
192 edible_base_attached = true;
193 break;
194 case "SmokingB":
195 m_SmokingSlots[1] = item_base;
196 edible_base_attached = true;
197 break;
198 case "SmokingC":
199 m_SmokingSlots[2] = item_base;
200 edible_base_attached = true;
201 break;
202 case "SmokingD":
203 m_SmokingSlots[3] = item_base;
204 edible_base_attached = true;
205 break;
206 }
207
208 // reset cooking time (to prevent the cooking exploit)
209 if (GetGame().IsServer() && edible_base_attached)
210 {
211 Edible_Base edBase = Edible_Base.Cast(item_base);
212 if (edBase)
213 {
214 if (edBase.GetFoodStage())
215 {
216 edBase.SetCookingTime(0);
217 }
218 }
219 }
220
222 }
223
224 override bool IsPrepareToDelete()
225 {
226 return false;
227 }
228
229 override void EEItemDetached(EntityAI item, string slot_name)
230 {
231 super.EEItemDetached(item, slot_name);
232
233 ItemBase item_base = ItemBase.Cast(item);
234 if (IsKindling(item_base) || IsFuel(item_base))
235 {
237 }
238
239 // direct cooking / smoking slots
240 switch (slot_name)
241 {
242 case "DirectCookingA":
243 m_DirectCookingSlots[0] = null;
244 break;
245 case "DirectCookingB":
246 m_DirectCookingSlots[1] = null;
247 break;
248 case "DirectCookingC":
249 m_DirectCookingSlots[2] = null;
250 break;
251
252 case "SmokingA":
253 m_SmokingSlots[0] = null;
254 break;
255 case "SmokingB":
256 m_SmokingSlots[1] = null;
257 break;
258 case "SmokingC":
259 m_SmokingSlots[2] = null;
260 break;
261 case "SmokingD":
262 m_SmokingSlots[3] = null;
263 break;
264 }
265
266 // cookware-specifics (remove audio visuals)
267 if (item_base.Type() == ATTACHMENT_CAULDRON || item_base.Type() == ATTACHMENT_COOKING_POT)
268 {
269 ClearCookingEquipment(item_base);
270 Bottle_Base cooking_pot = Bottle_Base.Cast(item);
271 cooking_pot.RemoveAudioVisualsOnClient();
272 }
273 if (item_base.Type() == ATTACHMENT_FRYING_PAN)
274 {
275 ClearCookingEquipment(item_base);
276 FryingPan frying_pan = FryingPan.Cast(item);
277 frying_pan.RemoveAudioVisualsOnClient();
278 }
279
281 }
282
283 //CONDITIONS
284 //this into/outo parent.Cargo
285 override bool CanPutInCargo( EntityAI parent )
286 {
287 if ( !super.CanPutInCargo( parent ) )
288 return false;
289
291 return false;
292
293 return true;
294 }
295
296 override bool CanRemoveFromCargo( EntityAI parent )
297 {
298 return true;
299 }
300
301 //cargo item into/outo this.Cargo
302 override bool CanReceiveItemIntoCargo( EntityAI item )
303 {
304 if ( GetHealthLevel() == GameConstants.STATE_RUINED )
305 return false;
306
307 if (!IsOpen())
308 return false;
309
310 return super.CanReceiveItemIntoCargo( item );
311 }
312
313 override bool CanLoadItemIntoCargo( EntityAI item )
314 {
315 if (!super.CanLoadItemIntoCargo( item ))
316 return false;
317
318 if ( GetHealthLevel() == GameConstants.STATE_RUINED )
319 return false;
320
321 if ( GetHierarchyParent() )
322 return false;
323
324 return true;
325 }
326
327 override bool CanReleaseCargo( EntityAI cargo )
328 {
329 return IsOpen();
330 }
331
332 //hands
333 override bool CanPutIntoHands(EntityAI parent)
334 {
335 if (!super.CanPutIntoHands(parent))
336 {
337 return false;
338 }
339
341 {
342 return false;
343 }
344
345 if ( !GetInventory().IsAttachment() && IsOpen() )
346 {
347 return false;
348 }
349
350 return true;
351 }
352
353 //INVENTORY DISPLAY CONDITIONS
354 override bool CanDisplayCargo()
355 {
356 //super
357 if( !super.CanDisplayCargo() )
358 {
359 return false;
360 }
361 //
362
363 return IsOpen();
364 }
365
366 override bool CanDisplayAttachmentCategory( string category_name )
367 {
368 //super
369 if( !super.CanDisplayAttachmentCategory( category_name ) )
370 {
371 return false;
372 }
373 //
374
375 if ( ( category_name == "CookingEquipment" ) || ( category_name == "Smoking" ) )
376 {
377 return !IsOpen();
378 }
379 else
380 {
381 return IsOpen();
382 }
383
384 return true;
385 }
386 // ---
387
388 //ACTIONS
389 override void Open()
390 {
391 m_Openable.Open();
392
393 m_RoofAbove = false;
394
396 SetTakeable(false);
397 UpdateVisualState();
398 }
399
400 void OpenLoad()
401 {
402 m_Openable.Open();
403 m_RoofAbove = false;
404
405 SetSynchDirty();
406 SetTakeable(false);
407 UpdateVisualState();
408 }
409
410 override void Close()
411 {
412 m_Openable.Close();
413 m_RoofAbove = true;
414
416 SetTakeable(true);
417 UpdateVisualState();
418 }
419
421 {
422 m_Openable.Close();
423 m_RoofAbove = true;
424
425 SetSynchDirty();
426 SetTakeable(true);
427 UpdateVisualState();
428 }
429
430 override bool IsOpen()
431 {
432 return m_Openable.IsOpened();
433 }
434
435 protected void UpdateVisualState()
436 {
437 if ( IsOpen() )
438 {
439 SetAnimationPhase( ANIMATION_OPENED, 0 );
440 SetAnimationPhase( ANIMATION_CLOSED, 1 );
441 }
442 else
443 {
444 SetAnimationPhase( ANIMATION_OPENED, 1 );
445 SetAnimationPhase( ANIMATION_CLOSED, 0 );
446 }
447 }
448
449 //Can extinguish fire
450 override bool CanExtinguishFire()
451 {
452 if ( IsOpen() && IsBurning() )
453 {
454 return true;
455 }
456
457 return false;
458 }
459
460 //particles
461 override bool CanShowSmoke()
462 {
463 return IsOpen();
464 }
465
466 // Item-to-item fire distribution
467 override bool HasFlammableMaterial()
468 {
469 return true;
470 }
471
472 override bool CanBeIgnitedBy( EntityAI igniter = NULL )
473 {
474 if ( HasAnyKindling() && !IsBurning() && IsOpen() && !GetHierarchyParent() )
475 {
476 return true;
477 }
478
479 return false;
480 }
481
482 override bool CanIgniteItem( EntityAI ignite_target = NULL )
483 {
484 if ( IsBurning() && IsOpen() )
485 {
486 return true;
487 }
488
489 return false;
490 }
491
492 override bool IsIgnited()
493 {
494 return IsBurning();
495 }
496
497 override void OnIgnitedTarget( EntityAI ignited_item )
498 {
499 }
500
501 override void OnIgnitedThis( EntityAI fire_source )
502 {
503 //remove grass
505 cc_object.SetOrientation ( GetOrientation() );
506 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).CallLater( DestroyClutterCutter, 0.2, false, cc_object );
507
508 //start fire
509 StartFire();
510 }
511
513 {
514 EffectSound sound = SEffectManager.PlaySound( "barrel_open_SoundSet", GetPosition() );
515 sound.SetAutodestroy( true );
516 }
517
519 {
520 EffectSound sound = SEffectManager.PlaySound( "barrel_close_SoundSet", GetPosition() );
521 sound.SetAutodestroy( true );
522 }
523
524 void DestroyClutterCutter( Object clutter_cutter )
525 {
526 GetGame().ObjectDelete( clutter_cutter );
527 }
528
529 override bool IsThisIgnitionSuccessful( EntityAI item_source = NULL )
530 {
531 //check kindling
532 if ( !HasAnyKindling() && IsOpen() )
533 {
534 return false;
535 }
536
537 //check surface
538 if ( IsOnWaterSurface() )
539 {
540 return false;
541 }
542
543 return true;
544 }
545
546 //================================================================
547 // ADVANCED PLACEMENT
548 //================================================================
549
550 override string GetPlaceSoundset()
551 {
552 return "placeBarrel_SoundSet";
553 }
554
555 override void SetActions()
556 {
558 super.SetActions();
559
564 }
565
566 override void OnDebugSpawn()
567 {
568 m_Openable.Open();
569 super.OnDebugSpawn();
570 m_Openable.Close();
571 }
572}
void AddAction(typename actionName)
vector GetOrientation()
override string GetInvulnerabilityTypeString()
const int ECE_PLACE_ON_SURFACE
void RefreshFireplaceVisuals()
bool HasAnyKindling()
bool SmokingSlotsInUse()
bool DirectCookingSlotsInUse()
ATTACHMENT_FRYING_PAN
ATTACHMENT_CAULDRON
protected int PARTICLE_SMALL_FIRE
protected ItemBase m_SmokingSlots[SMOKING_SLOT_COUNT]
protected void RemoveFromFireConsumables(FireConsumable fire_consumable)
protected bool IsFuel(ItemBase item)
Returns if item attached to fireplace is fuel.
bool IsOnWaterSurface()
const string OBJECT_CLUTTER_CUTTER
protected int PARTICLE_FIRE_END
protected int PARTICLE_SMALL_SMOKE
protected FireConsumable GetFireConsumableByItem(ItemBase item)
protected int PARTICLE_FIRE_START
protected int PARTICLE_NORMAL_FIRE
bool IsCargoEmpty()
protected bool m_RoofAbove
protected void AddToFireConsumables(ItemBase item)
ATTACHMENT_COOKING_POT
protected int PARTICLE_STEAM_END
bool IsBurning()
void StartFire(bool force_start=false)
protected float m_LightDistance
protected bool IsKindling(ItemBase item)
Returns if item attached to fireplace is kindling.
protected int PARTICLE_NORMAL_SMOKE
void ClearCookingEquipment()
DEPRECATED.
protected void RefreshFireParticlesAndSounds(bool force_refresh)
protected ItemBase m_DirectCookingSlots[DIRECT_COOKING_SLOT_COUNT]
bool IsOpen()
Definition ItemBase.c:8610
void SoundSynchRemote()
Definition ItemBase.c:8883
override bool IsBeingPlaced()
Definition ItemBase.c:5540
override void SetTakeable(bool pState)
Definition ItemBase.c:8843
void Close()
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Definition ItemBase.c:8031
void Open()
Implementations only.
Definition CannedFood.c:88
bool IsSoundSynchRemote()
Definition ItemBase.c:8890
protected bool m_Initialized
class JsonUndergroundAreaTriggerData GetPosition
proto native void ObjectDelete(Object obj)
proto native Object CreateObjectEx(string type, vector pos, int iFlags, int iRotation=RF_DEFAULT)
Creates object of certain type.
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
override bool IsOpen()
override void OnDebugSpawn()
override bool CanDisplayAttachmentCategory(string category_name)
override bool IsBarrelWithHoles()
override void OnIgnitedTarget(EntityAI ignited_item)
override bool CanDisplayCargo()
override void OnStoreSave(ParamsWriteContext ctx)
override bool CanReceiveItemIntoCargo(EntityAI item)
override bool CanLoadItemIntoCargo(EntityAI item)
override bool CanExtinguishFire()
override bool CanBeIgnitedBy(EntityAI igniter=NULL)
override bool CanPutInCargo(EntityAI parent)
override bool IsIgnited()
override bool CanReleaseCargo(EntityAI cargo)
override void EEItemDetached(EntityAI item, string slot_name)
override void OnIgnitedThis(EntityAI fire_source)
override int GetDamageSystemVersionChange()
override string GetPlaceSoundset()
override bool CanIgniteItem(EntityAI ignite_target=NULL)
override bool IsThisIgnitionSuccessful(EntityAI item_source=NULL)
override void OnWasDetached(EntityAI parent, int slot_id)
override bool CanPutIntoHands(EntityAI parent)
override bool CanRemoveFromCargo(EntityAI parent)
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override void Close()
override bool HasFlammableMaterial()
protected ref OpenableBehaviour m_Openable
override void EEItemAttached(EntityAI item, string slot_name)
override bool IsPrepareToDelete()
void DestroyClutterCutter(Object clutter_cutter)
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanShowSmoke()
override void OnVariablesSynchronized()
protected void UpdateVisualState()
override bool CanDetachAttachment(EntityAI parent)
override void Open()
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
override bool CanLoadAttachment(EntityAI attachment)
override string GetInvulnerabilityTypeString()
override void SetActions()
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
override bool CanLoadAttachment(EntityAI attachment)
static const int BARREL_NORMAL_SMOKE
static const int BARREL_NORMAL_FIRE
static const int BARREL_FIRE_END
static const int BARREL_FIRE_START
static const int BARREL_SMALL_SMOKE
static const int BARREL_SMALL_FIRE
static const int BARREL_FIRE_STEAM_2END
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.
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
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()
const int STATE_RUINED
Definition constants.c:742
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10