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");
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;
101 super.OnStoreSave( ctx );
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;
154 super.OnVariablesSynchronized();
156 if (m_YieldItemIdx != m_YieldItemIdxLocal)
158 m_YieldItemIdxLocal = m_YieldItemIdx;
159 if (m_YieldItemIdxLocal != -1)
178 if ( newState ==
true )
208 g_Game.SurfaceGetType3D( position[0], position[1], position[2], surface_type);
211 return g_Game.IsSurfaceDigable(surface_type);
218 if ( GetHierarchyRootPlayer() && GetHierarchyRootPlayer().CanDropEntity(
this ) )
231 vector trapPos = player.GetPosition() + ( player.GetDirection() * 0.5 );
232 trapPos[1] =
g_Game.SurfaceRoadY( trapPos[0], trapPos[2] );
243 if (MemoryPointExists(
"Prey_Position"))
244 m_PreyPos = ModelToWorld(GetMemoryPointPos(
"Prey_Position"));
249 if (
g_Game.IsServer() && m_IsFoldable ==
true )
260 DecreaseHealth(
"",
"", m_DefectRate );
280 super.CanPutInCargo( parent );
286 super.CanPutIntoHands( parent );
292 m_ActivationTime =
g_Game.GetTickTime();
294 m_CurrentMinimalDistance = m_MinimalDistanceFromPlayersToCatch;
297 m_dbgAttemptCount = 0;
305 m_AdjustedMaxActiveTime = m_MaxActiveTime;
310 m_AdjustedMaxActiveTime = m_MaxActiveTime + m_InitWaitTime;
326 m_CurrentlyUsedDelta = 1;
332 m_CurrentlyUsedDelta = duration;
333 m_Timer.Run(duration,
this, fnName);
349 if (m_CatchParticleEffecterId >= 0)
351 m_CatchParticleEffecterId = -1;
363 m_InitWaitTime =
Math.RandomFloatInclusive(m_InitWaitTimeMin,m_InitWaitTimeMax);
370 m_AdjustedMaxActiveTime = m_MaxActiveTime + m_InitWaitTime;
377 m_AdjustedMaxActiveTime = m_MaxActiveTime;
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);
485 Print(
"dbgTrapz | m_dbgAttemptCount: " + m_dbgAttemptCount +
"/" + (m_MaxActiveTime/m_UpdateWaitTime));
489 bool success =
false;
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;
547 Debug.Log(
"CE not enabled, player avoidance not available!");
551 return !GetCEApi().AvoidPlayer(
GetPosition(), m_CurrentMinimalDistance);
567 else if (m_ElapsedTime < m_AdjustedMaxActiveTime)
598 m_IsCatchSuccessful = successful;
615 if (m_YieldItemIdx == -1)
618 YieldItemBase yItem =
g_Game.GetMission().GetWorldData().GetCatchYieldBank().GetYieldItemByIdx(m_YieldItemIdx);
626 if (m_YieldItemIdx == -1)
629 YieldItemBase yItem =
g_Game.GetMission().GetWorldData().GetCatchYieldBank().GetYieldItemByIdx(m_YieldItemIdx);
649 g_Game.GetNoiseSystem().AddNoiseTarget(m_PreyPos, 5,
m_NoisePar, noiseMultiplier);
658 if (m_CatchParticleEffecterId < 0)
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)
710 g_Game.SurfaceGetType3D(position[0], position[1], position[2], surfaceType);
718 super.CanDisplayAttachmentSlot( slot_id );
724 super.CanReceiveAttachment( attachment, slotId );
730 super.EEItemAttached( item, slot_name );
743 super.EEItemDetached( item, slot_name );
776 if (m_IsCatchSuccessful)
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);
818 if (
g_Game.IsMultiplayer())
820 player.ServerTakeToDst(source, destination);
825 PlayerBase.Cast(player).GetDayZPlayerInventory().RedirectToHandEvent(
InventoryMode.LOCAL, source, destination);
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 ) )
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()
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.
ref EffectSound m_DeployLoopSound
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)
void Fold(bool keep_connected=false)
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)
float GetCatchAINoiseBaseStrength()
string GetCatchDeathSoundset()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Serializer ParamsReadContext
Serializer ParamsWriteContext
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.
vector GetPosition()
Get the world position of the Effect.
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()
void SetInactive(bool stop_timer=true)
void SetupTrapPlayer(PlayerBase player, bool set_position=true)