-- this section here although initially important
-- handles creating the combat object
local combat = createCombatObject()
-- and the effect in this case magic blue
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
-- this is an area object the AREA_SQUARE1X1 is the region to cast the spell
-- it is a table defined in data/spells/lib/spells.lua
local area = createCombatArea(AREA_SQUARE1X1)
-- this part of the script registers the area object to the combat object
setCombatArea(combat, area)
-- here we have the definition of the callback function
function onTargetCreature(cid, target) return doChallengeCreature(cid, target) end
-- here we are registering the callback function to the combat object so that
-- when the spell successfully executes it executes the callback function causing the effect
-- of challenging the creature
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
-- this is pretty obvious and needs no explanation
function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end