• 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 SCRIPT FOR BOSS WITH PORTAL + TIME + STORAGE

nilvagner

Long live the otland.net
Joined
May 3, 2010
Messages
118
Reaction score
3
Location
Brazil
I need a script to be used in CANARY 13.21
I would really appreciate it if anyone could help me! I've been trying for a few days and haven't had any results.

I'll use Amazon's Boss as an example: Xenia

With the following variables:


-- VARIABLES --

-- WHEN KILLING THE CREATURE, A PORTAL APPEARS WITH A TIME PERIOD OF 3 MINUTES
PORTAL LOCATION 32890/31883/9
-- TO USE THIS PORTAL, THE PLAYER MUST CAUSE DAMAGE TO THE BOSS
-- THIS PORTAL MUST LAUNCH THE PLAYER TO A SPECIFIC LOCATION AT 32816/32260/5
-- I NEED TO HAVE STORAGE FOR THOSE WHO USE THE PORTAL
 
Solution
You.. used none of the script I provided. lol
amazing work.

After looking at your files, I've edited my script to work as I think you're expecting.

Just put it into data/scripts as a single file..

Lua:
local config = {
    storage = {
        key = Storage.TheCallinKalys.Mission01,
        requiredValue = 1,
        newValue = 2
    },
    positions = {
        origin = Position(32890, 31883, 9),
        destination = Position(32816, 32260, 5)
    },
    teleportActionId = 32816,
    teleportItemId = 20121,
    teleportDecay = 180 -- seconds
}

local bossDamageMap = {} -- don't edit


