//Function called whenever this effect heals the target character
    private void HealCharacter()
    {
        //Making sure the character isn't dead before healing
        if (this.characterToEffect.charPhysState.currentHealth <= 0)
        {
            return;
        }

        //Seeing if this effect will trigger
        float triggerRoll = Random.Range(0, 1);

        if (triggerRoll > this.chanceToTrigger)
        {
            //If we roll over the trigger chance, nothing happens and we don't tick
            return;
        }

        //Finding out how much health we heal this tick
        int damagehealed = Mathf.RoundToInt(Random.Range(this.healPerTickRange.x, this.healPerTickRange.y));

        //Finding out if we crit
        float critRoll    = Random.Range(0, 1);
        bool  didThisCrit = false;

        if (critRoll < this.critChance)
        {
            //If we crit this tick, the amount healed is multiplied
            damagehealed = damagehealed * this.critMultiplier;
            didThisCrit  = true;
        }

        //Looping through the perks of the character that used this ability to see if they have any damage type boost perks
        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            if (charPerk.GetType() == typeof(DamageTypeBoostPerk) && this.healType == charPerk.GetComponent <DamageTypeBoostPerk>().damageTypeToBoost)
            {
                damagehealed += charPerk.GetComponent <DamageTypeBoostPerk>().GetDamageBoostAmount(this.characterWhoTriggered, didThisCrit, true, this.healType);
            }
        }

        //Looping through the defending character's perks to see if they have any spell resist or absorb perks
        SpellResistTypes magicResistType = SpellResistTypes.Normal;

        foreach (Perk defPerk in this.characterToEffect.charPerks.allPerks)
        {
            if (defPerk.GetType() == typeof(SpellResistAbsorbPerk))
            {
                SpellResistAbsorbPerk resistPerk = defPerk.GetComponent <SpellResistAbsorbPerk>();

                //Checking to see if the current heal type is the same as this spell resist perk
                if (resistPerk.typeToResist == this.healType)
                {
                    //Checking to see if the heal is negated entirely
                    if (resistPerk.negateAllDamage)
                    {
                        magicResistType = SpellResistTypes.Negate;
                    }
                    //Otherwise we just get the amount that it normally resists
                    else
                    {
                        damagehealed -= resistPerk.GetSpellResistAmount(this.characterToEffect, didThisCrit, false);
                    }
                }
            }
        }

        //Subtracting any magic resistance from the amount that we're trying to heal
        switch (this.healType)
        {
        case CombatManager.DamageType.Arcane:
            damagehealed -= this.characterToEffect.charInventory.totalArcaneResist;
            break;

        case CombatManager.DamageType.Fire:
            damagehealed -= this.characterToEffect.charInventory.totalFireResist;
            break;

        case CombatManager.DamageType.Water:
            damagehealed -= this.characterToEffect.charInventory.totalWaterResist;
            break;

        case CombatManager.DamageType.Electric:
            damagehealed -= this.characterToEffect.charInventory.totalElectricResist;
            break;

        case CombatManager.DamageType.Wind:
            damagehealed -= this.characterToEffect.charInventory.totalWindResist;
            break;

        case CombatManager.DamageType.Nature:
            damagehealed -= this.characterToEffect.charInventory.totalNatureResist;
            break;

        case CombatManager.DamageType.Holy:
            damagehealed -= this.characterToEffect.charInventory.totalHolyResist;
            break;

        case CombatManager.DamageType.Dark:
            damagehealed -= this.characterToEffect.charInventory.totalDarkResist;
            break;
            //Pure damage type has no resist
        }

        //Looping through the attacking character's perks to see if there's any bonus threat to add to this effect
        int bonusThreat = 0;

        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            //If the perk is a threat boosting perk
            if (charPerk.GetType() == typeof(ThreatBoostPerk))
            {
                ThreatBoostPerk threatPerk = charPerk.GetComponent <ThreatBoostPerk>();

                //If the perk has the same damage type as this HoT or it affects all damage types
                if (threatPerk.damageTypeToThreaten == this.healType || threatPerk.threatenAllDamageTypes)
                {
                    bonusThreat += threatPerk.GetAddedActionThreat(damagehealed, didThisCrit, true);
                }
            }
        }

        //If the heal was negated completely
        if (magicResistType == SpellResistTypes.Negate)
        {
            //Telling the combat manager to display that no damage was healed
            CombatTile healedCharTile = CombatManager.globalReference.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, 0, this.healType, healedCharTile, didThisCrit, true);
        }
        //Otherwise, the heal happens normally
        else
        {
            //Healing the damage to the effected character
            this.characterToEffect.charPhysState.HealCharacter(damagehealed);

            //Telling the combat manager to display the damage healed
            CombatTile healedCharTile = CombatManager.globalReference.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, damagehealed, this.healType, healedCharTile, didThisCrit, true);

            //If the target character and the character who cast this effect are player characters, we need to increase threat
            if (!this.characterToEffect.GetComponent <EnemyCombatAI_Basic>() && !this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
            {
                //Applying threat to all enemies for the amount that's healed
                CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, damagehealed + bonusThreat, true);
            }
        }

        //Creating the visual effect for this effect
        CharacterSpriteBase targetCharSprite = CombatManager.globalReference.GetCharacterSprite(this.characterToEffect);

        this.SpawnVisualAtLocation(targetCharSprite.transform.localPosition, targetCharSprite.transform);

        //If this effect isn't unlimited, we need to reduce the ticks remaining
        if (!this.unlimitedTicks)
        {
            this.ticksLeft -= 1;

            //If there are no more ticks left, this effect is over and the object is destroyed
            if (this.ticksLeft <= 0)
            {
                this.RemoveEffect();
            }
        }
    }
    //Function called whenever this effect deals damage
    private void DamageCharacter()
    {
        //Making sure the character isn't dead before dealing damage
        if (this.characterToEffect == null || this.characterToEffect.charPhysState.currentHealth <= 0)
        {
            return;
        }

        //Seeing if this effect will trigger
        float triggerRoll = Random.Range(0, 1);

        if (triggerRoll > this.chanceToTrigger)
        {
            //If we roll over the trigger chance, nothing happens and we don't tick
            return;
        }

        //Finding out how much damage we deal this tick
        int damageDealt = Mathf.RoundToInt(Random.Range(this.damagePerTickRange.x, this.damagePerTickRange.y));

        //Finding out if we crit
        float critRoll    = Random.Range(0, 1);
        bool  didThisCrit = false;

        if (critRoll < this.critChance)
        {
            //If we crit this tick, the damage is multiplied
            damageDealt = damageDealt * this.critMultiplier;
            didThisCrit = true;
        }

        //Looping through the perks of the character that used this ability to see if they have any damage type boost perks
        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            if (charPerk.GetType() == typeof(DamageTypeBoostPerk) && this.damageType == charPerk.GetComponent <DamageTypeBoostPerk>().damageTypeToBoost)
            {
                damageDealt += charPerk.GetComponent <DamageTypeBoostPerk>().GetDamageBoostAmount(this.characterWhoTriggered, didThisCrit, true, this.damageType);
            }
        }

        //Looping through the defending character's perks to see if they have any spell resist or absorb perks
        SpellResistTypes magicResistType = SpellResistTypes.Normal;

        foreach (Perk defPerk in this.characterToEffect.charPerks.allPerks)
        {
            if (defPerk.GetType() == typeof(SpellResistAbsorbPerk))
            {
                SpellResistAbsorbPerk resistPerk = defPerk.GetComponent <SpellResistAbsorbPerk>();

                //Checking to see if the current damage type is the same as this spell resist perk
                if (resistPerk.typeToResist == this.damageType)
                {
                    //Checking to see if the damage is negated entirely
                    if (resistPerk.negateAllDamage)
                    {
                        //If the resist type for this spell isn't on absorb, we can negate it. ALWAYS have preference to absorb because it heals
                        if (magicResistType != SpellResistTypes.Absorb)
                        {
                            magicResistType = SpellResistTypes.Negate;
                        }
                    }
                    //Checking to see if the damage is absorbed to heal the target
                    else if (resistPerk.absorbDamage)
                    {
                        magicResistType = SpellResistTypes.Absorb;
                        //Applying the damage reduction so the defender isn't healed as much
                        damageDealt -= resistPerk.GetSpellResistAmount(this.characterToEffect, didThisCrit, false);
                    }
                    //Otherwise we just get the amount that it normally resists
                    else
                    {
                        damageDealt -= resistPerk.GetSpellResistAmount(this.characterToEffect, didThisCrit, false);
                    }
                }
            }
        }

        //Subtracting any magic resistance from the damage that we're trying to deal
        switch (this.damageType)
        {
        case DamageType.Arcane:
            damageDealt -= this.characterToEffect.charEquipment.totalArcaneResist;
            break;

        case DamageType.Enchant:
            damageDealt -= this.characterToEffect.charEquipment.totalEnchantResist;
            break;

        case DamageType.Holy:
            damageDealt -= this.characterToEffect.charEquipment.totalHolyResist;
            break;

        case DamageType.Dark:
            damageDealt -= this.characterToEffect.charEquipment.totalDarkResist;
            break;

        case DamageType.Fire:
            damageDealt -= this.characterToEffect.charEquipment.totalFireResist;
            break;

        case DamageType.Water:
            damageDealt -= this.characterToEffect.charEquipment.totalWaterResist;
            break;

        case DamageType.Electric:
            damageDealt -= this.characterToEffect.charEquipment.totalElectricResist;
            break;

        case DamageType.Wind:
            damageDealt -= this.characterToEffect.charEquipment.totalWindResist;
            break;

        case DamageType.Stone:
            damageDealt -= this.characterToEffect.charEquipment.totalStoneResist;
            break;
        }

        //Looping through the attacking character's perks to see if there's any bonus threat to add to this effect
        int bonusThreat = 0;

        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            //If the perk is a threat boosting perk
            if (charPerk.GetType() == typeof(ThreatBoostPerk))
            {
                ThreatBoostPerk threatPerk = charPerk.GetComponent <ThreatBoostPerk>();

                //If the perk has the same damage type as this DoT or it affects all damage types
                if (threatPerk.damageTypeToThreaten == this.damageType || threatPerk.threatenAllDamageTypes)
                {
                    bonusThreat += threatPerk.GetAddedActionThreat(damageDealt, didThisCrit, true);
                }
            }
        }

        //If the damage was dealt normally
        if (magicResistType == SpellResistTypes.Normal)
        {
            //Dealing the damage to the effected character
            this.characterToEffect.charPhysState.DamageCharacter(damageDealt);

            //Telling the combat manager to display the damage dealt
            CombatTile3D damagedCharTile = CombatManager.globalReference.tileHandler.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];

            CombatManager.globalReference.DisplayDamageDealt(0, damageDealt, this.damageType, damagedCharTile, didThisCrit);

            //If this character has the EnemyCombatAI component, we increase the threat for the character who put this effect on
            if (this.characterToEffect.GetComponent <EnemyCombatAI_Basic>())
            {
                //If the character who cast this effect is a player character, we make the enemies hate that character
                if (!this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
                {
                    //If the attack didn't crit
                    if (!didThisCrit)
                    {
                        //Applying threat to the targeted character
                        this.characterToEffect.GetComponent <EnemyCombatAI_Basic>().IncreaseThreat(this.characterWhoTriggered, damageDealt + bonusThreat);
                    }
                    //If the attack did crit, we boost threat against all enemies by 25%
                    else
                    {
                        //Finding the bonus amount of threat that's applied to all enemies
                        int boostedThreat = damageDealt + bonusThreat;
                        boostedThreat = Mathf.RoundToInt(boostedThreat * 0.25f);
                        CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, boostedThreat, true);

                        //Applying the rest of the threat to the target character
                        CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, this.characterToEffect, damageDealt + bonusThreat - boostedThreat, false);
                    }
                }
            }
        }
        //If the damage was negated completely
        else if (magicResistType == SpellResistTypes.Negate)
        {
            //Telling the combat manager to display no damage dealt
            CombatTile3D damagedCharTile = CombatManager.globalReference.tileHandler.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, 0, this.damageType, damagedCharTile, didThisCrit);
        }
        //If the damage was absorbed and healed the character
        else if (magicResistType == SpellResistTypes.Absorb)
        {
            //Healing the damage to the effected character
            this.characterToEffect.charPhysState.HealCharacter(damageDealt);

            //Telling the combat manager to display the damage healed
            CombatTile3D damagedCharTile = CombatManager.globalReference.tileHandler.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, damageDealt, this.damageType, damagedCharTile, didThisCrit, true);

            //If the caster of this effect and the target are player characters, we increase the threat for the character who put this effect on them
            if (!this.characterToEffect.GetComponent <EnemyCombatAI_Basic>() && !this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
            {
                //Applying threat to all enemies for the amount that's healed
                CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, damageDealt + bonusThreat, true);
            }
        }

        //Creating the visual effect for this effect
        GameObject targetCharModel = CombatManager.globalReference.characterHandler.GetCharacterModel(this.characterToEffect);

        this.SpawnVisualAtLocation(targetCharModel.transform.localPosition, targetCharModel.transform);

        //If this effect isn't unlimited, we need to reduce the ticks remaining
        if (!this.unlimitedTicks)
        {
            this.ticksLeft -= 1;

            //If there are no more ticks left, this effect is over and the object is destroyed
            if (this.ticksLeft <= 0)
            {
                this.RemoveEffect();
            }
        }
    }
    //Overrided function from Effect.cs to trigger this heal effect
    public override void TriggerEffect(Character usingCharacter_, Character targetCharacter_, float timeDelay_ = 0)
    {
        //Setting the character references of who is attacking and who is being attacked
        this.characterToEffect     = targetCharacter_;
        this.characterWhoTriggered = usingCharacter_;

        //Int to hold the heal total for the effect
        int totalHeal = 0;

        //Adding the base heal
        totalHeal += this.baseHeal;

        //Looping through each individual die rolled
        for (int d = 0; d < this.diceRolled; ++d)
        {
            //Finding the value rolled on the current die
            totalHeal += Random.Range(1, this.diceSides);
        }

        //Rolling to see if this effect crits
        float critRoll = Random.Range(0, 1);
        bool  isCrit   = false;

        if (critRoll < this.critChance)
        {
            totalHeal = Mathf.RoundToInt(totalHeal * this.critMultiplier);
        }

        //Looping through the perks of the character that used this ability to see if they have any damage type boost perks
        foreach (Perk charPerk in usingCharacter_.charPerks.allPerks)
        {
            //If the perk boosts a damage type that's the same as this damage (heal) type, we boost it
            if (charPerk.GetType() == typeof(DamageTypeBoostPerk) && this.type == charPerk.GetComponent <DamageTypeBoostPerk>().damageTypeToBoost)
            {
                totalHeal += charPerk.GetComponent <DamageTypeBoostPerk>().GetDamageBoostAmount(usingCharacter_, isCrit, false, this.type);
            }
        }

        //Looping through the defending character's perks to see if they have any spell resist or absorb perks
        SpellResistTypes magicResistType = SpellResistTypes.Normal;

        foreach (Perk defPerk in this.characterToEffect.charPerks.allPerks)
        {
            if (defPerk.GetType() == typeof(SpellResistAbsorbPerk))
            {
                SpellResistAbsorbPerk resistPerk = defPerk.GetComponent <SpellResistAbsorbPerk>();

                //Checking to see if the current heal type is the same as this spell resist perk
                if (resistPerk.typeToResist == this.type)
                {
                    //Checking to see if the heal is negated entirely
                    if (resistPerk.negateAllDamage)
                    {
                        magicResistType = SpellResistTypes.Negate;
                    }
                    //Otherwise we just get the amount that it normally resists
                    else
                    {
                        totalHeal -= resistPerk.GetSpellResistAmount(this.characterToEffect, isCrit, false);
                    }
                }
            }
        }

        //Subtracting the target character's magic resistances
        switch (this.type)
        {
        case CombatManager.DamageType.Slashing:
            if (targetCharacter_.charInventory.totalSlashingArmor > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalSlashingArmor;
            }
            break;

        case CombatManager.DamageType.Stabbing:
            if (targetCharacter_.charInventory.totalStabbingArmor > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalStabbingArmor;
            }
            break;

        case CombatManager.DamageType.Crushing:
            if (targetCharacter_.charInventory.totalCrushingArmor > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalCrushingArmor;
            }
            break;

        case CombatManager.DamageType.Fire:
            if (targetCharacter_.charInventory.totalFireResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalFireResist;
            }
            break;

        case CombatManager.DamageType.Water:
            if (targetCharacter_.charInventory.totalWaterResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalWaterResist;
            }
            break;

        case CombatManager.DamageType.Electric:
            if (targetCharacter_.charInventory.totalElectricResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalElectricResist;
            }
            break;

        case CombatManager.DamageType.Wind:
            if (targetCharacter_.charInventory.totalWindResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalWindResist;
            }
            break;

        case CombatManager.DamageType.Nature:
            if (targetCharacter_.charInventory.totalNatureResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalNatureResist;
            }
            break;

        case CombatManager.DamageType.Arcane:
            if (targetCharacter_.charInventory.totalArcaneResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalArcaneResist;
            }
            break;

        case CombatManager.DamageType.Holy:
            if (targetCharacter_.charInventory.totalHolyResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalHolyResist;
            }
            break;

        case CombatManager.DamageType.Dark:
            if (targetCharacter_.charInventory.totalDarkResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalDarkResist;
            }
            break;

        case CombatManager.DamageType.Bleed:
            if (targetCharacter_.charInventory.totalBleedResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalBleedResist;
            }
            break;
        }

        //Looping through the attacking character's perks to see if there's any bonus threat to add to this effect
        int bonusThreat = 0;

        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            //If the perk is a threat boosting perk
            if (charPerk.GetType() == typeof(ThreatBoostPerk))
            {
                ThreatBoostPerk threatPerk = charPerk.GetComponent <ThreatBoostPerk>();

                //If the perk has the same damage type as this effect or it affects all damage types
                if (threatPerk.damageTypeToThreaten == this.type || threatPerk.threatenAllDamageTypes)
                {
                    bonusThreat += threatPerk.GetAddedActionThreat(totalHeal, isCrit, false);
                }
            }
        }

        //Finding the combat tile that the target character is on
        CombatTile targetCharTile = CombatManager.globalReference.FindCharactersTile(targetCharacter_);

        //If the heal was negated completely
        if (magicResistType == SpellResistTypes.Negate)
        {
            //Telling the combat manager to display that no damage was healed
            CombatTile healedCharTile = CombatManager.globalReference.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, 0, this.type, healedCharTile, isCrit, true);
        }
        //Otherwise, the heal happens normally
        else
        {
            //Healing the damage to the effected character
            this.characterToEffect.charPhysState.HealCharacter(totalHeal);

            //Telling the combat manager to display the damage healed
            CombatTile healedCharTile = CombatManager.globalReference.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, totalHeal, this.type, healedCharTile, isCrit, true);

            //If the acting character is a player character, we need to increase the threat against them
            if (!this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
            {
                //If this character DOESN'T have the EnemyCombatAI component, we increase the threat for the character who put this effect on
                if (!this.characterToEffect.GetComponent <EnemyCombatAI_Basic>())
                {
                    //Applying threat to all enemies based on the amount healed
                    CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, totalHeal + bonusThreat, true);
                }
            }
        }

        //Creating the visual effect for this effect
        CharacterSpriteBase targetCharSprite = CombatManager.globalReference.GetCharacterSprite(targetCharacter_);

        this.SpawnVisualAtLocation(targetCharSprite.transform.localPosition, targetCharSprite.transform);

        //Destroying this effect once everything is finished up
        Destroy(this.gameObject);
    }
