- Joined
- Nov 17, 2010
- Messages
- 6,791
- Solutions
- 581
- Reaction score
- 5,354
I've been trying to modify Storm of the Century to work with 0.3.7.. however a few errors keep popping up and I'm not sure how to fix them.
In the edited spell MindRage gave some advise to add some [i.] into the spell to fix the original error message, however the thread has gone dead since then.
My plan is to update the thread with a working 0.3.7 version of the script, however we just need to get it working first!
As always,
I love you all and all comments/feedback/criticism will be taken gladly.
Xikini
In the edited spell MindRage gave some advise to add some [i.] into the spell to fix the original error message, however the thread has gone dead since then.
My plan is to update the thread with a working 0.3.7 version of the script, however we just need to get it working first!
Code:
local config = {
minAttacks = 100, --Change the minimum number of attacks here
maxAttacks = 300, --Change the maximum number of attacks here
expansionInterval = 300, --Change here how many ms it takes at max between expansions(it can be a random value between 0 and this value)
spreadPercent = 20, --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]) then
eff = config.effectType[2]
break
else
efc = efc - config.effectType[1]
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
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
Code:
<instant name="storm of the century" words="lmaorofl" lvl="10" mana="45" prem="0" range="3" casterTargetOrDirection="1" blockwalls="1" exhaustion="3000" groups="1,1000" icon="89" needlearn="0" event="script" value="wizard skills/storm of the century.lua">
<vocation id="1"/>
<vocation id="9"/>
<vocation id="25"/>
<vocation id="26"/>
<vocation id="27"/>
</instant>
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>
I love you all and all comments/feedback/criticism will be taken gladly.
Xikini
Last edited: