Dayz Explorer 1.28.160049
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
14 override bool GetActionWidgetOverride(out typename name)
15 {
16 PlayerBase owner;
17 if (Class.CastTo(owner,GetHierarchyRootPlayer()))
18 {
19 ActionFishingNew action;
20 if (Class.CastTo(action,owner.GetActionManager().GetRunningAction()) && owner.GetActionManager().GetActionState() == UA_PROCESSING)
21 {
23 return true;
24 }
25 }
26 return false;
27 }
28
29 override bool IsOpen()
30 {
31 return false;
32 }
33
34 void AnimateFishingRodEx(float phase, bool instant = false)
35 {
36 if (instant)
37 SetAnimationPhaseNow("AnimateRod",phase);
38 else
39 SetAnimationPhase("AnimateRod",phase);
40 }
41
42 override void OnDebugSpawn()
43 {
44 ItemBase hook;
45 for (int i = 0; i < 6; ++i)
46 {
47 if (Class.CastTo(hook,GetGame().CreateObjectEx("Hook", GetPosition(), ECE_PLACE_ON_SURFACE)))
48 hook.GetInventory().CreateAttachment("Worm");
49 }
50
51 if (Class.CastTo(hook,GetInventory().CreateAttachment("Hook")))
52 hook.GetInventory().CreateAttachment("Worm");
53 }
54
56
58 float GetFishingEffectivityBonus()
59 {
60 return 0.0;
61 }
62
64 void AnimateFishingRod(bool state)
65 {
66 AnimateFishingRodEx(state);
67 }
68}
69
71{
72 const string ANIM_PHASE_OPENED = "OpenRod";
73 const string ANIM_PHASE_CLOSED = "CloseRod";
74
75 const float BREAK_PULL = 36;
76 const float TOO_MUCH_PULL = 32;
77 const float HIGH_PULL = 22;
78 const float LOW_PULL = 18;
79 const float TOO_FEW_PULL = 8;
80 const float LOOSE_PULL = 0;
81 const int LOSS_BREAK = 0;
82 const int LOSS_LOOSE = 1;
83 const int WIN = 2;
84 const int INTERUPTED = 3;
85 const float INIT_LINE_STRETCH = 15;
86 const float MIN_FISHING_TIME = 100;
87 const float MAX_FISHING_TIME = 150;
88 const int FISH_PULL_CHANCE = 15;
89 const int FISH_AGILITY = 15;
90
95 float m_Pull;
96 float m_DeltaT;
104
106 {
107 m_Fishing = false;
108 }
109
110 void Init()
111 {
112 m_Player = PlayerBase.Cast( GetGame().GetPlayer() );
114 m_IsFishPulling = false;
115 //TIMERDEPRECATED - randomized time of fishing
119 //TIMERDEPRECATED
120 if(!m_Cycler)
121 {
122 m_Cycler = new Timer();
123 }
125 {
126 m_CyclerCatching = new Timer();
127 }
128 m_CyclerCatching.Run(4, this, "Catching", NULL,true);
129 m_Player.Message("I have started fishing.", "colorFriendly");
130 }
131
133 {
134 return m_Fishing;
135 }
136
138 {
139 m_Fishing = true;
140 //Init();
141 }
142
144 {
146 }
147
148
149
150 void FishPull()
151 {
152 if ( !m_IsFishPulling )
153 {
154 float rand = Math.RandomInt(1, FISH_PULL_CHANCE);
156 {
157 //TIMERDEPRECATED - randomizing timeframe to pull fish out
158 if ( Math.RandomInt(0, 1) )
159 {
160 m_FishPull = rand;
161 }
162 else
163 {
164 m_FishPull = -rand;
165 }
166 //TIMERDEPRECATED - randomizing timeframe to pull fish out
167 m_PullTime = Math.RandomInt(2, 6);
168 m_IsFishPulling = true;
169 }
170 }
171 else
172 {
173 m_PullTime--;
174 if (m_PullTime == 0)
175 {
176 m_IsFishPulling = false;
177 }
178 }
179 }
180
181 void Catching()
182 {
183 if(m_FishProximity == 0 && m_WasPulled)
184 {
185 m_CyclerCatching.Stop();
186 m_Cycler.Run(0.3, this, "Pulling", NULL,true);
187 }
188 else
189 {
190 if (m_WasPulled)
191 {
192 m_WasPulled = false;
194 }
195 //TIMERDEPRECATED - randomized proximity of fish to
196 m_FishProximity = Math.RandomInt(0,m_ChanceRange);
197 string fline = "";
198 for (int i = 0; i < m_FishProximity; i++)
199 {
200 fline += " .";
201 }
202 m_Player.Message("", "colorStatusChannel");
203 m_Player.Message("HOLD right mouse button to pull the fishing line", "colorAction");
204 m_Player.Message("", "colorStatusChannel");
205 m_Player.Message("", "colorStatusChannel");
206 m_Player.Message("", "colorStatusChannel");
207 m_Player.Message("Start pulling when J and <*)))>< meet:", "colorStatusChannel");
208 m_Player.Message("", "colorStatusChannel");
209 m_Player.Message("J"+fline+" <*)))><", "colorImportant");
210 if(m_ChanceRange > 0)
211 {
213 }
214 }
215 }
216
217 void Pulling()
218 {
219 float agent_speed_distance = vector.Distance("0 0 0",m_Player.GetModelSpeed());
220 if (m_Player.GetItemInHands() != this || !m_Player.IsInWater() || agent_speed_distance > 1 )
221 {
223 }
224 else
225 {
226 if ( m_FishingTime <= 0)
227 {
228 ItemBase pcatch = ItemBase.Cast( m_Player.GetInventory().CreateInInventory("Carp") );
229 //ItemBase pcatch = ItemBase.Cast( m_Player.CreateInInventory("Carp","cargo_bait") );
230 pcatch.SetQuantity(800,false);
231 End(WIN);
232 }
233 else
234 {
235 FishPull();
236 if ( m_IsFishPulling )
237 {
239 }
240 if (m_WasPulled)
241 {
242 m_Pull += 1;
243 }
244 else
245 {
246 m_Pull -= 1;
247 }
248 m_WasPulled = false;
250 DisplayState();
251 if ( m_Pull <= LOOSE_PULL)
252 {
254 }
255 if ( m_Pull >= BREAK_PULL)
256 {
258 }
259 }
260 }
261 }
262
263 void End( int result )
264 {
265 m_Cycler.Stop();
266 m_CyclerCatching.Stop();
267 m_Fishing = false;
268
269 switch (result)
270 {
271 case LOSS_BREAK:
272 m_Player.Message("", "colorStatusChannel");
273 m_Player.Message("", "colorStatusChannel");
274 m_Player.Message("", "colorStatusChannel");
275 m_Player.Message("The fish had broken the fishing line and swam away.", "colorImportant");
276 m_Player.Message("", "colorStatusChannel");
277 m_Player.Message("", "colorStatusChannel");
278 m_Player.Message("", "colorStatusChannel");
279 m_Player.Message("", "colorStatusChannel");
280 break;
281
282 case LOSS_LOOSE:
283 m_Player.Message("", "colorStatusChannel");
284 m_Player.Message("", "colorStatusChannel");
285 m_Player.Message("", "colorStatusChannel");
286 m_Player.Message("The fish escaped.", "colorImportant");
287 m_Player.Message("", "colorStatusChannel");
288 m_Player.Message("", "colorStatusChannel");
289 m_Player.Message("", "colorStatusChannel");
290 m_Player.Message("", "colorStatusChannel");
291 break;
292
293 case WIN:
294 m_Player.Message("", "colorStatusChannel");
295 m_Player.Message("", "colorStatusChannel");
296 m_Player.Message("", "colorStatusChannel");
297 m_Player.Message("I caught the fish!", "colorFriendly");
298 m_Player.Message("", "colorStatusChannel");
299 m_Player.Message("", "colorStatusChannel");
300 m_Player.Message("", "colorStatusChannel");
301 m_Player.Message("", "colorStatusChannel");
302 break;
303
304 case INTERUPTED:
305 m_Player.Message("", "colorStatusChannel");
306 m_Player.Message("", "colorStatusChannel");
307 m_Player.Message("", "colorStatusChannel");
308 m_Player.Message("Fishing time is over.", "colorFriendly");
309 m_Player.Message("", "colorStatusChannel");
310 m_Player.Message("", "colorStatusChannel");
311 m_Player.Message("", "colorStatusChannel");
312 m_Player.Message("", "colorStatusChannel");
313 break;
314
315 default:
316 Print("Wrong number");
317 break;
318 }
319 }
320
321 void AddPull(float delta)
322 {
323 m_DeltaT = delta;
324 m_WasPulled = true;
325 }
326
328 {
329 string fline = "";
330 for (int i = 0; i < m_Pull; i++)
331 {
332 fline += "-";
333 }
334 m_Player.Message("", "colorStatusChannel");
335 m_Player.Message("HOLD right mouse button to pull the fishing line", "colorAction");
336 m_Player.Message("RELEASE right mouse button to loosen the fishing line", "colorAction");
337 m_Player.Message("", "colorStatusChannel");
338 m_Player.Message("", "colorStatusChannel");
339 m_Player.Message("Fishing line stretch :", "colorStatusChannel");
340 m_Player.Message("", "colorStatusChannel");
341 if (m_Pull >= TOO_MUCH_PULL)
342 {
343 m_Player.Message("<"+fline+">", "colorImportant");
344 }
346 {
347 m_Player.Message("<"+fline+">", "colorAction");
348 }
350 {
351 m_Player.Message("<"+fline+">", "colorFriendly");
352 }
354 {
355 m_Player.Message("<"+fline+">", "colorStatusChannel");
356 }
357 if (m_Pull <= TOO_FEW_PULL)
358 {
359 m_Player.Message("<"+fline+">", "colorImportant");
360 }
361 }
362
363 // Conditions
364 override bool CanPutInCargo( EntityAI parent )
365 {
366 if( !super.CanPutInCargo(parent) ) {return false;}
367 if ( GetAnimationPhase(ANIM_PHASE_CLOSED) > 0.5 )
368 {
369 return true;
370 }
371 return false;
372 }
373
374 override void SetActions()
375 {
376 super.SetActions();
377
378 //AddAction(ActionToggleFishing);
379 //AddAction(ActionFishingNew);
380 }
381
383 {
384 return 0.0;
385 }
386}
void AddAction(typename actionName)
void SetActions()
const int ECE_PLACE_ON_SURFACE
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Super root of all classes in Enforce script.
Definition enscript.c:11
Definition enmath.c:7
override Widget Init()
Definition dayzgame.c:127
void End()
called on surrender end request end
override bool CanPutInCargo(EntityAI parent)
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
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
class JsonUndergroundAreaTriggerData GetPosition
const int UA_PROCESSING
Definition constants.c:464
DayZPlayer m_Player
Definition hand_events.c:42
PlayerBase GetPlayer()