Elin Modding Docs Doc
Loading...
Searching...
No Matches
ActRanged.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
5
6// Token: 0x020001C1 RID: 449
7public class ActRanged : ActThrow
8{
9 // Token: 0x17000338 RID: 824
10 // (get) Token: 0x06000CFD RID: 3325 RVA: 0x000667B4 File Offset: 0x000649B4
11 public bool IsReload
12 {
13 get
14 {
15 return Act.CC.IsPC && Act.TC == Act.CC && !Act.CC.HasCondition<ConReload>() && EClass.player.currentHotItem.Thing != null && !(EClass.player.currentHotItem.Thing.trait is TraitToolRangeCane);
16 }
17 }
18
19 // Token: 0x17000339 RID: 825
20 // (get) Token: 0x06000CFE RID: 3326 RVA: 0x00066817 File Offset: 0x00064A17
21 public override CursorInfo CursorIcon
22 {
23 get
24 {
25 return CursorSystem.IconRange;
26 }
27 }
28
29 // Token: 0x1700033A RID: 826
30 // (get) Token: 0x06000CFF RID: 3327 RVA: 0x0006681E File Offset: 0x00064A1E
31 public override int PerformDistance
32 {
33 get
34 {
35 return 99;
36 }
37 }
38
39 // Token: 0x1700033B RID: 827
40 // (get) Token: 0x06000D00 RID: 3328 RVA: 0x00066822 File Offset: 0x00064A22
41 public override string Name
42 {
43 get
44 {
45 if (!this.IsReload)
46 {
47 return base.Name;
48 }
49 return "ActReload".lang();
50 }
51 }
52
53 // Token: 0x06000D01 RID: 3329 RVA: 0x0006683D File Offset: 0x00064A3D
54 public override string GetText(string str = "")
55 {
56 if (!this.IsReload)
57 {
58 return base.GetText(str);
59 }
60 return this.Name;
61 }
62
63 // Token: 0x06000D02 RID: 3330 RVA: 0x00066858 File Offset: 0x00064A58
64 public override bool CanPerform()
65 {
66 if (Act.CC.isRestrained)
67 {
68 return false;
69 }
70 if (Act.CC.HasCondition<ConReload>())
71 {
72 return false;
73 }
74 if (Act.TC == null)
75 {
76 return Act.CC.CanSeeLos(Act.TP, -1);
77 }
78 return Act.TC.IsAliveInCurrentZone && Act.CC.CanSeeLos(Act.TC.pos, -1);
79 }
80
81 // Token: 0x06000D03 RID: 3331 RVA: 0x000668BC File Offset: 0x00064ABC
82 public override bool Perform()
83 {
84 ActRanged.<>c__DisplayClass10_0 CS$<>8__locals1 = new ActRanged.<>c__DisplayClass10_0();
85 CS$<>8__locals1.<>4__this = this;
86 if (Act.TC == null)
87 {
88 Act.TC = Act.TP.FindAttackTarget();
89 }
90 if (Act.TC != null)
91 {
92 Act.TP.Set(Act.TC.pos);
93 }
94 if (Act.TC != null && Act.CC == EClass.pc && !(Act.CC.ai is AI_PracticeDummy) && (Act.TC.trait is TraitTrainingDummy || Act.TC.IsRestrainedResident))
95 {
96 Act.CC.SetAI(new AI_PracticeDummy
97 {
98 target = Act.TC,
99 range = true
100 });
101 return true;
102 }
103 Act.CC.renderer.NextFrame();
104 if (!Act.CC.IsPC)
105 {
106 Act.CC.TryEquipRanged();
107 }
108 CS$<>8__locals1.weapon = Act.CC.ranged;
109 if (CS$<>8__locals1.weapon == null || !CS$<>8__locals1.weapon.CanAutoFire(Act.CC, Act.TC, false))
110 {
111 return false;
112 }
113 if (Act.CC.body.IsTooHeavyToEquip(CS$<>8__locals1.weapon))
114 {
115 if (Act.CC.IsPC)
116 {
117 Msg.Say("tooHeavyToEquip", CS$<>8__locals1.weapon, null, null, null);
118 }
119 return false;
120 }
121 bool flag = CS$<>8__locals1.weapon.trait is TraitToolRangeGun;
122 bool flag2 = CS$<>8__locals1.weapon.trait is TraitToolRangeCane;
123 GameSetting.EffectData effectData;
124 if ((effectData = EClass.setting.effect.guns.TryGetValue(CS$<>8__locals1.weapon.id, null)) == null)
125 {
126 effectData = EClass.setting.effect.guns[flag2 ? "cane" : (flag ? "gun" : "bow")];
127 }
128 GameSetting.EffectData effectData2 = effectData;
129 CS$<>8__locals1.hasHit = false;
130 CS$<>8__locals1.numFire = effectData2.num;
131 CS$<>8__locals1.numFireWithoutDamageLoss = CS$<>8__locals1.numFire;
132 int num = CS$<>8__locals1.weapon.Evalue(602);
133 if (num > 0)
134 {
135 CS$<>8__locals1.numFire += num / 10 + ((num % 10 > EClass.rnd(10)) ? 1 : 0);
136 }
137 CS$<>8__locals1.numFire += Act.CC.Evalue(1652);
138 int num2 = CS$<>8__locals1.numFire;
139 int num3 = 1 + CS$<>8__locals1.weapon.material.hardness / 30 + EClass.rnd(3);
140 CS$<>8__locals1.drill = CS$<>8__locals1.weapon.Evalue(606);
141 CS$<>8__locals1.scatter = CS$<>8__locals1.weapon.Evalue(607);
142 int num4 = CS$<>8__locals1.weapon.Evalue(604);
143 if (num4 > 0)
144 {
145 for (int i = 0; i < CS$<>8__locals1.numFire; i++)
146 {
147 if (Mathf.Sqrt((float)num4) * 5f + 10f > (float)EClass.rnd(100))
148 {
149 num2--;
150 }
151 }
152 num3 = Mathf.Max(1, num3 * 100 / (100 + num4 * 5));
153 }
154 CS$<>8__locals1.missSound = ((CS$<>8__locals1.weapon.trait is TraitToolRangeGun) ? "miss_bullet" : "miss_arrow");
155 if (CS$<>8__locals1.weapon.trait is TraitToolRangeCane)
156 {
157 foreach (Element element in from e in CS$<>8__locals1.weapon.elements.dict.Values
158 where e.source.categorySub == "eleAttack"
159 select e)
160 {
161 num3 += element.source.LV / 15;
162 }
163 if (Act.CC.IsPC)
164 {
165 if (Act.CC.mana.value < num3)
166 {
167 if (!Act.CC.ai.IsNoGoal)
168 {
169 return false;
170 }
171 if (!Dialog.warned && !EClass.debug.godMode)
172 {
173 ActPlan.warning = true;
174 Dialog.TryWarnMana(delegate
175 {
176 if (CS$<>8__locals1.<>4__this.Perform())
177 {
178 EClass.player.EndTurn(true);
179 }
180 });
181 return false;
182 }
183 }
184 EClass.ui.CloseLayers();
185 }
186 }
187 else
188 {
189 if (this.IsReload)
190 {
191 return ActRanged.TryReload(CS$<>8__locals1.weapon, null);
192 }
193 if (CS$<>8__locals1.weapon.c_ammo <= 0)
194 {
195 if (!ActRanged.TryReload(CS$<>8__locals1.weapon, null))
196 {
197 if (Act.CC.IsPC)
198 {
199 EInput.Consume(false, 1);
200 }
201 return false;
202 }
203 if (Act.CC.HasCondition<ConReload>())
204 {
205 return true;
206 }
207 }
208 if (Act.CC.HasCondition<ConFear>())
209 {
210 Act.CC.Say("fear", Act.CC, Act.TC, null, null);
211 if (Act.CC.IsPC)
212 {
213 EInput.Consume(true, 1);
214 }
215 return true;
216 }
217 }
218 Act.CC.LookAt(Act.TP);
219 CS$<>8__locals1.index = 0;
220 CS$<>8__locals1.orgTP = Act.TP.Copy();
221 CS$<>8__locals1.points = new List<Point>();
222 if (CS$<>8__locals1.drill > 0)
223 {
224 CS$<>8__locals1.points = EClass._map.ListPointsInLine(Act.CC.pos, Act.TP, CS$<>8__locals1.drill / 10 + ((CS$<>8__locals1.drill % 10 > EClass.rnd(10)) ? 1 : 0) + 1);
225 }
226 else if (CS$<>8__locals1.scatter > 0)
227 {
228 Act.TP.ForeachNeighbor(delegate(Point _p)
229 {
230 CS$<>8__locals1.points.Add(_p.Copy());
231 }, true);
232 }
233 if (EClass.core.config.game.waitOnRange)
234 {
235 EClass.Wait(0.25f, Act.CC);
236 }
237 CS$<>8__locals1.<Perform>g__Shoot|1(Act.TC, Act.TP);
238 if (CS$<>8__locals1.points.Count > 0)
239 {
240 Point obj = Act.TP.Copy();
241 foreach (Point point in CS$<>8__locals1.points)
242 {
243 if (!point.Equals(obj))
244 {
245 Chara firstChara = point.FirstChara;
246 if ((firstChara == null || firstChara.IsHostile(Act.CC)) && (firstChara != null || CS$<>8__locals1.scatter != 0))
247 {
248 CS$<>8__locals1.<Perform>g__Shoot|1(point.FirstChara, point);
249 }
250 }
251 }
252 }
253 if (!(CS$<>8__locals1.weapon.trait is TraitToolRangeCane))
254 {
255 CS$<>8__locals1.weapon.c_ammo -= num2;
256 if (CS$<>8__locals1.weapon.ammoData != null)
257 {
258 CS$<>8__locals1.weapon.ammoData.Num = CS$<>8__locals1.weapon.c_ammo;
259 }
260 if (CS$<>8__locals1.weapon.c_ammo <= 0)
261 {
262 CS$<>8__locals1.weapon.c_ammo = 0;
263 CS$<>8__locals1.weapon.ammoData = null;
264 }
265 }
266 if (Act.CC.IsPC)
267 {
268 LayerInventory.SetDirty(CS$<>8__locals1.weapon);
269 }
270 if (Act.TC != null && !CS$<>8__locals1.hasHit)
271 {
272 Act.CC.PlaySound(CS$<>8__locals1.missSound, 1f, true);
273 }
274 if (!Act.CC.isDead)
275 {
276 if (EClass.rnd(2) == 0)
277 {
278 Act.CC.RemoveCondition<ConInvisibility>();
279 }
280 if (CS$<>8__locals1.weapon.trait is TraitToolRangeCane)
281 {
282 Act.CC.mana.Mod(-num3 * CS$<>8__locals1.numFire);
283 }
284 }
285 return true;
286 }
287
288 // Token: 0x06000D04 RID: 3332 RVA: 0x00066FCC File Offset: 0x000651CC
289 public static bool TryReload(Thing weapon, Thing ammo = null)
290 {
291 TraitToolRange traitToolRange = weapon.trait as TraitToolRange;
292 if (Act.CC.IsPC)
293 {
294 LayerInventory.SetDirty(weapon);
295 }
296 if (weapon.ammoData != null)
297 {
298 if (weapon.ammoData.Num > 0)
299 {
300 Act.CC.Pick(weapon.ammoData, true, true);
301 }
302 weapon.ammoData = null;
303 }
304 int num;
305 if (Act.CC.IsPC)
306 {
307 if (ammo == null)
308 {
309 ammo = EClass.player.FindAmmo(weapon);
310 }
311 if (ammo == null)
312 {
313 if (!weapon.IsMeleeWithAmmo)
314 {
315 Msg.Say("noAmmo", weapon, null, null, null);
316 }
317 return false;
318 }
319 num = Mathf.Min(ammo.Num, traitToolRange.MaxAmmo);
320 Thing thing = ammo.Split(num);
321 Act.CC.Say("takeAmmo", thing, null, null);
322 if (thing.GetRootCard() == Act.CC)
323 {
324 thing.parent.RemoveCard(thing);
325 }
326 weapon.ammoData = thing;
327 }
328 else
329 {
330 num = traitToolRange.MaxAmmo;
331 }
332 weapon.c_ammo = num;
333 int num2 = traitToolRange.ReloadTurn;
334 num2 = num2 * 100 / (100 + Act.CC.Evalue(1652) * 100);
335 if (traitToolRange.NeedReload && num2 > 0)
336 {
337 Act.CC.AddCondition<ConReload>(num2 * 10, false);
338 }
339 return true;
340 }
341}
Definition Act.2.cs:7
Definition Chara.cs:12
Definition Msg.cs:7
Definition Point.cs:11
Definition Thing.cs:10