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

Solved creatureScript not working(for quest)

simse

New Member
Joined
Jan 22, 2009
Messages
29
Reaction score
0
I am doing wrath of the emperor quest last boss, but not exactly as real tibia.
When u talk to npc and say "yes", the first boss spawns, when u kill it, the next boss spawns at the pos that the first boss died, then next spawns, and for last boss a tp appear on boss deadlocation that leads to tp room.

As of now it works to talk with npc and spawn the first boss, this is happening in the NPC script. I have script in creaturescripts, onKill function for the rest, but this does not work, help is apprecieated! Thanks!


Here is the creaturescript:

Code:
local config = {
        timeToRemove = 180, -- seconds
        message = "You now have 3 minutes to exit this room through the teleporter or the teleporter will dissapear. It will bring you to the reward room",
        teleportId = 9711,
        bosses = { -- Monster Name,  Teleport Position
                ["Snake God Essence"] = {  pos={ x=33066, y=31153, z=15, stackpos=1 }},
                ["Snake Thing"] = {  pos={ x=33066, y=31153, z=15, stackpos=1 }},
                ["Lizard Abomination"] = {  pos={ x=33066, y=31153, z=15, stackpos=1 }},
                ["Mutated Zalomon"] = {  pos={ x=33066, y=31153, z=15, stackpos=1 }, aid=9955}
                },
       
        Area =  {
                fromPos = {x=33056, y=31143, z=15},
                toPos = {x=33076, y=31161, z=15}   
                }
}

local function removal(position)
    doRemoveThing(getTileItemById(position, config.teleportId).uid, 1)
    return TRUE
end

function onKill(cid, target, lastHit)
    if(config.bosses[getCreatureName(target)]) then
        local t = config.bosses[getCreatureName(target)]
        if (t = "Snake God Essence") then
        doSummonCreature("Snake Thing", {x=33066, y=31153, z=15})
        elseif (t = "Snake Thing") then
        doSummonCreature("Lizard Abomination"), {x=33066, y=31153, z=15})
        elseif (t = "Lizard Abomination") then
        doSummonCreature("Mutated Zalomon"), {x=33066, y=31153, z=15})
        else if (t = "Mutated Zalomon")then
        local teleport = doCreateItem(config.teleportId, t.pos)
        local position = t.pos
        doItemSetAttribute(teleport, "aid", t.aid)
        doCreatureSay(cid, config.message, TALKTYPE_ORANGE_1)
        addEvent(removal, config.timeToRemove * 1000, position)

    end
    return TRUE
end
 
What is it supposed to do exactly?
There are tp positions for all 4 monsters, but in the script it only creates a tp if the monsters is a Mutated Zalomon, with the other 3 monsters it summens an other monster. is it supposed to be like this?
What do you want with the Area part? Should the script check if the player is in that area when killing the monsters?
It adds an actionid to an item that looks like a teleport, do you have a movement script for that or is it supposed to be a real teleport?
And there is missing an end above return true at the bottom of the script.
 
What is it supposed to do exactly?
There are tp positions for all 4 monsters, but in the script it only creates a tp if the monsters is a Mutated Zalomon, with the other 3 monsters it summens an other monster. is it supposed to be like this?
What do you want with the Area part? Should the script check if the player is in that area when killing the monsters?
It adds an actionid to an item that looks like a teleport, do you have a movement script for that or is it supposed to be a real teleport?
And there is missing an end above return true at the bottom of the script.

I copied most of it from inquisition creaturescript when boss dies. The tp positions is the same, I don't rly need them.
Yes it's supposed to summon a new boss for first 3, then when Mutated Zalamon dies, a tp will appear, which I will make a movement script for, I'm just not sure how I should connect it.
The area part has no function yet, It's just there, I guess I don't rly need it.

I want this script to do exactly this: When the boss "Snake god essence" dies, the boss "Snake Thing" will spawn on same place where first boss died, then same thing with "Lizard abomination" and "mutated zalomon" But when mutated zalomon dies, a tp will appear which I will have a movement script for, that will lead to reward room. Any ideas?
 
Code:
local config = {
     timeToRemove = 180, -- seconds
     teleportId = 9740,
     bosses = { -- Monster Name,  Summon
         ["Snake God Essence"] = {summon = "Snake Thing", pos = {x=33066, y=31153, z=15}},
         ["Snake Thing"] = {summon = "Lizard Abomination", pos = {x=33066, y=31153, z=15}},
         ["Lizard Abomination"] = {summon = "Mutated Zalomon", pos = {x=33066, y=31153, z=15}},
     },
     tpboss = {
         ["Mutated Zalomon"] = {pos = {x=33066, y=31153, z=15}, aid=9955}
     }
}

