4 bool m_CanCatch =
false;
7 bool m_NeedInstalation;
11 int m_SpawnUpdateWaitTime;
13 float m_BaitLossFraction;
15 float m_MinimalDistanceFromPlayersToCatch;
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;
48 int m_dbgAttemptCount = 0;
55 RegisterNetSyncVariableBool(
"m_IsActive");
56 RegisterNetSyncVariableBool(
"m_IsDeployed");
57 RegisterNetSyncVariableInt(
"m_YieldItemIdx");
60 m_CatchesPond =
new multiMap<string, float>;
61 m_CatchesSea =
new multiMap<string, float>;
62 m_CatchesGroundAnimal =
new multiMap<string, float>;
73 ClearCatchingComponent();
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;
87 m_IsCatchSuccessful =
false;
88 m_MinimalDistanceFromPlayersToCatch = 0;
92 m_AnimationPhaseUsed =
"";
95 m_PlaceableWaterSurfaceList.Insert(
UAWaterType.SEA);
96 m_PlaceableWaterSurfaceList.Insert(
UAWaterType.FRESH);
101 super.OnStoreSave( ctx );
105 ctx.Write( m_IsDeployed );
107 ctx.Write(m_CatchEnviroMask);
112 if ( !super.OnStoreLoad(ctx, version) )
117 bool b_is_active =
false;
118 if ( !ctx.Read( b_is_active ) )
121 bool b_is_in_progress =
false;
124 if ( !ctx.Read( b_is_in_progress ) )
125 b_is_in_progress =
false;
128 bool b_is_deployed =
false;
129 if ( !ctx.Read( b_is_deployed ) )
130 b_is_deployed =
false;
135 if (ctx.Read(enviroMask))
136 m_CatchEnviroMask = enviroMask;
141 InitCatchingComponent();
145 SetDeployed( b_is_deployed );
154 super.OnVariablesSynchronized();
156 if (m_YieldItemIdx != m_YieldItemIdxLocal)
158 m_YieldItemIdxLocal = m_YieldItemIdx;
159 if (m_YieldItemIdxLocal != -1)
160 OnCatchSpawnClient();
176 m_IsDeployed = newState;
178 if ( newState ==
true )
184 SetAnimationPhase( m_AnimationPhaseUsed, 1 );
193 SetAnimationPhase( m_AnimationPhaseUsed, 1 );
218 if ( GetHierarchyRootPlayer() && GetHierarchyRootPlayer().CanDropEntity(
this ) )
231 vector trapPos = player.GetPosition() + ( player.GetDirection() * 0.5 );
243 if (MemoryPointExists(
"Prey_Position"))
244 m_PreyPos = ModelToWorld(GetMemoryPointPos(
"Prey_Position"));
249 if (
GetGame().IsServer() && m_IsFoldable ==
true )
270 if ( !IsDeployed() || ( GetInventory().AttachmentCount() == 0 && IsDeployed() ) )
280 super.CanPutInCargo( parent );
286 super.CanPutIntoHands( parent );
292 m_ActivationTime =
GetGame().GetTickTime();
294 m_CurrentMinimalDistance = m_MinimalDistanceFromPlayersToCatch;
297 m_dbgAttemptCount = 0;
303 if (m_IsPastWaitingTime)
305 m_AdjustedMaxActiveTime = m_MaxActiveTime;
306 RunTrappingTimer(m_UpdateWaitTime,
"EvaluateCatch");
311 RunTrappingTimer(
m_InitWaitTime + m_UpdateWaitTime,
"EvaluateCatch");
326 m_CurrentlyUsedDelta = 1;
332 m_CurrentlyUsedDelta = duration;
333 m_Timer.Run(duration,
this, fnName);
344 SetCatchSuccessful(
false);
346 m_IsPastWaitingTime =
false;
349 if (m_CatchParticleEffecterId >= 0)
351 m_CatchParticleEffecterId = -1;
359 SetAnimationPhase( m_AnimationPhaseUsed, 1 );
362 ResetActiveProgress();
366 InitCatchingComponent();
369 RunTrappingTimer(
m_InitWaitTime + m_UpdateWaitTime,
"EvaluateCatch");
376 RunTrappingTimer(m_UpdateWaitTime,
"EvaluateCatch");
377 m_AdjustedMaxActiveTime = m_MaxActiveTime;
389 ClearCatchingComponent();
396 m_IsPastWaitingTime =
false;
398 SetDeployed(
false );
410 m_IsDeployed =
false;
415 DetachAllAttachments();
417 ClearCatchingComponent();
424 m_IsPastWaitingTime =
false;
430 SetAnimationPhase( m_AnimationPhaseUsed, 0 );
433 m_CatchingContext = null;
441 m_ElapsedTime += m_CurrentlyUsedDelta;
446 Print(
"dbgTrapz | delta: " + m_CurrentlyUsedDelta);
447 Print(
"dbgTrapz | m_ElapsedTime: " + m_ElapsedTime);
448 Print(
"dbgTrapz | m_AdjustedMaxActiveTime: " + m_AdjustedMaxActiveTime);
455 if (m_CurrentMinimalDistance > 0)
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);
467 Print(
"dbgTrapz | adjusted distance: " + m_CurrentMinimalDistance +
"/" + m_MinimalDistanceFromPlayersToCatch +
" | LERP progress: " + time);
479 m_IsPastWaitingTime =
true;
480 IncreaseElapsedTime();
485 Print(
"dbgTrapz | m_dbgAttemptCount: " + m_dbgAttemptCount +
"/" + (m_MaxActiveTime/m_UpdateWaitTime));
489 bool success =
false;
490 m_CanCatch = SetCanCatch(
m_Bait);
494 if (m_CatchingContext.RollCatch())
501 Print(
"dbgTrapz | success!!!");
502 Print(
"---------------------");
509 string dbgSuccessOverride;
510 if (
GetCLIParam(
"trapsSuccessOverride",dbgSuccessOverride))
512 if (dbgSuccessOverride ==
"true" || dbgSuccessOverride.ToInt() == 1)
514 else if (dbgSuccessOverride ==
"false" || dbgSuccessOverride.ToInt() == 0)
522 if (m_ElapsedTime >= m_AdjustedMaxActiveTime || (
IsCLIParam(
"trapsQuick") && !success))
524 if (m_ElapsedTime >= m_AdjustedMaxActiveTime)
533 m_RollSuccessTime = m_ElapsedTime;
534 m_CurrentlyUsedDelta = 0;
539 RunTrappingTimer(m_UpdateWaitTime,
"EvaluateCatch");
547 Debug.Log(
"CE not enabled, player avoidance not available!");
551 return !GetCEApi().AvoidPlayer(
GetPosition(), m_CurrentMinimalDistance);
556 IncreaseElapsedTime();
557 AdjustDetectionRange();
560 if (
IsCLIParam(
"trapsQuick") || m_CurrentMinimalDistance <= 0 || !IsPlayerInVicinity())
562 if (m_CurrentMinimalDistance <= 0 || !IsPlayerInVicinity())
567 else if (m_ElapsedTime < m_AdjustedMaxActiveTime)
569 RunTrappingTimer(m_SpawnUpdateWaitTime,
"TrySpawnCatch");
585 catch =
ItemBase.Cast(m_CatchingContext.SpawnAndSetupCatch(m_YieldItemIdx,m_PreyPos));
587 OnCatchSpawnServer();
588 SetCatchSuccessful(
catch != null);
598 m_IsCatchSuccessful = successful;
603 PlayCatchEffectsServer();
610 PlayCatchEffectsClient();
615 if (m_YieldItemIdx == -1)
620 PlayCatchNoise(yItem);
621 PlayCatchParticleSynced(yItem);
626 if (m_YieldItemIdx == -1)
630 PlayCatchSound(yItem);
649 GetGame().GetNoiseSystem().AddNoiseTarget(m_PreyPos, 5,
m_NoisePar, noiseMultiplier);
658 if (m_CatchParticleEffecterId < 0)
672 return m_CatchingContext.IsValid();
677 super.OnItemLocationChanged( old_owner, new_owner );
682 if ( new_owner == NULL && m_NeedInstalation ==
false )
686 else if ( old_owner == NULL && new_owner != NULL )
698 if (m_YieldItemIdx != -1)
712 return Surface.AllowedWaterSurface(position[1] + 0.1, surfaceType, m_PlaceableWaterSurfaceList);
718 super.CanDisplayAttachmentSlot( slot_id );
724 super.CanReceiveAttachment( attachment, slotId );
730 super.EEItemAttached( item, slot_name );
734 ResetActiveProgress();
735 m_CatchingContext.UpdateDataAndMasks();
736 m_CatchingContext.GenerateResult();
737 ResetRunningTimerProgress();
743 super.EEItemDetached( item, slot_name );
747 ResetActiveProgress();
748 m_CatchingContext.UpdateDataAndMasks();
749 m_CatchingContext.GenerateResult();
750 ResetRunningTimerProgress();
758 if (m_CatchingContext)
759 delete m_CatchingContext;
764 m_CatchEnviroMask = m_CatchingContext.UpdateTrapEnviroMask();
769 m_CatchingContext.SetTrapEnviroMask(value);
774 if (m_CatchingContext)
776 if (m_IsCatchSuccessful)
777 m_CatchingContext.RemoveBait();
779 m_CatchingContext.ReduceBaitQty(m_BaitLossFraction);
786 int count = GetInventory().AttachmentCount();
790 for (
int i = 0; i < count; i++)
792 att = GetInventory().GetAttachmentFromIndex(i);
804 super.OnPlacementComplete(player, position, orientation);
808 vector rotation_matrix[3];
810 Math3D.YawPitchRollMatrix(orientation, rotation_matrix);
811 Math3D.MatrixToQuat(rotation_matrix, direction);
815 if (GetInventory().GetCurrentInventoryLocation(source))
817 destination.SetGroundEx(
this, position, direction);
820 player.ServerTakeToDst(source, destination);
825 PlayerBase.Cast(player).GetDayZPlayerInventory().RedirectToHandEvent(
InventoryMode.LOCAL, source, destination);
830 InitCatchingComponent();
842 GetInventory().GetCurrentInventoryLocation(loc);
847 vector player_pos = player.GetPosition();
848 vector aim_pos = player.GetAimPosition();
850 if (
vector.DistanceSq(player_pos, aim_pos) <= ( 1.5 * 1.5 ) )
852 return IsPlaceableAtPosition( aim_pos );
862 return IsPlaceableAtPosition(position);
878 const string m_PlaceableWaterType
884 ref
Timer m_AlignCatchTimer;
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
ActionActivateTrapCB ActionContinuousBaseCB ActionActivateTrap()
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.
YieldItemBase GetYieldItemByIdx(int idx)
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Wrapper class for managing sound through SEffectManager.
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 OnCatchSpawnServer()
void ResetRunningTimerProgress()
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 PlayCatchNoise(YieldItemBase yItem)
void AlignCatch(ItemBase obj, string catch_name)
DEPRECATED.
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 SetupTrapPlayer(PlayerBase player, bool set_position=true)
void PlayCatchSound(YieldItemBase yItem)
ref multiMap< string, float > m_CatchesGroundAnimal
DEPRECATED.
override void OnStoreSave(ParamsWriteContext ctx)
void UpdateTrapEnviroMask()
ref multiMap< string, float > m_CatchesSea
DEPRECATED.
void ClearCatchingComponent()
bool IsPlayerInVicinity()
override void EEItemDetached(EntityAI item, string slot_name)
override void OnVariablesSynchronized()
this event is called all variables are synchronized on client
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)
const string m_PlaceableWaterType ref Timer m_PrevTimer
DEPRECATED.
override bool IsTakeable()
bool IsPlaceableAtPosition(vector position)
string m_AnimationPhaseSet
void StopDeployLoopSound()
DEPRECATED.
override bool CanBePlaced(Man player, vector position)
bool m_WaterSurfaceForSetup
DEPRECATED.
ref multiMap< string, float > m_CatchesPond
DEPRECATED.
void CatchSetQuant(ItemBase catch)
!DEPRECATED
string m_AnimationPhaseUsed
ref array< string > m_PlaceableWaterSurfaceList
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:
CatchYieldBank GetCatchYieldBank()
float GetCatchAINoiseBaseStrength()
string GetCatchDeathSoundset()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
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.
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.
InventoryLocationType
types of Inventory Location
class NoiseSystem NoiseParams()
string m_AnimationPhaseTriggered
ref EffectSound m_DeployLoopSound
DEPRECATED.
string m_AnimationPhaseSet
void SetInactive(bool stop_timer=true)
void SetupTrapPlayer(PlayerBase player, bool set_position=true)