• 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.4] Disable fromVoc

secondlife

Member
Joined
Aug 1, 2009
Messages
298
Reaction score
23
hi guys, how are you?

I wonder if someone more experienced can help me with this.
On my server I have new vocations (9~20) and I am trying to disable "fromVoc". For example:
Code:
<vocation id = "17" name = "Ancient Knight" description = "a ancient knight" needpremium = "0" gaincap = "75" gainhp = "55" gainmana = "20" gainhpticks = "1" gainhpamount = "19" gainmanaticks = "1" gainmanaamount = "12" manamultiplier = "3.0" attackspeed = "500" soulmax = "250" gainsoulticks = "2" gainsoulamount = "3" fromvoc = "16" lessloss = "30">
....

However, every time the character with voc 17 logout and login again, he goes back to vocation 16. I want to disable this function of returning the character to fromVoc.
I tried to remove it here, but it didn't work:
PLAYER.CPP

Code:
void Player::setPromotionLevel(uint32_t pLevel)
{
    if(pLevel > promotionLevel)
    {
        uint32_t tmpLevel = 0, currentVoc = vocationId;
        for(uint32_t i = promotionLevel; i < pLevel; ++i)
        {
            currentVoc = Vocations::getInstance()->getPromotedVocation(currentVoc);
            if(!currentVoc)
                break;

            tmpLevel++;
            Vocation* voc = Vocations::getInstance()->getVocation(currentVoc);
            if(voc->isPremiumNeeded() && !isPremium() && g_config.getBool(ConfigManager::PREMIUM_FOR_PROMOTION))
                continue;

            vocationId = currentVoc;
        }

        promotionLevel += tmpLevel;
    }
    else if(pLevel < promotionLevel)
    {
        uint32_t tmpLevel = 0, currentVoc = vocationId;
        for(uint32_t i = pLevel; i < promotionLevel; ++i)
        {
            Vocation* voc = Vocations::getInstance()->getVocation(currentVoc);
            if(voc->getFromVocation() == currentVoc)
                break;

            tmpLevel++;
            currentVoc = voc->getFromVocation();
            if(voc->isPremiumNeeded() && !isPremium() && g_config.getBool(ConfigManager::PREMIUM_FOR_PROMOTION))
                continue;

            vocationId = currentVoc;
        }

        promotionLevel -= tmpLevel;
    }

    setVocation(vocationId);
}

I just want to disable the line in the source that makes the character come back from vocation (fromVoc), but i am not able to find it. Is this more complicated than i think?

Thank you guys!!
 
Set the fromVoc to the vocId?

XML:
<vocation
    id="17"
    fromvoc="17"
    name="Ancient Knight"
    description="a ancient knight"
    needpremium="0"
    gaincap="75"
    gainhp="55"
    gainmana="20"
    gainhpticks="1"
    gainhpamount="19"
    gainmanaticks="1"
    gainmanaamount="12"
    manamultiplier="3.0"
    attackspeed="500"
    soulmax="250"
    gainsoulticks="2"
    gainsoulamount="3"
    lessloss="30">
 
Alright' I'm looking at the code. There is checks against the player's promotion level both on player load and playersave. Are you using some custom npc or method to promote players? Why not just set the promotion level correctly?

On player load the Player::setPromotionLevel is called and can downgrade the player
At player save the IOLoginData::savePlayer is called and can downgrade the player

Both are checking against promotion level.
 
Hi @Lessaire!

Thank you so much for your answer.

In that section of the code at iologindata.cpp:
Code:
Vocation * tmpVoc = player-> vocation;
// for (uint32_t i = 0; i <= player-> promotionLevel; ++ i)
// tmpVoc = Vocations :: getInstance () -> getVocation (tmpVoc-> getFromVocation ());
query << "` vocation` = "<< tmpVoc-> getId () <<" WHERE `id` =" << player-> getGUID () << db-> getUpdateLimiter ();
I commented this part of the code (with //), leaving it disabled and it worked. The character did not return to fromVoc. Do you think I may have a problem with the server removing this? For the system, it worked perfectly. I don't use any type of promotionLevel, all players will have promotion = 0 in the database.

Thanks!
 
Then how do players get their vocation?

I believe you would be better served by fixing the logic of your implementation than altering the logic of your server.

Post automatically merged:


Maybe this is your actual problem: all players will have promotion = 0 in the database.
That's what you should fix, just set everyones promotion to 1.

Bash:
# replace mariadb with mysql if you don't use maria
# most distros, where root@localhost can always login
sudo mariadb
# Ubuntu, who thinks you should protect against root@localhost. Will prompt you for root database user's password
sudo mariadb -p

SQL:
# This should get you into your database. You could also use the user and pass from your config.lua
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 92
Server version: 10.4.12-MariaDB Arch Linux

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
# Once in your database server shell, select your database by name, replacing %dbname% with it's name.
MariaDB [(none)]> USE %dbname% ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
# Lets check out the situation.
MariaDB [otserver]> SELECT promotion FROM players;             
+-----------+
| promotion |
+-----------+
|         0 |
|         0 |
|         0 |
+-----------+
3 rows in set (0.001 sec)

# Lets change them all!
MariaDB [otserver]> UPDATE players SET promotion = 1;
Query OK, 3 rows affected (0.040 sec)
Rows matched: 3 Changed: 3 Warnings: 0

MariaDB [otserver]> SELECT promotion FROM players;
+-----------+
| promotion |
+-----------+
|         1 |
|         1 |
|         1 |
+-----------+
3 rows in set (0.001 sec)

# That's it! Done!
MariaDB [otserver]> QUIT;


I do believe my first answer should also work, even with promotion level being 0. Observe the default vocations: Their fromvoc == id
XML:
    <vocation id="0" clientId="0" name="None"                         fromvoc="0" attackable="no" droploot="no">
    <vocation id="1" clientId="3" name="Sorcerer"                     fromvoc="1">
    <vocation id="2" clientId="4" name="Druid"                        fromvoc="2">
    <vocation id="3" clientId="2" name="Paladin"                      fromvoc="3">
    <vocation id="4" clientId="1" name="Knight"                       fromvoc="4">
    <vocation id="5" clientId="3" name="Master Sorcerer"              fromvoc="1" lessloss="30">
    <vocation id="6" clientId="4" name="Elder Druid"                  fromvoc="2" lessloss="30">
    <vocation id="7" clientId="2" name="Royal Paladin"                fromvoc="3" lessloss="30">
    <vocation id="8" clientId="1" name="Elite Knight"                 fromvoc="4" lessloss="30">

The engine probably presumes any vocation where the fromvoc is not the same as the id is a promoted vocation. Which your XML you presented qualifies for.
 
Last edited:
Back
Top