- Status effects all have a timer that is used to determine when the effect degrades in intensity
- In lua, we define a duration time for each status effect. The duration applies the same time to each intensity, so we currently have no way to make one intensity last longer than another
- In lua we define three functions for each affect: Apply, Update, and Finish
- Apply is called when the status effect first becomes active
- Update is called every once every game loop. Currently all update functions check to see if the status effect intensity changed and if not, it does nothing
- Finish is called when the status effect is cured or otherwise dissipates
This scheme works for what we have right now, but it's not powerful or flexible enough to do anything interesting with it. For example, there's no way for an effect to do a periodic update, like poison removing HP every few seconds. There's no way for an effect to do anything interesting, like putting an actor in a state where they can not be targeted (a stasis sort of effect). And so on. Furthermore thinking beyond status effects, we would like some skills to have certain outcomes on the battlefield. This could be reducing an enemies' position on the action bar, a character defending an ally by taking a hit for them, etc. Using the current effects system we have and applying it to more than just status effects seems like it would be the way to go for things like this.
I'm thinking of improving the battle effects system by mimicing the design of map events, where we have a single base class and multiple subclasses for different types of effects. More specifically, I'm thinking of doing the following:
- BattleEffect would be a base class (might be abstract, might not). It holds a _status_type member that determines whether or not this represents a status effect, and if so what status effect it is
- BattleStaticEffect would do what are current effects do now. It only makes a static change when the effect is applied or the intensity changes.
- BattlePeriodicEffect would have a second timer in addition to the duration timer. This timer would be shorter than the duration timer and when it completes, we make some change such as draining HP for a poison effect. The duration timer loops infinitely while the effect is active.
- BattleConditionalEffect would be an effect that activates only when certain conditions are checked and met. For example, when an ally is about to damage from an attacker.
- BattleCustomEffect would be implemented entirely in Lua, allowing us to do virtually anything we wanted there.
- In Lua, depending on the type of effect we would have to define specific functionality (for example, the duration of the periodic timer for the periodic effects). Additionally, we should have some member in Lua that declares what type of class effect this is
I think this is a good start to a more advanced and flexible effects system. For the time being, I'm going to implement the first three effect classes and leave placeholders for the last two (which are more complicated to get working). Getting a working poison status effect (BattlePeriodicEffect type) is my first immediate goal.
Does anyone have any thoughts or suggestions on how to best support effects? I want us to have a well-designed and elegant system that at the same time grants a lot of flexibility. We don't need to be able to support absolutely every kind of crazy effect we can dream up, but I want to eliminate most barriers from implementing new effects on a whim, which we will likely do for boss battles later in the game.