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

TFS 0.X why necromancer revive rune is getting a delay?

hiwyn

Member
Joined
Aug 30, 2021
Messages
78
Reaction score
8
I have this rune that can bring monsters corpses back to life as summon to mages, but there is a problem:

after monster die in my server (GitHub - Fir3element/3777 (https://github.com/Fir3element/3777)) for some seconds it cant be pushed
and when monsters are like that the rune does not work, it shows the message sorry its not possible

why it is happen?
there is a way to fix it or atlast shows, wait some time until u can revive the monster?


rune script:
Code:
-- mana based on monster health
BodyMonsterNames = {
    [5976] = {name = "Ghoul", mana = 100},
    [3113] = {name = "Ghoul", mana = 100},
    [3114] = {name = "Ghoul", mana = 100},
    [3115] = {name = "Ghoul", mana = 100},
    [8964] = {name = "Fire Elemental", mana = 280},
    [8969] = {name = "Fire Elemental", mana = 280},
    [6004] = {name = "Mummy", mana = 240},
    [2949] = {name = "Mummy", mana = 240},
    [2950] = {name = "Mummy", mana = 240},
    [2951] = {name = "Mummy", mana = 240},
    -- daqui pra baixo só peguei 2
    [6029] = {name = "Crypt Shambler", mana = 330},
    [3028] = {name = "Crypt Shambler", mana = 330},
    [3029] = {name = "Crypt Shambler", mana = 330},
    [3030] = {name = "Crypt Shambler", mana = 330},
    [5963] = {name = "Demon Skeleton", mana = 400},
    [2809] = {name = "Demon Skeleton", mana = 400},
    [2922] = {name = "Demon Skeleton", mana = 400},
    [2923] = {name = "Demon Skeleton", mana = 400},
    [9875] = {name = "Zombie", mana = 500},
    [9876] = {name = "Zombie", mana = 500},
    [9877] = {name = "Zombie", mana = 500},
    [9878] = {name = "Zombie", mana = 500},
    [9938] = {name = "Gozzler", mana = 240},
    [9935] = {name = "Gozzler", mana = 240},
    [9936] = {name = "Gozzler", mana = 240},
    [9937] = {name = "Gozzler", mana = 240},
    [9938] = {name = "Gozzler", mana = 240},
    [5962] = {name = "Cyclops", mana = 260},
    [3069] = {name = "Cyclops", mana = 260},
    [2808] = {name = "Cyclops", mana = 260},
    [3117] = {name = "Cyclops", mana = 260},
    [3118] = {name = "Cyclops", mana = 260},
    [7847] = {name = "Cyclops Drone", mana = 325},
    [7848] = {name = "Cyclops Drone", mana = 325},
    [7849] = {name = "Cyclops Drone", mana = 325},
    -- [7743] = {name = "Cyclops Drone", mana = 325},
    [7740] = {name = "Cyclops Smith", mana = 435},
    [7741] = {name = "Cyclops Smith", mana = 435},
    [7742] = {name = "Cyclops Smith", mana = 435},
    -- [7743] = {name = "Cyclops Smith", mana = 435},
    [6006] = {name = "Vampire", mana = 475},
    [2956] = {name = "Vampire", mana = 475},
    [2957] = {name = "Vampire", mana = 475},
    [2958] = {name = "Vampire", mana = 475},
    [9658] = {name = "Vampire Bride", mana = 1200},
    [9659] = {name = "Vampire Bride", mana = 1200},
    [5973] = {name = "Dragon", mana = 1000},
    [3104] = {name = "Dragon", mana = 1000},
    [3105] = {name = "Dragon", mana = 1000},
    [3106] = {name = "Dragon", mana = 1000},
    [3107] = {name = "Dragon", mana = 1000},
    [5984] = {name = "Dragon Lord", mana = 1900},
    [2881] = {name = "Dragon Lord", mana = 1900},
    [2882] = {name = "Dragon Lord", mana = 1900},
    [2883] = {name = "Dragon Lord", mana = 1900},
    [7091] = {name = "Frost Dragon", mana = 1800},
    [7092] = {name = "Frost Dragon", mana = 1800},
    [7093] = {name = "Frost Dragon", mana = 1800},
    [7094] = {name = "Frost Dragon", mana = 1800},
    [8941] = {name = "Wyrm", mana = 1825},
    [8942] = {name = "Wyrm", mana = 1825},
    [8943] = {name = "Wyrm", mana = 1825},
    [8944] = {name = "Wyrm", mana = 1825},
    [6060] = {name = "Tarantula", mana = 225},
    [4320] = {name = "Tarantula", mana = 225},
    [4321] = {name = "Tarantula", mana = 225},
    [4322] = {name = "Tarantula", mana = 225},
    [5977] = {name = "Giant Spider", mana = 1300},
    [2857] = {name = "Giant Spider", mana = 1300},
    [2858] = {name = "Giant Spider", mana = 1300},
    [2859] = {name = "Giant Spider", mana = 1300},
    [6048] = {name = "Hydra", mana = 2350},
    [4283] = {name = "Hydra", mana = 2350},
    [4284] = {name = "Hydra", mana = 2350},
    [4285] = {name = "Hydra", mana = 2350},
    [8955] = {name = "Grim Reaper", mana = 3900},
    [8956] = {name = "Grim Reaper", mana = 3900},
    [8957] = {name = "Grim Reaper", mana = 3900},
    [8958] = {name = "Grim Reaper", mana = 3900}
}
local function doTargetCorpse(cid, position)
    position.stackpos = 255
    -- from config.lua:
    -- local maxSummons = getConfigValue('maxPlayerSummons')
    -- fuck config.lua:
    local maxSummons = 3
    local corpse = getThingFromPos(position)
    monster = BodyMonsterNames[corpse.itemid]
    if(monster and getCreatureSkullType(cid) ~= SKULL_BLACK) then
        if #getCreatureSummons(cid) >= maxSummons then
            return (doPlayerSendCancel(cid, "You cannot summon more creatures.") and doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)) and true
        end
        local reqMana = monster.mana * 2
        if (getPlayerMana(cid) < reqMana) then
            return (doPlayerSendCancel(cid, "You need " .. reqMana .. " mana points to revive this monster.") and doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)) and true
        end
        local createMonster = doCreateMonster(monster.name, position)
        if createMonster then
            doPlayerAddMana(cid, (reqMana * -1))
            doCreatureSetSkullType(createMonster, SKULL_YELLOW)
            setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) / 2))
            doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) / 2)
            doConvinceCreature(cid, createMonster)
            doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
            doRemoveItem(corpse.uid)
            return true
        end
    end
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end
function onCastSpell(cid, var)
    local position = variantToPosition(var)
    if(position.x ~= 0 and position.y ~= 0) then
        return doTargetCorpse(cid, position)
    end
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end
 
