Elin Decompiled Documentation EA 23.102 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);
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 {
72 owner.Say("shear_end", owner, target, fur.Name);
73 owner.Pick(fur, msg: false);
74 owner.elements.ModExp(237, 50 * furLv);
75 owner.stamina.Mod(-1);
77 }
78 }
79 }.SetDuration((6 + furLv * 6) * 100 / (100 + owner.Tool.material.hardness * 2), 3);
80 yield return Do(seq);
81 }
82
83 public static int GetFurLv(Chara c)
84 {
85 return Mathf.Clamp(c.c_fur / 10 + 1, 1, 5);
86 }
87
88 public static Thing GetFur(Chara c, int mod = 100)
89 {
90 int furLv = GetFurLv(c);
91 string text = "fiber";
92 string idMat = "wool";
93 string text2 = c.id;
94 if (!(text2 == "putty_snow"))
95 {
96 if (text2 == "putty_snow_gold")
97 {
98 idMat = "gold";
99 }
100 else if (!c.Chara.race.fur.IsEmpty())
101 {
102 string[] array = c.Chara.race.fur.Split('/');
103 text = array[0];
104 idMat = array[1];
105 }
106 }
107 else
108 {
109 idMat = "cashmere";
110 }
111 Thing thing = ThingGen.Create(text, idMat);
112 int num = mod * furLv + furLv * furLv * 10;
113 int num2 = c.LV;
114 if (c.IsInCombat || c.IsMinion)
115 {
116 Msg.Say("shear_penalty");
117 num /= 2;
118 num2 /= 2;
119 }
120 int num3 = 20 + thing.material.tier * 20;
121 thing.SetNum(Mathf.Max(num / num3, 1) + EClass.rnd(furLv + 1));
122 thing.SetEncLv(EClass.curve(num2, 30, 10) / 10);
123 thing.elements.ModBase(2, EClass.curve(num2 / 10 * 10, 30, 10));
124 c.c_fur = -5;
125 return thing;
126 }
127}
AnimeID
Definition: AnimeID.cs:2
Status Do(AIAct _seq, Func< Status > _onChildFail=null)
Definition: AIAct.cs:416
virtual Status Cancel()
Definition: AIAct.cs:291
new Chara owner
Definition: AIAct.cs:14
Status DoGoto(Point pos, int dist=0, bool ignoreConnection=false, Func< Status > _onChildFail=null)
Definition: AIAct.cs:432
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:83
static Thing GetFur(Chara c, int mod=100)
Definition: AI_Shear.cs:88
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:1946
ElementContainerCard elements
Definition: Card.cs:37
string id
Definition: Card.cs:31
SourceMaterial.Row material
Definition: Card.cs:1927
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
Thing Tool
Definition: Card.cs:2270
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:5949
Thing SetNum(int a)
Definition: Card.cs:3242
Point pos
Definition: Card.cs:55
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2003
void SetEncLv(int a)
Definition: Card.cs:3567
bool CanBeSheared()
Definition: Card.cs:6996
int Dist(Card c)
Definition: Card.cs:6777
CardRenderer renderer
Definition: Card.cs:57
int c_fur
Definition: Card.cs:1265
int LV
Definition: Card.cs:370
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
Definition: Chara.cs:10
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:7166
bool IsInCombat
Definition: Chara.cs:817
override bool IsMinion
Definition: Chara.cs:612
Stats stamina
Definition: Chara.cs:955
MoveResult TryMoveTowards(Point p)
Definition: Chara.cs:2320
override void LookAt(Card c)
Definition: Chara.cs:3219
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:3920
SourceRace.Row race
Definition: Chara.cs:449
Definition: EClass.cs:5
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:55
static int rnd(int a)
Definition: EClass.cs:50
void ModExp(int ele, int a, bool chain=false)
Element ModBase(int ele, int v)
Definition: Lang.cs:6
static string[] GetList(string id)
Definition: Lang.cs:114
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
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