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

Monster level problem

Nerevr back

Member
Joined
Nov 7, 2014
Messages
269
Reaction score
7
i found this in other forum and compile done but when open exe get this error

i think the problem here
Code:
void Monster::onCreatureAppear(const Creature* creature)

im use 0.4
TL3EgcZ.png


monsters.h

Procure por:
Code:
bool isSummonable, isIllusionable, isConvinceable, isAttackable, isHostile, isLureable,
    isWalkable, canPushItems, canPushCreatures, pushable, hideName, hideHealth;

Replace For:

Code:
bool isSummonable, isIllusionable, isConvinceable, isAttackable, isHostile, isLureable,
    isWalkable, canPushItems, canPushCreatures, pushable, hideName, hideHealth, hideLevel;

find:

Code:
int32_t defense, armor, health, healthMax, baseSpeed, lookCorpse, corpseUnique, corpseAction,
    maxSummons, targetDistance, runAwayHealth, conditionImmunities, damageImmunities,
    lightLevel, lightColor, changeTargetSpeed, changeTargetChance;

Replace for:

Code:
int32_t defense, armor, health, healthMax, baseSpeed, lookCorpse, corpseUnique, corpseAction,
    maxSummons, targetDistance, runAwayHealth, conditionImmunities, damageImmunities,
    lightLevel, lightColor, changeTargetSpeed, changeTargetChance, levelMin, levelMax;

monsters.cpp

Find:

Code:
canPushItems = canPushCreatures = isSummonable = isIllusionable = isConvinceable = isLureable = isWalkable = hideName = hideHealth = false;

Replace for:

Code:
canPushItems = canPushCreatures = isSummonable = isIllusionable = isConvinceable = isLureable = isWalkable = hideName = hideHealth = hideLevel = false;

find:
Code:
baseSpeed = 200;

Under it add:

levelMin = levelMax = 1;

find:

Code:
bool Monsters::loadMonster

find this from same fuction:

Code:
for(xmlNodePtr p = root->children; p; p = p->next)
    {
        if(p->type != XML_ELEMENT_NODE)
            continue;

        if(!xmlStrcmp(p->name, (const xmlChar*)"health"))
        {
            if(!readXMLInteger(p, "max", intValue))
            {
                SHOW_XML_ERROR("Missing health.max");
                monsterLoad = false;
                break;
            }

            mType->healthMax = intValue;
            if(!readXMLInteger(p, "now", intValue))
                mType->health = mType->healthMax;
            else
                mType->health = intValue;
        }

under this add:

Code:
else if(!xmlStrcmp(p->name, (const xmlChar*)"level"))
        {
            if(!readXMLInteger(p, "max", intValue))
                mType->levelMax = 1;
            else
                mType->levelMax = intValue;

            if(!readXMLInteger(p, "min", intValue))
                mType->levelMin = mType->levelMax;
            else
                mType->levelMin = intValue;
        }

find:

Code:
if(readXMLString(tmpNode, "emblem", strValue))
    mType->guildEmblem = getEmblems(strValue);

under it add:

Code:
if(readXMLString(tmpNode, "hidelevel", strValue))
        mType->hideLevel = booleanString(strValue);

monster.h

find:
Code:
class Monster : public Creature
{

and then find that:

public:
Code:
#ifdef __ENABLE_SERVER_DIAGNOSTIC__
        static uint32_t monsterCount;
#endif
        virtual ~Monster();

under it add :

Code:
std::string name, nameDescription;
int32_t level;
double bonusAttack, bonusDefense;

find:

Code:
virtual const std::string& getName() const {return mType->name;}
virtual const std::string& getNameDescription() const {return mType->nameDescription;}
virtual std::string getDescription(int32_t) const {return mType->nameDescription + ".";}

Replace for:

Code:
virtual const std::string& getName() const {return name;}
virtual const std::string& getNameDescription() const {return nameDescription;}
virtual std::string getDescription(int32_t) const {return nameDescription + ".";}

monster.cpp

find:
Code:
isIdle = true;

under this add:

Code:
name = _mType->name;
nameDescription = _mType->nameDescription;
level = (int32_t)random_range(_mType->levelMin, _mType->levelMax, DISTRO_NORMAL);
bonusAttack = 1.0;
bonusDefense = 1.0;

Find:

Code:
Monster::onCreatureAppear

replace all function for:

Code:
void Monster::onCreatureAppear(const Creature* creature)
{
    Creature::onCreatureAppear(creature);
    if(creature == this)
    {
        //We just spawned lets look around to see who is there.
        if(isSummon())
        {
            std::string value;
            this->master->getStorage((std::string)"monster_level", value);

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

        if(g_config.getBool(ConfigManager::MONSTER_HAS_LEVEL))
        {
            this->healthMax = std::floor(this->getMaxHealth() * (1. + (0.1 * (level - 1))));
            this->health = this->healthMax;

            this->bonusAttack += (0.01 * (level - 1));
            this->bonusDefense += (0.005 * (level - 1));
        }



        updateTargetList();
        updateIdleStatus();
    }
    else
        onCreatureEnter(const_cast<Creature*>(creature));
}


find:

Code:
g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE)

replace for:

Code:
g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE) * bonusDefense

find:

Code:
g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK)

