Creating New Spells
To add a new spell, a few steps are required.
Creating the Database Entry
The spell database data/db_spells.json needs to be appended with an entry for the new spell. This is done by creating a new entry with a new unique ID, and specifying the key and value pairs. Which keys are required depends on the type of spell that is added. More information can be found here.
The spell also needs to be added to the spell_list of the unit or interactable that should use the spell, in either the data/db_stats_player.json file, the data/db_stats_npc.json file, or the data/db_stats_interactable.json file.
Creating the Spell Scene
Every spell needs an associated scene. The scene consists of a node of type Node, which has to be named spell_[id], where [id] is replaced by the ID of the spell. This scene will then be added to the spell container of the unit that should have the spell available.
Creating the Spell Script
Every spell scene needs an attached spell script that handles the triggering of the spell. The script should inherit from the BaseSpell class, which contains some core functionality. The _ready function of the spell script should call initialize_base_spell with the spell ID as the argument. This creates the dictionaries that contain the spell data, and the cooldown timer. The script should further contain a trigger function, which determines the source and target of the spell, and goes through a number of checks that determine whether the spell can actually be used when it is triggered. The standard checks, such as whether the spell is already on cooldown, whether the target is within range, etc., are contained in the BaseSpell class. After the checks, if the spell can be triggered, the resource cost can be applied using the update_Resourceupdate_resource function of BaseSpell, and a combat event can be sent using Combat.combat_event_entrypoint or Combat.combat_event_aura_entrypoint, depending on the type of spell.