Elin Decompiled Documentation EA 23.316 Nightly
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 && !owner.IsPC)
254 {
255 owner.TryPickGroundItem((Card t) => t.category.IsChildOf("fish") || t.SelfWeight <= 1000);
257 }
258 yield return Success();
259 }
260 if (owner.fov == null)
261 {
262 yield return Cancel();
263 }
264 List<Point> list = owner.fov.ListPoints();
265 foreach (Point p in list)
266 {
268 {
269 continue;
270 }
271 for (int _x = p.x - 1; _x <= p.x + 1; _x++)
272 {
273 for (int _z = p.z - 1; _z <= p.z + 1; _z++)
274 {
275 Point.shared.Set(_x, _z);
277 {
278 Point dest = Point.shared.Copy();
279 yield return DoGoto(dest);
280 owner.LookAt(dest);
281 yield return DoProgress();
282 yield return Status.Success;
283 }
284 }
285 }
286 }
287 }
288
289 public static Point GetFishingPoint(Point p)
290 {
291 Point point = new Point();
293 {
294 return Point.Invalid;
295 }
296 for (int i = p.x - 1; i <= p.x + 1; i++)
297 {
298 for (int j = p.z - 1; j <= p.z + 1; j++)
299 {
300 point.Set(i, j);
302 {
303 return point;
304 }
305 }
306 }
307 return Point.Invalid;
308 }
309
310 public static Thing Makefish(Chara c)
311 {
312 bool hqFever = c.IsPC && c.Evalue(1659) > 0 && EClass.player.fished < 5;
313 int num = c.Evalue(245);
314 if (!hqFever && EClass.rnd(3 + num) == 0)
315 {
316 return null;
317 }
318 if (hqFever)
319 {
320 c.PlayEffect("revive");
321 c.Say("fishingFever");
322 }
323 int[] array = new int[18]
324 {
325 233, 235, 236, 236, 236, 1170, 1143, 1144, 727, 728,
326 237, 869, 1178, 1179, 1180, 1243, 1244, 1245
327 };
328 Thing thing = null;
329 int num2 = 1;
330 string text = "";
331 int num3 = 0;
332 if (c.IsPC || EClass.rnd(20) == 0)
333 {
334 if (EClass.rnd(30) == 0)
335 {
336 text = "book_ancient";
337 }
338 if (EClass.rnd(40) == 0 && EClass.rnd(40) < num / 3 + 10)
339 {
340 text = "medal";
341 }
342 if (EClass.rnd(35) == 0)
343 {
344 text = "plat";
345 if (EClass.rnd(2) == 0)
346 {
347 text = "scratchcard";
348 }
349 if (EClass.rnd(3) == 0)
350 {
351 text = "casino_coin";
352 }
353 if (EClass.rnd(3) == 0)
354 {
355 text = "gacha_coin";
356 }
357 if (EClass.rnd(50) == 0)
358 {
359 text = new string[7] { "659", "758", "759", "806", "828", "1190", "1191" }.RandomItem();
360 if (!c.IsPC)
361 {
362 num3 = 10;
363 }
364 }
365 }
366 if (!c.IsPC)
367 {
368 if (text == "plat" || text == "medal")
369 {
370 num3 = 1;
371 }
372 if (num3 != 0)
373 {
374 if (EClass.rnd(EClass.player.fishArtifact + 1) <= 0)
375 {
376 EClass.player.fishArtifact += num3;
377 }
378 else
379 {
380 text = "";
381 }
382 }
383 }
384 }
385 if (!hqFever && text != "")
386 {
387 thing = ThingGen.Create(text, -1, EClass._zone.ContentLv);
388 }
389 else if (!hqFever && EClass.rnd(5 + num / 3) == 0)
390 {
391 thing = ThingGen.Create(array.RandomItem().ToString() ?? "");
392 }
393 else
394 {
395 SetFeverSeed();
396 int lv = EClass.rnd(num * 2) + 1;
397 int num4 = 0;
398 if (EClass.rnd(EClass.debug.enable ? 1 : (c.IsPC ? 5 : (c.IsPCFaction ? 250 : 2500))) == 0)
399 {
400 num4 = Mathf.Min(EClass.rnd(EClass.rnd(EClass.rnd(EClass.curve(num, 100, 50, 70) + 50))) / 50, 3);
401 }
402 if (hqFever && ((EClass.pc.Evalue(1659) >= 2 && EClass.player.fished == 0) || EClass.rnd(5) == 0))
403 {
404 num4++;
405 }
406 if (num4 > 3)
407 {
408 num4 = 3;
409 }
410 SetFeverSeed();
411 string text2 = "fish";
412 if (EClass._zone.id == "startVillage2")
413 {
414 text2 = "65";
415 }
416 thing = ThingGen.Create(text2, -1, lv);
417 SetFeverSeed();
418 int num5 = Mathf.Max(1, num / (thing.source.LV * 2 + 10));
419 int num6 = 5;
420 if (EClass.Branch != null)
421 {
422 num6 += EClass.Branch.Evalue(3604) * 20 + EClass.Branch.Evalue(3605) * 20 + EClass.Branch.Evalue(3606) * 20 + EClass.Branch.Evalue(3706) * 25;
423 }
424 if (EClass._zone is Zone_Kapul)
425 {
426 num6 = 35;
427 }
428 bool num7 = num6 >= EClass.rnd(100);
429 if (num7)
430 {
431 c.Say("bigCatch", c);
432 }
433 num2 = (num7 ? num5 : EClass.rnd(num5)) / (num4 + 1) + 1;
434 if (thing.id == "65" && EClass.rnd(EClass.debug.enable ? 2 : (c.IsPCParty ? 8192 : 819200)) == 0)
435 {
436 thing = ThingGen.Create("65_gold", -1, lv);
437 num2 = 1;
438 }
439 if (num4 != 0)
440 {
441 thing.SetTier(num4);
442 }
443 Rand.SetSeed();
444 }
445 if (thing != null)
446 {
448 {
449 num2 = 1;
450 }
451 if (num2 > 1)
452 {
453 thing.SetNum(num2);
454 }
455 thing.SetBlessedState(BlessedState.Normal);
456 }
457 if (c.IsPC)
458 {
460 }
461 return thing;
462 void SetFeverSeed()
463 {
464 if (hqFever)
465 {
467 }
468 }
469 }
470}
AnimeID
Definition: AnimeID.cs:2
BlessedState
Definition: BlessedState.cs:2
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:289
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:310
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:1017
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:4027
bool isDestroyed
Definition: Card.cs:78
bool IsPCFactionOrMinion
Definition: Card.cs:2326
int tier
Definition: Card.cs:413
ElementContainerCard elements
Definition: Card.cs:42
string id
Definition: Card.cs:36
int ChildrenWeight
Definition: Card.cs:2065
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6543
Thing Tool
Definition: Card.cs:2464
virtual int SelfWeight
Definition: Card.cs:2097
Fov fov
Definition: Card.cs:58
Thing SetNum(int a)
Definition: Card.cs:3653
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:4053
Point pos
Definition: Card.cs:60
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6577
void Destroy()
Definition: Card.cs:5268
ThingContainer things
Definition: Card.cs:39
int Evalue(int ele)
Definition: Card.cs:2688
int Dist(Card c)
Definition: Card.cs:8096
int ChildrenAndSelfWeight
Definition: Card.cs:2093
int Num
Definition: Card.cs:161
SourceCategory.Row category
Definition: Card.cs:2101
void ModNum(int a, bool notify=true)
Definition: Card.cs:3673
CardRenderer renderer
Definition: Card.cs:64
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6285
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7221
bool IsTopWaterAndNoSnow
Definition: Cell.cs:720
Definition: Chara.cs:10
void TryPickGroundItem(Func< Card, bool > func=null)
Definition: Chara.cs:4578
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9647
override bool IsPC
Definition: Chara.cs:630
override bool IsPCParty
Definition: Chara.cs:633
override int WeightLimit
Definition: Chara.cs:728
override bool IsPCFaction
Definition: Chara.cs:689
void TryClearInventory()
Definition: Chara.cs:8876
Stats stamina
Definition: Chara.cs:1181
override void LookAt(Card c)
Definition: Chara.cs:3670
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4460
bool enable
Definition: CoreDebug.cs:301
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:80
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:736
int days
Definition: Player.cs:75
Flags flags
Definition: Player.cs:1161
int fishArtifact
Definition: Player.cs:1035
Stats stats
Definition: Player.cs:1083
int fished
Definition: Player.cs:1032
int CountKeyItem(string alias)
Definition: Player.cs:2240
void TryEquipBait()
Definition: Player.cs:2354
Thing eqBait
Definition: Player.cs:1173
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:1259
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:100
virtual bool IsUserZone
Definition: Zone.cs:275
virtual bool IsUnderwater
Definition: Zone.cs:273
Card AddCard(Card t, Point point)
Definition: Zone.cs:2066