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