Elin Decompiled Documentation EA 23.286 Nightly Patch 1
Loading...
Searching...
No Matches
AI_Fish.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class AI_Fish : AIAct
5{
6 public class ProgressFish : AIProgress
7 {
8 public int hit = -1;
9
11
12 public override bool ShowProgress => false;
13
14 public override int MaxProgress => 100;
15
16 public override int LeftHand => -1;
17
18 public override int RightHand => 1107;
19
20 public override void OnStart()
21 {
22 if (!shouldCancel)
23 {
24 owner.PlaySound("fish_cast");
25 if (owner.Tool != null)
26 {
27 owner.Say("fish_start", owner, owner.Tool);
28 }
29 else
30 {
31 owner.Say("fish_start2", owner);
32 }
33 }
34 }
35
36 public override void OnProgress()
37 {
38 if (owner.IsPC && (owner.Tool == null || !owner.Tool.HasElement(245)))
39 {
40 Cancel();
41 }
42 else if (hit >= 0)
43 {
45 owner.PlaySound("fish_fight");
46 Ripple();
47 int a = Mathf.Clamp(10 - EClass.rnd(owner.Evalue(245) + 1) / 10, 5, 10);
48 if (hit > EClass.rnd(a))
49 {
50 hit = 100;
52 }
53 hit++;
54 }
55 else
56 {
57 if (EClass.rnd(Mathf.Clamp(10 - EClass.rnd(owner.Evalue(245) + 1) / 5, 2, 10)) == 0 && progress >= 10)
58 {
59 hit = 0;
60 }
61 if (progress == 2 || (progress >= 8 && progress % 6 == 0 && EClass.rnd(3) == 0))
62 {
64 Ripple();
65 }
66 }
67 }
68
69 public void Ripple()
70 {
71 if (posWater != null)
72 {
73 Effect.Get("ripple").Play(posWater, -0.04f);
74 posWater.PlaySound("fish_splash");
75 }
76 }
77
78 public override void OnProgressComplete()
79 {
80 TraitToolFishing traitToolFishing = owner.FindTool<TraitToolFishing>();
82 if (hit < 100)
83 {
84 Fail();
85 return;
86 }
88 {
90 {
91 Msg.Say("noBait");
92 return;
93 }
95 }
96 Thing thing = Makefish(owner);
97 if (thing == null)
98 {
99 Fail();
100 return;
101 }
102 int num = thing.Num;
103 if (!owner.IsPC)
104 {
105 num += 5;
106 }
107 EClass._zone.AddCard(thing, owner.pos);
108 thing.renderer.PlayAnime(AnimeID.Jump);
109 owner.Say("fish_get", owner, thing);
110 owner.PlaySound("fish_get");
111 owner.elements.ModExp(245, thing.tier * 200 + 80 + EClass.curve(thing.Num, 5, 75) * 20);
112 if (thing.id == "medal")
113 {
114 thing.isHidden = false;
115 }
116 if (EClass.rnd(EClass.debug.enable ? 2 : 1000) == 0 && thing.category.IsChildOf("fish"))
117 {
118 owner.PlayEffect("fizzle");
119 if (owner.IsPC)
120 {
121 owner.PlaySound("escape");
122 owner.Say("fish_ehe");
123 owner.Say("fish_ehe2");
124 owner.Say("fish_ehe3");
127 if (EClass.rnd(777) == 0)
128 {
130 ActEffect.Proc(EffectId.Wish, EClass.pc, null, 50 + EClass.player.CountKeyItem("well_enhance") * 50 + EClass.player.flags.fishStolen * 50);
131 }
132 }
133 thing.Destroy();
134 }
135 else if (owner.IsPC)
136 {
138 {
140 {
141 EClass.pc.Say("tooHeavy", thing);
142 shouldCancel = true;
143 }
144 else
145 {
146 owner.Pick(thing);
147 }
148 }
149 }
150 else if (!owner.IsPCParty)
151 {
152 foreach (Thing item in owner.things.List((Thing t) => t.source._origin == "fish"))
153 {
154 item.Destroy();
155 }
156 if (owner.things.IsFull())
157 {
158 thing.Destroy();
159 }
160 }
161 if (traitToolFishing != null)
162 {
163 num = num * 100 / (50 + traitToolFishing.owner.material.hardness * 2);
164 }
165 if (EClass.rnd(2) == 0 || num > 1)
166 {
167 owner.stamina.Mod(Mathf.Min(-1, -num));
168 }
169 }
170
171 public void Fail()
172 {
173 if (owner.IsPC)
174 {
175 owner.Say("fish_miss", owner);
176 }
177 owner.stamina.Mod(-1);
178 }
179 }
180
181 public Point pos;
182
183 public static bool shouldCancel;
184
185 public override int MaxRestart => 9999;
186
188
189 public override bool CanManualCancel()
190 {
191 return true;
192 }
193
194 public override bool CanPerform()
195 {
197 {
199 }
200 return true;
201 }
202
203 public override AIProgress CreateProgress()
204 {
205 return new ProgressFish
206 {
207 posWater = pos
208 };
209 }
210
211 public override IEnumerable<Status> Run()
212 {
213 if (!owner.IsPC)
214 {
215 owner.TryPickGroundItem((Card t) => t.category.IsChildOf("fish") || t.SelfWeight <= 1000);
216 }
217 if (pos != null)
218 {
220 {
221 yield return Cancel();
222 }
223 yield return DoGoto(pos, 1);
225 if (owner.IsPC)
226 {
228 if (EClass.player.eqBait == null)
229 {
230 Msg.Say("noBait");
231 yield return Cancel();
232 }
233 }
235 {
236 yield return Cancel();
237 }
239 if (shouldCancel)
240 {
241 shouldCancel = false;
242 yield return Cancel();
243 }
244 if (status == Status.Running)
245 {
246 yield return Status.Running;
247 }
248 if (owner == EClass.pc)
249 {
250 yield return Restart();
251 }
252 yield return DoWait(2);
253 if (owner != null)
254 {
255 if (!owner.IsPC)
256 {
257 owner.TryPickGroundItem((Card t) => t.category.IsChildOf("fish") || t.SelfWeight <= 1000);
258 }
260 {
262 }
263 }
264 yield return Success();
265 }
266 if (owner.fov == null)
267 {
268 yield return Cancel();
269 }
270 List<Point> list = owner.fov.ListPoints();
271 foreach (Point p in list)
272 {
274 {
275 continue;
276 }
277 for (int _x = p.x - 1; _x <= p.x + 1; _x++)
278 {
279 for (int _z = p.z - 1; _z <= p.z + 1; _z++)
280 {
281 Point.shared.Set(_x, _z);
283 {
284 Point dest = Point.shared.Copy();
285 yield return DoGoto(dest);
286 owner.LookAt(dest);
287 yield return DoProgress();
288 yield return Status.Success;
289 }
290 }
291 }
292 }
293 }
294
295 public static Point GetFishingPoint(Point p)
296 {
297 Point point = new Point();
299 {
300 return Point.Invalid;
301 }
302 for (int i = p.x - 1; i <= p.x + 1; i++)
303 {
304 for (int j = p.z - 1; j <= p.z + 1; j++)
305 {
306 point.Set(i, j);
308 {
309 return point;
310 }
311 }
312 }
313 return Point.Invalid;
314 }
315
316 public static Thing Makefish(Chara c)
317 {
318 bool hqFever = c.IsPC && c.Evalue(1659) > 0 && EClass.player.fished < 5;
319 int num = c.Evalue(245);
320 if (!hqFever && EClass.rnd(3 + num) == 0)
321 {
322 return null;
323 }
324 if (hqFever)
325 {
326 c.PlayEffect("revive");
327 c.Say("fishingFever");
328 }
329 int[] array = new int[18]
330 {
331 233, 235, 236, 236, 236, 1170, 1143, 1144, 727, 728,
332 237, 869, 1178, 1179, 1180, 1243, 1244, 1245
333 };
334 Thing thing = null;
335 int num2 = 1;
336 string text = "";
337 int num3 = 0;
338 if (c.IsPC || EClass.rnd(20) == 0)
339 {
340 if (EClass.rnd(30) == 0)
341 {
342 text = "book_ancient";
343 }
344 if (EClass.rnd(40) == 0 && EClass.rnd(40) < num / 3 + 10)
345 {
346 text = "medal";
347 }
348 if (EClass.rnd(35) == 0)
349 {
350 text = "plat";
351 if (EClass.rnd(2) == 0)
352 {
353 text = "scratchcard";
354 }
355 if (EClass.rnd(3) == 0)
356 {
357 text = "casino_coin";
358 }
359 if (EClass.rnd(3) == 0)
360 {
361 text = "gacha_coin";
362 }
363 if (EClass.rnd(50) == 0)
364 {
365 text = new string[7] { "659", "758", "759", "806", "828", "1190", "1191" }.RandomItem();
366 if (!c.IsPC)
367 {
368 num3 = 10;
369 }
370 }
371 }
372 if (!c.IsPC)
373 {
374 if (text == "plat" || text == "medal")
375 {
376 num3 = 1;
377 }
378 if (num3 != 0)
379 {
380 if (EClass.rnd(EClass.player.fishArtifact + 1) <= 0)
381 {
382 EClass.player.fishArtifact += num3;
383 }
384 else
385 {
386 text = "";
387 }
388 }
389 }
390 }
391 if (!hqFever && text != "")
392 {
393 thing = ThingGen.Create(text, -1, EClass._zone.ContentLv);
394 }
395 else if (!hqFever && EClass.rnd(5 + num / 3) == 0)
396 {
397 thing = ThingGen.Create(array.RandomItem().ToString() ?? "");
398 }
399 else
400 {
401 SetFeverSeed();
402 int lv = EClass.rnd(num * 2) + 1;
403 int num4 = 0;
404 if (EClass.rnd(EClass.debug.enable ? 1 : (c.IsPC ? 5 : (c.IsPCFaction ? 250 : 2500))) == 0)
405 {
406 num4 = Mathf.Min(EClass.rnd(EClass.rnd(EClass.rnd(EClass.curve(num, 100, 50, 70) + 50))) / 50, 3);
407 }
408 if (hqFever && ((EClass.pc.Evalue(1659) >= 2 && EClass.player.fished == 0) || EClass.rnd(5) == 0))
409 {
410 num4++;
411 }
412 if (num4 > 3)
413 {
414 num4 = 3;
415 }
416 SetFeverSeed();
417 string text2 = "fish";
418 if (EClass._zone.id == "startVillage2")
419 {
420 text2 = "65";
421 }
422 thing = ThingGen.Create(text2, -1, lv);
423 SetFeverSeed();
424 int num5 = Mathf.Max(1, num / (thing.source.LV * 2 + 10));
425 int num6 = 5;
426 if (EClass.Branch != null)
427 {
428 num6 += EClass.Branch.Evalue(3604) * 20 + EClass.Branch.Evalue(3605) * 20 + EClass.Branch.Evalue(3606) * 20 + EClass.Branch.Evalue(3706) * 25;
429 }
430 if (EClass._zone is Zone_Kapul)
431 {
432 num6 = 35;
433 }
434 bool num7 = num6 >= EClass.rnd(100);
435 if (num7)
436 {
437 c.Say("bigCatch", c);
438 }
439 num2 = (num7 ? num5 : EClass.rnd(num5)) / (num4 + 1) + 1;
440 if (thing.id == "65" && EClass.rnd(EClass.debug.enable ? 2 : (c.IsPCParty ? 8192 : 819200)) == 0)
441 {
442 thing = ThingGen.Create("65_gold", -1, lv);
443 num2 = 1;
444 }
445 if (num4 != 0)
446 {
447 thing.SetTier(num4);
448 }
449 Rand.SetSeed();
450 }
451 if (thing != null)
452 {
454 {
455 num2 = 1;
456 }
457 if (num2 > 1)
458 {
459 thing.SetNum(num2);
460 }
461 thing.SetBlessedState(BlessedState.Normal);
462 }
463 if (c.IsPC)
464 {
466 }
467 return thing;
468 void SetFeverSeed()
469 {
470 if (hqFever)
471 {
473 }
474 }
475 }
476}
AnimeID
Definition: AnimeID.cs:2
BlessedState
Definition: BlessedState.cs:2
ClearInventoryType
EffectId
Definition: EffectId.cs:2
ID_Achievement
Definition: AIAct.cs:6
virtual Status Cancel()
Definition: AIAct.cs:305
Status status
Definition: AIAct.cs:16
new Chara owner
Definition: AIAct.cs:14
Status
Definition: AIAct.cs:8
Status DoWait(int count=1)
Definition: AIAct.cs:546
Status DoProgress()
Definition: AIAct.cs:531
Status DoGoto(Point pos, int dist=0, bool ignoreConnection=false, Func< Status > _onChildFail=null)
Definition: AIAct.cs:446
Status Restart()
Definition: AIAct.cs:251
int progress
Definition: AIProgress.cs:5
override int MaxProgress
Definition: AI_Fish.cs:14
override bool ShowProgress
Definition: AI_Fish.cs:12
override void OnProgressComplete()
Definition: AI_Fish.cs:78
override int RightHand
Definition: AI_Fish.cs:18
override void OnProgress()
Definition: AI_Fish.cs:36
override int LeftHand
Definition: AI_Fish.cs:16
override void OnStart()
Definition: AI_Fish.cs:20
override int MaxRestart
Definition: AI_Fish.cs:185
override bool CanPerform()
Definition: AI_Fish.cs:194
static Point GetFishingPoint(Point p)
Definition: AI_Fish.cs:295
override AIProgress CreateProgress()
Definition: AI_Fish.cs:203
override bool CanManualCancel()
Definition: AI_Fish.cs:189
static bool shouldCancel
Definition: AI_Fish.cs:183
static Thing Makefish(Chara c)
Definition: AI_Fish.cs:316
override IEnumerable< Status > Run()
Definition: AI_Fish.cs:211
Point pos
Definition: AI_Fish.cs:181
static void Proc(EffectId id, Card cc, Card tc=null, int power=100, ActRef actRef=default(ActRef))
Definition: ActEffect.cs:1035
Definition: ACT.cs:62
static Point TP
Definition: ACT.cs:81
void PlayAnime(AnimeID id, bool force)
Definition: Card.cs:11
void SetTier(int a, bool setTraits=true)
Definition: Card.cs:3951
bool isDestroyed
Definition: Card.cs:76
bool IsPCFactionOrMinion
Definition: Card.cs:2312
int tier
Definition: Card.cs:411
ElementContainerCard elements
Definition: Card.cs:42
string id
Definition: Card.cs:36
int ChildrenWeight
Definition: Card.cs:2051
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6375
Thing Tool
Definition: Card.cs:2450
virtual int SelfWeight
Definition: Card.cs:2083
Fov fov
Definition: Card.cs:58
Thing SetNum(int a)
Definition: Card.cs:3577
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:3977
Point pos
Definition: Card.cs:60
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6409
void Destroy()
Definition: Card.cs:5164
ThingContainer things
Definition: Card.cs:39
int Evalue(int ele)
Definition: Card.cs:2611
int Dist(Card c)
Definition: Card.cs:7901
int ChildrenAndSelfWeight
Definition: Card.cs:2079
int Num
Definition: Card.cs:159
SourceCategory.Row category
Definition: Card.cs:2087
void ModNum(int a, bool notify=true)
Definition: Card.cs:3597
CardRenderer renderer
Definition: Card.cs:62
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6122
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7052
bool IsTopWaterAndNoSnow
Definition: Cell.cs:712
Definition: Chara.cs:10
void TryPickGroundItem(Func< Card, bool > func=null)
Definition: Chara.cs:4499
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9451
override bool IsPC
Definition: Chara.cs:626
override bool IsPCParty
Definition: Chara.cs:629
override int WeightLimit
Definition: Chara.cs:724
override bool IsPCFaction
Definition: Chara.cs:685
void ClearInventory(ClearInventoryType type)
Definition: Chara.cs:8724
Stats stamina
Definition: Chara.cs:1172
override void LookAt(Card c)
Definition: Chara.cs:3597
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4381
bool enable
Definition: CoreDebug.cs:286
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static int curve(long _a, int start, int step, int rate=75)
Definition: EClass.cs:69
static Zone _zone
Definition: EClass.cs:21
static int rnd(long a)
Definition: EClass.cs:59
static FactionBranch Branch
Definition: EClass.cs:23
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
Definition: Effect.cs:7
static Effect Get(Effect original)
Definition: Effect.cs:85
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
Definition: Effect.cs:100
void ModExp(int ele, float a, bool chain=false)
int Evalue(int ele)
List< Point > ListPoints()
Definition: Fov.cs:114
ConfigPreference preference
Definition: Game.cs:97
Config config
Definition: Game.cs:219
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
int fishStolen
Definition: Player.cs:724
int days
Definition: Player.cs:75
Flags flags
Definition: Player.cs:1149
int fishArtifact
Definition: Player.cs:1023
Stats stats
Definition: Player.cs:1071
int fished
Definition: Player.cs:1020
int CountKeyItem(string alias)
Definition: Player.cs:2228
void TryEquipBait()
Definition: Player.cs:2342
Thing eqBait
Definition: Player.cs:1161
Definition: Point.cs:9
static Point shared
Definition: Point.cs:20
static Point Invalid
Definition: Point.cs:28
Point Copy()
Definition: Point.cs:491
Point Set(int _x, int _z)
Definition: Point.cs:503
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
SoundSource PlaySound(string id, bool synced=true, float v=1f, bool spatial=true)
Definition: Point.cs:1253
bool IsValid
Definition: Point.cs:88
Cell cell
Definition: Point.cs:51
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:44
string id
Definition: Spatial.cs:13
override int GetPhase()
Definition: StatsBurden.cs:17
virtual void Mod(int a)
Definition: Stats.cs:135
Definition: Steam.cs:10
static void GetAchievement(ID_Achievement id)
Definition: Steam.cs:51
static TargetTypeGround Ground
Definition: TargetType.cs:15
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
bool IsFull(int y=0)
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
override int ContentLv
Definition: Zone.cs:98
virtual bool IsUserZone
Definition: Zone.cs:273
virtual bool IsUnderwater
Definition: Zone.cs:271
Card AddCard(Card t, Point point)
Definition: Zone.cs:2014