adrenyslopez
Member
- Joined
- Dec 22, 2015
- Messages
- 201
- Reaction score
- 15
Is it possible to fix this scripts so that I don't get this duplicate for id?
Lua:
local config = {
["Weak Soul"] = {id = 38626, effect = CONST_ME_ICEATTACK, type = COMBAT_ICEDAMAGE},
["Soulsnatcher"] = {id = 38626, effect = CONST_ME_FIREAREA, type = COMBAT_FIREDAMAGE},
}
local area = createCombatArea(AREA_CIRCLE2X2)
local monsters = {"Soulsnatcher", "Weak Soul"}
local soulVortex = MoveEvent()
function soulVortex.onStepIn(creature, item, position, fromPosition)
if creature:isPlayer() or creature:getMaster() then
return true
end
local name = creature:getName()
if not isInArray(monsters, name) then
return true
end
local data = config[name]
position:sendMagicEffect(CONST_ME_MORTAREA)
local gred = Creature("Goshnar's Greed")
if not gred then
return true
end
if data.id == item:getId() then
local oldStorage = gred:getStorageValue(69813)
gred:setStorageValue(69813, oldStorage + 1)
-- remove -1 from storage after 20seconds:
addEvent(function(cid, storage)
local mob = Creature(cid)
if not mob then return end
mob:setStorageValue(69813, storage - 1)
end, 10 * 1000, gred:getId(), oldStorage + 1)
else
if math.random(2) == 2 then
doAreaCombatHealth(creature, data.type, creature:getPosition(), area, -750, -1250, data.effect)
else
doTargetCombatHealth(0, gred, COMBAT_HEALING, 3500, 5500, CONST_ME_NONE)
end
end
creature:remove()
return true
end
soulVortex:type("stepin")
for index, value in pairs(config) do
soulVortex:id(value.id)
end
soulVortex:register()