Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

Not tested but I wrote them anyway... this is a means of adding the missing stat information in TFS 1.3 & OTX 3 for 10.98 & up.

 

This is the previous code protocolgame.cpp in TFS 1.3

void ProtocolGame::AddPlayerStats(NetworkMessage& msg)
{
    msg.addByte(0xA0);
 
    msg.add<uint16_t>(std::min<int32_t>(player->getHealth(), std::numeric_limits<uint16_t>::max()));
    msg.add<uint16_t>(std::min<int32_t>(player->getMaxHealth(), std::numeric_limits<uint16_t>::max()));
 
    msg.add<uint32_t>(player->getFreeCapacity());
    msg.add<uint32_t>(player->getCapacity());
 
    msg.add<uint64_t>(player->getExperience());
 
    msg.add<uint16_t>(player->getLevel());
    msg.addByte(player->getLevelPercent());
 
    msg.add<uint16_t>(100); // base xp gain rate
    msg.add<uint16_t>(0); // xp voucher
    msg.add<uint16_t>(0); // low level bonus
    msg.add<uint16_t>(0); // xp boost
    msg.add<uint16_t>(100); // stamina multiplier (100 = x1.0)
 
    msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
    msg.add<uint16_t>(std::min<int32_t>(player->getMaxMana(), std::numeric_limits<uint16_t>::max()));
 
    msg.addByte(std::min<uint32_t>(player->getMagicLevel(), std::numeric_limits<uint8_t>::max()));
    msg.addByte(std::min<uint32_t>(player->getBaseMagicLevel(), std::numeric_limits<uint8_t>::max()));
    msg.addByte(player->getMagicLevelPercent());
 
    msg.addByte(player->getSoul());
 
    msg.add<uint16_t>(player->getStaminaMinutes());
 
    msg.add<uint16_t>(player->getBaseSpeed() / 2);
 
    Condition* condition = player->getCondition(CONDITION_REGENERATION);
    msg.add<uint16_t>(condition ? condition->getTicks() / 1000 : 0x00);
 
    msg.add<uint16_t>(player->getOfflineTrainingTime() / 60 / 1000);
 
    msg.add<uint16_t>(0); // xp boost time (seconds)
    msg.addByte(0); // enables exp boost in the store
}

The focus of what we want to change here is this

    msg.add<uint16_t>(100); // base xp gain rate
    msg.add<uint16_t>(0); // xp voucher
    msg.add<uint16_t>(0); // low level bonus
    msg.add<uint16_t>(0); // xp boost
    msg.add<uint16_t>(100); // stamina multiplier (100 = x1.0)

and this

msg.add<uint16_t>(0); // xp boost time (seconds)
msg.addByte(0); // enables exp boost in the store

 

 

To do this we'll use storage values that are referenced via methods of the player class.
Our new code will look something like this.

    // base xp gain rate
    msg.add<uint16_t>(player->getBaseXpGain());
    // xp voucher
    msg.add<uint16_t>(player->getVoucherXpBoost());
    // low level bonus
    msg.add<uint16_t>(player->getGrindingXpBoost());
    // xp boost
    msg.add<uint16_t>(player->getStoreXpBoost());
    // stamina multiplier (100 = x1.0)
    msg.add<uint16_t>(player->getStaminaXpBoost());

and this

    // xp boost time (seconds)
    msg.add<uint16_t>(player->getExpBoostStamina());
    // enables exp boost in the store
    msg.addByte(1);

 

In player.h
Under

#include "mounts.h"

place this

#include "configmanager.h"

 

 

Under

class Guild;

place this

extern ConfigManager g_config;

 

 

Under

bool hasLearnedInstantSpell(const std::string& spellName) const;

