• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua Otbr TFS 1.3 New vocation crash

alejandro762

Member
Joined
Sep 6, 2021
Messages
105
Reaction score
15
Hello everyone,

As i Try to add a new vocation on otservbr editing this files,
"Crusader" Vocation.

Data/lib/core/player.lua ( added):
Lua:
function Player.isCrusader(self)
    return table.contains({VOCATION.ID.CRUSADER, VOCATION.ID.CRUSADER}, self:getVocation():getId())
end
Data/lib/tables/vocations.lua(added):
Code:
VOCATION = {
    ID = {
        NONE = 0,
        SORCERER = 1,
        DRUID = 2,
        PALADIN = 3,
        KNIGHT = 4,
        MASTER_SORCERER = 5,
        ELDER_DRUID = 6,
        ROYAL_PALADIN = 7,
        ELITE_KNIGHT = 8,
        CRUSADER = 9
    },
    CLIENT_ID = {
        NONE = 0,
        KNIGHT = 1,
        PALADIN = 2,
        SORCERER = 3,
        DRUID = 4,
        ELITE_KNIGHT = 11,
        ROYAL_PALADIN = 12,
        MASTER_SORCERER = 13,
        ELDER_DRUID = 14,
        CRUSADER = 15
    },
    BASE_ID = {
        NONE = 0,
        SORCERER = 1,
        DRUID = 2,
        PALADIN = 3,
        KNIGHT = 4,
        CRUSADER = 5
    }
}

Data/vocations.xml
Code:
<vocation id="9" clientid="15" baseid="5" name="Crusader" description="a Crusader" magicshield="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="4000" gainhpamount="1" gainmanaticks="6000" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" basespeed="220" soulmax="200" gainsoulticks="15000" fromvoc="4">
        <formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
        <skill id="0" multiplier="1.1" />
        <skill id="1" multiplier="1.1" />
        <skill id="2" multiplier="1.1" />
        <skill id="3" multiplier="1.1" />
        <skill id="4" multiplier="1.4" />
        <skill id="5" multiplier="1.1" />
        <skill id="6" multiplier="1.1" />
    </vocation>

Website:
Code:
9 => array(
            'name' => 'CRUSADER',
            'fromVoc' => false
        )
      
        // After
      
        9 => array(
            'hp' => 15,
            'mp' => 5,
            'cap' => 25
        ),
      
        //after
        5 => array(
                    'magic' => 0,
                    'fist' => 10,
                    'club' => 10,
                    'axe' => 10,
                    'sword' => 10,
                    'dist' => 10,
                    'shield' => 10,
                    'fishing' => 10,
                ),

When i try enter i got a directly crash of server, debug from visual took me to sources from a 'familiar' code show as error. ( I will post it in many hours).

Familiar i just copy paste the knight familiar and added Id 9
Code:
<familiar vocation="9" lookType="1365" name="Snowbash" premium="yes" unlocked="no" enabled="yes" />


Error Showed on Debug Visual Studio 2019: ( error appears with or without familiar added ).

Exception thrown: read access violation.
familiar was 0xFFFFFFFFFFFFFFDD.

Player.cpp: Is returning this:

