Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ActMelee.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class ActMelee : ActBaseAttack
5{
6 public override int PerformDistance
7 {
8 get
9 {
10 if (Act.CC != null)
11 {
12 return Act.CC.body.GetMeleeDistance();
13 }
14 return 1;
15 }
16 }
17
18 public override bool ResetAxis => true;
19
20 public override bool CanPressRepeat => true;
21
22 public bool HideHint(Card c)
23 {
24 if (!EClass.pc.isBlind && c != null)
25 {
26 if (c.isChara)
27 {
28 return !EClass.pc.CanSee(c);
29 }
30 return false;
31 }
32 return true;
33 }
34
35 public override string GetHintText(string str = "")
36 {
37 return "";
38 }
39
40 public override string GetTextSmall(Card c)
41 {
42 if (!HideHint(c))
43 {
44 return base.GetTextSmall(c);
45 }
46 return null;
47 }
48
49 public override CursorInfo GetCursorIcon(Card c)
50 {
51 if (!HideHint(c))
52 {
54 }
55 return null;
56 }
57
58 public override bool ShowMouseHint(Card c)
59 {
60 return !HideHint(c);
61 }
62
63 public override bool CanPerform()
64 {
65 if (Act.TC == null || !Act.TC.IsAliveInCurrentZone)
66 {
67 return false;
68 }
70 {
71 return false;
72 }
73 if (PerformDistance == 1)
74 {
76 {
77 return false;
78 }
79 }
80 else if (!Act.CC.CanSeeLos(Act.TC))
81 {
82 return false;
83 }
84 return base.CanPerform();
85 }
86
87 public override bool Perform()
88 {
89 return Attack();
90 }
91
92 public bool Attack(float dmgMulti = 1f, bool maxRoll = false)
93 {
94 Act.CC.combatCount = 10;
98 {
99 Act.CC.Say("fear", Act.CC, Act.TC);
100 if (Act.CC.IsPC)
101 {
102 EInput.Consume(consumeAxis: true);
103 }
104 return true;
105 }
107 Act.TC?.Chara?.RequestProtection(Act.CC, delegate(Chara c)
108 {
109 Act.TC = c;
110 });
111 CellEffect effect = Act.TP.cell.effect;
112 if (effect != null && effect.id == 6 && EClass.rnd(2) == 0)
113 {
114 Act.CC.PlaySound("miss");
115 Act.CC.Say("abMistOfDarkness_miss", Act.CC);
116 return true;
117 }
118 bool hasHit = false;
119 bool usedWeapon = false;
120 bool usedTalisman = false;
121 int count = 0;
122 int dist = Act.CC.Dist(Act.TC);
123 Point orgPos = Act.TC.pos.Copy();
124 Card orgTC = Act.TC;
125 foreach (BodySlot slot in Act.CC.body.slots)
126 {
127 _Attack(slot);
128 }
129 if (!usedWeapon)
130 {
131 _Attack(null);
132 }
134 {
135 EClass.Wait(0.25f, Act.CC);
136 }
137 if (!hasHit)
138 {
139 Act.CC.PlaySound("miss");
140 }
141 if (EClass.rnd(2) == 0)
142 {
143 Act.CC.RemoveCondition<ConInvisibility>();
144 }
145 return true;
146 void _Attack(BodySlot slot)
147 {
148 Act.TC = orgTC;
149 Act.TP = orgPos;
150 Thing w;
151 int splash;
152 int chaser;
153 int flurry;
154 int frustration;
155 int feint;
156 if (Act.TC != null && Act.TC.IsAliveInCurrentZone)
157 {
158 w = null;
159 if (slot != null)
160 {
161 if (slot.thing == null || slot.elementId != 35 || slot.thing.source.offense.Length < 2)
162 {
163 return;
164 }
165 w = slot.thing;
166 }
167 int num = 1 + Mathf.Max(Act.CC.Evalue(666), (w != null) ? w.Evalue(666) : 0);
168 if (dist <= 1 || dist <= num)
169 {
170 if (w != null)
171 {
172 usedWeapon = true;
173 if (w.IsMeleeWithAmmo && Act.CC.IsPC && w.c_ammo <= 0 && !Act.CC.HasCondition<ConReload>())
174 {
176 }
177 }
178 int num2 = GetWeaponEnc(606, addSelfEnc: false);
179 int scatter = GetWeaponEnc(607, addSelfEnc: false);
180 splash = GetWeaponEnc(608, addSelfEnc: true);
181 chaser = GetWeaponEnc(620, addSelfEnc: true);
182 flurry = GetWeaponEnc(621, addSelfEnc: true);
183 frustration = GetWeaponEnc(624, addSelfEnc: true);
184 int num3 = GetWeaponEnc(622, addSelfEnc: true);
185 feint = GetWeaponEnc(623, addSelfEnc: true);
186 List<Point> list2 = EClass._map.ListPointsInLine(Act.CC.pos, Act.TC.pos, num2 / 10 + ((num2 % 10 > EClass.rnd(10)) ? 1 : 0) + 1);
187 AttackWithFlurry(Act.TC, Act.TP, 1f, subAttack: false);
188 if (num2 > 0)
189 {
190 foreach (Point item in list2)
191 {
192 if (!item.Equals(orgPos))
193 {
194 Chara firstChara = item.FirstChara;
195 if (firstChara != null && firstChara.IsHostile(Act.CC))
196 {
197 AttackWithFlurry(firstChara, item, 1f, subAttack: false);
198 }
199 }
200 }
201 }
202 else if (scatter > 0)
203 {
204 Act.TP.ForeachNeighbor(delegate(Point p)
205 {
206 if (!p.Equals(orgPos))
207 {
208 Chara firstChara2 = p.FirstChara;
209 if (firstChara2 != null && firstChara2.IsHostile(Act.CC))
210 {
211 AttackWithFlurry(firstChara2, p, Mathf.Min(0.5f + 0.05f * Mathf.Sqrt(scatter), 1f + 0.01f * Mathf.Sqrt(scatter)), subAttack: true);
212 }
213 }
214 });
215 }
216 else if (num3 > 0)
217 {
218 List<Point> list = new List<Point>();
219 Act.TP.ForeachNeighbor(delegate(Point p)
220 {
221 list.Add(p.Copy());
222 });
223 list.Shuffle();
224 int num4 = 0;
225 for (int i = 0; i < 9 && num3 > EClass.rnd(10 + (int)Mathf.Pow(3f, i + 2)); i++)
226 {
227 num4++;
228 }
229 foreach (Point item2 in list)
230 {
231 foreach (Card item3 in item2.ListCards().Copy())
232 {
233 if (num4 <= 0 || !Act.CC.IsAliveInCurrentZone)
234 {
235 break;
236 }
237 if (item3.trait.CanBeAttacked || (item3.isChara && item3.Chara.IsHostile(Act.CC)))
238 {
239 AttackWithFlurry(item3, item2, 1f, subAttack: true);
240 num4--;
241 }
242 }
243 }
244 }
245 count++;
246 }
247 }
248 void Attack(Card _tc, Point _tp, float mtp, bool subAttack)
249 {
250 Act.TC = _tc;
251 Act.TP = _tp;
253 int num5 = 1;
254 if (chaser > 0)
255 {
256 for (int j = 0; j < 10; j++)
257 {
258 if (chaser > EClass.rnd(4 + (int)Mathf.Pow(4f, j + 2)))
259 {
260 num5++;
261 }
262 }
263 }
264 bool flag = false;
265 for (int k = 0; k < num5; k++)
266 {
267 if (k > 0)
268 {
269 Act.CC.Say("attack_chaser");
270 }
271 flag = AttackProcess.Current.Perform(count, hasHit, dmgMulti * mtp, maxRoll, subAttack);
272 if (!flag && frustration > 0 && 10f + 2f * Mathf.Sqrt(frustration) > (float)EClass.rnd(100))
273 {
274 AttackProcess.Current.critFury = true;
275 flag = AttackProcess.Current.Perform(count, hasHit, dmgMulti * mtp, maxRoll, subAttack);
276 AttackProcess.Current.critFury = false;
277 }
279 {
280 break;
281 }
282 }
283 if (w != null && w.c_ammo > 0 && !Act.CC.HasCondition<ConReload>())
284 {
285 bool flag2 = true;
286 TraitAmmo traitAmmo = ((w.ammoData == null) ? null : (w.ammoData.trait as TraitAmmo));
287 if (traitAmmo != null && traitAmmo is TraitAmmoTalisman traitAmmoTalisman)
288 {
289 flag2 = false;
290 if (flag && !usedTalisman && Act.TC != null && Act.TC.IsAliveInCurrentZone)
291 {
292 Act act = Act.CC.elements.GetElement(traitAmmoTalisman.owner.refVal)?.act ?? ACT.Create(traitAmmoTalisman.owner.refVal);
293 Act.powerMod = traitAmmo.owner.encLV;
294 if (act.Perform(Act.CC, Act.TC, Act.TP))
295 {
296 usedTalisman = true;
297 flag2 = true;
298 int spellExp = Act.CC.elements.GetSpellExp(Act.CC, act, 200);
299 Act.CC.ModExp(act.id, spellExp);
300 }
301 Act.powerMod = 100;
302 }
303 }
304 if (flag2)
305 {
306 w.c_ammo--;
307 if (w.ammoData != null)
308 {
309 w.ammoData.Num = w.c_ammo;
310 }
311 if (w.c_ammo <= 0)
312 {
313 w.c_ammo = 0;
314 w.ammoData = null;
315 }
317 }
318 }
319 Act.TC = _tc;
321 {
323 if (feint > 0 && 10f + 4f * Mathf.Sqrt(feint) > (float)EClass.rnd(100))
324 {
325 Act.TC.Chara.AddCondition<ConSupress>(100 + 5 * (int)Mathf.Sqrt(feint));
326 }
327 }
328 if (splash > 0)
329 {
330 Act.TP.ForeachNeighbor(delegate(Point p)
331 {
332 if (p.Equals(Act.TP) || p.Equals(Act.CC.pos))
333 {
334 return;
335 }
336 if (!p.IsBlocked)
337 {
338 p.PlayEffect("smoke_shockwave");
339 p.Copy().Animate(AnimeID.QuakeMini, animeBlock: true);
340 }
341 foreach (Card item4 in p.ListCards())
342 {
343 if (item4.trait.CanBeAttacked || (item4.isChara && item4.Chara.IsHostile(Act.CC)))
344 {
345 int rawDamage = AttackProcess.Current.GetRawDamage(0.1f + 0.05f * Mathf.Sqrt(splash), crit: false, maxRoll: false);
346 rawDamage = item4.ApplyProtection(rawDamage);
347 item4.DamageHP(rawDamage, 0, 100, AttackSource.Shockwave, Act.CC);
348 }
349 }
350 });
351 }
352 }
353 void AttackWithFlurry(Card _tc, Point _tp, float mtp, bool subAttack)
354 {
355 int num6 = 1;
356 if (flurry > 0)
357 {
358 for (int l = 0; l < 10 && flurry > EClass.rnd(25 + (int)Mathf.Pow(5f, l + 2)); l++)
359 {
360 num6++;
361 }
362 }
363 for (int m = 0; m < num6; m++)
364 {
366 {
367 break;
368 }
369 if (!_tc.IsAliveInCurrentZone)
370 {
371 break;
372 }
373 if (m > 0)
374 {
375 Act.CC.Say("attack_flurry");
376 }
377 Attack(_tc, _tp, mtp, subAttack);
378 }
379 }
380 int GetWeaponEnc(int ele, bool addSelfEnc)
381 {
382 return (addSelfEnc ? Act.CC.Evalue(ele) : 0) + ((w != null) ? w.Evalue(ele) : 0) + (Act.CC.IsPCFactionOrMinion ? EClass.pc.faction.charaElements.Value(ele) : 0);
383 }
384 }
385 }
386}
AnimeID
Definition: AnimeID.cs:2
AttackSource
Definition: AttackSource.cs:2
Definition: ACT.cs:6
static Act Create(int id)
Definition: ACT.cs:36
override bool ResetAxis
Definition: ActMelee.cs:18
bool Attack(float dmgMulti=1f, bool maxRoll=false)
Definition: ActMelee.cs:92
override CursorInfo GetCursorIcon(Card c)
Definition: ActMelee.cs:49
bool HideHint(Card c)
Definition: ActMelee.cs:22
override bool CanPerform()
Definition: ActMelee.cs:63
override bool Perform()
Definition: ActMelee.cs:87
override string GetTextSmall(Card c)
Definition: ActMelee.cs:40
override bool CanPressRepeat
Definition: ActMelee.cs:20
override string GetHintText(string str="")
Definition: ActMelee.cs:35
override int PerformDistance
Definition: ActMelee.cs:7
override bool ShowMouseHint(Card c)
Definition: ActMelee.cs:58
static bool TryReload(Thing weapon, Thing ammo=null)
Definition: ActRanged.cs:342
Definition: ACT.cs:62
virtual bool Perform()
Definition: ACT.cs:264
static Card TC
Definition: ACT.cs:79
static Point TP
Definition: ACT.cs:81
static Chara CC
Definition: ACT.cs:77
void Prepare(Chara _CC, Thing _weapon, Card _TC=null, Point _TP=null, int _attackIndex=0, bool _isThrow=false)
bool Perform(int count, bool hasHit, float dmgMulti=1f, bool maxRoll=false, bool subAttack=false)
static AttackProcess Current
Definition: AttackProcess.cs:8
int GetRawDamage(float dmgMulti, bool crit, bool maxRoll)
int elementId
Definition: BodySlot.cs:6
Thing thing
Definition: BodySlot.cs:8
void PlayAnime(AnimeID id, bool force)
virtual void NextFrame()
Definition: Card.cs:11
bool IsPCFactionOrMinion
Definition: Card.cs:2132
virtual Chara Chara
Definition: Card.cs:1946
ElementContainerCard elements
Definition: Card.cs:37
int c_ammo
Definition: Card.cs:1385
void DamageHP(int dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:3735
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
Point pos
Definition: Card.cs:55
virtual int ApplyProtection(int dmg, int mod=100)
Definition: Card.cs:3710
Trait trait
Definition: Card.cs:49
int encLV
Definition: Card.cs:310
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2003
virtual bool isChara
Definition: Card.cs:1959
int Evalue(int ele)
Definition: Card.cs:2431
int Dist(Card c)
Definition: Card.cs:6777
void ModExp(string alias, int a)
Definition: Card.cs:2508
CardRenderer renderer
Definition: Card.cs:57
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
CellEffect effect
Definition: Cell.cs:94
int GetMeleeDistance()
Definition: CharaBody.cs:414
List< BodySlot > slots
Definition: CharaBody.cs:8
Definition: Chara.cs:10
override bool IsAliveInCurrentZone
Definition: Chara.cs:546
CharaBody body
Definition: Chara.cs:91
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8415
Faction faction
Definition: Chara.cs:412
override bool IsPC
Definition: Chara.cs:597
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1059
bool HasCondition(string alias)
Definition: Chara.cs:8568
bool CanSee(Card c)
Definition: Chara.cs:1027
bool CanInteractTo(Card c)
Definition: Chara.cs:2225
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:5707
bool isBlind
Definition: Chara.cs:125
void RequestProtection(Chara attacker, Action< Chara > action)
Definition: Chara.cs:7623
bool IsHostile()
Definition: Chara.cs:5884
override void LookAt(Card c)
Definition: Chara.cs:3219
new GameConfig game
Definition: CoreConfig.cs:596
CoreConfig config
Definition: Core.cs:70
static CursorInfo IconMelee
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Core core
Definition: EClass.cs:6
static void Wait(float a, Card c)
Definition: EClass.cs:89
static Map _map
Definition: EClass.cs:18
static Chara pc
Definition: EClass.cs:14
Definition: EInput.cs:8
static void Consume(int _skipFrame)
Definition: EInput.cs:656
int Value(int ele)
int GetSpellExp(Chara c, Element e, int costMod=100)
Element GetElement(string alias)
int id
Definition: ELEMENT.cs:240
Act act
Definition: ELEMENT.cs:384
ElementContainerFaction charaElements
Definition: FACTION.cs:144
static void SetDirty(Thing t)
List< Point > ListPointsInLine(Point center, Point to, int radius)
Definition: Map.cs:2304
Definition: Point.cs:9
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1015
Point Copy()
Definition: Point.cs:467
void ForeachNeighbor(Action< Point > action, bool diagonal=true)
Definition: Point.cs:1361
bool IsBlocked
Definition: Point.cs:339
bool Equals(int _x, int _z)
Definition: Point.cs:924
Effect PlayEffect(string id)
Definition: Point.cs:1212
Cell cell
Definition: Point.cs:51
void Animate(AnimeID id, bool animeBlock=false)
Definition: Point.cs:1266
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
bool IsMeleeWithAmmo
Definition: Thing.cs:20
virtual bool CanBeAttacked
Definition: Trait.cs:159
Card owner
Definition: Trait.cs:26