Code:
function checkAreaForItem(pos, range, item)
local from = {x=pos.x-range, y=pos.y-range, z=pos.z}
local to = {x=pos.x+range, y=pos.y+range, z=pos.z}
for z = from.z, to.z do
for y = from.y, to.y do
for x = from.x, to.x do
local t = Tile(Position(x, y, z))
if t:getItemById(item) then
return true
end
end
end
end
end
function storage()
setGlobalStorageValue(91231522,0)
end
local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 7000)
condition:setFormula(-1111.7333, 0, -11110.9333, 0)
function onCastSpell(creature, var)
local pos = creature:getPosition()
if checkAreaForItem(pos, 2, 36309) and checkAreaForItem(pos, 2, 36310) and checkAreaForItem(pos, 2, 36311) and checkAreaForItem(pos, 2, 36312) and getGlobalStorageValue(91231522) >= 1 then
creature:addCondition(condition)
addEvent(storage, 10000)
end
if checkAreaForItem(pos, 1, 36309) and checkAreaForItem(pos, 1, 36310) and checkAreaForItem(pos, 1, 36311) and checkAreaForItem(pos, 1, 36312) and getGlobalStorageValue(91231522) >= 1 then
creature:addCondition(condition)
addEvent(storage, 10000)
end
if checkAreaForItem(pos, 3, 36309) and checkAreaForItem(pos, 3, 36310) and checkAreaForItem(pos, 3, 36311) and checkAreaForItem(pos, 3, 36312) and getGlobalStorageValue(91231522) >= 1 then
creature:addCondition(condition)
addEvent(storage, 10000)
end
return true
end
- Lua Script Error: [Spell Interface]
- data/spells/scripts/monster/.luanCastSpell
- data/spells/scripts/monster/.lua:8: attempt to index local 't' (a nil value)
- stack traceback:
- [C]: in function '__index'
- data/spells/scripts/monster/.lua:8: in function 'checkAreaForItem'
- data/spells/scripts/monster/.lua:48: in function <data/spells/scripts/monster/.lua:27>
in other script
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
local hp = math.random(2000,7500)
if not creature:isMonster() then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if creature:getName() == "demon" and getGlobalStorageValue(91231522) >= 1 then
if attacker and attacker:isPlayer() then
if primaryDamage > 0 then
print(creature:addHealth(-hp))
end
if secondaryDamage > 0 then
print(creature:addHealth(-hp))
end
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end