Replace for:

Code:
g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK) * bonusAttack

map.cpp

find:

Code:
#include "game.h"

under this add:

Code:
#include "configmanager.h"

find:
Code:
extern Game g_game;

under this add:
Code:
extern ConfigManager g_config;

find:
Code:
bool Map::placeCreature

and after this { add:

Code:
 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) + "]";
        }
    }

configmanager.h

find:
Code:
MONSTER_SPAWN_WALKBACK,

under this add:

Code:
MONSTER_HAS_LEVEL,

configmanager.cpp

find:
Code:
m_loaded = true;

ander this add:

Code:
m_confBool[MONSTER_HAS_LEVEL] = getGlobalBool("monsterHasLevel", true);

config.lua

Code:
monsterHasLevel = true

how to fix this?? anyone can help me?
 
Last edited by a moderator:
I can just read "aadfasdkfljashdflkasdhfklasdfhkasdjfh windows hjflkasjdfhklasdfhaskjdf" lol

Btw try to set monsterHasLevel = false just to know if the lvl thing from config is the issue
 
first line
windows can search on Solution of the problem via the Internet

second line and last line = close program


first line in blue is
the forgottenl server stop working
 
first line
windows can search on Solution of the problem via the Internet

second line and last line = close program


first line in blue is
the forgottenl server stop working
1st question what version of TFS are you compiling?
2nd question what version is this code for?
 
1st question what version of TFS are you compiling?
2nd question what version is this code for?
the answer for 2 question is 0.4
when compile get this error

monster.cpp In member function `virtual void Monster::eek:nCreatureAppear(const Creature*)':

monster.cpp [Warning] converting to `int32_t' from `double'
but when ignore it and complete compile its say done but i can't open my oto always get first error in first imag

bump

?????????

anyone can fix it please to work on 0.4
 
Last edited by a moderator:
Tried to compile this but getting these errors:

1>C:\Desktop\src\map.cpp(190,37): error C2664: 'bool Creature::getStorage(const uint32_t,std::string &) const': cannot convert argument 1 from 'std::string' to 'const uint32_t'
1>C:\\Desktop\src\map.cpp(190,50): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>C:\Desktop\src\creature.h(336,16): message : see declaration of 'Creature::getStorage' (compiling source file ..\map.cpp)
1>C:\Desktop\src\map.cpp(190,37): message : while trying to match the argument list '(std::string, std::string)'
1>C:\Desktop\src\monster.cpp(175,25): error C2664: 'bool Creature::getStorage(const uint32_t,std::string &) const': cannot convert argument 1 from 'std::string' to 'const uint32_t'
1>C:\Desktop\src\monster.cpp(175,38): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>C:\Desktop\src\creature.h(336,16): message : see declaration of 'Creature::getStorage' (compiling source file ..\monster.cpp)
1>C:\Desktop\src\monster.cpp(175,25): message : while trying to match the argument list '(std::string, std::string)'

can anyone help?
 
Back
Top