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

RevScripts epic idea?? kill boss spawn multi TPS some leads to death some to next room or reward

Lbtg

Advanced OT User
Joined
Nov 22, 2008
Messages
2,368
Reaction score
152
Hey hey , tfs 1.4++ revscrtipt request ask and and idea explotation xd i think its great idea for alot of us :)) please someone if could try to do this

idea:

as you kill boss lets say Orshabaal , you spawn around him where he died 3-7 teleports( in config i shoud be aible to set how much tps it spawns on death)
i shoud be aible to set 1 death location or 2 or 3. if i set 1 location but is tps 9 lets say so all 8 wrong tps leads to that 1 location, but if i set 3 locations those 8 wrong tps goes to one of the 3 locations. as example.

and in config i shoud be aible ofc to set right teleport x/y/z where it leads.

Also on all teleports, wrong and right, shoud be a timer then the teleports will dissapear.
and if i can set teleport Ids, diferent like to have different teleports would be also nice. so its like random always.

Also if a script can handle mutliple bosses with also different aible to set settings all would be nice.


I hope i explain it right and someone can assist us with this in my opinion wonderfull IDEA! xd :)
 
Hey hey , tfs 1.4++ revscrtipt request ask and and idea explotation xd i think its great idea for alot of us :)) please someone if could try to do this

idea:

as you kill boss lets say Orshabaal , you spawn around him where he died 3-7 teleports( in config i shoud be aible to set how much tps it spawns on death)
i shoud be aible to set 1 death location or 2 or 3. if i set 1 location but is tps 9 lets say so all 8 wrong tps leads to that 1 location, but if i set 3 locations those 8 wrong tps goes to one of the 3 locations. as example.

and in config i shoud be aible ofc to set right teleport x/y/z where it leads.

Also on all teleports, wrong and right, shoud be a timer then the teleports will dissapear.
and if i can set teleport Ids, diferent like to have different teleports would be also nice. so its like random always.

Also if a script can handle mutliple bosses with also different aible to set settings all would be nice.


I hope i explain it right and someone can assist us with this in my opinion wonderfull IDEA! xd :)
This should do the trick:
LUA:
local bosses = {
    ["orshabaal"] = {
        teleportDuration = 120,                        -- duration of a teleport in seconds
        teleportIDs = {1387, 1387},                    -- item ids of all random teleports
        teleportRadius = 5,                            -- the radius range around the corpse of where it can spawn
        teleportAmount = 9,                            -- amount of teleports INCLUDING the correct one
        correctDestination = Position(500, 500, 7),    -- destination of the correct teleport
        decoyDestinations = {                          -- destinations of the decoy teleports
            Position(500, 500, 7),
            Position(500, 500, 7),
            Position(500, 500, 7),
        }
    },
    ["morgaroth"] = {
        teleportDuration = 120,                        -- duration of a teleport in seconds
        teleportIDs = {1387, 1387},                    -- item ids of all random teleports
        teleportRadius = 5,                            -- the radius range around the corpse of where it can spawn
        teleportAmount = 9,                            -- amount of teleports INCLUDING the correct one
        correctDestination = Position(500, 500, 7),    -- destination of the correct teleport
        decoyDestinations = {                          -- destinations of the decoy teleports
            Position(500, 500, 7),
            Position(500, 500, 7),
            Position(500, 500, 7),
        }
    },
}

for _, bossData in pairs(bosses) do
    bossData.store = {}
end

local function removeTeleports(key)
    local data = bosses[key]
    if not data then
        return
    end
 
    local store = data.store
    for _, item in ipairs(store) do
        if item and type(item) == 'userdata' then
            item:remove()
        end
    end
 
    store = {}
end

local deathTPs = CreatureEvent("deathTPs")
function deathTPs.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if not creature or not creature:isMonster() then
        return true
    end
 
    local bossName = creature:getName():lower()
    local data = bosses[bossName]
    if not data then
        return true
    end
 
    local position = corpse:getPosition()
    for i = 1, data.teleportAmount do
        local spawnPos, attempts = nil, 0
        repeat
            local _pos = {
                x = position.x + math.random(-data.teleportRadius, data.teleportRadius),
                y = position.y + math.random(-data.teleportRadius, data.teleportRadius),
                z = position.z
            }
            local _tile = Tile(_pos)
            local _suitable = true
     
            --there are probably more checks you want to do below
            if _tile
            and _tile:getGround()
            and not _tile:hasFlag(TILESTATE_NONE)
            and not _tile:hasFlag(TILESTATE_BLOCKSOLID)
            and not _tile:hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID)
            and not _tile:getTopCreature() then
                local _items = _tile:getItems()
                if _items then
                    for _, _item in ipairs(_items) do
                        if table.contains(data.teleportIDs, _item:getId()) then
                            _suitable = false
                            break
                        end
                    end
                end
         
                if _suitable then
                    spawnPos = _pos
                end
            end
            attempts = attempts + 1
        until spawnPos ~= nil or attempts == 50
 
        if spawnPos then
            local teleportId = data.teleportIDs[math.random(#data.teleportIDs)]
            local teleport = Game.createItem(teleportId, 1, spawnPos)
            if teleport then
                if i == 1 then
                    teleport:setDestination(data.correctDestination)
                else
                    local randomDestination = data.decoyDestinations[math.random(#data.decoyDestinations)]
                    teleport:setDestination(randomDestination)
                end
    
                table.insert(data.store, teleport)
            end
        end
    end
 
    addEvent(removeTeleports, data.teleportDuration * 1000, bossName)
    return true
end
deathTPs:register()

Make sure you register "deathTPs" as an event to each boss in their monster XML/lua:
XML:
<script>
    <event name="deathTPs"/>
</script>
 
Last edited by a moderator:

Similar threads

Back
Top