Try replacing your function with this.

Lua:
local function doTargetCorpse(cid, position)
    local maxSummons = 3
    local corpse = 0
    local check_pos
    -----------------------
    for i = 1, 255 do -- searches from the bottom up until it can't find any items.
        check_pos = {x = position.x, y = position.y, z = position.z, stackpos = i}
        if getThingFromPos(check_pos).itemid <= 0 then
            if i == 1 then
                print("No item found.")
                break
            end
            check_pos = {x = position.x, y = position.y, z = position.z, stackpos = i - 1}
            corpse = getThingFromPos(check_pos)
            print("ItemId " .. (corpse.itemid) .. " is the top-most item on this tile.")
            break
        end               -- Xikini's Edit
    end
    ----------------------
    monster = BodyMonsterNames[corpse.itemid]
    if(monster and getCreatureSkullType(cid) ~= SKULL_BLACK) then
        if #getCreatureSummons(cid) >= maxSummons then
            return (doPlayerSendCancel(cid, "You cannot summon more creatures.") and doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)) and true
        end
        local reqMana = monster.mana * 2
        if (getPlayerMana(cid) < reqMana) then
            return (doPlayerSendCancel(cid, "You need " .. reqMana .. " mana points to revive this monster.") and doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)) and true
        end
        local createMonster = doCreateMonster(monster.name, position)
        if createMonster then
            doPlayerAddMana(cid, (reqMana * -1))
            doCreatureSetSkullType(createMonster, SKULL_YELLOW)
            setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) / 2))
            doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) / 2)
            doConvinceCreature(cid, createMonster)
            doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
            doRemoveItem(corpse.uid)
            return true
        end
    end
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end
 
