Elin Modding Docs Doc
Loading...
Searching...
No Matches
AI_Idle.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
5
6// Token: 0x020001EC RID: 492
7public class AI_Idle : AIAct
8{
9 // Token: 0x170003A1 RID: 929
10 // (get) Token: 0x06000E0E RID: 3598 RVA: 0x0006A9AB File Offset: 0x00068BAB
11 public override bool IsIdle
12 {
13 get
14 {
15 return !base.IsChildRunning;
16 }
17 }
18
19 // Token: 0x170003A2 RID: 930
20 // (get) Token: 0x06000E0F RID: 3599 RVA: 0x0006A9B6 File Offset: 0x00068BB6
21 public override bool InformCancel
22 {
23 get
24 {
25 return false;
26 }
27 }
28
29 // Token: 0x170003A3 RID: 931
30 // (get) Token: 0x06000E10 RID: 3600 RVA: 0x0006A9B9 File Offset: 0x00068BB9
31 public override int MaxRestart
32 {
33 get
34 {
35 return this.maxRepeat;
36 }
37 }
38
39 // Token: 0x06000E11 RID: 3601 RVA: 0x0006A9C1 File Offset: 0x00068BC1
40 public override void OnStart()
41 {
42 this.owner.SetTempHand(-1, -1);
43 this.owner.ShowEmo(Emo.none, 0f, true);
44 }
45
46 // Token: 0x06000E12 RID: 3602 RVA: 0x0006A9E2 File Offset: 0x00068BE2
47 public unsafe override IEnumerable<AIAct.Status> Run()
48 {
49 for (;;)
50 {
51 if (this.owner.held != null)
52 {
53 this.owner.PickHeld(false);
54 }
55 if (this.owner.nextUse != null)
56 {
57 Thing nextUse = this.owner.nextUse;
58 this.owner.nextUse = null;
59 if (nextUse.parent == this.owner && !nextUse.isDestroyed)
60 {
61 this.owner.TryUse(nextUse);
62 }
63 yield return base.KeepRunning();
64 }
65 if (EClass.rnd(100) == 0 && this.owner.hunger.GetPhase() >= 3)
66 {
67 Thing thing = this.owner.things.Find((Thing a) => this.owner.CanEat(a, this.owner.IsPCFaction), false);
68 if (thing == null && this.owner.IsPCFaction)
69 {
70 thing = this.owner.things.Find((Thing a) => this.owner.CanEat(a, false), false);
71 }
72 if (thing == null && this.owner.IsPCFaction && EClass._zone.IsPCFaction)
73 {
74 thing = EClass._zone.branch.GetMeal(this.owner);
75 if (thing != null)
76 {
77 this.owner.Pick(thing, true, true);
78 }
79 }
80 if (thing == null && !this.owner.IsPCParty)
81 {
82 if (!this.owner.IsPCFaction && EClass.rnd(8) != 0)
83 {
84 this.owner.hunger.Mod(-30);
85 }
86 else
87 {
88 thing = ThingGen.CreateFromCategory("food", EClass.rnd(EClass.rnd(60) + 1) + 10);
89 thing.isNPCProperty = true;
90 if ((thing.ChildrenAndSelfWeight < 5000 || !this.owner.IsPCParty) && thing.trait.CanEat(this.owner))
91 {
92 thing = this.owner.AddThing(thing, true, -1, -1);
93 }
94 }
95 }
96 if (thing != null)
97 {
98 yield return base.Do(new AI_Eat
99 {
100 target = thing
101 }, null);
102 }
103 }
104 if (EClass.rnd(3) == 0 && this.owner.mana.value > 0)
105 {
106 Act act = null;
107 Act actRevive = null;
108 foreach (ActList.Item item in this.owner.ability.list.items)
109 {
110 Act act2 = item.act;
111 if (act2.id == 8430)
112 {
113 actRevive = act2;
114 }
115 string[] abilityType = act2.source.abilityType;
116 if (!abilityType.IsEmpty() && (abilityType[0] == "heal" || abilityType[0] == "hot"))
117 {
118 act = item.act;
119 }
120 }
121 if (act != null)
122 {
123 List<Chara> list;
124 if (!this.owner.IsPCParty)
125 {
126 (list = new List<Chara>()).Add(this.owner);
127 }
128 else
129 {
130 list = EClass.pc.party.members;
131 }
132 List<Chara> list2 = list;
133 foreach (Chara chara in list2)
134 {
135 if ((float)chara.hp <= (float)chara.MaxHP * 0.75f && this.owner.CanSeeLos(chara, -1, false) && (!(act.source.abilityType[0] == "hot") || !chara.HasCondition<ConHOT>()))
136 {
137 this.owner.UseAbility(act, chara, null, false);
138 yield return base.KeepRunning();
139 break;
140 }
141 }
142 List<Chara>.Enumerator enumerator2 = default(List<Chara>.Enumerator);
143 }
144 if (actRevive != null)
145 {
146 if ((from a in EClass.game.cards.globalCharas
147 where a.Value.isDead && a.Value.faction == EClass.pc.faction && !a.Value.isSummon && a.Value.GetInt(103, null) != 0
148 select a).ToList<KeyValuePair<int, Chara>>().Count > 0 && this.owner.UseAbility(actRevive.source.alias, this.owner, null, false))
149 {
150 yield return base.KeepRunning();
151 }
152 }
153 actRevive = null;
154 }
155 if (this.owner.IsPCFaction && EClass._zone.IsPCFaction)
156 {
157 this.owner.sharedCheckTurn--;
158 if (this.owner.sharedCheckTurn < 0 && EClass.rnd(EClass.debug.enable ? 2 : 20) == 0)
159 {
160 this.owner.TryTakeSharedItems(true);
161 this.owner.TryPutSharedItems(true);
162 this.owner.sharedCheckTurn += (EClass.debug.enable ? 20 : 200);
163 }
164 }
165 if ((EClass._zone is Zone_Civilized || EClass._zone.IsPCFaction) && (this.owner.IsPCParty ? 10 : (this.owner.IsPCFaction ? 2 : 0)) > EClass.rnd(100))
166 {
167 Thing thing2 = this.owner.things.Find("polish_powder", -1, -1);
168 if (thing2 != null && EClass._map.props.installed.Find<TraitGrindstone>() != null)
169 {
170 foreach (Thing thing3 in this.owner.things)
171 {
172 if (thing3.IsEquipment && thing3.encLV < 0)
173 {
174 int num = 0;
175 while (num < 5 && thing3.encLV < 0)
176 {
177 this.owner.Say("polish", this.owner, thing3, null, null);
178 thing3.ModEncLv(1);
179 thing2.ModNum(-1, true);
180 if (thing2.isDestroyed)
181 {
182 break;
183 }
184 num++;
185 }
186 if (thing2.isDestroyed)
187 {
188 break;
189 }
190 }
191 }
192 }
193 }
194 if (this.owner.IsPCParty)
195 {
196 if (this.owner.IsRestrainedResident && this.owner.stamina.value > this.owner.stamina.max / 2)
197 {
198 this.owner.SetAI(new AI_Torture
199 {
200 shackle = this.owner.pos.FindThing<TraitShackle>()
201 });
202 yield return base.Restart();
203 }
204 if (EClass.rnd(100) == 0 && !EClass._zone.IsRegion && this.owner.HasElement(1227, 1))
205 {
206 List<Chara> list3 = new List<Chara>();
207 foreach (Chara chara2 in EClass.pc.party.members)
208 {
209 if (chara2.Evalue(1227) > 0)
210 {
211 list3.Add(chara2);
212 }
213 }
214 if (list3.Count > 2)
215 {
216 list3.Remove(this.owner);
217 this.owner.SetEnemy(list3.RandomItem<Chara>());
218 yield return base.Success(null);
219 }
220 }
221 if (EClass.rnd(150) == 0 && this.owner.host != null && this.owner.host.parasite == this.owner && this.owner.GetInt(108, null) == 1)
222 {
223 this.owner.host.PlaySound("whip", 1f, true);
224 this.owner.host.Say("use_whip3", this.owner, this.owner.host, null, null);
225 this.owner.Talk("insult", null, null, false);
226 this.owner.host.PlayAnime(AnimeID.Shiver, false);
227 this.owner.host.DamageHP(5 + EClass.rndHalf(this.owner.host.MaxHP / 5), 919, 100, AttackSource.Condition, null, true);
228 this.owner.host.OnInsulted();
229 yield return base.KeepRunning();
230 }
231 if (EClass.rnd(EClass.debug.enable ? 2 : 20) == 0 && this.owner.CanSee(EClass.pc))
232 {
233 this.owner.TryTakeSharedItems(EClass.pc.things.List((Thing t) => t.IsSharedContainer, false), true, false);
234 }
235 if (this.owner.isSynced && EClass.rnd((this.owner.host == null) ? 200 : 150) == 0 && this.owner.GetInt(106, null) == 0)
236 {
237 if (EClass.rnd(2) == 0 && this.owner.GetInt(108, null) == 1)
238 {
239 this.owner.Talk("insult", null, null, false);
240 }
241 else
242 {
243 this.owner.TalkTopic("calm");
244 }
245 }
246 if (EClass.rnd(100) == 0 && EClass._zone.IsTown)
247 {
248 this.owner.ClearInventory(ClearInventoryType.Party);
249 }
250 if ((EClass.rnd(20) == 0 || EClass.debug.enable) && this.owner.GetCurrency("money") >= 500)
251 {
252 bool flag = EClass._zone.IsTown;
253 if (EClass._zone.IsPCFaction)
254 {
255 foreach (Chara chara3 in EClass._zone.branch.members)
256 {
257 if (chara3.ExistsOnMap && chara3.trait is TraitTrainer)
258 {
259 flag = true;
260 }
261 }
262 }
263 if (flag)
264 {
265 bool flag2 = false;
266 foreach (Element element in this.owner.elements.dict.Values)
267 {
268 if (!(element.source.category != "skill") && element.vTempPotential < 900)
269 {
270 flag2 = true;
271 break;
272 }
273 }
274 if (flag2)
275 {
276 int num2 = this.owner.GetCurrency("money");
277 if (num2 >= 20000)
278 {
279 num2 = 20000;
280 }
281 this.owner.PlaySound("pay", 1f, true);
282 int num3 = num2 / 200;
283 foreach (Element element2 in this.owner.elements.dict.Values)
284 {
285 if (!(element2.source.category != "skill"))
286 {
287 int num4 = num3 * 100 / (100 + (100 + element2.vTempPotential / 2 + element2.ValueWithoutLink) * (100 + element2.vTempPotential / 2 + element2.ValueWithoutLink) / 100);
288 num4 += 1 + EClass.rnd(3);
289 this.owner.elements.ModTempPotential(element2.id, Mathf.Max(1, num4), 9999);
290 }
291 }
292 Msg.Say("party_train", this.owner, Lang._currency(num2, false, 14), null, null);
293 this.owner.PlaySound("ding_potential", 1f, true);
294 this.owner.ModCurrency(-num2, "money");
295 }
296 }
297 }
298 }
299 if (this.owner.c_uidMaster != 0)
300 {
301 Chara chara4 = this.owner.master;
302 if (chara4 == null || !chara4.IsAliveInCurrentZone)
303 {
304 chara4 = this.owner.FindMaster();
305 }
306 if (chara4 != null && chara4.IsAliveInCurrentZone)
307 {
308 if (this.owner.enemy == null)
309 {
310 this.owner.SetEnemy(chara4.enemy);
311 }
312 int num5 = this.owner.Dist(chara4.pos);
313 if (this.owner.source.aiIdle != "root" && num5 > EClass.game.config.tactics.AllyDistance(this.owner) && EClass._zone.PetFollow && this.owner.c_minionType == MinionType.Default)
314 {
315 this.owner.TryMoveTowards(chara4.pos);
316 yield return base.KeepRunning();
317 continue;
318 }
319 }
320 }
321 Party party = this.owner.party;
322 if (party == null || party.leader == this.owner || !party.leader.IsAliveInCurrentZone || this.owner.host != null || !EClass._zone.PetFollow)
323 {
324 break;
325 }
326 if (this.owner.source.aiIdle == "root")
327 {
328 yield return base.KeepRunning();
329 }
330 else if (this.owner.Dist(party.leader.pos) <= EClass.game.config.tactics.AllyDistance(this.owner))
331 {
332 yield return base.KeepRunning();
333 }
334 else
335 {
336 if (this.owner.TryMoveTowards(party.leader.pos) == Card.MoveResult.Fail && this.owner.Dist(party.leader) > 4)
337 {
338 this.moveFailCount++;
339 bool flag3 = (EClass._zone is Zone_Civilized || EClass._zone.IsPCFaction) && (EClass.pc.enemy == null || !EClass.pc.enemy.IsAliveInCurrentZone);
340 if (this.moveFailCount >= (flag3 ? 100 : 10))
341 {
342 this.owner.Teleport(party.leader.pos.GetNearestPoint(false, false, true, true), false, true);
343 this.moveFailCount = 0;
344 }
345 }
346 else
347 {
348 this.moveFailCount = 0;
349 }
350 yield return base.KeepRunning();
351 }
352 }
353 if (((this.owner.homeBranch != null && this.owner.homeBranch == EClass.Branch && EClass.rnd(100) == 0) || (this.owner.IsGuest() && EClass.rnd(50) == 0)) && this.owner.FindBed() == null)
354 {
355 this.owner.TryAssignBed();
356 }
357 if (this.owner.isSynced && !this.owner.IsPCParty)
358 {
359 if (this.owner.IsPCFaction && this.owner.GetInt(32, null) + 4320 < EClass.world.date.GetRaw(0))
360 {
361 if (this.owner.GetInt(32, null) != 0 && Zone.okaerinko < 10)
362 {
363 this.owner.Talk("welcomeBack", null, null, false);
364 Zone.okaerinko++;
365 }
366 this.owner.SetInt(32, EClass.world.date.GetRaw(0));
367 }
368 else if (EClass.player.stats.turns > this.owner.turnLastSeen + 50 && Los.IsVisible(EClass.pc, this.owner) && this.owner.CanSee(EClass.pc))
369 {
370 if (EClass._zone.IsTown && EClass.rnd(15) == 0 && this.owner.hostility >= Hostility.Neutral && !this.owner.IsPCFaction && !EClass.pc.HasCondition<ConIncognito>())
371 {
372 bool flag4 = EClass._zone is Zone_Derphy;
373 string text = (EClass.player.karma <= 10) ? (flag4 ? "rumor_good" : "rumor_bad") : ((EClass.player.karma >= 90) ? (flag4 ? "rumor_bad" : "rumor_good") : "");
374 if (!text.IsEmpty())
375 {
376 this.owner.Talk(text, null, null, false);
377 }
378 if ((flag4 ? (EClass.player.karma >= 90) : (EClass.player.karma <= 10)) && EClass.rnd(10) == 0)
379 {
380 Thing t3 = ThingGen.Create("stone", -1, -1);
381 AI_PlayMusic.ignoreDamage = true;
382 ActThrow.Throw(this.owner, EClass.pc.pos, t3, ThrowMethod.Punish, 0f);
383 AI_PlayMusic.ignoreDamage = false;
384 }
385 }
386 else
387 {
388 this.owner.TalkTopic("fov");
389 }
390 this.owner.turnLastSeen = EClass.player.stats.turns;
391 }
392 }
393 if (EClass.rnd(25) == 0 && this.owner.IsInMutterDistance(10))
394 {
395 if (this.owner.isRestrained)
396 {
397 this.owner.PlayAnime(AnimeID.Shiver, false);
398 }
399 TCText tc = this.owner.HostRenderer.GetTC<TCText>();
400 if (tc == null || tc.pop.items.Count == 0)
401 {
402 if (this.owner.noMove)
403 {
404 foreach (Thing thing4 in this.owner.pos.Things)
405 {
406 if (thing4.IsInstalled && thing4.trait is TraitGeneratorWheel)
407 {
408 this.owner.Talk("labor", null, null, false);
409 this.owner.PlayAnime(AnimeID.Shiver, false);
410 yield return base.Restart();
411 }
412 }
413 List<Thing>.Enumerator enumerator6 = default(List<Thing>.Enumerator);
414 }
415 if (this.owner.isDrunk && (this.owner.race.id == "cat" || this.owner.id == "sailor"))
416 {
417 this.owner.Talk("drunk_cat", null, null, false);
418 }
419 else if (this.owner.isRestrained)
420 {
421 this.owner.Talk("restrained", null, null, false);
422 }
423 else if (this.owner.GetInt(106, null) == 0 && !this.owner.IsPCParty)
424 {
425 if (this.owner.HasElement(1232, 1) && EClass.rnd(4) == 0)
426 {
427 this.owner.Talk("baby", null, null, false);
428 }
429 else if (EClass.rnd((this.owner.host == null) ? 2 : 10) == 0 && this.owner.isSynced && this.owner.TalkTopic("calm").IsEmpty())
430 {
431 this.owner.Talk("idle", null, null, false);
432 }
433 }
434 }
435 }
436 if (EClass.rnd(8) == 0 && this.owner.race.id == "chicken")
437 {
438 this.owner.PlaySound("Animal/Chicken/chicken", 1f, true);
439 }
440 if (EClass.rnd(80) == 0 && this.owner.race.id == "cat")
441 {
442 this.owner.PlaySound("Animal/Cat/cat", 1f, true);
443 }
444 if (this.owner.trait.IdAmbience != null && this.owner.IsInMutterDistance(15))
445 {
446 float mtp = 1f;
447 Room room = this.owner.Cell.room;
448 Room room2 = EClass.pc.Cell.room;
449 if (room != room2 && room2 != null)
450 {
451 if (((room != null) ? room.lot : null) == ((room2 != null) ? room2.lot : null))
452 {
453 mtp = 0.7f;
454 }
455 else
456 {
457 mtp = 0.4f;
458 }
459 }
460 EClass.Sound.PlayAmbience(this.owner.trait.IdAmbience, *this.owner.pos.Position(), mtp);
461 }
462 if (EClass.rnd(2000) == 0 && this.owner.IsHuman && (this.owner.host == null || this.owner.host.ride != this.owner))
463 {
464 Thing thing5 = this.owner.things.Find((Thing a) => !a.IsNegativeGift && a.trait.CanDrink(this.owner), false);
465 if (thing5 != null && thing5.trait is TraitPotion && this.owner.IsPCParty)
466 {
467 thing5 = null;
468 }
469 if (thing5 == null && (this.owner.homeBranch == null || !this.owner.homeBranch.policies.IsActive(2503, -1)))
470 {
471 thing5 = ThingGen.Create("crimAle", -1, -1);
472 this.owner.Drink(thing5);
473 }
474 if (thing5 != null && !thing5.isDestroyed)
475 {
476 this.owner.TryUse(thing5);
477 yield return base.Restart();
478 }
479 }
480 if (EClass.rnd(this.owner.IsPCParty ? 1000 : 200) == 0 && this.owner.isDrunk && (this.owner.isSynced || EClass.rnd(5) == 0))
481 {
482 this.DoSomethingToCharaInRadius(3, null, delegate(Chara c)
483 {
484 this.owner.Say("drunk_mess", this.owner, c, null, null);
485 this.owner.Talk("drunk_mess", null, null, false);
486 bool flag5 = EClass.rnd(5) == 0 && !c.IsPC;
487 if (c.IsPCParty && this.owner.hostility >= Hostility.Friend)
488 {
489 flag5 = false;
490 }
491 if (flag5)
492 {
493 this.owner.Say("drunk_counter", c, this.owner, null, null);
494 c.Talk("drunk_counter", null, null, false);
495 c.DoHostileAction(this.owner, false);
496 }
497 });
498 }
499 if (EClass.rnd(100) == 0 && this.owner.trait.CanFish)
500 {
501 Point fishingPoint = AI_Fish.GetFishingPoint(this.owner.pos);
502 if (fishingPoint.IsValid)
503 {
504 yield return base.Do(new AI_Fish
505 {
506 pos = fishingPoint
507 }, null);
508 }
509 }
510 string idAct = this.owner.source.actIdle.RandomItem<string>();
511 if (EClass.rnd(EClass.world.date.IsNight ? 1500 : 15000) == 0 && !this.owner.IsPCFaction && !this.owner.noMove)
512 {
513 this.owner.AddCondition<ConSleep>(1000 + EClass.rnd(1000), true);
514 }
515 if (EClass.rnd(40) == 0 && this.owner.IsHuman)
516 {
517 this.DoSomethingToNearChara((Chara c) => (!c.IsPCParty || EClass.rnd(5) == 0) && c.IsMofuable && !this.owner.IsHostile(c) && !c.IsInCombat, delegate(Chara c)
518 {
519 this.owner.Cuddle(c, false);
520 });
521 }
522 if (EClass.rnd(100) == 0 && this.owner.trait is TraitBitch)
523 {
524 Chara chara5 = this.DoSomethingToNearChara((Chara c) => c.IsIdle && !c.IsPCParty && !(c.trait is TraitBitch), null);
525 if (chara5 != null)
526 {
527 yield return base.Do(new AI_Fuck
528 {
529 target = chara5,
530 bitch = true
531 }, null);
532 }
533 }
534 if (EClass.rnd(50) == 0 && this.owner.trait is TraitBard)
535 {
536 yield return base.Do(new AI_PlayMusic(), null);
537 }
538 if (EClass.rnd(4) == 0 && this.TryPerformIdleUse())
539 {
540 yield return base.Restart();
541 }
542 if (EClass.rnd(20) == 0 && this.owner.trait.IdleAct())
543 {
544 yield return base.Restart();
545 }
546 if (idAct == "janitor" && EClass.rnd(5) == 0)
547 {
548 this.DoSomethingToCharaInRadius(4, null, delegate(Chara c)
549 {
550 if (c.HasElement(1211, 1) && !(EClass._zone is Zone_Casino))
551 {
552 this.owner.Talk("snail", null, null, false);
553 Thing t4 = ThingGen.Create("1142", -1, -1);
554 ActThrow.Throw(this.owner, c.pos, t4, ThrowMethod.Default, 0f);
555 }
556 });
557 yield return base.Restart();
558 }
559 if (this.owner.IsRestrainedResident && this.owner.stamina.value > this.owner.stamina.max / 2)
560 {
561 this.owner.SetAI(new AI_Torture
562 {
563 shackle = this.owner.pos.FindThing<TraitShackle>()
564 });
565 yield return base.Restart();
566 }
567 if (!this.owner.IsPCFactionOrMinion && EClass.rnd(this.owner.isSynced ? 50 : 2000) == 0 && this.owner.hostility == Hostility.Neutral && EClass.pc.party.HasElement(1563) && !this.owner.race.tag.Contains("animal") && EClass._zone.IsTown && !EClass._zone.IsPCFaction)
568 {
569 EClass.pc.DoHostileAction(this.owner, false);
570 }
571 if (EClass.rnd(200) == 0)
572 {
573 Point cleanPoint = AI_Clean.GetCleanPoint(this.owner, 4, 10);
574 if (cleanPoint != null)
575 {
576 yield return base.Do(new AI_Clean
577 {
578 pos = cleanPoint
579 }, null);
580 }
581 }
582 if (EClass.rnd(35) == 0 && this.owner.id == "child" && this.owner.pos.cell.IsSnowTile)
583 {
584 foreach (Chara chara6 in EClass._map.charas)
585 {
586 if (EClass.rnd(3) != 0 && chara6 != this.owner && chara6.pos.cell.IsSnowTile && chara6.Dist(this.owner) <= 6 && Los.IsVisible(chara6, this.owner))
587 {
588 Thing t2 = ThingGen.Create("snow", -1, -1);
589 ActThrow.Throw(this.owner, chara6.pos, t2, ThrowMethod.Default, 0f);
590 break;
591 }
592 }
593 }
594 if (EClass.rnd(EClass.debug.enable ? 3 : 30) == 0)
595 {
596 Thing thing6 = this.owner.things.Find<TraitBall>();
597 if (thing6 == null)
598 {
599 this.owner.pos.ForeachNeighbor(delegate(Point p)
600 {
601 TraitBall traitBall = p.FindThing<TraitBall>();
602 Card card = (traitBall != null) ? traitBall.owner : null;
603 if (card != null)
604 {
605 this.owner.Pick(card.Thing, true, true);
606 }
607 }, true);
608 }
609 else
610 {
611 foreach (Chara chara7 in EClass._map.charas)
612 {
613 if (EClass.rnd(3) != 0 && chara7 != this.owner && chara7.Dist(this.owner) <= 6 && chara7.Dist(this.owner) >= 3 && Los.IsVisible(chara7, this.owner))
614 {
615 ActThrow.Throw(this.owner, chara7.pos, thing6, ThrowMethod.Default, 0f);
616 break;
617 }
618 }
619 }
620 }
621 if (EClass.rnd(20) == 0 && AI_Shopping.TryShop(this.owner, true))
622 {
623 yield return base.Restart();
624 }
625 if (EClass.rnd(20) == 0 && this.owner.IsPCFaction && AI_Shopping.TryRestock(this.owner, true))
626 {
627 yield return base.Restart();
628 }
629 this.owner.idleActTimer--;
630 string a2;
631 if (this.owner.idleActTimer <= 0 && !this.owner.source.actIdle.IsEmpty())
632 {
633 this.owner.idleActTimer = 10 + EClass.rnd(50);
634 a2 = idAct;
635 if (!(a2 == "torture_snail"))
636 {
637 if (!(a2 == "buffMage"))
638 {
639 if (!(a2 == "buffThief"))
640 {
641 if (!(a2 == "buffGuildWatch"))
642 {
643 if (!(a2 == "buffHealer"))
644 {
645 if (!(a2 == "readBook"))
646 {
647 if (LangGame.Has("idle_" + idAct))
648 {
649 this.IdleActText(idAct);
650 }
651 }
652 else if (EClass.rnd(2) != 0 && (!this.owner.IsPCParty || EClass.rnd(20) == 0))
653 {
654 List<Thing> list4 = this.owner.things.List((Thing a) => a.parent == this.owner && (a.category.id == "spellbook" || a.category.id == "ancientbook"), false);
655 Thing thing7 = null;
656 if (list4.Count > 0)
657 {
658 thing7 = list4.RandomItem<Thing>();
659 if (!thing7.trait.CanRead(this.owner))
660 {
661 thing7 = null;
662 }
663 }
664 if (thing7 == null)
665 {
666 thing7 = ThingGen.CreateFromCategory((EClass.rnd(5) != 0) ? "spellbook" : "ancientbook", -1);
667 thing7.isNPCProperty = true;
668 }
669 if (!(thing7.id == "1084") || !this.owner.IsPCFaction)
670 {
671 if (!this.owner.HasElement(285, 1))
672 {
673 this.owner.elements.ModBase(285, 1);
674 }
675 yield return base.Do(new AI_Read
676 {
677 target = thing7
678 }, null);
679 }
680 }
681 }
682 else
683 {
684 this.TryCast(EffectId.Heal, 100);
685 }
686 }
687 else
688 {
689 this.TryCast<ConGravity>(EffectId.Gravity, 300 + EClass.rnd(300));
690 }
691 }
692 else
693 {
694 this.TryCast<ConNightVision>(EffectId.CatsEye, 100 + EClass.rnd(100));
695 }
696 }
697 else if (EClass.rnd(2) == 0)
698 {
699 this.TryCast<ConHolyVeil>(EffectId.HolyVeil, 300 + EClass.rnd(300));
700 }
701 else
702 {
703 this.TryCast<ConLevitate>(EffectId.Levitate, 300 + EClass.rnd(300));
704 }
705 }
706 else
707 {
708 this.DoSomethingToNearChara((Chara c) => c.race.id == "snail", delegate(Chara c)
709 {
710 this.owner.Say("use_whip3", this.owner, c, null, null);
711 this.owner.PlaySound("whip", 1f, true);
712 this.owner.Talk("insult", null, null, false);
713 c.PlayAnime(AnimeID.Shiver, false);
714 c.OnInsulted();
715 });
716 }
717 yield return base.Restart();
718 }
719 if (this.owner.host != null)
720 {
721 yield return base.Restart();
722 }
723 if (this.owner.HasEditorTag(EditorTag.AINoMove) || this.owner.trait.IdleBehaviour == AI_Idle.Behaviour.NoMove || this.owner.noMove)
724 {
725 if (this.owner.orgPos != null && !this.owner.pos.Equals(this.owner.orgPos) && !this.owner.orgPos.IsBlocked && !this.owner.orgPos.HasChara)
726 {
727 yield return base.DoGoto(this.owner.orgPos, 0, false, null);
728 }
729 yield return base.Restart();
730 }
731 if (this.owner.HasEditorTag(EditorTag.AIFollow) && this.owner.pos.Distance(EClass.pc.GetDestination()) > 1)
732 {
733 yield return base.DoGoto(EClass.pc, null);
734 }
735 if (EClass.rnd(100) == 0 && !this.owner.IsPCFaction)
736 {
737 if (this.owner.id == "ashland" || this.owner.id == "fiama")
738 {
739 Trait trait = EClass._map.Installed.traits.restSpots.RandomItem<int, Trait>();
740 if (trait != null)
741 {
742 yield return base.DoGotoSpot(trait.owner, null);
743 }
744 else
745 {
746 Room room3 = this.owner.FindRoom();
747 if (room3 != null)
748 {
749 yield return base.DoGoto(room3.GetRandomPoint(true, true).GetNearestPoint(false, true, true, false), 0, false, null);
750 }
751 }
752 }
753 else if (this.owner.orgPos != null && !this.owner.pos.Equals(this.owner.orgPos) && !this.owner.orgPos.IsBlocked && !this.owner.orgPos.HasChara)
754 {
755 yield return base.DoGoto(this.owner.orgPos, 0, false, null);
756 }
757 }
758 if (EClass.rnd(100) == 0 && this.owner.id == "bee")
759 {
760 List<Thing> list5 = EClass._map.ListThing<TraitBeekeep>();
761 Thing thing8 = (list5 != null) ? list5.RandomItem<Thing>() : null;
762 if (thing8 != null)
763 {
764 yield return base.DoGoto(thing8.pos, 0, false, null);
765 }
766 }
767 a2 = this.owner.source.aiIdle;
768 if (!(a2 == "stand") && !(a2 == "root"))
769 {
770 if (EClass.rnd(15) == 0)
771 {
772 this.owner.MoveRandom();
773 }
774 if (this.owner == null)
775 {
776 yield return this.Cancel();
777 }
778 }
779 if (EClass._zone.IsPCFaction && this.owner.IsPCFaction && !this.owner.IsPCParty && (this.owner.GetWork("Clean") != null || this.owner.GetWork("Chore") != null) && !(EClass.pc.ai is AI_UseCrafter))
780 {
781 AI_Haul ai_Haul = AI_Haul.TryGetAI(this.owner);
782 if (ai_Haul != null)
783 {
784 yield return base.Do(ai_Haul, null);
785 }
786 }
787 yield return base.Restart();
788 yield break;
789 yield break;
790 }
791
792 // Token: 0x06000E13 RID: 3603 RVA: 0x0006A9F4 File Offset: 0x00068BF4
793 public void IdleActText(string id)
794 {
795 string text = "idle_" + id;
796 this.owner.PlaySound(text, 1f, true);
797 if (Lang.Game.map.ContainsKey(text))
798 {
799 this.owner.Say(text, this.owner, null, null);
800 }
801 }
802
803 // Token: 0x06000E14 RID: 3604 RVA: 0x0006AA46 File Offset: 0x00068C46
804 public void TryCast<T>(EffectId id, int power = 100) where T : Condition
805 {
806 if (!this.owner.HasCondition<T>())
807 {
808 this.TryCast(id, power);
809 }
810 }
811
812 // Token: 0x06000E15 RID: 3605 RVA: 0x0006AA60 File Offset: 0x00068C60
813 public void TryCast(EffectId id, int power = 100)
814 {
815 this.owner.Say("idle_cast", this.owner, null, null);
816 ActEffect.Proc(id, power, BlessedState.Normal, this.owner, null, default(ActRef));
817 }
818
819 // Token: 0x06000E16 RID: 3606 RVA: 0x0006AAA0 File Offset: 0x00068CA0
820 public BaseArea GetRandomAssignedRoom()
821 {
822 AI_Idle._listRoom.Clear();
823 foreach (BaseArea baseArea in EClass._map.rooms.listRoom.Concat(EClass._map.rooms.listArea))
824 {
825 if (baseArea.type != null && baseArea.type.uidCharas.Contains(this.owner.uid))
826 {
827 AI_Idle._listRoom.Add(baseArea);
828 }
829 }
830 return AI_Idle._listRoom.RandomItem<BaseArea>();
831 }
832
833 // Token: 0x06000E17 RID: 3607 RVA: 0x0006AB48 File Offset: 0x00068D48
834 public Chara DoSomethingToNearChara(Func<Chara, bool> funcPickChara, Action<Chara> action = null)
835 {
836 List<Chara> list = this.owner.pos.ListCharasInNeighbor((Chara c) => c != this.owner && this.owner.CanSee(c) && (funcPickChara == null || funcPickChara(c)));
837 if (list.Count > 0)
838 {
839 Chara chara = list.RandomItem<Chara>();
840 if (action != null)
841 {
842 action(chara);
843 }
844 return chara;
845 }
846 return null;
847 }
848
849 // Token: 0x06000E18 RID: 3608 RVA: 0x0006ABA4 File Offset: 0x00068DA4
850 public Chara DoSomethingToCharaInRadius(int radius, Func<Chara, bool> funcPickChara, Action<Chara> action = null)
851 {
852 List<Chara> list = this.owner.pos.ListCharasInRadius(this.owner, radius, (Chara c) => c != this.owner && this.owner.CanSee(c) && (funcPickChara == null || funcPickChara(c)));
853 if (list.Count > 0)
854 {
855 Chara chara = list.RandomItem<Chara>();
856 if (action != null)
857 {
858 action(chara);
859 }
860 return chara;
861 }
862 return null;
863 }
864
865 // Token: 0x06000E19 RID: 3609 RVA: 0x0006AC08 File Offset: 0x00068E08
866 public bool TryPerformIdleUse()
867 {
868 for (int i = 0; i < 10; i++)
869 {
870 Point randomPoint = this.owner.pos.GetRandomPoint(7, true, true, true, 100);
871 if (randomPoint != null && randomPoint.detail != null)
872 {
873 foreach (Thing thing in randomPoint.detail.things)
874 {
875 if (thing.IsInstalled)
876 {
877 int num = this.owner.Dist(thing);
878 if (EClass.rnd((this.owner.memberType == FactionMemberType.Guest) ? 5 : 50) == 0 && thing.HasTag(CTAG.tourism) && num <= 2)
879 {
880 this.owner.LookAt(thing);
881 this.owner.Talk("nice_statue", null, null, false);
882 return true;
883 }
884 if (EClass.rnd(thing.trait.IdleUseChance) == 0 && thing.trait.IdleUse(this.owner, num))
885 {
886 this.owner.LookAt(thing);
887 return true;
888 }
889 }
890 }
891 }
892 }
893 return false;
894 }
895
896 // Token: 0x04000D37 RID: 3383
897 public int maxRepeat = 10;
898
899 // Token: 0x04000D38 RID: 3384
900 public int moveFailCount;
901
902 // Token: 0x04000D39 RID: 3385
903 private static List<BaseArea> _listRoom = new List<BaseArea>();
904
905 // Token: 0x020008D6 RID: 2262
906 public enum Behaviour
907 {
908 // Token: 0x04002581 RID: 9601
909 Default,
910 // Token: 0x04002582 RID: 9602
911 NoMove
912 }
913}
Definition AIAct.cs:7
Definition Act.2.cs:7
Definition Card.cs:13
Definition Chara.cs:12
Definition Los.cs:6
Definition Msg.cs:7
Definition Party.cs:8
Definition Point.cs:11
Definition Room.cs:6
Definition Thing.cs:10
Definition Trait.cs:9
Definition Zone.cs:14