Skip to main content

Spell

Instance of Entity.

Spell functions are accessible to all entities, but will throw if the entity is not a Spell or Obstacle.

Spell.new(team?)

Returns a new Entity instance.

Spell.from(entity)

Returns the entity passed in if the entity is a spell, otherwise returns nil.

spell:set_tile_highlight(highlight)

Sets the highlight mode for tiles the spell passes over.

See tile:set_highlight()

spell:copy_hit_props()

Returns a copy of the spell's HitProps

spell:set_hit_props(hit_props)

spell:attack_tile(tile?)

Attack entities on the target tile, defaults to the spell's current tile.

If this function is called on every frame by this spell, attacks queued for the same tile will be ignored after the first frame hits occur in.

To allow a spell to hit multiple times on the same tile, calls to this function should be skipped for at least a frame, or a new spell should be spawned to perform the attack.

See SharedHitbox for a convenience spell to handle attacks.

spell:attack_tiles(tiles)

Same as calling spell:attack_tile(tile) for each tile.

spell.on_collision_func = function(self, entity)

Called when the spell hits an entity and isn't blocked by intangibility.

spell.on_attack_func = function(self, entity)

Called after processing damage on the entity, if damage isn't blocked by DefenseRules.

Hitbox

Attacks on first update then deletes self.

Hitbox.new(team?, damage?)

Returns a new Entity instance.

SharedHitbox

Adopts the parent spell's HitProps and Team. Attacks every frame until deleted.

The SharedHitbox's on_collision_func and on_attack_func calls the parent spell's on_collision_func and on_attack_func.

SharedHitbox.new(spell, duration?)

  • duration: The amount of frames this spell should exist for. If unset, it will require manual deletion.

Creates a SharedHitbox.

Returns a new Entity instance.