Elin Decompiled Documentation EA 23.102 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 {
81 if (hit < 100)
82 {
83 Fail();
84 return;
85 }
87 {
89 {
90 Msg.Say("noBait");
91 return;
92 }
94 }
95 Thing thing = Makefish(owner);
96 if (thing == null)
97 {
98 Fail();
99 return;
100 }
101 int num = thing.Num;
102 EClass._zone.AddCard(thing, owner.pos);
103 thing.renderer.PlayAnime(AnimeID.Jump);
104 owner.Say("fish_get", owner, thing);
105 owner.PlaySound("fish_get");
106 owner.elements.ModExp(245, 100);
107 if (thing.id == "medal")
108 {
109 thing.isHidden = false;
110 }
111 if (owner.IsPC)
112 {
114 {
116 {
117 EClass.pc.Say("tooHeavy", thing);
118 shouldCancel = true;
119 }
120 else
121 {
122 owner.Pick(thing);
123 }
124 }
125 }
126 else
127 {
128 foreach (Thing item in owner.things.List((Thing t) => t.source._origin == "fish"))
129 {
130 item.Destroy();
131 }
132 if (owner.things.IsFull())
133 {
134 thing.Destroy();
135 }
136 }
137 if (EClass.rnd(2) == 0 || num > 1)
138 {
139 owner.stamina.Mod(-1 * num);
140 }
141 }
142
143 public void Fail()
144 {
145 if (owner.IsPC)
146 {
147 owner.Say("fish_miss", owner);
148 }
149 owner.stamina.Mod(-1);
150 }
151 }
152
153 public Point pos;
154
155 public static bool shouldCancel;
156
157 public override int MaxRestart => 9999;
158
160
161 public override bool CanManualCancel()
162 {
163 return true;
164 }
165
166 public override bool CanPerform()
167 {
169 }
170
171 public override AIProgress CreateProgress()
172 {
173 return new ProgressFish
174 {
175 posWater = pos
176 };
177 }
178
179 public override IEnumerable<Status> Run()
180 {
181 if (!owner.IsPC)
182 {
184 }
185 if (pos != null)
186 {
188 {
189 yield return Cancel();
190 }
191 yield return DoGoto(pos, 1);
193 if (owner.IsPC)
194 {
196 if (EClass.player.eqBait == null)
197 {
198 Msg.Say("noBait");
199 yield return Cancel();
200 }
201 }
203 {
204 yield return Cancel();
205 }
207 if (shouldCancel)
208 {
209 shouldCancel = false;
210 yield return Cancel();
211 }
212 if (status == Status.Running)
213 {
214 yield return Status.Running;
215 }
216 if (owner == EClass.pc)
217 {
218 yield return Restart();
219 }
220 yield return DoWait(2);
221 if (owner != null)
222 {
223 if (!owner.IsPC)
224 {
226 }
228 {
230 }
231 }
232 yield return Success();
233 }
234 if (owner.fov == null)
235 {
236 yield return Cancel();
237 }
238 List<Point> list = owner.fov.ListPoints();
239 foreach (Point p in list)
240 {
242 {
243 continue;
244 }
245 for (int _x = p.x - 1; _x <= p.x + 1; _x++)
246 {
247 for (int _z = p.z - 1; _z <= p.z + 1; _z++)
248 {
249 Point.shared.Set(_x, _z);
251 {
252 Point dest = Point.shared.Copy();
253 yield return DoGoto(dest);
254 owner.LookAt(dest);
255 yield return DoProgress();
256 yield return Status.Success;
257 }
258 }
259 }
260 }
261 }
262
263 public static Point GetFishingPoint(Point p)
264 {
265 Point point = new Point();
267 {
268 return Point.Invalid;
269 }
270 for (int i = p.x - 1; i <= p.x + 1; i++)
271 {
272 for (int j = p.z - 1; j <= p.z + 1; j++)
273 {
274 point.Set(i, j);
275 if (point.IsValid && point.cell.IsTopWaterAndNoSnow)
276 {
277 return point;
278 }
279 }
280 }
281 return Point.Invalid;
282 }
283
284 public static Thing Makefish(Chara c)
285 {
286 int num = c.Evalue(245);
287 if (EClass.rnd(3 + num) == 0)
288 {
289 return null;
290 }
291 int[] array = new int[15]
292 {
293 233, 235, 236, 236, 236, 1170, 1143, 1144, 727, 728,
294 237, 869, 1178, 1179, 1180
295 };
296 Thing thing = null;
297 int num2 = 1;
298 string text = "";
299 if (c.IsPC || EClass.rnd(20) == 0)
300 {
301 if (EClass.rnd(30) == 0)
302 {
303 text = "book_ancient";
304 }
305 if (EClass.rnd(35) == 0 || EClass.debug.enable)
306 {
307 text = "plat";
308 if (EClass.rnd(2) == 0)
309 {
310 text = "scratchcard";
311 }
312 if (EClass.rnd(3) == 0)
313 {
314 text = "casino_coin";
315 }
316 if (EClass.rnd(3) == 0)
317 {
318 text = "gacha_coin";
319 }
320 if (EClass.rnd(50) == 0 || EClass.debug.enable)
321 {
322 text = new string[7] { "659", "758", "759", "806", "828", "1190", "1191" }.RandomItem();
323 }
324 }
325 if (EClass.rnd(40) == 0 && EClass.rnd(40) < num / 3 + 10)
326 {
327 text = "medal";
328 }
329 }
330 if (text != "")
331 {
332 thing = ThingGen.Create(text, -1, EClass._zone.ContentLv);
333 }
334 else if (EClass.rnd(5 + num / 3) == 0)
335 {
336 thing = ThingGen.Create(array.RandomItem().ToString() ?? "");
337 }
338 else
339 {
340 int num3 = EClass.rnd(num * 2) + 1;
341 thing = ThingGen.Create("fish", -1, num3);
342 num2 = EClass.rnd(num / (num3 + 10)) + 1;
343 int num4 = 5;
344 if (EClass.Branch != null)
345 {
346 num4 += EClass.Branch.Evalue(3604) * 20 + EClass.Branch.Evalue(3605) * 20 + EClass.Branch.Evalue(3706) * 25;
347 }
348 if (num4 >= EClass.rnd(100))
349 {
350 num2++;
351 }
352 }
353 if (thing != null)
354 {
355 thing.SetNum(num2);
356 thing.SetBlessedState(BlessedState.Normal);
357 }
358 return thing;
359 }
360}
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:157
override bool CanPerform()
Definition: AI_Fish.cs:166
static Point GetFishingPoint(Point p)
Definition: AI_Fish.cs:263
override AIProgress CreateProgress()
Definition: AI_Fish.cs:171
override bool CanManualCancel()
Definition: AI_Fish.cs:161
static bool shouldCancel
Definition: AI_Fish.cs:155
static Thing Makefish(Chara c)
Definition: AI_Fish.cs:284
override IEnumerable< Status > Run()
Definition: AI_Fish.cs:179
Point pos
Definition: AI_Fish.cs:153
Definition: ACT.cs:62
static Point TP
Definition: ACT.cs:81
void PlayAnime(AnimeID id, bool force)
bool isDestroyed
Definition: Card.cs:71
ElementContainerCard elements
Definition: Card.cs:37
string id
Definition: Card.cs:31
int ChildrenWeight
Definition: Card.cs:1889
bool HasElement(int ele, int req=1)
Definition: Card.cs:5214
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
Thing Tool
Definition: Card.cs:2270
Fov fov
Definition: Card.cs:53
Thing SetNum(int a)
Definition: Card.cs:3242
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:3572
Point pos
Definition: Card.cs:55
void Destroy()
Definition: Card.cs:4538
ThingContainer things
Definition: Card.cs:34
int Evalue(int ele)
Definition: Card.cs:2431
int Dist(Card c)
Definition: Card.cs:6777
int ChildrenAndSelfWeight
Definition: Card.cs:1917
int Num
Definition: Card.cs:154
void ModNum(int a, bool notify=true)
Definition: Card.cs:3262
CardRenderer renderer
Definition: Card.cs:57
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
bool IsTopWaterAndNoSnow
Definition: Cell.cs:712
Definition: Chara.cs:10
void TryPickGroundItem()
Definition: Chara.cs:4038
override bool IsPC
Definition: Chara.cs:597
override bool IsPCParty
Definition: Chara.cs:600
override int WeightLimit
Definition: Chara.cs:695
override bool IsPCFaction
Definition: Chara.cs:656
void ClearInventory(ClearInventoryType type)
Definition: Chara.cs:7768
Stats stamina
Definition: Chara.cs:955
override void LookAt(Card c)
Definition: Chara.cs:3219
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:3920
bool enable
Definition: CoreDebug.cs:285
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static int rnd(int a)
Definition: EClass.cs:50
static Zone _zone
Definition: EClass.cs:20
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, int 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
void TryEquipBait()
Definition: Player.cs:2060
Thing eqBait
Definition: Player.cs:907
Definition: Point.cs:9
static Point shared
Definition: Point.cs:20
static Point Invalid
Definition: Point.cs:28
Point Copy()
Definition: Point.cs:467
Point Set(int _x, int _z)
Definition: Point.cs:479
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:1217
bool IsValid
Definition: Point.cs:88
Cell cell
Definition: Point.cs:51
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
Card AddCard(Card t, Point point)
Definition: Zone.cs:1893