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

Convert from 1.2 to 0.4

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
135
Location
Sweden
Could someone please convert this script to 0.4?
Would save my day.

Script from @Stigma
Thanks in advance.

Lua:
-- <event type="death" name="boss death" script="filename.lua"/>

local rewardRoom = Position(x, y, z)

function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)
    killer:teleportTo(rewardRoom)
    rewardRoom:sendMagicEffect(CONST_ME_TELEPORT)
    killer:unregisterEvent("bossroom death")
    bossRoom.player = nil
    bossRoom.boss = nil
    return true
end

Lua:
-- <movevent event="StepIn" actionid="77745" script="filename.lua"/>

local cfg = {
    destination = Position(x, y, z),
    boss = {
        name = "Demon",
        spawnPos = Position(x, y, z)
    }
}

bossRoom = {player = nil, boss = nil} -- global, accessible from other files

function onStepIn(creature, item, toPosition, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end
    -- there is a player still in the room
    if bossRoom.player then
        return false
    end
    local boss = Game.createMonster(cfg.boss.name, cfg.boss.spawnPos, true)
    if not boss then
        return false
    end
    player:teleportTo(cfg.destination)
    cfg.destination:sendMagicEffect(CONST_ME_TELEPORT)
    boss:registerEvent("boss death")
    player:registerEvent("bossroom death")
    bossRoom.player = player
    bossRoom.boss = boss
    return true
end

Lua:
-- <event type="preparedeath" name="bossroom death" script="filename.lua"/>

function onPrepareDeath(creature, killer)
    bossRoom.player = nil
    bossRoom.boss:remove()
    bossRoom.boss = nil
    return true
end
 
Read and understand the code, and do it yourself.
This is one of the most basic things ever, and if you can't do that, then maybe making OTs doesn't suit you very well.. just saying..
 
Read and understand the code, and do it yourself.
This is one of the most basic things ever, and if you can't do that, then maybe making OTs doesn't suit you very well.. just saying..
Say that to 80% of this community and it is dead for sure. What the freak are you talking about? If it's so easy and basic then teach him that, explain why and where he should change the code. God damn it bro...
 
Read and understand the code, and do it yourself.
This is one of the most basic things ever, and if you can't do that, then maybe making OTs doesn't suit you very well.. just saying..

Well i lack the time and knowledge to convert the script myself, therefore i need support for that.
I'm glad you find this "the most basic things ever". So either you could help me convert it, or don't bother replying to the post at all.
Just saying
 
Not tested.
Lua:
local rewardRoom = {x = 1031, y = 1373, z = 13}

function onDeath(cid, corpse, killer)
    doTeleportThing(killer, rewardRoom)
    doSendMagicEffect(rewardRoom, CONST_ME_TELEPORT)
    unregisterCreatureEvent(killer, "bossroom death")
    bossRoom.player = nil
    bossRoom.boss = nil
    return true
end

Lua:
local cfg = {
    destination = {x = 1031, y = 1373, z = 13},
    boss = {
        name = "Demon",
        spawnPos = {x = 1031, y = 1373, z = 13}
    }
}

bossRoom = {player = nil, boss = nil} -- global, accessible from other files

function onStepIn(cid, item, position, fromPosition)
    if not isPlayer(cid) then
        return false
    end
    -- there is a player still in the room
    if bossRoom.player then
        return false
    end
    local boss = doCreateMonster(cfg.boss.name, cfg.boss.spawnPos)
    if not boss then
        return false
    end
    doTeleportThing(cid, cfg.destination)
    doSendMagicEffect(cfg.destination, CONST_ME_TELEPORT)
    registerCreatureEvent(boss, "boss death")
    registerCreatureEvent(cid, "bossroom death")
    bossRoom.player = cid
    bossRoom.boss = boss
    return true
end

Lua:
function onPrepareDeath(cid, killer)
    bossRoom.player = nil
    doRemoveCreature(bossRoom.boss)
    bossRoom.boss = nil
    return true
end
 
Not tested.
Lua:
local rewardRoom = {x = 1031, y = 1373, z = 13}

function onDeath(cid, corpse, killer)
    doTeleportThing(killer, rewardRoom)
    doSendMagicEffect(rewardRoom, CONST_ME_TELEPORT)
    unregisterCreatureEvent(killer, "bossroom death")
    bossRoom.player = nil
    bossRoom.boss = nil
    return true
end

Lua:
local cfg = {
    destination = {x = 1031, y = 1373, z = 13},
    boss = {
        name = "Demon",
        spawnPos = {x = 1031, y = 1373, z = 13}
    }
}

bossRoom = {player = nil, boss = nil} -- global, accessible from other files

function onStepIn(cid, item, position, fromPosition)
    if not isPlayer(cid) then
        return false
    end
    -- there is a player still in the room
    if bossRoom.player then
        return false
    end
    local boss = doCreateMonster(cfg.boss.name, cfg.boss.spawnPos)
    if not boss then
        return false
    end
    doTeleportThing(cid, cfg.destination)
    doSendMagicEffect(cfg.destination, CONST_ME_TELEPORT)
    registerCreatureEvent(boss, "boss death")
    registerCreatureEvent(cid, "bossroom death")
    bossRoom.player = cid
    bossRoom.boss = boss
    return true
end

Lua:
function onPrepareDeath(cid, killer)
    bossRoom.player = nil
    doRemoveCreature(bossRoom.boss)
    bossRoom.boss = nil
    return true
end


changed killer to 'cid'

Now i just got this error when killing the boss:

Lua:
[16:14:05.140] [Error - CreatureScript Interface]
[16:14:05.143] data/creaturescripts/scripts/hydraboss/hydrabossreward.lua:onDeath
[16:14:05.147] Description:
[16:14:05.149] ...reaturescripts/scripts/hydraboss/hydrabossreward.lua:7: attempt to index global 'bossRoom' (a nil value)
[16:14:05.154] stack traceback:
[16:14:05.155]  ...reaturescripts/scripts/hydraboss/hydrabossreward.lua:7: in function <...reaturescripts/scripts/hydraboss/hydrabossreward.lua:3>

Lua:
local rewardRoom = {x = 798, y = 1105, z = 8}

function onDeath(cid, corpse, deathList)
    doTeleportThing(cid, rewardRoom)
    doSendMagicEffect(rewardRoom, CONST_ME_TELEPORT)
    unregisterCreatureEvent(cid, "bossroom death")
    bossRoom.player = nil
    bossRoom.boss = nil
    return true
end
 
Last edited:
changed killer to 'cid'

Now i just got this error when killing the boss:

Lua:
[16:14:05.140] [Error - CreatureScript Interface]
[16:14:05.143] data/creaturescripts/scripts/hydraboss/hydrabossreward.lua:onDeath
[16:14:05.147] Description:
[16:14:05.149] ...reaturescripts/scripts/hydraboss/hydrabossreward.lua:7: attempt to index global 'bossRoom' (a nil value)
[16:14:05.154] stack traceback:
[16:14:05.155]  ...reaturescripts/scripts/hydraboss/hydrabossreward.lua:7: in function <...reaturescripts/scripts/hydraboss/hydrabossreward.lua:3>
Remove this from the movement script & put it in data/lib/000-constant.lua
Lua:
bossRoom = {player = nil, boss = nil} -- global, accessible from other files
 
Back
Top