local function removeTeleport(position, teleportItemId)
    local tile = Tile(position)
    if not tile then
        print("Error: tile not found...
Register the event to the boss in xml / lua file, depending on your source.

XML
XML:
<script>
    <event name="onDeath_bossPortal" />
</script>
LUA
Lua:
monsterType:registerEvent("onDeath_bossPortal")
Of if you are spawning via script..
Lua:
local monster = Game.createMonster("monsterName", position)
if monster then
    monster:registerEvent("onDeath_bossPortal")
else
    -- monster did not spawn correctly
end

and the rest is just into data/scripts
Lua:
local config = {
    storage = { -- given when using the portal
        key = 45002,
        value = 1
    },
    positions = {
        origin = Position(1001, 1001, 7),
        destination = Position(1001, 1003, 7)
    },
    teleportActionId = 45003,
    teleportItemId = 1387,
    teleportDecay = 180 -- seconds
}

local bossDamageMap = {} -- don't edit


local function removeTeleport(position, teleportItemId)
    local tile = Tile(position)
    if not tile then
        print("Error: tile not found at location")
        return
    end
    local teleport = tile:getItemById(teleportItemId)
    if not teleport then
        return
    end
    teleport:remove()
end

local function countDown(timer, position)
    if timer % 5 == 0 and timer ~= 0 then
        for _, creature in pairs(Game.getPlayers()) do
            creature:say(timer, TALKTYPE_MONSTER_SAY, false, nil, position)
            break
        end
    end
    if timer > 0 then
        addEvent(countDown, 1000, timer - 1, position)
    end
end


local creatureevent = CreatureEvent("onDeath_bossPortal")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- create and remove teleport
    local teleport = Game.createItem(config.teleportItemId, 1, config.positions.origin)
    teleport:setActionId(config.teleportActionId)
    addEvent(removeTeleport, 1000 * config.teleportDecay, config.positions.origin, config.teleportItemId)
    countDown(config.teleportDecay, config.positions.origin)
    -- setup damage map
    bossDamageMap = {}
    for creatureId, damage in pairs(creature:getDamageMap()) do
        local _creature = Creature(creatureId)
        if _creature then
            local master = _creature:getMaster()
            if master and master:isPlayer() then
                _creature = master
            end
            if _creature:isPlayer() then
                local name = _creature:getName()
                bossDamageMap[name] = (bossDamageMap[name] or 0) + damage.total
            end
        end
    end
    return true
end

creatureevent:register()


local moveevent = MoveEvent()

function moveevent.onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        creature:teleportTo(fromPosition, true)
        return false
    end
    if not bossDamageMap[creature:getName()] then
        creature:teleportTo(fromPosition, true)
        return false
    end
    creature:setStorageValue(config.storage.key, config.storage.value)
    creature:teleportTo(config.positions.destination)
    return true
end

moveevent:aid(config.teleportActionId)
moveevent:register()
 
Last edited:
Thanks for the support!
@Xikini
I'm using CANARY 13.21

See my progress...
Kill the boss and the portal appears along with the message: Ok
Enter the portal and reach the informed destination: Ok
Edit portal uptime: Failed
Storage Value, once you use the portal: Failed
Show the quest in the quest player logo: Failed

Can you help me?
 

Attachments

Last edited:
You.. used none of the script I provided. lol
amazing work.

After looking at your files, I've edited my script to work as I think you're expecting.

Just put it into data/scripts as a single file..

Lua:
local config = {
    storage = {
        key = Storage.TheCallinKalys.Mission01,
        requiredValue = 1,
        newValue = 2
    },
    positions = {
        origin = Position(32890, 31883, 9),
        destination = Position(32816, 32260, 5)
    },
    teleportActionId = 32816,
    teleportItemId = 20121,
    teleportDecay = 180 -- seconds
}

local bossDamageMap = {} -- don't edit


local function removeTeleport(position, teleportItemId)
    local tile = Tile(position)
    if not tile then
        print("Error: tile not found at location")
        return
    end
    local teleport = tile:getItemById(teleportItemId)
    if not teleport then
        return
    end
    teleport:remove()
end

local function countDown(timer, position)
    if timer % 5 == 0 and timer ~= 0 then
        for _, creature in pairs(Game.getPlayers()) do
            creature:say(timer, TALKTYPE_MONSTER_SAY, false, nil, position)
            break
        end
    end
    if timer > 0 then
        addEvent(countDown, 1000, timer - 1, position)
    end
end


local creatureevent = CreatureEvent("KillBossDeath")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- create and remove teleport
    local teleport = Game.createItem(config.teleportItemId, 1, config.positions.origin)
    teleport:setActionId(config.teleportActionId)
    addEvent(removeTeleport, 1000 * config.teleportDecay, config.positions.origin, config.teleportItemId)
    countDown(config.teleportDecay, config.positions.origin)
    creature:say("YOU HAVE LITTLE TIME TO ENTER THE PORTAL!", TALKTYPE_ORANGE_1)
    -- setup damage map
    bossDamageMap = {}
    for creatureId, damage in pairs(creature:getDamageMap()) do
        local _creature = Creature(creatureId)
        if _creature then
            local master = _creature:getMaster()
            if master and master:isPlayer() then
                _creature = master
            end
            if _creature:isPlayer() then
                local name = _creature:getName()
                bossDamageMap[name] = (bossDamageMap[name] or 0) + damage.total
            end
        end
    end
    return true
end

creatureevent:register()


local moveevent = MoveEvent()

function moveevent.onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if quest is not started, don't allow access to portal
    if creature:getStorageValue(config.storage.key) < config.storage.requiredValue then
        creature:say("Quest not started.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if no damage to boss, don't allow access to portal
    if not bossDamageMap[creature:getName()] then
        creature:say("This character dealt no damage to the boss.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if portal hasn't been entered before, update storage
    if creature:getStorageValue(config.storage.key) == config.storage.requiredValue then
        creature:setStorageValue(config.storage.key, config.storage.newValue)
    end
    creature:teleportTo(config.positions.destination)
    return true
end

moveevent:type("stepin")
moveevent:aid(config.teleportActionId)
moveevent:register()
 
Solution
You.. used none of the script I provided. lol
amazing work.

After looking at your files, I've edited my script to work as I think you're expecting.

Just put it into data/scripts as a single file..

Lua:
local config = {
    storage = {
        key = Storage.TheCallinKalys.Mission01,
        requiredValue = 1,
        newValue = 2
    },
    positions = {
        origin = Position(32890, 31883, 9),
        destination = Position(32816, 32260, 5)
    },
    teleportActionId = 32816,
    teleportItemId = 20121,
    teleportDecay = 180 -- seconds
}

local bossDamageMap = {} -- don't edit


local function removeTeleport(position, teleportItemId)
    local tile = Tile(position)
    if not tile then
        print("Error: tile not found at location")
        return
    end
    local teleport = tile:getItemById(teleportItemId)
    if not teleport then
        return
    end
    teleport:remove()
end

local function countDown(timer, position)
    if timer % 5 == 0 and timer ~= 0 then
        for _, creature in pairs(Game.getPlayers()) do
            creature:say(timer, TALKTYPE_MONSTER_SAY, false, nil, position)
            break
        end
    end
    if timer > 0 then
        addEvent(countDown, 1000, timer - 1, position)
    end
end


local creatureevent = CreatureEvent("KillBossDeath")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- create and remove teleport
    local teleport = Game.createItem(config.teleportItemId, 1, config.positions.origin)
    teleport:setActionId(config.teleportActionId)
    addEvent(removeTeleport, 1000 * config.teleportDecay, config.positions.origin, config.teleportItemId)
    countDown(config.teleportDecay, config.positions.origin)
    creature:say("YOU HAVE LITTLE TIME TO ENTER THE PORTAL!", TALKTYPE_ORANGE_1)
    -- setup damage map
    bossDamageMap = {}
    for creatureId, damage in pairs(creature:getDamageMap()) do
        local _creature = Creature(creatureId)
        if _creature then
            local master = _creature:getMaster()
            if master and master:isPlayer() then
                _creature = master
            end
            if _creature:isPlayer() then
                local name = _creature:getName()
                bossDamageMap[name] = (bossDamageMap[name] or 0) + damage.total
            end
        end
    end
    return true
end

creatureevent:register()


local moveevent = MoveEvent()

function moveevent.onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if quest is not started, don't allow access to portal
    if creature:getStorageValue(config.storage.key) < config.storage.requiredValue then
        creature:say("Quest not started.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if no damage to boss, don't allow access to portal
    if not bossDamageMap[creature:getName()] then
        creature:say("This character dealt no damage to the boss.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if portal hasn't been entered before, update storage
    if creature:getStorageValue(config.storage.key) == config.storage.requiredValue then
        creature:setStorageValue(config.storage.key, config.storage.newValue)
    end
    creature:teleportTo(config.positions.destination)
    return true
end

moveevent:type("stepin")
moveevent:aid(config.teleportActionId)
moveevent:register()
you will entrap people from leaving like it happened on soe if they didnt do damage instead give no reward maybe.
 
Once again... Thank you!
Look at my folder structure... I must put it in the correct folder!

creaturescripts ?

Sorry! Many years without doing this. Trying to do it now for the kids.



ESTRUTURA DE PASTA.png
 
Once again... Thank you!
Look at my folder structure... I must put it in the correct folder!

creaturescripts ?

Sorry! Many years without doing this. Trying to do it now for the kids.



View attachment 81565
In any of those folders. In a new folder. Outside the folders.
Any place will work as long as it's inside the main folder data/scripts
Post automatically merged:

you will entrap people from leaving like it happened on soe if they didnt do damage instead give no reward maybe.
I scripted it as asked in the main post of the request.
Sincerely, it never even crossed my mind as a possibility, since the portal itself only lasts 3 minutes.
I would assume there is another way out of this area by default.
 
My dear... @Xikini

I'm using your script, and I got the following results:

  • When you kill the boss and there is no loot!
  • When trying to enter the portal, it says: "Quest not started."

My quest log looks like this:
 

Attachments

  • When you kill the boss and there is no loot!
You've never mentioned any rewards or loot additions in the request until now?
We can add that if needed, but you've given no information regarding this.

  • When trying to enter the portal, it says: "Quest not started."
You have 4 different storages.

Storage.TheCallinKalys.QuestLine -- shows the quest log
Storage.TheCallinKalys.Mission01 -- something about tombstones
Storage.TheCallinKalys.Mission02 -- something about ghost residue
Storage.TheCallinKalys.Mission03 -- something about ghost samples

I'm unsure which one of these corresponds to killing the boss.
I used the tombstones mission (Mission01), as that is the one you attempted to use in your own script provided earlier.

So, either you're not giving the storage to the player, or you're giving the wrong storage.
You'd have to check your other script that is providing the storages to the player and confirm which is the issue.
 
Dear @Xikini

Your script worked! Thank you very much for your support!
I would like to know if you can help me with this issue:

I'm going to make a copy of this file for my second mission, but I need it to contain the following function: "Only those who have the storage from the first mission can enter the portal."

Can you help me? Thank you very much in advance!

Lua:
local config = {
    storage = {
        key = Storage.TheCallinKalys.Mission01,
        requiredValue = 1,
        newValue = 2
    },
    positions = {
        origin = Position(32389, 32210, 7),
        destination = Position(32390, 32212, 7)
    },
    teleportActionId = 32816,
    teleportItemId = 20121,
    teleportDecay = 60 -- seconds
}

local bossDamageMap = {} -- don't edit


local function removeTeleport(position, teleportItemId)
    local tile = Tile(position)
    if not tile then
        print("Error: tile not found at location")
        return
    end
    local teleport = tile:getItemById(teleportItemId)
    if not teleport then
        return
    end
    teleport:remove()
end

local creatureevent = CreatureEvent("TheCallKillBossDeath")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- create and remove teleport
    local teleport = Game.createItem(config.teleportItemId, 1, config.positions.origin)
    teleport:setActionId(config.teleportActionId)
    addEvent(removeTeleport, 1000 * config.teleportDecay, config.positions.origin, config.teleportItemId)
 
    creature:say("YOU HAVE LITTLE TIME TO ENTER THE PORTAL!", TALKTYPE_ORANGE_1)
    -- setup damage map
    bossDamageMap = {}
    for creatureId, damage in pairs(creature:getDamageMap()) do
        local _creature = Creature(creatureId)
        if _creature then
            local master = _creature:getMaster()
            if master and master:isPlayer() then
                _creature = master
            end
            if _creature:isPlayer() then
                local name = _creature:getName()
                bossDamageMap[name] = (bossDamageMap[name] or 0) + damage.total
            end
        end
    end
    return true
end

creatureevent:register()


local moveevent = MoveEvent()

function moveevent.onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if quest is not started, don't allow access to portal
    if creature:getStorageValue(config.storage.key) < config.storage.requiredValue then
        creature:say("Quest not started.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if no damage to boss, don't allow access to portal
    if not bossDamageMap[creature:getName()] then
        creature:say("This character dealt no damage to the boss.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if portal hasn't been entered before, update storage
    if creature:getStorageValue(config.storage.key) == config.storage.requiredValue then
        creature:setStorageValue(config.storage.key, config.storage.newValue)
    end
    creature:teleportTo(config.positions.destination)
    return true
end

moveevent:type("stepin")
moveevent:aid(config.teleportActionId)
moveevent:register()
 
Dear @Xikini

Your script worked! Thank you very much for your support!
I would like to know if you can help me with this issue:

I'm going to make a copy of this file for my second mission, but I need it to contain the following function: "Only those who have the storage from the first mission can enter the portal."

Can you help me? Thank you very much in advance!

Lua:
local config = {
    storage = {
        key = Storage.TheCallinKalys.Mission01,
        requiredValue = 1,
        newValue = 2
    },
    positions = {
        origin = Position(32389, 32210, 7),
        destination = Position(32390, 32212, 7)
    },
    teleportActionId = 32816,
    teleportItemId = 20121,
    teleportDecay = 60 -- seconds
}

local bossDamageMap = {} -- don't edit


local function removeTeleport(position, teleportItemId)
    local tile = Tile(position)
    if not tile then
        print("Error: tile not found at location")
        return
    end
    local teleport = tile:getItemById(teleportItemId)
    if not teleport then
        return
    end
    teleport:remove()
end

local creatureevent = CreatureEvent("TheCallKillBossDeath")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- create and remove teleport
    local teleport = Game.createItem(config.teleportItemId, 1, config.positions.origin)
    teleport:setActionId(config.teleportActionId)
    addEvent(removeTeleport, 1000 * config.teleportDecay, config.positions.origin, config.teleportItemId)
 
    creature:say("YOU HAVE LITTLE TIME TO ENTER THE PORTAL!", TALKTYPE_ORANGE_1)
    -- setup damage map
    bossDamageMap = {}
    for creatureId, damage in pairs(creature:getDamageMap()) do
        local _creature = Creature(creatureId)
        if _creature then
            local master = _creature:getMaster()
            if master and master:isPlayer() then
                _creature = master
            end
            if _creature:isPlayer() then
                local name = _creature:getName()
                bossDamageMap[name] = (bossDamageMap[name] or 0) + damage.total
            end
        end
    end
    return true
end

creatureevent:register()


local moveevent = MoveEvent()

function moveevent.onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if quest is not started, don't allow access to portal
    if creature:getStorageValue(config.storage.key) < config.storage.requiredValue then
        creature:say("Quest not started.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if no damage to boss, don't allow access to portal
    if not bossDamageMap[creature:getName()] then
        creature:say("This character dealt no damage to the boss.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if portal hasn't been entered before, update storage
    if creature:getStorageValue(config.storage.key) == config.storage.requiredValue then
        creature:setStorageValue(config.storage.key, config.storage.newValue)
    end
    creature:teleportTo(config.positions.destination)
    return true
end

moveevent:type("stepin")
moveevent:aid(config.teleportActionId)
moveevent:register()

Instead of altering the script further, I'll just tell you how to do it yourself

change this part
Lua:
function moveevent.onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if quest is not started, don't allow access to portal
    if creature:getStorageValue(config.storage.key) < config.storage.requiredValue then
        creature:say("Quest not started.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end

to this
Lua:
function moveevent.onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- previous mission requirement
    if creature:getStorageValue(STORAGE_KEY) < STORAGE_VALUE then
        creature:say("Previous mission not completed yet.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end
    -- if quest is not started, don't allow access to portal
    if creature:getStorageValue(config.storage.key) < config.storage.requiredValue then
        creature:say("Quest not started.", TALKTYPE_ORANGE_1, false, creature)
        creature:teleportTo(fromPosition, true)
        return false
    end

Then just change this line as needed.
Lua:
if creature:getStorageValue(STORAGE_KEY) < STORAGE_VALUE then
if creature:getStorageValue(Storage.TheCallinKalys.Mission01) < 2 then
 
Thank you very much for your support, my dear!
I did the exchange and testing.

Everything is OK!

Millions of likes for you!
 
Last edited:
Back
Top