Elin Decompiled Documentation EA 23.201 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.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.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")) || (owner.isBerserk && !(act is ActMelee) && !(act is ActRanged) && !(act is ActBreathe) && !(act is ActThrow)))
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 bool isHOT;
526 switch (text)
527 {
528 case "any":
529 num = 50;
530 break;
531 case "item":
532 num = (ability.act as ActItem).BuildAct(owner);
533 break;
534 case "wait":
535 if (owner.IsPCParty)
536 {
537 continue;
538 }
539 num = 50;
540 break;
541 case "taunt":
542 {
543 bool flag6 = owner.HasCondition<StanceTaunt>();
544 bool flag7 = tactics.source.taunt != -1 && 100 * owner.hp / owner.MaxHP >= tactics.source.taunt;
545 num = ((flag6 && !flag7) ? 100 : ((!flag6 && flag7) ? 100 : 0));
546 break;
547 }
548 case "song":
549 {
550 bool flag10 = owner.HasCondition<BaseSong>();
551 bool flag11 = owner.mana.value > owner.mana.max / 3;
552 num = ((flag10 && !flag11) ? 100 : ((!flag10 && flag11) ? 100 : 0));
553 break;
554 }
555 case "melee":
556 if (dist > owner.body.GetMeleeDistance())
557 {
558 continue;
559 }
560 num = ((!flag3) ? tactics.P_Melee : ((!owner.IsPC) ? (tactics.P_Melee / 2) : 0));
561 if (isConfused)
562 {
563 num -= (owner.IsPC ? 30 : 10);
564 }
565 if (isBlind)
566 {
567 num -= (owner.IsPC ? 50 : 10);
568 }
569 if (dist <= 1)
570 {
571 if (tc.HasElement(1221))
572 {
573 num -= 40;
574 }
575 if (tc.HasElement(1223))
576 {
577 num -= 40;
578 }
579 if (!owner.IsPC && owner.IsPCFaction && tc.id == "hedgehog_ether")
580 {
581 continue;
582 }
583 if (!owner.IsPCFaction && num < 10)
584 {
585 num = 10;
586 }
587 }
588 break;
589 case "range":
590 if (!flag || EClass.rnd(100) > tactics.RangedChance)
591 {
592 continue;
593 }
594 num = ((!flag3) ? tactics.P_Range : ((!owner.IsPC) ? (tactics.P_Range / 2) : 0));
595 if (isConfused)
596 {
597 num -= (owner.IsPC ? 30 : 10);
598 }
599 if (isBlind)
600 {
601 num -= (owner.IsPC ? 50 : 10);
602 }
603 if (owner.ranged != null && owner.ranged.trait is TraitToolRangeCane && owner.mana.value <= 0)
604 {
605 continue;
606 }
607 break;
608 case "teleport":
609 num = 40;
610 break;
611 case "hot":
612 case "heal":
613 isHOT = text == "hot";
614 num = ForeachChara(ability, (Chara c) => HealFactor(c), isFriendlyAbility: true);
615 if (ability.aiPt || (owner.IsPC && tactics.CastPartyBuff))
616 {
617 ability.pt = true;
618 }
619 break;
620 case "dot":
621 case "attack":
622 case "attackMelee":
623 {
624 if (!flag)
625 {
626 continue;
627 }
628 bool flag8 = text == "dot";
629 if (flag8 && (owner.isRestrained || (tc != null && tc.IsRestrainedResident)))
630 {
631 continue;
632 }
633 num = ((text == "attackMelee") ? tactics.P_Melee : tactics.P_Spell) + GetAttackMod(act);
634 if (num > 0 && flag8)
635 {
636 num += 10;
637 }
638 if (ability.aiPt)
639 {
640 ability.pt = true;
641 }
642 break;
643 }
644 case "attackArea":
645 {
646 if (owner.isRestrained || (tc != null && tc.IsRestrainedResident))
647 {
648 continue;
649 }
650 bool flag9 = ability.act is ActBolt;
652 {
653 continue;
654 }
655 GetNumEnemy(flag9 ? 6 : 5);
656 if (numEnemy == 0 || (owner.IsPCFactionOrMinion && GetNumNeutral(flag9 ? 6 : 5) > 0))
657 {
658 continue;
659 }
660 num = tactics.P_Spell - 20 + numEnemy * 10 + GetAttackMod(act);
661 break;
662 }
663 case "buff":
664 num = ForeachChara(ability, (Chara c) => (!c.HasCondition(s.proc[1])) ? tactics.P_Buff : 0, isFriendlyAbility: true);
665 if (ability.aiPt || (owner.IsPC && tactics.CastPartyBuff))
666 {
667 ability.pt = true;
668 }
669 break;
670 case "buffStats":
671 num = ForeachChara(ability, delegate(Chara c)
672 {
673 Element buffStats2 = c.GetBuffStats(s.proc[1]);
674 return (buffStats2 == null || buffStats2.Value < 0) ? tactics.P_Buff : 0;
675 }, isFriendlyAbility: true);
676 if (ability.aiPt || (owner.IsPC && tactics.CastPartyBuff))
677 {
678 ability.pt = true;
679 }
680 break;
681 case "debuff":
682 if (!flag)
683 {
684 continue;
685 }
686 num = tactics.P_Debuff;
687 if (ability.aiPt)
688 {
689 ability.pt = true;
690 }
691 break;
692 case "debuffStats":
693 if (!flag)
694 {
695 continue;
696 }
697 num = ForeachChara(ability, delegate(Chara c)
698 {
699 Element buffStats = c.GetBuffStats(s.proc[1]);
700 return (buffStats == null || buffStats.Value > 0) ? tactics.P_Debuff : 0;
701 }, isFriendlyAbility: false);
702 if (ability.aiPt)
703 {
704 ability.pt = true;
705 }
706 break;
707 case "ground":
708 if (!flag || owner.isRestrained || (tc != null && tc.IsRestrainedResident))
709 {
710 continue;
711 }
712 num = 50;
713 if (isPCFaction)
714 {
715 num -= 10;
716 }
717 break;
718 case "summon":
719 {
720 if (owner.isRestrained || (tc != null && tc.IsRestrainedResident))
721 {
722 continue;
723 }
724 int num2 = EClass._zone.CountMinions(owner);
725 if (num2 >= owner.MaxSummon)
726 {
727 continue;
728 }
729 num = tactics.P_Summon - 20 * num2 / owner.MaxSummon;
730 break;
731 }
732 case "summonAlly":
733 if (owner.isRestrained || (tc != null && tc.IsRestrainedResident))
734 {
735 continue;
736 }
737 if (owner.IsPC)
738 {
739 if (EClass.player.lastEmptyAlly <= 0)
740 {
741 continue;
742 }
743 }
744 else if (EClass._zone.CountMinions(owner) > 0)
745 {
746 continue;
747 }
748 num = tactics.P_Summon;
749 break;
750 case "summonSpecial":
751 if (owner.GetInt(70) > EClass.world.date.GetRaw())
752 {
753 continue;
754 }
755 num = 1000;
756 break;
757 case "suicide":
759 {
760 continue;
761 }
762 if (owner.HasTag(CTAG.kamikaze))
763 {
764 num = ((dist <= 1) ? 1000 : 0);
765 break;
766 }
767 num = 100 - 125 * owner.hp / owner.MaxHP;
768 if (EClass.rnd(200) <= num && (!owner.IsPowerful || owner.hp < owner.MaxHP / 2))
769 {
770 break;
771 }
772 continue;
773 default:
774 num = 0;
775 break;
776 }
777 switch (act.id)
778 {
779 case 6606:
780 if (owner.mana.value <= 0)
781 {
782 continue;
783 }
784 break;
785 case 6603:
786 if (!tc.IsPCParty || tc.Evalue(418) < 0)
787 {
788 break;
789 }
790 foreach (Chara member in EClass.pc.party.members)
791 {
792 if (member.Evalue(418) < 0)
793 {
794 owner.enemy = (tc = member);
795 return false;
796 }
797 }
798 break;
799 case 6602:
800 if (dist <= 1 || tc.HasCondition<ConEntangle>())
801 {
802 continue;
803 }
804 break;
805 case 6450:
806 if (isPCFaction && (tc.HasElement(1221) || tc.HasElement(1223) || tc.id == "hedgehog_ether"))
807 {
808 continue;
809 }
810 break;
811 case 8200:
812 case 8201:
813 if (owner.HasElement(400))
814 {
815 continue;
816 }
817 break;
818 case 6400:
819 if (isPCFaction)
820 {
821 continue;
822 }
823 break;
824 case 8790:
825 case 8791:
826 if (tc.host != null)
827 {
828 continue;
829 }
830 break;
831 case 6900:
832 if (owner.IsPC)
833 {
834 continue;
835 }
836 if (owner.IsPCParty)
837 {
838 foreach (Chara member2 in EClass.pc.party.members)
839 {
840 float num3 = 100f - (float)(member2.mana.value * 100) / MathF.Max(1f, member2.mana.max);
841 if (num3 > (float)num)
842 {
843 num = (int)num3;
844 }
845 }
846 }
847 else
848 {
849 num = 100 - owner.mana.value * 100 / Mathf.Max(1, owner.mana.max);
850 }
851 break;
852 case 6627:
853 if (Act.CC.GetNearbyCatToSniff() == null || Act.CC.HasCondition<ConHOT>())
854 {
855 continue;
856 }
857 num = 100 - owner.hp * 100 / Mathf.Max(1, owner.MaxHP);
858 break;
859 }
860 if (s.target == "Neighbor")
861 {
862 if (dist > 1)
863 {
864 continue;
865 }
866 num += 10;
867 }
868 if (s.proc.Length != 0 && s.proc[0] == "Debuff" && tc.HasCondition(s.proc[1]))
869 {
870 continue;
871 }
872 if (s.abilityType.Length > 1)
873 {
874 num += (owner.IsPC ? s.abilityType[2] : s.abilityType[1]).ToInt();
875 }
876 if (act is Spell)
877 {
878 if (owner.IsPC)
879 {
880 if (act.vPotential <= 0)
881 {
882 continue;
883 }
884 if (flag2 || isConfused || flag4)
885 {
886 num -= 50;
887 }
888 }
889 else
890 {
891 if (flag2)
892 {
893 num -= 30;
894 }
895 if (isConfused || flag4)
896 {
897 num -= 10;
898 }
899 }
900 }
901 if (num > 0)
902 {
903 num += ability.priorityMod + EClass.rnd(tactics.RandomFacotr + ability.priorityMod);
904 }
905 ability.priority = num;
906 int HealFactor(Chara c)
907 {
908 if (isHOT && c.HasCondition(s.proc[1]))
909 {
910 return 0;
911 }
912 float num4 = (float)c.hp / (float)c.MaxHP;
913 if (num4 > (isHOT ? 0.85f : 0.75f))
914 {
915 return 0;
916 }
917 int num5 = tactics.P_Heal - (int)((float)tactics.P_Heal * num4) + (isHOT ? 50 : 25);
918 foreach (Condition condition in c.conditions)
919 {
920 if (condition is ConFear)
921 {
922 num5 += 10;
923 }
924 else if (condition is ConPoison)
925 {
926 num5 += 2;
927 }
928 else if (condition is ConConfuse)
929 {
930 num5 += 4;
931 }
932 else if (condition is ConDim)
933 {
934 num5 += 6;
935 }
936 else if (condition is ConBleed)
937 {
938 num5 += 8;
939 }
940 }
941 return num5;
942 }
943 }
944 abilities.Sort((ItemAbility a, ItemAbility b) => b.priority - a.priority);
945 foreach (ItemAbility ability2 in abilities)
946 {
947 if (ability2.priority <= 0)
948 {
949 continue;
950 }
952 {
953 Debug.Log(ability2.act.Name + "/" + ability2.priority);
954 }
955 if (ability2.act.source.alias == "ActRanged")
956 {
957 if (TryThrow(dist))
958 {
959 return true;
960 }
961 if (TryUseRanged(dist))
962 {
963 return true;
964 }
965 continue;
966 }
967 Cost cost = ability2.act.GetCost(owner);
968 if (owner.IsPCParty && ability2.pt && !ability2.act.IsTargetHostileParty() && !ability2.act.TargetType.ForceParty && cost.cost * EClass.pc.party.members.Count > owner.mana.value)
969 {
970 continue;
971 }
972 if (isPCFaction && cost.cost > 0)
973 {
974 switch (cost.type)
975 {
976 case CostType.MP:
977 if (cost.cost > owner.mana.value)
978 {
979 continue;
980 }
981 break;
982 case CostType.SP:
983 if (cost.cost > owner.stamina.value)
984 {
985 continue;
986 }
987 break;
988 }
989 }
990 if (cost.cost > 0 && EClass.rnd(100) > tactics.AbilityChance)
991 {
992 continue;
993 }
994 Chara chara = owner;
995 if (ability2.act.CanPerform(owner, ability2.tg ?? tc) && owner.UseAbility(ability2.act, ability2.tg ?? tc, null, (ability2.act.HaveLongPressAction && ability2.pt) || ability2.aiPt))
996 {
998 {
999 Debug.Log("Used Ability: " + chara?.ToString() + "/" + ability2.act?.ToString() + "/" + ability2.tg?.ToString() + "/" + tc);
1000 Debug.Log(ability2.act.CanPerform(chara, ability2.tg ?? tc));
1001 }
1002 return true;
1003 }
1004 }
1006 {
1007 Debug.Log(owner.Name + "/" + abilities.Count);
1008 foreach (ItemAbility ability3 in abilities)
1009 {
1010 Debug.Log(ability3.act.Name + "/" + ability3.priority);
1011 }
1012 }
1013 return false;
1014 void BuildCharaList()
1015 {
1016 if (charaBuilt)
1017 {
1018 return;
1019 }
1020 charas.Clear();
1021 charaBuilt = true;
1022 int sightRadius = owner.GetSightRadius();
1023 foreach (Chara chara2 in EClass._map.charas)
1024 {
1025 if (chara2 != owner)
1026 {
1027 int num8 = owner.Dist(chara2);
1028 if (num8 > sightRadius || !owner.CanSeeLos(chara2, num8))
1029 {
1030 continue;
1031 }
1032 }
1033 charas.Add(chara2);
1034 }
1035 }
1036 int ForeachChara(ItemAbility a, Func<Chara, int> func, bool isFriendlyAbility)
1037 {
1038 if (a.act.TargetType.Range == TargetRange.Self)
1039 {
1040 a.tg = owner;
1041 return func(owner);
1042 }
1043 BuildCharaList();
1044 int num9 = 0;
1045 foreach (Chara chara3 in charas)
1046 {
1047 int num10 = func(chara3);
1048 if (num10 > 0)
1049 {
1050 if (isFriendlyAbility)
1051 {
1052 if (owner.IsPCParty)
1053 {
1054 if (!chara3.IsPCParty)
1055 {
1056 continue;
1057 }
1058 }
1059 else if (!owner.IsFriendOrAbove(chara3))
1060 {
1061 continue;
1062 }
1063 if (chara3 != owner)
1064 {
1065 num10 += tactics.P_Party;
1066 }
1067 }
1068 else if (!owner.IsHostile(chara3))
1069 {
1070 continue;
1071 }
1072 if (num10 >= num9)
1073 {
1074 a.tg = chara3;
1075 num9 = num10;
1076 }
1077 }
1078 }
1079 return num9;
1080 }
1081 int GetAttackMod(Act a)
1082 {
1083 if (!owner.IsPCParty || a.source.aliasRef.IsEmpty())
1084 {
1085 return 0;
1086 }
1087 int num6 = ((a.source.aliasRef == "mold") ? owner.MainElement.id : EClass.sources.elements.alias[a.source.aliasRef].id);
1088 int num7 = -15 * tc.ResistLvFrom(num6);
1089 if (a is ActSword)
1090 {
1091 num7 = 0;
1092 }
1093 switch (num6)
1094 {
1095 case 910:
1096 if (tc.isWet)
1097 {
1098 num7 -= 30;
1099 }
1100 break;
1101 case 911:
1102 if (tc.HasCondition<ConBurning>())
1103 {
1104 num7 -= 30;
1105 }
1106 break;
1107 case 912:
1108 if (tc.isWet)
1109 {
1110 num7 += 30;
1111 }
1112 break;
1113 }
1114 return num7;
1115 }
1116 void GetNumEnemy(int radius)
1117 {
1118 if (numEnemy != -1)
1119 {
1120 return;
1121 }
1122 BuildCharaList();
1123 numEnemy = 0;
1124 foreach (Chara chara4 in charas)
1125 {
1126 if (chara4.host == null && owner.IsHostile(chara4) && owner.Dist(chara4) < radius && owner.CanSeeLos(chara4))
1127 {
1128 numEnemy++;
1129 }
1130 }
1131 }
1132 int GetNumNeutral(int radius)
1133 {
1134 if (numNeutral != -1)
1135 {
1136 return numNeutral;
1137 }
1138 BuildCharaList();
1139 numNeutral = 0;
1140 foreach (Chara chara5 in charas)
1141 {
1142 if (!chara5.IsPCFactionOrMinion && chara5.IsNeutralOrAbove() && owner.Dist(chara5) <= radius && owner.CanSeeLos(chara5))
1143 {
1144 numNeutral++;
1145 }
1146 }
1147 return numNeutral;
1148 }
1149 }
1150
1151 public virtual void BuildAbilityList()
1152 {
1153 foreach (ActList.Item item in owner.ability.list.items)
1154 {
1155 AddAbility(item.act, 0, item.chance, item.pt);
1156 }
1161 {
1162 TryAddAbility(6410);
1163 }
1164 }
1165
1166 public virtual bool TryAbortCombat()
1167 {
1168 return false;
1169 }
1170}
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: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
Definition: Card.cs:11
bool IsPCFactionOrMinion
Definition: Card.cs:2234
Thing Split(int a)
Definition: Card.cs:3382
string id
Definition: Card.cs:33
int GetSightRadius()
Definition: Card.cs:6184
bool IsRestrainedResident
Definition: Card.cs:2220
bool HasElement(int ele, int req=1)
Definition: Card.cs:5725
bool isRestrained
Definition: Card.cs:552
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5939
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6489
int hp
Definition: Card.cs:228
string Name
Definition: Card.cs:2099
bool ExistsOnMap
Definition: Card.cs:2047
bool HasTag(CTAG tag)
Definition: Card.cs:2557
Point pos
Definition: Card.cs:57
int DEX
Definition: Card.cs:2297
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:5973
void ShowEmo(Emo _emo=Emo.none, float duration=0f, bool skipSame=true)
Definition: Card.cs:5907
Trait trait
Definition: Card.cs:51
bool IsPowerful
Definition: Card.cs:2056
MoveResult
Definition: Card.cs:13
bool HasEditorTag(EditorTag tag)
Definition: Card.cs:2562
BossType c_bossType
Definition: Card.cs:1195
int turn
Definition: Card.cs:63
int Evalue(int ele)
Definition: Card.cs:2533
int Dist(Card c)
Definition: Card.cs:7406
bool isHidden
Definition: Card.cs:516
void ModExp(string alias, int a)
Definition: Card.cs:2610
int LV
Definition: Card.cs:372
int ResistLvFrom(int ele)
Definition: Card.cs:5715
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6586
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:5620
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:2625
Element GetBuffStats(string alias)
Definition: Chara.cs:9075
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:2518
Chara GetNearbyCatToSniff()
Definition: Chara.cs:7782
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1232
override bool IsPCParty
Definition: Chara.cs:613
override string ToString()
Definition: Chara.cs:1154
Party party
Definition: Chara.cs:43
List< Condition > conditions
Definition: Chara.cs:209
bool HasCondition(string alias)
Definition: Chara.cs:9063
bool IsNeutralOrAbove()
Definition: Chara.cs:6351
override bool IsMinion
Definition: Chara.cs:625
bool MoveRandom()
Definition: Chara.cs:2523
override bool IsPCFaction
Definition: Chara.cs:669
int MaxSummon
Definition: Chara.cs:712
Thing TryGetThrowable()
Definition: Chara.cs:7483
int calmCheckTurn
Definition: Chara.cs:116
void MakeMinion(Chara _master, MinionType type=MinionType.Default)
Definition: Chara.cs:2286
bool CanSee(Card c)
Definition: Chara.cs:1200
override bool IsPCFactionMinion
Definition: Chara.cs:653
bool IsFriendOrAbove()
Definition: Chara.cs:6395
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:1136
bool FindNewEnemy()
Definition: Chara.cs:6223
Stats stamina
Definition: Chara.cs:1128
Chara parasite
Definition: Chara.cs:30
Chara ride
Definition: Chara.cs:27
bool CanBeTempAlly(Chara c)
Definition: Chara.cs:2273
MoveResult TryMoveTowards(Point p)
Definition: Chara.cs:2563
bool isBerserk
Definition: Chara.cs:122
bool FindNearestNewEnemy()
Definition: Chara.cs:6292
Chara enemy
Definition: Chara.cs:86
CharaAbility ability
Definition: Chara.cs:422
Chara SetEnemy(Chara c=null)
Definition: Chara.cs:6081
bool isBlind
Definition: Chara.cs:130
bool IsMachine
Definition: Chara.cs:901
Tactics tactics
Definition: Chara.cs:832
bool IsHostile()
Definition: Chara.cs:6307
bool isDead
Definition: Chara.cs:387
bool isConfused
Definition: Chara.cs:126
bool TryEquipRanged()
Definition: Chara.cs:7559
void TrySetEnemy(Chara c)
Definition: Chara.cs:6098
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:457
override IEnumerable< Status > Run()
Definition: GoalCombat.cs:53
virtual bool TryThrow(int dist)
Definition: GoalCombat.cs:466
virtual void BuildAbilityList()
Definition: GoalCombat.cs:1151
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:1166
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:1293
int lastEmptyAlly
Definition: Player.cs:1149
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:973
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:529
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
void SetBGM(List< int > ids, bool refresh=true)
Definition: Zone.cs:2867
int CountMinions(Chara c)
Definition: Zone.cs:3589
virtual bool IsTown
Definition: Zone.cs:220
bool IsPCFaction
Definition: Zone.cs:468
Definition: ACT.cs:71
CostType type
Definition: ACT.cs:74
int cost
Definition: ACT.cs:72