Elin Modding Docs Doc
Loading...
Searching...
No Matches
AttackProcess.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.CompilerServices;
5using UnityEngine;
6
7// Token: 0x020001BC RID: 444
8public class AttackProcess : EClass
9{
10 // Token: 0x1700032C RID: 812
11 // (get) Token: 0x06000CCC RID: 3276 RVA: 0x00062FF8 File Offset: 0x000611F8
12 public bool IsMartial
13 {
14 get
15 {
16 return this.weapon == null;
17 }
18 }
19
20 // Token: 0x1700032D RID: 813
21 // (get) Token: 0x06000CCD RID: 3277 RVA: 0x00063003 File Offset: 0x00061203
22 public bool IsMartialWeapon
23 {
24 get
25 {
26 return this.weapon != null && this.weapon.category.skill == 100;
27 }
28 }
29
30 // Token: 0x1700032E RID: 814
31 // (get) Token: 0x06000CCE RID: 3278 RVA: 0x00063023 File Offset: 0x00061223
32 public bool IsRanged
33 {
34 get
35 {
36 return this.toolRange != null && !this.isThrow && !this.toolRange.owner.Thing.isEquipped;
37 }
38 }
39
40 // Token: 0x1700032F RID: 815
41 // (get) Token: 0x06000CCF RID: 3279 RVA: 0x0006304F File Offset: 0x0006124F
42 public bool IsCane
43 {
44 get
45 {
46 return this.IsRanged && this.toolRange is TraitToolRangeCane;
47 }
48 }
49
50 // Token: 0x06000CD0 RID: 3280 RVA: 0x0006306C File Offset: 0x0006126C
51 public string GetText()
52 {
53 string text = this.dNum.ToString() + "d" + this.dDim.ToString();
54 text = text + ((this.dBonus >= 0) ? "+" : "") + this.dBonus.ToString();
55 string @ref = this.IsMartial ? "evalHand".lang() : "evalWeapon".lang((this.attackIndex + 1).ToString() ?? "", null, null, null, null);
56 return "attackEval".lang(@ref, text, this.dMulti.ToString("F2") ?? "", this.toHit.ToString() ?? "", this.penetration.ToString() ?? "");
57 }
58
59 // Token: 0x06000CD1 RID: 3281 RVA: 0x0006314C File Offset: 0x0006134C
60 public void Prepare(Chara _CC, Thing _weapon, Card _TC = null, Point _TP = null, int _attackIndex = 0, bool _isThrow = false)
61 {
62 this.CC = _CC;
63 this.TC = _TC;
64 this.TP = _TP;
65 this.isThrow = _isThrow;
66 this.weapon = _weapon;
67 this.ammo = ((_weapon == null) ? null : _weapon.ammoData);
68 this.hit = (this.crit = (this.evadePlus = false));
69 Thing thing = this.weapon;
70 this.toolRange = (((thing != null) ? thing.trait : null) as TraitToolRange);
71 this.attackType = AttackType.Slash;
72 this.attackStyle = AttackStyle.Default;
73 this.evasion = 0;
74 this.penetration = 0;
75 this.distMod = 100;
76 this.attackIndex = _attackIndex;
77 this.posRangedAnime = this.TP;
78 this.ignoreAnime = (this.ignoreAttackSound = false);
79 if (!this.isThrow)
80 {
81 if (!this.IsRanged)
82 {
83 this.attackStyle = this.CC.body.GetAttackStyle();
84 }
85 else if (this.TP != null)
86 {
87 int num = this.CC.pos.Distance(this.TP);
88 this.distMod = Mathf.Max(115 - 10 * Mathf.Abs(num - this.toolRange.BestDist) * 100 / (100 + this.weapon.Evalue(605) * 10), 80);
89 }
90 }
91 if (this.isThrow)
92 {
93 bool flag = this.weapon.HasTag(CTAG.throwWeapon) || this.weapon.HasTag(CTAG.throwWeaponEnemy);
94 int num2 = (int)Mathf.Clamp(Mathf.Sqrt((float)(this.weapon.SelfWeight + this.weapon.ChildrenWeight)) * 3f + 25f + (float)(flag ? 75 : 0), 10f, 400f + Mathf.Sqrt((float)this.CC.STR) * 50f);
95 int num3 = Mathf.Clamp(this.weapon.material.hardness, flag ? 40 : 20, 200);
96 this.weaponSkill = this.CC.elements.GetOrCreateElement(108);
97 this.attackType = AttackType.Blunt;
98 this.dBonus = (this.CC.IsPCParty ? 3 : 7);
99 this.dNum = 2;
100 this.dDim = ((this.CC.IsPCParty ? 0 : this.CC.LV) + this.CC.STR + this.CC.Evalue(108)) * num2 * num3 / 10000 / 2;
101 this.dMulti = 1f;
102 this.toHitBase = EClass.curve(this.CC.DEX / 4 + this.CC.STR / 2 + this.weaponSkill.Value, 50, 25, 75) + (this.CC.IsPC ? 75 : 250);
103 this.toHitFix = this.CC.HIT + this.weapon.HIT;
104 this.penetration = 25;
105 }
106 else if (this.IsMartial || this.IsMartialWeapon)
107 {
108 this.weaponSkill = this.CC.elements.GetOrCreateElement(100);
109 this.attackType = (this.CC.race.meleeStyle.IsEmpty() ? ((EClass.rnd(2) == 0) ? AttackType.Kick : AttackType.Punch) : this.CC.race.meleeStyle.ToEnum(true));
110 this.dBonus = this.CC.DMG + this.CC.encLV + (int)Mathf.Sqrt((float)(this.CC.STR / 5 + this.weaponSkill.Value / 4));
111 this.dNum = 2 + Mathf.Min(this.weaponSkill.Value / 10, 4);
112 this.dDim = 5 + (int)Mathf.Sqrt((float)(this.weaponSkill.Value / 3));
113 this.dMulti = 0.6f + (float)(this.CC.STR / 2 + this.weaponSkill.Value / 2 + this.CC.Evalue(132) / 2) / 50f;
114 this.dMulti += 0.05f * (float)this.CC.Evalue(1400);
115 this.toHitBase = EClass.curve(this.CC.DEX / 3 + this.CC.STR / 3 + this.weaponSkill.Value, 50, 25, 75) + 50;
116 this.toHitFix = this.CC.HIT;
117 if (this.attackStyle == AttackStyle.Shield)
118 {
119 this.toHitBase = this.toHitBase * 75 / 100;
120 }
121 this.penetration = Mathf.Clamp(this.weaponSkill.Value / 10 + 5, 5, 20) + this.CC.Evalue(92);
122 if (this.IsMartialWeapon)
123 {
124 this.dBonus += this.weapon.DMG;
125 this.dNum += this.weapon.source.offense[0];
126 this.dDim = Mathf.Max(this.dDim / 2 + this.weapon.c_diceDim, 1);
127 this.toHitFix += this.weapon.HIT;
128 this.penetration += this.weapon.Penetration;
129 if (!this.weapon.source.attackType.IsEmpty())
130 {
131 this.attackType = this.weapon.source.attackType.ToEnum(true);
132 }
133 }
134 }
135 else
136 {
137 if (this.IsRanged)
138 {
139 this.weaponSkill = this.CC.elements.GetOrCreateElement(this.toolRange.WeaponSkill);
140 }
141 else
142 {
143 this.weaponSkill = this.CC.elements.GetOrCreateElement(this.weapon.category.skill);
144 }
145 if (!this.weapon.source.attackType.IsEmpty())
146 {
147 this.attackType = this.weapon.source.attackType.ToEnum(true);
148 }
149 bool flag2 = this.IsCane || this.weapon.Evalue(482) > 0;
150 if (flag2)
151 {
152 this.weaponSkill = this.CC.elements.GetOrCreateElement(305);
153 }
154 this.dBonus = this.CC.DMG + this.CC.encLV + this.weapon.DMG;
155 this.dNum = this.weapon.source.offense[0];
156 this.dDim = this.weapon.c_diceDim;
157 this.dMulti = 0.6f + (float)(this.weaponSkill.GetParent(this.CC).Value + this.weaponSkill.Value / 2 + this.CC.Evalue(flag2 ? 304 : (this.IsRanged ? 133 : 132))) / 50f;
158 this.dMulti += 0.05f * (float)this.CC.Evalue(this.IsRanged ? 1404 : 1400);
159 this.toHitBase = EClass.curve((this.IsCane ? this.CC.WIL : this.CC.DEX) / 4 + this.weaponSkill.GetParent(this.CC).Value / 3 + this.weaponSkill.Value, 50, 25, 75) + 50;
160 this.toHitFix = this.CC.HIT + this.weapon.HIT;
161 this.penetration = this.weapon.Penetration + this.CC.Evalue(92);
162 if (this.IsCane)
163 {
164 this.toHitBase += 50;
165 }
166 }
167 if (this.ammo != null)
168 {
169 this.dNumAmmo = ((this.ammo.source.offense.Length != 0) ? this.ammo.source.offense[0] : 0);
170 this.dDimAmmo = this.ammo.c_diceDim;
171 this.dBonusAmmo = this.ammo.DMG;
172 if (this.dNumAmmo < 1)
173 {
174 this.dNumAmmo = 1;
175 }
176 if (this.dDimAmmo < 1)
177 {
178 this.dDimAmmo = 1;
179 }
180 this.dBonus += this.ammo.DMG;
181 this.toHitFix += this.ammo.HIT;
182 }
183 else
184 {
185 this.dNumAmmo = 0;
186 this.dDimAmmo = 0;
187 }
188 if (this.dNum < 1)
189 {
190 this.dNum = 1;
191 }
192 if (this.dDim < 1)
193 {
194 this.dDim = 1;
195 }
196 if (this.penetration > 100)
197 {
198 this.penetration = 100;
199 }
200 if (this.attackStyle == AttackStyle.TwoHand)
201 {
202 this.dMulti = this.dMulti * 1.5f + 0.1f * Mathf.Sqrt((float)this.CC.Evalue(130));
203 }
204 this.dMulti = this.dMulti * (float)this.distMod / 100f;
205 this.toHit = this.toHitBase + this.toHitFix;
206 this.toHit = this.toHit * this.distMod / 100;
207 if (this.CC.HasCondition<ConBane>())
208 {
209 this.toHit = this.toHit * 75 / 100;
210 }
211 if (this.TC != null && this.CC.HasHigherGround(this.TC))
212 {
213 this.toHit = this.toHit * 120 / 100;
214 }
215 if (this.CC.ride != null)
216 {
217 this.toHit = this.toHit * 100 / (100 + 500 / Mathf.Max(5, 10 + this.CC.EvalueRiding()));
218 }
219 if (this.CC.parasite != null)
220 {
221 this.toHit = this.toHit * 100 / (100 + 1000 / Mathf.Max(5, 10 + this.CC.Evalue(227)));
222 }
223 if (this.CC.host != null)
224 {
225 if (this.CC.host.ride == this.CC)
226 {
227 this.toHit = this.toHit * 100 / (100 + 1000 / Mathf.Max(5, 10 + this.CC.STR));
228 }
229 if (this.CC.host.parasite == this.CC)
230 {
231 this.toHit = this.toHit * 100 / (100 + 2000 / Mathf.Max(5, 10 + this.CC.DEX));
232 }
233 }
234 if (this.attackStyle == AttackStyle.TwoHand)
235 {
236 this.toHit += 25 + (int)Mathf.Sqrt((float)(this.CC.Evalue(130) * 2));
237 }
238 else if (this.attackStyle == AttackStyle.TwoWield && this.toHit > 0)
239 {
240 this.toHit = this.toHit * 100 / (115 + this.attackIndex * 15 + this.attackIndex * Mathf.Clamp(2000 / (20 + this.CC.Evalue(131)), 0, 100));
241 }
242 if (this.CC.isBlind)
243 {
244 this.toHit /= ((this.IsRanged || this.isThrow) ? 10 : 3);
245 }
246 if (this.CC.isConfused || this.CC.HasCondition<ConDim>())
247 {
248 this.toHit /= 2;
249 }
250 if (this.TC == null)
251 {
252 return;
253 }
254 this.evasion = EClass.curve(this.TC.PER / 3 + this.TC.Evalue(150), 50, 10, 75) + this.TC.DV + 25;
255 if (this.TC.isChara && this.TC.Chara.isBlind)
256 {
257 this.evasion /= 2;
258 }
259 if (this.TC.HasCondition<ConDim>())
260 {
261 this.evasion /= 2;
262 }
263 if (this.TC.isChara && this.TC.Chara.HasHigherGround(this.CC))
264 {
265 this.evasion = this.evasion * 120 / 100;
266 }
267 }
268
269 // Token: 0x06000CD2 RID: 3282 RVA: 0x00063DBC File Offset: 0x00061FBC
270 public unsafe void PlayRangedAnime(int numFire)
271 {
272 AttackProcess.<>c__DisplayClass43_0 CS$<>8__locals1 = new AttackProcess.<>c__DisplayClass43_0();
273 CS$<>8__locals1.<>4__this = this;
274 CS$<>8__locals1.isGun = (this.toolRange is TraitToolRangeGun);
275 CS$<>8__locals1.isCane = (this.toolRange is TraitToolRangeCane);
276 AttackProcess.<>c__DisplayClass43_0 CS$<>8__locals2 = CS$<>8__locals1;
278 if ((data = EClass.setting.effect.guns.TryGetValue(this.weapon.id, null)) == null)
279 {
280 data = EClass.setting.effect.guns[CS$<>8__locals1.isCane ? "cane" : (CS$<>8__locals1.isGun ? "gun" : "bow")];
281 }
282 CS$<>8__locals2.data = data;
283 CS$<>8__locals1.isPCC = (this.CC.IsPCC && this.CC.renderer.hasActor);
284 CS$<>8__locals1.firePos = (CS$<>8__locals1.isPCC ? new Vector2(CS$<>8__locals1.data.firePos.x * (float)((this.CC.renderer.actor.currentDir == 0 || this.CC.renderer.actor.currentDir == 1) ? -1 : 1), CS$<>8__locals1.data.firePos.y) : Vector2.zero);
285 CS$<>8__locals1._CC = this.CC;
286 CS$<>8__locals1._TP = this.posRangedAnime.Copy();
287 CS$<>8__locals1._weapon = this.weapon;
288 CS$<>8__locals1.ignoreSound = this.ignoreAttackSound;
289 for (int i = 0; i < numFire; i++)
290 {
291 float delay = (float)i * CS$<>8__locals1.data.delay;
292 Action action;
293 if ((action = CS$<>8__locals1.<>9__0) == null)
294 {
295 action = (CS$<>8__locals1.<>9__0 = delegate()
296 {
297 if (!EClass.core.IsGameStarted || !CS$<>8__locals1._CC.IsAliveInCurrentZone)
298 {
299 return;
300 }
301 if (CS$<>8__locals1._weapon.id == "gun_rail")
302 {
303 CS$<>8__locals1._CC.PlayEffect("laser", true, 0f, default(Vector3)).GetComponent<SpriteBasedLaser>().Play(*CS$<>8__locals1._TP.PositionCenter());
304 }
305 else
306 {
307 Effect effect = Effect.Get("ranged_arrow")._Play(CS$<>8__locals1._CC.pos, CS$<>8__locals1._CC.isSynced ? CS$<>8__locals1._CC.renderer.position : (*CS$<>8__locals1._CC.pos.Position()), 0f, CS$<>8__locals1._TP, CS$<>8__locals1.data.sprite);
308 if (CS$<>8__locals1.isCane)
309 {
310 IEnumerable<Element> enumerable = from e in CS$<>8__locals1.<>4__this.toolRange.owner.elements.dict.Values
311 where e.source.categorySub == "eleAttack"
312 select e;
313 if (enumerable.Count<Element>() > 0)
314 {
315 Element element = enumerable.RandomItem<Element>();
316 effect.sr.color = EClass.Colors.elementColors[element.source.alias];
317 }
318 }
319 }
320 if (CS$<>8__locals1.data.eject)
321 {
322 if (!CS$<>8__locals1.ignoreSound)
323 {
324 CS$<>8__locals1._CC.PlaySound("bullet_drop", 1f, true);
325 }
326 CS$<>8__locals1._CC.PlayEffect("bullet", true, 0f, default(Vector3)).Emit(1);
327 }
328 if (CS$<>8__locals1.isGun)
329 {
330 if (CS$<>8__locals1.isPCC)
331 {
332 CS$<>8__locals1._weapon.PlayEffect(CS$<>8__locals1.data.idEffect.IsEmpty("gunfire"), true, 0f, CS$<>8__locals1.firePos);
333 }
334 else
335 {
336 CS$<>8__locals1._CC.PlayEffect(CS$<>8__locals1.data.idEffect.IsEmpty("gunfire"), true, 0f, default(Vector3));
337 }
338 }
339 if (!CS$<>8__locals1.ignoreSound)
340 {
341 CS$<>8__locals1._CC.PlaySound(CS$<>8__locals1.data.idSound.IsEmpty("attack_gun"), 1f, true);
342 }
343 });
344 }
345 TweenUtil.Delay(delay, action);
346 }
347 }
348
349 // Token: 0x06000CD3 RID: 3283 RVA: 0x00063F68 File Offset: 0x00062168
350 public bool Perform(int count, bool hasHit, float dmgMulti = 1f, bool maxRoll = false)
351 {
352 bool flag = this.CC.HasCondition<ConReload>();
353 this.hit = this.CalcHit();
354 int num = Dice.Roll(this.dNum, this.dDim, this.dBonus, this.CC);
355 if (this.ammo != null && !flag)
356 {
357 num += Dice.Roll(this.dNumAmmo, this.dDimAmmo, this.dBonusAmmo, this.CC);
358 }
359 if (this.crit || maxRoll)
360 {
361 num = Dice.RollMax(this.dNum, this.dDim, this.dBonus);
362 if (this.ammo != null && !flag)
363 {
364 num += Dice.RollMax(this.dNumAmmo, this.dDimAmmo, 0);
365 }
366 if (this.crit && (this.IsMartial || this.IsMartialWeapon))
367 {
368 this.dMulti *= 1.25f;
369 }
370 }
371 if (this.CC.Evalue(1355) > 0)
372 {
373 ConStrife condition = this.CC.GetCondition<ConStrife>();
374 if (condition != null)
375 {
376 num += condition.GetDice().Roll();
377 }
378 else
379 {
380 num++;
381 }
382 }
383 num = (int)(this.dMulti * (float)num * dmgMulti);
384 if (this.IsRanged && count >= this.numFireWithoutDamageLoss)
385 {
386 num = num * 100 / (100 + (count - this.numFireWithoutDamageLoss + 1) * 30);
387 }
388 if (this.CC.isRestrained)
389 {
390 num /= 2;
391 }
392 List<Element> list = new List<Element>();
393 int num2 = this.CC.Evalue(91);
394 int num3 = 0;
395 if (this.weapon != null)
396 {
397 list = this.weapon.elements.dict.Values.ToList<Element>();
398 if (this.ammo != null && !flag)
399 {
400 list = list.Concat(this.ammo.elements.dict.Values).ToList<Element>();
401 }
402 if (this.IsRanged || this.isThrow)
403 {
404 num2 += this.weapon.Evalue(91);
405 }
406 num3 += this.weapon.Evalue(603);
407 }
408 else if (this.CC.id == "rabbit_vopal")
409 {
410 list.Add(Element.Create(6650, 100));
411 }
412 Card tc = this.TC;
413 if (((tc != null) ? tc.Chara : null) != null)
414 {
415 SourceRace.Row race = this.TC.Chara.race;
416 AttackProcess.<>c__DisplayClass44_0 CS$<>8__locals1;
417 CS$<>8__locals1.bane = this.CC.Evalue(468);
418 this.<Perform>g__AddBane|44_5(race.IsUndead, 461, ref CS$<>8__locals1);
419 this.<Perform>g__AddBane|44_5(race.IsAnimal, 463, ref CS$<>8__locals1);
420 this.<Perform>g__AddBane|44_5(race.IsHuman, 464, ref CS$<>8__locals1);
421 this.<Perform>g__AddBane|44_5(race.IsDragon, 460, ref CS$<>8__locals1);
422 this.<Perform>g__AddBane|44_5(race.IsGod, 466, ref CS$<>8__locals1);
423 this.<Perform>g__AddBane|44_5(race.IsMachine, 465, ref CS$<>8__locals1);
424 this.<Perform>g__AddBane|44_5(race.IsFish, 467, ref CS$<>8__locals1);
425 this.<Perform>g__AddBane|44_5(race.IsFairy, 462, ref CS$<>8__locals1);
426 if (CS$<>8__locals1.bane != 0)
427 {
428 num = num * (100 + CS$<>8__locals1.bane * 3) / 100;
429 }
430 }
431 if (this.CC.IsPCFaction)
432 {
433 foreach (Element item in EClass.pc.faction.charaElements.dict.Values)
434 {
435 list.Add(item);
436 }
437 }
438 if (this.hit && num2 > EClass.rnd(100))
439 {
440 this.CC.Say("vopal", null, null);
441 this.penetration = 100;
442 }
443 if (this.crit && this.CC.IsPC)
444 {
445 this.CC.Say("critical", null, null);
446 this.CC.PlaySound("critical", 1f, true);
447 }
448 if (this.CC.isSynced || (this.TC != null && this.TC.isSynced))
449 {
450 if (this.toolRange != null && (!this.IsRanged || count == 0) && !flag && !this.ignoreAnime)
451 {
452 this.PlayRangedAnime(this.IsRanged ? this.numFire : 1);
453 }
454 if (this.hit && this.TC != null && !hasHit)
455 {
456 this.<Perform>g__PlayHitEffect|44_4();
457 }
458 }
459 if (this.TC == null)
460 {
461 this.CC.Say(this.IsRanged ? "attack_air_range" : "attack_air", this.CC, null, null);
462 return true;
463 }
464 if (!this.hit)
465 {
466 if (this.TC != null)
467 {
468 if (this.CC.IsPCParty)
469 {
470 this.CC.Say(this.evadePlus ? "evadePlus2" : "evade2", this.CC, this.TC, null, null);
471 }
472 else
473 {
474 this.TC.Say(this.evadePlus ? "evadePlus" : "evade", this.TC, this.CC, null, null);
475 }
476 this.<Perform>g__ModExpDef|44_2(150, 90);
477 this.<Perform>g__ModExpDef|44_2(151, 90);
478 }
479 this.<Perform>g__Proc|44_0(list);
480 return false;
481 }
482 if (this.TC.IsPC)
483 {
484 Msg.SetColor("attack_pc");
485 EClass.pc.Say("attackMeleeToPC", this.CC, this.TC, this.GetAttackText(this.attackType, 3), null);
486 }
487 else
488 {
489 this.CC.Say("attackMelee", this.CC, this.TC, this.GetAttackText(this.attackType, 0), null);
490 }
491 bool showEffect = true;
492 int num4 = 0;
493 int num5 = 0;
494 int num6 = 0;
495 ConWeapon conWeapon = null;
496 if (this.weapon != null)
497 {
498 foreach (Element element in this.weapon.elements.dict.Values)
499 {
500 if (element.source.categorySub == "eleConvert")
501 {
502 num4 = EClass.sources.elements.alias[element.source.aliasRef].id;
503 num5 = 50 + element.Value * 2;
504 num6 = Mathf.Min(element.Value, 100);
505 break;
506 }
507 }
508 }
509 if (num4 == 0)
510 {
511 if (this.CC.HasCondition<ConWeapon>())
512 {
513 conWeapon = this.CC.GetCondition<ConWeapon>();
514 num4 = conWeapon.sourceElement.id;
515 num5 = conWeapon.power / 2;
516 num6 = 40 + (int)Mathf.Min(MathF.Sqrt((float)conWeapon.power), 80f);
517 }
518 if (conWeapon == null && this.weapon == null && (this.CC.MainElement != Element.Void || this.CC.HasElement(1565, 1)))
519 {
520 num4 = (this.CC.HasElement(1565, 1) ? 915 : this.CC.MainElement.id);
521 num5 = this.CC.Power / 3 + EClass.rnd(this.CC.Power / 2);
522 if (this.CC.MainElement != Element.Void)
523 {
524 num5 += this.CC.MainElement.Value;
525 }
526 showEffect = false;
527 num6 = 50;
528 }
529 if (conWeapon == null && this.weapon != null && this.weapon.trait is TraitToolRangeCane)
530 {
531 IEnumerable<Element> enumerable = from e in this.weapon.elements.dict.Values
532 where e.source.categorySub == "eleAttack"
533 select e;
534 if (enumerable.Count<Element>() > 0)
535 {
536 num4 = enumerable.RandomItem<Element>().id;
537 if (num4 != 914)
538 {
539 if (num4 != 918)
540 {
541 if (num4 == 920)
542 {
543 num5 = 30;
544 }
545 else
546 {
547 num5 = 100;
548 }
549 }
550 else
551 {
552 num5 = 50;
553 }
554 }
555 else
556 {
557 num5 = 50;
558 }
559 }
560 num6 = 50;
561 }
562 }
563 int num7 = num;
564 int num8 = num * num6 / 100;
565 num -= num8;
566 int num9 = num * this.penetration / 100;
567 num -= num9;
568 num = this.TC.ApplyProtection(num, 100) + num9 + num8;
569 this.TC.DamageHP(num, num4, num5, (this.IsRanged || this.isThrow) ? AttackSource.Range : AttackSource.Melee, this.CC, showEffect);
570 if (conWeapon != null)
571 {
572 conWeapon.Mod(-1, false);
573 }
574 bool flag2 = this.IsCane || (this.weapon != null && this.weapon.Evalue(482) > 0);
575 int attackStyleElement = this.CC.body.GetAttackStyleElement(this.attackStyle);
576 int mod = 100 / (count + 1);
577 if (!this.IsRanged || count == 0)
578 {
579 this.<Perform>g__ModExpAtk|44_3(this.weaponSkill.id, mod);
580 this.<Perform>g__ModExpAtk|44_3(flag2 ? 304 : (this.IsRanged ? 133 : 132), mod);
581 }
582 if (this.crit)
583 {
584 this.<Perform>g__ModExpAtk|44_3(134, 50);
585 }
586 if (count == 0 && attackStyleElement != 0)
587 {
588 this.<Perform>g__ModExpAtk|44_3(attackStyleElement, 100);
589 }
590 if (!this.CC.IsAliveInCurrentZone || !this.TC.IsAliveInCurrentZone)
591 {
592 return true;
593 }
594 if (EClass.rnd(8) == 0 && this.TC.isChara && this.CC.HasElement(1219, 1))
595 {
596 this.CC.Say("abCrab", this.CC, this.TC, null, null);
597 this.TC.Chara.AddCondition<ConParalyze>(30 + EClass.rnd(30), false);
598 this.TC.Chara.AddCondition<ConGravity>(100, false);
599 }
600 if (list.Count > 0)
601 {
602 foreach (Element element2 in list)
603 {
604 if (!this.TC.IsAliveInCurrentZone)
605 {
606 break;
607 }
608 if (element2.source.categorySub == "eleAttack")
609 {
610 int num10 = 25;
611 int dmg = EClass.rnd(num * (100 + element2.Value * 10) / 500 + 5);
612 if (conWeapon == null && this.weapon != null && this.weapon.trait is TraitToolRangeCane)
613 {
614 num10 = 0;
615 }
616 if (num10 >= EClass.rnd(100))
617 {
618 this.TC.DamageHP(dmg, element2.id, this.isThrow ? (100 + element2.Value * 5) : (30 + element2.Value), AttackSource.WeaponEnchant, this.CC, true);
619 }
620 }
621 }
622 this.<Perform>g__Proc|44_0(list);
623 }
624 if (!this.CC.IsAliveInCurrentZone || !this.TC.IsAliveInCurrentZone)
625 {
626 return true;
627 }
628 if (!this.IsRanged && this.attackStyle == AttackStyle.Shield)
629 {
630 int num11 = this.CC.Evalue(123);
631 if (this.CC.elements.ValueWithoutLink(123) >= 10 && Mathf.Clamp(Mathf.Sqrt((float)num11) - 2f, 8f, 12f) > (float)EClass.rnd(100))
632 {
633 num = num7 * Mathf.Min(50 + num11, 200) / 100;
634 num = this.TC.ApplyProtection(num, 100);
635 Debug.Log("Bash:" + num.ToString() + "/" + num7.ToString());
636 this.CC.PlaySound("shield_bash", 1f, true);
637 this.CC.Say("shield_bash", this.CC, this.TC, null, null);
638 this.TC.DamageHP(num, AttackSource.None, this.CC);
639 if (this.TC.IsAliveInCurrentZone && this.TC.isChara)
640 {
641 if (EClass.rnd(2) == 0)
642 {
643 this.TC.Chara.AddCondition<ConDim>(50 + (int)Mathf.Sqrt((float)num11) * 10, false);
644 }
645 this.TC.Chara.AddCondition<ConParalyze>(EClass.rnd(2), true);
646 }
647 }
648 }
649 if (!this.CC.IsAliveInCurrentZone || !this.TC.IsAliveInCurrentZone)
650 {
651 return true;
652 }
653 if (this.TC.isChara && num3 > 0 && num3 * 2 + 15 > EClass.rnd(100) && !this.TC.isRestrained && this.TC.Chara.TryMoveFrom(this.CC.pos) == Card.MoveResult.Success)
654 {
655 this.TC.pos.PlayEffect("vanish");
656 this.TC.PlaySound("push", 1.5f, true);
657 }
658 return true;
659 }
660
661 // Token: 0x06000CD4 RID: 3284 RVA: 0x00064C4C File Offset: 0x00062E4C
662 private bool Crit()
663 {
664 this.crit = true;
665 return true;
666 }
667
668 // Token: 0x06000CD5 RID: 3285 RVA: 0x00064C56 File Offset: 0x00062E56
669 private bool EvadePlus()
670 {
671 this.evadePlus = true;
672 return false;
673 }
674
675 // Token: 0x06000CD6 RID: 3286 RVA: 0x00064C60 File Offset: 0x00062E60
676 public bool CalcHit()
677 {
678 if (this.TC != null)
679 {
680 if (this.TC.HasCondition<ConDim>() && EClass.rnd(4) == 0)
681 {
682 return this.Crit();
683 }
684 if (this.TC.IsDeadOrSleeping)
685 {
686 return this.Crit();
687 }
688 int num = this.TC.Evalue(151);
689 if (num != 0 && this.toHit < num * 10)
690 {
691 int num2 = this.evasion * 100 / Mathf.Clamp(this.toHit, 1, this.toHit);
692 if (num2 > 300 && EClass.rnd(num + 250) > 100)
693 {
694 return this.EvadePlus();
695 }
696 if (num2 > 200 && EClass.rnd(num + 250) > 150)
697 {
698 return this.EvadePlus();
699 }
700 if (num2 > 150 && EClass.rnd(num + 250) > 200)
701 {
702 return this.EvadePlus();
703 }
704 }
705 if (this.TC.Evalue(57) > EClass.rnd(100))
706 {
707 return this.EvadePlus();
708 }
709 }
710 if (EClass.rnd(20) == 0)
711 {
712 return true;
713 }
714 if (EClass.rnd(20) == 0)
715 {
716 return false;
717 }
718 if (this.toHit < 1)
719 {
720 return false;
721 }
722 if (this.evasion < 1)
723 {
724 return true;
725 }
726 if (EClass.rnd(this.toHit) < EClass.rnd(this.evasion * 3 / 2))
727 {
728 return false;
729 }
730 if (EClass.rnd(5000) < this.CC.Evalue(73) + 50)
731 {
732 return this.Crit();
733 }
734 if ((float)this.CC.Evalue(90) + Mathf.Sqrt((float)this.CC.Evalue(134)) > (float)EClass.rnd(200))
735 {
736 return this.Crit();
737 }
738 if (this.CC.Evalue(1420) > 0)
739 {
740 int num3 = Mathf.Min(100, 100 - this.CC.hp * 100 / this.CC.MaxHP);
741 if (num3 >= 50 && num3 * num3 * num3 * num3 / 3 > EClass.rnd(100000000))
742 {
743 return this.Crit();
744 }
745 }
746 return true;
747 }
748
749 // Token: 0x06000CD7 RID: 3287 RVA: 0x00064E6B File Offset: 0x0006306B
750 public string GetAttackText(AttackType type, int id)
751 {
752 return Lang.GetList("attack" + type.ToString())[id];
753 }
754
755 // Token: 0x06000CDA RID: 3290 RVA: 0x00064EA0 File Offset: 0x000630A0
756 [CompilerGenerated]
757 private void <Perform>g__Proc|44_0(List<Element> list)
758 {
759 if (list == null)
760 {
761 return;
762 }
763 foreach (Element element in list)
764 {
765 if (element is Ability)
766 {
767 int value = element.Value;
768 int power = 100 + element.Value * 10;
769 if (value >= EClass.rnd(100))
770 {
771 Act act = element as Act;
772 Card card = act.TargetType.CanSelectSelf ? this.CC : this.TC;
773 string text = (element.source.proc.Length >= 2) ? element.source.proc[1] : "";
774 if ((!(act.source.abilityType.TryGet(0, -1) == "buff") || !this.CC.HasCondition(text)) && card.IsAliveInCurrentZone)
775 {
776 if (act.TargetType.CanTargetGround)
777 {
778 ActEffect.ProcAt(element.source.proc[0].ToEnum(true), power, BlessedState.Normal, this.CC, card, card.pos, false, new ActRef
779 {
780 n1 = text,
781 aliasEle = element.source.aliasRef,
782 noFriendlyFire = true
783 });
784 }
785 else
786 {
787 ActEffect.ProcAt(element.source.proc[0].ToEnum(true), power, BlessedState.Normal, this.CC, card, this.CC.pos, false, new ActRef
788 {
789 n1 = text,
790 aliasEle = element.source.aliasRef,
791 noFriendlyFire = true
792 });
793 }
794 }
795 }
796 }
797 }
798 }
799
800 // Token: 0x06000CDB RID: 3291 RVA: 0x00065070 File Offset: 0x00063270
801 [CompilerGenerated]
802 private bool <Perform>g__IgnoreExp|44_1()
803 {
804 return this.CC.HasEditorTag(EditorTag.Invulnerable) || this.CC.HasEditorTag(EditorTag.InvulnerableToMobs) || this.TC.HasEditorTag(EditorTag.Invulnerable) || this.TC.HasEditorTag(EditorTag.InvulnerableToMobs);
805 }
806
807 // Token: 0x06000CDC RID: 3292 RVA: 0x000650B0 File Offset: 0x000632B0
808 [CompilerGenerated]
809 private void <Perform>g__ModExpDef|44_2(int ele, int mod)
810 {
811 if (this.<Perform>g__IgnoreExp|44_1())
812 {
813 return;
814 }
815 if (this.CC.isCopy && EClass.rnd(10) != 0)
816 {
817 return;
818 }
819 int num = (Mathf.Clamp((this.CC.LV + 10 - this.TC.elements.ValueWithoutLink(ele)) / 2, 1, 10) + Mathf.Min(this.CC.LV / 10, 10)) * mod / 100;
820 num = Mathf.Min(num, this.TC.isRestrained ? 10 : 200);
821 if (this.TC == this.CC)
822 {
823 num /= 2;
824 }
825 if (!this.TC.IsPC && !this.TC.isRestrained && !this.TC.HasHost)
826 {
827 num *= 3;
828 }
829 if (num > 0)
830 {
831 this.TC.ModExp(ele, num + EClass.rnd(num / 2 + 1));
832 }
833 }
834
835 // Token: 0x06000CDD RID: 3293 RVA: 0x0006519C File Offset: 0x0006339C
836 [CompilerGenerated]
837 private void <Perform>g__ModExpAtk|44_3(int ele, int mod)
838 {
839 if (this.<Perform>g__IgnoreExp|44_1())
840 {
841 return;
842 }
843 if (this.TC.isCopy && EClass.rnd(10) != 0)
844 {
845 return;
846 }
847 int num = (Mathf.Clamp((this.TC.LV + 10 - this.CC.elements.ValueWithoutLink(ele)) / 2, 1, 10) + Mathf.Min(this.TC.LV / 10, 10)) * mod / 100;
848 num = Mathf.Min(num, 200);
849 if (this.TC == this.CC)
850 {
851 num /= 2;
852 }
853 if (num > 0)
854 {
855 this.CC.ModExp(ele, num + EClass.rnd(num / 2 + 1));
856 }
857 }
858
859 // Token: 0x06000CDE RID: 3294 RVA: 0x00065249 File Offset: 0x00063449
860 [CompilerGenerated]
861 private void <Perform>g__AddBane|44_5(bool valid, int idEle, ref AttackProcess.<>c__DisplayClass44_0 A_3)
862 {
863 if (!valid)
864 {
865 return;
866 }
867 A_3.bane += this.CC.Evalue(idEle);
868 }
869
870 // Token: 0x06000CDF RID: 3295 RVA: 0x00065268 File Offset: 0x00063468
871 [CompilerGenerated]
872 private void <Perform>g__PlayHitEffect|44_4()
873 {
874 string id = "hit_default";
875 string id2 = "hit_default";
876 switch (this.attackType)
877 {
878 case AttackType.Slash:
879 id2 = "hit_slash";
880 id = "hit_slash";
881 break;
882 case AttackType.Blunt:
883 case AttackType.Punch:
884 case AttackType.Kick:
885 case AttackType.Bow:
886 case AttackType.Gun:
887 case AttackType.Cane:
888 id2 = "hit_blunt";
889 id = "hit_blunt";
890 break;
891 case AttackType.Claw:
892 case AttackType.Bite:
893 id2 = "hit_claw";
894 id = "hit_claw";
895 break;
896 case AttackType.Spore:
897 id2 = "hit_spore";
898 id = "hit_spore";
899 break;
900 }
901 if (this.TC != null)
902 {
903 this.TC.PlayEffect(id2, true, 0f, default(Vector3)).SetScale(this.crit ? 1.25f : 0.75f);
904 }
905 this.CC.PlaySound(id, 1f, true);
906 }
907
908 // Token: 0x04000CDD RID: 3293
909 public static AttackProcess Current = new AttackProcess();
910
911 // Token: 0x04000CDE RID: 3294
912 public int dNum;
913
914 // Token: 0x04000CDF RID: 3295
915 public int dDim;
916
917 // Token: 0x04000CE0 RID: 3296
918 public int dBonus;
919
920 // Token: 0x04000CE1 RID: 3297
921 public int toHit;
922
923 // Token: 0x04000CE2 RID: 3298
924 public int toHitBase;
925
926 // Token: 0x04000CE3 RID: 3299
927 public int toHitFix;
928
929 // Token: 0x04000CE4 RID: 3300
930 public int evasion;
931
932 // Token: 0x04000CE5 RID: 3301
933 public int penetration;
934
935 // Token: 0x04000CE6 RID: 3302
936 public int distMod;
937
938 // Token: 0x04000CE7 RID: 3303
939 public int attackIndex;
940
941 // Token: 0x04000CE8 RID: 3304
942 public int dNumAmmo;
943
944 // Token: 0x04000CE9 RID: 3305
945 public int dDimAmmo;
946
947 // Token: 0x04000CEA RID: 3306
948 public int dBonusAmmo;
949
950 // Token: 0x04000CEB RID: 3307
951 public int numFire;
952
953 // Token: 0x04000CEC RID: 3308
954 public int numFireWithoutDamageLoss;
955
956 // Token: 0x04000CED RID: 3309
957 public float dMulti;
958
959 // Token: 0x04000CEE RID: 3310
960 public bool crit;
961
962 // Token: 0x04000CEF RID: 3311
963 public bool hit;
964
965 // Token: 0x04000CF0 RID: 3312
966 public bool evadePlus;
967
968 // Token: 0x04000CF1 RID: 3313
969 public bool isThrow;
970
971 // Token: 0x04000CF2 RID: 3314
972 public bool ignoreAnime;
973
974 // Token: 0x04000CF3 RID: 3315
975 public bool ignoreAttackSound;
976
977 // Token: 0x04000CF4 RID: 3316
978 public Chara CC;
979
980 // Token: 0x04000CF5 RID: 3317
981 public Card TC;
982
983 // Token: 0x04000CF6 RID: 3318
984 public Point TP;
985
986 // Token: 0x04000CF7 RID: 3319
987 public Point posRangedAnime;
988
989 // Token: 0x04000CF8 RID: 3320
990 public Element weaponSkill;
991
992 // Token: 0x04000CF9 RID: 3321
993 public Thing weapon;
994
995 // Token: 0x04000CFA RID: 3322
996 public Thing ammo;
997
998 // Token: 0x04000CFB RID: 3323
999 public TraitToolRange toolRange;
1000
1001 // Token: 0x04000CFC RID: 3324
1002 public AttackType attackType;
1003
1004 // Token: 0x04000CFD RID: 3325
1005 public AttackStyle attackStyle;
1006}
Definition Act.2.cs:7
Definition Card.cs:13
Definition Chara.cs:12
Definition Dice.cs:7
Definition Msg.cs:7
Definition Point.cs:11
Definition TC.cs:6
Definition Thing.cs:10