RiftMayhem/Assets/Scripts/AbilitySystem/Effects/DamageIncomeModifierEffect.cs
Pedro Gomes d89d22a267 New enemy type + Bugfix & Quality of life changes
- New enemy Crazied Orc Grunt basic + Boss
- New abilities for crazied orc grunt
- bugfix Damage input modifier effect instance not using stat scaling properly
- updated damage input/output modifier effects scaling
- Added QoL shift+click on stat point allocation button to add +10 in a single click
2025-01-11 23:50:11 +00:00

63 lines
2.6 KiB
C#

using Kryz.CharacterStats;
using Kryz.CharacterStats.Examples;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "DamageIncomeModifierEffect", menuName = "RiftMayhem/AbilitySystem/Effects/DamageIncomeModifier Effect", order = 1)]
public class DamageIncomeModifierEffect : StatusEffect
{
public float damageIncomeModifierPercentage;
public bool avoidAllies = false;
DamageIncomeModifierEffectInstance targetDamageIncomeModifierEffect;
public override void ApplyEffect(Taggable user, List<Taggable> targets)
{
base.ApplyEffect(user, targets);
if (applyToTargetsHit)
{
foreach (Taggable target in targets)
{
if(avoidAllies)
{
if (user.AlliedTagsContains(target.targetTag)) continue;
}
targetDamageIncomeModifierEffect = target.GetComponent<DamageIncomeModifierEffectInstance>();
targetDamageIncomeModifierEffect.owner.RPC(nameof(targetDamageIncomeModifierEffect.RPC_ApplyDamageIncomeModifierEffect), targetDamageIncomeModifierEffect.owner.Owner, StatusEffectIndexer.Instance.StatusEffects.IndexOf(this), CalculateFinalAmount(user));
}
}
if(applyToSelf)
{
targetDamageIncomeModifierEffect = user.GetComponent<DamageIncomeModifierEffectInstance>();
targetDamageIncomeModifierEffect.ApplyEffect(this, CalculateFinalAmount(user));
}
}
private float CalculateFinalAmount(Taggable user)
{
float finalAmount = damageIncomeModifierPercentage;
CharacterStats stats = user.GetComponent<CharacterStats>();
foreach (var statInfluence in influencingStats)
{
if (stats.primaryStatsDictionary.TryGetValue(statInfluence.statTag.name.ToLower(), out CharacterStat stat))
{
Debug.Log("#DIMod: " + this.name + " = " + damageIncomeModifierPercentage + " += " + stat.Value + " * " + statInfluence.percentInfluence);
finalAmount += stat.Value * statInfluence.percentInfluence;
}
else if (stats.secondaryStatsDictionary.TryGetValue(statInfluence.statTag.name.ToLower(), out CharacterStat secondaryStat))
{
Debug.Log("#DIMod: " + this.name + " = " + damageIncomeModifierPercentage + " += " + stat.Value + " * " + statInfluence.percentInfluence);
finalAmount += secondaryStat.Value * statInfluence.percentInfluence;
}
}
Debug.Log("#DIMod: " + this.name + " finalAmount = " + finalAmount);
return finalAmount;
}
}