Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
trap_fishnet.c
Go to the documentation of this file.
1 class Trap_FishNet extends TrapSpawnBase
2 {
3  void Trap_FishNet()
4  {
5  m_DefectRate = 15; //Added damage after trap activation
6 
7  m_InitWaitTime = Math.RandomFloat(900,1500);
8  m_UpdateWaitTime = 30;
9  m_IsFoldable = true;
10 
11  m_MinimalDistanceFromPlayersToCatch = 15;
12 
13  m_BaitCatchProb = 85;
14  m_NoBaitCatchProb = 15;
15 
16  m_AnimationPhaseSet = "inventory";
17  m_AnimationPhaseTriggered = "placing";
18  m_AnimationPhaseUsed = "triggered";
19 
20  m_WaterSurfaceForSetup = true;
21 
22  m_CatchesPond = new multiMap<string, float>;
23  m_CatchesPond.Insert("Carp",1);
24 
25  m_CatchesSea = new multiMap<string, float>;
26  m_CatchesSea.Insert("Mackerel",1);
27  }
28 
29  override void OnVariablesSynchronized()
30  {
31  super.OnVariablesSynchronized();
32 
33  if ( IsPlaceSound() )
34  {
36  }
37  }
38 
39  //========================================================
40  //======================= CATCHING =======================
41  //========================================================
42 
43  override void SpawnCatch()
44  {
45  super.SpawnCatch();
46 
47  if ( m_CanCatch )
48  {
49  multiMap<string, float> catches;
50  vector pos = GetPosition();
51 
52  ItemBase catch;
53  // Select catch type depending on water type ( FRESH VS SALT )
54  if ( GetGame().SurfaceIsSea( pos[0], pos[2] ) )
55  {
56  catches = m_CatchesSea;
57  }
58  else if ( GetGame().SurfaceIsPond( pos[0], pos[2] ) )
59  {
60  catches = m_CatchesPond;
61  }
62 
63  if ( catches && catches.Count() > 0 )
64  {
65  // select random object from catches
66  int count = catches.Count() - 1;
67  int randomCatchIndex = Math.RandomInt( 0, count );
68 
69  if ( Math.RandomFloat(0, 100) < m_FinalCatchProb )
70  {
71  catch = ItemBase.Cast( GetGame().CreateObjectEx( catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_NONE ) );
72 
73  // Set the quantity of caught prey
74  if ( catch )
75  CatchSetQuant( catch );
76  }
77 
78  // We change the trap state and visuals
79  SetUsed();
80 
81  // We remove the bait from this trap
82  if ( m_Bait )
83  m_Bait.Delete();
84  }
85 
86  // Deal damage to trap
87  AddDefect();
88  }
89  }
90 
91  //========================================================
92  //============= PLACING AND INVENTORY EVENTS =============
93  //========================================================
94 
95  override bool IsPlaceableAtPosition( vector position )
96  {
97  return IsSurfaceWater( position );
98  }
99 
100  override bool CanReceiveAttachment( EntityAI attachment, int slotId )
101  {
102  if ( !attachment.IsInherited( Worm ) )
103  return false;
104 
105  return super.CanReceiveAttachment( attachment, slotId );
106  }
107 
108  #ifdef PLATFORM_WINDOWS
109  // How one sees the tripwire when in vicinity
110  override int GetViewIndex()
111  {
112  if ( MemoryPointExists( "invView2" ) )
113  {
115  GetInventory().GetCurrentInventoryLocation( il );
116  InventoryLocationType type = il.GetType();
117  switch ( type )
118  {
119  case InventoryLocationType.CARGO:
120  {
121  return 0;
122  }
123  case InventoryLocationType.ATTACHMENT:
124  {
125  return 1;
126  }
127  case InventoryLocationType.HANDS:
128  {
129  return 0;
130  }
131  case InventoryLocationType.GROUND:
132  {
133  // Different view index depending on deployment state
134  if ( IsActive() )
135  return 1;
136 
137  // When folded
138  return 0;
139  }
140  case InventoryLocationType.PROXYCARGO:
141  {
142  return 0;
143  }
144  default:
145  {
146  if ( IsActive() )
147  return 1;
148 
149  // When folded
150  return 0;
151  }
152  }
153  }
154  return 0;
155  }
156  #endif
157 
158  //================================================================
159  // ADVANCED PLACEMENT
160  //================================================================
161 
162  override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
163  {
164  super.OnPlacementComplete( player, position, orientation );
165 
166  SetIsPlaceSound( true );
167  }
168 
169  override bool IsDeployable()
170  {
171  return true;
172  }
173 
174  override string GetDeploySoundset()
175  {
176  return "placeFishNetTrap_SoundSet";
177  }
178 
179  override string GetLoopDeploySoundset()
180  {
181  return "fishnet_deploy_SoundSet";
182  }
183 }
184 
185 class FishNetTrap extends Trap_FishNet
186 {
187 
188 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
IsPlaceableAtPosition
bool IsPlaceableAtPosition(vector position)
Definition: trapbase.c:207
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: anniversarymusicsource.c:42
IsPlaceSound
bool IsPlaceSound()
Definition: itembase.c:4288
TrapSpawnBase
Definition: trap_fishnet.c:1
OnPlacementComplete
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition: explosivesbase.c:133
m_AnimationPhaseSet
string m_AnimationPhaseSet
Definition: trapbase.c:33
GetLoopDeploySoundset
override string GetLoopDeploySoundset()
Definition: largetent.c:151
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
vector
Definition: enconvert.c:105
ECE_NONE
const int ECE_NONE
Definition: centraleconomy.c:7
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
PlayPlaceSound
void PlayPlaceSound()
Definition: itembase.c:4348
SetIsPlaceSound
void SetIsPlaceSound(bool is_place_sound)
Definition: itembase.c:4283
IsDeployable
override bool IsDeployable()
Definition: basebuildingbase.c:339
AddDefect
void AddDefect()
Definition: trapbase.c:429
IsActive
bool IsActive()
Definition: modifierbase.c:130
Math
Definition: enmath.c:6
m_DefectRate
float m_DefectRate
Definition: trapbase.c:19
m_AnimationPhaseTriggered
string m_AnimationPhaseTriggered
Definition: trapbase.c:34
m_InitWaitTime
float m_InitWaitTime
Definition: trapbase.c:17
CanReceiveAttachment
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition: basebuildingbase.c:895
GetDeploySoundset
override string GetDeploySoundset()
Definition: largetent.c:146
EntityAI
Definition: building.c:5