Elin Decompiled Documentation EA 23.102 Nightly
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.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 if (config.bUseHotBar)
94 {
95 foreach (Thing item in EClass.pc.things.Where((Thing t) => t.IsHotItem && t.trait is TraitAbility))
96 {
97 Element element = owner.elements.GetElement(item.c_idAbility);
98 if (element != null && func(element) && (element.id != 9150 || EClass.player.favAbility.Contains(element.id)))
99 {
100 AddAbility(element.act, 15);
101 }
102 }
103 }
104 if (!config.bUseInventory)
105 {
106 return;
107 }
108 foreach (Element value in owner.elements.dict.Values)
109 {
110 if ((!config.bUseFav || EClass.player.favAbility.Contains(value.id)) && func(value) && (value.id != 9150 || EClass.player.favAbility.Contains(value.id)))
111 {
112 AddAbility(value.act);
113 }
114 }
115 }
116
117 public override void BuildAbilityList()
118 {
119 GetAbilities((Element e) => e.source.abilityType.Length != 0);
120 AddAbility(ACT.Ranged);
121 AddAbility(ACT.Melee);
122 AddAbility(ACT.Item);
123 }
124
125 public override bool TryAbortCombat()
126 {
127 if (idleCount >= 2)
128 {
129 Msg.Say("abort_idle");
130 return true;
131 }
132 return false;
133 }
134}
Definition: ACT.cs:6
static ActRanged Ranged
Definition: ACT.cs:17
static ActMelee Melee
Definition: ACT.cs:15
static ActItem Item
Definition: ACT.cs:21
new Chara owner
Definition: AIAct.cs:14
override bool Perform()
Definition: ActRanged.cs:65
int c_ammo
Definition: Card.cs:1385
int hp
Definition: Card.cs:226
bool IsRangedWeapon
Definition: Card.cs:2103
bool IsHotItem
Definition: Card.cs:115
Trait trait
Definition: Card.cs:49
ThingContainer things
Definition: Card.cs:34
int Evalue(int ele)
Definition: Card.cs:2431
Definition: Chara.cs:10
bool IsCriticallyWounded(bool includeRide=false)
Definition: Chara.cs:986
Thing FindAmmo(Thing weapon)
Definition: Chara.cs:7051
Party party
Definition: Chara.cs:43
Thing ranged
Definition: Chara.cs:95
Stats mana
Definition: Chara.cs:963
bool CanEquipRanged(Thing t)
Definition: Chara.cs:7000
Color colorActWarnning
Color colorActCriticalWarning
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static ColorProfile Colors
Definition: EClass.cs:38
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
int id
Definition: ELEMENT.cs:240
SourceElement.Row source
Definition: ELEMENT.cs:263
Act act
Definition: ELEMENT.cs:384
ConfigAutoCombat autoCombat
Definition: Game.cs:93
Config config
Definition: Game.cs:215
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:26
Chara destEnemy
Definition: GoalCombat.cs:24
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:138
List< Chara > members
Definition: Party.cs:18
HashSet< int > favAbility
Definition: Player.cs:868
virtual int value
Definition: Stats.cs:56
void Foreach(Action< Thing > action, bool onlyAccessible=true)
Definition: Thing.cs:8