Elin Decompiled Documentation EA 23.220 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 (owner.IsPC)
117 {
119 {
121 {
122 EClass.pc.Say("tooHeavy", thing);
123 shouldCancel = true;
124 }
125 else
126 {
127 owner.Pick(thing);
128 }
129 }
130 }
131 else
132 {
133 foreach (Thing item in owner.things.List((Thing t) => t.source._origin == "fish"))
134 {
135 item.Destroy();
136 }
137 if (owner.things.IsFull())
138 {
139 thing.Destroy();
140 }
141 }
142 if (traitToolFishing != null)
143 {
144 num = num * 100 / (50 + traitToolFishing.owner.material.hardness * 2);
145 }
146 if (EClass.rnd(2) == 0 || num > 1)
147 {
148 owner.stamina.Mod(Mathf.Min(-1, -num));
149 }
150 }
151
152 public void Fail()
153 {
154 if (owner.IsPC)
155 {
156 owner.Say("fish_miss", owner);
157 }
158 owner.stamina.Mod(-1);
159 }
160 }
161
162 public Point pos;
163
164 public static bool shouldCancel;
165
166 public override int MaxRestart => 9999;
167
169
170 public override bool CanManualCancel()
171 {
172 return true;
173 }
174
175 public override bool CanPerform()
176 {
178 {
180 }
181 return true;
182 }
183
184 public override AIProgress CreateProgress()
185 {
186 return new ProgressFish
187 {
188 posWater = pos
189 };
190 }
191
192 public override IEnumerable<Status> Run()
193 {
194 if (!owner.IsPC)
195 {
197 }
198 if (pos != null)
199 {
201 {
202 yield return Cancel();
203 }
204 yield return DoGoto(pos, 1);
206 if (owner.IsPC)
207 {
209 if (EClass.player.eqBait == null)
210 {
211 Msg.Say("noBait");
212 yield return Cancel();
213 }
214 }
216 {
217 yield return Cancel();
218 }
220 if (shouldCancel)
221 {
222 shouldCancel = false;
223 yield return Cancel();
224 }
225 if (status == Status.Running)
226 {
227 yield return Status.Running;
228 }
229 if (owner == EClass.pc)
230 {
231 yield return Restart();
232 }
233 yield return DoWait(2);
234 if (owner != null)
235 {
236 if (!owner.IsPC)
237 {
239 }
241 {
243 }
244 }
245 yield return Success();
246 }
247 if (owner.fov == null)
248 {
249 yield return Cancel();
250 }
251 List<Point> list = owner.fov.ListPoints();
252 foreach (Point p in list)
253 {
255 {
256 continue;
257 }
258 for (int _x = p.x - 1; _x <= p.x + 1; _x++)
259 {
260 for (int _z = p.z - 1; _z <= p.z + 1; _z++)
261 {
262 Point.shared.Set(_x, _z);
264 {
265 Point dest = Point.shared.Copy();
266 yield return DoGoto(dest);
267 owner.LookAt(dest);
268 yield return DoProgress();
269 yield return Status.Success;
270 }
271 }
272 }
273 }
274 }
275
276 public static Point GetFishingPoint(Point p)
277 {
278 Point point = new Point();
280 {
281 return Point.Invalid;
282 }
283 for (int i = p.x - 1; i <= p.x + 1; i++)
284 {
285 for (int j = p.z - 1; j <= p.z + 1; j++)
286 {
287 point.Set(i, j);
289 {
290 return point;
291 }
292 }
293 }
294 return Point.Invalid;
295 }
296
297 public static Thing Makefish(Chara c)
298 {
299 bool hqFever = c.IsPC && c.Evalue(1659) > 0 && EClass.player.fished < 5;
300 int num = c.Evalue(245);
301 if (!hqFever && EClass.rnd(3 + num) == 0)
302 {
303 return null;
304 }
305 if (hqFever)
306 {
307 c.PlayEffect("revive");
308 c.Say("fishingFever");
309 }
310 int[] array = new int[18]
311 {
312 233, 235, 236, 236, 236, 1170, 1143, 1144, 727, 728,
313 237, 869, 1178, 1179, 1180, 1243, 1244, 1245
314 };
315 Thing thing = null;
316 int num2 = 1;
317 string text = "";
318 int num3 = 0;
319 if (c.IsPC || EClass.rnd(20) == 0)
320 {
321 if (EClass.rnd(30) == 0)
322 {
323 text = "book_ancient";
324 }
325 if (EClass.rnd(40) == 0 && EClass.rnd(40) < num / 3 + 10)
326 {
327 text = "medal";
328 }
329 if (EClass.rnd(35) == 0)
330 {
331 text = "plat";
332 if (EClass.rnd(2) == 0)
333 {
334 text = "scratchcard";
335 }
336 if (EClass.rnd(3) == 0)
337 {
338 text = "casino_coin";
339 }
340 if (EClass.rnd(3) == 0)
341 {
342 text = "gacha_coin";
343 }
344 if (EClass.rnd(50) == 0)
345 {
346 text = new string[7] { "659", "758", "759", "806", "828", "1190", "1191" }.RandomItem();
347 if (!c.IsPC)
348 {
349 num3 = 10;
350 }
351 }
352 }
353 if (!c.IsPC)
354 {
355 if (text == "plat" || text == "medal")
356 {
357 num3 = 1;
358 }
359 if (num3 != 0)
360 {
361 if (EClass.rnd(EClass.player.fishArtifact + 1) <= 0)
362 {
363 EClass.player.fishArtifact += num3;
364 }
365 else
366 {
367 text = "";
368 }
369 }
370 }
371 }
372 if (!hqFever && text != "")
373 {
374 thing = ThingGen.Create(text, -1, EClass._zone.ContentLv);
375 }
376 else if (!hqFever && EClass.rnd(5 + num / 3) == 0)
377 {
378 thing = ThingGen.Create(array.RandomItem().ToString() ?? "");
379 }
380 else
381 {
382 SetFeverSeed();
383 int lv = EClass.rnd(num * 2) + 1;
384 int num4 = 0;
385 if (EClass.rnd(EClass.debug.enable ? 1 : (c.IsPC ? 5 : (c.IsPCFaction ? 250 : 2500))) == 0)
386 {
387 num4 = Mathf.Min(EClass.rnd(EClass.rnd(EClass.rnd(EClass.curve(num, 100, 50, 70) + 50))) / 50, 3);
388 }
389 if (hqFever && ((EClass.pc.Evalue(1659) >= 2 && EClass.player.fished == 0) || EClass.rnd(5) == 0))
390 {
391 num4++;
392 }
393 if (num4 > 3)
394 {
395 num4 = 3;
396 }
397 SetFeverSeed();
398 thing = ThingGen.Create("fish", -1, lv);
399 SetFeverSeed();
400 int num5 = Mathf.Max(1, num / (thing.source.LV * 2 + 10));
401 int num6 = 5;
402 if (EClass.Branch != null)
403 {
404 num6 += EClass.Branch.Evalue(3604) * 20 + EClass.Branch.Evalue(3605) * 20 + EClass.Branch.Evalue(3606) * 20 + EClass.Branch.Evalue(3706) * 25;
405 }
406 if (EClass._zone is Zone_Kapul)
407 {
408 num6 = 35;
409 }
410 bool num7 = num6 >= EClass.rnd(100);
411 if (num7)
412 {
413 c.Say("bigCatch", c);
414 }
415 num2 = (num7 ? num5 : EClass.rnd(num5)) / (num4 + 1) + 1;
416 if (num4 != 0)
417 {
418 thing.SetTier(num4);
419 }
420 Rand.SetSeed();
421 }
422 if (thing != null)
423 {
425 {
426 num2 = 1;
427 }
428 if (num2 > 1)
429 {
430 thing.SetNum(num2);
431 }
432 thing.SetBlessedState(BlessedState.Normal);
433 }
434 if (c.IsPC)
435 {
437 }
438 return thing;
439 void SetFeverSeed()
440 {
441 if (hqFever)
442 {
444 }
445 }
446 }
447}
AnimeID
Definition: AnimeID.cs:2
BlessedState
Definition: BlessedState.cs:2
ClearInventoryType
Definition: AIAct.cs:6
virtual Status Cancel()
Definition: AIAct.cs:291
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:532
Status DoProgress()
Definition: AIAct.cs:517
Status DoGoto(Point pos, int dist=0, bool ignoreConnection=false, Func< Status > _onChildFail=null)
Definition: AIAct.cs:432
Status Restart()
Definition: AIAct.cs:237
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:166
override bool CanPerform()
Definition: AI_Fish.cs:175
static Point GetFishingPoint(Point p)
Definition: AI_Fish.cs:276
override AIProgress CreateProgress()
Definition: AI_Fish.cs:184
override bool CanManualCancel()
Definition: AI_Fish.cs:170
static bool shouldCancel
Definition: AI_Fish.cs:164
static Thing Makefish(Chara c)
Definition: AI_Fish.cs:297
override IEnumerable< Status > Run()
Definition: AI_Fish.cs:192
Point pos
Definition: AI_Fish.cs:162
Definition: ACT.cs:62
static Point TP
Definition: ACT.cs:81
void PlayAnime(AnimeID id, bool force)
void SetTier(int a, bool setTraits=true)
Definition: Card.cs:3799
bool isDestroyed
Definition: Card.cs:75
bool IsPCFactionOrMinion
Definition: Card.cs:2260
int tier
Definition: Card.cs:410
ElementContainerCard elements
Definition: Card.cs:41
string id
Definition: Card.cs:35
int ChildrenWeight
Definition: Card.cs:2001
bool HasElement(int ele, int req=1)
Definition: Card.cs:5787
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6009
Thing Tool
Definition: Card.cs:2398
Fov fov
Definition: Card.cs:57
Thing SetNum(int a)
Definition: Card.cs:3425
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:3825
Point pos
Definition: Card.cs:59
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6043
void Destroy()
Definition: Card.cs:4981
ThingContainer things
Definition: Card.cs:38
int Evalue(int ele)
Definition: Card.cs:2559
int Dist(Card c)
Definition: Card.cs:7500
int ChildrenAndSelfWeight
Definition: Card.cs:2029
int Num
Definition: Card.cs:158
void ModNum(int a, bool notify=true)
Definition: Card.cs:3445
CardRenderer renderer
Definition: Card.cs:61
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6661
bool IsTopWaterAndNoSnow
Definition: Cell.cs:712
Definition: Chara.cs:10
void TryPickGroundItem()
Definition: Chara.cs:4349
override bool IsPC
Definition: Chara.cs:610
override bool IsPCParty
Definition: Chara.cs:613
override int WeightLimit
Definition: Chara.cs:708
override bool IsPCFaction
Definition: Chara.cs:669
void ClearInventory(ClearInventoryType type)
Definition: Chara.cs:8312
Stats stamina
Definition: Chara.cs:1140
override void LookAt(Card c)
Definition: Chara.cs:3501
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4231
bool enable
Definition: CoreDebug.cs:286
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:68
static Zone _zone
Definition: EClass.cs:20
static int rnd(long a)
Definition: EClass.cs:58
static FactionBranch Branch
Definition: EClass.cs:22
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
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:96
Config config
Definition: Game.cs:215
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 days
Definition: Player.cs:75
int fishArtifact
Definition: Player.cs:965
Stats stats
Definition: Player.cs:1013
int fished
Definition: Player.cs:962
void TryEquipBait()
Definition: Player.cs:2262
Thing eqBait
Definition: Player.cs:1103
Definition: Point.cs:9
static Point shared
Definition: Point.cs:20
static Point Invalid
Definition: Point.cs:28
Point Copy()
Definition: Point.cs:479
Point Set(int _x, int _z)
Definition: Point.cs:491
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:1241
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:37
override int GetPhase()
Definition: StatsBurden.cs:17
virtual void Mod(int a)
Definition: Stats.cs:135
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:95
virtual bool IsUserZone
Definition: Zone.cs:268
virtual bool IsUnderwater
Definition: Zone.cs:266
Card AddCard(Card t, Point point)
Definition: Zone.cs:1950