local function removal(position)
     doRemoveItem(getTileItemById(position, config.teleportId).uid, 1)
     doSendMagicEffect(position, CONST_ME_POFF)
     return true
end

function onKill(cid, target, lastHit)
     local bosses, tpboss = config.bosses[getCreatureName(target)], config.tpboss[getCreatureName(target)]

     if(isPlayer(target)) then
         return true
     end

     if(bosses) then
         doSummonCreature(bosses.summon, bosses.pos)
     end
     if(tpboss) then
         local teleport = doCreateItem(config.teleportId, tpboss.pos)
         doItemSetAttribute(teleport, "aid", tpboss.aid)
         doCreatureSay(cid, "You now have 3 minutes to exit this room through the teleporter or the teleporter will dissapear. It will bring you to the reward room", TALKTYPE_ORANGE_1)
         addEvent(removal, config.timeToRemove * 1000, tpboss.pos)
     end
     return true
end

If you want to do it without movement script, you can also do it like this.
Code:
local config = {
     timeToRemove = 180, -- seconds
     bosses = { -- Monster Name,  Summon
         ["Snake God Essence"] = {summon = "Snake Thing", pos = {x=33066, y=31153, z=15}},
         ["Snake Thing"] = {summon = "Lizard Abomination", pos = {x=33066, y=31153, z=15}},
         ["Lizard Abomination"] = {summon = "Mutated Zalomon", pos = {x=33066, y=31153, z=15}},
     },
     tpboss = {
         ["Mutated Zalomon"] = {pos = {x=33066, y=31153, z=15}, topos = {x=33066, y=31253, z=15}}
     }
}

local function removal(position)
     doRemoveItem(getTileItemById(position, config.teleportId).uid, 1)
     doSendMagicEffect(position, CONST_ME_POFF)
     return true
end

function onKill(cid, target, lastHit)
     local bosses, tpboss = config.bosses[getCreatureName(target)], config.tpboss[getCreatureName(target)]

     if(isPlayer(target)) then
         return true
     end

     if(bosses) then
         doSummonCreature(bosses.summon, bosses.pos)
     end
     if(tpboss) then
         doCreateTeleport(1387, tpboss.topos, tpboss.pos)
         doCreatureSay(cid, "You now have 3 minutes to exit this room through the teleporter or the teleporter will dissapear. It will bring you to the reward room", TALKTYPE_ORANGE_1)
         addEvent(removal, config.timeToRemove * 1000, tpboss.pos)
     end
     return true
end
 
Code:
local config = {
     timeToRemove = 180, -- seconds
     teleportId = 9740,
     bosses = { -- Monster Name,  Summon
         ["Snake God Essence"] = {summon = "Snake Thing", pos = {x=33066, y=31153, z=15}},
         ["Snake Thing"] = {summon = "Lizard Abomination", pos = {x=33066, y=31153, z=15}},
         ["Lizard Abomination"] = {summon = "Mutated Zalomon", pos = {x=33066, y=31153, z=15}},
     },
     tpboss = {
         ["Mutated Zalomon"] = {pos = {x=33066, y=31153, z=15}, aid=9955}
     }
}

local function removal(position)
     doRemoveItem(getTileItemById(position, config.teleportId).uid, 1)
     doSendMagicEffect(position, CONST_ME_POFF)
     return true
end

function onKill(cid, target, lastHit)
     local bosses, tpboss = config.bosses[getCreatureName(target)], config.tpboss[getCreatureName(target)]

     if(isPlayer(target)) then
         return true
     end

     if(bosses) then
         doSummonCreature(bosses.summon, bosses.pos)
     end
     if(tpboss) then
         local teleport = doCreateItem(config.teleportId, tpboss.pos)
         doItemSetAttribute(teleport, "aid", tpboss.aid)
         doCreatureSay(cid, "You now have 3 minutes to exit this room through the teleporter or the teleporter will dissapear. It will bring you to the reward room", TALKTYPE_ORANGE_1)
         addEvent(removal, config.timeToRemove * 1000, tpboss.pos)
     end
     return true
end

