Elin Decompiled Documentation EA 23.362 Stable
Loading...
Searching...
No Matches
GoalAutoCombat.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
5
7{
9
10 public List<Chara> listHealthy = new List<Chara>();
11
12 public override bool UseTurbo => EClass.game.config.autoCombat.turbo;
13
14 public override Thing RenderThing => renderThing;
15
17
18 public override Color GetActPlanColor()
19 {
21 {
23 {
24 return EClass.Colors.colorAct;
25 }
27 }
29 }
30
32 {
33 destEnemy = e;
34 EClass.player.autoCombatStartHP = ((EClass.pc.Evalue(1421) > 0) ? (EClass.pc.hp + EClass.pc.mana.value) : EClass.pc.hp);
35 foreach (Chara member in EClass.pc.party.members)
36 {
37 if (!member.IsCriticallyWounded())
38 {
39 listHealthy.Add(member);
40 }
41 }
42 }
43
44 public override bool TryUseRanged(int dist)
45 {
46 Thing ranged = owner.ranged;
47 owner.ranged = null;
49 {
50 FindRanged(hotbar: true);
51 }
52 if (owner.ranged != null && ACT.Ranged.Perform(owner, tc))
53 {
54 if (owner == null)
55 {
56 return true;
57 }
59 if (owner.ranged != ranged)
60 {
61 owner.ranged = ranged;
62 }
63 return true;
64 }
65 return false;
66 void FindRanged(bool hotbar)
67 {
68 owner.things.Foreach(delegate(Thing t)
69 {
70 if (t.IsHotItem)
71 {
72 if (!hotbar)
73 {
74 return false;
75 }
76 }
77 else if (hotbar)
78 {
79 return false;
80 }
81 if (t.IsRangedWeapon && (t.trait is TraitToolRangeCane || t.trait is TraitToolRangeSling || t.c_ammo > 0 || EClass.pc.FindAmmo(t) != null) && owner.CanEquipRanged(t))
82 {
83 owner.ranged = t;
84 return true;
85 }
86 return false;
87 });
88 }
89 }
90
91 public void GetAbilities(Func<Element, bool> func)
92 {
93 List<int> list = new List<int>();
94 foreach (Thing thing in EClass.pc.things)
95 {
96 if (!(thing.trait is TraitGrimoireForbidden))
97 {
98 continue;
99 }
100 foreach (Thing thing2 in thing.things)
101 {
102 if (thing2.trait is TraitAbility)
103 {
104 list.Add((thing2.trait as TraitAbility).act?.id ?? 0);
105 }
106 }
107 }
108 if (config.bUseHotBar)
109 {
110 foreach (Thing item in EClass.pc.things.Where((Thing t) => t.IsHotItem && t.trait is TraitAbility))
111 {
112 Element element = owner.elements.GetElement(item.c_idAbility);
113 if (element != null && func(element) && (element.id != 9150 || EClass.player.favAbility.Contains(element.id)) && !list.Contains(element.id))
114 {
115 AddAbility(element.act, 15);
116 }
117 }
118 }
119 if (!config.bUseInventory)
120 {
121 return;
122 }
123 foreach (Element value in owner.elements.dict.Values)
124 {
125 if ((!config.bUseFav || EClass.player.favAbility.Contains(value.id)) && func(value) && (value.id != 9150 || EClass.player.favAbility.Contains(value.id)) && !list.Contains(value.id))
126 {
127 AddAbility(value.act);
128 }
129 }
130 }
131
132 public override void BuildAbilityList()
133 {
134 base.BuildAbilityList();
135 GetAbilities((Element e) => e.source.abilityType.Length != 0);
136 }
137
138 public override bool TryAbortCombat()
139 {
140 if (idleCount >= 2)
141 {
142 Msg.Say("abort_idle");
143 return true;
144 }
145 ConDeathSentense condition = owner.GetCondition<ConDeathSentense>();
146 if (condition != null && condition.value <= 3)
147 {
148 Msg.Say("abort_sentense");
149 return true;
150 }
151 return false;
152 }
153}
Definition: ACT.cs:6
static ActRanged Ranged
Definition: ACT.cs:17
new Chara owner
Definition: AIAct.cs:14
override bool Perform()
Definition: ActRanged.cs:65
int c_ammo
Definition: Card.cs:1513
int hp
Definition: Card.cs:245
bool IsRangedWeapon
Definition: Card.cs:2309
bool IsHotItem
Definition: Card.cs:122
Trait trait
Definition: Card.cs:54
ThingContainer things
Definition: Card.cs:39
int Evalue(int ele)
Definition: Card.cs:2716
Definition: Chara.cs:10
bool IsCriticallyWounded(bool includeRide=false)
Definition: Chara.cs:1261
Thing FindAmmo(Thing weapon)
Definition: Chara.cs:8373
Party party
Definition: Chara.cs:45
Thing ranged
Definition: Chara.cs:100
Stats mana
Definition: Chara.cs:1238
bool CanEquipRanged(Thing t)
Definition: Chara.cs:8322
Color colorActWarnning
Color colorActCriticalWarning
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static ColorProfile Colors
Definition: EClass.cs:39
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
int id
Definition: ELEMENT.cs:259
SourceElement.Row source
Definition: ELEMENT.cs:282
Act act
Definition: ELEMENT.cs:403
ConfigAutoCombat autoCombat
Definition: Game.cs:94
Config config
Definition: Game.cs:219
override Thing RenderThing
ConfigAutoCombat config
override bool TryAbortCombat()
GoalAutoCombat(Chara e)
override bool TryUseRanged(int dist)
override Color GetActPlanColor()
List< Chara > listHealthy
override bool UseTurbo
override void BuildAbilityList()
void GetAbilities(Func< Element, bool > func)
Chara tc
Definition: GoalCombat.cs:28
Chara destEnemy
Definition: GoalCombat.cs:26
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
bool IsCriticallyWounded(bool includePc=false)
Definition: Party.cs:174
List< Chara > members
Definition: Party.cs:19
HashSet< int > favAbility
Definition: Player.cs:1146
virtual int value
Definition: Stats.cs:56
void Foreach(Action< Thing > action, bool onlyAccessible=true)
Definition: Thing.cs:8