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

Feature [TFS 1.3] Monster Levels

code: aasfdfdasfdafdasf · Vulcanx/forgottenserver@723b97b

config.lua:
Lua:
monsterBonusHealth = 0.5
monsterBonusSpeed = 0.02
monsterBonusDamage = 0.02

how to add to monsters (monster xml file):
XML:
<level min="5" max="100" />

for tfs 1.2 users, configmanager is changed in 1.3, so ignore the configmanager.h and configmanager.cpp changes in the main post
instead, use these changes for configmanager in 1.2: as,d,JS<KjDDDD · Vulcanx/forgottenserver@78a84b9



When a monster appears as level 10 for example, when you kill it, do you gain more EXP / loot than killing a level 5?
 
How do I add a skull system Into this?
It's solved already or?
 
data/events/events.xml
Code:
<event class="Player" method="onGainExperience" enabled="1" />
data/events/scripts/player.lua
Change or Add (idk. depends on your choice and reading of whole function etc.) in Player:eek:nGainExperience(source, exp, rawExp) function:
Code:
    if source:isMonster() and source:getLevel() > 0 then
    exp = (((exp * Game.getExperienceStage(self:getLevel()))/2) * source:getLevel())
    else
    exp = exp * Game.getExperienceStage(self:getLevel())
    end

It is possible to rewrite Code line
player.cpp ---->>
C++:
    g_events->eventPlayerOnGainExperience(this, source, exp, rawExp);
    if (exp == 0) {
        return;
    }


including ----->>

C++:
 if source:isMonster() and source:getLevel() > 0 then

    exp = (((exp * Game.getExperienceStage(self:getLevel()))/2) * source:getLevel())

    else

    exp = exp * Game.getExperienceStage(self:getLevel())

    end
 
It works successfully in my TFS 1.3. But, after I add that system in my server, all monsters (same having tag hostile = 0 in xml) are hostile. Monsters like Rabbit for example, are attacking me.

How I fix this problem?
 
It works successfully in my TFS 1.3. But, after I add that system in my server, all monsters (same having tag hostile = 0 in xml) are hostile. Monsters like Rabbit for example, are attacking me.

How I fix this problem?
you did something wrong or added something else other than this system
this code does not change any monster logic whatsoever, only multipliers to preexisting values
 
It is possible to rewrite Code line
player.cpp ---->>
C++:
    g_events->eventPlayerOnGainExperience(this, source, exp, rawExp);
    if (exp == 0) {
        return;
    }


including ----->>

C++:
 if source:isMonster() and source:getLevel() > 0 then

    exp = (((exp * Game.getExperienceStage(self:getLevel()))/2) * source:getLevel())

    else

    exp = exp * Game.getExperienceStage(self:getLevel())

    end

Yes
C++:
    const Monster* monster = source->getMonster();
    if (monster && monster->getLevel() > 0){
        exp += (exp * 0.08) * monster->getLevel();
    }
    g_events->eventPlayerOnGainExperience(this, source, exp, rawExp);
    if (exp == 0) {
        return;
    }
 
Last edited:
@Infernum Wanna lend a hand to maybe understand what am missing out? Put all the added and removed the xtra lines and when am compiling i get this?
1611587152594.png
 
edit Monster::Monster() constructor in monster.cpp and set skull to w/e you like based on level
 
Any idea how to modify the "place monster" command to create monster with a specific level?
 
Any idea how to modify the "place monster" command to create monster with a specific level?

I wrote a separate placeCreature with level function:

C++:
bool Game::placeCreatureWithLevel(Creature* creature, const Position& pos, bool extendedPos /*=false*/, bool forced /*= false*/, int32_t level)
{
    if (!internalPlaceCreature(creature, pos, extendedPos, forced)) {
        return false;
    }

    creature->setMonsterLevel(level);

    SpectatorVec spectators;
    map.getSpectators(spectators, creature->getPosition(), true);
    for (Creature* spectator : spectators) {
        if (Player* tmpPlayer = spectator->getPlayer()) {
            tmpPlayer->sendCreatureAppear(creature, creature->getPosition(), true);
        }
    }

    for (Creature* spectator : spectators) {
        spectator->onCreatureAppear(creature, true);
    }

    creature->getParent()->postAddNotification(creature, nullptr, 0);

    addCreatureCheck(creature);
    creature->onPlacedCreature();
    return true;
}
 
Back
Top