Untitled
unknown
plain_text
3 years ago
1.9 kB
6
Indexable
public void CalcAttack(CharacterComponent cc, Weapon weapon, Vector3 attackPosition, ITargetable t) { Reset(); target = t; var weaponProto = weapon.Prototype; var mainTargetAsCC = target as CharacterComponent; int pLuck = cc.Character.Stats.Luck; int eLuck = mainTargetAsCC.Character.Stats.Luck; int luck = pLuck - eLuck; int dpe = weaponProto.DamagePierce; int ape = mainTargetAsCC.AntiPierce; int dt = mainTargetAsCC.DamageThreshold; int pierce = dpe - ape; bool ignoreArmor = false; int shieldBlock = 0; if (pierce > 0) { int ignoreArmorDice = GetDice(1, 100 - luck); if (ignoreArmorDice <= pierce) { ignoreArmor = true; } } int meleeDamage = cc.Character.Stats.MeleeDamage; int finalDamage = meleeDamage + weaponProto.DamageMin + GetDice1DMax(weaponProto.DamageMax - weaponProto.DamageMin, 100 - luck); if(!ignoreArmor) { finalDamage = Math.Max(0, finalDamage - dt); } if (mainTargetAsCC.Character.HasShield()) { int shieldBlockChanceDice = GetDice(1, 100 - luck); if (shieldBlockChanceDice <= mainTargetAsCC.ShieldBlockChance) { shieldBlock = mainTargetAsCC.ShieldBlockDamageTreshold; finalDamage = Math.Max(0, finalDamage - shieldBlock); } } var a = new Attack(); a.bulletID = 0; a.status = AttackStatus.Hit; a.result = new AttackResult(weaponProto.Single.AP, finalDamage, attackPosition, 0, false, 0, WeaponProto.DamageTypeParam.Normal, ignoreArmor, shieldBlock, 0, 0, 0, 0); attacks.Add(a); }
Editor is loading...