DayZ 1.24
Loading...
Searching...
No Matches
Fireplace.c
Go to the documentation of this file.
1class Fireplace extends FireplaceBase
2{
4
18
19 override bool IsBaseFireplace()
20 {
21 return true;
22 }
23
24 override void EOnTouch(IEntity other, int extra)
25 {
27 }
28
30 {
31 ContactEvent(other, extra.Position);
32 }
33
35 {
36 if (GetGame().IsServer() && !m_ContactEventProcessing && dBodyIsActive(this) && !IsSetForDeletion())
37 {
38 m_ContactEventProcessing = true;
39 MiscGameplayFunctions.ThrowAllItemsInInventory(this, 0);
40 CheckForDestroy();
41 m_ContactEventProcessing = false;
42 }
43 }
44
45 //attachments
47 {
48 if (!super.CanReceiveAttachment(attachment, slotId))
49 return false;
50
52
53 //cookware
54 if ((item.Type() == ATTACHMENT_CAULDRON) || (item.Type() == ATTACHMENT_COOKING_POT))
55 {
56 if (FindAttachmentBySlotName("CookingTripod") || IsOven())
57 return true;
58 return false;
59 }
60 if (item.Type() == ATTACHMENT_FRYING_PAN)
61 {
62 if (IsOven())
63 return true;
64 return false;
65 }
66
67 // food on direct cooking slots
68 if (item.IsKindOf("Edible_Base"))
69 {
70 if (IsOven())
71 return true;
72 return false;
73 }
74 //tripod
75
76 if (item.IsInherited(TripodBase))
77 {
78 if (!IsOven() && !GetHierarchyParent())
79 return true;
80 return false;
81 }
82
83 //stones
84 if (item.Type() == ATTACHMENT_STONES)
85 {
86 if (!GetHierarchyParent() && !IsBurning())
87 return true;
88 return false;
89 }
90
91 return true;
92 }
93
95 {
97 if (super.CanDisplayAttachmentSlot(slot_id))
98 {
99 if (slot_name != "CookingEquipment" || FindAttachmentBySlotName("CookingTripod"))
100 return true;
101 }
102
103 return false;
104 }
105
107 {
108 if (!super.CanLoadAttachment(attachment))
109 return false;
110
112
113 //cookware
114 if ((item.Type() == ATTACHMENT_CAULDRON) || (item.Type() == ATTACHMENT_COOKING_POT))
115 {
116 //if ( IsItemTypeAttached( ATTACHMENT_TRIPOD ) /*|| IsOven()*/ )
117 return true;
118 }
119 if (item.Type() == ATTACHMENT_FRYING_PAN)
120 {
121 //if ( IsOven() )
122 return true;
123 }
124
125 // food on direct cooking slots
126 //if ( IsOven() )
127 //{
128 if (item.IsKindOf("Edible_Base"))
129 return true;
130 //}
131 //tripod
132 if (item.Type() == ATTACHMENT_TRIPOD)
133 {
134 if ( GetHierarchyParent() == NULL)
135 return true;
136 }
137
138 //stones
139 if (item.Type() == ATTACHMENT_STONES)
140 {
141 if (GetHierarchyParent() /*|| IsBurning()*/)
142 return false;
143
144 return true;
145 }
146
147 return true;
148 }
149
151 {
152 if (!super.CanReleaseAttachment(attachment))
153 return false;
154
156 //stones
157 if (item.Type() == ATTACHMENT_STONES)
158 {
159 if (IsBurning())
160 return false;
161
162 int stone_quantity = item.GetQuantity();
163 if (HasStoneCircle() && stone_quantity <= 8)
164 return false;
165
166 if (IsOven())
167 return false;
168 }
169
170 return true;
171 }
172
173 override void EEItemAttached(EntityAI item, string slot_name)
174 {
175 super.EEItemAttached(item, slot_name);
176
178
181
182 //cookware
183 if (item_base.Type() == ATTACHMENT_COOKING_POT)
184 {
186
187 //rotate handle (if not in 'Oven' stage)
188 if (GetGame().IsServer() && !IsOven())
189 item_base.SetAnimationPhase(ANIMATION_COOKWARE_HANDLE, 0);
190 }
191 if (item.Type() == ATTACHMENT_CAULDRON)
192 {
194
195 //rotate handle (if not in 'Oven' stage)
196 if (GetGame().IsServer() && !IsOven())
197 item_base.SetAnimationPhase(ANIMATION_CAULDRON_HANDLE, 0);
198 }
199
200 // direct cooking/smoking slots
201 bool edible_base_attached = false;
202 switch (slot_name)
203 {
204 case "DirectCookingA":
207 break;
208 case "DirectCookingB":
211 break;
212 case "DirectCookingC":
215 break;
216
217 case "SmokingA":
220 break;
221 case "SmokingB":
224 break;
225 case "SmokingC":
228 break;
229 case "SmokingD":
232 break;
233 }
234
235 // reset cooking time (to prevent the cooking exploit)
236 if (GetGame().IsServer() && edible_base_attached)
237 {
239 if (edBase)
240 {
241 if (edBase.GetFoodStage())
242 edBase.SetCookingTime(0);
243 }
244 }
245
246 //TODO
247 //add SetViewIndex when attaching various attachments
248
250 }
251
252 override void EEItemDetached(EntityAI item, string slot_name)
253 {
254 super.EEItemDetached(item, slot_name);
255
257
260
261 //cookware
262 if (item_base.Type() == ATTACHMENT_COOKING_POT)
263 {
265
266 //rotate handle
267 if (GetGame().IsServer())
268 item_base.SetAnimationPhase(ANIMATION_COOKWARE_HANDLE, 1);
269
270 //remove audio visuals
272 cooking_pot.RemoveAudioVisualsOnClient();
273 }
274 if (item_base.Type() == ATTACHMENT_CAULDRON)
275 {
277
278 //rotate handle
279 if (GetGame().IsServer())
280 item_base.SetAnimationPhase(ANIMATION_CAULDRON_HANDLE, 1);
281
282 //remove audio visuals
284 cauldron.RemoveAudioVisualsOnClient();
285 }
286 if (item_base.Type() == ATTACHMENT_FRYING_PAN)
287 {
289
290 //remove audio visuals
291 FryingPan frying_pan = FryingPan.Cast(item);
292 frying_pan.RemoveAudioVisualsOnClient();
293 }
294
295 // direct cooking/smoking slots
296 switch (slot_name)
297 {
298 case "DirectCookingA":
300 break;
301 case "DirectCookingB":
303 break;
304 case "DirectCookingC":
306 break;
307
308 case "SmokingA":
309 m_SmokingSlots[0] = null;
310 break;
311 case "SmokingB":
312 m_SmokingSlots[1] = null;
313 break;
314 case "SmokingC":
315 m_SmokingSlots[2] = null;
316 break;
317 case "SmokingD":
318 m_SmokingSlots[3] = null;
319 break;
320 }
321
322 //no attachments left, no cargo items & no ashes are present
323 CheckForDestroy();
325 }
326
327
329 {
330 super.SetCookingEquipment(equipment);
331
332 TripodBase stand = TripodBase.Cast(FindAttachmentBySlotName("CookingTripod"));
333 if (stand)
334 {
335 if (equipment)
336 stand.LockToParent();
337 else
338 stand.UnlockFromParent();
339 }
340 }
341
342 override void OnBeforeTryDelete()
343 {
344 super.OnBeforeTryDelete();
345
346 MiscGameplayFunctions.DropAllItemsInInventoryInBounds(this, m_HalfExtents);
347 }
348
349 override bool IsPrepareToDelete()
350 {
351 return GetInventory().AttachmentCount() == 0 && !IsBurning() && !HasAshes();
352 }
353
354 //CONDITIONS
355 //this into/outo parent.Cargo
356 override bool CanPutInCargo(EntityAI parent)
357 {
358 if (!super.CanPutInCargo(parent))
359 return false;
360
361 if (HasAshes() || IsBurning() || HasStones() || HasStoneCircle() || IsOven() || !IsCargoEmpty() || HasCookingStand())
362 return false;
363
364 return true;
365 }
366
367 override bool CanRemoveFromCargo(EntityAI parent)
368 {
369 return true;
370 }
371
372 //cargo item into/outo this.Cargo
374 {
375 if (GetHierarchyParent())
376 return false;
377
378 return super.CanReceiveItemIntoCargo(item);
379 }
380
382 {
383 if (!super.CanLoadItemIntoCargo(item))
384 return false;
385
386 if (GetHierarchyParent())
387 return false;
388
389 return true;
390 }
391
392 //hands
393 override bool CanPutIntoHands(EntityAI parent)
394 {
395 if (!super.CanPutIntoHands(parent))
396 return false;
397
398 if (HasAshes() || IsBurning() || HasStones() || HasStoneCircle() || IsOven() || !IsCargoEmpty() || HasCookingStand())
399 return false;
400
401 return true;
402 }
403
405 {
406 if (!super.CanDisplayAttachmentCategory(category_name))
407 return false;
408
409 if (IsOven())
410 {
411 if (category_name == "CookingEquipment")
412 return false;
413 if ((category_name == "DirectCooking") || (category_name == "Smoking"))
414 return true;
415 }
416 else
417 {
418 if (category_name == "CookingEquipment")
419 return true;
420 if ((category_name == "DirectCooking") || (category_name == "Smoking"))
421 return false;
422 }
423 return true;
424 }
425
427 {
428 return false;
429 }
430
432 {
433 return 0.32;
434 }
435
436 //particles
437 override bool CanShowSmoke()
438 {
439 return !IsOven();
440 }
441
442
444 {
445 GetGame().ObjectDelete(clutter_cutter);
446 }
447
448 override void RefreshPhysics()
449 {
450 super.RefreshPhysics();
451
452 //Oven
453 if (IsOven())
454 {
455 RemoveProxyPhysics(ANIMATION_OVEN);
456 AddProxyPhysics(ANIMATION_OVEN);
457 }
458 else
459 RemoveProxyPhysics(ANIMATION_OVEN);
460
461 //Tripod
463 {
464 RemoveProxyPhysics(ANIMATION_TRIPOD);
465 AddProxyPhysics(ANIMATION_TRIPOD);
466 }
467 else
468 RemoveProxyPhysics(ANIMATION_TRIPOD);
469 }
470
472 {
474 }
475
476 //on store save/load
478 {
479 super.OnStoreSave(ctx);
480
481 if (GetGame().SaveVersion() >= 110)
482 {
483 // save stone circle state
484 ctx.Write(m_HasStoneCircle);
485
486 // save stone oven state
487 ctx.Write(m_IsOven);
488 }
489 }
490
491 override bool OnStoreLoad(ParamsReadContext ctx, int version)
492 {
493 if (!super.OnStoreLoad(ctx, version))
494 return false;
495
496 if (version >= 110)
497 {
498 // read stone circle state
499 if (!ctx.Read(m_HasStoneCircle))
500 {
501 m_HasStoneCircle = false;
502 return false;
503 }
504 // read stone oven state
505 if (!ctx.Read(m_IsOven))
506 {
507 m_IsOven = false;
508 return false;
509 }
510 }
511 return true;
512 }
513
514 override void AfterStoreLoad()
515 {
516 super.AfterStoreLoad();
517
518 if (IsBurning())
519 {
520 if (!m_ClutterCutter)
521 {
523 m_ClutterCutter.SetOrientation(GetOrientation());
524 }
525 }
526 }
527
528 //================================================================
529 // IGNITION ACTION
530 //================================================================
531
532 // Item-to-item fire distribution
533 override bool HasFlammableMaterial()
534 {
535 return true;
536 }
537
539 {
540 return HasAnyKindling() && !IsBurning() && !GetHierarchyParent();
541 }
542
544 {
545 return IsBurning();
546 }
547
548 override bool IsIgnited()
549 {
550 return IsBurning();
551 }
552
554 {
555 }
556
558 {
559 //remove grass
561 cc_object.SetOrientation(GetOrientation());
562 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(DestroyClutterCutter, 200, false, cc_object);
563
564 //start fire
565 StartFire();
566
567 if (fire_source)
568 {
569 Man player = fire_source.GetHierarchyRootPlayer();
570
571 if (player)
572 {
574
575 if (fire_source.ClassName() == "Matchbox")
576 ignate_type = EFireIgniteType.Matchbox;
577 else if (fire_source.ClassName() == "Roadflare")
578 ignate_type = EFireIgniteType.Roadflare;
579 else if (fire_source.ClassName() == "HandDrillKit")
580 ignate_type = EFireIgniteType.HandDrill;
581
582
584 }
585 }
586 }
587
589 {
590 SetIgniteFailure(false);
592
593 //check kindling
594 if (!HasAnyKindling())
595 return false;
596
597 //check roof
598 if (!IsOven())
599 {
601 return false;
602 }
603
604 //check surface
605 if (IsOnWaterSurface())
606 return false;
607
608 //check wetness
609 if (IsWet())
610 {
611 SetIgniteFailure(true);
612
614 GetGame().RPCSingleParam(this, FirePlaceFailure.WET, failure, true);
615 return false;
616 }
617
618 // check if the fireplace isnt below a roof
619 // excluding this check whein oven stage
620 if (!IsOven() && !MiscGameplayFunctions.IsUnderRoof(this))
621 {
622 // if not, check if there is strong rain or wind
623 if (IsRainingAbove())
624 {
625 SetIgniteFailure(true);
626
628 GetGame().RPCSingleParam(this, FirePlaceFailure.WET, failure, true);
629 return false;
630 }
631
632 if (IsWindy())
633 {
634 SetIgniteFailure(true);
635
637 GetGame().RPCSingleParam(this, FirePlaceFailure.WIND, failure, true);
638 return false;
639 }
640 }
641
642 return true;
643 }
644
645 //================================================================
646 // FIREPLACE ENTITY
647 //================================================================
649 {
650 //get player
651 PlayerBase player = PlayerBase.Cast(fire_source.GetHierarchyRootPlayer());
652
653 //create fireplace
654 Fireplace fireplace = Fireplace.Cast(GetGame().CreateObjectEx("Fireplace", entity.GetPosition(), ECE_PLACE_ON_SURFACE));
655
656 //attach
657 if (!GetGame().IsMultiplayer()) //clear inventory reservation (single player)
658 {
660 entity.GetInventory().GetCurrentInventoryLocation(loc);
661 player.GetInventory().ClearInventoryReservationEx(entity, loc);
662 }
663
664 if (GetGame().IsServer() && GetGame().IsMultiplayer())
665 {
666 player.ServerTakeEntityToTargetAttachment(fireplace, entity); // multiplayer server side
667 }
668 else
669 {
670 player.LocalTakeEntityToTargetAttachment(fireplace, entity); // single player or multiplayer client side
671 }
672
673 //start fire
674 fireplace.StartFire();
675 fireplace.OnIgnitedThis(fire_source);
676
677 return fireplace;
678 }
679
681 {
682 //check ceiling (enough space for smoke)
683 if (MiscGameplayFunctions.IsUnderRoof(entity, FireplaceBase.MIN_CEILING_HEIGHT) && IsEntityOnInteriorSurface(entity))
684 return false;
685
686 //check surface
687 if (FireplaceBase.IsEntityOnWaterSurface(entity))
688 return false;
689
690 if (!MiscGameplayFunctions.IsUnderRoof(entity))
691 return !FireplaceBase.IsRainingAboveEntity(entity);
692
693 return true;
694 }
695
696 //================================================================
697 // ADVANCED PLACEMENT
698 //================================================================
699
700 override string GetPlaceSoundset()
701 {
702 return "placeFireplace_SoundSet";
703 }
704
719}
ActionBuildOvenCB ActionContinuousBaseCB ActionBuildOven()
ActionBuildStoneCircleCB ActionContinuousBaseCB ActionBuildStoneCircle()
ActionDismantleOvenCB ActionContinuousBaseCB ActionDismantleOven()
ActionDismantleStoneCircleCB ActionContinuousBaseCB ActionDismantleStoneCircle()
void AddAction(typename actionName)
vector GetOrientation()
const int ECE_PLACE_ON_SURFACE
Container_Base m_HalfExtents
EFireIgniteType
void RefreshFireplaceVisuals()
void RemoveFromFireConsumables(FireConsumable fire_consumable)
static bool IsEntityOnInteriorSurface(notnull EntityAI entity_ai)
bool HasAnyKindling()
const string ANIMATION_OVEN
Object m_ClutterCutter
ATTACHMENT_FRYING_PAN
ATTACHMENT_CAULDRON
bool IsCeilingHighEnoughForSmoke()
void AddToFireConsumables(ItemBase item)
int PARTICLE_STEAM_END
bool m_HasStoneCircle
bool HasCookingStand()
int PARTICLE_NORMAL_FIRE
bool IsOnWaterSurface()
const string OBJECT_CLUTTER_CUTTER
const string ANIMATION_CAULDRON_HANDLE
bool HasAshes()
bool IsRainingAbove()
const string ANIMATION_TRIPOD
static bool IsWindy()
bool HasStones()
int PARTICLE_FIRE_START
bool IsCargoEmpty()
bool IsFuel(ItemBase item)
Returns if item attached to fireplace is fuel.
bool GetIgniteFailure()
bool IsOnInteriorSurface()
int PARTICLE_NORMAL_SMOKE
ATTACHMENT_STONES
ATTACHMENT_COOKING_POT
bool IsBurning()
bool IsWet()
void StartFire(bool force_start=false)
ItemBase m_DirectCookingSlots[DIRECT_COOKING_SLOT_COUNT]
int PARTICLE_FIRE_END
void SetIgniteFailure(bool failure)
bool m_IsOven
ATTACHMENT_TRIPOD
bool HasStoneCircle()
int PARTICLE_SMALL_SMOKE
bool IsOven()
const string ANIMATION_COOKWARE_HANDLE
void ClearCookingEquipment()
DEPRECATED.
FireConsumable GetFireConsumableByItem(ItemBase item)
ItemBase m_SmokingSlots[SMOKING_SLOT_COUNT]
bool IsKindling(ItemBase item)
Returns if item attached to fireplace is kindling.
bool IsItemTypeAttached(typename item_type)
int PARTICLE_SMALL_FIRE
class JsonUndergroundAreaTriggerData GetPosition
override void OnBeforeTryDelete()
Definition Fireplace.c:342
void ContactEvent(IEntity other, vector position)
Definition Fireplace.c:34
override void SetActions()
Definition Fireplace.c:705
override bool IsBaseFireplace()
Definition Fireplace.c:19
override string GetPlaceSoundset()
Definition Fireplace.c:700
static Fireplace IgniteEntityAsFireplace(notnull EntityAI entity, notnull EntityAI fire_source)
Definition Fireplace.c:648
override void EOnTouch(IEntity other, int extra)
Definition Fireplace.c:24
override void EOnContact(IEntity other, Contact extra)
Definition Fireplace.c:29
override void RefreshFireplacePhysics()
Definition Fireplace.c:471
override bool CanIgniteItem(EntityAI ignite_target=NULL)
Definition Fireplace.c:543
override void EEItemAttached(EntityAI item, string slot_name)
Definition Fireplace.c:173
override bool IsPrepareToDelete()
Definition Fireplace.c:349
override void SetCookingEquipment(ItemBase equipment)
Definition Fireplace.c:328
override void RefreshPhysics()
Definition Fireplace.c:448
override bool CanPutIntoHands(EntityAI parent)
Definition Fireplace.c:393
override bool CanShowSmoke()
Definition Fireplace.c:437
void DestroyClutterCutter(Object clutter_cutter)
Definition Fireplace.c:443
override bool CanBeIgnitedBy(EntityAI igniter=NULL)
Definition Fireplace.c:538
bool m_ContactEventProcessing
Definition Fireplace.c:3
override bool CanDisplayAttachmentSlot(int slot_id)
Definition Fireplace.c:94
override void OnIgnitedTarget(EntityAI ignited_item)
Definition Fireplace.c:553
override bool HasFlammableMaterial()
Definition Fireplace.c:533
override bool CanPutInCargo(EntityAI parent)
Definition Fireplace.c:356
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition Fireplace.c:46
override bool CanLoadAttachment(EntityAI attachment)
Definition Fireplace.c:106
override bool IsIgnited()
Definition Fireplace.c:548
void Fireplace()
Definition Fireplace.c:5
override void OnIgnitedThis(EntityAI fire_source)
Definition Fireplace.c:557
override bool CanAssignAttachmentsToQuickbar()
Definition Fireplace.c:426
static bool CanIgniteEntityAsFireplace(notnull EntityAI entity)
Definition Fireplace.c:680
override bool CanReceiveItemIntoCargo(EntityAI item)
Definition Fireplace.c:373
override void AfterStoreLoad()
Definition Fireplace.c:514
override float HeightStartCheckOverride()
Definition Fireplace.c:431
override bool IsThisIgnitionSuccessful(EntityAI item_source=NULL)
Definition Fireplace.c:588
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition Fireplace.c:491
override void EEItemDetached(EntityAI item, string slot_name)
Definition Fireplace.c:252
override bool CanRemoveFromCargo(EntityAI parent)
Definition Fireplace.c:367
override void OnStoreSave(ParamsWriteContext ctx)
Definition Fireplace.c:477
override bool CanDisplayAttachmentCategory(string category_name)
Definition Fireplace.c:404
override bool CanReleaseAttachment(EntityAI attachment)
Definition Fireplace.c:150
override bool CanLoadItemIntoCargo(EntityAI item)
Definition Fireplace.c:381
InventoryLocation.
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
static const int CAMP_SMALL_SMOKE
static const int CAMP_FIRE_START
static const int CAMP_NORMAL_SMOKE
static const int CAMP_STEAM_2END
static const int CAMP_SMALL_FIRE
static const int CAMP_FIRE_END
static const int CAMP_NORMAL_FIRE
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
static void SendPlayerIgnatedFireplace(Man player, EFireIgniteType ignite_type)
Definition SyncEvents.c:77
proto native CGame GetGame()
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44
proto native bool dBodyIsActive(notnull IEntity ent)
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10