- Implemented Damage output modifier effects to all characters, allowing to temporarily increase/decrease the target's output - Added a complete set of priest abilities, when they want to join the dark side: - New Corrupted slash priest melee ability - New Shadow Orb priest projectile ability - New Burst of Corruption AoE ability - New Corrupted Grounds AoEOverTime ability - New Tainted Star AoEOverTime ability (future signature spell) - Added stackable damage income modifier to enemies hit by all corrupted priest abilities, making him insane in cursing and group utility. - Updated damage income/output modifiers to allow optional stacking of the same effects
85 lines
3.1 KiB
C#
85 lines
3.1 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
using Kryz.CharacterStats.Examples;
|
|
using Kryz.CharacterStats;
|
|
|
|
[CreateAssetMenu(fileName = "DamageOverTimeEffect", menuName = "RiftMayhem/AbilitySystem/Effects/Damage Over Time Effect", order = 1)]
|
|
public class DamageOverTimeEffect : StatusEffect
|
|
{
|
|
[Space]
|
|
public float baseDamagePerTick;
|
|
public float tickRate = 1f;
|
|
public DamageOverTimeType damageType;
|
|
|
|
private float finalTickValue;
|
|
private CharacterStats stats;
|
|
private DamageOutputModifierEffectInstance damageOutputModifier;
|
|
|
|
public override void ApplyEffect(Taggable user, List<Taggable> targets)
|
|
{
|
|
base.ApplyEffect(user, targets);
|
|
|
|
finalTickValue = CalculateFinalDamage(user);
|
|
|
|
if (applyToTargetsHit)
|
|
{
|
|
foreach (Taggable target in targets)
|
|
{
|
|
BaseDamageOverTimeEffectInstance dotInstance = GetOrAddCorrectInstance(target);
|
|
dotInstance.owner.RPC((nameof(dotInstance.RPC_ApplyDamageOverTimeEffect)+damageType.ToString()), dotInstance.owner.Owner, StatusEffectIndexer.Instance.StatusEffects.IndexOf(this), finalTickValue);
|
|
}
|
|
}
|
|
if (applyToSelf)
|
|
{
|
|
BaseDamageOverTimeEffectInstance dotInstance = GetOrAddCorrectInstance(user);
|
|
dotInstance.ApplyEffect(this, finalTickValue);
|
|
}
|
|
}
|
|
|
|
private BaseDamageOverTimeEffectInstance GetOrAddCorrectInstance(Taggable target)
|
|
{
|
|
switch (damageType)
|
|
{
|
|
case DamageOverTimeType.Burn:
|
|
return target.GetComponent<BurnEffectInstance>() ?? target.gameObject.AddComponent<BurnEffectInstance>();
|
|
case DamageOverTimeType.Poison:
|
|
return target.GetComponent<PoisonEffectInstance>() ?? target.gameObject.AddComponent<PoisonEffectInstance>();
|
|
case DamageOverTimeType.Bleed:
|
|
return target.GetComponent<BleedEffectInstance>() ?? target.gameObject.AddComponent<BleedEffectInstance>();
|
|
default:
|
|
throw new System.ArgumentException("Unknown damage type");
|
|
}
|
|
}
|
|
|
|
private float CalculateFinalDamage(Taggable user)
|
|
{
|
|
float finalDamage = baseDamagePerTick;
|
|
|
|
if (user == null) return finalDamage;
|
|
|
|
stats = user.GetComponent<CharacterStats>();
|
|
|
|
if (stats == null) return finalDamage;
|
|
|
|
damageOutputModifier = user.GetComponent<DamageOutputModifierEffectInstance>();
|
|
|
|
if (damageOutputModifier == null) return finalDamage;
|
|
|
|
foreach (var statInfluence in influencingStats)
|
|
{
|
|
if (stats.primaryStatsDictionary.TryGetValue(statInfluence.statTag.name.ToLower(), out CharacterStat stat))
|
|
{
|
|
finalDamage += stat.Value * statInfluence.percentInfluence;
|
|
}
|
|
else if (stats.secondaryStatsDictionary.TryGetValue(statInfluence.statTag.name.ToLower(), out CharacterStat secondaryStat))
|
|
{
|
|
finalDamage += secondaryStat.Value * statInfluence.percentInfluence;
|
|
}
|
|
}
|
|
|
|
finalDamage = damageOutputModifier.ModifyDamageOutput(finalDamage);
|
|
|
|
return finalDamage;
|
|
}
|
|
|
|
} |