DayZ 1.24
Loading...
Searching...
No Matches
Trap_SmallFish.c
Go to the documentation of this file.
1class Trap_SmallFish extends TrapSpawnBase
2{
4 {
5 m_DefectRate = 15; //Added damage after trap activation
6
8 m_UpdateWaitTime = 30;
9
10 m_AnimationPhaseSet = "inventory";
11 m_AnimationPhaseTriggered = "placing";
12 m_AnimationPhaseUsed = "triggered";
13
14 m_MinimalDistanceFromPlayersToCatch = 15;
15
16 m_BaitCatchProb = 85;
17 m_NoBaitCatchProb = 15;
18
19 m_WaterSurfaceForSetup = true;
20
21 m_CatchesPond = new multiMap<string, float>;
22 m_CatchesPond.Insert("Bitterlings", 1);
23
24 m_CatchesSea = new multiMap<string, float>;
25 m_CatchesSea.Insert("Sardines", 1);
26 }
27
29 {
30 super.OnVariablesSynchronized();
31
32 if (IsPlaceSound())
34 }
35
36 override void SpawnCatch()
37 {
38 super.SpawnCatch();
39
40 if (m_CanCatch)
41 {
42 // We get the prey position for spawning
44 vector pos = GetPosition();
45
46 ItemBase catch;
47 // Select catch type depending on water type ( FRESH VS SALT )
48 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
49 catches = m_CatchesSea;
50 else if (GetGame().SurfaceIsPond(pos[0], pos[2]))
51 catches = m_CatchesPond;
52
53 if (catches && catches.Count() > 0)
54 {
55 // select random object from catches
56 int count = catches.Count() - 1;
58
59 if (Math.RandomFloat(0, 100) < m_FinalCatchProb)
60 {
61 catch = ItemBase.Cast(GetGame().CreateObjectEx(catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_NONE));
62
63 // Set the quantity of caught prey
64 if (catch)
65 CatchSetQuant(catch);
66 }
67
68 // We change the trap state and visuals
69 SetUsed();
70
71 // We remove the bait from this trap
72 if (m_Bait)
73 m_Bait.Delete();
74 }
75
76 // Deal damage to trap
77 AddDefect();
78 }
79 }
80
81 //========================================================
82 //============= PLACING AND INVENTORY EVENTS =============
83 //========================================================
84
86 {
87 return IsSurfaceWater(position);
88 }
89
91 {
92 if (!attachment.IsInherited(Worm))
93 return false;
94
95 return super.CanReceiveAttachment(attachment, slotId);
96 }
97
98#ifdef PLATFORM_WINDOWS
99 // How one sees the tripwire when in vicinity
100 override int GetViewIndex()
101 {
102 if (MemoryPointExists("invView2"))
103 {
105 GetInventory().GetCurrentInventoryLocation(il);
106 InventoryLocationType type = il.GetType();
107 switch (type)
108 {
109 case InventoryLocationType.CARGO:
110 {
111 return 0;
112 }
113 case InventoryLocationType.ATTACHMENT:
114 {
115 return 1;
116 }
117 case InventoryLocationType.HANDS:
118 {
119 return 0;
120 }
121 case InventoryLocationType.GROUND:
122 {
123 // Different view index depending on deployment state
124 if (IsDeployed())
125 return 1;
126
127 // When folded
128 return 0;
129 }
130 case InventoryLocationType.PROXYCARGO:
131 {
132 return 0;
133 }
134 default:
135 {
136 if (IsDeployed())
137 return 1;
138
139 // When folded
140 return 0;
141 }
142 }
143 }
144 return 0;
145 }
146#endif
147}
148
149class SmallFishTrap extends Trap_SmallFish
150{
151 // DEPRECATED
153
154 //================================================================
155 // ADVANCED PLACEMENT
156 //================================================================
157
158 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
159 {
160 super.OnPlacementComplete(player, position, orientation);
161
162 SetIsPlaceSound(true);
163 }
164
165 override bool IsDeployable()
166 {
167 return true;
168 }
169
170 override string GetDeploySoundset()
171 {
172 return "placeSmallFishTrap_SoundSet";
173 }
174
175 override string GetLoopDeploySoundset()
176 {
177 return "fishtrap_deploy_SoundSet";
178 }
179
180 override bool DoPlacingHeightCheck()
181 {
182 return true; //has to be able to catch rain, default distance raycast
183 }
184}
const int ECE_NONE
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
InventoryLocationType
types of Inventory Location
bool IsDeployable()
Definition ItemBase.c:8891
string GetDeploySoundset()
Definition LargeTent.c:138
void PlayPlaceSound()
Definition ItemBase.c:9027
void SetIsPlaceSound(bool is_place_sound)
Definition ItemBase.c:8962
string GetLoopDeploySoundset()
Definition LargeTent.c:143
bool IsPlaceSound()
Definition ItemBase.c:8967
class Trap_SmallFish extends TrapSpawnBase m_RainProcurement
override bool DoPlacingHeightCheck()
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
DEPRECATED, done through the RainProcurementHandler / component instead.
override void SpawnCatch()
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
void Trap_SmallFish()
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].