Adding a New Buff
Last updated
Last updated
First, you need to find your skill prefab. You'll see that two new properties have been added to the skill script: the "Add Buff Event" where you can select a only event, and the second one where you can add your own or preset three buffs.
Assets/RGame/RoguelikeKit/Prefabs/Skill/BothSideSkill.prefab
This guide walks you through creating and configuring a new buff in the RGame RoguelikeKit, using BurnBuff as an example.
In Unity, navigate to:
Select BurnBuff.asset to view its properties in the Inspector. You will see four key fields:
Duration: Total lifespan of the buff (in seconds).
TickInterval: How often TickEffect() is called. For BurnBuff, this is set to 1s (one damage tick per second).
OnRemove: choose a unique event.
Damage: Amount of damage dealt each tick.
The remaining two built‑in buff types (e.g. FreezeBuff, SlowBuff) use the same properties—just examine their asset files and you’ll see how Duration, Interval, and effect parameters differ.
Right‑click in your project window and choose Create → RGame → RoguelikeKit → Buff → BaseBuff (or duplicate BurnBuff and rename).
Name your new script: MyCustomBuff.cs.
Each buff requires three overrides in your BaseBuff subclass:
Activate(): Called when the buff is applied.
TickEffect(): Called every TickInterval seconds while active.
DeActivate(): Called when the buff expires or is removed.
Below is the full BurnBuff implementation for reference:
In the Inspector, set Duration, TickInterval, and any custom parameters (e.g., damage, slow percentage).
Wire up OnRemoveAllBuff to the appropriate event channel.
If you prefer, ask your AI assistant to scaffold a new buff class using this pattern:
Your assistant can generate the C# boilerplate and even set up properties—no coding worries required.
You don't need to worry about the AI being unable to create the effect you want. As long as it's not particularly complex, the AI can handle it.
You’re all set! With this pattern, you can rapidly add new buff types—just follow the Activate(), TickEffect(), and DeActivate() lifecycle, then configure the asset parameters in the Inspector.