Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
torch.c
Go to the documentation of this file.
2{
3 void FlammableBase()
4 {
5 Init();
6 }
7
8 private SoundOnVehicle m_LoopSoundEntity;
9 Particle m_FireParticle;
10 bool m_CanReceiveUpgrade; // Synchronized variable
11 bool m_IsBeingDestructed = false;
12
13 float m_BurnTimePerRagEx;
14 float m_BurnTimePerFullLardEx;
15 float m_BurnTimePerFullFuelDoseEx;
16 float m_MaxConsumableLardQuantityEx;
17 float m_MaxConsumableFuelQuantityEx;
18 float m_WaterEvaporationByFireIntensityEx = 0.001;
19 int m_StartFadeOutOfLightAtQuantityEx = 3;
20
21 int m_RagsUpgradedCount;//how many rags were upgraded with fuel/lard
22 bool m_ConsumeRagFlipFlop;//are we burning rag or fuel/lard
23 vector m_ParticleLocalPos = Vector(0, 0.50, 0);
24
25 string m_DecraftResult = "WoodenStick";
26 TorchLight m_Light;
27 bool m_WasLit;//was this item ever lit ? (used for correct material setting after reconnect for extinguished flammable items)
28
31 protected ref UniversalTemperatureSourceLambdaConstant m_UTSLConstant;
32
33 override void DeferredInit()
34 {
35 if(m_RagsUpgradedCount)
36 {
37 LockRags(true);
38 }
39 }
40
41 void Init()
42 {
43 if ( m_BurnTimePerRagEx == 0 || m_BurnTimePerFullLardEx == 0 || m_MaxConsumableLardQuantityEx == 0 || m_MaxConsumableFuelQuantityEx == 0 )
44 {
45 string cfg_path = "CfgVehicles " + GetType();
46 m_BurnTimePerRagEx = GetGame().ConfigGetFloat( cfg_path + " burnTimePerRag" );
47 m_BurnTimePerFullLardEx = GetGame().ConfigGetFloat( cfg_path + " burnTimePerFullLardDose" );
48 m_BurnTimePerFullFuelDoseEx = GetGame().ConfigGetFloat( cfg_path + " burnTimePerFullFuelDose" );
49 m_MaxConsumableLardQuantityEx = GetGame().ConfigGetFloat( cfg_path + " maxConsumableLardDose" );
50 m_MaxConsumableFuelQuantityEx = GetGame().ConfigGetFloat( cfg_path + " maxConsumableFuelDose" );
51 }
52 RegisterNetSyncVariableBool("m_CanReceiveUpgrade");
53 }
54
55 override void EEInit()
56 {
57 super.EEInit();
58
59 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
60 {
62 m_UTSSettings.m_Updateable = true;
63 m_UTSSettings.m_UpdateInterval = 1;
64 m_UTSSettings.m_TemperatureItemCap = GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE;
65 m_UTSSettings.m_TemperatureCap = 5;
66 m_UTSSettings.m_RangeFull = 0.5;
67 m_UTSSettings.m_RangeMax = 1;
68
69 m_UTSLConstant = new UniversalTemperatureSourceLambdaConstant();
71 }
72
73 }
74
76 {
77 if (GetHierarchyRoot())
78 {
79 return GetHierarchyRoot().GetPosition();
80 }
81
82 return super.GetPosition();
83 }
84
85 override void EEDelete(EntityAI parent)
86 {
87 super.EEDelete(parent);
88 if ( m_LoopSoundEntity != NULL && GetGame() != NULL )
89 {
90 GetGame().ObjectDelete( m_LoopSoundEntity );
91 }
92
94 }
95
96 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
97 {
98 ItemBase att = ItemBase.Cast(GetInventory().FindAttachment(slotId));
99 if (att && att.IsFullQuantity())
100 return false;
101
102 return super.CanReceiveAttachment(attachment, slotId);
103 }
104
105 override bool CanPutInCargo( EntityAI parent )
106 {
107 if( !super.CanPutInCargo(parent) ) {return false;}
108 return CanBeTakenAsCargo();
109 }
110
111 override bool CanReleaseAttachment(EntityAI attachment)
112 {
113 if( !super.CanReleaseAttachment( attachment ) )
114 return false;
115 return !GetCompEM().IsWorking();
116 }
117
118 override bool CanRemoveFromCargo(EntityAI parent)
119 {
120 return CanBeTakenAsCargo();
121 }
122
123 override bool CanPutAsAttachment (EntityAI parent)
124 {
125 return !GetCompEM().IsWorking();
126 }
127
129 {
130 // Don't let players burn their pockets!
131 return !GetCompEM().IsWorking();
132 }
133
134 override bool IsIgnited()
135 {
136 return GetCompEM().IsWorking();
137 }
138
139 override bool CanIgniteItem(EntityAI ignite_target = NULL)
140 {
141 return GetCompEM().IsWorking();
142 }
143
144 override bool HasFlammableMaterial()
145 {
146 return true;
147 }
148
149 // Checkes if Torch can be ignited
150 override bool CanBeIgnitedBy(EntityAI igniter = NULL)
151 {
152 if ( !GetCompEM().CheckWetness() )
153 return false;
154
155 ItemBase rag = GetRag();
156
157 if (rag && GetCompEM().GetEnergy() < GetCompEM().GetEnergyUsage() * GetCompEM().GetUpdateInterval() )
158 {
159 if (IsRagDryEnough(rag))
160 return false;
161 }
162
163 if ( !GetCompEM().CanWork() )
164 return false;
165
166 if ( GetCompEM().GetEnergy() < 3 )
167 return false;
168
169 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
170 if (player)
171 {
172 if (this != player.GetItemInHands())//we are in player's inventory, but not in his hands
173 {
174 return false;
175 }
176 }
177
178 return true;
179 }
180
182 {
183 float wetness = rag.GetWet();
184 bool is_dry_enough = wetness <= 1-GetCompEM().GetWetnessExposure();
185 return is_dry_enough;
186 }
187
189 {
190 if ( GetGame().IsServer() || !GetGame().IsMultiplayer() )
191 {
192 m_CanReceiveUpgrade = GetRagQuantity() > 0 && m_RagsUpgradedCount < GetRagQuantity() || (m_BurnTimePerRagEx * (m_RagsUpgradedCount + GetRagQuantity()) - GetCompEM().GetEnergy()) > 1;
193 SetSynchDirty();
194 }
195 }
196
197 override void OnIgnitedThis(EntityAI fire_source)
198 {
199 if ( !GetCompEM().HasEnoughStoredEnergy() )
200 {
201 ConsumeRag();
202 }
203
204 GetCompEM().SwitchOn();
205 }
206
207 override void OnSwitchOn()
208 {
209 if (!GetCompEM().HasEnoughStoredEnergy())
210 {
211 GetCompEM().SwitchOff();
212 }
213
214 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
215 {
216 m_UTSource.SetActive(true);
217 }
218 }
219
220 override void OnSwitchOff()
221 {
222 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
223 {
224 m_UTSource.SetActive(false);
225 }
226 }
227
228 void SetTorchDecraftResult(string type)
229 {
230 m_DecraftResult = type; //not persistent for the moment
231 }
232
234 {
235 ItemBase rag = GetRag();
236
237 if (rag)
238 {
239 if (rag.GetQuantity() <= 1)
240 {
241 LockRags(false); // Unlock attachment slot before deletion. Otherwise it will get stuck locked and unusable.
242 }
243
244 rag.AddQuantity(-1);
245 rag.SetHealth(0);
246 //GetCompEM().AddEnergy( m_BurnTimePerRagEx );
247 return true;
248 }
249
250 return false;
251 }
252
253 void ConsumeLard(Lard lard)
254 {
255 if (lard)
256 {
257 float lard_quant = lard.GetQuantity();
258
259 float available_lard_quant = lard_quant;
260
261 if ( available_lard_quant > m_MaxConsumableLardQuantityEx )
262 available_lard_quant = m_MaxConsumableLardQuantityEx;
263
264 float available_lard_coef = available_lard_quant / m_MaxConsumableLardQuantityEx;
265
266 float add_energy = m_BurnTimePerFullLardEx * available_lard_coef;
267 float add_energy_coef = 1;
268
269 float energy_limit = GetCompEM().GetEnergyMax() - GetCompEM().GetEnergy();
270
271 if (add_energy > energy_limit )
272 {
273 add_energy_coef = energy_limit / add_energy;
274 add_energy = energy_limit;
275 available_lard_quant = available_lard_quant * add_energy_coef;
276 }
277
278 GetCompEM().AddEnergy( add_energy );
279 lard.AddQuantity(-available_lard_quant);
280
282
284 }
285 }
286
287 void Upgrade(ItemBase source)
288 {
289 if (!GetRag())
290 {
291 return;
292 }
293 RuinRags();
294 LockRags(true);
295 float torchCurrentEnergy = GetCompEM().GetEnergy();
296 float sourceQuantity = 100000;//for upgrade from environment(gas pump)
297
298 if (source)
299 {
300 sourceQuantity = source.GetQuantity();
301 }
302
303 float maxOverallCapacity = GetRagQuantity() * 2 * m_BurnTimePerRagEx;
304 //float maxUpgradeCapacity = GetRagQuantity() * m_BurnTimePerRagEx;
305 float currentlyUpgraded = Math.Max(0, torchCurrentEnergy - (GetRagQuantity() * m_BurnTimePerRagEx));
306 //float freeUpgradeCapacity = maxUpgradeCapacity - currentlyUpgraded;
307 float freeUpgradeCapacity = maxOverallCapacity - torchCurrentEnergy;
308 float upgradeQuantity = Math.Min(freeUpgradeCapacity, sourceQuantity);
309 int upgradedRags = Math.Ceil((upgradeQuantity + currentlyUpgraded) / m_BurnTimePerRagEx);
310 upgradedRags = Math.Min(GetRagQuantity(), upgradedRags);
311 m_RagsUpgradedCount = upgradedRags;
312 GetCompEM().AddEnergy(upgradeQuantity);
313 m_ConsumeRagFlipFlop = 0;//consume fuel first
314 if (source)
315 {
316 source.AddQuantity(-upgradeQuantity);
317 }
320 }
321
322
323
325 {
326 if (vessel)
327 {
328 float vessel_quant = vessel.GetQuantity();
329
330 float available_vessel_quant = vessel_quant;
331
332 if ( available_vessel_quant > m_MaxConsumableFuelQuantityEx )
333 available_vessel_quant = m_MaxConsumableFuelQuantityEx;
334
335 float available_vessel_coef = available_vessel_quant / m_MaxConsumableFuelQuantityEx;
336
337 float add_energy = m_BurnTimePerFullFuelDoseEx * available_vessel_coef;
338 float add_energy_coef = 1;
339
340 float energy_limit = GetCompEM().GetEnergyMax() - GetCompEM().GetEnergy();
341
342 if (add_energy > energy_limit )
343 {
344 add_energy_coef = energy_limit / add_energy;
345 add_energy = energy_limit;
346 available_vessel_quant = available_vessel_quant * add_energy_coef;
347 }
348
349 GetCompEM().AddEnergy( add_energy );
350 vessel.AddQuantity(-available_vessel_quant);
351
353
355 }
356 }
357
359 {
360 float add_energy = m_BurnTimePerFullFuelDoseEx;
361 float add_energy_coef = 1;
362
363 float energy_limit = GetCompEM().GetEnergyMax() - GetCompEM().GetEnergy();
364
365 if (add_energy > energy_limit )
366 {
367 add_energy_coef = energy_limit / add_energy;
368 add_energy = energy_limit;
369 }
370
371 GetCompEM().AddEnergy( add_energy );
374 }
375
376 void RuinRags()
377 {
378 ItemBase rag = GetRag();
379
380 if (rag)
381 {
382 rag.SetHealth(1); //does not actually ruin rags, combining would be impossible
383 }
384 }
385
386 // Inventory manipulation
387 override void OnInventoryExit(Man player)
388 {
389 super.OnInventoryExit(player);
390
391 StandUp();
392 }
393
394 // Stands up the torch, if possible. Returns true on success.
395 bool StandUp()
396 {
397 string surface_type;
398 vector position = GetPosition();
399 GetGame().SurfaceGetType ( position[0], position[2], surface_type );
400 bool is_surface_soft = GetGame().IsSurfaceDigable(surface_type);
401
402 if ( is_surface_soft && !IsRuined() )
403 {
404 vector ori_rotate = "0 0 0";
405 ori_rotate[0] = Math.RandomFloat(0, 360);
406 ori_rotate[1] = Math.RandomFloat(0, 10);
407 SetOrientation(ori_rotate);
408
409 return true; // I am standing up
410 }
411
412 return false; // I am NOT standing up
413 }
414
416 {
417 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
418 {
419 SetQuantityNormalized(GetCompEM().GetEnergy0To1());
420 }
421 }
422
424 {
425 return m_CanReceiveUpgrade;
426 }
427
428 void CraftingInit(float quantity)
429 {
430 GetCompEM().SetEnergy(m_BurnTimePerRagEx * quantity);
431 m_CanReceiveUpgrade = true;
432 SetSynchDirty();
433 }
434
435
436 override void EEItemAttached( EntityAI item, string slot_name )
437 {
438 super.EEItemAttached( item, slot_name );
441 }
442
443
444 override void EEItemDetached( EntityAI item, string slot_name )
445 {
446 super.EEItemDetached( item, slot_name );
447
448 if (m_IsBeingDestructed)
449 {
450 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
451 {
452 EntityAI rags = EntityAI.Cast(GetGame().CreateObjectEx(item.GetType(), GetPosition(), ECE_PLACE_ON_SURFACE));
453 if( rags )
454 MiscGameplayFunctions.TransferItemProperties(item, rags);
455 }
456 return;
457 }
458
461 GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( TryTransformIntoStick, 100);
462 }
463
465 {
466 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && !IsIgnited() && !GetRag() && !IsSetForDeletion() )
467 return true;
468 else
469 return false;
470 }
471
473 {
474 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
475 if ( m_IsBeingDestructed || (player && player.IsPlayerDisconnected()) )
476 return;
477
478 if ( CanTransformIntoStick() )
479 {
480 m_IsBeingDestructed = true;
481 if (player)
482 {
483 // Transform object into wooden stick
485
486 TorchLambda lambda = new TorchLambda(this, m_DecraftResult);
487 player.ServerReplaceItemInHandsWithNew(lambda);
488 }
489 else
490 {
491 // Create wooden stick and delete Torch
492 vector pos = GetPosition();
493 vector ori = GetOrientation();
494
495 if ( GetType() == "WoodenStick" )
496 ori = ori + Vector(0,90,0);
497
498 ItemBase stick = ItemBase.Cast( GetGame().CreateObjectEx(m_DecraftResult, pos, ECE_PLACE_ON_SURFACE) );
500 stick.SetPosition(pos);
501 stick.PlaceOnSurface();
502
503 if ( stick.GetType() == "LongWoodenStick" )
504 {
505 pos = stick.GetPosition() + Vector(0,-0.3,0);
506 stick.SetPosition(pos);
507 }
508
509 stick.SetOrientation(ori);
510 GetGame().ObjectDelete(this);
511 }
512 }
513 }
514
515
516 override void OnWorkStart()
517 {
518 m_WasLit = true;
519 LockRags(true);
521 }
522
524 {
525 if (m_FireParticle)
526 {
527 m_FireParticle.Stop();
528 }
529 }
530
531 Rag GetRag()
532 {
533 return Rag.Cast( GetAttachmentByType(Rag) );
534 }
535
536 void LockRags(bool do_lock)
537 {
538 ItemBase rag = GetRag();
539 if (rag)
540 {
541 if (do_lock)
542 {
543 rag.LockToParent();
544 }
545 else if (!m_RagsUpgradedCount)
546 {
547 rag.UnlockFromParent();
548 }
549 }
550 }
551
553 {
554 if (!m_Light)
555 {
556 m_Light = TorchLight.Cast( ScriptedLightBase.CreateLight( TorchLight, Vector(0,0,0), 1 ) );
557 m_Light.AttachOnObject(this, m_ParticleLocalPos + Vector (0,0.2,0));
558 }
559
560 if (m_FireParticle)
561 {
562 Object direct_particle = m_FireParticle.GetDirectParticleEffect();
563
564 if (direct_particle && direct_particle != m_Light.GetAttachmentParent())
565 {
566 m_Light.AttachOnObject(direct_particle, Vector(0,0.2,0));
567 }
568 }
569
570 float update_interval = GetCompEM().GetUpdateInterval();
571
572 if (GetQuantity() <= m_StartFadeOutOfLightAtQuantityEx)
573 {
574 float brightness_coef = GetQuantity() / m_StartFadeOutOfLightAtQuantityEx;
575 float radius_coef = GetQuantity() / m_StartFadeOutOfLightAtQuantityEx;
576
577 if (radius_coef < m_StartFadeOutOfLightAtQuantityEx/10)
578 radius_coef = m_StartFadeOutOfLightAtQuantityEx/10;
579
580 if (brightness_coef < m_StartFadeOutOfLightAtQuantityEx/10)
581 brightness_coef = m_StartFadeOutOfLightAtQuantityEx/10;
582
583 m_Light.FadeBrightnessTo(m_Light.m_TorchBrightness * brightness_coef, update_interval);
584 m_Light.FadeRadiusTo(m_Light.m_TorchRadius * radius_coef, update_interval);
585 }
586 else
587 {
588 m_Light.FadeBrightnessTo(m_Light.m_TorchBrightness, update_interval);
589 m_Light.FadeRadiusTo(m_Light.m_TorchRadius, update_interval);
590 }
591 }
592
594 {
595 GetCompEM().SwitchOff();
596 }
597
598
599 override void OnWork( float consumed_energy )
600 {
602 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
603 {
604 if (GetCompEM().GetEnergy() < ((GetRagQuantity() + m_RagsUpgradedCount) - 1) * m_BurnTimePerRagEx)
605 {
606 if (m_RagsUpgradedCount==0)//always burn rag
607 {
608 ConsumeRag();
609 }
610 else if (m_ConsumeRagFlipFlop)//burn rag
611 {
612 ConsumeRag();
613 m_ConsumeRagFlipFlop = !m_ConsumeRagFlipFlop;
614 }
615 else//burn lard/fuel
616 {
617 m_RagsUpgradedCount--;
618 m_ConsumeRagFlipFlop = !m_ConsumeRagFlipFlop;
619 }
620 }
621 if (GetRag() && GetCompEM().GetEnergy() == 0 && GetRagQuantity() > 0)
622 {
623 GetRag().SetQuantity(0);
624 }
625 RuinRags();
626
628
630
631 AddWet( -m_WaterEvaporationByFireIntensityEx * GetCompEM().GetUpdateInterval() );
632
633 Rag rag = GetRag();
634
635 if ( rag )
636 {
637 rag.AddWet( -m_WaterEvaporationByFireIntensityEx * GetCompEM().GetUpdateInterval() );
638 }
639 }
640
641 if ( !m_LoopSoundEntity && GetGame() && ( !GetGame().IsDedicatedServer() ) )
642 {
643 m_LoopSoundEntity = PlaySoundLoop(GetSoundName(), 50);
644 }
645
646 // Effect scaling by fuel
647 if ( !GetGame().IsDedicatedServer() )
648 {
649 UpdateLight();
651 }
652 }
653
654
656 {
657 return "torchLoop";
658 }
659
661 {
662 if ( GetQuantity() < 40 )
663 {
664 if (!m_FireParticle)
665 m_FireParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.TORCH_T1, this, m_ParticleLocalPos);
666
667 float scale = GetQuantity() / 40;
668
669 if (scale > 1)
670 scale = 1;
671
672 if (scale < 0.25)
673 scale = 0.25;
674
675 m_FireParticle.ScaleParticleParamFromOriginal(EmitorParam.SIZE, scale);
676 m_FireParticle.ScaleParticleParamFromOriginal(EmitorParam.VELOCITY, scale);
677 m_FireParticle.ScaleParticleParamFromOriginal(EmitorParam.VELOCITY_RND, scale);
678 }
679 else
680 {
681 if ( !m_FireParticle || m_FireParticle.GetParticleID() != ParticleList.TORCH_T2 )
682 {
683 // Executes once when fire particle starts or changes
684
685 if (m_FireParticle)
686 m_FireParticle.Stop();
687
688 m_FireParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.TORCH_T2, this, m_ParticleLocalPos);
689 }
690 }
691
692 }
693
694 override void OnWorkStop()
695 {
697 if (m_Light)
698 m_Light.FadeOut();
699
700 if ( m_LoopSoundEntity && GetGame() && ( !GetGame().IsDedicatedServer() ) )
701 {
702 GetGame().ObjectDelete( m_LoopSoundEntity );
703 m_LoopSoundEntity = NULL;
704 }
705
706 if ( m_FireParticle)
707 {
708 m_FireParticle.Stop();
709 m_FireParticle = NULL;
710 }
711
714
715 LockRags(false);
716
717 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
718 {
719 if (GetRag() && GetCompEM().GetEnergy() == 0 && GetRagQuantity() > 0)
720 {
721 GetRag().SetQuantity(0);
722 }
723 }
724
726 }
727
728 // COMBAT
729 // This needs refactor!
730 override int GetMeleeMode()
731 {
732 if ( GetCompEM().IsWorking() )
733 return 3; // ???
734 else
735 return 0; // ???
736 }
737
738 override int GetMeleeHeavyMode()
739 {
740 if ( GetCompEM().IsWorking() )
741 return 4; // ???
742 else
743 return 1; // ???
744 }
745
746 override int GetMeleeSprintMode()
747 {
748 if ( GetCompEM().IsWorking() )
749 return 5; // ???
750 else
751 return 2; // ???
752 }
753
754 override void SetActions()
755 {
756 super.SetActions();
757
759 }
760
761 override void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
762 {
763 super.OnAttachmentQuantityChangedEx(item, delta);
764 if (delta != 0)
765 {
766 if (delta > 0 || !GetCompEM().IsWorking()) // dont adjust energy when rag burns out
767 GetCompEM().AddEnergy(m_BurnTimePerRagEx * delta);
768
771 }
772 }
773
774
776 {
777 return true;
778 }
779
780 override void OnDebugSpawn()
781 {
782 GetInventory().CreateAttachment("Rag");
785 }
786
788 {
789 if (GetRag())
790 {
791 return Math.Round(GetRag().GetQuantity());
792 }
793 return 0;
794 }
795
797 {
798 return "";
799 }
800
802 {
803 return "";
804 }
805
807 {
808 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
809 {
810 if (GetCompEM().IsWorking())
811 {
812 if (GetBurningMaterial())
813 {
814 SetObjectMaterial(0, GetBurningMaterial());
815 }
816 }
817 else if (m_WasLit)
818 {
819 if (GetBurntMaterial())
820 {
821 SetObjectMaterial(0, GetBurntMaterial());
822 }
823 }
824 }
825 }
826
827
829 {
830 super.OnStoreSave(ctx);
831 ctx.Write(m_WasLit);
832 }
833
834
835 override bool OnStoreLoad( ParamsReadContext ctx, int version )
836 {
837 if (!super.OnStoreLoad(ctx, version))
838 {
839 return false;
840 }
841 if (version >= 130)
842 {
843 if (!ctx.Read( m_WasLit ))
844 {
845 return false;
846 }
847 }
849 return true;
850 }
851
853 {
854 result.SetQuantity(1);
855 }
856
857 //-------------
858 // DEBUG BELLOW
859 //-------------
860 #ifdef DEVELOPER
861 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
862 {
863 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Ignite", FadeColors.LIGHT_GREY));
864 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
865
866 super.GetDebugActions(outputList);
867 }
868
869 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
870 {
871 if (super.OnAction(action_id, player, ctx))
872 return true;
873 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
874 {
875 if (action_id == EActions.ACTIVATE_ENTITY)
876 {
877 OnIgnitedThis(null);
878 }
879
880 }
881 return false;
882 }
883
884 override string GetDebugText()
885 {
886 string debug_output;
887
888 debug_output = super.GetDebugText();
889
890 if( GetGame().IsDedicatedServer())
891 {
892 debug_output+="m_RagsUpgradedCount:"+m_RagsUpgradedCount+"\n";
893 debug_output+="m_ConsumeRagFlipFlop:"+m_ConsumeRagFlipFlop+"\n";
894 if (IsIgnited() && m_ConsumeRagFlipFlop)
895 {
896 debug_output+="Burning rag \n";
897 }
898 else if (IsIgnited())
899 {
900 debug_output+="Burning lard/fuel \n";
901 }
902 }
903 else
904 {
905
906 }
907 return debug_output;
908 }
909 #endif
910}
911
912
913class Torch : FlammableBase
914{
915 //legacy vars which cannot be moved/removed
916 static float m_BurnTimePerRag;
917 static float m_BurnTimePerFullLard;
918 static float m_BurnTimePerFullFuelDose;
919 static float m_MaxConsumableLardQuantity;
920 static float m_MaxConsumableFuelQuantity;
921 static float m_WaterEvaporationByFireIntensity = 0.001;
922 static int m_StartFadeOutOfLightAtQuantity = 3;
923
924
925 override void Init()
926 {
927 super.Init();
928
929 //for legacy reasons
930 m_BurnTimePerRag = m_BurnTimePerRagEx;
931 m_BurnTimePerFullLard = m_BurnTimePerFullLardEx;
932 m_BurnTimePerFullFuelDose = m_BurnTimePerFullFuelDoseEx;
933 m_MaxConsumableLardQuantity = m_MaxConsumableLardQuantityEx;
934 m_MaxConsumableFuelQuantity = m_MaxConsumableFuelQuantityEx;
935 }
936
937 override void SetActions()
938 {
939 super.SetActions();
940
943 }
944
945 // !Called on CHILD when it's attached to parent.
946 override void OnWasAttached( EntityAI parent, int slot_id )
947 {
948 super.OnWasAttached(parent, slot_id);
949 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
950 LockRags(true);
951 }
952
953 // !Called on CHILD when it's detached from parent.
954 override void OnWasDetached( EntityAI parent, int slot_id )
955 {
956 super.OnWasDetached(parent, slot_id);
957 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
958 LockRags(false);
959 }
960
961
963 {
964 super.OnStoreSave(ctx);
965 ctx.Write(m_ConsumeRagFlipFlop);
966 ctx.Write(m_RagsUpgradedCount);
967 }
968
969
970 override bool OnStoreLoad( ParamsReadContext ctx, int version )
971 {
972 if (!super.OnStoreLoad(ctx, version))
973 {
974 return false;
975 }
976
977 if (version >= 129)
978 {
979 if (!ctx.Read( m_ConsumeRagFlipFlop ))
980 {
981 return false;
982 }
983
984 if (!ctx.Read( m_RagsUpgradedCount ))
985 {
986 return false;
987 }
988 }
989 UpdateCheckForReceivingUpgrade();
990 return true;
991 }
992};
993
995{
996 override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
997 {
998 super.CopyOldPropertiesToNew(old_item, new_item);
999
1000 ItemBase stick;
1001 FlammableBase flammable = FlammableBase.Cast(old_item);
1002 Class.CastTo(stick, new_item);
1003 if (stick && flammable)
1004 {
1005 flammable.ApplyResultModifications(stick);
1006 }
1007 }
1008};
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition entityai.c:97
eBleedingSourceType GetType()
ActionLightItemOnFireCB ActionContinuousBaseCB ActionLightItemOnFire()
void AddAction(typename actionName)
void SetActions()
vector GetOrientation()
const int ECE_PLACE_ON_SURFACE
bool IsSurfaceDigable(string surface)
Checks if the surface is digable.
Definition game.c:1211
proto float SurfaceGetType(float x, float z, out string type)
Returns: Y position the surface was found.
Super root of all classes in Enforce script.
Definition enscript.c:11
void ConsumeFuelFromGasStation()
Definition torch.c:358
override void OnDebugSpawn()
Definition torch.c:780
override bool CanPutInCargo(EntityAI parent)
Definition torch.c:105
void UpdateLight()
Definition torch.c:552
void RuinRags()
Definition torch.c:376
void ApplyResultModifications(ItemBase result)
Definition torch.c:852
bool IsRagDryEnough(ItemBase rag)
Definition torch.c:181
override void OnInventoryExit(Man player)
Definition torch.c:387
Rag GetRag()
Definition torch.c:531
override int GetMeleeMode()
Definition torch.c:730
bool CanBeTakenAsCargo()
Definition torch.c:128
void UpdateCheckForReceivingUpgrade()
Definition torch.c:188
void ConsumeLard(Lard lard)
Definition torch.c:253
override bool IsIgnited()
Definition torch.c:134
override bool CanReleaseAttachment(EntityAI attachment)
Definition torch.c:111
bool CanTransformIntoStick()
Definition torch.c:464
ref UniversalTemperatureSource m_UTSource
Definition torch.c:29
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition torch.c:835
override void OnIgnitedThis(EntityAI fire_source)
Definition torch.c:197
override void EEInit()
Definition torch.c:55
override void SetActions()
Definition torch.c:754
void CraftingInit(float quantity)
Definition torch.c:428
override void OnWork(float consumed_energy)
Definition torch.c:599
override void OnStoreSave(ParamsWriteContext ctx)
Definition torch.c:828
int GetRagQuantity()
Definition torch.c:787
override void OnWorkStop()
Definition torch.c:694
void TryTransformIntoStick()
Definition torch.c:472
override void DeferredInit()
Definition torch.c:33
override void EEDelete(EntityAI parent)
Definition torch.c:85
void Upgrade(ItemBase source)
Definition torch.c:287
override void EEItemDetached(EntityAI item, string slot_name)
Definition torch.c:444
void LockRags(bool do_lock)
Definition torch.c:536
override bool CanRemoveFromCargo(EntityAI parent)
Definition torch.c:118
override void OnSwitchOff()
Definition torch.c:220
string GetBurningMaterial()
Definition torch.c:796
bool StandUp()
Definition torch.c:395
override bool CanBeIgnitedBy(EntityAI igniter=NULL)
Definition torch.c:150
ref UniversalTemperatureSourceLambdaConstant m_UTSLConstant
Definition torch.c:31
void SetTorchDecraftResult(string type)
Definition torch.c:228
override void OnSwitchOn()
Definition torch.c:207
override void OnWorkStart()
Definition torch.c:516
void UpdateMaterial()
Definition torch.c:806
void CalculateQuantity()
Definition torch.c:415
void StopAllParticles()
Definition torch.c:523
override void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Definition torch.c:761
ref UniversalTemperatureSourceSettings m_UTSSettings
Definition torch.c:30
override bool DisassembleOnLastDetach()
Definition torch.c:775
override vector GetUniversalTemperatureSourcePosition()
Definition torch.c:75
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition torch.c:96
bool CanReceiveUpgrade()
Definition torch.c:423
override int GetMeleeSprintMode()
Definition torch.c:746
override bool CanIgniteItem(EntityAI ignite_target=NULL)
Definition torch.c:139
override int GetMeleeHeavyMode()
Definition torch.c:738
void UpdateParticle()
Definition torch.c:660
override bool CanPutAsAttachment(EntityAI parent)
Definition torch.c:123
override void EEItemAttached(EntityAI item, string slot_name)
Definition torch.c:436
void ConsumeFuelFromBottle(ItemBase vessel)
Definition torch.c:324
bool ConsumeRag()
Definition torch.c:233
override bool HasFlammableMaterial()
Definition torch.c:144
void Init()
Definition torch.c:41
override void OnItemInHandsPlayerSwimStart(PlayerBase player)
Definition torch.c:593
string GetBurntMaterial()
Definition torch.c:801
string GetSoundName()
Definition torch.c:655
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition enmath.c:7
Legacy way of using particles in the game.
Definition particle.c:7
static Particle PlayOnObject(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_world_rotation=false)
Creates a particle emitter, attaches it on the given object and activates it.
Definition particle.c:152
int GetParticleID()
Gets particle id.
Definition particle.c:297
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition particle.c:266
Object GetDirectParticleEffect()
Returns direct particle effect entity which is usually handled by this class 'Particle' if there is o...
Definition particle.c:307
base class for transformation operations (creating one item from another)
void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Step E. copy properties from old object to the created one.
Serialization general interface. Serializer API works with:
Definition serializer.c:56
original Timer deletes m_params which is unwanted
override Widget Init()
Definition dayzgame.c:127
EActions
Definition eactions.c:2
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
EmitorParam
Definition envisual.c:114
const int SAT_DEBUG_ACTION
Definition constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
override float GetQuantity()
Definition itembase.c:8296
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Definition itembase.c:8220
float GetEnergy()
Definition itembase.c:8420
override void AddWet(float value)
Definition itembase.c:8506
class Land_Buoy extends House m_Light
string GetDebugText()
void OnStoreSave(ParamsWriteContext ctx)
bool OnStoreLoad(ParamsReadContext ctx, int version)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
override void OnWasDetached(EntityAI parent, int slot_id)
FlammableBase m_BurnTimePerRag