Elin Decompiled Documentation EA 23.102 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 string GetText()
115 {
116 string text = dNum + "d" + dDim;
117 text = text + ((dBonus >= 0) ? "+" : "") + dBonus;
118 string @ref = (IsMartial ? "evalHand".lang() : "evalWeapon".lang((attackIndex + 1).ToString() ?? ""));
119 return "attackEval".lang(@ref, text, dMulti.ToString("F2") ?? "", toHit.ToString() ?? "", penetration.ToString() ?? "");
120 }
121
122 public void Prepare(Chara _CC, Thing _weapon, Card _TC = null, Point _TP = null, int _attackIndex = 0, bool _isThrow = false)
123 {
124 CC = _CC;
125 TC = _TC;
126 TP = _TP;
127 isThrow = _isThrow;
128 weapon = _weapon;
129 ammo = _weapon?.ammoData;
130 hit = (crit = (critFury = (evadePlus = false)));
132 attackType = AttackType.Slash;
133 attackStyle = AttackStyle.Default;
134 evasion = 0;
135 penetration = 0;
136 distMod = 100;
137 attackIndex = _attackIndex;
139 ignoreAnime = (ignoreAttackSound = false);
140 if (!isThrow)
141 {
142 if (!IsRanged)
143 {
145 }
146 else if (TP != null)
147 {
148 int num = CC.pos.Distance(TP);
149 distMod = Mathf.Max(115 - 10 * Mathf.Abs(num - toolRange.BestDist) * 100 / (100 + weapon.Evalue(605) * 10), 80);
150 }
151 }
152 if (isThrow)
153 {
154 bool flag = weapon.HasTag(CTAG.throwWeapon) || weapon.HasTag(CTAG.throwWeaponEnemy);
155 int num2 = (int)Mathf.Clamp(Mathf.Sqrt(weapon.SelfWeight + weapon.ChildrenWeight) * 3f + 25f + (float)(flag ? 75 : 0), 10f, 400f + Mathf.Sqrt(CC.STR) * 50f);
156 int num3 = Mathf.Clamp(weapon.material.hardness, flag ? 40 : 20, 200);
158 attackType = AttackType.Blunt;
159 dBonus = CC.DMG + (CC.IsPCParty ? 3 : 7);
160 dNum = 2;
161 dDim = (((!CC.IsPCParty) ? CC.LV : 0) + CC.STR + CC.Evalue(108)) * num2 / 100 * num3 / 100 / 2;
162 dMulti = 1f;
163 toHitBase = EClass.curve(CC.DEX / 4 + CC.STR / 2 + weaponSkill.Value, 50, 25) + (CC.IsPCFaction ? 75 : 250);
164 toHitFix = CC.HIT + weapon.HIT;
165 penetration = 25;
166 }
167 else if (IsMartial || IsMartialWeapon)
168 {
170 bool flag2 = weapon != null && weapon.Evalue(482) > 0;
171 if (flag2)
172 {
174 }
175 attackType = ((!CC.race.meleeStyle.IsEmpty()) ? CC.race.meleeStyle.ToEnum<AttackType>() : ((EClass.rnd(2) == 0) ? AttackType.Kick : AttackType.Punch));
176 dBonus = CC.DMG + CC.encLV + (int)Mathf.Sqrt(Mathf.Max(0, weaponSkill.GetParent(CC).Value / 5 + weaponSkill.Value / 4));
177 dNum = 2 + Mathf.Min(weaponSkill.Value / 10, 4);
178 dDim = 5 + (int)Mathf.Sqrt(Mathf.Max(0, weaponSkill.Value / 3));
179 dMulti = 0.6f + (float)(weaponSkill.GetParent(CC).Value / 2 + weaponSkill.Value / 2 + CC.Evalue(flag2 ? 304 : 132) / 2) / 50f;
180 dMulti += 0.05f * (float)CC.Evalue(1400);
182 toHitFix = CC.HIT;
183 if (attackStyle == AttackStyle.Shield)
184 {
185 toHitBase = toHitBase * 75 / 100;
186 }
187 penetration = Mathf.Clamp(weaponSkill.Value / 10 + 5, 5, 20) + CC.Evalue(92);
188 if (IsMartialWeapon)
189 {
190 dBonus += weapon.DMG;
191 dNum += weapon.source.offense[0];
192 dDim = Mathf.Max(dDim / 2 + weapon.c_diceDim, 1);
195 if (!weapon.source.attackType.IsEmpty())
196 {
197 attackType = weapon.source.attackType.ToEnum<AttackType>();
198 }
199 }
200 }
201 else
202 {
203 if (IsRanged)
204 {
206 }
207 else
208 {
210 }
211 if (!weapon.source.attackType.IsEmpty())
212 {
213 attackType = weapon.source.attackType.ToEnum<AttackType>();
214 }
215 bool flag3 = IsCane || weapon.Evalue(482) > 0;
216 if (flag3)
217 {
219 }
220 dBonus = CC.DMG + CC.encLV + weapon.DMG;
221 dNum = weapon.source.offense[0];
223 dMulti = 0.6f + (float)(weaponSkill.GetParent(CC).Value + weaponSkill.Value / 2 + CC.Evalue(flag3 ? 304 : (IsRanged ? 133 : 132))) / 50f;
224 dMulti += 0.05f * (float)CC.Evalue(IsRanged ? 1404 : 1400);
225 toHitBase = EClass.curve((IsCane ? CC.WIL : CC.DEX) / 4 + weaponSkill.GetParent(CC).Value / 3 + weaponSkill.Value, 50, 25) + 50;
226 toHitFix = CC.HIT + weapon.HIT;
227 penetration = weapon.Penetration + CC.Evalue(92);
228 if (IsCane)
229 {
230 toHitBase += 50;
231 }
232 }
233 if (ammo != null && !(ammo.trait is TraitAmmoTalisman))
234 {
235 dNumAmmo = ((ammo.source.offense.Length != 0) ? ammo.source.offense[0] : 0);
237 dBonusAmmo = ammo.DMG + ammo.encLV;
238 if (dNumAmmo < 1)
239 {
240 dNumAmmo = 1;
241 }
242 if (dDimAmmo < 1)
243 {
244 dDimAmmo = 1;
245 }
246 toHitFix += ammo.HIT;
247 }
248 else
249 {
250 dNumAmmo = 0;
251 dDimAmmo = 0;
252 }
253 if (dNum < 1)
254 {
255 dNum = 1;
256 }
257 if (dDim < 1)
258 {
259 dDim = 1;
260 }
261 if (penetration > 100)
262 {
263 penetration = 100;
264 }
265 if (attackStyle == AttackStyle.TwoHand)
266 {
267 dMulti = dMulti * 1.5f + 0.1f * Mathf.Sqrt(Mathf.Max(0, CC.Evalue(130)));
268 }
269 dMulti = dMulti * (float)distMod / 100f;
270 toHit = (toHitBase + toHitFix) * (100 + CC.Evalue(414)) / 100;
271 toHit = toHit * distMod / 100;
272 if (CC.HasCondition<ConBane>())
273 {
274 toHit = toHit * 75 / 100;
275 }
276 if (TC != null && CC.HasHigherGround(TC))
277 {
278 toHit = toHit * 120 / 100;
279 }
280 if (CC.ride != null)
281 {
282 toHit = toHit * 100 / (100 + 500 / Mathf.Max(5, 10 + CC.EvalueRiding()));
283 }
284 if (CC.parasite != null)
285 {
286 toHit = toHit * 100 / (100 + 1000 / Mathf.Max(5, 10 + CC.Evalue(227)));
287 }
288 if (CC.host != null)
289 {
290 if (CC.host.ride == CC)
291 {
292 toHit = toHit * 100 / (100 + 1000 / Mathf.Max(5, 10 + CC.STR));
293 }
294 if (CC.host.parasite == CC)
295 {
296 toHit = toHit * 100 / (100 + 2000 / Mathf.Max(5, 10 + CC.DEX));
297 }
298 }
299 if (attackStyle == AttackStyle.TwoHand)
300 {
301 toHit += 25 + (int)Mathf.Sqrt(Mathf.Max(0, CC.Evalue(130)) * 2);
302 }
303 else if (attackStyle == AttackStyle.TwoWield && toHit > 0)
304 {
305 toHit = toHit * 100 / (115 + attackIndex * 15 + attackIndex * Mathf.Clamp(2000 / (20 + CC.EvalueMax(131, -10)), 0, 100));
306 }
307 if (CC.isBlind)
308 {
309 toHit /= ((IsRanged || isThrow) ? 10 : 3);
310 }
312 {
313 toHit /= 2;
314 }
315 if (TC != null)
316 {
317 evasion = EClass.curve(TC.PER / 3 + TC.Evalue(150), 50, 10) + TC.DV + 25;
318 if (TC.isChara && TC.Chara.isBlind)
319 {
320 evasion /= 2;
321 }
322 if (TC.HasCondition<ConDim>())
323 {
324 evasion /= 2;
325 }
326 if (TC.isChara && TC.Chara.HasHigherGround(CC))
327 {
328 evasion = evasion * 120 / 100;
329 }
330 }
331 }
332
333 public void PlayRangedAnime(int numFire)
334 {
335 bool isGun = toolRange is TraitToolRangeGun;
336 bool isCane = toolRange is TraitToolRangeCane;
337 GameSetting.EffectData data = EClass.setting.effect.guns.TryGetValue(weapon.id) ?? EClass.setting.effect.guns[isCane ? "cane" : (isGun ? "gun" : "bow")];
338 bool isPCC = CC.IsPCC && CC.renderer.hasActor;
339 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);
340 Chara _CC = CC;
341 Point _TP = posRangedAnime.Copy();
342 Thing _weapon = weapon;
343 bool ignoreSound = ignoreAttackSound;
345 Color effColor = Color.white;
346 if (isCane)
347 {
348 IEnumerable<Element> enumerable = toolRange.owner.elements.dict.Values.Where((Element e) => e.source.categorySub == "eleAttack");
349 if (enumerable.Count() > 0)
350 {
351 Element element = enumerable.RandomItem();
352 effColor = EClass.Colors.elementColors[element.source.alias];
353 }
354 }
355 for (int i = 0; i < numFire; i++)
356 {
357 TweenUtil.Delay((float)i * data.delay, delegate
358 {
360 {
361 if (_weapon.id == "gun_rail")
362 {
363 _CC.PlayEffect("laser").GetComponent<SpriteBasedLaser>().Play(_TP.PositionCenter());
364 }
365 else
366 {
367 Effect effect = Effect.Get("ranged_arrow")._Play(_CC.pos, _CC.isSynced ? _CC.renderer.position : _CC.pos.Position(), 0f, _TP, data.sprite);
368 if (isCane)
369 {
370 effect.sr.color = effColor;
371 }
372 }
373 if (data.eject)
374 {
375 if (!ignoreSound)
376 {
377 _CC.PlaySound("bullet_drop");
378 }
379 _CC.PlayEffect("bullet").Emit(1);
380 }
381 if (isGun)
382 {
383 if (isPCC)
384 {
385 _weapon.PlayEffect(data.idEffect.IsEmpty("gunfire"), useRenderPos: true, 0f, firePos);
386 }
387 else
388 {
389 _CC.PlayEffect(data.idEffect.IsEmpty("gunfire"));
390 }
391 }
392 if (!ignoreSound)
393 {
394 _CC.PlaySound(data.idSound.IsEmpty("attack_gun"));
395 }
396 }
397 });
398 }
399 }
400
401 public int GetRawDamage(float dmgMulti, bool crit, bool maxRoll)
402 {
403 bool flag = CC.HasCondition<ConReload>();
404 int num = Dice.Roll(dNum, dDim, dBonus, CC);
405 if (ammo != null && !flag)
406 {
408 }
409 if (crit || maxRoll)
410 {
411 num = Dice.RollMax(dNum, dDim, dBonus);
412 if (ammo != null && !flag)
413 {
415 }
416 if (crit && (IsMartial || IsMartialWeapon))
417 {
418 dMulti *= 1.25f;
419 }
420 }
421 int num2 = CC.Evalue(1355);
422 ConStrife condition = CC.GetCondition<ConStrife>();
423 if (condition != null)
424 {
425 num += condition.GetDice().Roll();
426 }
427 else if (num2 > 0)
428 {
429 num++;
430 }
431 num = Mathf.Clamp(num, 0, 9999999);
432 num = (int)(dMulti * (float)num * dmgMulti);
433 return Mathf.Clamp(num, 0, 9999999);
434 }
435
436 public bool Perform(int count, bool hasHit, float dmgMulti = 1f, bool maxRoll = false, bool subAttack = false)
437 {
438 bool flag = CC.HasCondition<ConReload>();
439 hit = CalcHit();
440 int num = GetRawDamage(dmgMulti, crit, maxRoll);
441 if (IsRanged && count >= numFireWithoutDamageLoss)
442 {
443 num = num * 100 / (100 + (count - numFireWithoutDamageLoss + 1) * 30);
444 }
445 if (CC.isRestrained)
446 {
447 num /= 2;
448 }
449 List<Element> list2 = new List<Element>();
450 int num2 = CC.Evalue(91);
451 int num3 = 0;
452 if (weapon != null)
453 {
454 list2 = weapon.elements.dict.Values.ToList();
455 if (ammo != null && !flag)
456 {
457 list2 = list2.Concat(ammo.elements.dict.Values).ToList();
458 }
459 num2 += weapon.Evalue(91, ignoreGlobalElement: true);
460 num3 += weapon.Evalue(603, ignoreGlobalElement: true);
461 }
462 else if (CC.id == "rabbit_vopal")
463 {
464 list2.Add(Element.Create(6650, 100));
465 }
466 int bane;
467 if (TC?.Chara != null)
468 {
469 SourceRace.Row race = TC.Chara.race;
470 bane = 0;
471 AddBane(valid: true, 468, 50);
472 AddBane(race.IsUndead, 461, 100);
473 AddBane(race.IsAnimal, 463, 100);
474 AddBane(race.IsHuman, 464, 100);
475 AddBane(race.IsDragon, 460, 100);
476 AddBane(race.IsGod, 466, 100);
477 AddBane(race.IsMachine, 465, 100);
478 AddBane(race.IsFish, 467, 100);
479 AddBane(race.IsFairy, 462, 100);
480 if (bane != 0)
481 {
482 num = num * (100 + bane * 3) / 100;
483 }
484 }
485 if (CC.IsPCFaction)
486 {
487 foreach (Element value in EClass.pc.faction.charaElements.dict.Values)
488 {
489 if (value.Value > 0)
490 {
491 list2.Add(value);
492 }
493 }
494 }
495 if (hit && num2 > EClass.rnd(100))
496 {
497 CC.Say("vopal");
498 penetration = 100;
499 }
500 if (crit)
501 {
502 CC.Say((critFury ? "fury_" : "") + (CC.IsHostile() ? "critical_enemy" : "critical"));
503 if (CC.IsPC)
504 {
505 CC.PlaySound("critical");
506 }
507 }
508 if (CC.isSynced || (TC != null && TC.isSynced))
509 {
510 if (toolRange != null && (!IsRanged || count == 0) && !flag && !ignoreAnime)
511 {
513 }
514 if (hit && TC != null && !hasHit)
515 {
516 PlayHitEffect();
517 }
518 }
519 if (TC == null)
520 {
521 CC.Say(IsRanged ? "attack_air_range" : "attack_air", CC);
522 return true;
523 }
524 if (!hit)
525 {
526 if (TC != null)
527 {
528 if (CC.IsPCParty)
529 {
530 CC.Say(evadePlus ? "evadePlus2" : "evade2", CC, TC);
531 }
532 else
533 {
534 TC.Say(evadePlus ? "evadePlus" : "evade", TC, CC);
535 }
536 ModExpDef(150, 90);
537 ModExpDef(151, 90);
538 }
539 Proc(list2);
540 return false;
541 }
542 if (TC.IsPC)
543 {
544 Msg.SetColor("attack_pc");
545 EClass.pc.Say("attackMeleeToPC", CC, TC, GetAttackText(attackType, 3));
546 }
547 else
548 {
549 CC.Say("attackMelee", CC, TC, GetAttackText(attackType, 0));
550 }
551 bool showEffect = true;
552 int num4 = 0;
553 int num5 = 0;
554 int num6 = 0;
555 ConWeapon conWeapon = null;
556 if (weapon != null)
557 {
558 foreach (Element value2 in weapon.elements.dict.Values)
559 {
560 if (value2.source.categorySub == "eleConvert")
561 {
562 num4 = EClass.sources.elements.alias[value2.source.aliasRef].id;
563 num5 = 50 + value2.Value * 2;
564 num6 = Mathf.Min(value2.Value, 100);
565 break;
566 }
567 }
568 }
569 if (num4 == 0)
570 {
572 {
573 conWeapon = CC.GetCondition<ConWeapon>();
574 num4 = conWeapon.sourceElement.id;
575 num5 = conWeapon.power / 2;
576 num6 = (int)Mathf.Min(40f + MathF.Sqrt(conWeapon.power), 80f);
577 }
578 if (conWeapon == null && weapon == null && (CC.MainElement != Element.Void || CC.HasElement(1565)))
579 {
580 num4 = (CC.HasElement(1565) ? 915 : CC.MainElement.id);
581 num5 = CC.Power / 3 + EClass.rnd(CC.Power / 2);
582 if (CC.MainElement != Element.Void)
583 {
584 num5 += CC.MainElement.Value;
585 }
586 showEffect = false;
587 num6 = 50;
588 }
589 if (conWeapon == null && weapon != null && weapon.trait is TraitToolRangeCane)
590 {
591 IEnumerable<Element> enumerable = weapon.elements.dict.Values.Where((Element e) => e.source.categorySub == "eleAttack");
592 if (enumerable.Count() > 0)
593 {
594 num4 = enumerable.RandomItem().id;
595 num5 = num4 switch
596 {
597 920 => 30,
598 914 => 50,
599 918 => 50,
600 _ => 100,
601 };
602 }
603 num6 = 50;
604 }
605 }
606 int num7 = num;
607 int num8 = num * num6 / 100;
608 num -= num8;
609 int num9 = num * penetration / 100;
610 num -= num9;
611 num = TC.ApplyProtection(num) + num9 + num8;
612 TC.DamageHP(num, num4, num5, (!IsRanged && !isThrow) ? AttackSource.Melee : AttackSource.Range, CC, showEffect, weapon);
613 conWeapon?.Mod(-1);
614 bool flag2 = IsCane || (weapon != null && weapon.Evalue(482) > 0);
615 int attackStyleElement = CC.body.GetAttackStyleElement(attackStyle);
616 if (!subAttack)
617 {
618 int mod2 = 100 / (count + 1);
619 if (!IsRanged || count == 0)
620 {
621 ModExpAtk(weaponSkill.id, mod2);
622 ModExpAtk(flag2 ? 304 : (IsRanged ? 133 : 132), mod2);
623 }
624 if (crit)
625 {
626 ModExpAtk(134, 50);
627 }
628 if (count == 0 && attackStyleElement != 0)
629 {
630 ModExpAtk(attackStyleElement, 100);
631 }
632 }
633 if (!CC.IsAliveInCurrentZone || !TC.IsAliveInCurrentZone)
634 {
635 return true;
636 }
637 if (EClass.rnd(8) == 0 && TC.isChara && CC.HasElement(1219))
638 {
639 CC.Say("abCrab", CC, TC);
640 TC.Chara.AddCondition<ConParalyze>(30 + EClass.rnd(30));
641 TC.Chara.AddCondition<ConGravity>();
642 }
643 if (list2.Count > 0)
644 {
645 foreach (Element item in list2)
646 {
647 if (!TC.IsAliveInCurrentZone)
648 {
649 break;
650 }
651 if (item.IsActive(weapon) && item.source.categorySub == "eleAttack")
652 {
653 int num10 = 25;
654 int dmg = EClass.rnd(num * (100 + item.Value * 10) / 500 + 5);
655 if (conWeapon == null && weapon != null && weapon.trait is TraitToolRangeCane)
656 {
657 num10 = 0;
658 }
659 if (num10 > EClass.rnd(100))
660 {
661 TC.DamageHP(dmg, item.id, isThrow ? (100 + item.Value * 5) : (30 + item.Value), AttackSource.WeaponEnchant, CC);
662 }
663 }
664 }
665 Proc(list2);
666 }
667 if (!CC.IsAliveInCurrentZone || !TC.IsAliveInCurrentZone)
668 {
669 return true;
670 }
671 if (!IsRanged && attackStyle == AttackStyle.Shield)
672 {
673 int num11 = CC.Evalue(123);
674 if (CC.elements.ValueWithoutLink(123) >= 10 && Mathf.Clamp(Mathf.Sqrt(num11) - 2f, 8f, 12f) > (float)EClass.rnd(100))
675 {
676 num = num7 * Mathf.Min(50 + num11, 200) / 100;
677 num = TC.ApplyProtection(num);
678 Debug.Log("Bash:" + num + "/" + num7);
679 CC.PlaySound("shield_bash");
680 CC.Say("shield_bash", CC, TC);
681 TC.DamageHP(num, AttackSource.None, CC);
682 if (TC.IsAliveInCurrentZone && TC.isChara)
683 {
684 if (EClass.rnd(2) == 0)
685 {
686 TC.Chara.AddCondition<ConDim>(50 + (int)Mathf.Sqrt(num11) * 10);
687 }
688 TC.Chara.AddCondition<ConParalyze>(EClass.rnd(2), force: true);
689 }
690 }
691 }
692 if (!CC.IsAliveInCurrentZone || !TC.IsAliveInCurrentZone)
693 {
694 return true;
695 }
696 if (TC.isChara && num3 > 0 && num3 * 2 + 15 > EClass.rnd(100) && !TC.isRestrained && TC.Chara.TryMoveFrom(CC.pos) == Card.MoveResult.Success)
697 {
698 TC.pos.PlayEffect("vanish");
699 TC.PlaySound("push", 1.5f);
700 }
701 return true;
702 void AddBane(bool valid, int idEle, int mod)
703 {
704 if (valid)
705 {
706 bane += (CC.Evalue(idEle) + ((weapon != null) ? weapon.Evalue(idEle, ignoreGlobalElement: true) : 0)) * mod / 100;
707 }
708 }
709 bool IgnoreExp()
710 {
711 if (!CC.HasEditorTag(EditorTag.Invulnerable) && !CC.HasEditorTag(EditorTag.InvulnerableToMobs) && !TC.HasEditorTag(EditorTag.Invulnerable))
712 {
713 return TC.HasEditorTag(EditorTag.InvulnerableToMobs);
714 }
715 return true;
716 }
717 void ModExpAtk(int ele, int mod)
718 {
719 if (!IgnoreExp() && (!TC.isCopy || EClass.rnd(10) == 0))
720 {
721 int a = (Mathf.Clamp((TC.LV + 10 - CC.elements.ValueWithoutLink(ele)) / 2, 1, 10) + Mathf.Min(TC.LV / 10, 10)) * mod / 100;
722 a = Mathf.Min(a, 200);
723 if (TC == CC)
724 {
725 a /= 2;
726 }
727 if (a > 0)
728 {
729 CC.ModExp(ele, a + EClass.rnd(a / 2 + 1));
730 }
731 }
732 }
733 void ModExpDef(int ele, int mod)
734 {
735 if (!IgnoreExp() && (!CC.isCopy || EClass.rnd(10) == 0))
736 {
737 int a2 = (Mathf.Clamp((CC.LV + 10 - TC.elements.ValueWithoutLink(ele)) / 2, 1, 10) + Mathf.Min(CC.LV / 10, 10)) * mod / 100;
738 a2 = Mathf.Min(a2, TC.isRestrained ? 10 : 200);
739 if (TC == CC)
740 {
741 a2 /= 2;
742 }
743 if (!TC.IsPC && !TC.isRestrained && !TC.HasHost)
744 {
745 a2 *= 3;
746 }
747 if (a2 > 0)
748 {
749 TC.ModExp(ele, a2 + EClass.rnd(a2 / 2 + 1));
750 }
751 }
752 }
753 void PlayHitEffect()
754 {
755 string id = "hit_default";
756 string id2 = "hit_default";
757 switch (attackType)
758 {
759 case AttackType.Slash:
760 id2 = "hit_slash";
761 id = "hit_slash";
762 break;
763 case AttackType.Spore:
764 id2 = "hit_spore";
765 id = "hit_spore";
766 break;
767 case AttackType.Claw:
768 case AttackType.Bite:
769 id2 = "hit_claw";
770 id = "hit_claw";
771 break;
772 case AttackType.Blunt:
773 case AttackType.Punch:
774 case AttackType.Kick:
775 case AttackType.Bow:
776 case AttackType.Gun:
777 case AttackType.Cane:
778 id2 = "hit_blunt";
779 id = "hit_blunt";
780 break;
781 }
782 if (TC != null)
783 {
784 TC.PlayEffect(id2).SetScale(crit ? 1.25f : 0.75f);
785 }
786 CC.PlaySound(id);
787 }
788 void Proc(List<Element> list)
789 {
790 if (list == null)
791 {
792 return;
793 }
794 foreach (Element item2 in list)
795 {
796 if (item2 is Ability)
797 {
798 int num12 = 10 + item2.Value / 5;
799 int power = EClass.curve((100 + item2.Value * 10) * (100 + weaponSkill.Value) / 100, 400, 100);
800 if (num12 > EClass.rnd(100))
801 {
802 Act obj = item2 as Act;
803 Card card = (obj.TargetType.CanSelectSelf ? CC : TC);
804 string text = ((item2.source.proc.Length >= 2) ? item2.source.proc[1] : "");
805 string text2 = obj.source.abilityType.TryGet(0);
806 switch (text2)
807 {
808 case "buff":
809 if (CC.HasCondition(text))
810 {
811 continue;
812 }
813 card = CC;
814 break;
815 case "debuff":
816 case "attack":
817 case "dot":
818 card = TC;
819 break;
820 }
821 if (subAttack)
822 {
823 if (card == CC)
824 {
825 continue;
826 }
827 switch (text2)
828 {
829 case "attackArea":
830 case "summon":
831 case "teleport":
832 case "suicide":
833 continue;
834 }
835 }
836 if (card.IsAliveInCurrentZone)
837 {
838 Card tC = TC;
839 ActEffect.ProcAt(item2.source.proc[0].ToEnum<EffectId>(), power, BlessedState.Normal, CC, card, card.pos, isNeg: false, new ActRef
840 {
841 n1 = text,
842 aliasEle = item2.source.aliasRef,
843 noFriendlyFire = true
844 });
845 TC = tC;
846 }
847 }
848 }
849 }
850 }
851 }
852
853 private bool Crit()
854 {
855 crit = true;
856 return true;
857 }
858
859 private bool EvadePlus()
860 {
861 evadePlus = true;
862 return false;
863 }
864
865 public bool CalcHit()
866 {
867 if (critFury)
868 {
869 crit = true;
870 return true;
871 }
872 if (TC != null)
873 {
874 if (TC.HasCondition<ConDim>() && EClass.rnd(4) == 0)
875 {
876 return Crit();
877 }
878 if (TC.IsDeadOrSleeping)
879 {
880 return Crit();
881 }
882 int num = TC.Evalue(151);
883 if (num != 0 && toHit < num * 10)
884 {
885 int num2 = evasion * 100 / Mathf.Clamp(toHit, 1, toHit);
886 if (num2 > 300 && EClass.rnd(num + 250) > 100)
887 {
888 return EvadePlus();
889 }
890 if (num2 > 200 && EClass.rnd(num + 250) > 150)
891 {
892 return EvadePlus();
893 }
894 if (num2 > 150 && EClass.rnd(num + 250) > 200)
895 {
896 return EvadePlus();
897 }
898 }
899 if (TC.Evalue(57) > EClass.rnd(100))
900 {
901 return EvadePlus();
902 }
903 }
904 if (EClass.rnd(20) == 0)
905 {
906 return true;
907 }
908 if (EClass.rnd(20) == 0)
909 {
910 return false;
911 }
912 if (toHit < 1)
913 {
914 return false;
915 }
916 if (evasion < 1)
917 {
918 return true;
919 }
920 if (EClass.rnd(toHit) < EClass.rnd(evasion * (IsRanged ? 150 : 125) / 100))
921 {
922 return false;
923 }
924 if (EClass.rnd(5000) < CC.Evalue(73) + 50)
925 {
926 return Crit();
927 }
928 if ((float)(CC.Evalue(90) + ((weapon != null) ? weapon.Evalue(90, ignoreGlobalElement: true) : 0)) + Mathf.Sqrt(CC.Evalue(134)) > (float)EClass.rnd(200))
929 {
930 return Crit();
931 }
932 if (CC.Evalue(1420) > 0)
933 {
934 int num3 = Mathf.Min(100, 100 - CC.hp * 100 / CC.MaxHP);
935 if (num3 >= 50 && num3 * num3 * num3 * num3 / 3 > EClass.rnd(100000000))
936 {
937 return Crit();
938 }
939 }
940 return true;
941 }
942
943 public string GetAttackText(AttackType type, int id)
944 {
945 return Lang.GetList("attack" + type)[id];
946 }
947}
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:392
Definition: ACT.cs:62
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 AttackProcess Current
Definition: AttackProcess.cs:8
int GetRawDamage(float dmgMulti, bool crit, bool maxRoll)
string GetText()
bool ignoreAttackSound
int numFireWithoutDamageLoss
bool IsMartialWeapon
Point posRangedAnime
Element weaponSkill
AttackStyle attackStyle
void PlayRangedAnime(int numFire)
void Mod(int a, bool force=false)
SourceElement.Row sourceElement
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:2191
int EvalueMax(int ele, int min=0)
Definition: Card.cs:2445
ElementContainerCard elements
Definition: Card.cs:37
string id
Definition: Card.cs:31
int ChildrenWeight
Definition: Card.cs:1889
bool HasElement(int ele, int req=1)
Definition: Card.cs:5214
bool isRestrained
Definition: Card.cs:538
virtual int Power
Definition: Card.cs:2155
SourceMaterial.Row material
Definition: Card.cs:1927
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
int HIT
Definition: Card.cs:2189
bool isCopy
Definition: Card.cs:850
Thing ammoData
Definition: Card.cs:1685
int hp
Definition: Card.cs:226
int WIL
Definition: Card.cs:2203
int STR
Definition: Card.cs:2193
bool HasTag(CTAG tag)
Definition: Card.cs:2455
Point pos
Definition: Card.cs:55
int DEX
Definition: Card.cs:2195
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:5438
Trait trait
Definition: Card.cs:49
int encLV
Definition: Card.cs:310
int c_diceDim
Definition: Card.cs:1313
MoveResult
Definition: Card.cs:13
bool HasEditorTag(EditorTag tag)
Definition: Card.cs:2460
virtual Thing Thing
Definition: Card.cs:1934
int Evalue(int ele)
Definition: Card.cs:2431
void ModExp(string alias, int a)
Definition: Card.cs:2508
SourceCategory.Row category
Definition: Card.cs:1925
CardRenderer renderer
Definition: Card.cs:57
int LV
Definition: Card.cs:370
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
AttackStyle GetAttackStyle()
Definition: CharaBody.cs:427
int GetAttackStyleElement(AttackStyle style)
Definition: CharaBody.cs:460
Definition: Chara.cs:10
override bool IsAliveInCurrentZone
Definition: Chara.cs:546
Element MainElement
Definition: Chara.cs:702
CharaBody body
Definition: Chara.cs:91
Faction faction
Definition: Chara.cs:412
override bool IsPC
Definition: Chara.cs:597
Chara host
Definition: Chara.cs:33
override bool IsPCParty
Definition: Chara.cs:600
int EvalueRiding()
Definition: Chara.cs:5526
bool HasCondition(string alias)
Definition: Chara.cs:8568
override bool isSynced
Definition: Chara.cs:676
override bool IsPCFaction
Definition: Chara.cs:656
override int MaxHP
Definition: Chara.cs:693
Zone currentZone
Definition: Chara.cs:240
bool HasHigherGround(Card c)
Definition: Chara.cs:999
Chara parasite
Definition: Chara.cs:30
Chara ride
Definition: Chara.cs:27
bool isBlind
Definition: Chara.cs:125
bool IsHostile()
Definition: Chara.cs:5884
bool isConfused
Definition: Chara.cs:121
SourceRace.Row race
Definition: Chara.cs:449
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:55
static int rnd(int a)
Definition: EClass.cs:50
static Core core
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:20
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 ValueWithoutLink(int ele)
Element GetOrCreateElement(Element ele)
int id
Definition: ELEMENT.cs:240
SourceElement.Row source
Definition: ELEMENT.cs:263
int Value
Definition: ELEMENT.cs:282
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:913
static Element Void
Definition: ELEMENT.cs:228
Element GetParent(Card c)
Definition: ELEMENT.cs:512
ElementContainerFaction charaElements
Definition: FACTION.cs:144
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:524
Point Copy()
Definition: Point.cs:467
ref Vector3 PositionCenter()
Definition: Point.cs:563
int Distance(Point p)
Definition: Point.cs:953
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:62
int Penetration
Definition: Thing.cs:34
virtual Element WeaponSkill
Card owner
Definition: Trait.cs:26
bool TryGetValue(TKey key, out TValue value)
Definition: UDictionary.cs:178
Definition: Zone.cs:12
Definition: ActRef.cs:2