Code:
    if (familiar.premium && !isPremium()) {
        return false;

@EduardoDantas
 
Last edited:
Solution
Yes, o changed too,but i got a crash directly, and when player remains online when i try log in with another normal voc, reaching the position of the new voc, it crashes too.
Using 9 or 15, doesnt work.


I edit the familiars and added lines,
Familiars.xml, create a file crusader_familiar.lua with utevo gran res test, vocation, crusader, etc, and still crashing, but now is the client, so can see anything, just , enum value error. Maybe is not possible to add a new one using normal tibia client ?

Something like add custom sprites on bestiary, giving dimensions on assets editor , Monsters doesnt appear at the middle of picture, but cutted of at left, there is no way to move the picture.
Client Id, put it to 11. I am not sure, but...

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,033
Solutions
15
Reaction score
323
Location
Sweden
YouTube
Joriku
You're forgetting to add the vocation through sources, should be inside creatures_definitions.hpp

Lua:
enum Vocation_t : uint16_t {
    VOCATION_NONE = 0,
    VOCATION_SORCERER = 1,
    VOCATION_DRUID = 2,
    VOCATION_PALADIN = 3,
    VOCATION_KNIGHT = 4,
    VOCATION_MASTER_SORCERER = 5,
    VOCATION_ELDER_DRUID = 6,
    VOCATION_ROYAL_PALADIN = 7,
    VOCATION_ELITE_KNIGHT = 8,
    add your vocation here
    VOCATION_LAST = VOCATION_ELITE_KNIGHT -- then edit this to be the last vocation that you just created.
};
 

Niebieski

kasteria.pl
Premium User
Joined
Jan 29, 2010
Messages
602
Solutions
1
Reaction score
223
Location
Poland
Also, I'm not sure if you should use base_id 5 for the crusader, as it's taken by 'master sorcerer' vocation
 
OP
OP
alejandro762

alejandro762

Member
Joined
Sep 6, 2021
Messages
105
Reaction score
15
You're forgetting to add the vocation through sources, should be inside creatures_definitions.hpp

Lua:
enum Vocation_t : uint16_t {
    VOCATION_NONE = 0,
    VOCATION_SORCERER = 1,
    VOCATION_DRUID = 2,
    VOCATION_PALADIN = 3,
    VOCATION_KNIGHT = 4,
    VOCATION_MASTER_SORCERER = 5,
    VOCATION_ELDER_DRUID = 6,
    VOCATION_ROYAL_PALADIN = 7,
    VOCATION_ELITE_KNIGHT = 8,
    add your vocation here
    VOCATION_LAST = VOCATION_ELITE_KNIGHT -- then edit this to be the last vocation that you just created.
};
Now seems the console isn't crashing.

Now is the client crashing with an error "invalid enum value".
I just add:
Lua:
VOCATION_CRUSADER = 9,
VOCATION_LAST = VOCATION_CRUSADER

Code:
2022-08-02, 00:28:13: Error while processing network packet unhandled enum value

From here i edited all to number 9:
Code:
Code:
VOCATION = {
    ID = {
        NONE = 0,
        SORCERER = 1,
        DRUID = 2,
        PALADIN = 3,
        KNIGHT = 4,
        MASTER_SORCERER = 5,
        ELDER_DRUID = 6,
        ROYAL_PALADIN = 7,
        ELITE_KNIGHT = 8,
        CRUSADER = 9
    },
    CLIENT_ID = {
        NONE = 0,
        KNIGHT = 1,
        PALADIN = 2,
        SORCERER = 3,
        DRUID = 4,
        ELITE_KNIGHT = 11,
        ROYAL_PALADIN = 12,
        MASTER_SORCERER = 13,
        ELDER_DRUID = 14,
        CRUSADER = 9
    },
    BASE_ID = {
        NONE = 0,
        SORCERER = 1,
        DRUID = 2,
        PALADIN = 3,
        KNIGHT = 4,
        CRUSADER = 9
    }
 
OP
OP
alejandro762

alejandro762

Member
Joined
Sep 6, 2021
Messages
105
Reaction score
15
CLIENT_ID i think u are using 15 not 9
Post automatically merged:

<vocation id="9" clientid="15"
Yes, o changed too,but i got a crash directly, and when player remains online when i try log in with another normal voc, reaching the position of the new voc, it crashes too.
Using 9 or 15, doesnt work.

I think you have to edit files with familiars system
I edit the familiars and added lines,
Familiars.xml, create a file crusader_familiar.lua with utevo gran res test, vocation, crusader, etc, and still crashing, but now is the client, so can see anything, just , enum value error. Maybe is not possible to add a new one using normal tibia client ?

Something like add custom sprites on bestiary, giving dimensions on assets editor , Monsters doesnt appear at the middle of picture, but cutted of at left, there is no way to move the picture.
 

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,033
Solutions
15
Reaction score
323
Location
Sweden
YouTube
Joriku
Yes, o changed too,but i got a crash directly, and when player remains online when i try log in with another normal voc, reaching the position of the new voc, it crashes too.
Using 9 or 15, doesnt work.


I edit the familiars and added lines,
Familiars.xml, create a file crusader_familiar.lua with utevo gran res test, vocation, crusader, etc, and still crashing, but now is the client, so can see anything, just , enum value error. Maybe is not possible to add a new one using normal tibia client ?

Something like add custom sprites on bestiary, giving dimensions on assets editor , Monsters doesnt appear at the middle of picture, but cutted of at left, there is no way to move the picture.
Client Id, put it to 11. I am not sure, but I think I read that it was no longer in use which may even be written in the sources marked out above. I did this a while ago for someone which resulted in the usage of client id 11 in the vocations.xml.

And no, you do not have to touch the familiars unless you want the vocation to be able to use it.

"Yes, o changed too,but i got a crash directly, and when player remains online when i try log in with another normal voc, reaching the position of the new voc, it crashes too."
- Yes, it does result in that if the vocation is not imported.
 
Solution
OP
OP
alejandro762

alejandro762

Member
Joined
Sep 6, 2021
Messages
105
Reaction score
15
Client Id, put it to 11. I am not sure, but I think I read that it was no longer in use which may even be written in the sources marked out above. I did this a while ago for someone which resulted in the usage of client id 11 in the vocations.xml.

And no, you do not have to touch the familiars unless you want the vocation to be able to use it.

"Yes, o changed too,but i got a crash directly, and when player remains online when i try log in with another normal voc, reaching the position of the new voc, it crashes too."
- Yes, it does result in that if the vocation is not imported.
OMG.

Is working, but simple question, is this make any interference with the Elite Knight Client ID 11, or nothing with EK ?.
So if i wish to create another one, i just add 12 ( pally ?) on client id till the 14 Client ID , right ?

Thanks again man!
 

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,033
Solutions
15
Reaction score
323
Location
Sweden
YouTube
Joriku
OMG.

Is working, but simple question, is this make any interference with the Elite Knight Client ID 11, or nothing with EK ?.
So if i wish to create another one, i just add 12 ( pally ?) on client id till the 14 Client ID , right ?

Thanks again man!
No, so far as I know it should not matter with the client id. However it may say in the login menu if you login then logout that your character is an Elite Knight. But it does not conflict or mess up the character or it's vocation. It's simply just the display function as far as I am aware.

Not sure where client id is located to add a new id into it. Did not care enough to look into it sadly.

Best of luck.
- Joriku
 
OP
OP
alejandro762

alejandro762

Member
Joined
Sep 6, 2021
Messages
105
Reaction score
15
No, so far as I know it should not matter with the client id. However it may say in the login menu if you login then logout that your character is an Elite Knight. But it does not conflict or mess up the character or it's vocation. It's simply just the display function as far as I am aware.

Not sure where client id is located to add a new id into it. Did not care enough to look into it sadly.

Best of luck.
- Joriku
I look in many files, then i dont find it also.
I Just move to 0, in order to display when CTRL+G, None, in vocation.
Is working perfectly , spells, familiar, all.

Thanks very much Joriku, i will add your name to the list of people helping on the project.
 
Top