Try replacing your function with this.

Lua:
local function doTargetCorpse(cid, position)
    local maxSummons = 3
    local corpse = 0
    local check_pos
    -----------------------
    for i = 1, 255 do -- searches from the bottom up until it can't find any items.
        check_pos = {x = position.x, y = position.y, z = position.z, stackpos = i}
        if getThingFromPos(check_pos).itemid <= 0 then
            if i == 1 then
                print("No item found.")
                break
            end
            check_pos = {x = position.x, y = position.y, z = position.z, stackpos = i - 1}
            corpse = getThingFromPos(check_pos)
            print("ItemId " .. (corpse.itemid) .. " is the top-most item on this tile.")
            break
        end               -- Xikini's Edit
    end
    ----------------------
    monster = BodyMonsterNames[corpse.itemid]
    if(monster and getCreatureSkullType(cid) ~= SKULL_BLACK) then
        if #getCreatureSummons(cid) >= maxSummons then
            return (doPlayerSendCancel(cid, "You cannot summon more creatures.") and doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)) and true
        end
        local reqMana = monster.mana * 2
        if (getPlayerMana(cid) < reqMana) then
            return (doPlayerSendCancel(cid, "You need " .. reqMana .. " mana points to revive this monster.") and doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)) and true
        end
        local createMonster = doCreateMonster(monster.name, position)
        if createMonster then
            doPlayerAddMana(cid, (reqMana * -1))
            doCreatureSetSkullType(createMonster, SKULL_YELLOW)
            setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) / 2))
            doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) / 2)
            doConvinceCreature(cid, createMonster)
            doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
            doRemoveItem(corpse.uid)
            return true
        end
    end
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end

Still with the same problem @Gesior.pl mention, monsters that can't be moved are not detected on this function too...

For example, if i kill a ghoul and instant try to use the rune on his body (before the corpse can be moved)
It prints:
ItemId 3648 is the top-most item on this tile. (a stone on the ground)

until it become moveable and then also works like before

what should i do? :eek:
 
Still with the same problem @Gesior.pl mention, monsters that can't be moved are not detected on this function too...

For example, if i kill a ghoul and instant try to use the rune on his body (before the corpse can be moved)
It prints:
ItemId 3648 is the top-most item on this tile. (a stone on the ground)

until it become moveable and then also works like before

what should i do? :eek:
Do what i told you then:
1) Edit one of those items in the list with itemeditor, remove the unamovable flag and replace the items.xml and items.otbm in the server datapack, and the tibia.dat and tibia.otfi(?) in the client datapack..
2) Add that itemid to movements.xml, with a removeitem event or something like that, i.e:
XML:
<moveevent event="RemoveItem" itemid="5976" script="notmovableitems.lua"/>
3) Into that lua, just make the item unamovable.

So the item shouldn't be movable when you try to interact with it, but without the unamovable flag, so you should be able to find it through the function.
Post automatically merged:

I tried this:

Lua:
function onRemoveItem(item, tile, pos)
    doTeleportThing(item.uid,pos)
end

Although it seems to works, it calls an stack overflow...
 
Last edited:
Back
Top