flask-round-poisonStatus Effects

Status Effects Overview

A status effect is a temporary modifier that can be applied to a player or enemy, altering their behavior or stats for a short duration. The template includes four types of status effects:

  • Ignite - Deals damage over time in short bursts to its target.

  • Freeze - Slows down or completely immobilizes the target for a duration.

  • Poison - Inflicts a small amount of damage over time and reduces the target’s strength.

  • Shock - Deals minor damage over time and can spread to nearby targets.

Status effects are typically applied by abilities through their projectiles, although some enemies can also inflict them directly through their attacks.

How Status Effects Work

Let’s take a closer look at how status effects work using the Ignite Ability as an example.

1

Data For Status Effect

There isn’t a dedicated asset that stores universal status effect data. Instead, each ability or other entity has the freedom to define and initialize its own effect values as needed.

Ignite Ability Level Data

In the case of the Ignite Ability, the status effect parameters are stored within its Level data. These include the following fields:

  • Effect Duration - The amount of time the effect remains active on its target.

  • Arrow Damage Multiplier - Modifies the base damage of the projectile itself, giving creators finer control over game balance.

  • Effect Deals Damage Over Time - If enabled, the effect will periodically deal damage while it’s attached to the target.

  • Effect Damage Multiplier - The amount of damage dealt each tick, calculated as the projectile’s base damage multiplied by this value.

  • Effect Damage Interval - The time interval between each burst of damage.

2

Status Effect Component

When the Ignite Ability is acquired by the player, its SetData method creates an instance of the IgniteStatusEffect and attaches it as a component to its own GameObject. It then instructs the PlayerBehavior to apply this status effect to every projectile the player fires.

protected override void SetData(IgniteAbilityData data)
{
    base.SetData(data);

    effect = gameObject.AddComponent<IgniteStatusEffect>();
    StageController.Player.SetProjectileEffect(effect);
}

Next, in the SetAbilityLevel method, the ability assigns values from its Ability Level to the attached Status Effect instance. This process also occurs each time the ability is upgraded.

protected override void SetAbilityLevel(int levelId)
{
    base.SetAbilityLevel(levelId);

    effect.Duration = AbilityLevel.EffectDuration;
    effect.EffectDamageMultiplier = AbilityLevel.EffectDamageMultiplier;
    effect.ArrowDamageMultiplier = AbilityLevel.ArrowDamageMultiplier;
    effect.DamageInterval = AbilityLevel.EffectDealsDamageOverTime ? 
        AbilityLevel.EffectDamageInterval : AbilityLevel.EffectDuration + 1;
}
circle-info

Each entity that applies a status effect must create its own instance of that effect. This can be done either through code, as shown in the example above, or by adding the status effect component (e.g., IgniteStatusEffect) directly to the GameObject.

In both cases, the effect must be initialized and populated with its specific data in code to ensure proper behavior.

3

Applying Status Effects to Targets

The PlayerBehavior component attaches status effects from abilities to the projectiles it fires. When a projectile hits its target, it instructs the status effect instance created earlier to attach itself to that target:

appliedStatusEffects[i].ApplyToTarget(target, GetDamage());

Each Status Effect instance keeps track of all targets it is currently attached to, when to apply damage and when to remove itself after expiration.

Any class that can be affected by projectiles must implement the IProjectileTarget interface. This interface defines the methods used to manage status effects:

bool ApplyStatusEffect(StatusEffectType type, float multiplier);
void RemoveStatusEffect(StatusEffectType type);

The target is responsible for handling its response to each effect. For example, in the template, every target includes the StatusEffectHelper and RenderersHelper components, which control the visual and audio feedback for active effects, such as rim highlights, particles, and sounds, etc.

Status Effects Helper

The StatusEffectsHelper component defines how heroes and enemies respond to status effects applied to them. For each status effect, it contains its own configurable set of data fields:

Effect Data
  • Type - The type of status effect.

  • Cooldown - The duration during which the target is immune to this status effect after the previous one expires.

  • Initial Cooldown - The duration during which the target is immune to this status effect after spawning.

  • Resist Chance - The probability that the target will resist the status effect entirely.

  • Status Effect Duration Multiplier - Adjusts how long the status effect lasts, allowing certain enemies to be more resistant.

  • Particle Prefab - The particle effect that will be instantiated and played while the status effect is active.

  • Change Particle Shape - If enabled, the particle’s shape will be set to match the target’s mesh renderer.

  • Rim Data - A small asset containing color, strength, gradient, and direction values for a rim effect, specific to the October Shader.

  • Status Effect Audio Data - A small asset containing the sounds that play when the effect is applied, ticks, or expires.

Last updated