Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
AI_Idle.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
5
6public class AI_Idle : AIAct
7{
8 public enum Behaviour
9 {
10 Default,
11 NoMove
12 }
13
14 public int maxRepeat = 10;
15
16 public int moveFailCount;
17
18 private static List<BaseArea> _listRoom = new List<BaseArea>();
19
20 public override bool IsIdle => !base.IsChildRunning;
21
22 public override bool InformCancel => false;
23
24 public override int MaxRestart => maxRepeat;
25
26 public override void OnStart()
27 {
28 owner.SetTempHand(-1, -1);
29 owner.ShowEmo();
30 }
31
32 public override IEnumerable<Status> Run()
33 {
34 while (true)
35 {
36 if (owner.held != null)
37 {
39 }
40 if (owner.nextUse != null)
41 {
42 Thing nextUse = owner.nextUse;
43 owner.nextUse = null;
44 if (nextUse.parent == owner && !nextUse.isDestroyed)
45 {
46 owner.TryUse(nextUse);
47 }
48 yield return KeepRunning();
49 }
51 {
52 if (EClass.rnd(5) == 0)
53 {
54 owner.Talk("onFire");
55 }
57 {
58 yield return Restart();
59 }
60 }
61 if (EClass.rnd(owner.IsPCParty ? 10 : 100) == 0 && owner.hunger.GetPhase() >= 3)
62 {
63 Thing thing = owner.things.Find((Thing a) => owner.CanEat(a, owner.IsPCFaction) && !a.c_isImportant, recursive: false);
64 if (thing == null && owner.IsPCFaction)
65 {
66 thing = owner.things.Find((Thing a) => owner.CanEat(a) && !a.c_isImportant, recursive: false);
67 }
68 if (thing == null && owner.IsPCFaction && EClass._zone.IsPCFaction)
69 {
71 if (thing != null)
72 {
73 owner.Pick(thing);
74 }
75 }
76 if (thing == null && !owner.IsPCParty)
77 {
78 if (!owner.IsPCFaction && EClass.rnd(8) != 0)
79 {
80 owner.hunger.Mod(-30);
81 }
82 else if (!owner.things.IsFull())
83 {
84 thing = ThingGen.CreateFromCategory("food", EClass.rnd(EClass.rnd(60) + 1) + 10);
85 thing.isNPCProperty = true;
86 if ((thing.ChildrenAndSelfWeight < 5000 || !owner.IsPCParty) && thing.trait.CanEat(owner))
87 {
88 thing = owner.AddThing(thing);
89 }
90 }
91 }
92 if (thing != null)
93 {
95 {
96 owner.InstantEat(thing, sound: false);
97 yield return Restart();
98 }
99 else if (thing.Num == 1 || !owner.things.IsFull())
100 {
101 yield return Do(new AI_Eat
102 {
103 target = thing
104 });
105 }
106 }
107 }
108 if (EClass.rnd(3) == 0 && owner.mana.value > 0 && !EClass._zone.IsRegion)
109 {
110 Act act = null;
111 Act actRevive = null;
112 foreach (ActList.Item item in owner.ability.list.items)
113 {
114 Act act2 = item.act;
115 if (act2.id == 8430)
116 {
117 actRevive = act2;
118 }
119 string[] abilityType = act2.source.abilityType;
120 if (!abilityType.IsEmpty() && (abilityType[0] == "heal" || abilityType[0] == "hot"))
121 {
122 act = item.act;
123 }
124 }
125 if (act != null)
126 {
127 List<Chara> list = (owner.IsPCParty ? EClass.pc.party.members : new List<Chara> { owner });
128 foreach (Chara item2 in list)
129 {
130 if (!((float)item2.hp > (float)item2.MaxHP * 0.75f) && owner.CanSeeLos(item2) && (!(act.source.abilityType[0] == "hot") || !item2.HasCondition<ConHOT>()))
131 {
132 owner.UseAbility(act, item2);
133 yield return KeepRunning();
134 break;
135 }
136 }
137 }
138 if (actRevive != null && owner.IsPCFaction && EClass.game.cards.globalCharas.Where((KeyValuePair<int, Chara> a) => a.Value.isDead && a.Value.faction == EClass.pc.faction && !a.Value.isSummon && a.Value.c_wasInPcParty).ToList().Count > 0 && owner.UseAbility(actRevive.source.alias, owner))
139 {
140 yield return KeepRunning();
141 }
142 }
144 {
146 if (owner.sharedCheckTurn < 0 && EClass.rnd(EClass.debug.enable ? 2 : 20) == 0)
147 {
150 owner.sharedCheckTurn += (EClass.debug.enable ? 20 : 200);
151 }
152 }
153 if ((EClass._zone is Zone_Civilized || EClass._zone.IsPCFaction) && (owner.IsPCParty ? 10 : (owner.IsPCFaction ? 2 : 0)) > EClass.rnd(100))
154 {
155 Thing thing2 = owner.things.Find("polish_powder");
156 if (thing2 != null && EClass._map.props.installed.Find<TraitGrindstone>() != null)
157 {
158 foreach (Thing thing8 in owner.things)
159 {
160 if (!thing8.IsEquipment || thing8.encLV >= 0)
161 {
162 continue;
163 }
164 for (int i = 0; i < 5; i++)
165 {
166 if (thing8.encLV >= 0)
167 {
168 break;
169 }
170 owner.Say("polish", owner, thing8);
171 thing8.ModEncLv(1);
172 thing2.ModNum(-1);
173 if (thing2.isDestroyed)
174 {
175 break;
176 }
177 }
178 if (thing2.isDestroyed)
179 {
180 break;
181 }
182 }
183 }
184 }
185 if (owner.IsPCParty)
186 {
188 {
189 TraitShackle traitShackle = owner.pos.FindThing<TraitShackle>();
190 if (traitShackle != null && traitShackle.AllowTraining)
191 {
193 {
194 shackle = traitShackle
195 });
196 }
197 yield return Restart();
198 }
199 if (EClass.rnd(20) == 0)
200 {
201 Thing thing3 = owner.things.Find((Thing a) => a.parent == owner && a.isGifted && (a.category.id == "skillbook" || a.category.id == "ancientbook"));
202 if (thing3 != null && thing3.trait.CanRead(owner) && (thing3.Num == 1 || !owner.things.IsFull()))
203 {
204 yield return Do(new AI_Read
205 {
206 target = thing3
207 });
208 }
209 }
210 if (EClass.rnd(100) == 0 && !EClass._zone.IsRegion && owner.HasElement(1227))
211 {
212 List<Chara> list2 = new List<Chara>();
213 foreach (Chara member in EClass.pc.party.members)
214 {
215 if (member.Evalue(1227) > 0)
216 {
217 list2.Add(member);
218 }
219 }
220 if (list2.Count > 2)
221 {
222 list2.Remove(owner);
223 owner.SetEnemy(list2.RandomItem());
224 yield return Success();
225 }
226 }
227 if (EClass.rnd(150) == 0 && owner.host != null && owner.host.parasite == owner && owner.GetInt(108) == 1)
228 {
229 owner.host.PlaySound("whip");
230 owner.host.Say("use_whip3", owner, owner.host);
231 owner.Talk("insult");
232 owner.host.PlayAnime(AnimeID.Shiver);
233 owner.host.DamageHP(5 + EClass.rndHalf(owner.host.MaxHP / 5), 919, 100, AttackSource.Condition);
235 yield return KeepRunning();
236 }
237 if (EClass.rnd(EClass.debug.enable ? 2 : 20) == 0 && owner.CanSee(EClass.pc) && !(EClass.pc.ai is AI_Eat))
238 {
240 }
241 if (owner.isSynced && EClass.rnd((owner.host == null) ? 200 : 150) == 0 && owner.GetInt(106) == 0)
242 {
243 if (EClass.rnd(2) == 0 && owner.GetInt(108) == 1)
244 {
245 owner.Talk("insult");
246 }
247 else
248 {
250 }
251 }
252 if (EClass.rnd(100) == 0 && EClass._zone.IsTown)
253 {
255 }
256 if ((EClass.rnd(20) == 0 || EClass.debug.enable) && owner.GetCurrency() >= 500)
257 {
258 bool flag = EClass._zone.IsTown;
260 {
261 foreach (Chara member2 in EClass._zone.branch.members)
262 {
263 if (member2.ExistsOnMap && member2.trait is TraitTrainer)
264 {
265 flag = true;
266 }
267 }
268 }
269 if (flag)
270 {
271 bool flag2 = false;
272 foreach (Element value in owner.elements.dict.Values)
273 {
274 if (!(value.source.category != "skill") && value.vTempPotential < 900)
275 {
276 flag2 = true;
277 break;
278 }
279 }
280 if (flag2)
281 {
282 int num = owner.GetCurrency();
283 if (num >= 20000)
284 {
285 num = 20000;
286 }
287 owner.PlaySound("pay");
288 int num2 = num / 200;
289 foreach (Element value2 in owner.elements.dict.Values)
290 {
291 if (!(value2.source.category != "skill"))
292 {
293 int num3 = num2 * 100 / (100 + (100 + value2.vTempPotential / 2 + value2.ValueWithoutLink) * (100 + value2.vTempPotential / 2 + value2.ValueWithoutLink) / 100);
294 num3 += 1 + EClass.rnd(3);
295 owner.elements.ModTempPotential(value2.id, Mathf.Max(1, num3), 9999);
296 }
297 }
298 Msg.Say("party_train", owner, Lang._currency(num));
299 owner.PlaySound("ding_potential");
300 owner.ModCurrency(-num);
301 }
302 }
303 }
304 }
305 if (owner.c_uidMaster != 0)
306 {
307 Chara chara = owner.master;
308 if (chara == null || !chara.IsAliveInCurrentZone)
309 {
310 chara = owner.FindMaster();
311 }
312 if (chara != null && chara.IsAliveInCurrentZone)
313 {
314 if (owner.enemy == null)
315 {
316 owner.SetEnemy(chara.enemy);
317 }
318 int num4 = owner.Dist(chara.pos);
319 if (owner.source.aiIdle != "root" && num4 > EClass.game.config.tactics.AllyDistance(owner) && EClass._zone.PetFollow && owner.c_minionType == MinionType.Default)
320 {
321 if (owner.HasAccess(chara.pos))
322 {
323 owner.TryMoveTowards(chara.pos);
324 }
325 yield return KeepRunning();
326 continue;
327 }
328 }
329 }
330 Party party = owner.party;
331 if (party == null || party.leader == owner || !party.leader.IsAliveInCurrentZone || owner.host != null || !EClass._zone.PetFollow)
332 {
333 break;
334 }
335 if (owner.source.aiIdle == "root")
336 {
337 yield return KeepRunning();
338 continue;
339 }
341 {
342 yield return KeepRunning();
343 continue;
344 }
345 if (owner.HasAccess(party.leader.pos) && owner.TryMoveTowards(party.leader.pos) == Card.MoveResult.Fail && owner.Dist(party.leader) > 4)
346 {
348 bool flag3 = (EClass._zone is Zone_Civilized || EClass._zone.IsPCFaction) && (EClass.pc.enemy == null || !EClass.pc.enemy.IsAliveInCurrentZone);
349 if (moveFailCount >= (flag3 ? 100 : 10))
350 {
351 owner.Teleport(party.leader.pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: true, ignoreCenter: true), silent: false, force: true);
352 moveFailCount = 0;
353 }
354 }
355 else
356 {
357 moveFailCount = 0;
358 }
359 yield return KeepRunning();
360 }
361 if (EClass._zone.IsNefia && EClass._zone.Boss == owner && EClass.rnd(20) == 0)
362 {
364 }
365 if (EClass._zone.IsRegion && EClass.rnd(10) != 0)
366 {
367 yield return Restart();
368 }
369 if (((owner.homeBranch != null && owner.homeBranch == EClass.Branch && EClass.rnd(100) == 0) || (owner.IsGuest() && EClass.rnd(50) == 0)) && owner.FindBed() == null)
370 {
372 }
373 if (owner.id == "geist" && EClass.rnd(20) == 0)
374 {
375 Point nearestPoint = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: false);
376 if (nearestPoint != null)
377 {
378 foreach (Chara item3 in nearestPoint.ListCharasInRadius(owner, 6, (Chara _c) => _c != owner && !_c.IsPCFactionOrMinion))
379 {
380 item3.Teleport(nearestPoint.GetNearestPoint(allowBlock: false, allowChara: false) ?? nearestPoint);
381 }
382 if (owner != null)
383 {
384 owner.Teleport(nearestPoint);
385 }
386 yield return Success();
387 }
388 }
390 {
391 Room room = owner.pos.cell.room;
392 if (room != null)
393 {
394 Point point = null;
395 if (owner.memberType == FactionMemberType.Guest && room.data.accessType != 0)
396 {
397 point = FindMovePoint(BaseArea.AccessType.Public);
398 }
399 else if (owner.memberType == FactionMemberType.Default && room.data.accessType == BaseArea.AccessType.Private)
400 {
401 point = FindMovePoint(BaseArea.AccessType.Resident) ?? FindMovePoint(BaseArea.AccessType.Public);
402 }
403 if (point != null)
404 {
405 yield return DoGoto(point);
406 }
407 }
408 }
410 {
411 if (owner.IsPCFaction && owner.GetInt(32) + 4320 < EClass.world.date.GetRaw())
412 {
413 if (owner.GetInt(32) != 0 && Zone.okaerinko < 10)
414 {
415 owner.Talk("welcomeBack");
416 Zone.okaerinko++;
417 }
419 }
421 {
422 if (EClass.rnd(5) == 0 && owner.hostility >= Hostility.Neutral && EClass.pc.IsPCC && EClass.pc.pccData.state == PCCState.Undie && !EClass.pc.pos.cell.IsTopWaterAndNoSnow)
423 {
424 owner.Talk("pervert3");
425 }
426 else if (EClass.rnd(15) == 0 && EClass._zone.IsTown && owner.hostility >= Hostility.Neutral && !owner.IsPCFaction && !EClass.pc.HasCondition<ConIncognito>())
427 {
428 bool flag4 = EClass._zone is Zone_Derphy;
429 string text = ((EClass.player.karma > 10) ? ((EClass.player.karma < 90) ? "" : (flag4 ? "rumor_bad" : "rumor_good")) : (flag4 ? "rumor_good" : "rumor_bad"));
430 if (!text.IsEmpty())
431 {
432 owner.Talk(text);
433 }
434 if ((flag4 ? (EClass.player.karma >= 90) : (EClass.player.karma <= 10)) && EClass.rnd(10) == 0)
435 {
436 Thing t2 = ThingGen.Create("stone");
437 AI_PlayMusic.ignoreDamage = true;
439 AI_PlayMusic.ignoreDamage = false;
440 }
441 }
442 else
443 {
444 owner.TalkTopic("fov");
445 }
446 owner.turnLastSeen = EClass.player.stats.turns;
447 }
448 }
449 if (EClass.rnd(25) == 0 && owner.IsInMutterDistance())
450 {
452 {
453 owner.PlayAnime(AnimeID.Shiver);
454 }
456 if (tC == null || tC.pop.items.Count == 0)
457 {
458 if (owner.noMove)
459 {
460 foreach (Thing thing9 in owner.pos.Things)
461 {
462 if (thing9.IsInstalled && thing9.trait is TraitGeneratorWheel)
463 {
464 owner.Talk("labor");
465 owner.PlayAnime(AnimeID.Shiver);
466 yield return Restart();
467 }
468 }
469 }
470 if (owner.isDrunk && (owner.race.id == "cat" || owner.id == "sailor"))
471 {
472 owner.Talk("drunk_cat");
473 }
474 else if (owner.isRestrained)
475 {
476 owner.Talk("restrained");
477 }
478 else if (owner.GetInt(106) == 0 && !owner.IsPCParty)
479 {
480 if (owner.HasElement(1232) && EClass.rnd(4) == 0)
481 {
482 owner.Talk("baby");
483 }
484 else if (EClass.rnd((owner.host == null) ? 2 : 10) == 0 && owner.isSynced && owner.TalkTopic().IsEmpty())
485 {
486 owner.Talk(owner.pos.IsHotSpring ? "hotspring" : "idle");
487 }
488 }
489 }
490 }
491 if (EClass.rnd(8) == 0 && owner.race.id == "chicken")
492 {
493 owner.PlaySound("Animal/Chicken/chicken");
494 }
495 if (EClass.rnd(80) == 0 && owner.race.id == "cat")
496 {
497 owner.PlaySound("Animal/Cat/cat");
498 }
499 if (owner.trait.IdAmbience != null && owner.IsInMutterDistance(15))
500 {
501 float mtp = 1f;
502 Room room2 = owner.Cell.room;
503 Room room3 = EClass.pc.Cell.room;
504 if (room2 != room3 && room3 != null)
505 {
506 mtp = ((room2?.lot != room3?.lot) ? 0.4f : 0.7f);
507 }
508 EClass.Sound.PlayAmbience(owner.trait.IdAmbience, owner.pos.Position(), mtp);
509 }
510 if (EClass.rnd(2000) == 0 && owner.IsHuman && (owner.host == null || owner.host.ride != owner))
511 {
512 Thing thing4 = owner.things.Find((Thing a) => !a.IsNegativeGift && a.trait.CanDrink(owner), recursive: false);
513 if (thing4 != null && thing4.trait is TraitPotion && owner.IsPCParty)
514 {
515 thing4 = null;
516 }
517 if (thing4 == null && (owner.homeBranch == null || !owner.homeBranch.policies.IsActive(2503)))
518 {
519 thing4 = ThingGen.Create("crimAle");
520 owner.Drink(thing4);
521 }
522 if (thing4 != null && !thing4.isDestroyed)
523 {
524 owner.TryUse(thing4);
525 yield return Restart();
526 }
527 }
528 if (EClass.rnd(owner.IsPCParty ? 1000 : 200) == 0 && owner.isDrunk && (owner.isSynced || EClass.rnd(5) == 0))
529 {
530 DoSomethingToCharaInRadius(3, null, delegate(Chara c)
531 {
532 owner.Say("drunk_mess", owner, c);
533 owner.Talk("drunk_mess");
534 bool flag5 = EClass.rnd(5) == 0 && !c.IsPC;
535 if (c.IsPCParty && owner.hostility >= Hostility.Friend)
536 {
537 flag5 = false;
538 }
539 if (flag5)
540 {
541 owner.Say("drunk_counter", c, owner);
542 c.Talk("drunk_counter");
544 }
545 });
546 }
547 if (EClass.rnd(100) == 0 && owner.trait.CanFish)
548 {
549 Point fishingPoint = AI_Fish.GetFishingPoint(owner.pos);
550 if (fishingPoint.IsValid)
551 {
552 yield return Do(new AI_Fish
553 {
554 pos = fishingPoint
555 });
556 }
557 }
558 string idAct = owner.source.actIdle.RandomItem();
559 if (EClass.rnd(EClass.world.date.IsNight ? 1500 : 15000) == 0 && !owner.IsPCFaction && !owner.noMove)
560 {
561 owner.AddCondition<ConSleep>(1000 + EClass.rnd(1000), force: true);
562 }
563 if (EClass.rnd((owner.host != null && owner.GetInt(106) != 0) ? 1000 : 40) == 0 && owner.IsHuman)
564 {
565 DoSomethingToNearChara((Chara c) => (!c.IsPCParty || EClass.rnd(5) == 0) && c.IsMofuable && !owner.IsHostile(c) && !c.IsInCombat, delegate(Chara c)
566 {
567 owner.Cuddle(c);
568 });
569 }
570 if (EClass.rnd(100) == 0 && owner.trait is TraitBitch)
571 {
572 Chara chara2 = DoSomethingToNearChara((Chara c) => c.IsIdle && !c.IsPCParty && !(c.trait is TraitBitch));
573 if (chara2 != null)
574 {
575 yield return Do(new AI_Fuck
576 {
577 target = chara2,
578 bitch = true
579 });
580 }
581 }
582 if (EClass.rnd(50) == 0 && owner.trait is TraitBard)
583 {
584 yield return Do(new AI_PlayMusic());
585 }
586 if (EClass.rnd(4) == 0 && TryPerformIdleUse())
587 {
588 yield return Restart();
589 }
590 if (EClass.rnd(20) == 0 && owner.trait.IdleAct())
591 {
592 yield return Restart();
593 }
594 if (idAct == "janitor" && EClass.rnd(5) == 0)
595 {
596 DoSomethingToCharaInRadius(4, null, delegate(Chara c)
597 {
598 if (c.HasElement(1211) && !(EClass._zone is Zone_Casino))
599 {
600 owner.Talk("snail");
601 Thing t4 = ThingGen.Create("1142");
602 ActThrow.Throw(owner, c.pos, t4);
603 }
604 });
605 yield return Restart();
606 }
608 {
609 TraitShackle traitShackle2 = owner.pos.FindThing<TraitShackle>();
610 if (traitShackle2 != null && traitShackle2.AllowTraining)
611 {
613 {
614 shackle = traitShackle2
615 });
616 yield return Restart();
617 }
618 }
619 if (!owner.IsPCFactionOrMinion && EClass.rnd(owner.isSynced ? 50 : 2000) == 0 && owner.hostility == Hostility.Neutral && EClass.pc.party.HasElement(1563) && !owner.race.tag.Contains("animal") && EClass._zone.IsTown && !EClass._zone.IsPCFaction && !owner.HasCondition<ConIncognito>())
620 {
622 }
623 if (EClass.rnd(200) == 0 && !owner.noMove)
624 {
625 Point cleanPoint = AI_Clean.GetCleanPoint(owner, 4);
626 if (cleanPoint != null)
627 {
628 yield return Do(new AI_Clean
629 {
630 pos = cleanPoint
631 });
632 }
633 }
634 if (EClass.rnd(35) == 0 && owner.id == "child" && owner.pos.cell.IsSnowTile)
635 {
636 foreach (Chara chara3 in EClass._map.charas)
637 {
638 if (EClass.rnd(3) != 0 && chara3 != owner && chara3.pos.cell.IsSnowTile && chara3.Dist(owner) <= 6 && Los.IsVisible(chara3, owner))
639 {
640 Thing t3 = ThingGen.Create("snow");
641 ActThrow.Throw(owner, chara3.pos, t3);
642 break;
643 }
644 }
645 }
646 if (EClass.rnd(EClass.debug.enable ? 3 : 30) == 0)
647 {
648 Thing thing5 = owner.things.Find<TraitBall>();
649 if (thing5 == null)
650 {
651 owner.pos.ForeachNeighbor(delegate(Point p)
652 {
653 Card card2 = p.FindThing<TraitBall>()?.owner;
654 if (card2 != null)
655 {
656 owner.Pick(card2.Thing);
657 }
658 });
659 }
660 else
661 {
662 foreach (Chara chara4 in EClass._map.charas)
663 {
664 if (EClass.rnd(3) != 0 && chara4 != owner && chara4.Dist(owner) <= 6 && chara4.Dist(owner) >= 3 && Los.IsVisible(chara4, owner))
665 {
666 ActThrow.Throw(owner, chara4.pos, thing5);
667 break;
668 }
669 }
670 }
671 }
672 if (EClass.rnd(20) == 0 && AI_Shopping.TryShop(owner, realtime: true))
673 {
674 yield return Restart();
675 }
676 if (EClass.rnd(20) == 0 && owner.IsPCFaction && AI_Shopping.TryRestock(owner, realtime: true))
677 {
678 yield return Restart();
679 }
681 if (owner.idleActTimer <= 0 && !owner.source.actIdle.IsEmpty())
682 {
683 owner.idleActTimer = 10 + EClass.rnd(50);
684 switch (idAct)
685 {
686 case "torture_snail":
687 DoSomethingToNearChara((Chara c) => c.race.id == "snail", delegate(Chara c)
688 {
689 owner.Say("use_whip3", owner, c);
690 owner.PlaySound("whip");
691 owner.Talk("insult");
692 c.PlayAnime(AnimeID.Shiver);
693 c.OnInsulted();
694 });
695 break;
696 case "buffMage":
697 if (EClass.rnd(2) == 0)
698 {
699 TryCast<ConHolyVeil>(EffectId.HolyVeil, 300 + EClass.rnd(300));
700 }
701 else
702 {
703 TryCast<ConLevitate>(EffectId.Levitate, 300 + EClass.rnd(300));
704 }
705 break;
706 case "buffThief":
707 TryCast<ConNightVision>(EffectId.CatsEye, 100 + EClass.rnd(100));
708 break;
709 case "buffGuildWatch":
710 TryCast<ConGravity>(EffectId.Gravity, 300 + EClass.rnd(300));
711 break;
712 case "buffHealer":
713 TryCast(EffectId.Heal);
714 break;
715 case "readBook":
716 {
717 if (EClass.rnd(2) == 0 || (owner.IsPCParty && EClass.rnd(20) != 0))
718 {
719 break;
720 }
721 List<Thing> list3 = owner.things.List((Thing a) => a.parent == owner && (a.category.id == "spellbook" || a.category.id == "ancientbook" || a.category.id == "skillbook"), onlyAccessible: true);
722 Thing thing6 = null;
723 if (list3.Count > 0)
724 {
725 thing6 = list3.RandomItem();
726 if (!thing6.trait.CanRead(owner))
727 {
728 thing6 = null;
729 }
730 }
731 if (thing6 == null)
732 {
733 if (owner.things.IsFull())
734 {
735 break;
736 }
737 thing6 = ThingGen.CreateFromCategory((EClass.rnd(5) != 0) ? "spellbook" : "ancientbook");
738 thing6.isNPCProperty = true;
739 }
740 if (!(thing6.id == "1084") || !owner.IsPCFaction)
741 {
742 if (!owner.HasElement(285))
743 {
744 owner.elements.ModBase(285, 1);
745 }
746 yield return Do(new AI_Read
747 {
748 target = thing6
749 });
750 }
751 break;
752 }
753 default:
754 if (LangGame.Has("idle_" + idAct))
755 {
756 IdleActText(idAct);
757 }
758 break;
759 }
760 yield return Restart();
761 }
762 if (owner.host != null)
763 {
764 yield return Restart();
765 }
767 {
769 {
770 yield return DoGoto(owner.orgPos);
771 }
772 yield return Restart();
773 }
775 {
776 yield return DoGoto(EClass.pc);
777 }
778 if (EClass.rnd(100) == 0 && !owner.IsPCFaction)
779 {
780 if (owner.id == "ashland" || owner.id == "fiama")
781 {
783 if (card != null)
784 {
785 yield return DoGotoSpot(card);
786 }
787 else
788 {
789 Room room4 = owner.FindRoom();
790 if (room4 != null)
791 {
792 yield return DoGoto(room4.GetRandomPoint().GetNearestPoint());
793 }
794 }
795 }
797 {
798 yield return DoGoto(owner.orgPos, 0, ignoreConnection: false, delegate
799 {
800 if (!EClass._zone.IsPCFaction)
801 {
802 owner.Teleport(owner.orgPos, silent: false, force: true);
803 }
804 return Status.Success;
805 });
806 }
807 }
808 if (EClass.rnd(100) == 0 && owner.id == "bee")
809 {
810 Thing thing7 = EClass._map.ListThing<TraitBeekeep>()?.RandomItem();
811 if (thing7 != null)
812 {
813 yield return DoGoto(thing7.pos);
814 }
815 }
816 string aiIdle = owner.source.aiIdle;
817 if (!(aiIdle == "stand") && !(aiIdle == "root"))
818 {
819 if (EClass.rnd(15) == 0)
820 {
822 }
823 if (owner == null)
824 {
825 yield return Cancel();
826 }
827 }
828 if (EClass._zone.IsPCFaction && owner.IsPCFaction && !owner.IsPCParty && (owner.GetWork("Clean") != null || owner.GetWork("Chore") != null) && !(EClass.pc.ai is AI_UseCrafter))
829 {
830 AI_Haul aI_Haul = AI_Haul.TryGetAI(owner);
831 if (aI_Haul != null)
832 {
833 yield return Do(aI_Haul);
834 }
835 }
836 yield return Restart();
837 Point FindMovePoint(BaseArea.AccessType type)
838 {
839 for (int j = 0; j < 20; j++)
840 {
841 Point randomPoint = owner.pos.GetRandomPoint(5 + j, requireLos: false);
842 if (randomPoint != null && randomPoint.IsInBounds && (randomPoint.cell.room == null || randomPoint.cell.room.data.accessType == type))
843 {
844 return randomPoint;
845 }
846 }
847 return null;
848 }
849 }
850
851 public void IdleActText(string id)
852 {
853 string text = "idle_" + id;
854 owner.PlaySound(text);
855 if (Lang.Game.map.ContainsKey(text))
856 {
857 owner.Say(text, owner);
858 }
859 }
860
861 public void TryCast<T>(EffectId id, int power = 100) where T : Condition
862 {
863 if (!owner.HasCondition<T>())
864 {
865 TryCast(id, power);
866 }
867 }
868
869 public void TryCast(EffectId id, int power = 100)
870 {
871 owner.Say("idle_cast", owner);
872 ActEffect.Proc(id, power, BlessedState.Normal, owner);
873 }
874
876 {
877 _listRoom.Clear();
878 foreach (BaseArea item in ((IEnumerable<BaseArea>)EClass._map.rooms.listRoom).Concat((IEnumerable<BaseArea>)EClass._map.rooms.listArea))
879 {
880 if (item.type != null && item.type.uidCharas.Contains(owner.uid))
881 {
882 _listRoom.Add(item);
883 }
884 }
885 return _listRoom.RandomItem();
886 }
887
888 public Chara DoSomethingToNearChara(Func<Chara, bool> funcPickChara, Action<Chara> action = null)
889 {
890 List<Chara> list = owner.pos.ListCharasInNeighbor(delegate(Chara c)
891 {
892 if (c == owner || !owner.CanSee(c))
893 {
894 return false;
895 }
896 return funcPickChara == null || funcPickChara(c);
897 });
898 if (list.Count > 0)
899 {
900 Chara chara = list.RandomItem();
901 action?.Invoke(chara);
902 return chara;
903 }
904 return null;
905 }
906
907 public Chara DoSomethingToCharaInRadius(int radius, Func<Chara, bool> funcPickChara, Action<Chara> action = null)
908 {
909 List<Chara> list = owner.pos.ListCharasInRadius(owner, radius, delegate(Chara c)
910 {
911 if (c == owner || !owner.CanSee(c))
912 {
913 return false;
914 }
915 return funcPickChara == null || funcPickChara(c);
916 });
917 if (list.Count > 0)
918 {
919 Chara chara = list.RandomItem();
920 action?.Invoke(chara);
921 return chara;
922 }
923 return null;
924 }
925
926 public bool TryPerformIdleUse()
927 {
928 for (int i = 0; i < 10; i++)
929 {
930 Point randomPoint = owner.pos.GetRandomPoint(7, requireLos: true, allowChara: true, allowBlocked: true);
931 if (randomPoint == null || randomPoint.detail == null)
932 {
933 continue;
934 }
935 foreach (Thing thing in randomPoint.detail.things)
936 {
937 if (thing.IsInstalled)
938 {
939 int num = owner.Dist(thing);
940 if (EClass.rnd((owner.memberType == FactionMemberType.Guest) ? 5 : 50) == 0 && thing.HasTag(CTAG.tourism) && num <= 2)
941 {
942 owner.LookAt(thing);
943 owner.Talk("nice_statue");
944 return true;
945 }
946 if (EClass.rnd(thing.trait.IdleUseChance) == 0 && thing.trait.IdleUse(owner, num))
947 {
948 owner.LookAt(thing);
949 return true;
950 }
951 }
952 }
953 }
954 return false;
955 }
956}
AnimeID
Definition: AnimeID.cs:2
AttackSource
Definition: AttackSource.cs:2
BlessedState
Definition: BlessedState.cs:2
CTAG
Definition: CTAG.cs:2
ClearInventoryType
EditorTag
Definition: EditorTag.cs:2
EffectId
Definition: EffectId.cs:2
FactionMemberType
Hostility
Definition: Hostility.cs:2
MinionType
Definition: MinionType.cs:2
ThrowMethod
Definition: ThrowMethod.cs:2
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
Definition: AIAct.cs:6
Status Do(AIAct _seq, Func< Status > _onChildFail=null)
Definition: AIAct.cs:416
virtual Status Cancel()
Definition: AIAct.cs:291
new Chara owner
Definition: AIAct.cs:14
Status
Definition: AIAct.cs:8
Status DoGotoSpot(Card card, Func< Status > _onChildFail=null)
Definition: AIAct.cs:461
Status DoGoto(Point pos, int dist=0, bool ignoreConnection=false, Func< Status > _onChildFail=null)
Definition: AIAct.cs:432
Status KeepRunning()
Definition: AIAct.cs:321
Status Restart()
Definition: AIAct.cs:237
static Point GetCleanPoint(Chara c, int r=-1, int tries=10)
Definition: AI_Clean.cs:9
Definition: AI_Eat.cs:5
static Point GetFishingPoint(Point p)
Definition: AI_Fish.cs:263
static AI_Haul TryGetAI(Chara c)
Definition: AI_Haul.cs:76
Chara DoSomethingToNearChara(Func< Chara, bool > funcPickChara, Action< Chara > action=null)
Definition: AI_Idle.cs:888
BaseArea GetRandomAssignedRoom()
Definition: AI_Idle.cs:875
int moveFailCount
Definition: AI_Idle.cs:16
static List< BaseArea > _listRoom
Definition: AI_Idle.cs:18
override IEnumerable< Status > Run()
Definition: AI_Idle.cs:32
override bool IsIdle
Definition: AI_Idle.cs:20
override bool InformCancel
Definition: AI_Idle.cs:22
Chara DoSomethingToCharaInRadius(int radius, Func< Chara, bool > funcPickChara, Action< Chara > action=null)
Definition: AI_Idle.cs:907
int maxRepeat
Definition: AI_Idle.cs:14
override int MaxRestart
Definition: AI_Idle.cs:24
void IdleActText(string id)
Definition: AI_Idle.cs:851
bool TryPerformIdleUse()
Definition: AI_Idle.cs:926
override void OnStart()
Definition: AI_Idle.cs:26
void TryCast(EffectId id, int power=100)
Definition: AI_Idle.cs:869
Behaviour
Definition: AI_Idle.cs:9
static bool TryRestock(Chara c, bool realtime)
Definition: AI_Shopping.cs:94
static bool TryShop(Chara c, bool realtime)
Definition: AI_Shopping.cs:10
static void Proc(EffectId id, Card cc, Card tc=null, int power=100, ActRef actRef=default(ActRef))
Definition: ActEffect.cs:788
List< Item > items
Definition: ActList.cs:14
static EffectIRenderer Throw(Card c, Point p, Thing t, ThrowMethod method=ThrowMethod.Default, float failChance=0f)
Definition: ActThrow.cs:93
Definition: ACT.cs:62
BaseArea.AccessType accessType
Definition: AreaData.cs:42
AccessType
Definition: BaseArea.cs:9
AreaData data
Definition: BaseArea.cs:29
virtual Point GetRandomPoint(bool walkable=true, bool allowChara=true)
Definition: BaseArea.cs:88
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
GlobalCharaList globalCharas
Definition: CardManager.cs:46
TC GetTC(string id)
Definition: Card.cs:11
bool isDestroyed
Definition: Card.cs:71
bool IsPCFactionOrMinion
Definition: Card.cs:2132
void Teleport(Point point, bool silent=false, bool force=false)
Definition: Card.cs:5153
ElementContainerCard elements
Definition: Card.cs:37
string id
Definition: Card.cs:31
bool IsRestrainedResident
Definition: Card.cs:2118
void DamageHP(int dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:3735
bool HasElement(int ele, int req=1)
Definition: Card.cs:5214
bool isRestrained
Definition: Card.cs:538
CardRenderer HostRenderer
Definition: Card.cs:2302
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
int c_uidMaster
Definition: Card.cs:1373
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:2901
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:5949
int hp
Definition: Card.cs:226
ICardParent parent
Definition: Card.cs:51
bool ExistsOnMap
Definition: Card.cs:1961
int GetCurrency(string id="money")
Definition: Card.cs:3652
bool HasTag(CTAG tag)
Definition: Card.cs:2455
Point pos
Definition: Card.cs:55
bool IsInMutterDistance(int d=10)
Definition: Card.cs:6821
void ShowEmo(Emo _emo=Emo.none, float duration=0f, bool skipSame=true)
Definition: Card.cs:5372
Trait trait
Definition: Card.cs:49
void ModCurrency(int a, string id="money")
Definition: Card.cs:3638
int encLV
Definition: Card.cs:310
bool IsEquipment
Definition: Card.cs:2049
void ModEncLv(int a)
Definition: Card.cs:3549
bool c_isImportant
Definition: Card.cs:984
MoveResult
Definition: Card.cs:13
bool noMove
Definition: Card.cs:742
bool HasEditorTag(EditorTag tag)
Definition: Card.cs:2460
ThingContainer things
Definition: Card.cs:34
bool IsInstalled
Definition: Card.cs:2241
virtual Thing Thing
Definition: Card.cs:1934
int Evalue(int ele)
Definition: Card.cs:2431
int Dist(Card c)
Definition: Card.cs:6777
bool isGifted
Definition: Card.cs:754
Cell Cell
Definition: Card.cs:1931
int ChildrenAndSelfWeight
Definition: Card.cs:1917
int Num
Definition: Card.cs:154
void PlayAnime(AnimeID id, bool force=false)
Definition: Card.cs:5423
SourceCategory.Row category
Definition: Card.cs:1925
void ModNum(int a, bool notify=true)
Definition: Card.cs:3262
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
Room room
Definition: Cell.cs:102
bool IsSnowTile
Definition: Cell.cs:782
bool IsTopWaterAndNoSnow
Definition: Cell.cs:712
bool HasFire
Definition: Cell.cs:676
ActList list
Definition: CharaAbility.cs:12
Definition: Chara.cs:10
void OnInsulted()
Definition: Chara.cs:7408
bool UseAbility(string idAct, Card tc=null, Point pos=null, bool pt=false)
Definition: Chara.cs:5228
override bool IsAliveInCurrentZone
Definition: Chara.cs:546
new TraitChara trait
Definition: Chara.cs:488
Card held
Definition: Chara.cs:67
AIAct ai
Definition: Chara.cs:187
bool TryUse(Thing t)
Definition: Chara.cs:7110
void Cuddle(Chara c, bool headpat=false)
Definition: Chara.cs:5627
int sharedCheckTurn
Definition: Chara.cs:115
void InstantEat(Thing t=null, bool sound=true)
Definition: Chara.cs:6840
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8415
Faction faction
Definition: Chara.cs:412
override bool IsPC
Definition: Chara.cs:597
bool isDrunk
Definition: Chara.cs:119
Chara host
Definition: Chara.cs:33
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1059
bool IsMofuable
Definition: Chara.cs:917
override bool IsPCParty
Definition: Chara.cs:600
Party party
Definition: Chara.cs:43
bool IsInCombat
Definition: Chara.cs:817
TraitBed TryAssignBed()
Definition: Chara.cs:6641
void PickHeld(bool msg=false)
Definition: Chara.cs:4136
bool HasCondition(string alias)
Definition: Chara.cs:8568
AIAct SetAI(AIAct g)
Definition: Chara.cs:8045
bool IsIdle
Definition: Chara.cs:806
TraitBed FindBed()
Definition: Chara.cs:6629
Stats hunger
Definition: Chara.cs:951
override bool isSynced
Definition: Chara.cs:676
Point orgPos
Definition: Chara.cs:21
bool IsHuman
Definition: Chara.cs:835
bool MoveRandom()
Definition: Chara.cs:2284
void TryPutSharedItems(IEnumerable< Thing > containers, bool msg=true)
Definition: Chara.cs:6659
override bool IsPCFaction
Definition: Chara.cs:656
bool CanSee(Card c)
Definition: Chara.cs:1027
bool HasAccess(Card c)
Definition: Chara.cs:1089
bool CanEat(Thing t, bool shouldEat=false)
Definition: Chara.cs:6862
override int MaxHP
Definition: Chara.cs:693
void ClearInventory(ClearInventoryType type)
Definition: Chara.cs:7768
SourceChara.Row source
Definition: Chara.cs:143
Stats mana
Definition: Chara.cs:963
FactionMemberType memberType
Definition: Chara.cs:46
string TalkTopic(string topic="calm")
Definition: Chara.cs:6297
Stats stamina
Definition: Chara.cs:955
bool MoveNeighborDefinitely()
Definition: Chara.cs:2294
void SetTempHand(int right=0, int left=0)
Definition: Chara.cs:6057
Chara parasite
Definition: Chara.cs:30
Chara master
Definition: Chara.cs:85
bool IsGuest()
Definition: Chara.cs:5967
Hobby GetWork(string id)
Definition: Chara.cs:8156
Thing nextUse
Definition: Chara.cs:97
MoveResult TryMoveTowards(Point p)
Definition: Chara.cs:2320
Chara enemy
Definition: Chara.cs:83
CharaAbility ability
Definition: Chara.cs:409
Chara FindMaster()
Definition: Chara.cs:2093
Chara SetEnemy(Chara c=null)
Definition: Chara.cs:5658
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:5707
Room FindRoom()
Definition: Chara.cs:7161
Point GetDestination()
Definition: Chara.cs:6548
int turnLastSeen
Definition: Chara.cs:107
FactionBranch homeBranch
Definition: Chara.cs:889
void Drink(Card t)
Definition: Chara.cs:4612
Hostility hostility
Definition: Chara.cs:276
bool IsHostile()
Definition: Chara.cs:5884
void TryTakeSharedItems(bool msg=true)
Definition: Chara.cs:6697
PCCData pccData
Definition: Chara.cs:64
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:3920
override bool IsPCC
Definition: Chara.cs:667
int idleActTimer
Definition: Chara.cs:109
SourceRace.Row race
Definition: Chara.cs:449
Definition: ConHOT.cs:4
int AllyDistance(Chara c)
bool enable
Definition: CoreDebug.cs:285
int GetRaw(int offsetHours=0)
Definition: Date.cs:322
bool IsNight
Definition: Date.cs:112
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 World world
Definition: EClass.cs:40
static Map _map
Definition: EClass.cs:18
static FactionBranch Branch
Definition: EClass.cs:22
static int rndHalf(int a)
Definition: EClass.cs:74
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
static SoundManager Sound
Definition: EClass.cs:46
Dictionary< int, Element > dict
Element ModTempPotential(int ele, int v, int threshMsg=0)
Element ModBase(int ele, int v)
int ValueWithoutLink
Definition: ELEMENT.cs:284
int id
Definition: ELEMENT.cs:240
SourceElement.Row source
Definition: ELEMENT.cs:263
int vTempPotential
Definition: ELEMENT.cs:248
Act act
Definition: ELEMENT.cs:384
Thing GetMeal(Chara c)
List< Chara > members
PolicyManager policies
ConfigTactics tactics
Definition: Game.cs:90
CardManager cards
Definition: Game.cs:155
Config config
Definition: Game.cs:215
static bool Has(string id)
Definition: LangGame.cs:46
Definition: Lang.cs:6
static LangGame Game
Definition: Lang.cs:48
static string _currency(object a, string IDCurrency)
Definition: Lang.cs:162
Definition: Los.cs:5
static bool IsVisible(Point p1, Point p2, Action< Point, bool > _onVisit=null)
Definition: Los.cs:167
PropsInstalled Installed
Definition: Map.cs:123
PropsManager props
Definition: Map.cs:91
RoomManager rooms
Definition: Map.cs:31
List< Chara > charas
Definition: Map.cs:81
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
Definition: Party.cs:6
Chara leader
Definition: Party.cs:30
bool HasElement(int ele)
Definition: Party.cs:163
List< Chara > members
Definition: Party.cs:18
int turns
Definition: Player.cs:74
int karma
Definition: Player.cs:685
Stats stats
Definition: Player.cs:817
Definition: Point.cs:9
ref Vector3 Position(int height)
Definition: Point.cs:524
void ForeachNeighbor(Action< Point > action, bool diagonal=true)
Definition: Point.cs:1361
CellDetail detail
Definition: Point.cs:71
bool IsBlocked
Definition: Point.cs:339
List< Thing > Things
Definition: Point.cs:314
List< Chara > ListCharasInNeighbor(Func< Chara, bool > func)
Definition: Point.cs:1164
List< Chara > ListCharasInRadius(Chara cc, int dist, Func< Chara, bool > func, bool onlyVisible=true)
Definition: Point.cs:1184
bool Equals(int _x, int _z)
Definition: Point.cs:924
bool IsValid
Definition: Point.cs:88
int Distance(Point p)
Definition: Point.cs:953
bool IsInBounds
Definition: Point.cs:104
Cell cell
Definition: Point.cs:51
Thing FindThing(Func< Thing, bool > func)
Definition: Point.cs:1104
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false)
Definition: Point.cs:595
bool HasChara
Definition: Point.cs:226
bool IsHotSpring
Definition: Point.cs:351
Point GetRandomPoint(int radius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=100)
Definition: Point.cs:741
bool IsActive(int id, int days=-1)
List< PopItem > items
Definition: PopManager.cs:34
PropsInstalled installed
Definition: PropsManager.cs:8
TraitManager traits
Definition: Props.cs:18
Thing Find(int uid)
Definition: Props.cs:357
List< Room > listRoom
Definition: RoomManager.cs:13
List< Area > listArea
Definition: RoomManager.cs:10
Definition: Room.cs:4
Lot lot
Definition: Room.cs:21
virtual bool IsRegion
Definition: Spatial.cs:501
virtual void Mod(int a)
Definition: Stats.cs:135
override int GetPhase()
Definition: Stats.cs:117
virtual int value
Definition: Stats.cs:56
virtual int max
Definition: Stats.cs:68
Definition: TCText.cs:6
PopManager pop
Definition: TCText.cs:9
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
Thing Find(int uid)
bool IsFull(int y=0)
static Thing CreateFromCategory(string idCat, int lv=-1)
Definition: ThingGen.cs:75
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
bool IsSharedContainer
Definition: Thing.cs:92
virtual AI_Idle.Behaviour IdleBehaviour
Definition: TraitChara.cs:17
virtual string IdAmbience
Definition: TraitChara.cs:137
virtual bool CanFish
Definition: TraitChara.cs:139
virtual bool IdleAct()
Definition: TraitChara.cs:141
TraitMap restSpots
Definition: TraitManager.cs:10
virtual bool AllowTraining
Definition: TraitShackle.cs:13
virtual bool CanRead(Chara c)
Definition: Trait.cs:919
virtual bool CanEat(Chara c)
Definition: Trait.cs:928
virtual int IdleUseChance
Definition: Trait.cs:351
virtual bool IdleUse(Chara c, int dist)
Definition: Trait.cs:597
virtual bool CanDrink(Chara c)
Definition: Trait.cs:937
GameDate date
Definition: World.cs:6
Definition: Zone.cs:12
static int okaerinko
Definition: Zone.cs:31
virtual bool IsNefia
Definition: Zone.cs:278
FactionBranch branch
Definition: Zone.cs:34
Chara Boss
Definition: Zone.cs:83
virtual bool IsTown
Definition: Zone.cs:220
virtual bool PetFollow
Definition: Zone.cs:280
bool IsPCFaction
Definition: Zone.cs:464