Elin Decompiled Documentation EA 23.326 Nightly
Loading...
Searching...
No Matches
AI_Shear.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class AI_Shear : AI_TargetCard
5{
6 public override bool ShouldAllyAttack(Chara tg)
7 {
8 return tg != target;
9 }
10
11 public override string GetText(string str = "")
12 {
13 string[] list = Lang.GetList("fur");
14 string text = list[Mathf.Clamp(target.c_fur / 10, 0, list.Length - 1)];
15 return "AI_Shear".lang() + "(" + text + ")";
16 }
17
18 public override bool IsValidTC(Card c)
19 {
20 if (c != null && c.IsAliveInCurrentZone)
21 {
22 return c.CanBeSheared();
23 }
24 return false;
25 }
26
27 public override bool Perform()
28 {
29 target = Act.TC;
30 return base.Perform();
31 }
32
33 public override IEnumerable<Status> Run()
34 {
35 yield return DoGoto(target, 1, ignoreConnection: true);
36 int furLv = GetFurLv(target.Chara);
38 {
39 canProgress = () => IsValidTC(target),
40 onProgressBegin = delegate
41 {
42 owner.Say("shear_start", owner, target);
43 if (EClass.rnd(5) == 0)
44 {
45 owner.Talk("goodBoy");
46 }
47 },
48 onProgress = delegate(Progress_Custom p)
49 {
51 owner.PlaySound("shear");
53 if (owner.Dist(target) > 1)
54 {
56 if (owner == null)
57 {
58 p.Cancel();
59 }
60 else if (owner.Dist(target) > 1)
61 {
62 owner.Say("targetTooFar");
63 p.Cancel();
64 }
65 }
66 },
67 onProgressComplete = delegate
68 {
70 {
71 Point pos = target.pos;
72 int num = owner.Tool?.Evalue(770) ?? 0;
73 num = ((num <= 0) ? 1 : (2 + num / 10));
74 if (num > 1)
75 {
76 List<Point> list = EClass._map.ListPointsInSquare(pos, num - 1);
77 list.Sort((Point a, Point b) => a.Distance(pos) - b.Distance(pos));
78 {
79 foreach (Point item in list)
80 {
81 foreach (Chara item2 in item.ListCharas())
82 {
83 if (item2.CanBeSheared())
84 {
85 Shear(item2);
86 }
87 if (owner == null || owner.isDead)
88 {
89 break;
90 }
91 }
92 }
93 return;
94 }
95 }
96 Shear(target.Chara);
97 }
98 }
99 }.SetDuration((6 + furLv * 6) * 100 / (100 + owner.Tool.material.hardness * 2), 3);
100 yield return Do(seq);
101 void Shear(Chara c)
102 {
103 Thing fur = GetFur(c);
104 owner.Say("shear_end", owner, c, fur.Name);
105 owner.Pick(fur, msg: false);
106 owner.elements.ModExp(237, 50 * furLv);
107 owner.stamina.Mod(-1);
108 c.ModAffinity(owner, 1);
110 }
111 }
112
113 public static int GetFurLv(Chara c)
114 {
115 return Mathf.Clamp(c.c_fur / 10 + 1, 1, 5);
116 }
117
118 public static Thing GetFur(Chara c, int mod = 100)
119 {
120 int furLv = GetFurLv(c);
121 string text = "fiber";
122 string idMat = "wool";
123 string text2 = c.id;
124 if (!(text2 == "putty_snow"))
125 {
126 if (text2 == "putty_snow_gold")
127 {
128 idMat = "gold";
129 }
130 else if (!c.Chara.race.fur.IsEmpty())
131 {
132 string[] array = c.Chara.race.fur.Split('/');
133 text = array[0];
134 idMat = array[1];
135 }
136 }
137 else
138 {
139 idMat = "cashmere";
140 }
141 Thing thing = ThingGen.Create(text, idMat);
142 int num = mod * furLv + furLv * furLv * 10;
143 int num2 = c.LV;
144 if (c.IsInCombat || c.IsMinion)
145 {
146 Msg.Say("shear_penalty");
147 num /= 2;
148 num2 /= 2;
149 }
150 int num3 = 20 + thing.material.tier * 20;
151 thing.SetNum(Mathf.Max(num / num3, 1) + EClass.rnd(furLv + 1));
152 thing.SetEncLv(EClass.curve(num2, 30, 10) / 10);
153 thing.elements.ModBase(2, EClass.curve(num2 / 10 * 10, 30, 10));
154 c.c_fur = -5;
155 return thing;
156 }
157}
AnimeID
Definition: AnimeID.cs:2
Status Do(AIAct _seq, Func< Status > _onChildFail=null)
Definition: AIAct.cs:430
virtual Status Cancel()
Definition: AIAct.cs:305
new Chara owner
Definition: AIAct.cs:14
Status DoGoto(Point pos, int dist=0, bool ignoreConnection=false, Func< Status > _onChildFail=null)
Definition: AIAct.cs:446
override IEnumerable< Status > Run()
Definition: AI_Shear.cs:33
override bool ShouldAllyAttack(Chara tg)
Definition: AI_Shear.cs:6
override bool Perform()
Definition: AI_Shear.cs:27
static int GetFurLv(Chara c)
Definition: AI_Shear.cs:113
static Thing GetFur(Chara c, int mod=100)
Definition: AI_Shear.cs:118
override string GetText(string str="")
Definition: AI_Shear.cs:11
override bool IsValidTC(Card c)
Definition: AI_Shear.cs:18
Definition: ACT.cs:62
static Card TC
Definition: ACT.cs:79
void PlayAnime(AnimeID id, bool force)
Definition: Card.cs:11
virtual Chara Chara
Definition: Card.cs:2122
ElementContainerCard elements
Definition: Card.cs:42
string id
Definition: Card.cs:36
SourceMaterial.Row material
Definition: Card.cs:2103
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6602
Thing Tool
Definition: Card.cs:2480
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:7162
Thing SetNum(int a)
Definition: Card.cs:3669
Point pos
Definition: Card.cs:60
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2179
void SetEncLv(int a)
Definition: Card.cs:4038
bool CanBeSheared()
Definition: Card.cs:8383
int Evalue(int ele)
Definition: Card.cs:2704
int Dist(Card c)
Definition: Card.cs:8159
CardRenderer renderer
Definition: Card.cs:64
int c_fur
Definition: Card.cs:1369
int LV
Definition: Card.cs:389
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7280
Definition: Chara.cs:10
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:8344
bool IsInCombat
Definition: Chara.cs:911
override bool IsMinion
Definition: Chara.cs:645
Stats stamina
Definition: Chara.cs:1205
MoveResult TryMoveTowards(Point p)
Definition: Chara.cs:2834
bool isDead
Definition: Chara.cs:393
override void LookAt(Card c)
Definition: Chara.cs:3752
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4542
SourceRace.Row race
Definition: Chara.cs:468
Definition: EClass.cs:6
static int curve(long _a, int start, int step, int rate=75)
Definition: EClass.cs:69
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static Player player
Definition: EClass.cs:13
void ModExp(int ele, float a, bool chain=false)
Element ModBase(int ele, int v)
Definition: Lang.cs:7
static string[] GetList(string id)
Definition: Lang.cs:113
List< Point > ListPointsInSquare(Point center, int radius, bool mustBeWalkable=true, bool los=true)
Definition: Map.cs:2337
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
long shear
Definition: Player.cs:177
Stats stats
Definition: Player.cs:1083
Definition: Point.cs:9
int Distance(Point p)
Definition: Point.cs:995
virtual void Mod(int a)
Definition: Stats.cs:135
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8