DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Trap_FishNet.c
Go to the documentation of this file.
1class Trap_FishNet extends TrapSpawnBase
2{
4 {
5 m_DefectRate = 15; //Added damage after trap activation
6
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
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
185class FishNetTrap extends Trap_FishNet
186{
187
188}
const int ECE_NONE
InventoryLocationType
types of Inventory Location
void SetIsPlaceSound(bool is_place_sound)
Definition ItemBase.c:8900
void PlayPlaceSound()
Definition ItemBase.c:8938
bool IsPlaceSound()
Definition ItemBase.c:8905
bool IsActive()
string m_AnimationPhaseTriggered
Definition TrapBase.c:34
float m_DefectRate
Definition TrapBase.c:19
void AddDefect()
Definition TrapBase.c:455
string m_AnimationPhaseSet
Definition TrapBase.c:33
int m_InitWaitTime
Definition TrapBase.c:17
class JsonUndergroundAreaTriggerData GetPosition
InventoryLocation.
proto native int GetType()
returns type of InventoryLocation
Definition EnMath.c:7
override string GetDeploySoundset()
override string GetLoopDeploySoundset()
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
override bool IsDeployable()
override void OnVariablesSynchronized()
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
void Trap_FishNet()
Definition Trap_FishNet.c:3
override void SpawnCatch()
override bool IsPlaceableAtPosition(vector position)
proto native CGame GetGame()
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].