Exemple #1
0
    // Damage, Damage Type and Resistance Calculators
    #region
    public int GetBaseDamageValue(LivingEntity entity, int baseDamage, Ability abilityUsed, string attackDamageType, ItemDataSO weaponUsed = null)
    {
        Debug.Log("CombatLogic.GetBaseDamageValue() called...");
        int baseDamageValueReturned = 0;

        // Add damage from weapon, if the weapon is being used for the attack
        if (weaponUsed != null)
        {
            baseDamageValueReturned += weaponUsed.baseDamage;
            Debug.Log(weaponUsed.Name + " base damage is: " + weaponUsed.baseDamage.ToString());
        }
        else
        {
            baseDamageValueReturned += baseDamage;
            Debug.Log("Weapon not used, base damage from ability/effect is: " + baseDamageValueReturned.ToString());
        }

        // Add flat damage bonus from modifiers (strength, etc)
        if (abilityUsed != null &&
            abilityUsed.abilityType == AbilityDataSO.AbilityType.MeleeAttack)
        {
            baseDamageValueReturned += EntityLogic.GetTotalStrength(entity);
            Debug.Log("Base damage after strength and related modifiers added: " + baseDamageValueReturned.ToString());
        }

        // Add damage from damage type modifiers that effect spell damage (wisdom, shadowform etc)
        if (attackDamageType == "Fire" || attackDamageType == "Shadow" || attackDamageType == "Air" || attackDamageType == "Frost" || attackDamageType == "Poison")
        {
            baseDamageValueReturned += EntityLogic.GetTotalWisdom(entity);
            Debug.Log("Base damage after wisdom added: " + baseDamageValueReturned.ToString());
        }

        // multiply by ability damage multiplier if ability uses a weapon
        if (abilityUsed != null &&
            (abilityUsed.requiresMeleeWeapon || abilityUsed.requiresRangedWeapon))
        {
            baseDamageValueReturned = (int)(baseDamageValueReturned * abilityUsed.weaponDamagePercentage);
            Debug.Log("Base damage after ability percentage modifer " + baseDamageValueReturned.ToString());
        }

        // return final value
        Debug.Log("Final base damage value of attack returned: " + baseDamageValueReturned.ToString());
        return(baseDamageValueReturned);
    }