DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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() )
33 {
35 }
36 }
37
38 override void SpawnCatch()
39 {
40 super.SpawnCatch();
41
42 if ( m_CanCatch )
43 {
44 // We get the prey position for spawning
45 multiMap<string, float> catches;
46 vector pos = GetPosition();
47
48 ItemBase catch;
49 // Select catch type depending on water type ( FRESH VS SALT )
50 if ( GetGame().SurfaceIsSea( pos[0], pos[2] ) )
51 {
52 catches = m_CatchesSea;
53 }
54 else if ( GetGame().SurfaceIsPond( pos[0], pos[2] ) )
55 {
56 catches = m_CatchesPond;
57 }
58
59 if ( catches && catches.Count() > 0 )
60 {
61 // select random object from catches
62 int count = catches.Count() - 1;
63 int randomCatchIndex = Math.RandomInt( 0, count );
64
65 if ( Math.RandomFloat(0, 100) < m_FinalCatchProb )
66 {
67 catch = ItemBase.Cast( GetGame().CreateObjectEx( catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_NONE ) );
68
69 // Set the quantity of caught prey
70 if ( catch )
71 CatchSetQuant( catch );
72 }
73
74 // We change the trap state and visuals
75 SetUsed();
76
77 // We remove the bait from this trap
78 if ( m_Bait )
79 m_Bait.Delete();
80 }
81
82 // Deal damage to trap
83 AddDefect();
84 }
85 }
86
87 //========================================================
88 //============= PLACING AND INVENTORY EVENTS =============
89 //========================================================
90
91 override bool IsPlaceableAtPosition( vector position )
92 {
93 return IsSurfaceWater( position );
94 }
95
96 override bool CanReceiveAttachment( EntityAI attachment, int slotId )
97 {
98 if ( !attachment.IsInherited( Worm ) )
99 return false;
100
101 return super.CanReceiveAttachment( attachment, slotId );
102 }
103
104 #ifdef PLATFORM_WINDOWS
105 // How one sees the tripwire when in vicinity
106 override int GetViewIndex()
107 {
108 if ( MemoryPointExists( "invView2" ) )
109 {
111 GetInventory().GetCurrentInventoryLocation( il );
112 InventoryLocationType type = il.GetType();
113 switch ( type )
114 {
115 case InventoryLocationType.CARGO:
116 {
117 return 0;
118 }
119 case InventoryLocationType.ATTACHMENT:
120 {
121 return 1;
122 }
123 case InventoryLocationType.HANDS:
124 {
125 return 0;
126 }
127 case InventoryLocationType.GROUND:
128 {
129 // Different view index depending on deployment state
130 if ( IsDeployed() )
131 return 1;
132
133 // When folded
134 return 0;
135 }
136 case InventoryLocationType.PROXYCARGO:
137 {
138 return 0;
139 }
140 default:
141 {
142 if ( IsDeployed() )
143 return 1;
144
145 // When folded
146 return 0;
147 }
148 }
149 }
150 return 0;
151 }
152 #endif
153}
154
155class SmallFishTrap extends Trap_SmallFish
156{
157 // DEPRECATED
159
160 //================================================================
161 // ADVANCED PLACEMENT
162 //================================================================
163
164 override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
165 {
166 super.OnPlacementComplete( player, position, orientation );
167
168 SetIsPlaceSound( true );
169 }
170
171 override bool IsDeployable()
172 {
173 return true;
174 }
175
176 override string GetDeploySoundset()
177 {
178 return "placeSmallFishTrap_SoundSet";
179 }
180
181 override string GetLoopDeploySoundset()
182 {
183 return "fishtrap_deploy_SoundSet";
184 }
185
186 override bool DoPlacingHeightCheck()
187 {
188 return true; //has to be able to catch rain, default distance raycast
189 }
190}
const int ECE_NONE
InventoryLocationType
types of Inventory Location
bool IsDeployable()
Definition ItemBase.c:8829
string GetLoopDeploySoundset()
Definition LargeTent.c:151
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition ItemBase.c:8431
void SetIsPlaceSound(bool is_place_sound)
Definition ItemBase.c:8900
string GetDeploySoundset()
Definition LargeTent.c:146
void PlayPlaceSound()
Definition ItemBase.c:8938
bool IsPlaceSound()
Definition ItemBase.c:8905
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: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
DEPRECATED, done through the RainProcurementHandler / component instead.
void Trap_SmallFish()
override void OnVariablesSynchronized()
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
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].