• 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!

Lua Neutral Matter

duuh duuh

New Member
Joined
Jul 13, 2011
Messages
43
Reaction score
0
Guys,

I'm having a problem in Elemental Spheres Quest... Let's get to the point...

: When I use the Obsidian Knigt on The Lord Of Elements in order to get the item Neutral Matter nothing happend...

elemental machine.lua
Code:
local aids = {
    [4129] = {voc = 5, item = 8304, pos = {x = 33263, y = 31810, z = 12}},
    [4130] = {voc = 6, item = 8305, pos = {x = 33263, y = 31860, z = 12}},
    [4131] = {voc = 7, item = 8300, pos = {x = 33292, y = 31831, z = 12}},
    [4132] = {voc = 8, item = 8306, pos = {x = 33243, y = 31831, z = 12}},
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local p = Player(cid)
    local tab = aids[itemEx.actionid]

    local voc = p:getVocation():getId()
    if not tab or tab.voc ~= voc or tab.item ~= item.itemid or not isInArray({7913, 7914, 7911, 7912}, itemEx.itemid) then
        return false
    end

    local p = tab.pos

    if voc == 5 or voc == 6 then
        local p = tab.pos
        local machine1 = Tile(p):getItemById(7913)
        machine1:transform(8896)

        local machine2 = Tile({x = p.x, y = p.y + 1, z = p.z}):getItemById(7914)
        machine2:transform(8897)
    else
        local p = tab.pos
        local machine1 = Tile(p):getItemById(7912)
        machine1:transform(8895)

        local machine2 = Tile({x = p.x - 1, y = p.y, z = p.z}):getItemById(7911)
        machine2:transform(8894)
    end

    toPosition:sendMagicEffect(12)
    Item(item.uid):remove(1)
    return true
end

switch.lua
Code:
local positions = {
    [5] = {pos = {old = {x = 33268, y = 31833, z = 10}, new = {x = 33272, y = 31831, z = 12}}, itemid = 8304}, -- Sorcerer
    [6] = {pos = {old = {x = 33268, y = 31838, z = 10}, new = {x = 33263, y = 31840, z = 12}}, itemid = 8305}, -- Druid
    [7] = {pos = {old = {x = 33270, y = 31835, z = 10}, new = {x = 33263, y = 31831, z = 12}}, itemid = 8300}, -- Paladin
    [8] = {pos = {old = {x = 33266, y = 31835, z = 10}, new = {x = 33263, y = 31831, z = 12}}, itemid = 8306}, -- Knight

}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local p = Player(cid)
    if Tile({x = 33269, y = 31837, z = 12}):getItemById(5071) then
    --if getTileItemById({x = 33269, y = 31837, z = 12}, 5071).uid > 100 then
        return true
    end

    for vocation, info in pairs(positions) do
        local pid = Tile(info.pos.old):getTopCreature()

        if not pid or not pid:isPlayer() or pid:getVocation() ~= vocation or pid:getItemCount(info.itemid) < 1 then
            p:say("You need one player of each vocation having completed the Elemental Spheres quest and also carrying the elemental rare item.", TALKTYPE_MONSTER_SAY)
            return true
        end

    end

    if #getCreaturesInArea({x = 33241, y = 31815, z = 12}, {x = 33300, y = 31874, z = 12}, true) > 0 then
        p:say("A team is facing Lord of the Elements.", TALKTYPE_MONSTER_SAY)
        return true
    end

    for _, v in pairs(positions) do
        local pid = Tile(v.pos.old):getTopCreature()
        pid:getPosition():sendMagicEffect()
        pid:teleportTo(v.pos.new)
        Game.createMonster("Lord Of The Elements", {x = 33270, y = 31845, z = 12})
        pid:getPosition():sendMagicEffect(10)
    end

    return false
end

soil.lua
Code:
local aids = {
    [4120] = {used_id = 8299, target_id = 8573, effect = 3, transform_id = 8575, create_id = 0, sto = 40064}, -- Sorcerer
    [4121] = {used_id = 8303, target_id = 8567, effect = 29, transform_id = 0, create_id = 1491, sto = 40065}, -- Knight
    [4122] = {used_id = 8302, target_id = 8571, effect = 29, transform_id = 8574, create_id = 0, sto = 40066}, -- Paladin
    [4123] = {used_id = 8298, target_id = 8572, effect = 29, transform_id = 8576, create_id = 0, sto = 40067}, -- Druids
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local soil = aids[itemEx.actionid]
    if soil and item.itemid == soil.used_id  and itemEx.itemid == soil.target_id then

        if soil.create_id ~= 0 then
            Game.createItem(soil.create_id, 1, toPosition)
            addEvent(function()
                Tile(toPosition):getItemById(soil.create_id):remove(1)
                --doRemoveItem(getTileItemById(toPosition, create_id).uid, 1)
            end, 30000)
        else
            addEvent(function(aid)
                Tile(toPosition):getItemById(soil.transform_id):transform(aid)
                --doTransformItem(getTileItemById(toPosition, soil.transform_id).uid, aid)
            end, 30000, itemEx.itemid)

            Item(itemEx.uid):transform(soil.transform_id)
            --doTransformItem(itemEx.uid, soil.transform_id)

            Item(item.uid):remove(1)
            --doRemoveItem(item.uid, 1)
        end

        fromPosition:sendDistanceEffect(toPosition, soil.effect)
        --doSendDistanceShoot(fromPosition, toPosition, soil.effect)
        Item(item.uid):remove(1)
        return true
    end

    return false
end
 
lord_switch.lua
Code:
local vocs = {
        [5] = {x = 33180, y = 32198, z = 13},
        [6] = {x = 33329, y = 32075, z = 13},
        [7] = {x = 33262, y = 32201, z = 13},
        [8] = {x = 33085, y = 32095, z = 13},
}

function onUse(cid, item, fromPosition, itemEx, tp)
        local p = Player(cid)

        if isInArray({7915, 7916}, item.itemid) then
                if item.itemid == 7915 then
                        Tile({x = tp.x + 1, y = tp.y, z = tp.z}):getItemById(7916):transform(8895)
                        --doTransformItem(getTileItemById({x = tp.x + 1, y = tp.y, z = tp.z}, 7916).uid, 8895)
                        Item(item.uid):transform(8894) --doTransformItem(item.uid, 8894)
                else
                        Tile({x = tp.x - 1, y = tp.y, z = tp.z}):getItemById(7915):transform(8894)
                        --doTransformItem(getTileItemById({x = tp.x - 1, y = tp.y, z = tp.z}, 7915).uid, 8894)
                        Item(item.uid):transform(8895) --doTransformItem(item.uid, 8895)
                end

                tp:sendMagicEffect(12)
                p:say("ON", TALKTYPE_ORANGE_1, false, cid, (tp or getCreaturePosition(cid)))
                if p:getStorageValue(60026) == 20 then
                        Position(getThingPos(cid)):sendMagicEffect(10)
                        p:teleportTo(vocs[p:getVocation():getId()])
                        p:getPosition():sendMagicEffect(10)
                        --Position(vocs[p:getVocation():getId()]):sendMagicEffect(10)

                        p:setStorageValue(60026, -1)
                end
        else
                if item.itemid == 8894 then
                        Tile({x = tp.x + 1, y = tp.y, z = tp.z}):getItemById(7916):transform(8895)
                        --doTransformItem(getTileItemById({x = tp.x + 1, y = tp.y, z = tp.z}, 8895).uid, 7916)
                        Item(item.uid):transform(7915)
                        --doTransformItem(item.uid, 7915)
                else
                        Tile({x = tp.x - 1, y = tp.y, z = tp.z}):getItemById(8894):transform(7915)
                        --doTransformItem(getTileItemById({x = tp.x - 1, y = tp.y, z = tp.z}, 8894).uid, 7915)

                        Item(item.uid):transform(7916)
                        --doTransformItem(item.uid, 7916)
                end
                p:say("OFF", TALKTYPE_ORANGE_1, false, cid, (tp or getCreaturePosition(cid)))
        end

        return true
end

soil.lua
Code:
-- AJEITAR 8575 ANTES NO FIRE

local aids = {
    [4120] = {used_id = 8299, target_id = 8573, effect = 3, transform_id = 8575, create_id = 0, sto = 40064}, -- Sorcerer
    [4121] = {used_id = 8303, target_id = 8567, effect = 29, transform_id = 0, create_id = 1491, sto = 40065}, -- Knight
    [4122] = {used_id = 8302, target_id = 8571, effect = 29, transform_id = 8574, create_id = 0, sto = 40066}, -- Paladin
    [4123] = {used_id = 8298, target_id = 8572, effect = 29, transform_id = 8576, create_id = 0, sto = 40067}, -- Druids
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local soil = aids[itemEx.actionid]
    if soil and item.itemid == soil.used_id  and itemEx.itemid == soil.target_id then

        if soil.create_id ~= 0 then
            Game.createItem(soil.create_id, 1, toPosition)
            addEvent(function()
                Tile(toPosition):getItemById(soil.create_id):remove(1)
                --doRemoveItem(getTileItemById(toPosition, create_id).uid, 1)
            end, 30000)
        else
            addEvent(function(aid)
                Tile(toPosition):getItemById(soil.transform_id):transform(aid)
                --doTransformItem(getTileItemById(toPosition, soil.transform_id).uid, aid)
            end, 30000, itemEx.itemid)

            Item(itemEx.uid):transform(soil.transform_id)
            --doTransformItem(itemEx.uid, soil.transform_id)

            Item(item.uid):remove(1)
            --doRemoveItem(item.uid, 1)
        end

        fromPosition:sendDistanceEffect(toPosition, soil.effect)
        --doSendDistanceShoot(fromPosition, toPosition, soil.effect)
        Item(item.uid):remove(1)
        return true
    end

    return false
end
 
what tfs are you using? ( i assume tfs 1.0?)

use
print("is this script registrated")
on first line on each function to see did you even registrate the actions.
 
this is TFS 1.0 function

function onUse(cid, item, fromPosition, itemEx, toPosition)

in TFS 1.2
first, 2nd and 4th parameters are userdata values.

rework your entire script.
 
Rework everything?
The only thing that's not working is when I use the obdisian in the dead monster... The rest is working perfectly.. Isnt easier write only that step? @whitevo
 
The rest is working perfectly.. Isnt easier write only that step?
It is broken script!


replace your onUse function with this:
function onUse(p, item, frompos, itemEx, topos)

then on next lines add this:
Code:
local cid = p:getId()
local itemID = item:getId()
local itemAID = item:getActionId()

if you use itemEx on the function, add more lines:
Code:
if not itemEx then return false end
local itemExID = itemEx:getId()
local itemExAID = itemEx:getActionId()

now replace all the TFS 1.0 incorrect items and itemEx things.
 
@whitevo kkkk a long time coding

well looking here i found something that would be excelent i my "POV".. but still the same sh*t when using the knife on the body.... look

actions/lever.lua
Code:
local config = {
    {position = Position(33270, 31835, 10), itemid = 8300, toPosition = Position(33270, 31835, 12), vocationId = 3},
    {position = Position(33268, 31838, 10), itemid = 8305, toPosition = Position(33267, 31838, 12), vocationId = 2},
    {position = Position(33266, 31835, 10), itemid = 8306, toPosition = Position(33265, 31835, 12), vocationId = 4},
    {position = Position(33268, 31833, 10), itemid = 8304, toPosition = Position(33268, 31833, 12), vocationId = 1}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid ~= 1945 then
        item:transform(1945)
        return true
    end

    if player:getPosition() ~= Position(33270, 31835, 10) then
        return false
    end

    local spectators = Game.getSpectators(Position(33268, 31836, 12), false, true, 30, 30, 30, 30)
    if #spectators > 0 or Game.getStorageValue(GlobalStorage.ElementalSphere.BossRoom) > 0 then
        player:say('Wait for the current team to exit.', TALKTYPE_MONSTER_SAY, false, 0, Position(33268, 31835, 10))
        return true
    end

    local players = {}
    for i = 1, #config do
        local creature = Tile(config[i].position):getTopCreature()
        if not creature or not creature:isPlayer() then
            player:say('You need one player of each vocation having completed the Elemental Spheres quest and also carrying the elemental rare item.', TALKTYPE_MONSTER_SAY, false, 0, Position(33268, 31835, 10))
            return true
        end

        local vocationId = creature:getVocation():getBase():getId()
        if vocationId ~= config[i].vocationId or creature:getItemCount(config[i].itemid) < 1 or creature:getStorageValue(Storage.ElementalSphere.QuestLine) < 2 then
            player:say('You need one player of each vocation having completed the Elemental Spheres quest and also carrying the elemental rare item.', TALKTYPE_MONSTER_SAY, false, 0, Position(33268, 31835, 10))
            return true
        end

        players[#players + 1] = creature
    end

    for i = 1, #players do
        players[i]:teleportTo(config[i].toPosition)
        config[i].position:sendMagicEffect(CONST_ME_TELEPORT)
        config[i].toPosition:sendMagicEffect(CONST_ME_TELEPORT)
    end

    item:transform(item.itemid + 1)
    return true
end

actions/machine.lua
Code:
local config = {
    [1] = Position(33183, 32197, 13),
    [2] = Position(33331, 32076, 13),
    [3] = Position(33265, 32202, 13),
    [4] = Position(33087, 32096, 13)
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isInArray({7911, 7912}, item.itemid) then
        local gemCount = player:getStorageValue(Storage.ElementalSphere.MachineGemCount)
        if isInArray({33268, 33269}, toPosition.x) and toPosition.y == 31830 and toPosition.z == 10 and gemCount >= 20 then
            player:setStorageValue(Storage.ElementalSphere.MachineGemCount, gemCount - 20)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(config[player:getVocation():getBase():getId()], false)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        end
        toPosition.x = toPosition.x + (item.itemid == 7911 and 1 or -1)
        local tile = toPosition:getTile()
        if tile then
            local thing = tile:getItemById(item.itemid == 7911 and 7912 or 7911)
            if thing then
                thing:transform(thing.itemid + 4)
            end
        end
        item:transform(item.itemid + 4)
    else
        toPosition.x = toPosition.x + (item.itemid == 7915 and 1 or -1)
        local tile = toPosition:getTile()
        if tile then
            local thing = tile:getItemById(item.itemid == 7915 and 7916 or 7915)
            if thing then
                thing:transform(thing.itemid - 4)
            end
        end
        item:transform(item.itemid - 4)
    end
    return true
end

actions/machine2.lua
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not isInRange(toPosition, Position(33238, 31806, 12), Position(33297, 31865, 12)) then
        return false
    end

    if isInArray({7913, 7914}, item.itemid) then
        toPosition.y = toPosition.y + (item.itemid == 7913 and 1 or -1)
        local machineItem = Tile(toPosition):getItemById(item.itemid == 7913 and 7914 or 7913)
        if machineItem then
            machineItem:transform(machineItem.itemid + 4)
        end
        item:transform(item.itemid + 4)
        player:say('ON', TALKTYPE_MONSTER_SAY, false, player, toPosition)
    else
        toPosition.y = toPosition.y + (item.itemid == 7917 and 1 or -1)
        local machineItem = Tile(toPosition):getItemById(item.itemid == 7917 and 7918 or 7917)
        if machineItem then
            machineItem:transform(machineItem.itemid - 4)
        end
        item:transform(item.itemid - 4)
        player:say('OFF', TALKTYPE_MONSTER_SAY, false, player, toPosition)
    end
    return true
end
 
actions/OAELever.lua
Code:
local config = {
    exitPosition = Position(33265, 31838, 10),
    area = {
        from = Position(33238, 31806, 12),
        to = Position(33297, 31865, 12)
    },
    positions = {
        Position(33272, 31840, 12),
        Position(33263, 31840, 12),
        Position(33263, 31831, 12),
        Position(33272, 31831, 12)
    },
    leverPositions = {
        Position(33273, 31831, 12),
        Position(33273, 31840, 12),
        Position(33262, 31840, 12),
        Position(33262, 31831, 12)
    },
    walls = {
        {from = Position(33275, 31834, 12), to = Position(33275, 31838, 12), wallId = 5072, soundPosition = Position(33275, 31836, 12)},
        {from = Position(33266, 31843, 12), to = Position(33270, 31843, 12), wallId = 5071, soundPosition = Position(33268, 31843, 12)},
        {from = Position(33260, 31834, 12), to = Position(33260, 31838, 12), wallId = 5072, soundPosition = Position(33260, 31836, 12)},
        {from = Position(33266, 31828, 12), to = Position(33270, 31828, 12), wallId = 5071, soundPosition = Position(33268, 31828, 12)}
    },
    roomArea = {
        from = Position(33261, 31829, 12),
        to = Position(33274, 31842, 12)
    },
    machineStorages = {GlobalStorage.ElementalSphere.Machine1, GlobalStorage.ElementalSphere.Machine2, GlobalStorage.ElementalSphere.Machine3, GlobalStorage.ElementalSphere.Machine4},
    centerPosition = Position(33267, 31836, 12),
    effectPositions = {
        Position(33261, 31829, 12), Position(33262, 31830, 12), Position(33263, 31831, 12),
        Position(33264, 31832, 12), Position(33265, 31833, 12), Position(33266, 31834, 12),
        Position(33267, 31835, 12), Position(33268, 31836, 12), Position(33269, 31837, 12),
        Position(33270, 31838, 12), Position(33271, 31839, 12), Position(33272, 31840, 12),
        Position(33273, 31841, 12), Position(33274, 31842, 12), Position(33274, 31829, 12),
        Position(33273, 31830, 12), Position(33272, 31831, 12), Position(33271, 31832, 12),
        Position(33270, 31833, 12), Position(33269, 31834, 12), Position(33268, 31835, 12),
        Position(33267, 31836, 12), Position(33266, 31837, 12), Position(33265, 31838, 12),
        Position(33264, 31839, 12), Position(33263, 31840, 12), Position(33262, 31841, 12),
        Position(33261, 31842, 12)
    }
}


local function resetRoom(players)
    for i = 1, #players do
        local player = Player(players[i])
        if player and isInRange(player:getPosition(), config.area.from, config.area.to) then
            player:teleportTo(config.exitPosition)
            config.exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
        end
    end

    for i = 1, #config.walls do
        local wall = config.walls[i]
        for x = wall.from.x, wall.to.x do
            for y = wall.from.y, wall.to.y do
                local wallItem = Tile(Position(x, y, wall.from.z)):getItemById(wall.wallId)
                if wallItem then
                    wallItem:remove()
                end
            end
        end
    end

    local creature = Creature('lord of the elements')
    if creature then
        creature:remove()
    end

    for i = 1, #config.leverPositions do
        local leverItem = Tile(config.leverPositions[i]):getItemById(1946)
        if leverItem then
            leverItem:transform(1945)
        end
    end

    Game.setStorageValue(GlobalStorage.ElementalSphere.BossRoom, -1)
    for i = 1, #config.machineStorages do
        Game.setStorageValue(config.machineStorages[i], -1)
    end
    return true
end

local function warnPlayers(players)
    local player
    for i = 1, #players do
        player = Player(players[i])
        if player and isInRange(player:getPosition(), config.roomArea.from, config.roomArea.to) then
            break
        end
        player = nil
    end

    if not player then
        return
    end

    player:say('You have 5 minutes from now on until you get teleported out.', TALKTYPE_MONSTER_YELL, false, 0, Position(33266, 31835, 13))
end

local function areMachinesCharged()
    for i = 1, #config.machineStorages do
        if Game.getStorageValue(config.machineStorages[i]) <= 0 then
            return false
        end
    end
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid ~= 1945 then
        return true
    end

    for i = 1, #config.machineStorages do
        Game.setStorageValue(config.machineStorages[i], 1)
    end

    if not areMachinesCharged() then
        return false
    end

    local index = table.find(config.positions, player:getPosition())
    if not index then
        return false
    end

    item:transform(1946)
    local leverCount = 0
    for i = 1, #config.leverPositions do
        if Tile(config.leverPositions[i]):getItemById(1946) then
            leverCount = leverCount + 1
        end
    end

    local walls = config.walls[index]
    for x = walls.from.x, walls.to.x do
        for y = walls.from.y, walls.to.y do
            Game.createItem(walls.wallId, 1, Position(x, y, walls.from.z))
        end
    end
    player:say('ZOOOOOOOOM', TALKTYPE_MONSTER_SAY, false, 0, walls.soundPosition)

    if leverCount ~= #config.leverPositions then
        return true
    end

    local players = {}
    for i = 1, #config.positions do
        local creature = Tile(config.positions[i]):getTopCreature()
        if creature then
            players[#players + 1] = creature.uid
        end
    end

    Game.setStorageValue(GlobalStorage.ElementalSphere.BossRoom, 1)
    Game.createMonster('Lord of the Elements', config.centerPosition)
    player:say('You have 10 minutes from now on until you get teleported out.', TALKTYPE_MONSTER_YELL, false, 0, config.centerPosition)
    addEvent(warnPlayers, 5 * 60 * 1000, players)
    addEvent(resetRoom, 10 * 60 * 1000, players)

    for i = 1, #config.effectPositions do
        config.effectPositions[i]:sendMagicEffect(CONST_ME_ENERGYHIT)
    end
    return true
end

actions/soils.lua
Code:
local config = {
    [8298] = {targetId = 8572, transformId = 8576, effect = CONST_ME_BIGPLANTS},
    [8299] = {targetId = 8573, transformId = 8575},
    [8302] = {targetId = 8571, transformId = 8574, effect = CONST_ME_ICEATTACK},
    [8303] = {targetId = 8567, createId = 1495}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local soil = config[item.itemid]
    if not soil then
        return true
    end

    if soil.targetId ~= target.itemid then
        return true
    end

    if soil.transformId then
        target:transform(soil.transformId)
        target:decay()
    elseif soil.createId then
        local newItem = Game.createItem(soil.createId, 1, toPosition)
        if newItem then
            newItem:decay()
        end
    end

    if soil.effect then
        toPosition:sendMagicEffect(soil.effect)
    end

    item:transform(item.itemid, item.type - 1)
    return true
end

actions/soils2.lua
Code:
local spheres = {
    [8300] = {3, 7},
    [8304] = {1, 5},
    [8305] = {2, 6},
    [8306] = {4, 8}
}

local globalTable = {
    [1] = 10005,
    [2] = 10006,
    [3] = 10007,
    [4] = 10008
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not isInArray({7917, 7918, 7913, 7914}, target.itemid) then
        return false
    end

    if not isInRange(toPosition, {x=33238, y=31806, z=12}, {x=33297, y=31865, z=12}) then
        return false
    end

    if not isInArray(spheres[item.itemid], player:getVocation():getId()) then
        return false
    end

    if isInArray({7917, 7918}, target.itemid) then
        player:say('Turn off the machine first.', TALKTYPE_MONSTER_SAY)
        return true
    end

    toPosition:sendMagicEffect(CONST_ME_PURPLEENERGY)
    Game.setStorageValue(globalTable[player:getVocation():getBase():getId()], 1)
    item:remove(1)
    return true
end
 
creaturescripts/overlordkills.lua
Code:
local overlords = {
    ['energy overlord'] = {cStorage = Storage.ElementalSphere.BossStorage, cGlobalStorage = GlobalStorage.ElementalSphere.KnightBoss},
    ['fire overlord'] = {cStorage = Storage.ElementalSphere.BossStorage, cGlobalStorage = GlobalStorage.ElementalSphere.SorcererBoss},
    ['ice overlord'] = {cStorage = Storage.ElementalSphere.BossStorage, cGlobalStorage = GlobalStorage.ElementalSphere.PaladinBoss},
    ['earth overlord'] = {cStorage = Storage.ElementalSphere.BossStorage, cGlobalStorage = GlobalStorage.ElementalSphere.DruidBoss},
    ['lord of the elements'] = {}
}

function onKill(creature, target)
    if not target:isMonster() then
        return true
    end

    local bossName = target:getName()
    local bossConfig = overlords[bossName:lower()]
    if not bossConfig then
        return true
    end

    if bossConfig.cGlobalStorage then
        Game.setStorageValue(bossConfig.cGlobalStorage, 0)
    end

    if bossConfig.cStorage and creature:getStorageValue(bossConfig.cStorage) < 1 then
        creature:setStorageValue(bossConfig.cStorage, 1)
    end

    creature:say('You slayed ' .. bossName .. '.', TALKTYPE_MONSTER_SAY)
    return true
end

movements/summonOverlord.lua
Code:
local config = {
    [8568] = {
        storage = GlobalStorage.ElementalSphere.KnightBoss,
        corpse = 8967,
        charged = 1495,
        inactive = 0,
        boss = 'Energy Overlord',
        effect = CONST_ME_BIGCLOUDS,
        summonPos = Position(33095, 32194, 13),
        positions = {
            Position(33094, 32189, 13),
            Position(33097, 32189, 13),
            Position(33099, 32191, 13),
            Position(33099, 32194, 13),
            Position(33097, 32196, 13),
            Position(33094, 32196, 13),
            Position(33092, 32194, 13),
            Position(33092, 32191, 13)
        }
    },
    [8569] = {
        storage = GlobalStorage.ElementalSphere.SorcererBoss,
        corpse = 8969,
        charged = 8575,
        inactive = 8573,
        boss = 'Fire Overlord',
        effect = CONST_ME_FIREAREA,
        summonPos = Position(33199, 32103, 13),
        positions = {
            Position(33198, 32102, 13),
            Position(33201, 32102, 13),
            Position(33203, 32104, 13),
            Position(33203, 32107, 13),
            Position(33201, 32109, 13),
            Position(33198, 32109, 13),
            Position(33196, 32107, 13),
            Position(33196, 32104, 13)
        }
    },
    [8570] = {
        storage = GlobalStorage.ElementalSphere.PaladinBoss,
        corpse = 8968,
        charged = 8574,
        inactive = 8571,
        boss = 'Ice Overlord',
        effect = CONST_ME_ICETORNADO,
        summonEffect = CONST_ME_ICEAREA,
        summonPos = Position(33286, 32102, 13),
        positions = {
            Position(33285, 32097, 13),
            Position(33288, 32097, 13),
            Position(33290, 32099, 13),
            Position(33290, 32102, 13),
            Position(33288, 32104, 13),
            Position(33285, 32104, 13),
            Position(33283, 32102, 13),
            Position(33283, 32099, 13)
        }
    },
    [8578] = {
        storage = GlobalStorage.ElementalSphere.DruidBoss,
        corpse = 8934,
        charged = 8576,
        inactive = 8572,
        boss = 'Earth Overlord',
        effect = CONST_ME_BIGPLANTS,
        summonPos = Position(33347, 32208, 13),
        positions = {
            Position(33346, 32203, 13),
            Position(33349, 32203, 13),
            Position(33351, 32205, 13),
            Position(33351, 32208, 13),
            Position(33349, 32210, 13),
            Position(33346, 32210, 13),
            Position(33344, 32208, 13),
            Position(33344, 32205, 13)
        }
    }
}

function onAddItem(moveitem, tileitem, position)
    local target = config[tileitem.itemid]
    if not target then
        return true
    end

    local cStorage = target.storage
    if target.corpse ~= moveitem.itemid or Game.getStorageValue(cStorage) == 1 then
        return true
    end

    for i = 1, #target.positions do
        if not Tile(target.positions[i]):getItemById(target.charged) then
            return true
        end
    end

    moveitem:remove()
    position:sendMagicEffect(target.effect)
    target.summonPos:sendMagicEffect(target.summonEffect or target.effect)
    Game.createMonster(target.boss, target.summonPos)
    Game.setStorageValue(cStorage, 1)
    return true
end

movements/AOETeleportOut.lua
Code:
local config = {
    [8568] = {
        storage = GlobalStorage.ElementalSphere.KnightBoss,
        corpse = 8967,
        charged = 1495,
        inactive = 0,
        boss = 'Energy Overlord',
        effect = CONST_ME_BIGCLOUDS,
        summonPos = Position(33095, 32194, 13),
        positions = {
            Position(33094, 32189, 13),
            Position(33097, 32189, 13),
            Position(33099, 32191, 13),
            Position(33099, 32194, 13),
            Position(33097, 32196, 13),
            Position(33094, 32196, 13),
            Position(33092, 32194, 13),
            Position(33092, 32191, 13)
        }
    },
    [8569] = {
        storage = GlobalStorage.ElementalSphere.SorcererBoss,
        corpse = 8969,
        charged = 8575,
        inactive = 8573,
        boss = 'Fire Overlord',
        effect = CONST_ME_FIREAREA,
        summonPos = Position(33199, 32103, 13),
        positions = {
            Position(33198, 32102, 13),
            Position(33201, 32102, 13),
            Position(33203, 32104, 13),
            Position(33203, 32107, 13),
            Position(33201, 32109, 13),
            Position(33198, 32109, 13),
            Position(33196, 32107, 13),
            Position(33196, 32104, 13)
        }
    },
    [8570] = {
        storage = GlobalStorage.ElementalSphere.PaladinBoss,
        corpse = 8968,
        charged = 8574,
        inactive = 8571,
        boss = 'Ice Overlord',
        effect = CONST_ME_ICETORNADO,
        summonEffect = CONST_ME_ICEAREA,
        summonPos = Position(33286, 32102, 13),
        positions = {
            Position(33285, 32097, 13),
            Position(33288, 32097, 13),
            Position(33290, 32099, 13),
            Position(33290, 32102, 13),
            Position(33288, 32104, 13),
            Position(33285, 32104, 13),
            Position(33283, 32102, 13),
            Position(33283, 32099, 13)
        }
    },
    [8578] = {
        storage = GlobalStorage.ElementalSphere.DruidBoss,
        corpse = 8934,
        charged = 8576,
        inactive = 8572,
        boss = 'Earth Overlord',
        effect = CONST_ME_BIGPLANTS,
        summonPos = Position(33347, 32208, 13),
        positions = {
            Position(33346, 32203, 13),
            Position(33349, 32203, 13),
            Position(33351, 32205, 13),
            Position(33351, 32208, 13),
            Position(33349, 32210, 13),
            Position(33346, 32210, 13),
            Position(33344, 32208, 13),
            Position(33344, 32205, 13)
        }
    }
}

function onAddItem(moveitem, tileitem, position)
    local target = config[tileitem.itemid]
    if not target then
        return true
    end

    local cStorage = target.storage
    if target.corpse ~= moveitem.itemid or Game.getStorageValue(cStorage) == 1 then
        return true
    end

    for i = 1, #target.positions do
        if not Tile(target.positions[i]):getItemById(target.charged) then
            return true
        end
    end

    moveitem:remove()
    position:sendMagicEffect(target.effect)
    target.summonPos:sendMagicEffect(target.summonEffect or target.effect)
    Game.createMonster(target.boss, target.summonPos)
    Game.setStorageValue(cStorage, 1)
    return true
end
 
Back
Top