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

Two questions about looktype, and health problem

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
993
Solutions
5
Reaction score
55
Hi
i have a lot of new vocations but i cant find any information in google where can i change dead corpses looktype? And second problem when player die mana and health increase or decrease randomly so its messing up with health/mana when you die it should stay how it is.
 
Solution
is for TFS 1.2
Code:
local corpseTransfom = { -- [vocation ID] = { female itemid, male itemid }
    [1] = { 2160, 2152 },
    [2] = { 2160, 2152 },
    [3] = { 2160, 2152 },
    [4] = { 2160, 2152 },
    [5] = { 2160, 2152 },
    [6] = { 2160, 2152 },
    [7] = { 2160, 2152 },
    [8] = { 2160, 2152 }
}

function onDeath(creature, corpse)
    if creature:isPlayer() then
        if corpse then
            local position = creature:getPosition()
            local isCorpse = ItemType(corpse:getId()):isCorpse()
            if isCorpse then
                local c = { corpse:getId(), corpse:getPosition(), creature:getVocation():getId(), creature:getSex() }
                addEvent(function(c)
                    local corpseId, position...
Something like this would require source edit, since every player has one assigned corpse, depending on the sex - male or female.
 
Something like this would require source edit, since every player has one assigned corpse, depending on the sex - male or female.
Cant you achieve it with .lua? But if its not possible, where are those corpses made in source?
 
otland/forgottenserver
The other question i can answer later when i get out of class
Maybe its possible i'm not sure but probably it should look like this :D

Edit: Sorry i meant to reply to to @henkas
Code:
local corpses =
  {
    [Vocation ID] = {lookType = Corpses id}, -- Vocation
  }
function onDeath(player)
 
end
 
Last edited:
is for TFS 1.2
Code:
local corpseTransfom = { -- [vocation ID] = { female itemid, male itemid }
    [1] = { 2160, 2152 },
    [2] = { 2160, 2152 },
    [3] = { 2160, 2152 },
    [4] = { 2160, 2152 },
    [5] = { 2160, 2152 },
    [6] = { 2160, 2152 },
    [7] = { 2160, 2152 },
    [8] = { 2160, 2152 }
}

function onDeath(creature, corpse)
    if creature:isPlayer() then
        if corpse then
            local position = creature:getPosition()
            local isCorpse = ItemType(corpse:getId()):isCorpse()
            if isCorpse then
                local c = { corpse:getId(), corpse:getPosition(), creature:getVocation():getId(), creature:getSex() }
                addEvent(function(c)
                    local corpseId, position, vocId, sex = unpack(c)
                    --print(corpseId, position, vocId, sex)
                    local corpse = position:getTile():getItemById(corpseId)
                    if corpse then
                        corpse:transform(corpseTransfom[vocId][sex+1])
                    end
                end, 50, c)
            end
        end
    end
return true
end

Creaturescripts.xml
Code:
<event type="death" name="ChangeCorpse" script="others/changecorpse.lua"/>

add in your login.lua
Code:
player:registerEvent('ChangeCorpse')
 
Last edited:
Solution
is for TFS 1.2
Code:
local corpseTransfom = { -- [vocation ID] = { female itemid, male itemid }
    [1] = { 2160, 2152 },
    [2] = { 2160, 2152 },
    [3] = { 2160, 2152 },
    [4] = { 2160, 2152 },
    [5] = { 2160, 2152 },
    [6] = { 2160, 2152 },
    [7] = { 2160, 2152 },
    [8] = { 2160, 2152 }
}

function onDeath(creature, corpse)
    if creature:isPlayer() then
        if corpse then
            local position = creature:getPosition()
            local isCorpse = ItemType(corpse:getId()):isCorpse()
            if isCorpse then
                local c = { corpse:getId(), corpse:getPosition(), creature:getVocation():getId(), creature:getSex() }
                addEvent(function(c)
                    local corpseId, position, vocId, sex = unpack(c)
                    print(corpseId, position, vocId, sex)
                    local corpse = position:getTile():getItemById(corpseId)
                    if corpse then
                        corpse:transform(corpseTransfom[vocId][sex+1])
                    end
                end, 50, c)
            end
        end
    end
return true
end

Creaturescripts.xml
Code:
<event type="death" name="ChangeCorpse" script="others/changecorpse.lua"/>

add in your login.lua
Code:
player:registerEvent('ChangeCorpse')
fdgdfgdfg.png
 
Code:
local corpseTransfom = { -- [vocation ID] = { female itemid, male itemid }
    [1] = { 2160, 2152 },
    [2] = { 2160, 2152 },
    [3] = { 2160, 2152 },
    [4] = { 2160, 2152 },
    [5] = { 2160, 2152 },
    [6] = { 2160, 2152 },
    [7] = { 2160, 2152 },
    [8] = { 2160, 2152 }
}

function onDeath(creature, corpse)
    if creature:isPlayer() then
        if corpse then
            local position = creature:getPosition()
            local isCorpse = ItemType(corpse:getId()):isCorpse()
            if isCorpse then
                local c = { corpse:getId(), corpse:getPosition(), creature:getVocation():getId(), creature:getSex() }
                addEvent(function(c)
                    local corpseId, position, vocId, sex = unpack(c)
                    --print(corpseId, position, vocId, sex)
                    local corpse = position:getTile():getItemById(corpseId)
                    if corpse then
                        corpse:transform(corpseTransfom[vocId][sex+1])
                    end
                end, 50, c)
            end
        end
    end
return true
end
You must remember that each vocation must have their respective ID
example: sorcerer is 1, master sorcerer is 5.. blabla
 
Code:
local corpseTransfom = { -- [vocation ID] = { female itemid, male itemid }
    [1] = { 2160, 2152 },
    [2] = { 2160, 2152 },
    [3] = { 2160, 2152 },
    [4] = { 2160, 2152 },
    [5] = { 2160, 2152 },
    [6] = { 2160, 2152 },
    [7] = { 2160, 2152 },
    [8] = { 2160, 2152 }
}

function onDeath(creature, corpse)
    if creature:isPlayer() then
        if corpse then
            local position = creature:getPosition()
            local isCorpse = ItemType(corpse:getId()):isCorpse()
            if isCorpse then
                local c = { corpse:getId(), corpse:getPosition(), creature:getVocation():getId(), creature:getSex() }
                addEvent(function(c)
                    local corpseId, position, vocId, sex = unpack(c)
                    --print(corpseId, position, vocId, sex)
                    local corpse = position:getTile():getItemById(corpseId)
                    if corpse then
                        corpse:transform(corpseTransfom[vocId][sex+1])
                    end
                end, 50, c)
            end
        end
    end
return true
end
You must remember that each vocation must have their respective ID
example: sorcerer is 1, master sorcerer is 5.. blabla
I think there is something wrong with your script
 
Code:
local corpseTransfom = { -- [vocation ID] = { female itemid, male itemid }
    [1] = { 2160, 2152 },
    [2] = { 2160, 2152 },
    [3] = { 2160, 2152 },
    [4] = { 2160, 2152 },
    [5] = { 2160, 2152 },
    [6] = { 2160, 2152 },
    [7] = { 2160, 2152 },
    [8] = { 2160, 2152 }
}

function onDeath(creature, corpse)
    if creature:isPlayer() then
        if corpse then
            local position = creature:getPosition()
            local isCorpse = ItemType(corpse:getId()):isCorpse()
            if isCorpse then
                local c = { corpse:getId(), corpse:getPosition(), creature:getVocation():getId(), creature:getSex() }
                addEvent(function(c)
                    local corpseId, position, vocId, sex = unpack(c)
                    --print(corpseId, position, vocId, sex)
                    local corpse = position:getTile():getItemById(corpseId)
                    if corpse then
                        corpse:transform(corpseTransfom[vocId][sex+1])
                    end
                end, 50, c)
            end
        end
    end
return true
end
You must remember that each vocation must have their respective ID
example: sorcerer is 1, master sorcerer is 5.. blabla
Corpses are not changing. Maybe because my all vocations has sex value 0?
 
Back
Top