Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
trapspawnbase.c
Go to the documentation of this file.
1class TrapSpawnBase extends ItemBase
2{
3 bool m_IsFoldable;
4 bool m_CanCatch = false;
5
6 //configurable stuff
7 bool m_NeedInstalation;
8 int m_InitWaitTimeMin;
9 int m_InitWaitTimeMax;
10 int m_UpdateWaitTime;
11 int m_SpawnUpdateWaitTime;
12 int m_MaxActiveTime;
13 float m_BaitLossFraction;
14 float m_DefectRate;
15 float m_MinimalDistanceFromPlayersToCatch;
16
17 //derived stuff
18 private int m_InitWaitTime;
19 private int m_AdjustedMaxActiveTime;
20 private int m_ElapsedTime;
21 private int m_ActivationTime;
22 private int m_RollSuccessTime;
23 private float m_CurrentMinimalDistance;
24 private float m_CurrentlyUsedDelta;
25 private bool m_IsCatchSuccessful;
26 private int m_CatchEnviroMask = 0;
27 private int m_YieldItemIdxLocal = -1;
28 private int m_YieldItemIdx = -1;
29 private int m_CatchParticleEffecterId = -1;
30
31 vector m_PreyPos; // The position where prey will be spawned -> Will be overriden later
32
33 protected bool m_IsActive;
34 protected bool m_IsPastWaitingTime;
35 protected bool m_IsDeployed;
36
37 ref Timer m_Timer;
38
42
44
46
47 #ifdef DEVELOPER
48 int m_dbgAttemptCount = 0;
49 #endif
50
52 {
53 InitTrapValues();
54
55 RegisterNetSyncVariableBool("m_IsActive");
56 RegisterNetSyncVariableBool("m_IsDeployed");
57 RegisterNetSyncVariableInt("m_YieldItemIdx");
58
59 //DEPRECATED stuff below, legacy reasons only
60 m_CatchesPond = new multiMap<string, float>; //yields now in WorldData.InitYieldBank
61 m_CatchesSea = new multiMap<string, float>; //yields now in WorldData.InitYieldBank
62 m_CatchesGroundAnimal = new multiMap<string, float>; //yields now in WorldData.InitYieldBank
63 }
64
66 {
67 if (m_Timer)
68 {
69 m_Timer.Stop();
70 delete m_Timer;
71 }
72
73 ClearCatchingComponent();
74 }
75
77 {
78 m_DefectRate = 10; //Added damage after trap activation
79 m_BaitLossFraction = 0.2;
80 m_UpdateWaitTime = 60;
81 m_SpawnUpdateWaitTime = 30;
82 m_InitWaitTimeMin = 10;
83 m_InitWaitTimeMax = 10;
84 m_MaxActiveTime = 1200;
85 m_NeedInstalation = true;
86 m_IsFoldable = false;
87 m_IsCatchSuccessful = false;
88 m_MinimalDistanceFromPlayersToCatch = 0;
89
92 m_AnimationPhaseUsed = "";
93
94 m_PlaceableWaterSurfaceList = new array<string>();
95 m_PlaceableWaterSurfaceList.Insert(UAWaterType.SEA);
96 m_PlaceableWaterSurfaceList.Insert(UAWaterType.FRESH);
97 }
98
99 override void OnStoreSave( ParamsWriteContext ctx )
100 {
101 super.OnStoreSave( ctx );
102
103 ctx.Write( m_IsActive );
104
105 ctx.Write( m_IsDeployed );
106
107 ctx.Write(m_CatchEnviroMask);
108 }
109
110 override bool OnStoreLoad( ParamsReadContext ctx, int version )
111 {
112 if ( !super.OnStoreLoad(ctx, version) )
113 return false;
114
115 m_IsStoreLoad = true;
116
117 bool b_is_active = false;
118 if ( !ctx.Read( b_is_active ) )
119 b_is_active = false;
120
121 bool b_is_in_progress = false;
122 if (version < 139)
123 {
124 if ( !ctx.Read( b_is_in_progress ) )
125 b_is_in_progress = false;
126 }
127
128 bool b_is_deployed = false;
129 if ( !ctx.Read( b_is_deployed ) )
130 b_is_deployed = false;
131
132 if (version >= 139)
133 {
134 int enviroMask;
135 if (ctx.Read(enviroMask))
136 m_CatchEnviroMask = enviroMask;
137 }
138
139 if (b_is_active)
140 {
141 InitCatchingComponent();
142 SetActive();
143 }
144
145 SetDeployed( b_is_deployed );
146
147 m_IsStoreLoad = false;
148 return true;
149 }
150
153 {
154 super.OnVariablesSynchronized();
155
156 if (m_YieldItemIdx != m_YieldItemIdxLocal)
157 {
158 m_YieldItemIdxLocal = m_YieldItemIdx;
159 if (m_YieldItemIdxLocal != -1)
160 OnCatchSpawnClient();
161 }
162 }
163
164 bool IsActive()
165 {
166 return m_IsActive;
167 }
168
170 {
171 return m_IsDeployed;
172 }
173
174 void SetDeployed( bool newState )
175 {
176 m_IsDeployed = newState;
177
178 if ( newState == true )
179 {
181 {
182 SetAnimationPhase( m_AnimationPhaseSet, 1 );
183 SetAnimationPhase( m_AnimationPhaseTriggered, 0 );
184 SetAnimationPhase( m_AnimationPhaseUsed, 1 );
185 }
186 }
187 else
188 {
190 {
191 SetAnimationPhase( m_AnimationPhaseSet, 0 );
192 SetAnimationPhase( m_AnimationPhaseTriggered, 1 );
193 SetAnimationPhase( m_AnimationPhaseUsed, 1 );
194 }
195 }
196
197 SetSynchDirty();
198 }
199
200 override bool IsTakeable()
201 {
202 return true;
203 }
204
206 {
207 string surface_type;
208 GetGame().SurfaceGetType3D( position[0], position[1], position[2], surface_type);
209
210 // check surface
211 return GetGame().IsSurfaceDigable(surface_type);
212 }
213
215 {
216 if ( GetGame().IsServer() )
217 {
218 if ( GetHierarchyRootPlayer() && GetHierarchyRootPlayer().CanDropEntity( this ) )
219 {
220 SetupTrapPlayer( PlayerBase.Cast( GetHierarchyRootPlayer() ) );
221 }
222 }
223 }
224
225 void SetupTrapPlayer( PlayerBase player, bool set_position = true )
226 {
227 if ( GetGame().IsServer() )
228 {
229 if ( set_position )
230 {
231 vector trapPos = player.GetPosition() + ( player.GetDirection() * 0.5 );
232 trapPos[1] = GetGame().SurfaceRoadY( trapPos[0], trapPos[2] );
233 SetPosition( trapPos );
234 }
235
236 SetDeployed( true );
237 }
238 }
239
241 {
242 m_PreyPos = GetPosition();
243 if (MemoryPointExists("Prey_Position"))
244 m_PreyPos = ModelToWorld(GetMemoryPointPos("Prey_Position"));
245 }
246
247 void Fold()
248 {
249 if ( GetGame().IsServer() && m_IsFoldable == true )
250 {
251 SetInactive();
252 }
253 }
254
255 // Deal damage to trap on specific events
257 {
258 if ( GetGame().IsServer() )
259 {
260 DecreaseHealth( "", "", m_DefectRate );
261 }
262 }
263
264 void StartActivate( PlayerBase player ) { }
265
266 // IsTakeable is used to hide tooltips as well, so we use a custom method instead
267 // Used to prevent players from taking traps which should be set for catching
269 {
270 if ( !IsDeployed() || ( GetInventory().AttachmentCount() == 0 && IsDeployed() ) )
271 {
272 return true;
273 }
274
275 return false;
276 }
277
278 override bool CanPutInCargo( EntityAI parent )
279 {
280 super.CanPutInCargo( parent );
281 return CanBeTaken();
282 }
283
284 override bool CanPutIntoHands( EntityAI parent )
285 {
286 super.CanPutIntoHands( parent );
287 return CanBeTaken();
288 }
289
291 {
292 m_ActivationTime = GetGame().GetTickTime();
293 m_ElapsedTime = 0;
294 m_CurrentMinimalDistance = m_MinimalDistanceFromPlayersToCatch;
295
296 #ifdef DEVELOPER
297 m_dbgAttemptCount = 0;
298 #endif
299 }
300
302 {
303 if (m_IsPastWaitingTime)
304 {
305 m_AdjustedMaxActiveTime = m_MaxActiveTime;
306 RunTrappingTimer(m_UpdateWaitTime,"EvaluateCatch");
307 }
308 else
309 {
310 m_AdjustedMaxActiveTime = m_MaxActiveTime + m_InitWaitTime;
311 RunTrappingTimer(m_InitWaitTime + m_UpdateWaitTime,"EvaluateCatch");
312 }
313 }
314
316 void RunTrappingTimer(float duration, string fnName)
317 {
318 if (!m_Timer)
320 else
321 m_Timer.Stop();
322
323 #ifdef DEVELOPER
324 if (IsCLIParam("trapsQuick"))
325 {
326 m_CurrentlyUsedDelta = 1;
327 m_Timer.Run(1, this, fnName);
328 }
329 else
330 #endif
331 {
332 m_CurrentlyUsedDelta = duration;
333 m_Timer.Run(duration, this, fnName);
334 }
335 }
336
337 // Set animation phases according to state
339 {
340 UpdatePreyPos();
341
342 if ( GetGame().IsServer() && !IsActive() )
343 {
344 SetCatchSuccessful(false);
345 m_IsActive = true;
346 m_IsPastWaitingTime = false;
347 m_YieldItemIdx = -1;
348
349 if (m_CatchParticleEffecterId >= 0)
350 SEffectManager.DestroyEffecterParticleServer(m_CatchParticleEffecterId);
351 m_CatchParticleEffecterId = -1;
352
353 SetSynchDirty();
354
356 {
357 SetAnimationPhase( m_AnimationPhaseSet, 1 );
358 SetAnimationPhase( m_AnimationPhaseTriggered, 0 );
359 SetAnimationPhase( m_AnimationPhaseUsed, 1 );
360 }
361
362 ResetActiveProgress();
363 m_InitWaitTime = Math.RandomFloatInclusive(m_InitWaitTimeMin,m_InitWaitTimeMax);
364 if (!m_IsStoreLoad) //presumably activated by the player, store load initializes component separately
365 {
366 InitCatchingComponent();
368
369 RunTrappingTimer(m_InitWaitTime + m_UpdateWaitTime,"EvaluateCatch");
370 m_AdjustedMaxActiveTime = m_MaxActiveTime + m_InitWaitTime;
371 }
372 else //presumed store load
373 {
374 SetTrapEnviroMask(m_CatchEnviroMask);
375
376 RunTrappingTimer(m_UpdateWaitTime,"EvaluateCatch");
377 m_AdjustedMaxActiveTime = m_MaxActiveTime;
378 }
379 }
380 }
381
383 {
384 if ( GetGame().IsServer() )
385 {
386 // We stop timers as the trap is no longer active, then update visuals
387 m_IsActive = false;
388
389 ClearCatchingComponent();
390
391 if ( m_Timer )
392 {
393 m_Timer.Stop();
394 }
395
396 m_IsPastWaitingTime = false;
397
398 SetDeployed( false );
399
400 SetSynchDirty();
401 }
402 }
403
404 void SetUsed()
405 {
406 if ( GetGame().IsServer() )
407 {
408 // We updated state, visuals and stop timers
409 m_IsActive = false;
410 m_IsDeployed = false;
411
412 // Deal damage to trap
413 AddDefect();
414 HandleBaitLoss();
415 DetachAllAttachments();
416
417 ClearCatchingComponent();
418
419 if ( m_Timer )
420 {
421 m_Timer.Stop();
422 }
423
424 m_IsPastWaitingTime = false;
425
427 {
428 SetAnimationPhase( m_AnimationPhaseSet, 1 );
429 SetAnimationPhase( m_AnimationPhaseTriggered, 1 );
430 SetAnimationPhase( m_AnimationPhaseUsed, 0 );
431 }
432
433 m_CatchingContext = null;
434
435 SetSynchDirty();
436 }
437 }
438
440 {
441 m_ElapsedTime += m_CurrentlyUsedDelta;
442
443 #ifdef DEVELOPER
444 if (IsCLIParam("catchingLogs"))
445 {
446 Print("dbgTrapz | delta: " + m_CurrentlyUsedDelta);
447 Print("dbgTrapz | m_ElapsedTime: " + m_ElapsedTime);
448 Print("dbgTrapz | m_AdjustedMaxActiveTime: " + m_AdjustedMaxActiveTime);
449 }
450 #endif
451 }
452
454 {
455 if (m_CurrentMinimalDistance > 0)
456 {
457 float time = m_ElapsedTime - m_RollSuccessTime;
458 float timeLimit = m_AdjustedMaxActiveTime - m_RollSuccessTime;
459 time = Math.InverseLerp(0,timeLimit,time);
460 time = Easing.EaseInQuad(time);
461 m_CurrentMinimalDistance = Math.Lerp(m_MinimalDistanceFromPlayersToCatch,0,time);
462 m_CurrentMinimalDistance = Math.Clamp(m_CurrentMinimalDistance,0,m_MinimalDistanceFromPlayersToCatch);
463
464 #ifdef DEVELOPER
465 if (IsCLIParam("catchingLogs"))
466 {
467 Print("dbgTrapz | adjusted distance: " + m_CurrentMinimalDistance + "/" + m_MinimalDistanceFromPlayersToCatch + " | LERP progress: " + time);
468 }
469 #endif
470 }
471 }
472
474 {
475 #ifdef DEVELOPER
476 m_dbgAttemptCount++;
477 #endif
478
479 m_IsPastWaitingTime = true;
480 IncreaseElapsedTime();
481
482 #ifdef DEVELOPER
483 if (IsCLIParam("catchingLogs"))
484 {
485 Print("dbgTrapz | m_dbgAttemptCount: " + m_dbgAttemptCount + "/" + (m_MaxActiveTime/m_UpdateWaitTime));
486 }
487 #endif
488
489 bool success = false;
490 m_CanCatch = SetCanCatch(m_Bait);
491
492 if (m_CanCatch)
493 {
494 if (m_CatchingContext.RollCatch())
495 {
496 success = true;
497
498 #ifdef DEVELOPER
499 if (IsCLIParam("catchingLogs"))
500 {
501 Print("dbgTrapz | success!!!");
502 Print("---------------------");
503 }
504 #endif
505 }
506 }
507
508 #ifdef DEVELOPER
509 string dbgSuccessOverride;
510 if (GetCLIParam("trapsSuccessOverride",dbgSuccessOverride))
511 {
512 if (dbgSuccessOverride == "true" || dbgSuccessOverride.ToInt() == 1)
513 success = true;
514 else if (dbgSuccessOverride == "false" || dbgSuccessOverride.ToInt() == 0)
515 success = false;
516 }
517 #endif
518
519 m_Timer.Stop();
520
521 #ifdef DEVELOPER
522 if (m_ElapsedTime >= m_AdjustedMaxActiveTime || (IsCLIParam("trapsQuick") && !success))
523 #else
524 if (m_ElapsedTime >= m_AdjustedMaxActiveTime)
525 #endif
526 {
527 SetUsed();
528 return;
529 }
530
531 if (success)
532 {
533 m_RollSuccessTime = m_ElapsedTime;
534 m_CurrentlyUsedDelta = 0;
535 TrySpawnCatch();
536 }
537 else
538 {
539 RunTrappingTimer(m_UpdateWaitTime,"EvaluateCatch");
540 }
541 }
542
544 {
545 if (!GetCEApi())
546 {
547 Debug.Log("CE not enabled, player avoidance not available!");
548 return false;
549 }
550
551 return !GetCEApi().AvoidPlayer(GetPosition(), m_CurrentMinimalDistance);
552 }
553
555 {
556 IncreaseElapsedTime();
557 AdjustDetectionRange();
558
559 #ifdef DEVELOPER
560 if (IsCLIParam("trapsQuick") || m_CurrentMinimalDistance <= 0 || !IsPlayerInVicinity())
561 #else
562 if (m_CurrentMinimalDistance <= 0 || !IsPlayerInVicinity())
563 #endif
564 {
565 SpawnCatch();
566 }
567 else if (m_ElapsedTime < m_AdjustedMaxActiveTime)
568 {
569 RunTrappingTimer(m_SpawnUpdateWaitTime,"TrySpawnCatch");
570 }
571 }
572
573 // Actually spawns the prey
575 {
576 // Only server side, let's make sure
577 if (GetGame().IsMultiplayer() && GetGame().IsClient())
578 return;
579
580 UpdatePreyPos();
581
582 ItemBase catch;
583 if (m_CanCatch)
584 {
585 catch = ItemBase.Cast(m_CatchingContext.SpawnAndSetupCatch(m_YieldItemIdx,m_PreyPos));
586
587 OnCatchSpawnServer();
588 SetCatchSuccessful(catch != null);
589 // We change the trap state and visuals
590 SetUsed();
591 }
592
593 SetSynchDirty();
594 }
595
596 void SetCatchSuccessful(bool successful)
597 {
598 m_IsCatchSuccessful = successful;
599 }
600
602 {
603 PlayCatchEffectsServer();
604 }
605
607 {
608 UpdatePreyPos(); //previously set on server only
609
610 PlayCatchEffectsClient();
611 }
612
613 protected void PlayCatchEffectsServer()
614 {
615 if (m_YieldItemIdx == -1)
616 return;
617
618 YieldItemBase yItem = GetGame().GetMission().GetWorldData().GetCatchYieldBank().GetYieldItemByIdx(m_YieldItemIdx);
619
620 PlayCatchNoise(yItem);
621 PlayCatchParticleSynced(yItem);
622 }
623
624 protected void PlayCatchEffectsClient()
625 {
626 if (m_YieldItemIdx == -1)
627 return;
628
629 YieldItemBase yItem = GetGame().GetMission().GetWorldData().GetCatchYieldBank().GetYieldItemByIdx(m_YieldItemIdx);
630 PlayCatchSound(yItem);
631 }
632
633 protected void PlayCatchSound(YieldItemBase yItem)
634 {
635 if (yItem.GetCatchDeathSoundset() != "")
637 }
638
639 protected void PlayCatchNoise(YieldItemBase yItem)
640 {
641 string noiseType = yItem.GetCatchAINoise();
642 if (noiseType == "")
643 return;
644
646 m_NoisePar.Load(noiseType);
647 float noiseMultiplier = yItem.GetCatchAINoiseBaseStrength();
648 noiseMultiplier *= NoiseAIEvaluate.GetNoiseReduction(GetGame().GetWeather());
649 GetGame().GetNoiseSystem().AddNoiseTarget(m_PreyPos, 5, m_NoisePar, noiseMultiplier);
650 }
651
653 {
654 int particleId = yItem.GetCatchParticleID();
655 if (particleId == ParticleList.INVALID)
656 return;
657
658 if (m_CatchParticleEffecterId < 0)
659 {
660 m_CatchParticleEffecterId = SEffectManager.CreateParticleServer(m_PreyPos, new ParticleEffecterParameters("ParticleEffecter", 5, particleId));
661 }
662 else
663 {
664 SEffectManager.ReinitParticleServer(m_CatchParticleEffecterId, new ParticleEffecterParameters("ParticleEffecter", 5, particleId)); //reinit here, since particleId might differ
665 SEffectManager.ReactivateParticleServer(m_CatchParticleEffecterId);
666 }
667 }
668
669 //Pre-roll validation, bait compatibility handled between YieldItems and bait type
670 bool SetCanCatch( out EntityAI bait )
671 {
672 return m_CatchingContext.IsValid();
673 }
674
675 override void OnItemLocationChanged( EntityAI old_owner, EntityAI new_owner )
676 {
677 super.OnItemLocationChanged( old_owner, new_owner );
678
679 if ( GetGame().IsServer() )
680 {
681 // throw trap from vicinity if the trap does not need installation ( action required )
682 if ( new_owner == NULL && m_NeedInstalation == false )
683 {
684 SetActive();
685 }
686 else if ( old_owner == NULL && new_owner != NULL )
687 {
688 if ( m_IsFoldable )
689 {
690 Fold();
691 }
692 else
693 {
694 SetInactive();
695 }
696 }
697
698 if (m_YieldItemIdx != -1) //resets sound effect idx
699 {
700 m_YieldItemIdx = -1;
701 SetSynchDirty();
702 }
703 }
704 }
705
706 // Generic water check, no real distinction between pond or sea
707 bool IsSurfaceWater(vector position)
708 {
709 string surfaceType;
710 GetGame().SurfaceGetType3D(position[0], position[1], position[2], surfaceType);
711
712 return Surface.AllowedWaterSurface(position[1] + 0.1, surfaceType, m_PlaceableWaterSurfaceList);
713 }
714
715 // Can only receive attachment if deployed
716 override bool CanDisplayAttachmentSlot( int slot_id )
717 {
718 super.CanDisplayAttachmentSlot( slot_id );
719 return IsDeployed();
720 }
721
722 override bool CanReceiveAttachment( EntityAI attachment, int slotId )
723 {
724 super.CanReceiveAttachment( attachment, slotId );
725 return IsDeployed();
726 }
727
728 override void EEItemAttached( EntityAI item, string slot_name )
729 {
730 super.EEItemAttached( item, slot_name );
731
732 if (IsActive() && GetGame().IsServer())
733 {
734 ResetActiveProgress();
735 m_CatchingContext.UpdateDataAndMasks();
736 m_CatchingContext.GenerateResult();
737 ResetRunningTimerProgress();
738 }
739 }
740
741 override void EEItemDetached(EntityAI item, string slot_name)
742 {
743 super.EEItemDetached( item, slot_name );
744
745 if (IsActive() && GetGame().IsServer())
746 {
747 ResetActiveProgress();
748 m_CatchingContext.UpdateDataAndMasks();
749 m_CatchingContext.GenerateResult();
750 ResetRunningTimerProgress();
751 }
752 }
753
755
757 {
758 if (m_CatchingContext)
759 delete m_CatchingContext;
760 }
761
763 {
764 m_CatchEnviroMask = m_CatchingContext.UpdateTrapEnviroMask();
765 }
766
767 void SetTrapEnviroMask(int value)
768 {
769 m_CatchingContext.SetTrapEnviroMask(value);
770 }
771
773 {
774 if (m_CatchingContext)
775 {
776 if (m_IsCatchSuccessful)
777 m_CatchingContext.RemoveBait();
778 else
779 m_CatchingContext.ReduceBaitQty(m_BaitLossFraction);
780 }
781 }
782
785 {
786 int count = GetInventory().AttachmentCount();
787 if (count > 0)
788 {
789 EntityAI att;
790 for (int i = 0; i < count; i++)
791 {
792 att = GetInventory().GetAttachmentFromIndex(i);
793 GetInventory().DropEntity(InventoryMode.SERVER,this,att);
794 }
795 }
796 }
797
798 //================================================================
799 // ADVANCED PLACEMENT
800 //================================================================
801
802 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
803 {
804 super.OnPlacementComplete(player, position, orientation);
805
806 if (GetGame().IsServer())
807 {
808 vector rotation_matrix[3];
809 float direction[4];
810 Math3D.YawPitchRollMatrix(orientation, rotation_matrix);
811 Math3D.MatrixToQuat(rotation_matrix, direction);
813 InventoryLocation destination = new InventoryLocation;
814
815 if (GetInventory().GetCurrentInventoryLocation(source))
816 {
817 destination.SetGroundEx(this, position, direction);
818 if (GetGame().IsMultiplayer())
819 {
820 player.ServerTakeToDst(source, destination);
821 SetupTrapPlayer(PlayerBase.Cast(player), false);
822 }
823 else // singleplayer
824 {
825 PlayerBase.Cast(player).GetDayZPlayerInventory().RedirectToHandEvent(InventoryMode.LOCAL, source, destination);
826 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SetupTrapPlayer, 100, false, PlayerBase.Cast(player), false);
827 }
828 }
829
830 InitCatchingComponent();
832 SetActive();
833 }
834 }
835
836
838 {
839 if ( GetGame().IsServer() )
840 {
842 GetInventory().GetCurrentInventoryLocation(loc);
843 if (loc.GetType() == InventoryLocationType.HANDS)
844 {
845 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
846
847 vector player_pos = player.GetPosition();
848 vector aim_pos = player.GetAimPosition();
849
850 if ( vector.DistanceSq(player_pos, aim_pos) <= ( 1.5 * 1.5 ) )
851 {
852 return IsPlaceableAtPosition( aim_pos );
853 }
854 }
855 }
856
857 return false;
858 }
859
860 override bool CanBePlaced( Man player, vector position )
861 {
862 return IsPlaceableAtPosition(position);
863 }
864
865 // We add the action to deploy a trap laid on ground
866 override void SetActions()
867 {
868 super.SetActions();
869
872 }
873
874 // ===============================================================
875 // ===================== DEPRECATED ============================
876 // ===============================================================
877
878 const string m_PlaceableWaterType
879
883 private ItemBase m_Catch;
884 ref Timer m_AlignCatchTimer;
885 string m_InfoSetup;
886 protected bool m_IsInProgress;
887 protected ref EffectSound m_DeployLoopSound;
888 protected EntityAI m_Bait;
892
894 ref multiMap<string, float> m_CatchesPond;
895 ref multiMap<string, float> m_CatchesSea;
896 ref multiMap<string, float> m_CatchesGroundAnimal;
897
901 void AlignCatch(ItemBase obj, string catch_name);
906 // ===============================================================
907}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition inventory.c:22
ActionActivateTrapCB ActionContinuousBaseCB ActionActivateTrap()
ItemBase m_Bait
ref NoiseParams m_NoisePar
void AddAction(typename actionName)
void SetTrapEnviroMask(int value)
int UpdateTrapEnviroMask()
proto native float SurfaceRoadY(float x, float z, RoadSurfaceDetection rsd=RoadSurfaceDetection.LEGACY)
proto float SurfaceGetType3D(float x, float y, float z, out string type)
Y input: Maximum Y to trace down from; Returns: Y position the surface was found.
bool IsSurfaceDigable(string surface)
Checks if the surface is digable.
Definition game.c:1211
YieldItemBase GetYieldItemByIdx(int idx)
Definition debug.c:2
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Definition easing.c:3
Wrapper class for managing sound through SEffectManager.
Definition effectsound.c:5
InventoryLocation.
ref CatchingContextTrapsBase m_CatchingContext
void InitCatchingComponent()
override void EEItemAttached(EntityAI item, string slot_name)
void AdjustDetectionRange()
float m_NoBaitCatchProb
DEPRECATED.
void SetTrapEnviroMask(int value)
void UpdatePreyPos()
void OnCatchSpawnServer()
void ResetRunningTimerProgress()
bool m_IsDeployed
bool IsSurfaceWater(vector position)
string m_AnimationPhaseTriggered
void PlayCatchParticleSynced(YieldItemBase yItem)
bool SetCanCatch(out EntityAI bait)
bool m_IsInProgress
DEPRECATED.
override bool OnStoreLoad(ParamsReadContext ctx, int version)
void PlayCatchEffectsClient()
bool CanPutInInventory(EntityAI player)
DEPRECATED.
void HandleBaitLoss()
void PlayCatchNoise(YieldItemBase yItem)
void AlignCatch(ItemBase obj, string catch_name)
DEPRECATED.
bool IsDeployed()
void PlayCatchEffectsServer()
float m_FinalCatchProb
DEPRECATED.
void DetachAllAttachments()
detaches everything on catching end (some slots may not be accessible when folded)
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
bool m_BaitNeeded
DEPRECATED.
override bool CanPutIntoHands(EntityAI parent)
bool m_IsUsable
DEPRECATED.
void IncreaseElapsedTime()
void PlayDeployLoopSound()
override void SetActions()
void ResetActiveProgress()
void OnCatchSpawnClient()
void RunTrappingTimer(float duration, string fnName)
generic trapping launcher for traps, use this to store delta info
void SetCatchSuccessful(bool successful)
void SpawnCatch()
void SetInactive()
void SetupTrapPlayer(PlayerBase player, bool set_position=true)
void PlayCatchSound(YieldItemBase yItem)
ref multiMap< string, float > m_CatchesGroundAnimal
DEPRECATED.
void TrapSpawnBase()
void InitTrapValues()
void Fold()
override void OnStoreSave(ParamsWriteContext ctx)
void UpdateTrapEnviroMask()
ref multiMap< string, float > m_CatchesSea
DEPRECATED.
void SetUsed()
void AddDefect()
void ClearCatchingComponent()
bool IsPlayerInVicinity()
void SetActive()
override void EEItemDetached(EntityAI item, string slot_name)
override void OnVariablesSynchronized()
this event is called all variables are synchronized on client
bool IsPlaceable()
override bool CanDisplayAttachmentSlot(int slot_id)
void SetDeployed(bool newState)
EntityAI m_Bait
DEPRECATED.
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
override bool CanPutInCargo(EntityAI parent)
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
void StartActivate(PlayerBase player)
void ~TrapSpawnBase()
const string m_PlaceableWaterType ref Timer m_PrevTimer
DEPRECATED.
override bool IsTakeable()
bool m_IsActive
void TrySpawnCatch()
bool IsActive()
float m_BaitCatchProb
bool IsPlaceableAtPosition(vector position)
void SetupTrap()
string m_AnimationPhaseSet
void StopDeployLoopSound()
DEPRECATED.
bool m_IsPastWaitingTime
override bool CanBePlaced(Man player, vector position)
bool m_WaterSurfaceForSetup
DEPRECATED.
bool CanBeTaken()
void EvaluateCatch()
ref multiMap< string, float > m_CatchesPond
DEPRECATED.
void CatchSetQuant(ItemBase catch)
!DEPRECATED
string m_AnimationPhaseUsed
ref array< string > m_PlaceableWaterSurfaceList
Definition enmath.c:7
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound PlaySoundEnviroment(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound, updating environment variables.
static void DestroyEffecterParticleServer(int effecterID)
static int CreateParticleServer(vector pos, EffecterParameters parameters)
returns unique effecter ID
static void ReinitParticleServer(int effecterID, EffecterParameters parameters)
allows re-initializing existing effecter with new parameters (extept m_EffecterType,...
static void ReactivateParticleServer(int effecterID)
Serialization general interface. Serializer API works with:
Definition serializer.c:56
CatchYieldBank GetCatchYieldBank()
Definition worlddata.c:387
float GetCatchAINoiseBaseStrength()
string GetCatchDeathSoundset()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
ref Timer m_Timer
Definition dayzgame.c:705
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition effect.c:463
class JsonUndergroundAreaTriggerData GetPosition
proto native bool IsCLIParam(string param)
Returns if command line argument is present.
proto bool GetCLIParam(string param, out string val)
Returns command line argument.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
InventoryLocationType
types of Inventory Location
bool m_IsStoreLoad
Definition itembase.c:4910
bool m_IsActive
bool IsActive()
class NoiseSystem NoiseParams()
Definition noise.c:15
string m_AnimationPhaseTriggered
Definition trapbase.c:34
float m_DefectRate
Definition trapbase.c:19
void AddDefect()
Definition trapbase.c:406
void SetActive()
Definition trapbase.c:414
ref EffectSound m_DeployLoopSound
DEPRECATED.
Definition trapbase.c:692
string m_AnimationPhaseSet
Definition trapbase.c:33
string m_InfoSetup
Definition trapbase.c:36
void SetInactive(bool stop_timer=true)
Definition trapbase.c:459
float m_InitWaitTime
Definition trapbase.c:17
void SetupTrapPlayer(PlayerBase player, bool set_position=true)
Definition trapbase.c:388