Skip to main content

Spell Callbacks

Spell callbacks provide a powerful way to define custom logic for when and how spells should be cast. Instead of checking conditions in your rotation, you can attach the logic directly to the spell.

Basic Structure

spells.SpellName:callback(function(spell, logic)
-- Your spell logic here
if condition then
return spell:cast(target)
end
end)

Example Callbacks

Healing Spell with Health Threshold

spells.ImpendingVictory:callback(function(spell, logic)
local healAmount = player.healthmax * 0.2 -- Calculate 20% of max health
local healthMissing = player.healthmax - player.health -- Calculate missing health

if healthMissing >= healAmount * 0.8 then -- Use if we're missing at least 80% of the heal amount
return spell:cast(player)
end
end)

Basic Target Spell

spells.ShieldSlam:callback(function(spell, logic)
return spell:cast(target)
end)

AOE Spell with Enemy Count

spells.ThunderClap:callback(function(spell, logic)
if player.enemiesaround(8) > 0 then
return spell:cast(player)
end
end)

Distance and AOE Check

spells.ShieldCharge:callback(function(spell, logic)
if target.enemiesaround(8) > 0 and target.distanceto(player) <= 10 then
return spell:cast(target)
end
end)

Arc Check for Cleave Spells

spells.Revenge:callback(function(spell, logic)
Aurora.activeenemies:each(function(enemy)
if enemy.inarcof(player, 8, 180) then
return spell:cast(player)
end
end)
end)

Execute Phase Spell

spells.Execute:callback(function(spell, logic)
Aurora.activeenemies:each(function(enemy)
if enemy.hp <= 20 then
return spell:cast(enemy)
end
end)
end)

Common Patterns

Health-Based Decisions

spell:callback(function(spell, logic)
if player.hp < 40 then
return spell:cast(player)
end
end)

Resource-Based Decisions

spell:callback(function(spell, logic)
if player.rage >= 40 then
return spell:cast(target)
end
end)

Enemy Count Checks

spell:callback(function(spell, logic)
if player.enemiesaround(8) >= 3 then
return spell:cast(player)
end
end)

Next Steps

  1. Learn about Unit Properties for more targeting options
  2. Explore Object Manager for advanced unit handling
  3. Study Spell Methods for all available spell actions