The spell action
This is the base action for how many of the game's spells (and spell adjacent) abilities function. These spells function off of a cooldown-based system.
- [can_cast_spell][/datum/action/cooldown/spell/can_cast_spell] checks if the OWNER of the spell is able to cast the spell.
- [is_valid_target][/datum/action/cooldown/spell/is_valid_target] checks if the TARGET THE SPELL IS BEING CAST ON is a valid target for the spell. NOTE: The CAST TARGET is often THE SAME as THE OWNER OF THE SPELL, but is not always - depending on how Pre Activate is resolved.
- try_invoke is run in can_cast_spell to check if the OWNER of the spell is able to say the current invocation.
- [before_cast][/datum/action/cooldown/spell/before_cast] is the last chance for being able to interrupt a spell cast. This returns a bitflag. if SPELL_CANCEL_CAST is set, the spell will not continue.
- spell_feedback is called right before cast, and handles invocation and sound effects. Overridable, if you want a special method of invocation or sound effects, or you want your spell to handle invocation / sound via special means.
- cast is where the brunt of the spell effects should be done and implemented.
- after_cast is the aftermath - final effects that follow the main cast of the spell. By now, the spell cooldown has already started
- invocation handles saying any vocal (or emotive) invocations the spell may have, and can be overriden or extended. Called by spell_feedback.
- reset_spell_cooldown is a way to handle reverting a spell's cooldown and making it ready again if it fails to go off at any point. Not called anywhere by default. If you want to cancel a spell in before_cast and would like the cooldown restart, call this.
- level_spell is where the process of adding a spell level is handled. this can be extended if you wish to add unique effects on level up for wizards.
- delevel_spell is where the process of removing a spell level is handled. this can be extended if you wish to undo unique effects on level up for wizards.
- get_spell_title returns the prefix of the spell name based on its level, for use in updating the button name / spell name.
Vars | |
antimagic_flags | This determines what type of antimagic is needed to block the spell. (MAGIC_RESISTANCE, MAGIC_RESISTANCE_MIND, MAGIC_RESISTANCE_HOLY) If SPELL_REQUIRES_NO_ANTIMAGIC is set in Spell requirements, The spell cannot be cast if the caster has any of the antimagic flags set. |
---|---|
bypass_cost | Boolean, if true, resource costs will be ignored |
cooldown_reduction_per_rank | If the spell uses the wizard spell rank system, the cooldown reduction per rank of the spell |
invocation | What is uttered when the user casts the spell |
invocation_self_message | What is shown in chat when the user casts the spell, only matters for INVOCATION_EMOTE |
invocation_type | What type of invocation the spell is. Can be "none", "whisper", "shout", "emote" |
resource_costs | An associative list of all resource costs |
school | The school of magic the spell belongs to. Checked by some holy sects to punish the caster for casting things that do not align with their sect's alignment - see magic.dm in defines to learn more |
smoke_amt | The amount of smoke to create on cast. This is a range, so a value of 5 will create enough smoke to cover everything within 5 steps. |
smoke_type | The typepath of the smoke to create on cast. |
sound | The sound played on cast. |
sparks_amt | If set to a positive number, the spell will produce sparks when casted. |
spell_level | The current spell level, if taken multiple times by a wizard |
spell_max_level | The max possible spell level |
spell_requirements | Flag for certain states that the spell requires the user be in to cast. |
Procs | |
after_cast | Actions done after the main cast is finished. This is called after the cooldown's already begun. |
cast | Actions done as the main effect of the spell. |
consume_resource | Called after the effect happens, whether that's after the button press or after hitting someone with a touch ability |
delevel_spell | Levels the spell down a single level, down to 1. |
get_spell_title | Gets the title of the spell based on its level. |
invocation | The invocation that accompanies the spell, called from spell_feedback() before cast(). |
level_spell | Levels the spell up a single level, reducing the cooldown. If bypass_cap is TRUE, will level the spell up past it's set cap. |
reset_spell_cooldown | Resets the cooldown of the spell, sending COMSIG_SPELL_CAST_RESET and allowing it to be used immediately (+ updating button icon accordingly) |
spell_feedback | Provides feedback after a spell cast occurs, in the form of a cast sound and/or invocation |
try_invoke | Checks if the current OWNER of the spell is in a valid state to say the spell's invocation |
Var Details
antimagic_flags
This determines what type of antimagic is needed to block the spell. (MAGIC_RESISTANCE, MAGIC_RESISTANCE_MIND, MAGIC_RESISTANCE_HOLY) If SPELL_REQUIRES_NO_ANTIMAGIC is set in Spell requirements, The spell cannot be cast if the caster has any of the antimagic flags set.
bypass_cost
Boolean, if true, resource costs will be ignored
cooldown_reduction_per_rank
If the spell uses the wizard spell rank system, the cooldown reduction per rank of the spell
invocation
What is uttered when the user casts the spell
invocation_self_message
What is shown in chat when the user casts the spell, only matters for INVOCATION_EMOTE
invocation_type
What type of invocation the spell is. Can be "none", "whisper", "shout", "emote"
resource_costs
An associative list of all resource costs
school
The school of magic the spell belongs to. Checked by some holy sects to punish the caster for casting things that do not align with their sect's alignment - see magic.dm in defines to learn more
smoke_amt
The amount of smoke to create on cast. This is a range, so a value of 5 will create enough smoke to cover everything within 5 steps.
smoke_type
The typepath of the smoke to create on cast.
sound
The sound played on cast.
sparks_amt
If set to a positive number, the spell will produce sparks when casted.
spell_level
The current spell level, if taken multiple times by a wizard
spell_max_level
The max possible spell level
spell_requirements
Flag for certain states that the spell requires the user be in to cast.
Proc Details
after_cast
Actions done after the main cast is finished. This is called after the cooldown's already begun.
It can be used to apply late spell effects where order matters (for example, causing smoke after a teleport occurs in cast()) or to clean up variables or references post-cast.
cast
Actions done as the main effect of the spell.
For spells without a click intercept, [cast_on] will be the owner. For click spells, [cast_on] is whatever the owner clicked on in casting the spell.
consume_resource
Called after the effect happens, whether that's after the button press or after hitting someone with a touch ability
delevel_spell
Levels the spell down a single level, down to 1.
get_spell_title
Gets the title of the spell based on its level.
invocation
The invocation that accompanies the spell, called from spell_feedback() before cast().
level_spell
Levels the spell up a single level, reducing the cooldown. If bypass_cap is TRUE, will level the spell up past it's set cap.
reset_spell_cooldown
Resets the cooldown of the spell, sending COMSIG_SPELL_CAST_RESET and allowing it to be used immediately (+ updating button icon accordingly)
spell_feedback
Provides feedback after a spell cast occurs, in the form of a cast sound and/or invocation
try_invoke
Checks if the current OWNER of the spell is in a valid state to say the spell's invocation