• 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 animated dead revive the corpse, not create only a skeleton

sabodden

Member
Joined
Sep 27, 2019
Messages
138
Reaction score
18
Would be possible to when use this rune, instead of create a skeleton, get the monster corpse and create the creature killed?
I mean, if rune was used in a dead dwarf, create a dwarf, if was used in a dead rotworm, create a rotworm...

Code:
<rune name="Animate Dead" id="2316" allowfaruse="1" charges="1" maglv="4" exhaustion="2000" blocktype="solid" event="script" value="summon/animate dead rune.lua"/>

Code:
local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local corpse = getThingFromPos(position)
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getCreatureSkullType(cid) ~= SKULL_BLACK) then
        doRemoveItem(corpse.uid)
        doConvinceCreature(cid, doCreateMonster("Skeleton", position))

        doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
        return true
    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
 
Solution
Lua:
BodyMonsterNames = {
    [2960] = {name = "Dwarf", mana = 100},
    [5555] = {name = "Demon Skeleton", mana = 200} -- last dont have comma
}
local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local maxSummons = getConfigValue('maxPlayerSummons')
    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
        if (getPlayerMana(cid) < monster.mana) then
            return (doPlayerSendCancel(cid, "You...
Things you have to do:
make a big list with all itemids of dead bodies and names of the monsters
like:
Lua:
BodyMonsterNames = {
    [1234] = "Dwarf",
    [5555] = "Demon Skeleton"
}

and then use this instead:
Lua:
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getCreatureSkullType(cid) ~= SKULL_BLACK) then
        doConvinceCreature(cid, doCreateMonster(BodyMonsterNames[corpse.itemid], position))
        doRemoveItem(corpse.uid)

        doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
        return true
    end

There is also another method to make it works. You can get name of the item, then split string into 'dead' and 'mob name' and summon mob by mob name string. But this will require you to configure which monsters you cannot ressurect. Becouse it may let players reanimate demons and orshabaals.
 
Last edited:
Things you have to do:
make a big list with all itemids of dead bodies and names of the monsters
like:
Lua:
BodyMonsterNames = {
    [1234] = "Dwarf",
    [5555] = "Demon Skeleton"
}

and then use this instead:
Lua:
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getCreatureSkullType(cid) ~= SKULL_BLACK) then
        doConvinceCreature(cid, doCreateMonster(BodyMonsterNames[corpse.itemid], position))
        doRemoveItem(corpse.uid)

        doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
        return true
    end

There is also another method to make it works. You can get name of the item, then split string into 'dead' and 'mob name' and summon mob by mob name string. But this will require you to configure which monsters you cannot ressurect. Becouse it may let players reanimate demons and orshabaals.

I found some function who could make a better user experience (like monsters come back with half health) and a skull to signalize
But i couldn't make it to work, could you help me with the syntax?

Code:
BodyMonsterNames = {
    [1234] = "Dwarf", mana = 100
    [5555] = "Demon Skeleton", mana = 200
}

local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local corpse = getThingFromPos(position)
    -- how to get?
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getCreatureSkullType(cid) ~= SKULL_BLACK) then
        doRemoveItem(corpse.uid)

        -- mana
        if (getPlayerMana(cid) < mana) then
            doPlayerSendCancel(cid, "You need " .. mana " to revive this monster.")
            return true
        end
        doPlayerAddMana(cid, -mana)

        -- monster stuff
        doConvinceCreature(cid, doCreateMonster("Skeleton", position))
        doCreatureSetSkullType(monster, SKULL_YELLOW)
        doCreatureAddHealth(monster, getCreatureHealth(cid) / 2)
        setCreatureMaxHealth(monster, (getCreatureHealth(cid) / 2))
        

        doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
        return true
    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
 
Lua:
BodyMonsterNames = {
    [1234] = {name = "Dwarf", mana = 100},
    [5555] = {name = "Demon Skeleton", mana = 200} -- last dont have comma
}

...

if (getPlayerMana(cid) >= BodyMonsterNames[corpse.itemid].mana) then
   doConvinceCreature(cid, doCreateMonster(BodyMonsterNames[corpse.itemid].name, position))
 
Lua:
BodyMonsterNames = {
    [1234] = {name = "Dwarf", mana = 100},
    [5555] = {name = "Demon Skeleton", mana = 200} -- last dont have comma
}

...

if (getPlayerMana(cid) >= BodyMonsterNames[corpse.itemid].mana) then
   doConvinceCreature(cid, doCreateMonster(BodyMonsterNames[corpse.itemid].name, position))

how to get if monster is on the list?
how to get monster id to add this stuff?