If you want to do it without movement script, you can also do it like this.
Code:
local config = {
     timeToRemove = 180, -- seconds
     bosses = { -- Monster Name,  Summon
         ["Snake God Essence"] = {summon = "Snake Thing", pos = {x=33066, y=31153, z=15}},
         ["Snake Thing"] = {summon = "Lizard Abomination", pos = {x=33066, y=31153, z=15}},
         ["Lizard Abomination"] = {summon = "Mutated Zalomon", pos = {x=33066, y=31153, z=15}},
     },
     tpboss = {
         ["Mutated Zalomon"] = {pos = {x=33066, y=31153, z=15}, topos = {x=33066, y=31253, z=15}}
     }
}

local function removal(position)
     doRemoveItem(getTileItemById(position, config.teleportId).uid, 1)
     doSendMagicEffect(position, CONST_ME_POFF)
     return true
end

function onKill(cid, target, lastHit)
     local bosses, tpboss = config.bosses[getCreatureName(target)], config.tpboss[getCreatureName(target)]

     if(isPlayer(target)) then
         return true
     end

     if(bosses) then
         doSummonCreature(bosses.summon, bosses.pos)
     end
     if(tpboss) then
         doCreateTeleport(1387, tpboss.topos, tpboss.pos)
         doCreatureSay(cid, "You now have 3 minutes to exit this room through the teleporter or the teleporter will dissapear. It will bring you to the reward room", TALKTYPE_ORANGE_1)
         addEvent(removal, config.timeToRemove * 1000, tpboss.pos)
     end
     return true
end

Wow, great, thank you! Rep+

But it still doesn't work, I'm a little noobie on this, I have this in creaturescripts.xml
<event type="kill" name="WOTE" script="WOTE.lua"/>
Is there anywhere else I should "initialize this script", like in the NPC script? Because It's in the NPC script that the first boss gets summoned.
 
Which server do you use?
Be sure this is correct: script="WOTE.lua", if your server is using event and value you have to do it like that.

You also have to register the name in login.lua
Code:
registerCreatureEvent(cid, "WOTE")
You can add it under the other registerCreatureEvent lines.
 
Which server do you use?
Be sure this is correct: script="WOTE.lua", if your server is using event and value you have to do it like that.

You also have to register the name in login.lua
Code:
registerCreatureEvent(cid, "WOTE")
You can add it under the other registerCreatureEvent lines.

Ah yes that was it! Thanks!
 
Which server do you use?
Be sure this is correct: script="WOTE.lua", if your server is using event and value you have to do it like that.

You also have to register the name in login.lua
Code:
registerCreatureEvent(cid, "WOTE")
You can add it under the other registerCreatureEvent lines.

Now the tp don't work when last boss dies. TP comes up but appears under the corpse which is wierd. This error shows:

[Error - CreatureScript Interface]
data/creaturescripts/scripts/WOTE.lua:eek:nKill
Description:
(luaDoItemSetAttribute) Invalid data type

Also tp doesn't gets removed:

[Error - CreatureScript Interface
In a timer event called from:
data/creaturescripts/scripts/WOTE
Description:
(luaDoRemoveItem) Item not found

Here is creaturescript:

Code:
local config = {
    timeToRemove = 180, -- seconds
    teleportActionId = 9933,
    bosses = { -- Monster Name,  Summon
        ["Snake God Essence"] = {summon = "Snake Thing", pos = {x=33066, y=31153, z=15}},
        ["Snake Thing"] = {summon = "Lizard Abomination", pos = {x=33066, y=31153, z=15}},
        ["Lizard Abomination"] = {summon = "Mutated Zalamon", pos = {x=33066, y=31153, z=15}},
    },
    tpboss = {
        ["Mutated Zalamon"] = {pos = {x=33066, y=31153, z=15}, topos = {x=33075, y=31173, z=8}}
    }
}

local function removal(position)
    doRemoveItem(getTileItemById(position, config.teleportId).uid, 1)
    doSendMagicEffect(position, CONST_ME_POFF)
    return true
end

function onKill(cid, target, lastHit)
    local bosses, tpboss = config.bosses[getCreatureName(target)], config.tpboss[getCreatureName(target)]

    if(isPlayer(target)) then
        return true
    end

    if(bosses) then
        doSummonCreature(bosses.summon, bosses.pos)
    end
    if(tpboss) then
        local teleport = doCreateItem(1387, tpboss.pos)
        doItemSetAttribute(teleport, "aid", teleportActionId)
        doCreatureSay(cid, "You now have 3 minutes to exit this room through the teleporter or the teleporter will dissapear. It will bring you to the reward room", TALKTYPE_ORANGE_1)
        addEvent(removal, config.timeToRemove * 1000, tpboss.pos)
    end
    return true
end

And in Movements.xml

Code:
<movevent type="StepIn" actionid="9933" event="script" value="WOTETP.lua"/>

And in WOTETP.lua

Code:
function onStepIn(cid, item, position, fromPosition)

local destination = {x=33075, y=31173, z=8}

    if item.actionid == 9933 then       
        doTeleportThing(cid, destination, TRUE)
        doSendMagicEffect(destination,10) 
        setPlayerStorageValue(cid, 600, 1)
    end
 
    return TRUE
end

Any ideas? :) Thanks

