DayZ 1.24
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())
35 }
36
37 //========================================================
38 //======================= CATCHING =======================
39 //========================================================
40
41 override void SpawnCatch()
42 {
43 super.SpawnCatch();
44
45 if (m_CanCatch)
46 {
48 vector pos = GetPosition();
49
50 ItemBase catch;
51 // Select catch type depending on water type ( FRESH VS SALT )
52 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
53 catches = m_CatchesSea;
54 else if (GetGame().SurfaceIsPond(pos[0], pos[2]))
55 catches = m_CatchesPond;
56
57 if (catches && catches.Count() > 0)
58 {
59 // select random object from catches
60 int count = catches.Count() - 1;
62
63 if (Math.RandomFloat(0, 100) < m_FinalCatchProb)
64 {
65 catch = ItemBase.Cast(GetGame().CreateObjectEx(catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_NONE));
66
67 // Set the quantity of caught prey
68 if (catch)
69 CatchSetQuant(catch);
70 }
71
72 // We change the trap state and visuals
73 SetUsed();
74
75 // We remove the bait from this trap
76 if (m_Bait)
77 m_Bait.Delete();
78 }
79
80 // Deal damage to trap
81 AddDefect();
82 }
83 }
84
85 //========================================================
86 //============= PLACING AND INVENTORY EVENTS =============
87 //========================================================
88
90 {
91 return IsSurfaceWater(position);
92 }
93
95 {
96 if (!attachment.IsInherited(Worm))
97 return false;
98
99 return super.CanReceiveAttachment(attachment, slotId);
100 }
101
102#ifdef PLATFORM_WINDOWS
103 // How one sees the tripwire when in vicinity
104 override int GetViewIndex()
105 {
106 if (MemoryPointExists("invView2"))
107 {
109 GetInventory().GetCurrentInventoryLocation(il);
110 InventoryLocationType type = il.GetType();
111 switch (type)
112 {
113 case InventoryLocationType.CARGO:
114 {
115 return 0;
116 }
117 case InventoryLocationType.ATTACHMENT:
118 {
119 return 1;
120 }
121 case InventoryLocationType.HANDS:
122 {
123 return 0;
124 }
125 case InventoryLocationType.GROUND:
126 {
127 // Different view index depending on deployment state
128 if (IsActive())
129 return 1;
130
131 // When folded
132 return 0;
133 }
134 case InventoryLocationType.PROXYCARGO:
135 {
136 return 0;
137 }
138 default:
139 {
140 if (IsActive())
141 return 1;
142
143 // When folded
144 return 0;
145 }
146 }
147 }
148 return 0;
149 }
150#endif
151
152 //================================================================
153 // ADVANCED PLACEMENT
154 //================================================================
155
156 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
157 {
158 super.OnPlacementComplete(player, position, orientation);
159
160 SetIsPlaceSound(true);
161 }
162
163 override bool IsDeployable()
164 {
165 return true;
166 }
167
168 override string GetDeploySoundset()
169 {
170 return "placeFishNetTrap_SoundSet";
171 }
172
173 override string GetLoopDeploySoundset()
174 {
175 return "fishnet_deploy_SoundSet";
176 }
177}
178
179class FishNetTrap extends Trap_FishNet
180{
181
182}
const int ECE_NONE
InventoryLocationType
types of Inventory Location
void PlayPlaceSound()
Definition ItemBase.c:9027
void SetIsPlaceSound(bool is_place_sound)
Definition ItemBase.c:8962
bool IsPlaceSound()
Definition ItemBase.c:8967
bool IsActive()
string m_AnimationPhaseTriggered
Definition TrapBase.c:34
float m_DefectRate
Definition TrapBase.c:19
void AddDefect()
Definition TrapBase.c:403
string m_AnimationPhaseSet
Definition TrapBase.c:33
float m_InitWaitTime
Definition TrapBase.c:17
class JsonUndergroundAreaTriggerData GetPosition
InventoryLocation.
Definition EnMath.c:7
void Trap_FishNet()
Definition Trap_FishNet.c:3
override string GetLoopDeploySoundset()
override void SpawnCatch()
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
override bool IsDeployable()
override string GetDeploySoundset()
override bool IsPlaceableAtPosition(vector position)
override void OnVariablesSynchronized()
proto native CGame GetGame()
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].