Add Special Events for Skills

I get Skills that instantiate Fireballs, or give Attribute buffs and debuffs. But how do you make them have special events like “Revive yourself upon Death”, “Reduce all Status durations by 3 seconds”, “Gain Mana from eating Food”, “Reflect Magic Damage”… The list goes on about so many crazy skills, do you just create a new script for each crazy skill? Then how do you tell those crazy things to affect systems in such a complex way like “Reflect Magic”… Please help man, tldr; how do I encapsulate skills with unique behaviour

Use OOP.

Base script CrazySkill, with public virtual methods for trigger conditions. E.g. OnUse()

Individual effects scripts that extend CrazySkill (e.g. RandomBuff : CrazySkill), and have public override methods for what actually happens OnUse().

You can then use polymorphism, e.g. the player can have an array of type CrazySkill, which can be iterated through, selected from, or universally triggered with e.g. CrazySkills[5].OnUse(), but the individual skills can be subclasses with unique behaviours.

This needs to be offset against a stats system where you have a (huge) stats block for the player with base and active stats, e.g. magic reflection %. The ReflectMagic abilities script might only be:

public class ReflectMagicPotion : CrazyBuff

public override void OnUse(){

IEnumerator Use(){
   Player.stats.magicReflectionBonus += 0.1f;
   yield return new WaitForSeconds(10f);
   Player.stats.magicReflectionBonus -= 0.1f;

Of course this isn’t a complete system. How exactly magicReflectionBonus is used, capped, multiplied, etc. is all game-specific logic that needs to sit in calculations of damage; probably in a TakeDamage(type, source, amount) type method.

This inevitably means each skill still needs its own script, but the base class can handle the repetitive/heavy lifting of universal functionalities and when they’re called, so the per-skill scripts can be very short, which makes them easy to balance/debug.