Wah, still same error
 
Last edited:
Try with this

Code:
local config = {
    timeToRemove = 180, -- seconds
    teleportActionId = 9933,
    bosses = { -- Monster Name,  Summon
        ["Snake God Essence"] = {summon = "Snake Thing", pos = {x=33066, y=31153, z=15}},
        ["Snake Thing"] = {summon = "Lizard Abomination", pos = {x=33066, y=31153, z=15}},
        ["Lizard Abomination"] = {summon = "Mutated Zalamon", pos = {x=33066, y=31153, z=15}}
    },
    tpboss = {
        ["Mutated Zalamon"] = {pos = {x=33066, y=31153, z=15}, topos = {x=33075, y=31173, z=8}}
    }
}

local function removal(position)
    doRemoveItem(getTileItemById(position, config.teleportId).uid, 1)
    doSendMagicEffect(position, CONST_ME_POFF)
    return true
end

function onKill(cid, target, lastHit)
    local bosses, tpboss = config.bosses[getCreatureName(target)], config.tpboss[getCreatureName(target)]

    if(isPlayer(target)) then
        return true
    end

    if(bosses) then
        doSummonCreature(bosses.summon, bosses.pos)
    end
    if(tpboss) then
        local teleport = doCreateItem(1387, tpboss.pos)
        local position = tpboss.pos
        doItemSetAttribute(teleport, "aid", config.teleportActionId)
        doCreatureSay(cid, "You now have 3 minutes to exit this room through the teleporter or the teleporter will dissapear. It will bring you to the reward room", TALKTYPE_ORANGE_1)
        addEvent(removal, config.timeToRemove * 1000, position)
    end
    return true
end
 
Try with this

Code:
local config = {
    timeToRemove = 180, -- seconds
    teleportActionId = 9933,
    bosses = { -- Monster Name,  Summon
        ["Snake God Essence"] = {summon = "Snake Thing", pos = {x=33066, y=31153, z=15}},
        ["Snake Thing"] = {summon = "Lizard Abomination", pos = {x=33066, y=31153, z=15}},
        ["Lizard Abomination"] = {summon = "Mutated Zalamon", pos = {x=33066, y=31153, z=15}}
    },
    tpboss = {
        ["Mutated Zalamon"] = {pos = {x=33066, y=31153, z=15}, topos = {x=33075, y=31173, z=8}}
    }
}

local function removal(position)
    doRemoveItem(getTileItemById(position, config.teleportId).uid, 1)
    doSendMagicEffect(position, CONST_ME_POFF)
    return true
end

function onKill(cid, target, lastHit)
    local bosses, tpboss = config.bosses[getCreatureName(target)], config.tpboss[getCreatureName(target)]

    if(isPlayer(target)) then
        return true
    end

    if(bosses) then
        doSummonCreature(bosses.summon, bosses.pos)
    end
    if(tpboss) then
        local teleport = doCreateItem(1387, tpboss.pos)
        local position = tpboss.pos
        doItemSetAttribute(teleport, "aid", config.teleportActionId)
        doCreatureSay(cid, "You now have 3 minutes to exit this room through the teleporter or the teleporter will dissapear. It will bring you to the reward room", TALKTYPE_ORANGE_1)
        addEvent(removal, config.timeToRemove * 1000, position)
    end
    return true
end

Ah, yes, it works! Thank you! (dont understand why tho) x)
 
You changed aid=9955 in the tpboss part/table to teleportActionId = 9933 outside the tpboss part/table in the config.
You had to add that the teleportActionId is a part of the config table in doItemSetAttribute.
Code:
doItemSetAttribute(teleport, "aid", config.teleportActionId)

You had:
Code:
doItemSetAttribute(teleport, "aid", teleportActionId)

But you could also just use the first script I posted (I noticed you combinated the 2 scripts I posted), it was already working like you wanted (I tested it), you didn't need to edit it.
 
Back
Top