Esempio n. 1
0
    public int GetDamageValueAfterResistances(int damageValue, string attackDamageType, LivingEntity target)
    {
        // Debug
        Debug.Log("CombatLogic.GetDamageValueAfterResistances() called...");
        Debug.Log("Damage Type received as argument: " + attackDamageType);

        // Setup
        int   damageValueReturned  = damageValue;
        int   targetResistance     = 0;
        float resistanceMultiplier = 0;

        // Get total resistance
        targetResistance = EntityLogic.GetTotalResistance(target, attackDamageType);

        // Debug
        Debug.Log("Target has " + targetResistance + " total " + attackDamageType + " Resistance...");

        // Invert the resistance value from 100. (as in, 80% fire resistance means the attack will deal 20% of it original damage
        int invertedResistanceValue = 100 - targetResistance;

        Debug.Log("Resitance value after inversion: " + invertedResistanceValue.ToString());

        // Convert target resistance to float to multiply against base damage value
        resistanceMultiplier = (float)invertedResistanceValue / 100;
        Debug.Log("Resitance multiplier as float value: " + resistanceMultiplier.ToString());

        // Apply final resistance calculations to the value returned
        damageValueReturned = (int)(damageValueReturned * resistanceMultiplier);

        Debug.Log("Final damage value calculated: " + damageValueReturned.ToString());

        return(damageValueReturned);
    }