Godot Version
4.4.1
Question
Stumbling on how to best implement custom functions for special abilities in a turn-based battle system. Currently, it’s set up like this:
ability resources:
- have common properties, names, basic attack power/costs/ability type etc.
- also holds an enum for a special ability id.
battle_controller.gd:
- handles turn order logic, runs turns and abilities.
- on ability selection, it calls a damage/heal script on the target combatant based on ability properties.
- if the ability has a special id, it should run that script instead from the ability_DB…
ability_DB:
- autoload script, contains a dictionary [ability_id, Callable], holding special functions for abilities like ‘steal’, ‘swap turn’, that aren’t covered by just healing/taking damage.
Essentially, I want to be able to inject Callables from the ability_DB into the battle_controller when the ability used has a relevant id. I want to be able to do this to allow for abilities that manipulate turn order, as well as to ensure the full ability animations and notifications are completed before moving onto the next turn.
Now that I’ve set it up like this, I can see that I can’t write scripts that refer to battle_controller properties from within ability_DB, so short of just combining the scripts together and having a huge dictionary attached to my main battle script, I’m a little stuck.
Any advice on alternative approaches? I can see possibly just using signals when I want to change stuff with turn order, as maybe that’s the only instance where it’s actually necessary to run from within the controller script…