• 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
 
Have you considered looking at the corpse? Unmovable corpses have a different ID than the ones (movable) that they decay to
 
Have you considered looking at the corpse? Unmovable corpses have a different ID than the ones (movable) that they decay to

this i could not revive (the not moveable):
Code:
03:20 You see a dead tarantula (Vol:10).
ItemID: [6060].
DecayTo: [4320].
Position: [X: 1021] [Y: 1044] [Z: 7].

and after some time this i could (the moveable):
Code:
03:20 You see a dead tarantula (Vol:10).
ItemID: [4320].
DecayTo: [4321].
Position: [X: 1020] [Y: 1044] [Z: 7].

but both are on the list



---
same thing happens to ghoul

this does not work:
Code:
03:22 You see a slain ghoul (Vol:10).
ItemID: [5976].
DecayTo: [3113].
Position: [X: 1021] [Y: 1042] [Z: 7].

this works:
Code:
03:22 You see a slain ghoul (Vol:8).
ItemID: [3113].
DecayTo: [3114].
Position: [X: 1020] [Y: 1041] [Z: 7].

---

but i have no idea what is going on, all this items are on the list on the rune
 
I'm not sure, and maybe this input is not helpful, but the reason why the unmovable corpses exist is to protect the owners right to the loot, so that nobody steals it basically. It would make sense if this system also somehow generally prevents any manipulation of the unmovable corpses..

*edit
I've had trouble manipulating those corpses in the past and I was unable to solve it properly. My case was related to using obsidian knife / blessed wooden stake on the corpses. I solved it by simply changing the corpse spawned by the monsters in the monster_name.xml. Quite the crude solution, it would be much neater to somehow make an exception. But on the other hand, then you could get problems with people destroying loot on your OT
 
local corpse = getThingFromPos(position)
print(corpse) is printing all 0 on this fresh monsters (that u cant move)
Code:
  [actionid] => 0
  [uid] => 0
  [itemid] => 0
  [type] => 0
anybody here know why?
there is any other way to get the item?
 
Use getTileItemById instead
with variantToPosition(var)?

how to do?

i got this error:
Code:
[4:5:35] [Error - Spell Interface] 
[4:5:35] data/spells/scripts/summon/animate dead rune.lua:onCastSpell
[4:5:35] Description: 
[4:5:35] attempt to index a function value
[4:5:35] stack traceback:
[4:5:35]     [C]: in function 'getTileItemById'
[4:5:35]     data/spells/scripts/summon/animate dead rune.lua:151: in function <data/spells/scripts/summon/animate dead rune.lua:144>
[4:5:35]     (tail call): ?

with this 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)
    local corpse = getTileItemById(position).uid
    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
 
with variantToPosition(var)?

how to do?

i got this error:
Code:
[4:5:35] [Error - Spell Interface]
[4:5:35] data/spells/scripts/summon/animate dead rune.lua:onCastSpell
[4:5:35] Description:
[4:5:35] attempt to index a function value
[4:5:35] stack traceback:
[4:5:35]     [C]: in function 'getTileItemById'
[4:5:35]     data/spells/scripts/summon/animate dead rune.lua:151: in function <data/spells/scripts/summon/animate dead rune.lua:144>
[4:5:35]     (tail call): ?

with this 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)
    local corpse = getTileItemById(position).uid
    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
getTileItemById(position,item_id)

The position doesn't need to have the stackpos, just x,y,z.
 
getTileItemById(position,item_id)

The position doesn't need to have the stackpos, just x,y,z.

I saw another codes using this function so i tried mine
local corpse = getTileItemById(position).uid
local corpse = getTileItemById(position)

gave me that error msg

both didn't work...
 
