# BaseSpell Class

Spells inherit from the BaseSpell class, which contains some functionality that is shared between all spells. This class contains the dictionaries that store spell data, the cooldown timer, and the flag that determines whether a spell uses mouseover targeting.

**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.

**trigger\_gcd** causes the spell container to emit the gcd signal, which starts the gcd of all spells that use it, with the duration being specificed in the spell\_container.

**update\_resource** applies the resource cost (or gain) caused by the spell to the source of the spell.

**start\_cast** sets the is\_casting state to true, links the cast timer to the cast\_success function of the spell being cast, starts the cast timer, and causes the gcd signal to be emitted.

**cast\_success** is a dummy function for use with instant spells, and is overridden by spells that have a cast time. This function is then called when the cast timer times out. For spells with cast time, the overriding function in the individual spell script applies resource costs, sends the combat event, and calls finish\_cast.

**finish\_cast** plays the spell success animation, disconnects the cast timer from the cast\_success function, triggers the spell cd, sets the is\_casting state to false, and checks for queued spells that are automatically cast next.