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

Solved different corpses for each vocation

FilipeJF

New Member
Joined
Jan 9, 2012
Messages
124
Reaction score
4
In my server the vocations are different races.

I want to know how to make an elf become an elf when he die, a orc become an orc when die ... and so on.

I tried this script, but it did not work:

Code:
local array = {
  [1] = 2160,
  [2] = 2160,
  [3] = 2160,
  [4] = 2160
}

function onDeath(cid, corpse)
  doTransformItem(corpse.uid, array[getPlayerVocation(cid)], 1)
  doDecayItem(corpse.uid)
  return true
end

So, here I am, with the same doubt. Someone know how to make it work or another way to do this?
 
How about a C++ code?

vocations.h
Change:

Code:
int32_t lessLoss, capGain;
To:
Code:
int32_t lessLoss, capGain, corpse;


Under:
Code:
void setAttackable(bool v) {attackable = v;}
Add:
Code:
bool getCorpse() const {return corpse;}
void setCorpse(int32_t v) {corpse = v;}


vocations.cpp
Under:
Code:
if(readXMLInteger(p, "attackspeed", intValue))
    voc->setAttackSpeed(intValue);
Add:
Code:
if(readXMLInteger(p, "corpse", intValue))
    voc->setCorpse(intValue);


Under:
Code:
attackSpeed = 1500;
Add:
Code:
corpse = -1;

player.cpp
Change:
Code:
Item* corpse = Creature::createCorpse(deathList);
To:
Code:
Item* corpse;
if(getVocation()->getCorpse() >= 0)
    corpse = Item::CreateItem(getVocation()->getCorpse());
else
    corpse = Creature::createCorpse(deathList);

With this code you will be able to change corpses of each vocation.

Sample:
<vocation id="1" name="Sorcerer" description="a sorcerer" corpse="0" needpremium="0"...
When you type zero there, no corpse will be created. Delete whole corpse="" to use default ones.

Let me know if it's working, not tested.
 
So the most smart thing I can do is try to pass all my data to another Server with Sources.

Thanks for assistance.
 
Last edited:
Every server has sources, you just have to look around, I bet whatever you are using has sources available somewhere.
 
But the server needs to have an especific sources, alright? But I don't know who is the version of the TFS used in this.
 
It doesn't if nothing was changed before compilation but since "Sources Originais compiladas by Leozerarox" is not an original TFS message, it could be profoundly edited. Some functions may be added and after change they won't work. Don't worry, you can try. It's always a better choice to edit it by yourself.

Ah, version. It's probably TFS 0.4.
 
Oh, well; I can try.

But in your opinion, what would be the best thing to do? Pass the date folder to another server or try to modify the sources?
The first thing I would do, because I have no idea where to start modifying the sources.
 
You don't have sources so you can't modify it ;) First of all, download TFS 0.4 with sources and copy there current data folder. If there would be any errors with scripts, we can help you. Then check out few tutorials about compiling and add my code from 2nd reply.
 
Well, I'm back. When I try to compile in Dev-C++, I get this error: "libxml/xmlmemory.h: No such file or directory".

Someone know how to fix it? I never used Dev-C++ before, and I don't understand those erros.
 
There's a another way to make differents corpses of each vocation?
I compiled the server and I pass part of my data folder to the TFS 0.4. It's all ok, but the problem is the infinity "Connecting to the game world".
I'm really tired. I want to make the script of corpses works... But in another way.
 
Oh, well. I get some results... work fine with the code of Applezin (other forum member).


In Player.cpp, I searched for this code:

Code:
uint16_t Player::getLookCorpse() const
{
if(sex % 2)
return ITEM_MALE_CORPSE;
return ITEM_FEMALE_CORPSE;
}

And I overwrite this for this:

Code:
uint16_t Player::getLookCorpse() const
{
    uint16_t darkelf, geryon, dwarf, orc, elf, human, defaultt = 0;

    /*Config */

    darkelf = 2945;  // corpse of liz

    geryon = 3080;    // don't have the dead corpse yet

    dwarf = 2960;    // corpse dwarf

    orc = 3080;    // corpse normalorc

    elf = 2945;    // corpse of elf

    human = 3058;    // corpse do knight
  
    defaultt = 3354;    // corpse padrão.

    /*End */

    if (getVocationId() == 1 || getVocationId() == 1)
        return darkelf;

    else if (getVocationId() == 2 || getVocationId() == 2)
        return geryon;

    else if (getVocationId() == 3 || getVocationId() == 3)
        return  dwarf;

    else if (getVocationId() == 4 || getVocationId() == 4)
        return orc;
  
    else if (getVocationId() == 5 || getVocationId() == 5)
        return elf;
  
    else if (getVocationId() == 6 || getVocationId() == 6)
        return human;

    return defaultt;
}

So I compiled. I take the executable arquive and throw into my old server folder, and that works fine. But one problem persists...
The corpse of Elf and Human are working perfectly. When an elf die, he becomes an dead elf. When an human dies, he becomes an dead human. But ALL the others vocations disappears when die. Only the blood remains; the corpse, dissapear. Why is this hapening?

edit:
the real code is: (from tutorial of Applez):

Code:
uint16_t Player::getLookCorpse() const

{

    uint16_t sorcerer, druid, paladin, knight, defaultt = 0;

    /*Config */

    sorcerer = 3343;  // corpse do sorcerer

    druid = 3343;    // corpse do druid

    paladin = 3343;    // corpse do paladin

    knight = 334;    // corpse do knight
      
    defaultt = 3354;    // corpse padrão.

    /*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;
}
 
Last edited:
How about a C++ code?

vocations.h
Change:

Code:
int32_t lessLoss, capGain;
To:
Code:
int32_t lessLoss, capGain, corpse;


Under:
Code:
void setAttackable(bool v) {attackable = v;}
Add:
Code:
bool getCorpse() const {return corpse;}
void setCorpse(int32_t v) {corpse = v;}


vocations.cpp
Under:
Code:
if(readXMLInteger(p, "attackspeed", intValue))
    voc->setAttackSpeed(intValue);
Add:
Code:
if(readXMLInteger(p, "corpse", intValue))
    voc->setCorpse(intValue);

Under:
Code:
attackSpeed = 1500;
Add:
Code:
corpse = -1;

player.cpp
Change:
Code:
Item* corpse = Creature::createCorpse(deathList);
To:
Code:
Item* corpse;
if(getVocation()->getCorpse() >= 0)
    corpse = Item::CreateItem(getVocation()->getCorpse());
else
    corpse = Creature::createCorpse(deathList);

With this code you will be able to change corpses of each vocation.

Sample:
<vocation id="1" name="Sorcerer" description="a sorcerer" corpse="0" needpremium="0"...
When you type zero there, no corpse will be created. Delete whole corpse="" to use default ones.

Let me know if it's working, not tested.

One problem with that edit is there is no check for the gender of the vocation.

Minor issue, but still an important one.
 
Back
Top