luascript.cpp
Code:
int32_t LuaInterface::luaGetThingFromPos(lua_State* L)
{
    //getThingFromPos(pos[, displayError = true])
    //Note:
    //    stackpos = 255- top thing (movable item or creature)
255 = movable item or creature, so not movable corpses are not returned by this function.
I don't know, if there is any function that return top item of tile on 0.4.
If you use getTileItemById to search for item on tile, it may return corpse that is under fire field or other item.
 
luascript.cpp
Code:
int32_t LuaInterface::luaGetThingFromPos(lua_State* L)
{
    //getThingFromPos(pos[, displayError = true])
    //Note:
    //    stackpos = 255- top thing (movable item or creature)
255 = movable item or creature, so not movable corpses are not returned by this function.
I don't know, if there is any function that return top item of tile on 0.4.
If you use getTileItemById to search for item on tile, it may return corpse that is under fire field or other item.
he can validate if there is a magic field above first:

CORPSE = 1560
local corpse = getTileItemById(position,1560).uid
local magicfield = getThingFromPos(position, stackpos = 254}) -- stackpos 254 is any fire, poison or energy field

If corpse.itemid == CORPSE and magicfield == 0 then ...

etc
 
Last edited:
do i have to loop in all corpses with this function?
it will not be heavy?
how to do?

i tried but fail again
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)
    local maxSummons = 3
    for i in ipairs(BodyMonsterNames) do
      local corpse = getTileItemById(position,i).uid
      local magicfield = getThingFromPos(position, stackpos = 254}) -- stackpos 254 is any fire, poison or energy field
      if corpse.itemid == CORPSE and magicfield == 0 then
        print("found corpse: " .. i)
        local 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
    end
    end
  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
 
do i have to loop in all corpses with this function?
it will not be heavy?
how to do?

i tried but fail again
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)
    local maxSummons = 3
    for i in ipairs(BodyMonsterNames) do
      local corpse = getTileItemById(position,i).uid
      local magicfield = getThingFromPos(position, stackpos = 254}) -- stackpos 254 is any fire, poison or energy field
      if corpse.itemid == CORPSE and magicfield == 0 then
        print("found corpse: " .. i)
        local 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
    end
    end
  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
Use this destroy field rune as example (implemented in actions.xml to dissapear magic fields above unwalkeable items).

Actions.xml:
XML:
<action itemid="2261" script="destroy_field_rune.lua" allowfaruse="1"/>

Lua:
Lua:
local FIELDS = {1487,1488,1489,1490,1491,1492,1493,1494,1495,1496,1500,1501,1502,1503,1504}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isInArray(FIELDS, itemEx.itemid) == TRUE and getPlayerMagicLevel(cid) >= 3 then
        doRemoveItem(itemEx.uid, 1)
        doChangeTypeItem(item.uid, item.type-1)
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return LUA_NO_ERROR
    end
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    return LUA_ERROR
end
 
Use this destroy field rune as example (implemented in actions.xml to dissapear magic fields above unwalkeable items).

Actions.xml:
XML:
<action itemid="2261" script="destroy_field_rune.lua" allowfaruse="1"/>

Lua:
Lua:
local FIELDS = {1487,1488,1489,1490,1491,1492,1493,1494,1495,1496,1500,1501,1502,1503,1504}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isInArray(FIELDS, itemEx.itemid) == TRUE and getPlayerMagicLevel(cid) >= 3 then
        doRemoveItem(itemEx.uid, 1)
        doChangeTypeItem(item.uid, item.type-1)
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return LUA_NO_ERROR
    end
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    return LUA_ERROR
end

but BodyMonsterNames isn't an object?
i mean how can i use isInArray there?
 
Maybe you can change the structure, from:
Lua:
[5976] = {name = "Ghoul", mana = 100},
[3113] = {name = "Ghoul", mana = 100},

To:
Lua:
[1]= {id = 5976, name = "Ghoul", mana = 100},
[2] = {id = 3113, name = "Ghoul", mana = 100},

So you can iterate over it with a for:
for g, #BodyMonsterNames do
if itemEx.itemid == BodyMonsterNames[g].id then
blablabla...
break
etc
end

Idk how heavy would the query be, but might worth a try.

However, your best solution is adding those items ids to movements.xml creating a lua function that doesn't let you move them, so they would still have the 255 stackpos but couldn't be movables until they decay to the next corpse id, you would also need to modify them in the otbm file.
 
Back
Top