Elin Decompiled Documentation EA 23.264 Nightly
Loading...
Searching...
No Matches
ActTelekinesis.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using UnityEngine;
4
5public class ActTelekinesis : Spell
6{
7 public override bool ShowMapHighlight => true;
8
9 public override int PerformDistance => 20;
10
11 public override bool IsHostileAct
12 {
13 get
14 {
15 if (Act.TC != null)
16 {
17 return Act.TC.isNPCProperty;
18 }
19 return false;
20 }
21 }
22
23 public override string GetText(string str = "")
24 {
25 string text = " (" + Lang.GetList("skillDiff")[GetDifficulty()] + ")";
26 return base.GetText(str) + text;
27 }
28
29 public override void OnMarkMapHighlights()
30 {
32 {
33 return;
34 }
36 List<Point> list = ListPath(EClass.pc.pos, pos);
37 foreach (Point item in list)
38 {
39 item.SetHighlight(list.LastItem().Equals(item) ? 8 : 2);
40 }
41 }
42
43 public override bool CanPerform()
44 {
45 if (!Act.CC.IsPC)
46 {
47 return false;
48 }
50 if (Act.TC == null || Act.TC.pos.Equals(Act.CC.pos))
51 {
52 return false;
53 }
55 {
56 return false;
57 }
58 if (ListPath(Act.CC.pos, Act.TC.pos).Count <= 1)
59 {
60 return false;
61 }
62 Act.TP.Set(Act.TC.pos);
63 return base.CanPerform();
64 }
65
66 public List<Point> ListPath(Point start, Point end)
67 {
68 List<Point> list = new List<Point>();
69 List<Point> list2 = EClass._map.ListPointsInLine(start, end, 20, returnOnBlocked: false);
70 bool flag = start.Distance(end) != 1;
71 if (flag)
72 {
73 list2.Reverse();
74 }
75 foreach (Point item in list2)
76 {
77 if (!item.Equals(start) && (!flag || start.Distance(item) <= start.Distance(end)) && item.IsInBounds)
78 {
79 if (!item.Equals(end) && (item.IsBlocked || (item.HasChara && item.FirstChara.IsMultisize)))
80 {
81 break;
82 }
83 list.Add(item);
84 }
85 }
86 return list;
87 }
88
89 public int GetWeightLimit()
90 {
91 long num = GetPower(Act.CC);
92 if (num * num <= int.MaxValue)
93 {
94 return (int)(num * num);
95 }
96 return int.MaxValue;
97 }
98
99 public int GetDifficulty()
100 {
101 int num = Act.TC.SelfWeight / GetWeightLimit();
102 ConATField condition = Act.TC.GetCondition<ConATField>();
103 if (condition != null)
104 {
105 num += condition.value;
106 }
107 return Mathf.Clamp(num / 33, 0, 3);
108 }
109
110 public void DoDamage(Card c, int dist = 1, int mtp = 100)
111 {
112 long num = Dice.Create("SpTelekinesis", GetPower(Act.CC), Act.CC, this).Roll();
113 num = num * (50 + dist * 25) / 100;
114 if (Act.TC.SelfWeight > 1000)
115 {
116 num = num * (100 + (int)Mathf.Sqrt(Act.TC.SelfWeight / 10) / 2) / 100;
117 }
118 num = num * mtp / 100;
120 c.DamageHP(num, 925, 100, AttackSource.Throw, Act.CC);
121 }
122
123 public override bool Perform()
124 {
125 if (GetDifficulty() * 33 > EClass.rnd(100))
126 {
127 Act.TC.PlayEffect("Element/ball_Gravity");
128 Act.TC.PlaySound("gravity");
129 Act.CC.Say("tooHeavy", Act.TC);
130 return true;
131 }
132 bool flag = Act.TC.Dist(Act.CC) != 1;
133 List<Point> list = ListPath(Act.CC.pos, Act.TC.pos);
134 Act.CC.PlaySound("telekinesis");
135 Act.CC.PlayEffect("telekinesis");
136 if (EClass._zone.IsCrime(Act.CC, this))
137 {
138 Act.CC.pos.TryWitnessCrime(Act.CC, Act.TC.Chara, 5, (Chara c) => EClass.rnd(3) == 0);
139 }
140 Point point = list.Last();
141 for (int i = 0; i < list.Count; i++)
142 {
143 Point point2 = list[i];
144 Effect.Get("telekinesis2").Play(0.1f * (float)i, point2);
145 if (point2.Equals(Act.TC.pos) || !point2.HasChara)
146 {
147 continue;
148 }
149 foreach (Chara item in point2.ListCharas())
150 {
151 Act.TC.Kick(item, ignoreSelf: true, karmaLoss: false);
152 Act.TC.pos.PlayEffect("vanish");
153 if (!flag && (item.isChara || item.trait.CanBeAttacked))
154 {
155 DoDamage(item, i, 50);
156 }
157 }
158 }
159 if (point.HasChara)
160 {
162 }
163 Act.TC.MoveImmediate(point, focus: true, cancelAI: false);
164 Act.TC.pos.PlayEffect("telekinesis");
165 if (!flag)
166 {
167 Act.TC.pos.PlayEffect("vanish");
168 Act.TC.pos.PlaySound("rush");
170 {
171 DoDamage(Act.TC, list.Count);
172 }
173 }
174 if (!flag && Act.TC.isChara && Act.TC.IsAliveInCurrentZone)
175 {
177 }
178 return true;
179 }
180}
AttackSource
Definition: AttackSource.cs:2
override int GetPower(Card c)
Definition: ABILITY.cs:321
override void OnMarkMapHighlights()
override bool CanPerform()
void DoDamage(Card c, int dist=1, int mtp=100)
override string GetText(string str="")
List< Point > ListPath(Point start, Point end)
override bool Perform()
override bool IsHostileAct
override bool ShowMapHighlight
override int PerformDistance
Definition: ACT.cs:62
static Card TC
Definition: ACT.cs:79
static Point TP
Definition: ACT.cs:81
static Chara CC
Definition: ACT.cs:77
Definition: Card.cs:11
virtual bool IsMultisize
Definition: Card.cs:2161
virtual Chara Chara
Definition: Card.cs:2071
bool isNPCProperty
Definition: Card.cs:555
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6314
virtual int SelfWeight
Definition: Card.cs:2046
void Kick(Point p, bool ignoreSelf=false, bool checkWall=true)
Definition: Card.cs:5996
Point pos
Definition: Card.cs:60
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6348
Trait trait
Definition: Card.cs:54
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2128
void DamageHP(long dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:4088
virtual bool isChara
Definition: Card.cs:2084
int Dist(Card c)
Definition: Card.cs:7838
void MoveImmediate(Point p, bool focus=true, bool cancelAI=true)
Definition: Card.cs:5874
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6991
Definition: Chara.cs:10
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9231
override bool IsPC
Definition: Chara.cs:614
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:6314
Definition: Dice.cs:5
static int Roll(int num, int sides, int bonus=0, Card card=null)
Definition: Dice.cs:48
static Dice Create(Element ele, Card c)
Definition: Dice.cs:120
Definition: EClass.cs:6
static Scene scene
Definition: EClass.cs:31
static Zone _zone
Definition: EClass.cs:21
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static Chara pc
Definition: EClass.cs:15
Definition: Effect.cs:7
static Effect Get(Effect original)
Definition: Effect.cs:85
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
Definition: Effect.cs:100
Definition: Lang.cs:6
static string[] GetList(string id)
Definition: Lang.cs:114
List< Point > ListPointsInLine(Point center, Point to, int radius, bool returnOnBlocked=true)
Definition: Map.cs:2326
Definition: Point.cs:9
Point Set(int _x, int _z)
Definition: Point.cs:503
SoundSource PlaySound(string id, bool synced=true, float v=1f, bool spatial=true)
Definition: Point.cs:1253
bool Equals(int _x, int _z)
Definition: Point.cs:960
bool TryWitnessCrime(Chara criminal, Chara target=null, int radius=4, Func< Chara, bool > funcWitness=null)
Definition: Point.cs:873
bool IsValid
Definition: Point.cs:88
Effect PlayEffect(string id)
Definition: Point.cs:1248
int Distance(Point p)
Definition: Point.cs:989
Chara FirstChara
Definition: Point.cs:288
bool HasChara
Definition: Point.cs:238
PointTarget mouseTarget
Definition: Scene.cs:135
Definition: SPELL.cs:624
virtual bool CanBeAttacked
Definition: Trait.cs:177
virtual bool CanBeHeld
Definition: Trait.cs:291
virtual bool CanBeTeleported
Definition: Trait.cs:179
bool IsCrime(Chara c, Act act)
Definition: Zone.cs:3573