place this

        uint16_t getBaseXpGain() const {
            uint32_t key = g_config.getNumber(ConfigManager::BASEXPGAIN_STORAGE);
            int32_t value;
            getStorageValue(key, value);
            return (value < 0 ? 100 : (uint16_t)value);
        }
        uint16_t getVoucherXpBoost() const {
            uint32_t key = g_config.getNumber(ConfigManager::VOUCHERXPBOOST_STORAGE);
            int32_t value;
            getStorageValue(key, value);
            return (value < 0 ? 100 : (uint16_t)value);
        }
        uint16_t getGrindingXpBoost() const {
            uint32_t key = g_config.getNumber(ConfigManager::GRINDINGXPBOOST_STORAGE);
            int32_t value;
            getStorageValue(key, value);
            return (value < 0 ? 100 : (uint16_t)value);
        }
        uint16_t getStoreXpBoost() const {
            uint32_t key = g_config.getNumber(ConfigManager::STOREXPBOOST_STORAGE);
            int32_t value;
            getStorageValue(key, value);
            return (value < 0 ? 100 : (uint16_t)value);
        }
        uint16_t getStaminaXpBoost() const {
            uint32_t key = g_config.getNumber(ConfigManager::STATMINAXPBOOST_STORAGE);
            int32_t value;
            getStorageValue(key, value);
            return (value < 0 ? 100 : (uint16_t)value);
        }
        uint16_t getExpBoostStamina() {
            uint32_t key = g_config.getNumber(ConfigManager::EXPBOOSTSTAMINA_STORAGE);
            int32_t value;
            getStorageValue(key, value);
            return (value < 0 ? 100 : (uint16_t)value);
        }

 

 

Next we'll go into configmanger.cpp and find

integer[MAX_PACKETS_PER_SECOND] = getGlobalNumber(L, "maxPacketsPerSecond", 25);

and place this under it

    integer[BASEXPGAIN_STORAGE] = getGlobalNumber(L, "baseXpGain", 18000);
    integer[VOUCHERXPBOOST_STORAGE] = getGlobalNumber(L, "voucherXpBoost", 18001);
    integer[GRINDINGXPBOOST_STORAGE] = getGlobalNumber(L, "grindingXpBoost", 18002);
    integer[STOREXPBOOST_STORAGE] = getGlobalNumber(L, "storeXpBoost", 18003);
    integer[STATMINAXPBOOST_STORAGE] = getGlobalNumber(L, "staminaXpBoost", 18004);
    integer[EXPBOOSTSTAMINA_STORAGE] = getGlobalNumber(L, "expBoostStamina", 18005);

 

Then open up configmanager.h and find

MAX_PACKETS_PER_SECOND,

and place these under it

            BASEXPGAIN_STORAGE,
            VOUCHERXPBOOST_STORAGE,
            GRINDINGXPBOOST_STORAGE,
            STOREXPBOOST_STORAGE,
            STATMINAXPBOOST_STORAGE,
            EXPBOOSTSTAMINA_STORAGE,

 

Then add this to your config.lua

-- storages for player stats
baseXpGain = 18000
voucherXpBoost = 18001
grindingXpBoost = 18002
storeXpBoost = 18003
staminaXpBoost = 18004
expBoostStamina = 18005

 

Since it is just storage values then its just a matter of setting the correct storages to set the bonuses. if no value is set then it is set to a default of 100.

Here is a screen shot to show you that this works

statsbonus.thumb.png.85db639cbf11bceb4da7e6fd779955ca.png

 

This code is incomplete I will update it when I have time. :)

Editado por Codex NG (veja o histórico de edições)

Postado

Parabéns, seu tópico de conteúdo foi aprovado!
Muito obrigado pela sua contribuição, nós do Tibia King agradecemos.
Seu conteúdo com certeza ajudará à muitos outros, você recebeu +1 REP.

Spoiler

Congratulations, your content has been approved!
Thank you for your contribution, we of Tibia King we are grateful.
Your content will help many other users, you received +1 REP.

 

Postado

Bom bom! Ficou bem mais detalhado as informações. Espero que continue a aperfeiçoar o código. ;)

 

Very good! Informations was much more detailed. I hope you continue to refine the code. ;)

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo