Elin Modding Docs Doc
Loading...
Searching...
No Matches
AI_Steal.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5// Token: 0x02000201 RID: 513
6public class AI_Steal : AI_TargetCard
7{
8 // Token: 0x170003C0 RID: 960
9 // (get) Token: 0x06000EA3 RID: 3747 RVA: 0x0006D912 File Offset: 0x0006BB12
10 public override TargetType TargetType
11 {
12 get
13 {
14 return TargetType.SelfAndNeighbor;
15 }
16 }
17
18 // Token: 0x06000EA4 RID: 3748 RVA: 0x0006D91C File Offset: 0x0006BB1C
19 public override bool IsValidTC(Card c)
20 {
21 return !EClass._zone.IsUserZone && !(c.isThing & EClass._zone is Zone_LittleGarden) && (c.isNPCProperty || !c.isThing) && c.trait.CanBeStolen && c.c_lockLv <= 0 && (c.isThing || !c.IsPCFaction);
22 }
23
24 // Token: 0x170003C1 RID: 961
25 // (get) Token: 0x06000EA5 RID: 3749 RVA: 0x0006D98E File Offset: 0x0006BB8E
26 public override int MaxRadius
27 {
28 get
29 {
30 return 2;
31 }
32 }
33
34 // Token: 0x170003C2 RID: 962
35 // (get) Token: 0x06000EA6 RID: 3750 RVA: 0x0006D991 File Offset: 0x0006BB91
36 public override bool IsHostileAct
37 {
38 get
39 {
40 return true;
41 }
42 }
43
44 // Token: 0x06000EA7 RID: 3751 RVA: 0x0006D994 File Offset: 0x0006BB94
45 public override bool CanPerform()
46 {
47 return Act.TC != null;
48 }
49
50 // Token: 0x06000EA8 RID: 3752 RVA: 0x0006D99E File Offset: 0x0006BB9E
51 public override bool Perform()
52 {
53 this.target = Act.TC;
54 return base.Perform();
55 }
56
57 // Token: 0x06000EA9 RID: 3753 RVA: 0x0006D9B1 File Offset: 0x0006BBB1
58 public override IEnumerable<AIAct.Status> Run()
59 {
60 Chara chara = this.target.Chara;
61 if (chara != null)
62 {
63 this.target = chara.things.FindStealable();
64 if (this.target == null && chara.GetInt(30, null) < EClass.world.date.GetRaw(0))
65 {
66 if (EClass.rnd(2) == 0)
67 {
68 this.target = chara.AddThing(ThingGen.Create("money", -1, -1).SetNum(1 + EClass.rnd(chara.LV * 10)), true, -1, -1);
69 }
70 else
71 {
72 this.target = chara.AddThing(ThingGen.CreateFromFilter("steal", chara.LV), true, -1, -1);
73 chara.SetInt(30, EClass.world.date.GetRaw(0) + 1440);
74 }
75 }
76 if (this.target == null)
77 {
78 this.owner.Say("steal_chara_nothing", this.owner, chara, null, null);
79 yield return this.Cancel();
80 }
81 this.owner.Say("steal_chara", this.owner, chara, null, null);
82 }
83 else
84 {
85 if (this.target.things.Count > 0)
86 {
87 Thing thing = this.target.things.FindStealable();
88 if (thing != null)
89 {
90 this.target = thing;
91 }
92 }
93 this.owner.Say("steal_thing", this.owner, this.target, null, null);
94 }
95 ICardParent targetParent = this.target.parent;
96 Card card = chara;
97 if (card == null)
98 {
99 card = this.target;
100 }
101 Card root = card.GetRootCard();
102 Progress_Custom progress_Custom = new Progress_Custom();
103 progress_Custom.canProgress = (() => this.target.parent == targetParent && (chara == null || chara.ExistsOnMap));
104 progress_Custom.onProgressBegin = delegate()
105 {
106 };
107 Func<Chara, bool> <>9__4;
108 progress_Custom.onProgress = delegate(Progress_Custom p)
109 {
110 this.owner.LookAt(root);
111 this.owner.PlaySound("steal", 1f, true);
112 root.renderer.PlayAnime(AnimeID.Shiver, default(Vector3), false);
113 if (EClass.debug.godMode)
114 {
115 return;
116 }
117 Chara chara;
118 if (chara != null && this.owner.Dist(chara) > 1)
119 {
120 EClass.pc.TryMoveTowards(chara.pos);
121 if (this.owner == null)
122 {
123 p.Cancel();
124 return;
125 }
126 if (chara != null && this.owner.Dist(chara) > 1)
127 {
128 EClass.pc.Say("targetTooFar", null, null);
129 p.Cancel();
130 return;
131 }
132 }
133 if (this.target.ChildrenAndSelfWeight > this.owner.Evalue(281) * 200 + this.owner.STR * 100 + 1000)
134 {
135 EClass.pc.Say("tooHeavy", this.target, null, null);
136 p.Cancel();
137 return;
138 }
139 int count = this.owner.pos.ListWitnesses(this.owner, 4, WitnessType.crime, chara).Count;
140 Point pos = this.owner.pos;
141 Chara owner = this.owner;
142 chara = chara;
143 int radius = 4;
144 Func<Chara, bool> funcWitness;
145 if ((funcWitness = <>9__4) == null)
146 {
147 funcWitness = (<>9__4 = delegate(Chara c)
148 {
149 int num = c.CanSee(this.owner) ? 0 : 30;
150 int num2 = c.PER * 250 / 100;
151 if (this.target.isThing && this.target.Thing.isEquipped)
152 {
153 num2 *= 2;
154 if (this.target.rarity >= Rarity.Legendary)
155 {
156 num2 *= 2;
157 }
158 if (this.target.rarity >= Rarity.Artifact)
159 {
160 num2 *= 2;
161 }
162 }
163 if (c.IsUnique)
164 {
165 num2 *= 2;
166 }
167 return EClass.rnd(num2) > this.owner.Evalue(281) + this.owner.DEX + num;
168 });
169 }
170 if (pos.TryWitnessCrime(owner, chara, radius, funcWitness))
171 {
172 p.Cancel();
173 return;
174 }
175 this.owner.elements.ModExp(281, Mathf.Min(count * 5 + 5, 25), false);
176 };
177 progress_Custom.onProgressComplete = delegate()
178 {
179 if (this.target.isThing && this.target.IsInstalled)
180 {
181 this.target.SetPlaceState(PlaceState.roaming, false);
182 }
183 this.owner.Say("steal_end", this.owner, this.target, null, null);
184 if (chara != null && (chara.IsPCFaction || chara.OriginalHostility >= Hostility.Friend))
185 {
186 EClass.player.ModKarma(-1);
187 }
188 else if (chara == null || chara.hostility > Hostility.Enemy)
189 {
190 EClass.player.ModKarma(-1);
191 }
192 this.target.isNPCProperty = false;
193 if (!this.target.category.IsChildOf("currency"))
194 {
195 this.target.isStolen = true;
196 }
197 this.owner.Pick(this.target.Thing, true, true);
198 this.owner.elements.ModExp(281, 50, false);
199 if (EClass.rnd(2) == 0)
200 {
201 EClass.pc.stamina.Mod(-1);
202 }
203 };
204 Progress_Custom seq = progress_Custom.SetDuration(20, 4);
205 yield return base.Do(seq, null);
206 yield break;
207 }
208}
Definition AIAct.cs:7
Definition Act.2.cs:7
Definition Card.cs:13
Definition Chara.cs:12
Definition Point.cs:11
Definition Thing.cs:10