Example #4
0
    //Overrided function from Effect.cs to trigger this damage effect
    public override void TriggerEffect(Character usingCharacter_, Character targetCharacter_, float timeDelay_ = 0)
    {
        //Setting the character references of who is attacking and who is being attacked
        this.characterToEffect     = targetCharacter_;
        this.characterWhoTriggered = usingCharacter_;

        //Int to hold all of the damage for the attack
        int totalDamage = 0;

        //Adding the base damage
        totalDamage += this.baseDamage;

        //Looping through each individual die rolled
        for (int d = 0; d < this.diceRolled; ++d)
        {
            //Finding the value rolled on the current die
            totalDamage += Random.Range(1, this.diceSides);
        }

        //Rolling to see if this effect crits
        float critRoll = Random.Range(0, 1);
        bool  isCrit   = false;

        if (critRoll < this.critChance)
        {
            totalDamage = totalDamage * this.critMultiplier;
        }

        //Looping through the perks of the character that used this ability to see if they have any damage type boost perks
        foreach (Perk charPerk in usingCharacter_.charPerks.allPerks)
        {
            //If the perk boosts a damage type that's the same as this damage type, we boost it
            if (charPerk.GetType() == typeof(DamageTypeBoostPerk) && this.type == charPerk.GetComponent <DamageTypeBoostPerk>().damageTypeToBoost)
            {
                totalDamage += charPerk.GetComponent <DamageTypeBoostPerk>().GetDamageBoostAmount(usingCharacter_, isCrit, false, this.type);
            }
        }

        //Looping through the defending character's perks to see if they have any spell resist or absorb perks
        SpellResistTypes magicResistType = SpellResistTypes.Normal;

        foreach (Perk defPerk in targetCharacter_.charPerks.allPerks)
        {
            if (defPerk.GetType() == typeof(SpellResistAbsorbPerk))
            {
                SpellResistAbsorbPerk resistPerk = defPerk.GetComponent <SpellResistAbsorbPerk>();

                //Checking to see if the current damage type is the same as this spell resist perk
                if (resistPerk.typeToResist == this.type)
                {
                    //Checking to see if the damage is negated entirely
                    if (resistPerk.negateAllDamage)
                    {
                        //If the resist type for this spell isn't on absorb, we can negate it. ALWAYS have preference to absorb because it heals
                        if (magicResistType != SpellResistTypes.Absorb)
                        {
                            magicResistType = SpellResistTypes.Negate;
                        }
                    }
                    //Checking to see if the damage is absorbed to heal the target
                    else if (resistPerk.absorbDamage)
                    {
                        magicResistType = SpellResistTypes.Absorb;
                        //Applying the damage reduction so the defender isn't healed as much
                        totalDamage -= resistPerk.GetSpellResistAmount(this.characterToEffect, isCrit, false);
                    }
                    //Otherwise we just get the amount that it normally resists
                    else
                    {
                        totalDamage -= resistPerk.GetSpellResistAmount(this.characterToEffect, isCrit, false);
                    }
                }
            }
        }

        //Subtracting the target character's armor resist and magic resistances
        switch (this.type)
        {
        case CombatManager.DamageType.Slashing:
            if (targetCharacter_.charInventory.totalSlashingArmor > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalSlashingArmor;
            }
            break;

        case CombatManager.DamageType.Stabbing:
            if (targetCharacter_.charInventory.totalStabbingArmor > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalStabbingArmor;
            }
            break;

        case CombatManager.DamageType.Crushing:
            if (targetCharacter_.charInventory.totalCrushingArmor > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalCrushingArmor;
            }
            break;

        case CombatManager.DamageType.Fire:
            if (targetCharacter_.charInventory.totalFireResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalFireResist;
            }
            break;

        case CombatManager.DamageType.Water:
            if (targetCharacter_.charInventory.totalWaterResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalWaterResist;
            }
            break;

        case CombatManager.DamageType.Electric:
            if (targetCharacter_.charInventory.totalElectricResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalElectricResist;
            }
            break;

        case CombatManager.DamageType.Wind:
            if (targetCharacter_.charInventory.totalWindResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalWindResist;
            }
            break;

        case CombatManager.DamageType.Nature:
            if (targetCharacter_.charInventory.totalNatureResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalNatureResist;
            }
            break;

        case CombatManager.DamageType.Arcane:
            if (targetCharacter_.charInventory.totalArcaneResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalArcaneResist;
            }
            break;

        case CombatManager.DamageType.Holy:
            if (targetCharacter_.charInventory.totalHolyResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalHolyResist;
            }
            break;

        case CombatManager.DamageType.Dark:
            if (targetCharacter_.charInventory.totalDarkResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalDarkResist;
            }
            break;

        case CombatManager.DamageType.Bleed:
            if (targetCharacter_.charInventory.totalBleedResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalBleedResist;
            }
            break;
        }

        //Looping through the attacking character's perks to see if there's any bonus threat to add to this effect
        int bonusThreat = 0;

        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            //If the perk is a threat boosting perk
            if (charPerk.GetType() == typeof(ThreatBoostPerk))
            {
                ThreatBoostPerk threatPerk = charPerk.GetComponent <ThreatBoostPerk>();

                //If the perk has the same damage type as this effect or it affects all damage types
                if (threatPerk.damageTypeToThreaten == this.type || threatPerk.threatenAllDamageTypes)
                {
                    bonusThreat += threatPerk.GetAddedActionThreat(totalDamage, isCrit, false);
                }
            }
        }

        //Finding the combat tile that the target character is on
        CombatTile targetCharTile = CombatManager.globalReference.FindCharactersTile(targetCharacter_);

        //If the damage was dealt normally
        if (magicResistType == SpellResistTypes.Normal)
        {
            //Dealing damage to the target character and telling the combat manager to display how much was dealt
            targetCharacter_.charPhysState.DamageCharacter(totalDamage);
            CombatManager.globalReference.DisplayDamageDealt(timeDelay_, totalDamage, type, targetCharTile, isCrit);

            //If this character has the EnemyCombatAI component, we increase the threat for the character who put this effect on
            if (this.characterToEffect.GetComponent <EnemyCombatAI_Basic>())
            {
                //If the character who cast this effect is a player character, we increase threat against the caster
                if (!this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
                {
                    //If the attack didn't crit
                    if (!isCrit)
                    {
                        //Applying threat to the targeted character
                        this.characterToEffect.GetComponent <EnemyCombatAI_Basic>().IncreaseThreat(this.characterWhoTriggered, totalDamage + bonusThreat);
                    }
                    //If the attack did crit, we boost threat against all enemies by 25%
                    else
                    {
                        //Finding the bonus amount of threat that's applied to all enemies
                        int boostedThreat = totalDamage + bonusThreat;
                        boostedThreat = Mathf.RoundToInt(boostedThreat * 0.25f);
                        CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, boostedThreat, true);

                        //Applying the rest of the threat to the target character
                        CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, this.characterToEffect, totalDamage + bonusThreat - boostedThreat, false);
                    }
                }
            }
        }
        //If the damage was negated completely
        else if (magicResistType == SpellResistTypes.Negate)
        {
            //Telling the combat manager to display no damage dealt
            CombatManager.globalReference.DisplayDamageDealt(timeDelay_, 0, type, targetCharTile, isCrit);
        }
        //If the damage was abosrbed and healed the character
        else if (magicResistType == SpellResistTypes.Absorb)
        {
            //Telling the combat manager to display the damage healed
            targetCharacter_.charPhysState.HealCharacter(totalDamage);
            CombatManager.globalReference.DisplayDamageDealt(timeDelay_, totalDamage, type, targetCharTile, isCrit, true);

            //If the caster of this effect and the target are player characters, we increase the threat for the character who put this effect on them
            if (!this.characterToEffect.GetComponent <EnemyCombatAI_Basic>() && !this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
            {
                //Applying threat to all enemies for the amount that's healed
                CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, totalDamage + bonusThreat, true);
            }
        }

        //Creating the visual effect for this effect
        CharacterSpriteBase targetCharSprite = CombatManager.globalReference.GetCharacterSprite(targetCharacter_);

        this.SpawnVisualAtLocation(targetCharSprite.transform.localPosition, targetCharSprite.transform);


        //Increasing the threat to the target based on damage dealt
        //If the attack is a crit, ALL enemies have their threat increased for 25% of the damage
        if (isCrit)
        {
            //Getting 25% of the damage to pass to all enemies
            int threatForAll = (totalDamage + bonusThreat) / 4;
            CombatManager.globalReference.ApplyActionThreat(usingCharacter_, null, threatForAll, true);

            //Applying the rest of the threat to the target character
            CombatManager.globalReference.ApplyActionThreat(usingCharacter_, targetCharacter_, (totalDamage + bonusThreat) - threatForAll, false);
        }
        //If the attack wasn't a crit, only the target character takes threat
        else
        {
            CombatManager.globalReference.ApplyActionThreat(usingCharacter_, targetCharacter_, totalDamage + bonusThreat, false);
        }

        //Destroying this effect once everything is finished up
        Destroy(this.gameObject);
    }