• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Spell Storm of the Century

Needs some editing.
Code:
for i = 1, #config.effectType[1] do
if(efc < config.effectType[1][i]) then
  eff = config.effectType[2][i]
  break
else
  efc = efc - config.effectType[1][i]
end
end

look at line 28 and replace it with the above. Might still be some errors
A few left it seems :p
No error during start-up, this appears when casting spell now.
Code:
[6:11:43.653] [Error - Spell Interface]
[6:11:43.654] data/spells/scripts/wizard skills/storm of the century.lua:onCastSpell
[6:11:43.655] Description:
[6:11:43.656] ...pells/scripts/wizard skills/storm of the century.lua:52: attempt to index field '?' (a nil value)
[6:11:43.656] stack traceback:
[6:11:43.657]  ...pells/scripts/wizard skills/storm of the century.lua:52: in function <...pells/scripts/wizard skills/storm of the century.lua:18>
[6:11:43.657]  (tail call): ?
[6:11:43.803] [Error - Spell Interface]
[6:11:43.804] In a timer event called from:
[6:11:43.805] data/spells/scripts/wizard skills/storm of the century.lua:onCastSpell
[6:11:43.805] Description:
[6:11:43.806] ...pells/scripts/wizard skills/storm of the century.lua:39: attempt to perform arithmetic on field 'y' (a nil value)
[6:11:43.806] stack traceback:
[6:11:43.807]  ...pells/scripts/wizard skills/storm of the century.lua:39: in function <...pells/scripts/wizard skills/storm of the century.lua:18>
Code:
local config = {
minAttacks = 200, --Change the minimum number of attacks here
maxAttacks = 300, --Change the maximum number of attacks here
expansionInterval = 150, --Change here how many ms it takes at max between expansions(it can be a random value between 0 and this value)
spreadPercent = 40, --Change here the expansion %
combatType = COMBAT_ENERGYDAMAGE, --Change here the combat type
effectType = { {90, 10}, {CONST_ME_ENERGYHIT, CONST_ME_BIGCLOUDS} } --Change here the effect types, in the first table you set the chance of each effect to happen(must always sum to 100) and in the second table you set what effects appear
}


local function damageFormula(cid)
local minDmg = (getPlayerLevel(cid) / -5 + getPlayerMagLevel(cid) * 1) * -5 + -5
local maxDmg = (getPlayerLevel(cid) / -5 + getPlayerMagLevel(cid) * 1) * -5 + -12
return {min = minDmg, max = maxDmg}
end


local function stormSpreads(cid, pos, remainingArea)
if remainingArea[1] <= 0 or not isCreature(cid) then
return false
end
remainingArea[1] = remainingArea[1] - 1
local dmg = damageFormula(cid)
--Random effect calculation
local eff = config.effectType[2][1]
local efc = math.random(1, 100)
for i = 1, #config.effectType[1] do
 if(efc < config.effectType[1][i]) then
  eff = config.effectType[2][i]
  break
 else
  efc = efc - config.effectType[1][i]
 end
end
--/Random effect calculation
doCombatAreaHealth(cid, config.combatType, pos, nil, dmg.min, dmg.max, eff)
--Random area calculations
local posArray = {
[1] = {{x = pos.x, y = pos.y - 1, z = pos.z}, {2,4}}, --North
[2] = {{x = pos.x - 1, y = pos.y, z = pos.z}, {1,3}}, --East
[3] = {{x = pos.x, y = pos.y + 1, z = pos.z}, {2,4}}, --South
[4] = {{x = pos.x + 1, y = pos.y, z = pos.z}, {1,3}} --West
}
local i = math.random(1, 4)
addEvent(stormSpreads, config.expansionInterval, cid, posArray[1], remainingArea, i)
if math.random(1, 100) <= config.spreadPercent then
if isSightClear(pos, posArray[posArray[2][1]][1], true) then
addEvent(stormSpreads, math.random(0, config.expansionInterval), cid, posArray[posArray[2][1]][1], remainingArea, i)
end
end
if math.random(1, 100) <= config.spreadPercent then
if isSightClear(pos, posArray[posArray[2][2]][1], true) then
addEvent(stormSpreads, math.random(0, config.expansionInterval), cid, posArray[posArray[2][2]][1], remainingArea, i)
end
end
--/Random area calculations
return true
end


function onCastSpell(cid, var)
return stormSpreads(cid, getCreaturePosition(cid), {math.random(config.minAttacks, config.maxAttacks)})
end
 
For those who are looking for a working script for 0.3.7, look no further. :p
Code:
local config = {
minAttacks = 200, --Change the minimum number of attacks here
maxAttacks = 300, --Change the maximum number of attacks here
expansionInterval = 150, --Change here how many ms it takes at max between expansions(it can be a random value between 0 and this value)
spreadPercent = 40, --Change here the expansion %
combatType = COMBAT_ENERGYDAMAGE, --Change here the combat type
effectType = { {90, 10}, {CONST_ME_ENERGYHIT, CONST_ME_BIGCLOUDS} } --Change here the effect types, in the first table you set the chance of each effect to happen(must always sum to 100) and in the second table you set what effects appear
}


local function damageFormula(cid)
local minDmg = (getPlayerLevel(cid) / -5 + getPlayerMagLevel(cid) * 1) * -5 + -5
local maxDmg = (getPlayerLevel(cid) / -5 + getPlayerMagLevel(cid) * 1) * -5 + -12
return {min = minDmg, max = maxDmg}
end


local function stormSpreads(cid, pos, remainingArea)
if remainingArea[1] <= 0 or not isCreature(cid) then
return false
end
remainingArea[1] = remainingArea[1] - 1
local dmg = damageFormula(cid)
--Random effect calculation
local eff = config.effectType[2][1]
local efc = math.random(1, 100)
for i = 1, #config.effectType[1] do
 if(efc < config.effectType[1][i]) then
  eff = config.effectType[2][i]
  break
 else
  efc = efc - config.effectType[1][i]
 end
end
--/Random effect calculation
doCombatAreaHealth(cid, config.combatType, pos, nil, dmg.min, dmg.max, eff)
--Random area calculations
local posArray = {
[1] = {{x = pos.x, y = pos.y - 1, z = pos.z}, {2,4}}, --North
[2] = {{x = pos.x - 1, y = pos.y, z = pos.z}, {1,3}}, --East
[3] = {{x = pos.x, y = pos.y + 1, z = pos.z}, {2,4}}, --South
[4] = {{x = pos.x + 1, y = pos.y, z = pos.z}, {1,3}} --West
}
local i = math.random(1, 4)
addEvent(stormSpreads, config.expansionInterval, cid, posArray[i][1], remainingArea, i)
if math.random(1, 100) <= config.spreadPercent then
if isSightClear(pos, posArray[posArray[i][2][1]][1], true) then
addEvent(stormSpreads, math.random(0, config.expansionInterval), cid, posArray[posArray[i][2][1]][1], remainingArea, i)
end
end
if math.random(1, 100) <= config.spreadPercent then
if isSightClear(pos, posArray[posArray[i][2][2]][1], true) then
addEvent(stormSpreads, math.random(0, config.expansionInterval), cid, posArray[posArray[i][2][2]][1], remainingArea, i)
end
end
--/Random area calculations
return true
end


function onCastSpell(cid, var)
return stormSpreads(cid, getCreaturePosition(cid), {math.random(config.minAttacks, config.maxAttacks)})
end
 
Back
Top