Elin Decompiled Documentation EA 23.219 Nightly Patch 2
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 virtual bool AllowCounter => true;
7
8 public virtual bool AllowParry => true;
9
10 public virtual bool ShouldRollMax => false;
11
12 public virtual float BaseDmgMTP => 1f;
13
14 public virtual bool UseWeaponDist => true;
15
16 public override int PerformDistance
17 {
18 get
19 {
20 if (Act.CC != null)
21 {
22 return Act.CC.body.GetMeleeDistance();
23 }
24 return 1;
25 }
26 }
27
28 public override bool ResetAxis => true;
29
30 public override bool CanPressRepeat => true;
31
32 public bool HideHint(Card c)
33 {
34 if (!EClass.pc.isBlind && c != null)
35 {
36 if (c.isChara)
37 {
38 return !EClass.pc.CanSee(c);
39 }
40 return false;
41 }
42 return true;
43 }
44
45 public override string GetHintText(string str = "")
46 {
47 return "";
48 }
49
50 public override string GetTextSmall(Card c)
51 {
52 if (!HideHint(c))
53 {
54 return base.GetTextSmall(c);
55 }
56 return null;
57 }
58
59 public override CursorInfo GetCursorIcon(Card c)
60 {
61 if (!HideHint(c))
62 {
64 }
65 return null;
66 }
67
68 public override bool ShowMouseHint(Card c)
69 {
70 return !HideHint(c);
71 }
72
73 public override bool CanPerform()
74 {
75 if (Act.TC == null || !Act.TC.IsAliveInCurrentZone)
76 {
77 return false;
78 }
80 {
81 return false;
82 }
83 if (PerformDistance == 1)
84 {
86 {
87 return false;
88 }
89 }
90 else if (!Act.CC.CanSeeLos(Act.TC))
91 {
92 return false;
93 }
94 return base.CanPerform();
95 }
96
97 public override bool Perform()
98 {
99 Act.CurrentAct = this;
100 bool result = Attack();
101 Act.CurrentAct = null;
102 return result;
103 }
104
105 public bool Attack(float dmgMulti = 1f)
106 {
107 Act.CC.combatCount = 10;
108 Act.CC.LookAt(Act.TC);
110 if (Act.CC.HasCondition<ConFear>())
111 {
112 Act.CC.Say("fear", Act.CC, Act.TC);
113 if (Act.CC.IsPC)
114 {
115 EInput.Consume(consumeAxis: true);
116 }
117 return true;
118 }
120 bool intercepted = (Act.TC?.Chara?.RequestProtection(Act.CC, delegate(Chara c)
121 {
122 Act.TC = c;
123 })).GetValueOrDefault();
124 Act.TP.Set(Act.TC.pos);
125 CellEffect effect = Act.TP.cell.effect;
126 if (effect != null && effect.id == 6 && EClass.rnd(2) == 0)
127 {
128 Act.CC.PlaySound("miss");
129 Act.CC.Say("abMistOfDarkness_miss", Act.CC);
130 return true;
131 }
132 bool hasHit = false;
133 bool hasMissed = false;
134 bool usedWeapon = false;
135 bool usedTalisman = false;
136 bool maxRoll = ShouldRollMax;
137 int count = 0;
138 int dist = Act.CC.Dist(Act.TC);
139 Point orgPos = Act.TC.pos.Copy();
140 Chara cC = Act.CC;
141 Card orgTC = Act.TC;
143 bool parried = false;
144 foreach (BodySlot slot in Act.CC.body.slots)
145 {
146 _Attack(slot);
147 if (parried)
148 {
149 break;
150 }
151 }
152 if (!usedWeapon)
153 {
154 _Attack(null);
155 }
157 {
158 EClass.Wait(0.25f, Act.CC);
159 }
160 if (EClass.rnd(2) == 0)
161 {
162 Act.CC.RemoveCondition<ConInvisibility>();
163 }
164 if (orgTC.isChara && orgTC.ExistsOnMap && orgTC != cC && !orgTC.IsRestrainedResident && !orgTC.IsDisabled && ACT.Melee.CanPerform(orgTC.Chara, cC) && (!orgTC.IsPCFactionOrMinion || !EClass._zone.isPeace))
165 {
166 if (parried)
167 {
168 new ActMeleeParry().Perform(orgTC.Chara, cC);
169 }
170 else if (AllowCounter && hasMissed && !cC.HasElement(439) && orgTC.HasElement(380))
171 {
172 orgTC.Say((orgTC.isChara && orgTC.Chara.IsHostile()) ? "counter_enemy" : "counter");
173 new ActMeleeCounter().Perform(orgTC.Chara, cC);
174 }
175 }
176 Act.TC = orgTC;
177 Act.CC = cC;
178 if (!hasHit)
179 {
180 Act.CC.PlaySound("miss");
181 }
182 return true;
183 void _Attack(BodySlot slot)
184 {
185 Act.TC = orgTC;
186 Act.TP = orgPos;
187 Thing w;
188 int splash;
189 int chaser;
190 int flurry;
191 int frustration;
192 int feint;
193 int knockback;
194 int mod_talisman;
195 if (Act.TC != null && Act.TC.IsAliveInCurrentZone)
196 {
197 w = null;
198 if (slot != null)
199 {
200 if (slot.thing == null || slot.elementId != 35 || slot.thing.source.offense.Length < 2)
201 {
202 return;
203 }
204 w = slot.thing;
205 }
206 int num = 1 + Mathf.Max(Act.CC.Evalue(666), (w != null) ? w.Evalue(666) : 0);
207 if (!UseWeaponDist || dist <= 1 || dist <= num || intercepted)
208 {
209 int num2 = GetWeaponEnc(606, addSelfEnc: false);
210 int scatter = GetWeaponEnc(607, addSelfEnc: false);
211 splash = GetWeaponEnc(608, addSelfEnc: true);
212 chaser = GetWeaponEnc(620, addSelfEnc: true);
213 flurry = GetWeaponEnc(621, addSelfEnc: true);
214 frustration = GetWeaponEnc(624, addSelfEnc: true);
215 int num3 = GetWeaponEnc(622, addSelfEnc: true);
216 feint = GetWeaponEnc(623, addSelfEnc: true);
217 knockback = Act.CC.Evalue(603);
218 mod_talisman = GetWeaponEnc(609, addSelfEnc: true);
219 List<Point> list2 = EClass._map.ListPointsInLine(Act.CC.pos, Act.TC.pos, num2 / 10 + ((num2 % 10 > EClass.rnd(10)) ? 1 : 0) + 1);
220 if (w != null)
221 {
222 if (safety)
223 {
224 if (!w.HasElement(486))
225 {
226 return;
227 }
228 num2 = (scatter = (splash = (num3 = 0)));
229 }
230 usedWeapon = true;
231 if (w.IsMeleeWithAmmo && Act.CC.IsPC && w.c_ammo <= 0 && !Act.CC.HasCondition<ConReload>())
232 {
234 }
235 }
236 AttackWithFlurry(Act.TC, Act.TP, 1f, subAttack: false);
237 if (!parried)
238 {
239 if (num2 > 0)
240 {
241 foreach (Point item in list2)
242 {
243 if (!item.Equals(orgPos))
244 {
245 Chara firstChara = item.FirstChara;
246 if (firstChara != null && firstChara.IsHostile(Act.CC))
247 {
248 AttackWithFlurry(firstChara, item, 1f, subAttack: false);
249 }
250 }
251 }
252 }
253 else if (scatter > 0)
254 {
255 Act.TP.ForeachNeighbor(delegate(Point p)
256 {
257 if (!p.Equals(orgPos))
258 {
259 Chara firstChara2 = p.FirstChara;
260 if (firstChara2 != null && firstChara2.IsHostile(Act.CC))
261 {
262 AttackWithFlurry(firstChara2, p, Mathf.Min(0.5f + 0.05f * Mathf.Sqrt(scatter), 1f + 0.01f * Mathf.Sqrt(scatter)), subAttack: true);
263 }
264 }
265 });
266 }
267 else if (num3 > 0)
268 {
269 List<Point> list = new List<Point>();
270 Act.TP.ForeachNeighbor(delegate(Point p)
271 {
272 if (!p.Equals(Act.TP))
273 {
274 list.Add(p.Copy());
275 }
276 });
277 list.Shuffle();
278 int num4 = 0;
279 for (int i = 0; i < 9 && num3 > EClass.rnd(10 + (int)Mathf.Pow(3f, i + 2)); i++)
280 {
281 num4++;
282 }
283 foreach (Point item2 in list)
284 {
285 foreach (Card item3 in item2.ListCards().Copy())
286 {
287 if (num4 <= 0 || !Act.CC.IsAliveInCurrentZone)
288 {
289 break;
290 }
291 if (item3.trait.CanBeAttacked || (item3.isChara && item3.Chara.IsHostile(Act.CC)))
292 {
293 AttackWithFlurry(item3, item2, 1f, subAttack: true);
294 if (parried)
295 {
296 break;
297 }
298 num4--;
299 }
300 }
301 }
302 }
303 }
304 count++;
305 }
306 }
307 void Attack(Card _tc, Point _tp, float mtp, bool subAttack)
308 {
309 Act.TC = _tc;
310 Act.TP = _tp;
313 {
314 int num5 = Act.TC.Evalue(437);
315 if (num5 > 0 && !Act.CC.HasElement(439))
316 {
317 int num6 = EClass.curve(5 + num5 / 3, 10, 3, 70);
318 int ele2 = 123;
319 int num7 = Act.TC.Evalue(ele2);
320 if (Act.TC.isChara)
321 {
322 foreach (BodySlot slot2 in Act.TC.Chara.body.slots)
323 {
324 if (slot2.thing != null && slot2.thing.HasElement(437) && Act.TC.Evalue(slot2.thing.category.skill) > num7)
325 {
326 ele2 = slot2.thing.category.skill;
327 num7 = Act.TC.Evalue(ele2);
328 }
329 }
330 }
331 num6 = num6 * 100 / (int)Mathf.Clamp((float)AttackProcess.Current.weaponSkill.Value / (float)num7 * 100f, 50f, 150f);
332 if (EClass.rnd(100) < num6)
333 {
334 Act.TC.Say((Act.TC.isChara && Act.TC.Chara.IsHostile()) ? "parry_enemy" : "parry");
335 Act.TC.PlaySound("parry");
336 Act.TC.ModExp(ele2, 20);
337 parried = true;
338 return;
339 }
340 }
341 }
342 int num8 = 1;
343 if (chaser > 0)
344 {
345 for (int j = 0; j < 10; j++)
346 {
347 if (chaser > EClass.rnd(4 + (int)Mathf.Pow(4f, j + 2)))
348 {
349 num8++;
350 }
351 }
352 }
353 bool flag = false;
354 for (int k = 0; k < num8; k++)
355 {
357 {
358 break;
359 }
361 {
362 break;
363 }
364 if (k > 0)
365 {
366 Act.CC.Say(Act.CC.IsHostile() ? "attack_chaser_enemy" : "attack_chaser");
367 }
368 flag = AttackProcess.Current.Perform(count, hasHit, dmgMulti * mtp * BaseDmgMTP, maxRoll, subAttack);
369 if (!flag && frustration > 0 && !Act.TC.HasElement(439) && 10f + 2f * Mathf.Sqrt(frustration) > (float)EClass.rnd(100))
370 {
371 AttackProcess.Current.critFury = true;
372 flag = AttackProcess.Current.Perform(count, hasHit, dmgMulti * mtp, maxRoll, subAttack);
373 AttackProcess.Current.critFury = false;
374 }
376 {
377 break;
378 }
379 }
380 if (flag)
381 {
382 hasHit = true;
383 }
384 else
385 {
386 hasMissed = true;
387 }
388 Act.TC = _tc;
389 Act.TP = _tp;
390 if (w != null && w.c_ammo > 0 && !Act.CC.HasCondition<ConReload>() && !safety)
391 {
392 bool flag2 = true;
393 TraitAmmo traitAmmo = ((w.ammoData == null) ? null : (w.ammoData.trait as TraitAmmo));
394 if (traitAmmo != null && traitAmmo is TraitAmmoTalisman traitAmmoTalisman)
395 {
396 flag2 = false;
397 if (flag && !usedTalisman && Act.TC != null && Act.TC.IsAliveInCurrentZone)
398 {
399 Act act = Act.CC.elements.GetElement(traitAmmoTalisman.owner.refVal)?.act ?? ACT.Create(traitAmmoTalisman.owner.refVal);
400 Act.powerMod = traitAmmo.owner.encLV;
401 if (act.Perform(Act.CC, Act.TC, Act.TP))
402 {
403 usedTalisman = true;
404 flag2 = true;
405 if (mod_talisman > 0 && Mathf.Min(10f + Mathf.Sqrt(mod_talisman) * 5f, 90f) > (float)EClass.rnd(100))
406 {
407 flag2 = false;
408 }
409 int spellExp = Act.CC.elements.GetSpellExp(Act.CC, act, 200);
410 Act.CC.ModExp(act.id, spellExp);
411 }
412 Act.powerMod = 100;
413 }
414 }
415 if (flag2)
416 {
417 w.c_ammo--;
418 if (w.ammoData != null)
419 {
420 w.ammoData.Num = w.c_ammo;
421 }
422 if (w.c_ammo <= 0)
423 {
424 w.c_ammo = 0;
425 w.ammoData = null;
426 }
428 }
429 }
430 Act.TC = _tc;
432 {
434 if (feint > 0 && 10f + 4f * Mathf.Sqrt(feint) > (float)EClass.rnd(100))
435 {
436 Act.TC.Chara.AddCondition<ConSupress>(100 + 5 * (int)Mathf.Sqrt(feint));
437 }
438 }
439 if (splash > 0)
440 {
441 Act.TP.ForeachNeighbor(delegate(Point p)
442 {
443 if (p.Equals(Act.TP) || p.Equals(Act.CC.pos))
444 {
445 return;
446 }
447 if (!p.IsBlocked)
448 {
449 p.PlayEffect("smoke_shockwave");
450 p.Copy().Animate(AnimeID.QuakeMini, animeBlock: true);
451 }
452 foreach (Card item4 in p.ListCards().Copy())
453 {
454 if ((item4.trait.CanBeAttacked || (item4.isChara && item4.Chara.IsHostile(Act.CC))) && !item4.HasElement(430))
455 {
456 long rawDamage2 = AttackProcess.Current.GetRawDamage(0.1f + 0.05f * Mathf.Sqrt(splash), crit: false, maxRoll: false);
457 rawDamage2 = item4.ApplyProtection(rawDamage2);
458 item4.DamageHP(rawDamage2, 0, 100, AttackSource.Shockwave, Act.CC);
459 }
460 }
461 });
462 }
463 if (Act.TC.isChara && !Act.TC.HasCondition<ConGravity>() && Act.TC.ExistsOnMap && knockback > 0 && knockback * 2 + 15 > EClass.rnd(100) && !Act.TC.isRestrained)
464 {
466 bool flag3 = Act.CC.id == "tsunami";
467 if (num9 == Card.MoveResult.Success)
468 {
469 Act.TC.renderer.SetFirst(first: true);
470 Act.TC.PlaySound("wave_hit_small");
471 if (flag3)
472 {
473 Act.TC.Chara.AddCondition<ConParalyze>(20, force: true);
474 Act.TC.Chara.AddCondition<ConSuffocation>(100, force: true);
475 }
476 }
477 else if (flag3)
478 {
479 Act.TC.PlaySound("wave_hit");
480 Act.TC.pos.PlayEffect("wave_hit");
481 Act.TC.Chara.AddCondition<ConSuffocation>(200, force: true);
482 if (!Act.TC.HasElement(430))
483 {
484 long rawDamage = AttackProcess.Current.GetRawDamage(1f, crit: false, maxRoll: false);
485 rawDamage = Act.TC.ApplyProtection(rawDamage);
486 Act.TC.DamageHP(rawDamage, 0, 100, AttackSource.Shockwave, Act.CC);
487 }
488 Act.CC.Die();
489 }
490 }
491 }
492 void AttackWithFlurry(Card _tc, Point _tp, float mtp, bool subAttack)
493 {
494 int num10 = 1;
495 if (flurry > 0)
496 {
497 for (int l = 0; l < 10 && flurry > EClass.rnd(25 + (int)Mathf.Pow(5f, l + 2)); l++)
498 {
499 num10++;
500 }
501 }
502 for (int m = 0; m < num10; m++)
503 {
505 {
506 break;
507 }
508 if (!_tc.IsAliveInCurrentZone)
509 {
510 break;
511 }
512 if (m > 0)
513 {
514 Act.CC.Say(Act.CC.IsHostile() ? "attack_flurry_enemy" : "attack_flurry");
515 }
516 Attack(_tc, _tp, mtp, subAttack);
517 if (parried)
518 {
519 break;
520 }
521 }
522 }
523 int GetWeaponEnc(int ele, bool addSelfEnc)
524 {
525 return AttackProcess.GetWeaponEnc(Act.CC, w, ele, addSelfEnc);
526 }
527 }
528 }
529}
AnimeID
Definition: AnimeID.cs:2
AttackSource
Definition: AttackSource.cs:2
Definition: ACT.cs:6
static Act Create(int id)
Definition: ACT.cs:36
static ActMelee Melee
Definition: ACT.cs:15
override bool ResetAxis
Definition: ActMelee.cs:28
virtual bool ShouldRollMax
Definition: ActMelee.cs:10
override CursorInfo GetCursorIcon(Card c)
Definition: ActMelee.cs:59
bool HideHint(Card c)
Definition: ActMelee.cs:32
override bool CanPerform()
Definition: ActMelee.cs:73
virtual bool AllowCounter
Definition: ActMelee.cs:6
override bool Perform()
Definition: ActMelee.cs:97
override string GetTextSmall(Card c)
Definition: ActMelee.cs:50
override bool CanPressRepeat
Definition: ActMelee.cs:30
override string GetHintText(string str="")
Definition: ActMelee.cs:45
bool Attack(float dmgMulti=1f)
Definition: ActMelee.cs:105
virtual float BaseDmgMTP
Definition: ActMelee.cs:12
virtual bool AllowParry
Definition: ActMelee.cs:8
override int PerformDistance
Definition: ActMelee.cs:17
virtual bool UseWeaponDist
Definition: ActMelee.cs:14
override bool ShowMouseHint(Card c)
Definition: ActMelee.cs:68
static bool TryReload(Thing weapon, Thing ammo=null)
Definition: ActRanged.cs:400
Definition: ACT.cs:62
virtual bool Perform()
Definition: ACT.cs:266
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
long GetRawDamage(float dmgMulti, bool crit, bool maxRoll)
static int GetWeaponEnc(Chara CC, Thing w, int ele, bool addSelfEnc=false)
int elementId
Definition: BodySlot.cs:6
Thing thing
Definition: BodySlot.cs:8
void PlayAnime(AnimeID id, bool force)
virtual void NextFrame()
virtual void SetFirst(bool first, Vector3 pos)
Definition: Card.cs:11
bool IsPCFactionOrMinion
Definition: Card.cs:2260
virtual Chara Chara
Definition: Card.cs:2058
ElementContainerCard elements
Definition: Card.cs:41
int c_ammo
Definition: Card.cs:1461
bool IsRestrainedResident
Definition: Card.cs:2246
bool HasElement(int ele, int req=1)
Definition: Card.cs:5787
bool isRestrained
Definition: Card.cs:566
virtual bool IsDisabled
Definition: Card.cs:2099
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6001
Point pos
Definition: Card.cs:59
virtual long ApplyProtection(long dmg, int mod=100)
Definition: Card.cs:3968
Trait trait
Definition: Card.cs:53
int encLV
Definition: Card.cs:326
virtual bool IsAliveInCurrentZone
Definition: Card.cs:2115
void DamageHP(long dmg, AttackSource attackSource=AttackSource.None, Card origin=null)
Definition: Card.cs:3993
MoveResult
Definition: Card.cs:13
virtual bool isChara
Definition: Card.cs:2071
int Evalue(int ele)
Definition: Card.cs:2559
int Dist(Card c)
Definition: Card.cs:7492
void ModExp(string alias, int a)
Definition: Card.cs:2636
SourceCategory.Row category
Definition: Card.cs:2037
CardRenderer renderer
Definition: Card.cs:61
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6653
CellEffect effect
Definition: Cell.cs:94
int GetMeleeDistance()
Definition: CharaBody.cs:420
List< BodySlot > slots
Definition: CharaBody.cs:8
Definition: Chara.cs:10
override bool IsAliveInCurrentZone
Definition: Chara.cs:559
CharaBody body
Definition: Chara.cs:94
MoveResult TryMoveFrom(Point p)
Definition: Chara.cs:2652
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8988
override bool IsPC
Definition: Chara.cs:610
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1244
bool RequestProtection(Chara attacker, Action< Chara > action)
Definition: Chara.cs:8168
bool HasCondition(string alias)
Definition: Chara.cs:9145
bool CanSee(Card c)
Definition: Chara.cs:1212
override void Die(Element e=null, Card origin=null, AttackSource attackSource=AttackSource.None, Chara originalTarget=null)
Definition: Chara.cs:5187
bool CanInteractTo(Card c)
Definition: Chara.cs:2491
void DoHostileAction(Card _tg, bool immediate=false)
Definition: Chara.cs:6212
bool isBlind
Definition: Chara.cs:130
bool IsHostile()
Definition: Chara.cs:6389
override void LookAt(Card c)
Definition: Chara.cs:3501
new GameConfig game
Definition: CoreConfig.cs:605
CoreConfig config
Definition: Core.cs:70
static CursorInfo IconMelee
Definition: EClass.cs:5
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:68
static Core core
Definition: EClass.cs:6
static void Wait(float a, Card c)
Definition: EClass.cs:102
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
static int rnd(long a)
Definition: EClass.cs:58
static Chara pc
Definition: EClass.cs:14
Definition: EInput.cs:8
static void Consume(int _skipFrame)
Definition: EInput.cs:656
int GetSpellExp(Chara c, Element e, int costMod=100)
Element GetElement(string alias)
int id
Definition: ELEMENT.cs:250
Act act
Definition: ELEMENT.cs:394
static void SetDirty(Thing t)
List< Point > ListPointsInLine(Point center, Point to, int radius)
Definition: Map.cs:2326
Definition: Point.cs:9
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1035
Point Copy()
Definition: Point.cs:479
Point Set(int _x, int _z)
Definition: Point.cs:491
void ForeachNeighbor(Action< Point > action, bool diagonal=true)
Definition: Point.cs:1381
bool IsBlocked
Definition: Point.cs:351
bool Equals(int _x, int _z)
Definition: Point.cs:944
Effect PlayEffect(string id)
Definition: Point.cs:1232
Cell cell
Definition: Point.cs:51
void Animate(AnimeID id, bool animeBlock=false)
Definition: Point.cs:1286
bool isPeace
Definition: Spatial.cs:406
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
bool IsMeleeWithAmmo
Definition: Thing.cs:20
virtual bool CanBeAttacked
Definition: Trait.cs:164
Card owner
Definition: Trait.cs:27