Code:
BodyMonsterNames = {
    [1234] = {name = "Dwarf", mana = 100},
    [5555] = {name = "Demon Skeleton", mana = 200} -- last dont have comma
}

local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local corpse = getThingFromPos(position)
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getCreatureSkullType(cid) ~= SKULL_BLACK) then
        -- how to get if monster is on the list?
        if (creature is not on the list) then
            doPlayerSendCancel(cid, "This creature is not allowed to revive.")
            return true
        end

        if (getPlayerMana(cid) >= BodyMonsterNames[corpse.itemid].mana) then
            doPlayerSendCancel(cid, "You need " .. mana " to revive this monster.")
            return true
        end
        doPlayerAddMana(cid, -mana)

        doRemoveItem(corpse.uid)
        doConvinceCreature(cid, doCreateMonster(BodyMonsterNames[corpse.itemid].name, position))

        -- how to get monster id to add this stuff?
        doCreatureSetSkullType(monster, SKULL_YELLOW)
        doCreatureAddHealth(monster, getCreatureHealth(cid) / 2)
        setCreatureMaxHealth(monster, (getCreatureHealth(cid) / 2))
        
        doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
        return true
    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
 
I just take the function: doTargetCorpse...

Lua:
local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local corpse = getThingFromPos(position)
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getCreatureSkullType(cid) ~= SKULL_BLACK) then
------------------------------------------------------------
        -- how to get if monster is on the list?
        if isInArray(BodyMonsterNames[corpse.itemid], corpse.uid) == true then
            doSomething(cid)
        end
------------------------------------------------------------
        if (getPlayerMana(cid) >= BodyMonsterNames[corpse.itemid].mana) then
            doPlayerSendCancel(cid, "You need " .. mana " to revive this monster.")
            return true
        end
        doPlayerAddMana(cid, -mana)
        doRemoveItem(corpse.uid)
------------------------------------------------------------
        -- how to get monster id to add this stuff?
        local createMonster = doCreateMonster(BodyMonsterNames[corpse.itemid].name, position)
        if createMonster then
            doCreatureSetSkullType(createMonster, SKULL_YELLOW)
            doCreatureAddHealth(createMonster, getCreatureHealth(cid) / 2)
            setCreatureMaxHealth(createMonster, (getCreatureHealth(cid) / 2))
            doConvinceCreature(cid, createMonster)
            doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
            return true
        end
------------------------------------------------------------
    end
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return false
end
 
Error when i try to get up a dwarf (2960)

Code:
[14:23:53.771] [Error - Spell Interface] 
[14:23:53.771] data/spells/scripts/summon/animate dead rune.lua:onCastSpell
[14:23:53.771] Description: 
[14:23:53.772] data/spells/scripts/summon/animate dead rune.lua:17: attempt to call field 'mana' (a number value)
[14:23:53.772] stack traceback:
[14:23:53.772]     data/spells/scripts/summon/animate dead rune.lua:17: in function <data/spells/scripts/summon/animate dead rune.lua:6>
[14:23:53.773]     (tail call): ?

Code:
BodyMonsterNames = {
    [2960] = {name = "Dwarf", mana = 100},
    [5555] = {name = "Demon Skeleton", mana = 200} -- last dont have comma
}

local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local corpse = getThingFromPos(position)
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getCreatureSkullType(cid) ~= SKULL_BLACK) then
------------------------------------------------------------
        -- how to get if monster is on the list?
        if isInArray(BodyMonsterNames[corpse.itemid], corpse.uid) == true then
            doSomething(cid)
        end
------------------------------------------------------------
        if (getPlayerMana(cid) >= BodyMonsterNames[corpse.itemid].mana) then
            doPlayerSendCancel(cid, "You need " .. BodyMonsterNames[corpse.itemid].mana " to revive this monster.")
            return true
        end
        doPlayerAddMana(cid, -BodyMonsterNames[corpse.itemid].mana)
        doRemoveItem(corpse.uid)
------------------------------------------------------------
        -- how to get monster id to add this stuff?
        local createMonster = doCreateMonster(BodyMonsterNames[corpse.itemid].name, position)
        if createMonster then
            doCreatureSetSkullType(createMonster, SKULL_YELLOW)
            doCreatureAddHealth(createMonster, getCreatureHealth(cid) / 2)
            setCreatureMaxHealth(createMonster, (getCreatureHealth(cid) / 2))
            doConvinceCreature(cid, createMonster)
            doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
            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
 
Replace this
Lua:
if (getPlayerMana(cid) >= BodyMonsterNames[corpse.itemid].mana) then
    doPlayerSendCancel(cid, "You need " .. BodyMonsterNames[corpse.itemid].mana " to revive this monster.")
    return true
end


