public float damageValue(CarStatus attacker, CarStatus defenser, float weaponModifier) { float atkFactor = attacker.getAttack() * weaponModifier; float defFactor = 1 + 0.01f * (Mathf.Max(defenser.getDefense() - attacker.armorPenetration, 0)); bool isCritical = (Random.value < criticalChance); if (isCritical) { atkFactor *= (1 + criticalDamage);//CRITICAL } return(atkFactor / defFactor); }