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

Lua [tfs 1.3] Adding new corspes

Cebal

Member
Joined
Aug 28, 2009
Messages
18
Solutions
2
Reaction score
8
Ok guys, here I come with another problem. I know it's probably the most basic thing but Im struggling with adding new corpses for my new custom vocations and outfits. I added many monsters and some player outfit with new vocations like voc 1-30 but now Im trying to add corspes for every new vocation I added and have no idea where to look for it. Managed to replace old corpses in .spr file but it wont help me to be honest. I searched forum but could not find any helpfull information on adding new ones. Thanks in advance
 
Solution
Bump,
so I added item (corpse/container) which is itemid 26515 in itemx.xml, and tried to change in player.cpp code:
Lua:
uint16_t Player::getLookCorpse() const
{
if(sex % 2)
return ITEM_MALE_CORPSE;
return ITEM_FEMALE_CORPSE;
}

for this one:
Code:
uint16_t Player::getLookCorpse() const
{
    uint16_t sorcerer, druid, paladin, knight, defaultt = 0;

    /*Config */

    sorcerer = 26515;
    druid = 3343;
    paladin = 3343;
    knight = 334;
    defaultt = 3354;

    /*End */

    if (getVocationId() == 1 || getVocationId() == 5)
        return sorcerer;
    else if (getVocationId() == 2 || getVocationId() == 6)
        return druid;
    else if (getVocationId() == 3 || getVocationId() == 7)
        return  paladin;
    else if...
Bump,
so I added item (corpse/container) which is itemid 26515 in itemx.xml, and tried to change in player.cpp code:
Lua:
uint16_t Player::getLookCorpse() const
{
if(sex % 2)
return ITEM_MALE_CORPSE;
return ITEM_FEMALE_CORPSE;
}

for this one:
Code:
uint16_t Player::getLookCorpse() const
{
    uint16_t sorcerer, druid, paladin, knight, defaultt = 0;

    /*Config */

    sorcerer = 26515;
    druid = 3343;
    paladin = 3343;
    knight = 334;
    defaultt = 3354;

    /*End */

    if (getVocationId() == 1 || getVocationId() == 5)
        return sorcerer;
    else if (getVocationId() == 2 || getVocationId() == 6)
        return druid;
    else if (getVocationId() == 3 || getVocationId() == 7)
        return  paladin;
    else if (getVocationId() == 4 || getVocationId() == 8)
        return knight;
    return defaultt;
}

Recompiled and unfortunatelly when I die I still have "dead human" coprse instead of my corpse with my sprites... It seems like this code did not affect on corpse change on death so Im thinking it has to be somewhere else, not only player.cpp. Anyone?






EDIT:
kk, I solved it!

So I reverted player.cpp changes back and tried to do something via creaturescripts and it worked!
Here's the solution if anyone will have the same problem in the future with newer tfs':

In data\creaturescripts\scripts create corpse.lua file and put this code inside:
Lua:
local array = {
  [1] = 26515,
  [5] = 26515,
  [9] = 26515,
  [10] = 26515,
  [32] = 26516,
  [33] = 26516,
  [34] = 26516
}

function onDeath(cid, corpse)
  doTransformItem(corpse.uid, array[getPlayerVocation(cid)], 1)
  doDecayItem(corpse.uid)
  return true
end
26515 and 26516 are my corpse and it's the itemid from items.xml so change it for your corpses id. [1], [5] etc are my vocations from vocations.xml.

Now in creaturescripts.xml put:
Code:
<event type="death" name="SetPlayerCorpseOut" script="corpse.lua"/>

And the last thing is to put this code to login.lua:
Code:
player:registerEvent("SetPlayerCorpseOut")
 
Last edited:
Solution
If someone wants to use it in Revscript here it is:

data/scripts/vocationcorpses.lua
Lua:
local vocationCorpses = {
    -- [VocationID] = CorpseID
    [1] = 26515,
    [5] = 26515,
    [9] = 26515,
    [10] = 26515,
    [32] = 26516,
    [33] = 26516,
    [34] = 26516
}

local creatureEvent = CreatureEvent("vocationCorpsesDeath")
function creatureEvent.onDeath(player, corpse)
    local newCorpseId = vocationCorpses[player:getVocation():getId()]
    if newCorpseId then
        corpse:transform(newCorpseId)
        corpse:decay()
    end
    return true
end
creatureEvent:register()

creatureEvent = CreatureEvent("vocationCorpsesLogin")
function creatureEvent.onLogin(player)
    player:registerEvent("vocationCorpsesDeath")
    return true
end
creatureEvent:register()
 
Back
Top