• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 0.X [C++] Increase the magic level limit.

potinho

Advanced OT User
Joined
Oct 11, 2009
Messages
1,493
Solutions
17
Reaction score
187
Location
Brazil
For some reason, the Magic Level on my OTXServer 2 limits the Magic Level. The original values are considerably high, but I would like players to have the possibility to got higher Magic Levels. Actually the limit (for use spells, without consider item bonus, etc) is something around 156 for mages and 14 for knights, for example.
I guess that can be related to those codes:


C++:
void Player::addManaSpent(uint64_t amount, bool useMultiplier/* = true*/)
{
    if(!amount)
        return;

    uint64_t currReqMana = vocation->getReqMana(magLevel), nextReqMana = vocation->getReqMana(magLevel + 1);
    if(magLevel > 0 && currReqMana > nextReqMana) //player has reached max magic level
        return;

    if(useMultiplier)
        amount = uint64_t((double)amount * rates[SKILL__MAGLEVEL] * g_config.getDouble(ConfigManager::RATE_MAGIC));

    std::stringstream s;
    while(manaSpent + amount >= nextReqMana)
    {
        amount -= nextReqMana - manaSpent;
        manaSpent = 0;

        s.str("");
        s << "You advanced to magic level " << ++magLevel << ".";
        sendTextMessage(MSG_EVENT_ADVANCE, s.str());

        CreatureEventList advanceEvents = getCreatureEvents(CREATURE_EVENT_ADVANCE);
        for(CreatureEventList::iterator it = advanceEvents.begin(); it != advanceEvents.end(); ++it)
            (*it)->executeAdvance(this, SKILL__MAGLEVEL, (magLevel - 1), magLevel);

        currReqMana = nextReqMana;
        nextReqMana = vocation->getReqMana(magLevel + 1);
        if(currReqMana > nextReqMana)
        {
            amount = 0;
            break;
        }
    }

    if(amount)
        manaSpent += amount;

    uint16_t newPercent = Player::getPercentLevel(manaSpent, nextReqMana);
    if(magLevelPercent != newPercent)
    {
        magLevelPercent = newPercent;
        sendStats();
    }
    else if(!s.str().empty())
        sendStats();
}

C++:
uint64_t Vocation::getReqMana(uint32_t magLevel)
{
    if(!magLevel)
        return 0;

    cacheMap::iterator it = cacheMana.find(magLevel);
    if(it != cacheMana.end())
        return it->second;

    cacheMana[magLevel] = (uint64_t)(1600 * std::pow(formulaMultipliers[MULTIPLIER_MANA], (float)(magLevel - 1)));
    return cacheMana[magLevel];
}

I'm using OTCv8, so i guess client it will be not a problem, since skills are going through 255+
 
Use double skill, stats features.
For change protocolgame bytes uint8_t to uint16_t
i'm already using
LUA:
g_game.enableFeature(GameDoubleSkills)
on client and on protocolgame i've changed too, seems to be not just a visual thing...

C++:
void ProtocolGame::AddPlayerStats(NetworkMessage_ptr msg)
{
    msg->put<char>(0xA0);
    msg->put<uint32_t>(player->getHealth());
    msg->put<uint32_t>(player->getPlayerInfo(PLAYERINFO_MAXHEALTH));

    uint32_t capacity = uint32_t(player->getFreeCapacity());
    if (capacity >= INT32_MAX)
        msg->put<uint32_t>(INT32_MAX);
    else
        msg->put<uint32_t>(capacity);

    uint64_t experience = player->getExperience();
    msg->put<uint64_t>(experience);

    #ifdef _MULTIPLATFORM76
    msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_LEVEL));
    #else
    msg->put<char>(player->getPlayerInfo(PLAYERINFO_LEVEL));
    #endif
    msg->put<char>(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT));
    msg->put<uint32_t>(player->getPlayerInfo(PLAYERINFO_MANA));
    msg->put<uint32_t>(player->getPlayerInfo(PLAYERINFO_MAXMANA));
    msg->put<char>(player->getPlayerInfo(PLAYERINFO_MAGICLEVEL));
    msg->put<char>(player->getPlayerInfo(PLAYERINFO_MAGICLEVELPERCENT));
    #ifdef _MULTIPLATFORM76
    msg->put<char>(player->getPlayerInfo(PLAYERINFO_SOUL));
    #endif
}
 
knights manaspent value on database is stucked on 3357783040, on ml 14 and for mage mlvl got stucked on ml 156 with manaspent value 290467280. On database we already using BIGINT with UNSIGNED flag for manaspent column.

Also here's cacheMap on vocation.h:


C++:
        double getExperienceMultiplier() const {return skillMultipliers[SKILL__LEVEL];}
        void setSkillMultiplier(skills_t s, float v) {skillMultipliers[s] = v;}
        void setSkillBase(skills_t s, uint32_t v) {skillBase[s] = v;}

        uint64_t getReqSkillTries(int32_t skill, int32_t level);
        uint64_t getReqMana(uint32_t magLevel);

    private:
        typedef std::map<uint32_t, uint64_t> cacheMap;
        cacheMap cacheSkill[SKILL_LAST + 1];
        cacheMap cacheMana;

        bool attackable, needPremium, dropLoot, skillLoss;
        uint16_t clientId;
        int32_t lessLoss, capGain;
        uint32_t id, fromVocation, baseSpeed, attackSpeed;
        std::string name, description;

        int16_t absorb[COMBAT_LAST + 1], reflect[REFLECT_LAST + 1][COMBAT_LAST + 1];
        uint32_t gain[GAIN_LAST + 1], gainTicks[GAIN_LAST + 1], gainAmount[GAIN_LAST + 1], skillBase[SKILL_LAST + 1];
        float skillMultipliers[SKILL__LAST + 1], formulaMultipliers[MULTIPLIER_LAST + 1];
 
Change all of the values to uint32_t

player.h


You need to modify something in the database. I’m not sure if you need to reset it or not. I forgot… there was some query I ran years ago. The client is limited to 255.
 

Similar threads

Back
Top