Elin Modding Docs Doc
Loading...
Searching...
No Matches
ActThrow.cs
1using System;
2using UnityEngine;
3
4// Token: 0x020001C0 RID: 448
5public class ActThrow : ActBaseAttack
6{
7 // Token: 0x17000335 RID: 821
8 // (get) Token: 0x06000CF4 RID: 3316 RVA: 0x00065D49 File Offset: 0x00063F49
9 public override bool CanPressRepeat
10 {
11 get
12 {
13 return true;
14 }
15 }
16
17 // Token: 0x17000336 RID: 822
18 // (get) Token: 0x06000CF5 RID: 3317 RVA: 0x00065D4C File Offset: 0x00063F4C
19 public override TargetType TargetType
20 {
21 get
22 {
23 return TargetType.Ground;
24 }
25 }
26
27 // Token: 0x17000337 RID: 823
28 // (get) Token: 0x06000CF6 RID: 3318 RVA: 0x00065D53 File Offset: 0x00063F53
29 public override int PerformDistance
30 {
31 get
32 {
33 return 99;
34 }
35 }
36
37 // Token: 0x06000CF7 RID: 3319 RVA: 0x00065D58 File Offset: 0x00063F58
38 public override bool CanPerform()
39 {
40 if (this.pcTarget != null && this.pcTarget.ExistsOnMap)
41 {
42 Act.TP.Set(this.pcTarget.pos);
43 }
44 return !Act.TP.IsHidden && Act.CC.CanSeeLos(Act.TP, -1);
45 }
46
47 // Token: 0x06000CF8 RID: 3320 RVA: 0x00065DB0 File Offset: 0x00063FB0
48 public override bool Perform()
49 {
50 if (this.target == null)
51 {
52 this.target = (Act.TC as Thing);
53 }
54 if (this.target == null || this.target.isDestroyed || this.target.GetRootCard() != Act.CC)
55 {
56 return false;
57 }
58 if (this.pcTarget != null)
59 {
60 if (!this.pcTarget.ExistsOnMap)
61 {
62 return false;
63 }
64 Act.TP.Set(this.pcTarget.pos);
65 }
66 ActThrow.Throw(Act.CC, Act.TP, this.target.HasElement(410, 1) ? this.target : this.target.Split(1), ThrowMethod.Default, 0f);
67 return true;
68 }
69
70 // Token: 0x06000CF9 RID: 3321 RVA: 0x00065E6C File Offset: 0x0006406C
71 public static bool CanThrow(Chara c, Thing t, Chara target, Point p = null)
72 {
73 if (t == null)
74 {
75 return false;
76 }
77 if (t.c_isImportant && !t.HasElement(410, 1))
78 {
79 return false;
80 }
81 if (p == null && target != null && target.ExistsOnMap)
82 {
83 p = target.pos;
84 }
85 return p != null && (!p.HasBlock || p.cell.hasDoor || !p.sourceBlock.tileType.IsBlockPass) && !p.Equals(EClass.pc.pos) && !t.trait.CanExtendBuild && !t.trait.CanOnlyCarry;
86 }
87
88 // Token: 0x06000CFA RID: 3322 RVA: 0x00065F08 File Offset: 0x00064108
89 public static EffectIRenderer Throw(Card c, Point p, Thing t, ThrowMethod method = ThrowMethod.Default, float failChance = 0f)
90 {
91 if (failChance > EClass.rndf(1f))
92 {
93 Point randomPoint = p.GetRandomPoint(1, true, true, false, 100);
94 if (randomPoint != null && !randomPoint.Equals(c.pos))
95 {
96 p = randomPoint;
97 }
98 }
99 return ActThrow.Throw(c, p, p.FindAttackTarget(), t, method);
100 }
101
102 // Token: 0x06000CFB RID: 3323 RVA: 0x00065F54 File Offset: 0x00064154
103 public static EffectIRenderer Throw(Card c, Point p, Card target, Thing t, ThrowMethod method = ThrowMethod.Default)
104 {
105 if (t.parent != EClass._zone && !t.HasElement(410, 1))
106 {
107 EClass._zone.AddCard(t, c.pos).KillAnime();
108 }
109 Act.TP.Set(p);
110 Act.TC = target;
111 if (t.trait.ThrowType == ThrowType.Snow)
112 {
113 t.dir = EClass.rnd(2);
114 c.Talk("snow_throw", null, null, false);
115 if (EClass.rnd(2) == 0)
116 {
117 Act.TC = null;
118 }
119 }
120 c.Say("throw", c, t.GetName(NameStyle.Full, 1), null);
121 c.LookAt(p);
122 c.renderer.NextFrame();
123 c.PlaySound("throw", 1f, true);
124 EffectIRenderer result = null;
125 if (c.isSynced || p.IsSync)
126 {
127 result = Effect.Get<EffectIRenderer>((t.trait is TraitBall) ? "throw_ball" : "throw").Play(t, c.pos, p, 0.2f);
128 t.renderer.SetFirst(false, c.renderer.position);
129 }
130 if (!t.HasElement(410, 1))
131 {
132 t._Move(p, Card.MoveType.Walk);
133 }
134 if (!t.trait.CanBeDestroyed)
135 {
136 c.PlaySound("miss", 1f, true);
137 return result;
138 }
139 ThrowType throwType = t.trait.ThrowType;
140 if (throwType - ThrowType.Potion <= 1)
141 {
142 Msg.Say("shatter");
143 }
144 bool flag = method == ThrowMethod.Reward;
145 bool flag2 = method == ThrowMethod.Default;
146 switch (t.trait.ThrowType)
147 {
148 case ThrowType.Potion:
149 flag = true;
150 if (Act.TC != null)
151 {
152 Act.TC.Say("throw_hit", t, Act.TC, null, null);
153 }
154 Act.TP.ModFire(-50);
155 if (Act.TC != null && Act.TC.isChara)
156 {
157 if (t.trait.CanDrink(Act.TC.Chara))
158 {
159 t.trait.OnDrink(Act.TC.Chara);
160 }
161 flag2 = t.IsNegativeGift;
162 Act.TC.Chara.AddCondition<ConWet>(100, false);
163 }
164 else
165 {
166 t.trait.OnThrowGround(c.Chara, Act.TP);
167 }
168 t.Die(null, null, AttackSource.Throw);
169 c.ModExp(108, 50);
170 break;
171 case ThrowType.Vase:
172 t.Die(null, null, AttackSource.Throw);
173 break;
174 case ThrowType.Snow:
175 flag = true;
176 flag2 = false;
177 if (Act.TC != null && Act.TC.isChara)
178 {
179 Act.TC.Say("throw_hit", t, Act.TC, null, null);
180 if (EClass.rnd(2) == 0)
181 {
182 c.Talk("snow_hit", null, null, false);
183 }
184 Act.TC.Chara.AddCondition<ConWet>(50, false);
185 t.Die(null, null, AttackSource.Throw);
186 c.ModExp(108, 50);
187 }
188 break;
189 case ThrowType.Flyer:
190 flag = true;
191 flag2 = false;
192 if (Act.TC != null && Act.TC.isChara && c.isChara)
193 {
194 Act.TC.Say("throw_hit", t, Act.TC, null, null);
195 c.Chara.GiveGift(Act.TC.Chara, t);
196 c.ModExp(108, 50);
197 }
198 break;
199 case ThrowType.MonsterBall:
200 {
201 flag = true;
202 flag2 = false;
203 TraitMonsterBall traitMonsterBall = t.trait as TraitMonsterBall;
204 if (traitMonsterBall.chara != null)
205 {
206 if (!traitMonsterBall.IsLittleBall || EClass._zone is Zone_LittleGarden)
207 {
208 Chara _c = EClass._zone.AddCard(traitMonsterBall.chara, p).Chara;
209 _c.PlayEffect("identify", true, 0f, default(Vector3));
210 t.Die(null, null, AttackSource.None);
211 if (traitMonsterBall.IsLittleBall && _c.id == "littleOne")
212 {
213 _c.orgPos = c.pos.Copy();
214 _c.c_originalHostility = (_c.hostility = Hostility.Neutral);
215 EClass._zone.ModInfluence(5);
216 _c.PlaySound("chime_angel", 1f, true);
217 EClass.core.actionsNextFrame.Add(delegate
218 {
219 _c.Talk("little_saved", null, null, false);
220 });
221 EClass.player.flags.little_saved = true;
222 EClass.player.little_saved++;
223 }
224 else
225 {
226 _c.MakeAlly(true);
227 }
228 }
229 }
230 else if (Act.TC != null && Act.TC.isChara)
231 {
232 Act.TC.Say("throw_hit", t, Act.TC, null, null);
233 Chara chara = Act.TC.Chara;
234 if (traitMonsterBall.IsLittleBall)
235 {
236 if (chara.id != "littleOne" || EClass._zone is Zone_LittleGarden || EClass._zone.IsUserZone)
237 {
238 Msg.Say("monsterball_invalid");
239 break;
240 }
241 }
242 else
243 {
244 if (!chara.trait.CanBeTamed || EClass._zone.IsUserZone)
245 {
246 Msg.Say("monsterball_invalid");
247 break;
248 }
249 if (chara.LV > traitMonsterBall.owner.LV)
250 {
251 Msg.Say("monsterball_lv");
252 break;
253 }
254 if (!EClass.debug.enable && chara.hp > chara.MaxHP / 10)
255 {
256 Msg.Say("monsterball_hp");
257 break;
258 }
259 }
260 Msg.Say("monsterball_capture", c, chara, null, null);
261 chara.PlaySound("identify", 1f, true);
262 chara.PlayEffect("identify", true, 0f, default(Vector3));
263 t.ChangeMaterial("copper");
264 if (chara.IsLocalChara)
265 {
266 string str = "Creating Replacement NPC for:";
267 Chara chara2 = chara;
268 Debug.Log(str + ((chara2 != null) ? chara2.ToString() : null));
269 EClass._map.deadCharas.Add(chara.CreateReplacement());
270 }
271 traitMonsterBall.chara = chara;
272 EClass._zone.RemoveCard(chara);
273 chara.homeZone = null;
274 c.ModExp(108, 100);
275 }
276 break;
277 }
278 case ThrowType.Explosive:
279 flag = true;
280 t.c_uidRefCard = c.uid;
281 t.Die(null, c, AttackSource.Throw);
282 break;
283 case ThrowType.Ball:
284 flag = true;
285 flag2 = false;
286 if (Act.TC != null && Act.TC.isChara)
287 {
288 Act.TC.Say("throw_hit", t, Act.TC, null, null);
289 if (EClass.rnd(2) == 0)
290 {
291 c.Talk("snow_hit", null, null, false);
292 }
293 Act.TC.Say("ball_hit", null, null);
294 Chara chara3 = Act.TC.Chara;
295 if (chara3 != null)
296 {
297 chara3.Pick(t, true, true);
298 }
299 c.ModExp(108, 50);
300 }
301 break;
302 }
303 if (t.trait is TraitDye)
304 {
305 t.trait.OnThrowGround(c.Chara, Act.TP);
306 }
307 if (!flag && Act.TC != null)
308 {
309 AttackProcess.Current.Prepare(c.Chara, t, Act.TC, Act.TP, 0, true);
310 if (AttackProcess.Current.Perform(0, false, 1f, false))
311 {
312 if (Act.TC.IsAliveInCurrentZone && t.trait is TraitErohon && Act.TC.id == t.c_idRefName)
313 {
314 Act.TC.Chara.OnGiveErohon(t);
315 }
316 if (!t.isDestroyed && t.trait.CanBeDestroyed && !t.IsFurniture && !t.category.IsChildOf("instrument") && !t.IsUnique && !t.HasElement(410, 1))
317 {
318 t.Destroy();
319 }
320 }
321 else
322 {
323 c.PlaySound("miss", 1f, true);
324 }
325 }
326 if (EClass.rnd(2) == 0)
327 {
328 c.Chara.RemoveCondition<ConInvisibility>();
329 }
330 if (Act.TC != null)
331 {
332 if (flag2)
333 {
334 c.Chara.DoHostileAction(Act.TC, false);
335 }
336 if (Act.TC.trait.CanBeAttacked && EClass.rnd(2) == 0)
337 {
338 c.Chara.stamina.Mod(-1);
339 }
340 }
341 return result;
342 }
343
344 // Token: 0x04000CFE RID: 3326
345 public Thing target;
346
347 // Token: 0x04000CFF RID: 3327
348 public Chara pcTarget;
349}
Definition Act.2.cs:7
Definition Card.cs:13
Definition Chara.cs:12
Definition Msg.cs:7
Definition Point.cs:11
Definition Thing.cs:10