Elin Decompiled Documentation EA 23.229 Stable 1st Anniversary Patch 2
Loading...
Searching...
No Matches
GoalCombat.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class GoalCombat : Goal
6{
7 public class ItemAbility
8 {
9 public Act act;
10
11 public int priority;
12
13 public int priorityMod;
14
15 public int chance;
16
17 public Chara tg;
18
19 public bool pt;
20
21 public bool aiPt;
22 }
23
25
26 public Chara tc;
27
28 public int idleCount;
29
30 public int moveFail;
31
32 public List<ItemAbility> abilities;
33
34 public List<Chara> charas = new List<Chara>();
35
37
38 public override bool CancelWhenDamaged => false;
39
40 public override bool CancelOnAggro => false;
41
43
44 public override bool CanManualCancel()
45 {
46 if (owner != null)
47 {
48 return !owner.isBerserk;
49 }
50 return false;
51 }
52
53 public override IEnumerable<Status> Run()
54 {
55 if (destEnemy != null)
56 {
57 owner.enemy = destEnemy;
58 destEnemy = null;
59 }
60 int count = 0;
61 int lostCount = 0;
62 bool dontWander = owner.IsPCParty && !owner.IsPC && EClass.game.config.tactics.dontWander;
63 while (true)
64 {
66 {
67 EClass._zone.SetAlarm(enable: true);
68 }
69 bool canSeeLos = false;
71 {
72 Debug.Log("■" + owner.Name + "/" + count + "/" + lostCount);
73 }
75 {
76 owner.enemy = null;
77 owner.ShowEmo(Emo.happy);
78 yield return Success();
79 }
80 count++;
81 if (dontWander && owner.enemy != null && !EClass.pc.isBlind && !EClass.pc.CanSeeLos(owner.enemy) && (owner.Dist(EClass.pc) > 4 || owner.Dist(owner.enemy) > 1))
82 {
84 if (firstStep.IsValid && !firstStep.HasChara)
85 {
86 owner.enemy = null;
87 }
88 }
89 tc = owner.enemy;
90 if (tc != null && owner.IsPCFaction)
91 {
93 {
94 owner.enemy = null;
95 yield return Success();
96 }
98 {
99 tc = (owner.enemy = null);
100 }
101 }
102 if (tc == null || tc.isDead || !tc.ExistsOnMap || !tc.pos.IsInBounds || lostCount >= (owner.IsPowerful ? 50 : 5) || !owner.CanSee(tc))
103 {
104 tc = (owner.enemy = null);
106 {
107 yield return Success();
108 }
110 lostCount = 0;
111 if (owner.enemy == null)
112 {
113 yield return Success();
114 }
115 tc = owner.enemy;
116 }
117 else
118 {
119 canSeeLos = owner.CanSeeLos(tc);
120 lostCount = ((!canSeeLos) ? (lostCount + 1) : 0);
121 }
122 if (owner.IsPC && tc.HasEditorTag(EditorTag.Invulnerable))
123 {
124 Msg.Say("abort_idle");
125 yield return Success();
126 }
127 if (tc.IsPCFaction && owner.id == "melilith_boss" && EClass._map.plDay.list.Count > 1 && EClass._map.plDay.list[0].data.id != 107)
128 {
129 EClass._zone.SetBGM(107);
130 }
131 if (abilities == null)
132 {
133 abilities = new List<ItemAbility>();
135 }
136 if (owner.IsPCFaction && tc.IsPCFaction && EClass.rnd(5) == 0 && count > 2)
137 {
138 CalmDown();
139 yield return Success();
140 }
142 {
143 if (owner.calmCheckTurn < 0 || (!owner.enemy.IsPCParty && EClass.rnd(10) == 0))
144 {
145 CalmDown();
146 yield return Success();
147 }
149 }
150 if (owner.IsPC)
151 {
152 CursorSystem.ignoreCount = 1;
153 }
154 if (tc.host != null && (tc.hp == 0 || EClass.rnd(5) == 0))
155 {
157 }
158 if (tc.parasite != null && !tc.isRestrained && tc.parasite.hp > 0 && EClass.rnd(5) == 0)
159 {
161 }
162 if (tc.ride != null && !tc.isRestrained && tc.ride.hp > 0 && EClass.rnd(5) == 0)
163 {
165 }
166 if (tc.enemy != null)
167 {
169 }
170 if (!tc.IsMinion && EClass.rnd(10) == 0 && EClass.rnd(tc.DEX + 10) > owner.LV && tc.HasElement(1315) && !owner.HasElement(1315) && owner.IsMachine && owner.CanBeTempAlly(tc) && owner.id != "mech_scarab")
171 {
172 owner.Say("dominate_machine", tc, owner);
173 owner.PlayEffect("boost");
174 owner.PlaySound("boost");
175 owner.ShowEmo(Emo.love);
176 owner.lastEmo = Emo.angry;
178 yield return Success();
179 }
180 if (EClass.rnd(5) == 0 && tc.HasElement(1325) && owner.IsPlant && owner.CanBeTempAlly(tc))
181 {
182 owner.Say("dominate_plant", tc, owner);
183 owner.ShowEmo(Emo.love);
184 owner.lastEmo = Emo.angry;
186 yield return Success();
187 }
188 if (EClass.rnd(20) == 0 && owner.isRestrained)
189 {
190 owner.Talk("restrained");
191 }
192 if (this is GoalAutoCombat)
193 {
195 EClass.pc.ModExp(135, 20);
196 }
197 int dist = owner.Dist(tc);
198 bool move = owner.host == null && (tactics.ChanceMove > EClass.rnd(100) || (owner.IsPC && tc.HasCondition<ConFear>() && dist >= EClass.pc.GetSightRadius() - 1));
199 bool haltSecondMove = false;
200 if (!owner.IsPC && owner.IsNeutralOrAbove() && !owner.isBlind && !owner.isSummon && !owner.IsMinion)
201 {
202 int num = -1;
203 if (tc.HasElement(1221))
204 {
205 num = 1;
206 }
207 if (tc.source.HasTag(CTAG.suicide) && !tc.HasCondition<ConWet>())
208 {
209 num = 3;
210 }
211 if (num > 0)
212 {
213 if (dist <= num)
214 {
215 if (EClass.rnd(15) == 0)
216 {
217 owner.Talk("run_suicide");
218 }
219 if (owner.host == null && owner.TryMoveFrom(tc.pos) != 0)
220 {
221 yield return Status.Running;
222 idleCount = 0;
223 continue;
224 }
226 {
227 Debug.Log("Failed to Run: " + owner.Name);
228 }
229 }
230 if (dist == num + 1)
231 {
232 haltSecondMove = true;
233 move = false;
234 idleCount = 0;
235 }
236 }
237 }
238 if (dontWander)
239 {
240 int num2 = owner.Dist(EClass.pc);
241 if (num2 > 3)
242 {
243 int x = tc.pos.x;
244 int z = tc.pos.z;
245 if (EClass.pc.pos.Distance(owner.pos.x + ((x > owner.pos.x) ? 1 : ((x < owner.pos.x) ? (-1) : 0)), owner.pos.z + ((z > owner.pos.z) ? 1 : ((z < owner.pos.z) ? (-1) : 0))) >= num2)
246 {
247 move = false;
248 haltSecondMove = true;
249 }
250 }
251 }
252 if ((owner.IsPC && EClass.game.config.autoCombat.bDontChase) || (!canSeeLos && tc.isHidden))
253 {
254 move = false;
255 haltSecondMove = true;
256 }
258 {
259 Debug.Log(owner.Name + "/" + move + "/" + haltSecondMove + "/" + dist);
260 }
261 if (move)
262 {
263 if (owner.IsPC && dist <= owner.GetSightRadius() && TryUseAbility(dist, beforeMove: true))
264 {
265 yield return Status.Running;
266 idleCount = 0;
267 continue;
268 }
269 if (TryMove(dist))
270 {
272 {
273 Debug.Log("moved:" + owner.Name);
274 }
275 yield return Status.Running;
276 idleCount = 0;
277 continue;
278 }
279 }
280 if (owner == null)
281 {
282 yield return Cancel();
283 }
284 if (dist <= owner.GetSightRadius() && TryUseAbility(dist))
285 {
286 yield return Status.Running;
287 idleCount = 0;
288 continue;
289 }
291 {
292 Debug.Log(owner.Name + "/" + move + "/" + haltSecondMove + "/" + tactics.ChanceSecondMove);
293 }
294 if (!move && !haltSecondMove && tactics.ChanceSecondMove > EClass.rnd(100) && TryMove(dist))
295 {
296 yield return Status.Running;
297 idleCount = 0;
298 continue;
299 }
300 if (owner == null)
301 {
302 yield return Cancel();
303 }
304 idleCount++;
305 if (TryAbortCombat())
306 {
307 yield return Success();
308 }
309 if (idleCount > 1 && owner.id == "keeper_garden" && owner.enemy != null)
310 {
311 owner.Teleport(owner.enemy.pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: true, ignoreCenter: true, 3) ?? EClass._map.GetRandomSurface(), silent: false, force: true);
312 yield return Success();
313 }
314 if (idleCount > 2)
315 {
316 if (dontWander)
317 {
318 yield return Success();
319 }
320 idleCount = 0;
321 string aiIdle = owner.source.aiIdle;
322 if (aiIdle == "stand" || aiIdle == "root")
323 {
324 yield return Success();
325 }
326 yield return DoGoto(tc.pos);
327 }
328 else if (owner.FindNearestNewEnemy())
329 {
330 yield return Status.Running;
331 continue;
332 }
333 yield return Status.Running;
334 }
335 void CalmDown()
336 {
337 owner.enemy = null;
338 if (owner.ride != null)
339 {
340 owner.ride.enemy = null;
341 }
342 if (owner.parasite != null)
343 {
344 owner.parasite.enemy = null;
345 }
346 owner.hostility = owner.OriginalHostility;
347 if (tc.enemy == owner)
348 {
349 tc.enemy = null;
350 if (tc.ride != null)
351 {
352 tc.ride.enemy = null;
353 }
354 if (tc.parasite != null)
355 {
356 tc.parasite.enemy = null;
357 }
358 tc.hostility = tc.OriginalHostility;
359 }
360 owner.Say("calmDown", owner);
361 }
362 }
363
364 public bool TryMove(int dist)
365 {
367 {
368 Debug.Log("TryMove: " + owner.Name + "/" + dist);
369 }
370 if (owner.host != null)
371 {
372 return false;
373 }
374 if (owner.isBlind)
375 {
376 return owner.MoveRandom();
377 }
378 int num = (tc.HasCondition<ConFear>() ? 1 : tactics.DestDist);
379 if (!owner.IsPC && (tactics.source.id == "archer" || tactics.source.id == "gunner") && !owner.TryEquipRanged())
380 {
381 num = 1;
382 }
383 if (!owner.IsPC && num > 1)
384 {
385 if (tactics.DestDist == 2)
386 {
387 if (EClass.rnd(5) == 0)
388 {
389 num = 1;
390 }
391 }
392 else if (owner.turn / 3 % 5 > 2)
393 {
394 num--;
395 }
396 }
397 bool flag = false;
398 if (dist > num)
399 {
400 flag = owner.TryMoveTowards(tc.pos) != Card.MoveResult.Fail;
401 if (!flag)
402 {
403 moveFail++;
404 }
405 }
406 else if (dist < num)
407 {
408 flag = owner.TryMoveFrom(tc.pos) != Card.MoveResult.Fail;
409 }
410 if (flag)
411 {
412 moveFail = 0;
413 }
415 {
416 Debug.Log("TryMove:" + owner.Name + "/" + flag + "/" + dist + "/" + num);
417 }
418 return flag;
419 }
420
421 public void AddAbility(Act a, int mod = 0, int chance = 100, bool aiPt = false)
422 {
423 abilities.Add(new ItemAbility
424 {
425 act = a,
426 priorityMod = mod,
427 chance = chance,
428 aiPt = aiPt
429 });
430 }
431
432 public void TryAddAbility(int ele)
433 {
434 if (abilities == null)
435 {
437 }
438 foreach (ItemAbility ability in abilities)
439 {
440 Act obj = ability.act;
441 if (obj != null && obj.id == ele)
442 {
443 return;
444 }
445 }
446 AddAbility(Element.Create(ele) as Act);
447 }
448
449 public void TryRemoveAbility(int ele)
450 {
451 if (abilities == null)
452 {
453 return;
454 }
455 foreach (ItemAbility ability in abilities)
456 {
457 Act obj = ability.act;
458 if (obj != null && obj.id == ele)
459 {
460 abilities.Remove(ability);
461 break;
462 }
463 }
464 }
465
466 public virtual bool TryUseRanged(int dist)
467 {
468 if (owner.TryEquipRanged())
469 {
470 return ACT.Ranged.Perform(owner, tc);
471 }
472 return false;
473 }
474
475 public virtual bool TryThrow(int dist)
476 {
477 if (dist > owner.GetSightRadius())
478 {
479 return false;
480 }
481 Thing thing = owner.TryGetThrowable();
482 if (thing == null)
483 {
484 return false;
485 }
486 if (!ACT.Throw.CanPerform(owner, tc, tc.pos))
487 {
488 return false;
489 }
490 ActThrow.Throw(owner, tc.pos, tc, thing.HasElement(410) ? thing : thing.Split(1));
491 return true;
492 }
493
494 public virtual bool TryUseAbility(int dist, bool beforeMove = false)
495 {
496 if (abilities.Count == 0)
497 {
498 Debug.Log("no ability:" + owner);
499 return false;
500 }
501 int numEnemy = -1;
502 int numFriend = -1;
503 int numNeutral = -1;
504 bool charaBuilt = false;
505 bool flag = owner.CanSeeLos(tc, dist);
506 bool isPCFaction = owner.IsPCFaction;
507 bool flag2 = owner.HasCondition<ConSilence>();
508 bool isBlind = owner.isBlind;
509 bool flag3 = owner.HasCondition<ConFear>();
510 bool isConfused = owner.isConfused;
511 bool flag4 = owner.HasCondition<ConDim>();
512 bool flag5 = owner.HasCondition<ConSupress>();
513 foreach (ItemAbility ability in abilities)
514 {
515 Act act = ability.act;
516 ability.priority = 0;
517 ability.tg = null;
518 ability.pt = false;
519 if (EClass.rnd(100) >= ability.chance || (isBlind && ability.act.HasTag("reqSight")) || (owner.isBerserk && !(act is ActMelee) && !(act is ActRanged) && !(act is ActBreathe) && !(act is ActThrow)))
520 {
521 continue;
522 }
523 int num = 0;
525 if (s.abilityType.Length == 0 || (owner.IsPC && flag2 && act is Spell) || (beforeMove && !act.HasTag("before_move")))
526 {
527 continue;
528 }
529 string text = s.abilityType[0];
530 if (flag5 && !(text == "melee") && !(text == "range") && EClass.rnd(2) == 0)
531 {
532 continue;
533 }
534 bool isHOT;
535 switch (text)
536 {
537 case "any":
538 num = 50;
539 break;
540 case "item":
541 num = (ability.act as ActItem).BuildAct(owner);
542 break;
543 case "wait":
544 if (owner.IsPCParty)
545 {
546 continue;
547 }
548 num = 50;
549 break;
550 case "taunt":
551 {
552 bool flag10 = owner.HasCondition<StanceTaunt>();
553 bool flag11 = tactics.source.taunt != -1 && 100 * owner.hp / owner.MaxHP >= tactics.source.taunt;
554 num = ((flag10 && !flag11) ? 100 : ((!flag10 && flag11) ? 100 : 0));
555 break;
556 }
557 case "song":
558 {
559 bool flag7 = owner.HasCondition<BaseSong>();
560 bool flag8 = owner.mana.value > owner.mana.max / 3;
561 num = ((flag7 && !flag8) ? 100 : ((!flag7 && flag8) ? 100 : 0));
562 break;
563 }
564 case "melee":
565 if (tactics.source.melee == 0 || dist > owner.body.GetMeleeDistance())
566 {
567 continue;
568 }
569 num = ((!flag3) ? tactics.P_Melee : ((!owner.IsPC) ? (tactics.P_Melee / 2) : 0));
570 if (isConfused)
571 {
572 num -= (owner.IsPC ? 30 : 10);
573 }
574 if (isBlind)
575 {
576 num -= (owner.IsPC ? 50 : 10);
577 }
578 if (dist <= 1)
579 {
580 if (tc.HasElement(1221))
581 {
582 num -= 40;
583 }
584 if (tc.HasElement(1223))
585 {
586 num -= 40;
587 }
588 if (!owner.IsPC && owner.IsPCFaction && tc.id == "hedgehog_ether")
589 {
590 continue;
591 }
592 if (!owner.IsPCFaction && num < 10)
593 {
594 num = 10;
595 }
596 }
597 break;
598 case "range":
599 if (!flag || EClass.rnd(100) > tactics.RangedChance)
600 {
601 continue;
602 }
603 num = ((!flag3) ? tactics.P_Range : ((!owner.IsPC) ? (tactics.P_Range / 2) : 0));
604 if (isConfused)
605 {
606 num -= (owner.IsPC ? 30 : 10);
607 }
608 if (isBlind)
609 {
610 num -= (owner.IsPC ? 50 : 10);
611 }
612 if (owner.ranged != null && owner.ranged.trait is TraitToolRangeCane && owner.mana.value <= 0)
613 {
614 continue;
615 }
616 break;
617 case "teleport":
618 num = 40;
619 break;
620 case "hot":
621 case "heal":
622 isHOT = text == "hot";
623 num = ForeachChara(ability, (Chara c) => HealFactor(c), isFriendlyAbility: true);
624 if (ability.aiPt || (owner.IsPC && tactics.CastPartyBuff))
625 {
626 ability.pt = true;
627 }
628 break;
629 case "dot":
630 case "attack":
631 case "attackMelee":
632 {
633 if (!flag)
634 {
635 continue;
636 }
637 bool flag9 = text == "dot";
638 if (flag9 && (owner.isRestrained || (tc != null && tc.IsRestrainedResident)))
639 {
640 continue;
641 }
642 num = ((text == "attackMelee") ? tactics.P_Melee : tactics.P_Spell) + GetAttackMod(act);
643 if (num > 0 && flag9)
644 {
645 num += 10;
646 }
647 if (ability.aiPt)
648 {
649 ability.pt = true;
650 }
651 break;
652 }
653 case "attackArea":
654 {
655 if (owner.isRestrained || (tc != null && tc.IsRestrainedResident))
656 {
657 continue;
658 }
659 bool flag6 = ability.act is ActBolt;
661 {
662 continue;
663 }
664 GetNumEnemy(flag6 ? 6 : 5);
665 if (numEnemy == 0 || (owner.IsPCFactionOrMinion && GetNumNeutral(flag6 ? 6 : 5) > 0))
666 {
667 continue;
668 }
669 num = tactics.P_Spell - 20 + numEnemy * 10 + GetAttackMod(act);
670 break;
671 }
672 case "buff":
673 num = ForeachChara(ability, (Chara c) => (!c.HasCondition(s.proc[1])) ? tactics.P_Buff : 0, isFriendlyAbility: true);
674 if (ability.aiPt || (owner.IsPC && tactics.CastPartyBuff))
675 {
676 ability.pt = true;
677 }
678 break;
679 case "buffStats":
680 num = ForeachChara(ability, delegate(Chara c)
681 {
682 Element buffStats2 = c.GetBuffStats(s.proc[1]);
683 return (buffStats2 == null || buffStats2.Value < 0) ? tactics.P_Buff : 0;
684 }, isFriendlyAbility: true);
685 if (ability.aiPt || (owner.IsPC && tactics.CastPartyBuff))
686 {
687 ability.pt = true;
688 }
689 break;
690 case "cure":
691 num = ForeachChara(ability, (Chara c) => c.CountDebuff() * 30, isFriendlyAbility: true);
692 if (ability.aiPt || (owner.IsPC && tactics.CastPartyBuff))
693 {
694 ability.pt = true;
695 }
696 break;
697 case "debuff":
698 if (!flag)
699 {
700 continue;
701 }
702 num = tactics.P_Debuff;
703 if (ability.aiPt)
704 {
705 ability.pt = true;
706 }
707 break;
708 case "debuffStats":
709 if (!flag)
710 {
711 continue;
712 }
713 num = ForeachChara(ability, delegate(Chara c)
714 {
715 Element buffStats = c.GetBuffStats(s.proc[1]);
716 return (buffStats == null || buffStats.Value > 0) ? tactics.P_Debuff : 0;
717 }, isFriendlyAbility: false);
718 if (ability.aiPt)
719 {
720 ability.pt = true;
721 }
722 break;
723 case "ground":
724 if (!flag || owner.isRestrained || (tc != null && tc.IsRestrainedResident))
725 {
726 continue;
727 }
728 num = 50;
729 if (isPCFaction)
730 {
731 num -= 10;
732 }
733 break;
734 case "summon":
735 {
736 if (owner.isRestrained || (tc != null && tc.IsRestrainedResident))
737 {
738 continue;
739 }
740 int num2 = EClass._zone.CountMinions(owner);
741 if (num2 >= owner.MaxSummon)
742 {
743 continue;
744 }
745 num = tactics.P_Summon - 20 * num2 / owner.MaxSummon;
746 break;
747 }
748 case "summonAlly":
749 if (owner.isRestrained || (tc != null && tc.IsRestrainedResident))
750 {
751 continue;
752 }
753 if (owner.IsPC)
754 {
755 if (EClass.player.lastEmptyAlly <= 0)
756 {
757 continue;
758 }
759 }
760 else if (EClass._zone.CountMinions(owner) > 0)
761 {
762 continue;
763 }
764 num = tactics.P_Summon;
765 break;
766 case "summonSpecial":
767 if (owner.GetInt(70) > EClass.world.date.GetRaw())
768 {
769 continue;
770 }
771 num = 1000;
772 break;
773 case "suicide":
775 {
776 continue;
777 }
778 if (owner.HasTag(CTAG.kamikaze))
779 {
780 num = ((dist <= 1) ? 1000 : 0);
781 break;
782 }
783 num = 100 - 125 * owner.hp / owner.MaxHP;
784 if (EClass.rnd(200) <= num && (!owner.IsPowerful || owner.hp < owner.MaxHP / 2))
785 {
786 break;
787 }
788 continue;
789 default:
790 num = 0;
791 break;
792 }
793 switch (act.id)
794 {
795 case 6606:
796 if (owner.mana.value <= 0)
797 {
798 continue;
799 }
800 break;
801 case 6603:
802 if (!tc.IsPCParty || tc.Evalue(418) < 0)
803 {
804 break;
805 }
806 foreach (Chara member in EClass.pc.party.members)
807 {
808 if (member.Evalue(418) < 0)
809 {
810 owner.enemy = (tc = member);
811 return false;
812 }
813 }
814 break;
815 case 6602:
816 if (dist <= 1 || tc.HasCondition<ConEntangle>())
817 {
818 continue;
819 }
820 break;
821 case 6450:
822 if (isPCFaction && (tc.HasElement(1221) || tc.HasElement(1223) || tc.id == "hedgehog_ether"))
823 {
824 continue;
825 }
826 break;
827 case 8200:
828 case 8201:
829 if (owner.HasElement(400))
830 {
831 continue;
832 }
833 break;
834 case 6400:
835 if (isPCFaction)
836 {
837 continue;
838 }
839 break;
840 case 8790:
841 case 8791:
842 if (tc.host != null)
843 {
844 continue;
845 }
846 break;
847 case 6900:
848 if (owner.IsPC)
849 {
850 continue;
851 }
852 if (owner.IsPCParty)
853 {
854 foreach (Chara member2 in EClass.pc.party.members)
855 {
856 float num4 = 100f - (float)(member2.mana.value * 100) / MathF.Max(1f, member2.mana.max);
857 if (num4 > (float)num)
858 {
859 num = (int)num4;
860 }
861 }
862 }
863 else
864 {
865 num = 100 - owner.mana.value * 100 / Mathf.Max(1, owner.mana.max);
866 }
867 break;
868 case 6627:
869 if (Act.CC.GetNearbyCatToSniff() == null || Act.CC.HasCondition<ConHOT>())
870 {
871 continue;
872 }
873 num = 100 - owner.hp * 100 / Mathf.Max(1, owner.MaxHP);
874 break;
875 case 9200:
876 {
877 int num3 = 0;
878 foreach (Condition condition in tc.conditions)
879 {
880 if (condition.Type == ConditionType.Debuff)
881 {
882 num3++;
883 }
884 }
885 num = num3 * 15;
886 break;
887 }
888 }
889 if (s.target == "Neighbor")
890 {
891 if (dist > 1)
892 {
893 continue;
894 }
895 num += 10;
896 }
897 if (s.proc.Length != 0 && s.proc[0] == "Debuff" && tc.HasCondition(s.proc[1]))
898 {
899 continue;
900 }
901 if (s.abilityType.Length > 1)
902 {
903 num += (owner.IsPC ? s.abilityType[2] : s.abilityType[1]).ToInt();
904 }
905 if (act is Spell)
906 {
907 if (owner.IsPC)
908 {
909 if (act.vPotential <= 0)
910 {
911 continue;
912 }
913 if (flag2 || isConfused || flag4)
914 {
915 num -= 50;
916 }
917 }
918 else
919 {
920 if (flag2)
921 {
922 num -= 30;
923 }
924 if (isConfused || flag4)
925 {
926 num -= 10;
927 }
928 }
929 }
930 if (num > 0)
931 {
932 num += ability.priorityMod + EClass.rnd(tactics.RandomFacotr + ability.priorityMod);
933 }
934 ability.priority = num;
935 int HealFactor(Chara c)
936 {
937 if (isHOT && c.HasCondition(s.proc[1]))
938 {
939 return 0;
940 }
941 float num5 = (float)c.hp / (float)c.MaxHP;
942 if (num5 > (isHOT ? 0.85f : 0.75f))
943 {
944 return 0;
945 }
946 int num6 = tactics.P_Heal - (int)((float)tactics.P_Heal * num5) + (isHOT ? 50 : 25);
947 foreach (Condition condition2 in c.conditions)
948 {
949 if (condition2 is ConFear)
950 {
951 num6 += 10;
952 }
953 else if (condition2 is ConPoison)
954 {
955 num6 += 2;
956 }
957 else if (condition2 is ConConfuse)
958 {
959 num6 += 4;
960 }
961 else if (condition2 is ConDim)
962 {
963 num6 += 6;
964 }
965 else if (condition2 is ConBleed)
966 {
967 num6 += 8;
968 }
969 }
970 return num6;
971 }
972 }
973 abilities.Sort((ItemAbility a, ItemAbility b) => b.priority - a.priority);
974 foreach (ItemAbility ability2 in abilities)
975 {
976 if (ability2.priority <= 0)
977 {
978 continue;
979 }
981 {
982 Debug.Log(ability2.act.Name + "/" + ability2.priority);
983 }
984 if (ability2.act.source.alias == "ActRanged")
985 {
986 if (TryThrow(dist))
987 {
988 return true;
989 }
990 if (TryUseRanged(dist))
991 {
992 return true;
993 }
994 continue;
995 }
996 Cost cost = ability2.act.GetCost(owner);
997 if (owner.IsPCParty && ability2.pt && !ability2.act.IsTargetHostileParty() && !ability2.act.TargetType.ForceParty && cost.cost * EClass.pc.party.members.Count > owner.mana.value)
998 {
999 continue;
1000 }
1001 if (isPCFaction && cost.cost > 0)
1002 {
1003 switch (cost.type)
1004 {
1005 case CostType.MP:
1006 if (cost.cost > owner.mana.value)
1007 {
1008 continue;
1009 }
1010 break;
1011 case CostType.SP:
1012 if (cost.cost > owner.stamina.value)
1013 {
1014 continue;
1015 }
1016 break;
1017 }
1018 }
1019 if (cost.cost > 0 && EClass.rnd(100) > tactics.AbilityChance)
1020 {
1021 continue;
1022 }
1023 Chara chara = owner;
1024 if (ability2.act.CanPerform(owner, ability2.tg ?? tc) && owner.UseAbility(ability2.act, ability2.tg ?? tc, null, (ability2.act.HaveLongPressAction && ability2.pt) || ability2.aiPt))
1025 {
1027 {
1028 Debug.Log("Used Ability: " + chara?.ToString() + "/" + ability2.act?.ToString() + "/" + ability2.tg?.ToString() + "/" + tc);
1029 Debug.Log(ability2.act.CanPerform(chara, ability2.tg ?? tc));
1030 }
1031 return true;
1032 }
1033 }
1035 {
1036 Debug.Log(owner.Name + "/" + abilities.Count);
1037 foreach (ItemAbility ability3 in abilities)
1038 {
1039 Debug.Log(ability3.act.Name + "/" + ability3.priority);
1040 }
1041 }
1042 return false;
1043 void BuildCharaList()
1044 {
1045 if (charaBuilt)
1046 {
1047 return;
1048 }
1049 charas.Clear();
1050 charaBuilt = true;
1051 int sightRadius = owner.GetSightRadius();
1052 foreach (Chara chara2 in EClass._map.charas)
1053 {
1054 if (chara2 != owner)
1055 {
1056 int num11 = owner.Dist(chara2);
1057 if (num11 > sightRadius || !owner.CanSeeLos(chara2, num11))
1058 {
1059 continue;
1060 }
1061 }
1062 charas.Add(chara2);
1063 }
1064 }
1065 int ForeachChara(ItemAbility a, Func<Chara, int> func, bool isFriendlyAbility)
1066 {
1067 if (a.act.TargetType.Range == TargetRange.Self)
1068 {
1069 a.tg = owner;
1070 return func(owner);
1071 }
1072 BuildCharaList();
1073 int num7 = 0;
1074 foreach (Chara chara3 in charas)
1075 {
1076 int num8 = func(chara3);
1077 if (num8 > 0)
1078 {
1079 if (isFriendlyAbility)
1080 {
1081 if (owner.IsPCParty)
1082 {
1083 if (!chara3.IsPCParty)
1084 {
1085 continue;
1086 }
1087 }
1088 else if (!owner.IsFriendOrAbove(chara3))
1089 {
1090 continue;
1091 }
1092 if (chara3 != owner)
1093 {
1094 num8 += tactics.P_Party;
1095 }
1096 }
1097 else if (!owner.IsHostile(chara3))
1098 {
1099 continue;
1100 }
1101 if (num8 >= num7)
1102 {
1103 a.tg = chara3;
1104 num7 = num8;
1105 }
1106 }
1107 }
1108 return num7;
1109 }
1110 int GetAttackMod(Act a)
1111 {
1112 if (!owner.IsPCParty || a.source.aliasRef.IsEmpty())
1113 {
1114 return 0;
1115 }
1116 int num9 = ((a.source.aliasRef == "mold") ? owner.MainElement.id : EClass.sources.elements.alias[a.source.aliasRef].id);
1117 int num10 = -15 * tc.ResistLvFrom(num9);
1118 if (a is ActSword)
1119 {
1120 num10 = 0;
1121 }
1122 if (owner.HasElement(1238) && num10 < -15)
1123 {
1124 num10 = -15;
1125 }
1126 switch (num9)
1127 {
1128 case 910:
1129 if (tc.isWet)
1130 {
1131 num10 -= 30;
1132 }
1133 break;
1134 case 911:
1135 if (tc.HasCondition<ConBurning>())
1136 {
1137 num10 -= 30;
1138 }
1139 break;
1140 case 912:
1141 if (tc.isWet)
1142 {
1143 num10 += 30;
1144 }
1145 break;
1146 }
1147 return num10;
1148 }
1149 void GetNumEnemy(int radius)
1150 {
1151 if (numEnemy != -1)
1152 {
1153 return;
1154 }
1155 BuildCharaList();
1156 numEnemy = 0;
1157 foreach (Chara chara4 in charas)
1158 {
1159 if (chara4.host == null && owner.IsHostile(chara4) && owner.Dist(chara4) < radius && owner.CanSeeLos(chara4))
1160 {
1161 numEnemy++;
1162 }
1163 }
1164 }
1165 int GetNumNeutral(int radius)
1166 {
1167 if (numNeutral != -1)
1168 {
1169 return numNeutral;
1170 }
1171 BuildCharaList();
1172 numNeutral = 0;
1173 foreach (Chara chara5 in charas)
1174 {
1175 if (!chara5.IsPCFactionOrMinion && chara5.IsNeutralOrAbove() && owner.Dist(chara5) <= radius && owner.CanSeeLos(chara5))
1176 {
1177 numNeutral++;
1178 }
1179 }
1180 return numNeutral;
1181 }
1182 }
1183
1184 public virtual void BuildAbilityList()
1185 {
1186 foreach (ActList.Item item in owner.ability.list.items)
1187 {
1188 AddAbility(item.act, 0, item.chance, item.pt);
1189 }
1194 {
1195 TryAddAbility(6410);
1196 }
1197 }
1198
1199 public virtual bool TryAbortCombat()
1200 {
1201 return false;
1202 }
1203}
BossType
Definition: BossType.cs:2
CTAG
Definition: CTAG.cs:2
ConditionType
Definition: ConditionType.cs:2
EditorTag
Definition: EditorTag.cs:2
Emo
Definition: Emo.cs:2
Hostility
Definition: Hostility.cs:2
MinionType
Definition: MinionType.cs:2
TargetRange
Definition: TargetRange.cs:2
Definition: ACT.cs:6
static ActRanged Ranged
Definition: ACT.cs:17
static ActThrow Throw
Definition: ACT.cs:19
static ActMelee Melee
Definition: ACT.cs:15
static ActItem Item
Definition: ACT.cs:21
virtual Status Cancel()
Definition: AIAct.cs:291
virtual bool ShouldAllyAttack(Chara tg)
Definition: AIAct.cs:134
new Chara owner
Definition: AIAct.cs:14
Status
Definition: AIAct.cs:8
override string ToString()
Definition: AIAct.cs:124
Status DoGoto(Point pos, int dist=0, bool ignoreConnection=false, Func< Status > _onChildFail=null)
Definition: AIAct.cs:432
void SetTurbo(int mtp=-1)
Definition: AM_Adv.cs:1040
List< Item > items
Definition: ActList.cs:14
override bool Perform()
Definition: ActRanged.cs:65
static EffectIRenderer Throw(Card c, Point p, Thing t, ThrowMethod method=ThrowMethod.Default, float failChance=0f)
Definition: ActThrow.cs:97
override bool CanPerform()
Definition: ActThrow.cs:29
Definition: ACT.cs:62
CostType
Definition: ACT.cs:64
virtual TargetType TargetType
Definition: ACT.cs:142
static Chara CC
Definition: ACT.cs:77
virtual bool HaveLongPressAction
Definition: ACT.cs:133
virtual bool CanPerform()
Definition: ACT.cs:303
bool IsTargetHostileParty()
Definition: ACT.cs:241
static AM_Adv Adv
Definition: ActionMode.cs:15
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
virtual ConditionType Type
Definition: BaseStats.cs:19
Definition: Card.cs:11
bool IsPCFactionOrMinion
Definition: Card.cs:2260
void Teleport(Point point, bool silent=false, bool force=false)
Definition: Card.cs:5755
Thing Split(int a)
Definition: Card.cs:3414
string id
Definition: Card.cs:35
int GetSightRadius()
Definition: Card.cs:6288
bool IsRestrainedResident
Definition: Card.cs:2246
bool HasElement(int ele, int req=1)
Definition: Card.cs:5816
bool isRestrained
Definition: Card.cs:566
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6038
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6593
int hp
Definition: Card.cs:242
string Name
Definition: Card.cs:2125
bool ExistsOnMap
Definition: Card.cs:2073
bool HasTag(CTAG tag)
Definition: Card.cs:2583
Point pos
Definition: Card.cs:59
int DEX
Definition: Card.cs:2323
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6072
void ShowEmo(Emo _emo=Emo.none, float duration=0f, bool skipSame=true)
Definition: Card.cs:6006
Trait trait
Definition: Card.cs:53
bool IsPowerful
Definition: Card.cs:2082
MoveResult
Definition: Card.cs:13
bool HasEditorTag(EditorTag tag)
Definition: Card.cs:2588
BossType c_bossType
Definition: Card.cs:1221
int turn
Definition: Card.cs:65
int Evalue(int ele)
Definition: Card.cs:2559
int Dist(Card c)
Definition: Card.cs:7539
bool isHidden
Definition: Card.cs:530
void ModExp(string alias, int a)
Definition: Card.cs:2636
int LV
Definition: Card.cs:386
int ResistLvFrom(int ele)
Definition: Card.cs:5806
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6690
ActList list
Definition: CharaAbility.cs:12
int GetMeleeDistance()
Definition: CharaBody.cs:432
Definition: Chara.cs:10
bool UseAbility(string idAct, Card tc=null, Point pos=null, bool pt=false)
Definition: Chara.cs:5731
Element MainElement
Definition: Chara.cs:715
new TraitChara trait
Definition: Chara.cs:501
Hostility OriginalHostility
Definition: Chara.cs:469
CharaBody body
Definition: Chara.cs:94
AIAct ai
Definition: Chara.cs:200
MoveResult TryMoveFrom(Point p)
Definition: Chara.cs:2655
Element GetBuffStats(string alias)
Definition: Chara.cs:9226
bool isWet
Definition: Chara.cs:142
override bool IsPC
Definition: Chara.cs:610
Chara host
Definition: Chara.cs:33
bool IsPlant
Definition: Chara.cs:973
Point GetFirstStep(Point newPoint, PathManager.MoveType moveType=PathManager.MoveType.Default)
Definition: Chara.cs:2548
Chara GetNearbyCatToSniff()
Definition: Chara.cs:7933
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1248
override bool IsPCParty
Definition: Chara.cs:613
override string ToString()
Definition: Chara.cs:1170
Party party
Definition: Chara.cs:43
List< Condition > conditions
Definition: Chara.cs:209
bool HasCondition(string alias)
Definition: Chara.cs:9214
bool IsNeutralOrAbove()
Definition: Chara.cs:6466
override bool IsMinion
Definition: Chara.cs:625
bool MoveRandom()
Definition: Chara.cs:2553
int CountDebuff()
Definition: Chara.cs:9243
override bool IsPCFaction
Definition: Chara.cs:669
int MaxSummon
Definition: Chara.cs:712
Thing TryGetThrowable()
Definition: Chara.cs:7628
int calmCheckTurn
Definition: Chara.cs:116
void MakeMinion(Chara _master, MinionType type=MinionType.Default)
Definition: Chara.cs:2316
bool CanSee(Card c)
Definition: Chara.cs:1216
override bool IsPCFactionMinion
Definition: Chara.cs:653
bool IsFriendOrAbove()
Definition: Chara.cs:6510
override int MaxHP
Definition: Chara.cs:706
Thing ranged
Definition: Chara.cs:98
SourceChara.Row source
Definition: Chara.cs:156
Stats mana
Definition: Chara.cs:1152
bool FindNewEnemy()
Definition: Chara.cs:6334
Stats stamina
Definition: Chara.cs:1144
Chara parasite
Definition: Chara.cs:30
Chara ride
Definition: Chara.cs:27
bool CanBeTempAlly(Chara c)
Definition: Chara.cs:2303
MoveResult TryMoveTowards(Point p)
Definition: Chara.cs:2593
bool isBerserk
Definition: Chara.cs:122
bool FindNearestNewEnemy()
Definition: Chara.cs:6403
Chara enemy
Definition: Chara.cs:86
CharaAbility ability
Definition: Chara.cs:422
Chara SetEnemy(Chara c=null)
Definition: Chara.cs:6192
bool isBlind
Definition: Chara.cs:130
bool IsMachine
Definition: Chara.cs:901
Tactics tactics
Definition: Chara.cs:832
bool IsHostile()
Definition: Chara.cs:6418
bool isDead
Definition: Chara.cs:387
bool isConfused
Definition: Chara.cs:126
bool TryEquipRanged()
Definition: Chara.cs:7704
void TrySetEnemy(Chara c)
Definition: Chara.cs:6209
Definition: ConDim.cs:2
Definition: ConHOT.cs:4
Definition: ConWet.cs:2
bool logCombat
Definition: CoreDebug.cs:245
static CursorInfo IconMelee
int GetRaw(int offsetHours=0)
Definition: Date.cs:322
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Zone _zone
Definition: EClass.cs:20
static World world
Definition: EClass.cs:40
static Map _map
Definition: EClass.cs:18
static int rnd(long a)
Definition: EClass.cs:58
static SourceManager sources
Definition: EClass.cs:42
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
int id
Definition: ELEMENT.cs:250
SourceElement.Row source
Definition: ELEMENT.cs:273
int vPotential
Definition: ELEMENT.cs:256
bool HasTag(string tag)
Definition: ELEMENT.cs:473
int Value
Definition: ELEMENT.cs:292
virtual string Name
Definition: ELEMENT.cs:304
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1100
virtual Act.Cost GetCost(Chara c)
Definition: ELEMENT.cs:1024
Act act
Definition: ELEMENT.cs:394
ConfigTactics tactics
Definition: Game.cs:90
ConfigAutoCombat autoCombat
Definition: Game.cs:93
Config config
Definition: Game.cs:215
virtual bool TryUseRanged(int dist)
Definition: GoalCombat.cs:466
override IEnumerable< Status > Run()
Definition: GoalCombat.cs:53
virtual bool TryThrow(int dist)
Definition: GoalCombat.cs:475
virtual void BuildAbilityList()
Definition: GoalCombat.cs:1184
Chara tc
Definition: GoalCombat.cs:26
void TryRemoveAbility(int ele)
Definition: GoalCombat.cs:449
Tactics tactics
Definition: GoalCombat.cs:42
int idleCount
Definition: GoalCombat.cs:28
virtual bool TryAbortCombat()
Definition: GoalCombat.cs:1199
override bool CancelOnAggro
Definition: GoalCombat.cs:40
bool TryMove(int dist)
Definition: GoalCombat.cs:364
Chara destEnemy
Definition: GoalCombat.cs:24
List< ItemAbility > abilities
Definition: GoalCombat.cs:32
List< Chara > charas
Definition: GoalCombat.cs:34
virtual bool TryUseAbility(int dist, bool beforeMove=false)
Definition: GoalCombat.cs:494
override CursorInfo CursorIcon
Definition: GoalCombat.cs:36
override bool CancelWhenDamaged
Definition: GoalCombat.cs:38
int moveFail
Definition: GoalCombat.cs:30
void TryAddAbility(int ele)
Definition: GoalCombat.cs:432
override bool CanManualCancel()
Definition: GoalCombat.cs:44
void AddAbility(Act a, int mod=0, int chance=100, bool aiPt=false)
Definition: GoalCombat.cs:421
Definition: Goal.cs:4
Point GetRandomSurface(int x, int z, int radius, bool walkable=true, bool allowWater=false)
Definition: MapBounds.cs:182
Playlist plDay
Definition: Map.cs:77
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
List< Chara > members
Definition: Party.cs:18
bool IsCriminal
Definition: Player.cs:1334
int lastEmptyAlly
Definition: Player.cs:1190
Definition: Point.cs:9
int x
Definition: Point.cs:36
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
Definition: Point.cs:607
int z
Definition: Point.cs:39
bool IsValid
Definition: Point.cs:88
int Distance(Point p)
Definition: Point.cs:977
bool IsInBounds
Definition: Point.cs:104
bool HasChara
Definition: Point.cs:226
string[] abilityType
SourceElement elements
bool isAlarmSet
Definition: Spatial.cs:430
bool isPeace
Definition: Spatial.cs:406
Definition: SPELL.cs:615
virtual int value
Definition: Stats.cs:56
virtual int max
Definition: Stats.cs:68
int ChanceSecondMove
Definition: Tactics.cs:56
int RandomFacotr
Definition: Tactics.cs:12
int P_Party
Definition: Tactics.cs:71
int P_Spell
Definition: Tactics.cs:100
bool CastPartyBuff
Definition: Tactics.cs:118
int P_Debuff
Definition: Tactics.cs:113
int P_Buff
Definition: Tactics.cs:111
int P_Melee
Definition: Tactics.cs:74
int DestDist
Definition: Tactics.cs:24
int RangedChance
Definition: Tactics.cs:146
SourceTactics.Row source
Definition: Tactics.cs:3
int AbilityChance
Definition: Tactics.cs:130
int P_Range
Definition: Tactics.cs:86
int P_Summon
Definition: Tactics.cs:115
virtual TargetRange Range
Definition: TargetType.cs:25
virtual bool ForceParty
Definition: TargetType.cs:41
Definition: Thing.cs:8
GameDate date
Definition: World.cs:6
int CountMinions(Chara c)
Definition: Zone.cs:3691
virtual bool SetAlarmOnBreakLaw
Definition: Zone.cs:228
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:2917
virtual bool IsTown
Definition: Zone.cs:220
bool IsPCFaction
Definition: Zone.cs:470
virtual void SetAlarm(bool enable)
Definition: Zone.cs:3546
Definition: ACT.cs:71
CostType type
Definition: ACT.cs:74
int cost
Definition: ACT.cs:72