With
Lua:
 if (getPlayerMana(cid) < BodyMonsterNames[corpse.itemid].mana) then
    doPlayerSendCancel(cid, "You need " .. BodyMonsterNames[corpse.itemid].mana .. " mana points to revive this monster.")
    return true
end
 
Replace this
Lua:
if (getPlayerMana(cid) >= BodyMonsterNames[corpse.itemid].mana) then
    doPlayerSendCancel(cid, "You need " .. BodyMonsterNames[corpse.itemid].mana " to revive this monster.")
    return true
end


With
Lua:
 if (getPlayerMana(cid) < BodyMonsterNames[corpse.itemid].mana) then
    doPlayerSendCancel(cid, "You need " .. BodyMonsterNames[corpse.itemid].mana .. " mana points to revive this monster.")
    return true
end

now it is working...

but i have 3 problems

1 when i try to revive an invalid monster (not on list)
Code:
[12:37:38.274] [Error - Spell Interface] 
[12:37:38.274] data/spells/scripts/summon/animate dead rune.lua:onCastSpell
[12:37:38.274] Description: 
[12:37:38.274] data/spells/scripts/summon/animate dead rune.lua:16: attempt to index field '?' (a nil value)
[12:37:38.274] stack traceback:
[12:37:38.274]     data/spells/scripts/summon/animate dead rune.lua:16: in function <data/spells/scripts/summon/animate dead rune.lua:6>
[12:37:38.274]     (tail call): ?

2 i was trying to make a limit of how many monsters could be revived
tried this
Code:
BodyMonsterNames = {
    [2960] = {name = "Dwarf", mana = 100},
    [5555] = {name = "Demon Skeleton", mana = 200} -- last dont have comma
}

local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local corpse = getThingFromPos(position)
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getCreatureSkullType(cid) ~= SKULL_BLACK) then
------------------------------------------------------------
        -- how to get if monster is on the list?
        if isInArray(BodyMonsterNames[corpse.itemid], corpse.uid) == true then
            doSomething(cid)
        end
------------------------------------------------------------
        if (getPlayerMana(cid) < BodyMonsterNames[corpse.itemid].mana) then
            doPlayerSendCancel(cid, "You need " .. BodyMonsterNames[corpse.itemid].mana .. " mana points to revive this monster.")
            return true
        end
        getCreatureSummons(cid)

        local summons = getCreatureSummons(cid)
        print("You have this ammount of summons:")
        print(summons)

        doPlayerAddMana(cid, -BodyMonsterNames[corpse.itemid].mana)
        doRemoveItem(corpse.uid)
------------------------------------------------------------
        -- how to get monster id to add this stuff?
        local createMonster = doCreateMonster(BodyMonsterNames[corpse.itemid].name, position)
        if createMonster then
            doCreatureSetSkullType(createMonster, SKULL_YELLOW)
            doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) / 2)
            setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) / 2))
            doConvinceCreature(cid, createMonster)
            doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
            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

but it is printing:
Code:
You have this ammount of summons:

You have this ammount of summons:

You have this ammount of summons:

3 the yellow skull is working
but the life reduce / 2 is not working
dwarfs are backing with 90 health points, it should be 45
Code:
            doCreatureAddHealth(createMonster, getCreatureHealth(createMonster) / 2)
            setCreatureMaxHealth(createMonster, (getCreatureHealth(createMonster) / 2))

do u know how to fix this things? or atlast one of this?
 
Lua:
BodyMonsterNames = {
    [2960] = {name = "Dwarf", mana = 100},
    [5555] = {name = "Demon Skeleton", mana = 200} -- last dont have comma
}
local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local maxSummons = getConfigValue('maxPlayerSummons')
    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
        if (getPlayerMana(cid) < monster.mana) then
            return (doPlayerSendCancel(cid, "You need " .. BodyMonsterNames[corpse.itemid].mana .. " 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, -monster.mana)
            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

Monster health were not working correctly because functions were inversed. First you have to set the MaxHealth and then AddHealth.
Just for you to know.
 
Solution
Lua:
BodyMonsterNames = {
    [2960] = {name = "Dwarf", mana = 100},
    [5555] = {name = "Demon Skeleton", mana = 200} -- last dont have comma
}
local function doTargetCorpse(cid, position)
    position.stackpos = 255
    local maxSummons = getConfigValue('maxPlayerSummons')
    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
        if (getPlayerMana(cid) < monster.mana) then
            return (doPlayerSendCancel(cid, "You need " .. BodyMonsterNames[corpse.itemid].mana .. " 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, -monster.mana)
            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

Monster health were not working correctly because functions were inversed. First you have to set the MaxHealth and then AddHealth.
Just for you to know.

holy thank you!!!
 
Back
Top