Elin Decompiled Documentation EA 23.301 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 {
48 }
49 if (Act.TC == null || Act.TC.pos.Equals(Act.CC.pos))
50 {
51 return false;
52 }
53 if (!Act.CC.IsPC && Act.CC.Dist(Act.TC) != 1)
54 {
55 return false;
56 }
58 {
59 return false;
60 }
61 if (ListPath(Act.CC.pos, Act.TC.pos).Count <= 1)
62 {
63 return false;
64 }
65 Act.TP.Set(Act.TC.pos);
66 return base.CanPerform();
67 }
68
69 public List<Point> ListPath(Point start, Point end)
70 {
71 List<Point> list = new List<Point>();
72 List<Point> list2 = EClass._map.ListPointsInLine(start, end, 20, returnOnBlocked: false);
73 bool flag = start.Distance(end) != 1;
74 if (flag)
75 {
76 list2.Reverse();
77 }
78 foreach (Point item in list2)
79 {
80 if (!item.Equals(start) && (!flag || start.Distance(item) <= start.Distance(end)) && item.IsInBounds)
81 {
82 if (!item.Equals(end) && (item.IsBlocked || (item.HasChara && item.FirstChara.IsMultisize)))
83 {
84 break;
85 }
86 list.Add(item);
87 }
88 }
89 return list;
90 }
91
92 public int GetWeightLimit()
93 {
94 long num = GetPower(Act.CC);
95 if (num * num <= int.MaxValue)
96 {
97 return (int)(num * num);
98 }
99 return int.MaxValue;
100 }
101
102 public int GetDifficulty()
103 {
104 int num = Act.TC.SelfWeight / GetWeightLimit();
105 ConATField condition = Act.TC.GetCondition<ConATField>();
106 if (condition != null)
107 {
108 num += condition.value;
109 }
110 return Mathf.Clamp(num / 33, 0, 3);
111 }
112
113 public void DoDamage(Card c, int dist = 1, int mtp = 100)
114 {
115 long num = Dice.Create("SpTelekinesis", GetPower(Act.CC), Act.CC, this).Roll();
116 num = num * (50 + dist * 25) / 100;
117 if (Act.TC.SelfWeight > 1000)
118 {
119 num = num * (100 + (int)Mathf.Sqrt(Act.TC.SelfWeight / 10) / 2) / 100;
120 }
121 num = num * mtp / 100;
123 c.DamageHP(num, 925, 100, AttackSource.Throw, Act.CC);
124 }
125
126 public override bool Perform()
127 {
128 if (GetDifficulty() * 33 > EClass.rnd(100))
129 {
130 Act.TC.PlayEffect("Element/ball_Gravity");
131 Act.TC.PlaySound("gravity");
132 Act.CC.Say("tooHeavy", Act.TC);
133 return true;
134 }
135 bool flag = Act.TC.Dist(Act.CC) != 1;
136 List<Point> list = ListPath(Act.CC.pos, Act.TC.pos);
137 Act.CC.PlaySound("telekinesis");
138 Act.CC.PlayEffect("telekinesis");
139 if (EClass._zone.IsCrime(Act.CC, this))
140 {
141 Act.CC.pos.TryWitnessCrime(Act.CC, Act.TC.Chara, 5, (Chara c) => EClass.rnd(3) == 0);
142 }
143 Point point = list.Last();
144 for (int i = 0; i < list.Count; i++)
145 {
146 Point point2 = list[i];
147 Effect.Get("telekinesis2").Play(0.1f * (float)i, point2);
148 if (point2.Equals(Act.TC.pos) || !point2.HasChara)
149 {
150 continue;
151 }
152 foreach (Chara item in point2.ListCharas())
153 {
154 Act.TC.Kick(item, ignoreSelf: true, karmaLoss: false);
155 Act.TC.pos.PlayEffect("vanish");
156 if (!flag && (item.isChara || item.trait.CanBeAttacked))
157 {
158 DoDamage(item, i, 50);
159 }
160 }
161 }
162 if (point.HasChara)
163 {
165 }
166 Act.TC.MoveImmediate(point, focus: true, cancelAI: false);
167 Act.TC.pos.PlayEffect("telekinesis");
168 if (!flag)
169 {
170 Act.TC.pos.PlayEffect("vanish");
171 Act.TC.pos.PlaySound("rush");
173 {
174 DoDamage(Act.TC, list.Count);
175 }
176 }
177 if (!flag && Act.TC.isChara && Act.TC.IsAliveInCurrentZone)
178 {
180 }
181 return true;
182 }
183}
AttackSource
Definition: AttackSource.cs:2
override int GetPower(Card c)
Definition: ABILITY.cs:340
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:2200
virtual Chara Chara
Definition: Card.cs:2110
bool isNPCProperty
Definition: Card.cs:557
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6447
virtual int SelfWeight
Definition: Card.cs:2085
void Kick(Point p, bool ignoreSelf=false, bool checkWall=true)
Definition: Card.cs:6126
Point pos
Definition: Card.cs:60
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:6481
Trait trait
Definition: Card.cs:54
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2167
void DamageHP(long dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:4151
virtual bool isChara
Definition: Card.cs:2123
int Dist(Card c)
Definition: Card.cs:8000
void MoveImmediate(Point p, bool focus=true, bool cancelAI=true)
Definition: Card.cs:5989
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7125
Definition: Chara.cs:10
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:9472
override bool IsPC
Definition: Chara.cs:626
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:6494
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:116
List< Point > ListPointsInLine(Point center, Point to, int radius, bool returnOnBlocked=true)
Definition: Map.cs:2327
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:630
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:3603