Example #1
0
    // Calculate Crit, Parry, Dodge, Block Gain
    #region
    private int CalculateCriticalStrikeChance(LivingEntity attacker, LivingEntity target, Ability ability)
    {
        Debug.Log("CombatLogic.CalculateCriticalChance() called...");

        int critChanceReturned = 0;

        critChanceReturned += EntityLogic.GetTotalCriticalChance(attacker, ability);

        // Check for 'Shatter' passive
        if (attacker.myPassiveManager.shatter &&
            target.myPassiveManager.chilled &&
            ability.abilityType == AbilityDataSO.AbilityType.MeleeAttack)
        {
            critChanceReturned += 50;
            Debug.Log("Crit chance after 'Shatter' passive bonus" + critChanceReturned.ToString());
        }

        // Cap Crit Chance at 80%
        if (critChanceReturned > 80)
        {
            Debug.Log("Crit chance excedding crit cap of 80%, reducing to 80%...");
            critChanceReturned = 80;
        }

        // Check for sharpen blade
        if (attacker.myPassiveManager.sharpenedBlade && ability.abilityType == AbilityDataSO.AbilityType.MeleeAttack)
        {
            Debug.Log(attacker.name + " has 'Sharpened Blade' passive, increasing Crit chance to 100%...");
            critChanceReturned = 100;
        }

        Debug.Log("Final crit chance value returned: " + critChanceReturned.ToString());
        return(critChanceReturned);
    }