I haven't worked so much with spells, and this is the way I used to write spells (mostly smaller ones), so I wanted to know how you would write a spell like this (just a test spell I got from YouTube).
Lately, I have seen this method, but adding different areas doesn't work.

I am trying to learn how to make big spell scripts like this one as small as possible.
Lately, I have seen this method, but adding different areas doesn't work.
Lua:
local arr1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}
local arr2 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 2, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}
local arr3 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}
local arr4 = {
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0},
{1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 2, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1},
{0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0},
{0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0}
}
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYAREA)
combat:setArea(createCombatArea(arr1))
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
combat2:setArea(createCombatArea(arr2))
local combat3 = Combat()
combat3:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat3:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
combat3:setArea(createCombatArea(arr3))
local combat4 = Combat()
combat4:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat4:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKER)
combat4:setArea(createCombatArea(arr4))
function onGetFormulaValues(player, level, magicLevel)
local min = 1
local max = 1
return -min, -max
end
function onGetFormulaValues2(player, level, magicLevel)
local min = 2
local max = 2
return -min, -max
end
function onGetFormulaValues3(player, level, magicLevel)
local min = 3
local max = 3
return -min, -max
end
function onGetFormulaValues4(player, level, magicLevel)
local min = 4
local max = 4
return -min, -max
end
function onTargetTile(creature, position)
creature:getPosition():sendDistanceEffect(position, CONST_ANI_HOLY)
end
function onTargetTileTwo(creature, position)
creature:getPosition():sendDistanceEffect(position, CONST_ANI_HOLY)
end
function onTargetTileThree(creature, position)
creature:getPosition():sendDistanceEffect(position, CONST_ANI_HOLY)
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")
combat3:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues3")
combat4:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues4")
combat2:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")
combat3:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTileTwo")
combat4:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTileThree")
local function castSpell1(creatureId, variant)
local creature = Creature(creatureId)
if not creature then
return
end
combat:execute(creature, variant)
end
local function castSpell2(creatureId, variant)
local creature = Creature(creatureId)
if not creature then
return
end
combat2:execute(creature, variant)
end
local function castSpell3(creatureId, variant)
local creature = Creature(creatureId)
if not creature then
return
end
combat3:execute(creature, variant)
end
local function castSpell4(creatureId, variant)
local creature = Creature(creatureId)
if not creature then
return
end
combat4:execute(creature, variant)
end
function onCastSpell(creature, variant)
castSpell1(creature, variant)
addEvent(castSpell2, 100, creature:getId(), variant)
addEvent(castSpell3, 250, creature:getId(), variant)
addEvent(castSpell4, 500, creature:getId(), variant)
return true
end

I am trying to learn how to make big spell scripts like this one as small as possible.
Last edited: