Skip to main content

BaseSpell Class

Spells inherit from the BaseSpell class, which contains some functionality that is shared between all spells.

initialize_base_spell takes the ID of a spell as an argument, and reads the corresponding data from the data/db_spells.json file. It then creates the spell_base and spell_current dictionaries, and connects the signal for the global cooldown, if the spell is on the global cooldown, and adds the cooldown timer node.

Note: spell_base contains the unmodified data read from the data/db_spells.json file. It does not change. spell_current contains the spell data, and is modified with changes by things such as talents.

get_spell_target determines which target the spell is used on. The target can either be the mouseover target, or the selected target of the source. If both are null, an individual spell may set the target to the source in its own script. The current intent is to enable or disable mouseover targeting for each spell individually in a future update.

is_illegal_target checks whether the target of the spell is a legal target, by checking whether it is in the correct group.

is_on_cd checks whether the spell is currently on cooldown, by checking the cooldown timer.

insufficient_resource checks whether the source of the spell has sufficient resources to trigger the spell.

is_not_in_range checks whether the target of the spell is within the maximum range of the spell.

is_not_in_line_of_sight  checks whether the target is within line of sight of the source. This is currently not functional.

trigger_cd starts the cooldown timer of the spell, if it is not currently on cooldown with a higher remaining duration than the new cooldown would be. For example, a spell that has 25 seconds of cooldown left would not have a global cooldown applied to it, but a spell with no running cooldown timer would have the global cooldown applied to it.

update_resource applies the resource cost (or gain) caused by the spell to the source of the spell.