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

C++ Monster level

Xarvi

New Member
Joined
Aug 20, 2020
Messages
51
Reaction score
2
Hi. I have a problem with the monster level. The point is that the summon is always 255 lvl, no matter if it's created by the player or by the monster

I think the problem is here

map.cpp
C++:
bool Map::placeCreature(const Position& centerPos, Creature* creature, bool extendedPos /*= false*/, bool forced /*= false*/)
{

Monster* monster = creature->getMonster();
    if(monster && g_config.getBool(ConfigManager::MONSTER_HAS_LEVEL))
    {
        uint8_t level;
        if(!monster->getMonsterType()->hideLevel)
        {
            if(monster->isSummon())
            {
                std::string value;
                monster->getMaster()->getStorage((uint32_t)9999, value);

                uint8_t intValue = atoi(value.c_str());
                if(intValue || value == "0")
                    level = intValue;
                else
                    level = 1;
            }
            else
                level = monster->level;

            char buffer [10];
            monster->name = monster->getName() + " [LVL " + itoa(level, buffer, 10) + "]";
        }
    }

any idea ?
 
Solution
Now the summon actually has level 1 but is still strong for level 255

I try this code:
C++:
bool Map::placeCreature(const Position& centerPos, Creature* creature, bool extendedPos /*= false*/, bool forced /*= false*/)
{
    Monster* monster = creature->getMonster();
    if(monster && g_config.getBool(ConfigManager::MONSTER_HAS_LEVEL))
    {
        uint8_t level;
        if(!monster->getMonsterType()->hideLevel)
        {
            if(monster->isSummon())
            {
                std::string value;
                monster->getMaster()->getStorage((std::string)"monster_level", value);

                uint8_t intValue = atoi(value.c_str());
                if(intValue || value == "0")
                    level = intValue...
The point is ?
C++:
uint8_t intValue = atoi(value.c_str());
                if(intValue || value == "-1")
                    level = intValue;
                else
                    level = 1;
If so, it is still the same
Close.
C++:
uint8_t intValue = atoi(value.c_str());
                if(intValue > 0 && value != "-1")
                    level = intValue;
                else
                    level = 1;

Question... Why are you storing storage values as string?
 
Last edited:
Why is your storage

Close.
C++:
uint8_t intValue = atoi(value.c_str());
                if(intValue > 0 && value != "-1")
                    level = intValue;
                else
                    level = 1;

Question... Why are you storing storage values as string?
Now the summon actually has level 1 but is still strong for level 255

I try this code:
C++:
bool Map::placeCreature(const Position& centerPos, Creature* creature, bool extendedPos /*= false*/, bool forced /*= false*/)
{
    Monster* monster = creature->getMonster();
    if(monster && g_config.getBool(ConfigManager::MONSTER_HAS_LEVEL))
    {
        uint8_t level;
        if(!monster->getMonsterType()->hideLevel)
        {
            if(monster->isSummon())
            {
                std::string value;
                monster->getMaster()->getStorage((std::string)"monster_level", value);

                uint8_t intValue = atoi(value.c_str());
                if(intValue || value == "0")
                    level = intValue;
                else
                    level = 1;
            }
            else
                level = monster->level;

            char buffer [10];
            monster->name = monster->getName() + " [" + itoa(level, buffer, 10) + "]";
        }
    }

but a lot of compilation errors
 
Now the summon actually has level 1 but is still strong for level 255

I try this code:
C++:
bool Map::placeCreature(const Position& centerPos, Creature* creature, bool extendedPos /*= false*/, bool forced /*= false*/)
{
    Monster* monster = creature->getMonster();
    if(monster && g_config.getBool(ConfigManager::MONSTER_HAS_LEVEL))
    {
        uint8_t level;
        if(!monster->getMonsterType()->hideLevel)
        {
            if(monster->isSummon())
            {
                std::string value;
                monster->getMaster()->getStorage((std::string)"monster_level", value);

                uint8_t intValue = atoi(value.c_str());
                if(intValue || value == "0")
                    level = intValue;
                else
                    level = 1;
            }
            else
                level = monster->level;

            char buffer [10];
            monster->name = monster->getName() + " [" + itoa(level, buffer, 10) + "]";
        }
    }

but a lot of compilation errors
This code is not for setting level of the summon, this is only for the name part.
Ofc there are compilation errors, you are misusing getStorage.
 
Solution
This code is not for setting level of the summon, this is only for the name part.
Ofc there are compilation errors, you are misusing getStorage.
Thanks You
Solved this problem
monster.cpp:
C++:
//We just spawned lets look around to see who is there.
        if(isSummon())
        {
            std::string value;
//            this->master->getStorage((uint32_t)"1996", value);
            this->master->getStorage((uint32_t)1996, value);

            uint8_t intValue = atoi(value.c_str());
                if(intValue > 0 && value != "-1")
                    level = intValue;
                level = 1;
            isMasterInRange = canSee(master->getPosition());
        }
 
Thanks You
Solved this problem
monster.cpp:
C++:
//We just spawned lets look around to see who is there.
        if(isSummon())
        {
            std::string value;
//            this->master->getStorage((uint32_t)"1996", value);
            this->master->getStorage((uint32_t)1996, value);

            uint8_t intValue = atoi(value.c_str());
                if(intValue > 0 && value != "-1")
                    level = intValue;
                level = 1;
            isMasterInRange = canSee(master->getPosition());
        }
You solved nothing. You are setting level to 1 no matter what.
 
Back
Top