DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
FishingRod_Base.c
Go to the documentation of this file.
2{
4 {
5 }
6
7 override void SetActions()
8 {
9 super.SetActions();
10
12 }
13
15 {
16 return 0.0;
17 }
18
19 override bool IsOpen()
20 {
21 return false;
22 }
23
24 void AnimateFishingRod(bool state) {}
25
26 override void OnDebugSpawn()
27 {
28 GetInventory().CreateAttachment("Bait");
29 for (int i = 0; i < 6; ++i)
30 {
32 }
33 }
34}
35
37{
38 const string ANIM_PHASE_OPENED = "OpenRod";
39 const string ANIM_PHASE_CLOSED = "CloseRod";
40
41 const float BREAK_PULL = 36;
42 const float TOO_MUCH_PULL = 32;
43 const float HIGH_PULL = 22;
44 const float LOW_PULL = 18;
45 const float TOO_FEW_PULL = 8;
46 const float LOOSE_PULL = 0;
47 const int LOSS_BREAK = 0;
48 const int LOSS_LOOSE = 1;
49 const int WIN = 2;
50 const int INTERUPTED = 3;
51 const float INIT_LINE_STRETCH = 15;
52 const float MIN_FISHING_TIME = 100;
53 const float MAX_FISHING_TIME = 150;
54 const int FISH_PULL_CHANCE = 15;
55 const int FISH_AGILITY = 15;
56
61 float m_Pull;
62 float m_DeltaT;
70
72 {
73 m_Fishing = false;
74 }
75
76 void Init()
77 {
80 m_IsFishPulling = false;
81 //TIMERDEPRECATED - randomized time of fishing
85 //TIMERDEPRECATED
86 if(!m_Cycler)
87 {
88 m_Cycler = new Timer();
89 }
91 {
92 m_CyclerCatching = new Timer();
93 }
94 m_CyclerCatching.Run(4, this, "Catching", NULL,true);
95 m_Player.Message("I have started fishing.", "colorFriendly");
96 }
97
99 {
100 return m_Fishing;
101 }
102
104 {
105 m_Fishing = true;
106 //Init();
107 }
108
110 {
112 }
113
114
115
116 void FishPull()
117 {
118 if ( !m_IsFishPulling )
119 {
120 float rand = Math.RandomInt(1, FISH_PULL_CHANCE);
121 if ( rand <= 2 && m_Pull <= TOO_MUCH_PULL && m_Pull >= TOO_FEW_PULL )
122 {
123 //TIMERDEPRECATED - randomizing timeframe to pull fish out
124 if ( Math.RandomInt(0, 1) )
125 {
126 m_FishPull = rand;
127 }
128 else
129 {
130 m_FishPull = -rand;
131 }
132 //TIMERDEPRECATED - randomizing timeframe to pull fish out
133 m_PullTime = Math.RandomInt(2, 6);
134 m_IsFishPulling = true;
135 }
136 }
137 else
138 {
139 m_PullTime--;
140 if (m_PullTime == 0)
141 {
142 m_IsFishPulling = false;
143 }
144 }
145 }
146
147 void Catching()
148 {
149 if(m_FishProximity == 0 && m_WasPulled)
150 {
152 m_Cycler.Run(0.3, this, "Pulling", NULL,true);
153 }
154 else
155 {
156 if (m_WasPulled)
157 {
158 m_WasPulled = false;
160 }
161 //TIMERDEPRECATED - randomized proximity of fish to
163 string fline = "";
164 for (int i = 0; i < m_FishProximity; i++)
165 {
166 fline += " .";
167 }
168 m_Player.Message("", "colorStatusChannel");
169 m_Player.Message("HOLD right mouse button to pull the fishing line", "colorAction");
170 m_Player.Message("", "colorStatusChannel");
171 m_Player.Message("", "colorStatusChannel");
172 m_Player.Message("", "colorStatusChannel");
173 m_Player.Message("Start pulling when J and <*)))>< meet:", "colorStatusChannel");
174 m_Player.Message("", "colorStatusChannel");
175 m_Player.Message("J"+fline+" <*)))><", "colorImportant");
176 if(m_ChanceRange > 0)
177 {
179 }
180 }
181 }
182
183 void Pulling()
184 {
185 float agent_speed_distance = vector.Distance("0 0 0",m_Player.GetModelSpeed());
186 if (m_Player.GetItemInHands() != this || !m_Player.IsInWater() || agent_speed_distance > 1 )
187 {
189 }
190 else
191 {
192 if ( m_FishingTime <= 0)
193 {
194 ItemBase pcatch = ItemBase.Cast( m_Player.GetInventory().CreateInInventory("Carp") );
195 //ItemBase pcatch = ItemBase.Cast( m_Player.CreateInInventory("Carp","cargo_bait") );
196 pcatch.SetQuantity(800,false);
197 End(WIN);
198 }
199 else
200 {
201 FishPull();
202 if ( m_IsFishPulling )
203 {
205 }
206 if (m_WasPulled)
207 {
208 m_Pull += 1;
209 }
210 else
211 {
212 m_Pull -= 1;
213 }
214 m_WasPulled = false;
216 DisplayState();
217 if ( m_Pull <= LOOSE_PULL)
218 {
220 }
221 if ( m_Pull >= BREAK_PULL)
222 {
224 }
225 }
226 }
227 }
228
229 void End( int result )
230 {
231 m_Cycler.Stop();
233 m_Fishing = false;
234
235 switch (result)
236 {
237 case LOSS_BREAK:
238 m_Player.Message("", "colorStatusChannel");
239 m_Player.Message("", "colorStatusChannel");
240 m_Player.Message("", "colorStatusChannel");
241 m_Player.Message("The fish had broken the fishing line and swam away.", "colorImportant");
242 m_Player.Message("", "colorStatusChannel");
243 m_Player.Message("", "colorStatusChannel");
244 m_Player.Message("", "colorStatusChannel");
245 m_Player.Message("", "colorStatusChannel");
246 break;
247
248 case LOSS_LOOSE:
249 m_Player.Message("", "colorStatusChannel");
250 m_Player.Message("", "colorStatusChannel");
251 m_Player.Message("", "colorStatusChannel");
252 m_Player.Message("The fish escaped.", "colorImportant");
253 m_Player.Message("", "colorStatusChannel");
254 m_Player.Message("", "colorStatusChannel");
255 m_Player.Message("", "colorStatusChannel");
256 m_Player.Message("", "colorStatusChannel");
257 break;
258
259 case WIN:
260 m_Player.Message("", "colorStatusChannel");
261 m_Player.Message("", "colorStatusChannel");
262 m_Player.Message("", "colorStatusChannel");
263 m_Player.Message("I caught the fish!", "colorFriendly");
264 m_Player.Message("", "colorStatusChannel");
265 m_Player.Message("", "colorStatusChannel");
266 m_Player.Message("", "colorStatusChannel");
267 m_Player.Message("", "colorStatusChannel");
268 break;
269
270 case INTERUPTED:
271 m_Player.Message("", "colorStatusChannel");
272 m_Player.Message("", "colorStatusChannel");
273 m_Player.Message("", "colorStatusChannel");
274 m_Player.Message("Fishing time is over.", "colorFriendly");
275 m_Player.Message("", "colorStatusChannel");
276 m_Player.Message("", "colorStatusChannel");
277 m_Player.Message("", "colorStatusChannel");
278 m_Player.Message("", "colorStatusChannel");
279 break;
280
281 default:
282 Print("Wrong number");
283 break;
284 }
285 }
286
287 void AddPull(float delta)
288 {
289 m_DeltaT = delta;
290 m_WasPulled = true;
291 }
292
294 {
295 string fline = "";
296 for (int i = 0; i < m_Pull; i++)
297 {
298 fline += "-";
299 }
300 m_Player.Message("", "colorStatusChannel");
301 m_Player.Message("HOLD right mouse button to pull the fishing line", "colorAction");
302 m_Player.Message("RELEASE right mouse button to loosen the fishing line", "colorAction");
303 m_Player.Message("", "colorStatusChannel");
304 m_Player.Message("", "colorStatusChannel");
305 m_Player.Message("Fishing line stretch :", "colorStatusChannel");
306 m_Player.Message("", "colorStatusChannel");
307 if (m_Pull >= TOO_MUCH_PULL)
308 {
309 m_Player.Message("<"+fline+">", "colorImportant");
310 }
312 {
313 m_Player.Message("<"+fline+">", "colorAction");
314 }
315 if ( m_Pull < HIGH_PULL && m_Pull > LOW_PULL)
316 {
317 m_Player.Message("<"+fline+">", "colorFriendly");
318 }
319 if ( m_Pull <= LOW_PULL && m_Pull > TOO_FEW_PULL)
320 {
321 m_Player.Message("<"+fline+">", "colorStatusChannel");
322 }
323 if (m_Pull <= TOO_FEW_PULL)
324 {
325 m_Player.Message("<"+fline+">", "colorImportant");
326 }
327 }
328
329 // Conditions
330 override bool CanPutInCargo( EntityAI parent )
331 {
332 if( !super.CanPutInCargo(parent) ) {return false;}
333 if ( GetAnimationPhase(ANIM_PHASE_CLOSED) > 0.5 )
334 {
335 return true;
336 }
337 return false;
338 }
339
340 override void SetActions()
341 {
342 super.SetActions();
343
344 //AddAction(ActionToggleFishing);
345 //AddAction(ActionFishing);
346 //AddAction(ActionFishingNew);
347 }
348
350 {
351 return 0.0;
352 }
353}
void AddAction(typename actionName)
const int ECE_PLACE_ON_SURFACE
override Widget Init()
Definition DayZGame.c:122
void End()
called on surrender end request end
void Pulling()
void FishPull()
const float TOO_FEW_PULL
const float MIN_FISHING_TIME
float m_PullTime
float m_FishPull
void FishingRod_Base()
const int INTERUPTED
const int LOSS_LOOSE
const float TOO_MUCH_PULL
const int FISH_AGILITY
ref Timer m_CyclerCatching
bool IsFishingActive()
bool m_Fishing
const float BREAK_PULL
bool m_IsFishPulling
void AddPull(float delta)
float GetFishingEffectivityBonus()
float m_Pull
bool m_WasPulled
int m_FishingTime
FishingRod_Base_New ANIM_PHASE_OPENED
void Catching()
const string ANIM_PHASE_CLOSED
void ActivateFishing()
const float LOW_PULL
const int FISH_PULL_CHANCE
const float MAX_FISHING_TIME
void DisplayState()
float m_DeltaT
int m_FishProximity
const float LOOSE_PULL
int m_ChanceRange
const float HIGH_PULL
ref Timer m_Cycler
void DeactivateFishing()
const int LOSS_BREAK
const float INIT_LINE_STRETCH
const int WIN
DayZPlayer m_Player
Definition Hand_Events.c:42
PlayerBase GetPlayer()
class JsonUndergroundAreaTriggerData GetPosition
proto native Object CreateObjectEx(string type, vector pos, int iFlags, int iRotation=RF_DEFAULT)
Creates object of certain type.
override bool IsOpen()
override void OnDebugSpawn()
float GetFishingEffectivityBonus()
void AnimateFishingRod(bool state)
override void SetActions()
override bool CanPutInCargo(EntityAI parent)
Definition GardenBase.c:288
override void SetActions()
Definition EnMath.c:7
override void Stop()
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].