7 bool m_CanCatch =
false;
8 float m_MinimalDistanceFromPlayersToCatch;
10 float m_BaitCatchProb;
11 float m_NoBaitCatchProb;
12 float m_FinalCatchProb;
19 protected bool m_IsDeployed;
26 string m_AnimationPhaseUsed;
28 const string m_PlaceableWaterType
31 bool m_WaterSurfaceForSetup;
32 ref multiMap<string, float> m_CatchesPond;
33 ref multiMap<string, float> m_CatchesSea;
34 ref multiMap<string, float> m_CatchesGroundAnimal;
41 ref
Timer m_PrevTimer;
42 bool m_NeedInstalation;
46 ref
Timer m_AlignCatchTimer;
53 m_UpdateWaitTime = 10;
55 m_NeedInstalation =
true;
58 m_MinimalDistanceFromPlayersToCatch = 0;
61 m_NoBaitCatchProb = 50;
65 m_AnimationPhaseUsed =
"";
69 m_CatchesGroundAnimal = NULL;
72 m_PlaceableWaterSurfaceList.Insert(
UAWaterType.SEA);
73 m_PlaceableWaterSurfaceList.Insert(
UAWaterType.FRESH);
75 RegisterNetSyncVariableBool(
"m_IsSoundSynchRemote");
76 RegisterNetSyncVariableBool(
"m_IsDeploySound");
77 RegisterNetSyncVariableBool(
"m_IsActive");
78 RegisterNetSyncVariableBool(
"m_IsDeployed");
88 super.OnStoreSave( ctx );
94 ctx.Write( m_IsDeployed );
99 if ( !super.OnStoreLoad(ctx, version) )
102 bool b_is_active =
false;
103 if ( !ctx.Read( b_is_active ) )
106 bool b_is_in_progress =
false;
107 if ( !ctx.Read( b_is_in_progress ) )
108 b_is_in_progress =
false;
110 bool b_is_deployed =
false;
111 if ( !ctx.Read( b_is_deployed ) )
112 b_is_deployed =
false;
119 if ( b_is_in_progress && !b_is_active )
124 SetDeployed( b_is_deployed );
130 override void OnVariablesSynchronized()
132 super.OnVariablesSynchronized();
160 void SetDeployed(
bool newState )
162 m_IsDeployed = newState;
164 if ( newState ==
true )
170 SetAnimationPhase( m_AnimationPhaseUsed, 1 );
179 SetAnimationPhase( m_AnimationPhaseUsed, 1 );
191 bool IsPlaceableAtPosition(
vector position )
194 GetGame().SurfaceGetType3D( position[0], position[1], position[2], surface_type);
197 return GetGame().IsSurfaceDigable(surface_type);
204 if ( GetHierarchyRootPlayer() && GetHierarchyRootPlayer().CanDropEntity(
this ) )
217 vector trapPos = player.GetPosition() + ( player.GetDirection() * 0.5 );
218 trapPos[1] =
GetGame().SurfaceRoadY( trapPos[0], trapPos[2] );
228 if (
GetGame().IsServer() && m_IsFoldable ==
true )
249 if ( !IsDeployed() || ( GetInventory().AttachmentCount() == 0 && IsDeployed() ) )
259 super.CanPutInCargo( parent );
265 super.CanPutIntoHands( parent );
280 SetAnimationPhase( m_AnimationPhaseUsed, 1 );
302 SetDeployed(
false );
314 m_IsDeployed =
false;
324 SetAnimationPhase( m_AnimationPhaseUsed, 0 );
346 m_CanCatch = SetCanCatch( m_Bait );
352 if ( m_MinimalDistanceFromPlayersToCatch > 0 )
363 m_Timer.Run( m_UpdateWaitTime,
this,
"SpawnCatch" );
371 m_FinalCatchProb = m_BaitCatchProb;
373 m_FinalCatchProb = m_NoBaitCatchProb;
377 if ( MemoryPointExists(
"Prey_Position") )
379 m_PreyPos = ModelToWorld( GetMemoryPointPos(
"Prey_Position") );
385 bool SetCanCatch( out
EntityAI bait )
388 bait = GetInventory().FindAttachment( slotIdx );
395 if ( !edibleBait.GetFoodStage().IsFoodBurned() && !edibleBait.GetFoodStage().IsFoodRotten() )
406 void CatchSetQuant(
ItemBase catch )
411 float coef =
Math.RandomFloatInclusive(0.5, 1.0);
412 float item_quantity =
catch.GetQuantityMax() * coef;
413 item_quantity =
Math.Round(item_quantity);
414 catch.SetQuantity( item_quantity );
420 super.OnItemLocationChanged( old_owner, new_owner );
425 if ( new_owner == NULL && m_NeedInstalation ==
false )
429 else if ( old_owner == NULL && new_owner != NULL )
444 bool IsSurfaceWater(
vector position)
447 GetGame().SurfaceGetType3D(position[0], position[1], position[2], surfaceType);
449 return Surface.AllowedWaterSurface(position[1] + 0.1, surfaceType, m_PlaceableWaterSurfaceList);
455 super.CanDisplayAttachmentSlot( slot_id );
459 override bool CanReceiveAttachment(
EntityAI attachment,
int slotId )
461 super.CanReceiveAttachment( attachment, slotId );
467 super.EEItemAttached( item, slot_name );
470 if ( IsDeployed() && slot_name ==
"Trap_Bait" )
480 override void OnPlacementComplete(Man player,
vector position =
"0 0 0",
vector orientation =
"0 0 0")
482 super.OnPlacementComplete(player, position, orientation);
486 vector rotation_matrix[3];
488 Math3D.YawPitchRollMatrix(orientation, rotation_matrix);
489 Math3D.MatrixToQuat(rotation_matrix, direction);
493 if (GetInventory().GetCurrentInventoryLocation(source))
495 destination.SetGroundEx(
this, position, direction);
497 player.ServerTakeToDst(source, destination);
499 player.GetInventory().TakeToDst(
InventoryMode.LOCAL, source, destination);
510 if ( !
GetGame().IsDedicatedServer() )
521 if ( !
GetGame().IsDedicatedServer() )
529 override void SetActions()
542 bool CanPutInInventory(
EntityAI player ) { }
544 void AlignCatch(
ItemBase obj,
string catch_name ) { }
550 if ( GetHierarchyRootPlayer() != NULL && GetHierarchyRootPlayer().GetHumanInventory().GetEntityInHands() ==
this )
554 vector player_pos = player.GetPosition();
555 vector aim_pos = player.GetAimPosition();
557 if (
vector.DistanceSq(player_pos, aim_pos) <= ( 1.5 * 1.5 ) )
559 return IsPlaceableAtPosition( aim_pos );
567 override bool CanBePlaced( Man player,
vector position )
569 return IsPlaceableAtPosition(position);