Elin Decompiled Documentation EA 23.199 Nightly
Loading...
Searching...
No Matches
AttackProcess.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
5
6public class AttackProcess : EClass
7{
8 public static AttackProcess Current = new AttackProcess();
9
10 public int dNum;
11
12 public int dDim;
13
14 public int dBonus;
15
16 public int toHit;
17
18 public int toHitBase;
19
20 public int toHitFix;
21
22 public int evasion;
23
24 public int penetration;
25
26 public int distMod;
27
28 public int attackIndex;
29
30 public int dNumAmmo;
31
32 public int dDimAmmo;
33
34 public int dBonusAmmo;
35
36 public int numFire;
37
39
40 public float dMulti;
41
42 public bool crit;
43
44 public bool critFury;
45
46 public bool hit;
47
48 public bool evadePlus;
49
50 public bool isThrow;
51
52 public bool ignoreAnime;
53
54 public bool ignoreAttackSound;
55
56 public Chara CC;
57
58 public Card TC;
59
60 public Point TP;
61
63
65
66 public Thing weapon;
67
68 public Thing ammo;
69
71
73
75
76 public bool IsMartial => weapon == null;
77
78 public bool IsMartialWeapon
79 {
80 get
81 {
82 if (weapon != null)
83 {
84 return weapon.category.skill == 100;
85 }
86 return false;
87 }
88 }
89
90 public bool IsRanged
91 {
92 get
93 {
94 if (toolRange != null && !isThrow)
95 {
97 }
98 return false;
99 }
100 }
101
102 public bool IsCane
103 {
104 get
105 {
106 if (IsRanged)
107 {
109 }
110 return false;
111 }
112 }
113
114 public static int GetWeaponEnc(Chara CC, Thing w, int ele, bool addSelfEnc = false)
115 {
116 int num = w?.Evalue(ele) ?? 0;
118 {
119 num += EClass.pc.faction.charaElements.Value(ele);
120 }
121 num = num * (100 + GetTwoHandEncBonus(CC)) / 100;
122 if (addSelfEnc)
123 {
124 num += CC.Evalue(ele);
125 }
126 return num;
127 }
128
129 public static int GetTwoHandEncBonus(Chara CC)
130 {
131 if (CC == null || CC.body.GetAttackStyle() != AttackStyle.TwoHand)
132 {
133 return 0;
134 }
135 return Mathf.Clamp(CC.Evalue(130) / 15, 0, 2) * 25;
136 }
137
138 public string GetText()
139 {
140 string text = dNum + "d" + dDim;
141 text = text + ((dBonus >= 0) ? "+" : "") + dBonus;
142 string @ref = (IsMartial ? "evalHand".lang() : "evalWeapon".lang((attackIndex + 1).ToString() ?? ""));
143 return "attackEval".lang(@ref, text, dMulti.ToString("F2") ?? "", toHit.ToString() ?? "", penetration.ToString() ?? "");
144 }
145
146 public void Prepare(Chara _CC, Thing _weapon, Card _TC = null, Point _TP = null, int _attackIndex = 0, bool _isThrow = false)
147 {
148 CC = _CC;
149 TC = _TC;
150 TP = _TP;
151 isThrow = _isThrow;
152 weapon = _weapon;
153 ammo = _weapon?.ammoData;
154 hit = (crit = (critFury = (evadePlus = false)));
156 attackType = AttackType.Slash;
157 attackStyle = AttackStyle.Default;
158 evasion = 0;
159 penetration = 0;
160 distMod = 100;
161 attackIndex = _attackIndex;
163 ignoreAnime = (ignoreAttackSound = false);
164 if (!isThrow)
165 {
166 if (!IsRanged)
167 {
169 }
170 else if (TP != null)
171 {
172 int num = CC.pos.Distance(TP);
173 distMod = Mathf.Max(115 - 10 * Mathf.Abs(num - toolRange.BestDist) * 100 / (100 + weapon.Evalue(605) * 10), 80);
174 }
175 }
176 if (isThrow)
177 {
178 bool flag = weapon.HasTag(CTAG.throwWeapon) || weapon.HasTag(CTAG.throwWeaponEnemy);
179 int num2 = (int)Mathf.Clamp(Mathf.Sqrt(weapon.SelfWeight + weapon.ChildrenWeight) * 3f + 25f + (float)(flag ? 75 : 0), 10f, 400f + Mathf.Sqrt(CC.STR) * 50f);
180 int num3 = Mathf.Clamp(weapon.material.hardness, flag ? 40 : 20, 200);
182 attackType = AttackType.Blunt;
183 dBonus = CC.DMG + (CC.IsPCParty ? 3 : 7) + Math.Min(weapon.encLV, 99);
184 dNum = 2;
185 dDim = (((!CC.IsPCParty) ? CC.LV : 0) + CC.STR + CC.Evalue(108)) * num2 / 100 * num3 / 100 / 2;
186 dMulti = 1f;
187 toHitBase = EClass.curve(CC.DEX / 4 + CC.STR / 2 + weaponSkill.Value, 50, 25) + (CC.IsPCFaction ? 75 : 250);
188 toHitFix = CC.HIT + weapon.HIT;
189 penetration = 25;
190 }
191 else if (IsMartial || IsMartialWeapon)
192 {
194 bool flag2 = weapon != null && weapon.Evalue(482) > 0;
195 if (flag2)
196 {
198 }
199 attackType = ((!CC.race.meleeStyle.IsEmpty()) ? CC.race.meleeStyle.ToEnum<AttackType>() : ((EClass.rnd(2) == 0) ? AttackType.Kick : AttackType.Punch));
200 dBonus = CC.DMG + CC.encLV + (int)Mathf.Sqrt(Mathf.Max(0, weaponSkill.GetParent(CC).Value / 5 + weaponSkill.Value / 4));
201 dNum = 2 + Mathf.Min(weaponSkill.Value / 10, 4);
202 dDim = 5 + (int)Mathf.Sqrt(Mathf.Max(0, weaponSkill.Value / 3));
203 dMulti = 0.6f + (float)(weaponSkill.GetParent(CC).Value / 2 + weaponSkill.Value / 2 + CC.Evalue(flag2 ? 304 : 132) / 2) / 50f;
204 dMulti += 0.05f * (float)CC.Evalue(1400);
206 toHitFix = CC.HIT;
207 if (attackStyle == AttackStyle.Shield)
208 {
209 toHitBase = toHitBase * 75 / 100;
210 }
211 penetration = Mathf.Clamp(weaponSkill.Value / 10 + 5, 5, 20) + CC.Evalue(92);
212 if (CC.HasElement(1246))
213 {
214 penetration += 25;
215 }
216 if (IsMartialWeapon)
217 {
218 dBonus += weapon.DMG;
219 dNum += weapon.source.offense[0];
220 dDim = Mathf.Max(dDim / 2 + weapon.c_diceDim, 1);
223 if (!weapon.source.attackType.IsEmpty())
224 {
225 attackType = weapon.source.attackType.ToEnum<AttackType>();
226 }
227 }
228 }
229 else
230 {
231 if (IsRanged)
232 {
234 }
235 else
236 {
238 }
239 if (!weapon.source.attackType.IsEmpty())
240 {
241 attackType = weapon.source.attackType.ToEnum<AttackType>();
242 }
243 bool flag3 = IsCane || weapon.Evalue(482) > 0;
244 if (flag3)
245 {
247 }
248 dBonus = CC.DMG + CC.encLV + weapon.DMG;
249 dNum = weapon.source.offense[0];
251 dMulti = 0.6f + (float)(weaponSkill.GetParent(CC).Value + weaponSkill.Value / 2 + CC.Evalue(flag3 ? 304 : (IsRanged ? 133 : 132))) / 50f;
252 dMulti += 0.05f * (float)CC.Evalue(IsRanged ? 1404 : 1400);
253 toHitBase = EClass.curve((IsCane ? CC.WIL : CC.DEX) / 4 + weaponSkill.GetParent(CC).Value / 3 + weaponSkill.Value, 50, 25) + 50;
254 toHitFix = CC.HIT + weapon.HIT;
255 penetration = weapon.Penetration + CC.Evalue(92);
256 if (IsRanged)
257 {
258 if (CC.HasElement(1244))
259 {
260 penetration += 25;
261 }
262 }
263 else if (CC.HasElement(1247))
264 {
265 penetration += 25;
266 }
267 if (IsCane)
268 {
269 toHitBase += 50;
270 }
271 }
272 if (ammo != null && !(ammo.trait is TraitAmmoTalisman))
273 {
274 dNumAmmo = ((ammo.source.offense.Length != 0) ? ammo.source.offense[0] : 0);
276 dBonusAmmo = ammo.DMG + ammo.encLV;
277 if (dNumAmmo < 1)
278 {
279 dNumAmmo = 1;
280 }
281 if (dDimAmmo < 1)
282 {
283 dDimAmmo = 1;
284 }
285 toHitFix += ammo.HIT;
286 }
287 else
288 {
289 dNumAmmo = 0;
290 dDimAmmo = 0;
291 }
292 if (dNum < 1)
293 {
294 dNum = 1;
295 }
296 if (dDim < 1)
297 {
298 dDim = 1;
299 }
300 if (penetration > 100)
301 {
302 penetration = 100;
303 }
304 if (attackStyle == AttackStyle.TwoHand)
305 {
306 dMulti = dMulti * 1.5f + 0.1f * Mathf.Sqrt(Mathf.Max(0, CC.Evalue(130)));
307 }
308 dMulti = dMulti * (float)distMod / 100f;
309 toHit = (toHitBase + toHitFix) * (100 + CC.Evalue(414)) / 100;
310 toHit = toHit * distMod / 100;
311 if (CC.HasCondition<ConBane>())
312 {
313 toHit = toHit * 75 / 100;
314 }
315 if (TC != null && CC.HasHigherGround(TC))
316 {
317 toHit = toHit * 120 / 100;
318 }
319 if (CC.ride != null)
320 {
321 toHit = toHit * 100 / (100 + 500 / Mathf.Max(5, 10 + CC.EvalueRiding()));
322 }
323 if (CC.parasite != null)
324 {
325 toHit = toHit * 100 / (100 + 1000 / Mathf.Max(5, 10 + CC.Evalue(227)));
326 }
327 if (CC.host != null)
328 {
329 if (CC.host.ride == CC)
330 {
331 toHit = toHit * 100 / (100 + 1000 / Mathf.Max(5, 10 + CC.STR));
332 }
333 if (CC.host.parasite == CC)
334 {
335 toHit = toHit * 100 / (100 + 2000 / Mathf.Max(5, 10 + CC.DEX));
336 }
337 }
338 if (attackStyle == AttackStyle.TwoHand)
339 {
340 toHit += 25 + (int)Mathf.Sqrt(Mathf.Max(0, CC.Evalue(130)) * 2);
341 }
342 else if (attackStyle == AttackStyle.TwoWield)
343 {
344 int num4 = CC.EvalueMax(131, -10);
345 int num5 = ((num4 >= 50) ? 10 : ((num4 >= 25) ? 12 : 15));
346 if (toHit > 0)
347 {
348 toHit = toHit * 100 / (100 + (attackIndex + 1) * num5 + attackIndex * Mathf.Clamp(2000 / (20 + num4), 0, 100));
349 }
350 }
351 if (CC.isBlind)
352 {
353 toHit /= ((IsRanged || isThrow) ? 10 : 3);
354 }
356 {
357 toHit /= 2;
358 }
359 if (TC != null)
360 {
361 evasion = EClass.curve(TC.PER / 3 + TC.Evalue(150), 50, 10) + TC.DV + 25;
362 if (TC.isChara && TC.Chara.isBlind)
363 {
364 evasion /= 2;
365 }
366 if (TC.HasCondition<ConDim>())
367 {
368 evasion /= 2;
369 }
370 if (TC.isChara && TC.Chara.HasHigherGround(CC))
371 {
372 evasion = evasion * 120 / 100;
373 }
374 }
375 }
376
377 public void PlayRangedAnime(int numFire)
378 {
379 if (weapon == null)
380 {
381 return;
382 }
383 bool isGun = toolRange is TraitToolRangeGun;
384 bool isCane = toolRange is TraitToolRangeCane;
385 GameSetting.EffectData data = EClass.setting.effect.guns.TryGetValue(weapon.id) ?? EClass.setting.effect.guns[isCane ? "cane" : (isGun ? "gun" : "bow")];
386 bool isPCC = CC.IsPCC && CC.renderer.hasActor;
387 Vector2 firePos = (isPCC ? new Vector2(data.firePos.x * (float)((CC.renderer.actor.currentDir != 0 && CC.renderer.actor.currentDir != 1) ? 1 : (-1)), data.firePos.y) : Vector2.zero);
388 Chara _CC = CC;
389 Point _TP = posRangedAnime.Copy();
390 Thing _weapon = weapon;
391 bool ignoreSound = ignoreAttackSound;
393 Color effColor = Color.white;
394 if (isCane)
395 {
396 IEnumerable<Element> enumerable = toolRange.owner.elements.dict.Values.Where((Element e) => e.source.categorySub == "eleAttack");
397 if (enumerable.Count() > 0)
398 {
399 Element element = enumerable.RandomItem();
400 effColor = EClass.Colors.elementColors[element.source.alias];
401 }
402 }
403 for (int i = 0; i < numFire; i++)
404 {
405 TweenUtil.Delay((float)i * data.delay, delegate
406 {
408 {
409 if (_weapon.id == "gun_rail")
410 {
411 _CC.PlayEffect("laser").GetComponent<SpriteBasedLaser>().Play(_TP.PositionCenter());
412 }
413 else
414 {
415 Effect effect = Effect.Get("ranged_arrow")._Play(_CC.pos, _CC.isSynced ? _CC.renderer.position : _CC.pos.Position(), 0f, _TP, data.sprite);
416 if (isCane)
417 {
418 effect.sr.color = effColor;
419 }
420 }
421 if (data.eject)
422 {
423 if (!ignoreSound)
424 {
425 _CC.PlaySound("bullet_drop");
426 }
427 _CC.PlayEffect("bullet").Emit(1);
428 }
429 if (isGun)
430 {
431 if (isPCC)
432 {
433 _weapon.PlayEffect(data.idEffect.IsEmpty("gunfire"), useRenderPos: true, 0f, firePos);
434 }
435 else
436 {
437 _CC.PlayEffect(data.idEffect.IsEmpty("gunfire"));
438 }
439 }
440 if (!ignoreSound)
441 {
442 _CC.PlaySound(data.idSound.IsEmpty("attack_gun"));
443 }
444 }
445 });
446 }
447 }
448
449 public int GetRawDamage(float dmgMulti, bool crit, bool maxRoll)
450 {
451 bool flag = CC.HasCondition<ConReload>();
452 int num = Dice.Roll(dNum, dDim, dBonus, CC);
453 if (ammo != null && !flag)
454 {
456 }
457 if (crit || maxRoll)
458 {
459 num = Dice.RollMax(dNum, dDim, dBonus);
460 if (ammo != null && !flag)
461 {
463 }
464 if (crit && (IsMartial || IsMartialWeapon))
465 {
466 dMulti *= 1.25f;
467 }
468 }
469 int num2 = CC.Evalue(1355);
470 ConStrife condition = CC.GetCondition<ConStrife>();
471 if (condition != null)
472 {
473 num += condition.GetDice().Roll();
474 }
475 else if (num2 > 0)
476 {
477 num++;
478 }
479 num = Mathf.Clamp(num, 0, 9999999);
480 num = (int)(dMulti * (float)num * dmgMulti);
481 return Mathf.Clamp(num, 0, 9999999);
482 }
483
484 public static void ProcShieldEncs(Chara CC, Card TC, int mtpChance = 100)
485 {
486 foreach (BodySlot slot in CC.body.slots)
487 {
488 if (slot.elementId == 35 && slot.thing != null && (slot.thing.category.IsChildOf("shield") || slot.thing.category.IsChildOf("martial")))
489 {
490 ProcAbility(slot.thing.elements.dict.Values.ToList(), CC, TC, CC.Evalue((slot.thing.category.skill == 0) ? 123 : slot.thing.category.skill), subAttack: false, mtpChance);
491 }
492 }
493 }
494
495 public static void ProcAbility(List<Element> list, Chara CC, Card TC, int bonus, bool subAttack = false, int mtpChance = 100)
496 {
497 if (list == null)
498 {
499 return;
500 }
501 foreach (Element item in list)
502 {
503 ProcAbility(item, CC, TC, bonus, subAttack, mtpChance);
504 }
505 }
506
507 public static void ProcAbility(Element e, Chara CC, Card TC, int bonus, bool subAttack = false, int mtpChance = 100)
508 {
509 if (!(e is Ability))
510 {
511 return;
512 }
513 int num = (10 + e.Value / 5) * mtpChance / 100;
514 int power = EClass.curve((100 + e.Value * 10) * (100 + bonus) / 100, 400, 100);
515 if (e.id == 6602)
516 {
517 num = 100;
518 }
519 if (num <= EClass.rnd(100))
520 {
521 return;
522 }
523 Act obj = e as Act;
524 Card card = (obj.TargetType.CanSelectSelf ? CC : TC);
525 string text = ((e.source.proc.Length >= 2) ? e.source.proc[1] : "");
526 string text2 = obj.source.abilityType.TryGet(0);
527 switch (text2)
528 {
529 case "buff":
530 if (CC.HasCondition(text))
531 {
532 return;
533 }
534 card = CC;
535 break;
536 case "debuff":
537 case "attack":
538 case "dot":
539 card = TC;
540 break;
541 }
542 if (subAttack)
543 {
544 if (card == CC)
545 {
546 return;
547 }
548 switch (text2)
549 {
550 case "summon":
551 return;
552 case "teleport":
553 return;
554 case "suicide":
555 return;
556 }
557 }
558 if (card.IsAliveInCurrentZone)
559 {
560 Card tC = Act.TC;
561 ActEffect.ProcAt(e.source.proc[0].ToEnum<EffectId>(), power, BlessedState.Normal, CC, card, card.pos, isNeg: false, new ActRef
562 {
563 n1 = text,
564 aliasEle = e.source.aliasRef,
565 noFriendlyFire = true
566 });
567 Act.TC = tC;
568 }
569 }
570
571 public bool Perform(int count, bool hasHit, float dmgMulti = 1f, bool maxRoll = false, bool subAttack = false)
572 {
573 bool flag = CC.HasCondition<ConReload>();
574 bool flag2 = CC.HasElement(486) && CC.IsPCFactionOrMinion;
575 hit = CalcHit();
576 if (CC.id == "tsunami")
577 {
578 hit = true;
579 }
580 int num = GetRawDamage(dmgMulti, crit, maxRoll);
581 if (IsRanged && count >= numFireWithoutDamageLoss)
582 {
583 num = num * 100 / (100 + (count - numFireWithoutDamageLoss + 1) * 30);
584 }
585 if (CC.isRestrained)
586 {
587 num /= 2;
588 }
589 List<Element> list = new List<Element>();
590 int num2 = CC.Evalue(91);
591 string id = CC.id;
592 if ((id == "stalker" || id == "stalker_shadow") && TC.isChara && TC.Chara.CanSee(CC))
593 {
594 num2 = 0;
595 }
596 int num3 = 0;
597 if (weapon != null)
598 {
599 list = weapon.elements.dict.Values.ToList();
600 if (ammo != null && !flag)
601 {
602 list = list.Concat(ammo.elements.dict.Values).ToList();
603 }
604 num2 += weapon.Evalue(91, ignoreGlobalElement: true);
605 num3 += weapon.Evalue(603, ignoreGlobalElement: true);
606 }
607 else
608 {
609 id = CC.id;
610 if (id == "rabbit_vopal" || id == "mantis_killer")
611 {
612 list.Add(Element.Create(6650, 100));
613 }
614 }
615 int bane;
616 if (TC?.Chara != null)
617 {
618 bane = 0;
619 AddBane(valid: true, 468, 50);
620 AddBane(TC.Chara.IsUndead, 461, 100);
621 AddBane(TC.Chara.IsAnimal, 463, 100);
622 AddBane(TC.Chara.IsHuman, 464, 100);
623 AddBane(TC.Chara.IsDragon, 460, 100);
624 AddBane(TC.Chara.IsGod, 466, 100);
625 AddBane(TC.Chara.IsMachine, 465, 100);
626 AddBane(TC.Chara.IsFish, 467, 100);
627 AddBane(TC.Chara.IsFairy, 462, 100);
628 if (bane != 0)
629 {
630 num = num * (100 + bane * 3) / 100;
631 }
632 }
633 if (CC.IsPCFaction)
634 {
635 foreach (Element value in EClass.pc.faction.charaElements.dict.Values)
636 {
637 if (value.Value > 0)
638 {
639 list.Add(value);
640 }
641 }
642 }
643 if (hit && num2 > EClass.rnd(100))
644 {
645 CC.Say("vopal");
646 penetration = 100;
647 }
648 if (crit)
649 {
650 CC.Say((critFury ? "fury_" : "") + (CC.IsHostile() ? "critical_enemy" : "critical"));
651 if (CC.IsPC)
652 {
653 CC.PlaySound("critical");
654 }
655 }
656 if (CC.isSynced || (TC != null && TC.isSynced))
657 {
658 if (toolRange != null && (!IsRanged || count == 0) && !flag && !ignoreAnime)
659 {
661 }
662 if (hit && TC != null && !hasHit)
663 {
664 PlayHitEffect();
665 }
666 }
667 if (TC == null)
668 {
669 CC.Say(IsRanged ? "attack_air_range" : "attack_air", CC);
670 return true;
671 }
672 if (!hit)
673 {
674 if (TC != null)
675 {
676 if (CC.IsPCParty)
677 {
678 CC.Say(evadePlus ? "evadePlus2" : "evade2", CC, TC);
679 }
680 else
681 {
682 TC.Say(evadePlus ? "evadePlus" : "evade", TC, CC);
683 }
684 ModExpDef(150, 90);
685 ModExpDef(151, 90);
686 }
687 ProcAbility(list, CC, TC, weaponSkill.Value + GetTwoHandEncBonus(CC), subAttack);
688 return false;
689 }
690 if (TC.IsPC)
691 {
692 Msg.SetColor("attack_pc");
693 EClass.pc.Say("attackMeleeToPC", CC, TC, GetAttackText(attackType, 3));
694 }
695 else
696 {
697 CC.Say("attackMelee", CC, TC, GetAttackText(attackType, 0));
698 }
699 bool showEffect = true;
700 int num4 = 0;
701 int num5 = 0;
702 int num6 = 0;
703 ConWeapon conWeapon = null;
704 if (weapon != null)
705 {
706 foreach (Element value2 in weapon.elements.dict.Values)
707 {
708 if (value2.source.categorySub == "eleConvert")
709 {
710 num4 = EClass.sources.elements.alias[value2.source.aliasRef].id;
711 num5 = 50 + value2.Value * 2;
712 num6 = Mathf.Min(value2.Value, 100);
713 break;
714 }
715 }
716 }
717 if (num4 == 0)
718 {
720 {
721 conWeapon = CC.GetCondition<ConWeapon>();
722 num4 = conWeapon.sourceElement.id;
723 num5 = conWeapon.power / 2;
724 num6 = (int)Mathf.Min(40f + MathF.Sqrt(conWeapon.power), 80f);
725 }
726 if (conWeapon == null && weapon == null && (CC.MainElement != Element.Void || CC.HasElement(1565)))
727 {
728 num4 = (CC.HasElement(1565) ? 915 : CC.MainElement.id);
729 num5 = CC.Power / 3 + EClass.rnd(CC.Power / 2);
730 if (CC.MainElement != Element.Void)
731 {
732 num5 += CC.MainElement.Value;
733 }
734 showEffect = false;
735 num6 = 50;
736 }
737 if (conWeapon == null && weapon != null && weapon.trait is TraitToolRangeCane)
738 {
739 IEnumerable<Element> enumerable = weapon.elements.dict.Values.Where((Element e) => e.source.categorySub == "eleAttack");
740 if (enumerable.Count() > 0)
741 {
742 num4 = enumerable.RandomItem().id;
743 num5 = num4 switch
744 {
745 920 => 30,
746 914 => 50,
747 918 => 50,
748 _ => 100,
749 };
750 }
751 num6 = 50;
752 }
753 }
754 int num7 = num;
755 int num8 = num * num6 / 100;
756 num -= num8;
757 int num9 = num * penetration / 100;
758 num -= num9;
759 num = TC.ApplyProtection(num) + num9 + num8;
760 int weaponEnc = GetWeaponEnc(CC, weapon, 609, addSelfEnc: true);
761 TC.DamageHP(num, num4, num5, (!IsRanged && !isThrow) ? AttackSource.Melee : AttackSource.Range, CC, showEffect, weapon);
762 if (conWeapon != null && (weaponEnc <= 0 || !(Mathf.Min(10f + Mathf.Sqrt(weaponEnc) * 5f, 90f) > (float)EClass.rnd(100))))
763 {
764 conWeapon.Mod(-1);
765 }
766 bool flag3 = IsCane || (weapon != null && weapon.Evalue(482) > 0);
767 int attackStyleElement = CC.body.GetAttackStyleElement(attackStyle);
768 if (!subAttack)
769 {
770 int mod2 = 100 / (count + 1);
771 if (!IsRanged || count == 0)
772 {
773 ModExpAtk(weaponSkill.id, mod2);
774 ModExpAtk(flag3 ? 304 : (IsRanged ? 133 : 132), mod2);
775 }
776 if (crit)
777 {
778 ModExpAtk(134, 50);
779 }
780 if (count == 0 && attackStyleElement != 0)
781 {
782 ModExpAtk(attackStyleElement, 100);
783 }
784 }
785 if (!CC.IsAliveInCurrentZone || !TC.IsAliveInCurrentZone)
786 {
787 return true;
788 }
789 if (EClass.rnd(8) == 0 && TC.isChara && CC.HasElement(1219))
790 {
791 CC.Say("abCrab", CC, TC);
792 TC.Chara.AddCondition<ConParalyze>(30 + EClass.rnd(30));
793 TC.Chara.AddCondition<ConGravity>();
794 }
795 if (list.Count > 0 && !flag2)
796 {
797 foreach (Element item in list)
798 {
799 if (!TC.IsAliveInCurrentZone)
800 {
801 break;
802 }
803 if (item.IsActive(weapon) && item.source.categorySub == "eleAttack")
804 {
805 int num10 = 25;
806 int num11 = EClass.rnd(num * (100 + item.Value * 10) / 500 + 5);
807 num11 = num11 * (100 + GetTwoHandEncBonus(CC)) / 100;
808 if (conWeapon == null && weapon != null && weapon.trait is TraitToolRangeCane)
809 {
810 num10 = 0;
811 }
812 if (num10 > EClass.rnd(100))
813 {
814 TC.DamageHP(num11, item.id, isThrow ? (100 + item.Value * 5) : (30 + item.Value), AttackSource.WeaponEnchant, CC);
815 }
816 }
817 }
818 ProcAbility(list, CC, TC, weaponSkill.Value + GetTwoHandEncBonus(CC), subAttack);
819 }
820 if (!CC.IsAliveInCurrentZone || !TC.IsAliveInCurrentZone)
821 {
822 return true;
823 }
824 if (!IsRanged && !flag2 && attackStyle == AttackStyle.Shield)
825 {
826 int num12 = CC.Evalue(123);
827 int num13 = CC.Evalue(381);
828 if (CC.elements.ValueWithoutLink(123) >= 10 && Mathf.Clamp(Mathf.Sqrt(num12) - 2f, 8f, 15f) + Mathf.Min(Mathf.Sqrt(num13), 25f) > (float)EClass.rnd(100))
829 {
830 num = num7 * (Mathf.Min(50 + num12 + num13, 200) + (int)Mathf.Min(Mathf.Sqrt(num13), 100f)) / 100;
831 penetration = (int)Mathf.Sqrt(num13) + ((num13 != 0) ? 20 : 0);
832 if (penetration > 100)
833 {
834 penetration = 100;
835 }
836 num9 = num * penetration / 100;
837 num -= num9;
838 num = TC.ApplyProtection(num) + num9;
839 Debug.Log("Bash:" + num + "/" + num7);
840 CC.PlaySound("shield_bash");
841 CC.Say("shield_bash", CC, TC);
842 TC.DamageHP(num, AttackSource.None, CC);
843 if (TC.IsAliveInCurrentZone && TC.isChara)
844 {
845 if (EClass.rnd(2) == 0)
846 {
847 TC.Chara.AddCondition<ConDim>(50 + (int)Mathf.Sqrt(num12) * 10);
848 }
849 TC.Chara.AddCondition<ConParalyze>(EClass.rnd(2), force: true);
850 }
851 ProcShieldEncs(CC, TC, 500 + num13);
852 }
853 }
854 if (!CC.IsAliveInCurrentZone || !TC.IsAliveInCurrentZone)
855 {
856 return true;
857 }
858 if (TC.isChara && !TC.HasCondition<ConGravity>() && num3 > 0 && num3 * 2 + 15 > EClass.rnd(100) && !TC.isRestrained && TC.Chara.TryMoveFrom(CC.pos) == Card.MoveResult.Success)
859 {
860 TC.pos.PlayEffect("vanish");
861 TC.PlaySound("push", 1.5f);
862 }
863 return true;
864 void AddBane(bool valid, int idEle, int mod)
865 {
866 if (valid)
867 {
868 bane += (CC.Evalue(idEle) + ((weapon != null) ? weapon.Evalue(idEle, ignoreGlobalElement: true) : 0)) * mod / 100;
869 }
870 }
871 bool IgnoreExp()
872 {
873 if (!CC.HasEditorTag(EditorTag.Invulnerable) && !CC.HasEditorTag(EditorTag.InvulnerableToMobs) && !TC.HasEditorTag(EditorTag.Invulnerable))
874 {
875 return TC.HasEditorTag(EditorTag.InvulnerableToMobs);
876 }
877 return true;
878 }
879 void ModExpAtk(int ele, int mod)
880 {
881 if (!IgnoreExp() && (!TC.isCopy || EClass.rnd(10) == 0))
882 {
883 int a = (Mathf.Clamp((TC.LV + 10 - CC.elements.ValueWithoutLink(ele)) / 2, 1, 10) + Mathf.Min(TC.LV / 10, 10)) * mod / 100;
884 a = Mathf.Min(a, 200);
885 if (TC == CC)
886 {
887 a /= 2;
888 }
889 if (a > 0)
890 {
891 CC.ModExp(ele, a + EClass.rnd(a / 2 + 1));
892 }
893 }
894 }
895 void ModExpDef(int ele, int mod)
896 {
897 if (!IgnoreExp() && (!CC.isCopy || EClass.rnd(10) == 0))
898 {
899 int a2 = (Mathf.Clamp((CC.LV + 10 - TC.elements.ValueWithoutLink(ele)) / 2, 1, 10) + Mathf.Min(CC.LV / 10, 10)) * mod / 100;
900 a2 = Mathf.Min(a2, TC.isRestrained ? 10 : 200);
901 if (TC == CC)
902 {
903 a2 /= 2;
904 }
905 if (!TC.IsPC && !TC.isRestrained && !TC.HasHost)
906 {
907 a2 *= 3;
908 }
909 if (a2 > 0)
910 {
911 TC.ModExp(ele, a2 + EClass.rnd(a2 / 2 + 1));
912 }
913 }
914 }
915 void PlayHitEffect()
916 {
917 string id2 = "hit_default";
918 string id3 = "hit_default";
919 switch (attackType)
920 {
921 case AttackType.Slash:
922 id3 = "hit_slash";
923 id2 = "hit_slash";
924 break;
925 case AttackType.Spore:
926 id3 = "hit_spore";
927 id2 = "hit_spore";
928 break;
929 case AttackType.Claw:
930 case AttackType.Bite:
931 id3 = "hit_claw";
932 id2 = "hit_claw";
933 break;
934 case AttackType.Blunt:
935 case AttackType.Punch:
936 case AttackType.Kick:
937 case AttackType.Bow:
938 case AttackType.Gun:
939 case AttackType.Cane:
940 id3 = "hit_blunt";
941 id2 = "hit_blunt";
942 break;
943 }
944 if (TC != null)
945 {
946 TC.PlayEffect(id3).SetScale(crit ? 1.25f : 0.75f);
947 }
948 CC.PlaySound(id2);
949 }
950 }
951
952 private bool Crit()
953 {
954 crit = true;
955 return true;
956 }
957
958 private bool EvadePlus()
959 {
960 evadePlus = true;
961 return false;
962 }
963
964 public bool CalcHit()
965 {
966 if (critFury)
967 {
968 crit = true;
969 return true;
970 }
971 if (CC.HasCondition<ConSevenSense>() && (CC.HasElement(1244) || CC.HasElement(1246) || CC.HasElement(1247)))
972 {
973 return true;
974 }
975 if (TC != null)
976 {
977 if (TC.HasCondition<ConDim>() && EClass.rnd(4) == 0)
978 {
979 return Crit();
980 }
981 if (TC.IsDeadOrSleeping)
982 {
983 return Crit();
984 }
985 int num = TC.Evalue(151);
986 if (num != 0 && toHit < num * 10)
987 {
988 int num2 = evasion * 100 / Mathf.Clamp(toHit, 1, toHit);
989 if (num2 > 300 && EClass.rnd(num + 250) > 100)
990 {
991 return EvadePlus();
992 }
993 if (num2 > 200 && EClass.rnd(num + 250) > 150)
994 {
995 return EvadePlus();
996 }
997 if (num2 > 150 && EClass.rnd(num + 250) > 200)
998 {
999 return EvadePlus();
1000 }
1001 }
1002 if (TC.Evalue(57) > EClass.rnd(100))
1003 {
1004 return EvadePlus();
1005 }
1006 }
1007 if (EClass.rnd(20) == 0)
1008 {
1009 return true;
1010 }
1011 if (EClass.rnd(20) == 0)
1012 {
1013 return false;
1014 }
1015 if (toHit < 1)
1016 {
1017 return false;
1018 }
1019 if (evasion < 1)
1020 {
1021 return true;
1022 }
1023 if (EClass.rnd(toHit) < EClass.rnd(evasion * (IsRanged ? 150 : 125) / 100))
1024 {
1025 return false;
1026 }
1027 if (EClass.rnd(5000) < CC.Evalue(73) + 50)
1028 {
1029 return Crit();
1030 }
1031 if ((float)(CC.Evalue(90) + ((weapon != null) ? weapon.Evalue(90, ignoreGlobalElement: true) : 0)) + Mathf.Sqrt(CC.Evalue(134)) > (float)EClass.rnd(200))
1032 {
1033 return Crit();
1034 }
1035 if (CC.Evalue(1420) > 0)
1036 {
1037 int num3 = Mathf.Min(100, 100 - CC.hp * 100 / CC.MaxHP) * (50 + CC.Evalue(1420) * 50) / 100;
1038 if (num3 >= 50 && num3 * num3 * num3 * num3 / 3 > EClass.rnd(100000000))
1039 {
1040 return Crit();
1041 }
1042 }
1043 return true;
1044 }
1045
1046 public string GetAttackText(AttackType type, int id)
1047 {
1048 return Lang.GetList("attack" + type)[id];
1049 }
1050}
AttackSource
Definition: AttackSource.cs:2
AttackStyle
Definition: AttackStyle.cs:2
AttackType
Definition: AttackType.cs:2
BlessedState
Definition: BlessedState.cs:2
CTAG
Definition: CTAG.cs:2
EditorTag
Definition: EditorTag.cs:2
EffectId
Definition: EffectId.cs:2
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
static void ProcAt(EffectId id, int power, BlessedState state, Card cc, Card tc, Point tp, bool isNeg, ActRef actRef=default(ActRef))
Definition: ActEffect.cs:430
Definition: ACT.cs:62
static Card TC
Definition: ACT.cs:79
TraitToolRange toolRange
AttackType attackType
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)
string GetAttackText(AttackType type, int id)
static void ProcAbility(List< Element > list, Chara CC, Card TC, int bonus, bool subAttack=false, int mtpChance=100)
static AttackProcess Current
Definition: AttackProcess.cs:8
static int GetTwoHandEncBonus(Chara CC)
int GetRawDamage(float dmgMulti, bool crit, bool maxRoll)
static void ProcAbility(Element e, Chara CC, Card TC, int bonus, bool subAttack=false, int mtpChance=100)
string GetText()
bool ignoreAttackSound
int numFireWithoutDamageLoss
bool IsMartialWeapon
Point posRangedAnime
Element weaponSkill
static int GetWeaponEnc(Chara CC, Thing w, int ele, bool addSelfEnc=false)
AttackStyle attackStyle
void PlayRangedAnime(int numFire)
static void ProcShieldEncs(Chara CC, Card TC, int mtpChance=100)
void Mod(int a, bool force=false)
SourceElement.Row sourceElement
int elementId
Definition: BodySlot.cs:6
Thing thing
Definition: BodySlot.cs:8
virtual int currentDir
Definition: CardActor.cs:41
Vector3 position
Definition: CardRenderer.cs:21
CardActor actor
Definition: CardRenderer.cs:11
Definition: Card.cs:11
int DMG
Definition: Card.cs:2293
bool IsPCFactionOrMinion
Definition: Card.cs:2234
int EvalueMax(int ele, int min=0)
Definition: Card.cs:2547
ElementContainerCard elements
Definition: Card.cs:39
string id
Definition: Card.cs:33
int ChildrenWeight
Definition: Card.cs:1975
bool HasElement(int ele, int req=1)
Definition: Card.cs:5725
bool isRestrained
Definition: Card.cs:552
virtual int Power
Definition: Card.cs:2257
SourceMaterial.Row material
Definition: Card.cs:2013
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5939
int HIT
Definition: Card.cs:2291
bool isCopy
Definition: Card.cs:864
Thing ammoData
Definition: Card.cs:1759
int hp
Definition: Card.cs:228
int WIL
Definition: Card.cs:2305
int STR
Definition: Card.cs:2295
bool HasTag(CTAG tag)
Definition: Card.cs:2557
Point pos
Definition: Card.cs:57
int DEX
Definition: Card.cs:2297
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:5973
Trait trait
Definition: Card.cs:51
int encLV
Definition: Card.cs:312
int c_diceDim
Definition: Card.cs:1363
MoveResult
Definition: Card.cs:13
bool HasEditorTag(EditorTag tag)
Definition: Card.cs:2562
virtual Thing Thing
Definition: Card.cs:2020
int Evalue(int ele)
Definition: Card.cs:2533
void ModExp(string alias, int a)
Definition: Card.cs:2610
SourceCategory.Row category
Definition: Card.cs:2011
CardRenderer renderer
Definition: Card.cs:59
int LV
Definition: Card.cs:372
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6586
List< BodySlot > slots
Definition: CharaBody.cs:8
AttackStyle GetAttackStyle()
Definition: CharaBody.cs:433
int GetAttackStyleElement(AttackStyle style)
Definition: CharaBody.cs:466
Definition: Chara.cs:10
override bool IsAliveInCurrentZone
Definition: Chara.cs:559
Element MainElement
Definition: Chara.cs:715
CharaBody body
Definition: Chara.cs:94
Faction faction
Definition: Chara.cs:425
override bool IsPC
Definition: Chara.cs:610
Chara host
Definition: Chara.cs:33
override bool IsPCParty
Definition: Chara.cs:613
int EvalueRiding()
Definition: Chara.cs:5932
bool HasCondition(string alias)
Definition: Chara.cs:9054
override bool isSynced
Definition: Chara.cs:689
override bool IsPCFaction
Definition: Chara.cs:669
override int MaxHP
Definition: Chara.cs:706
Zone currentZone
Definition: Chara.cs:253
bool HasHigherGround(Card c)
Definition: Chara.cs:1172
Chara parasite
Definition: Chara.cs:30
Chara ride
Definition: Chara.cs:27
bool isBlind
Definition: Chara.cs:130
bool IsHostile()
Definition: Chara.cs:6298
bool isConfused
Definition: Chara.cs:126
SourceRace.Row race
Definition: Chara.cs:462
UD_String_Color elementColors
Definition: ConDim.cs:2
Dice GetDice()
Definition: ConStrife.cs:52
bool IsGameStarted
Definition: Core.cs:84
Definition: Dice.cs:4
static int RollMax(int num, int sides, int bonus=0)
Definition: Dice.cs:46
static int Roll(int num, int sides, int bonus=0, Card card=null)
Definition: Dice.cs:15
Definition: EClass.cs:5
static ColorProfile Colors
Definition: EClass.cs:38
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:68
static Core core
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:20
static int rnd(long a)
Definition: EClass.cs:58
static SourceManager sources
Definition: EClass.cs:42
static Chara pc
Definition: EClass.cs:14
static GameSetting setting
Definition: EClass.cs:34
Definition: Effect.cs:7
Effect _Play(Point from, Vector3 fromV, float fixY=0f, Point to=null, Sprite sprite=null)
Definition: Effect.cs:115
Effect Emit(int num)
Definition: Effect.cs:279
static Effect Get(Effect original)
Definition: Effect.cs:85
Dictionary< int, Element > dict
int Value(int ele)
int ValueWithoutLink(int ele)
Element GetOrCreateElement(Element ele)
int id
Definition: ELEMENT.cs:250
SourceElement.Row source
Definition: ELEMENT.cs:273
int Value
Definition: ELEMENT.cs:292
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1100
static Element Void
Definition: ELEMENT.cs:238
Element GetParent(Card c)
Definition: ELEMENT.cs:522
ElementContainerFaction charaElements
Definition: FACTION.cs:146
UD_String_EffectData guns
Definition: GameSetting.cs:276
EffectSetting effect
Definition: GameSetting.cs:299
Definition: Lang.cs:6
static string[] GetList(string id)
Definition: Lang.cs:114
Definition: Msg.cs:5
static void SetColor()
Definition: Msg.cs:22
Definition: Point.cs:9
ref Vector3 Position(int height)
Definition: Point.cs:536
Point Copy()
Definition: Point.cs:479
ref Vector3 PositionCenter()
Definition: Point.cs:575
int Distance(Point p)
Definition: Point.cs:973
SourceElement elements
Definition: TC.cs:4
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
bool isEquipped
Definition: Thing.cs:17
override int SelfWeight
Definition: Thing.cs:82
int Penetration
Definition: Thing.cs:34
virtual Element WeaponSkill
Card owner
Definition: Trait.cs:27
bool TryGetValue(TKey key, out TValue value)
Definition: UDictionary.cs:178
Definition: Zone.cs:12
Definition: ActRef.cs:2