• 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

If you do the changes that are in the commit posted in the first post it should work, the last file, "protocolgame.cpp" was changed in order to show the monster level.
But they show only 07:55 You see a rotworm, it is level 11.Health: 422 / 422.Position: 132, 135, 7

What need to change for show : Rotworm [L.11]
 
Only change on Monster.h

return strDescription + ", it is level " + std::to_string(level) + '.';

to

return nameDescription + ", it is level " + std::to_string(level) + '.';

So we got error on compile when use strDescription is not declarated
Post automatically merged:


All Fixed thanks <3
Post automatically merged:

if possible to add some chance monster dont have skulls all time ? so some % to add this

Albert José ???​

 
Last edited:
Warning: For everyone using it, it gets a little buggy in these cases:
  1. Players using mana shield
  2. Mana Drain Attacks
  3. Players using energy ring
In short: the monster level damage multiplier is not applied, I made some changes to my server to resolve these bugs, I will try to organize everything into a single commit to post here.
 
The monster is showing only.
You see a rat, it is level 0.

I dont have any error in console


XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Rat" nameDescription="a rat" race="blood" experience="5" speed="134" manacost="200">
    <level min="5" max="100" />  
    <health now="20" max="20"/>
    <look type="21" corpse="2813"/>
    <targetchange interval="1000" chance="0"/>
    <targetstrategies nearest="100" health="0" damage="0" random="0"/>
    <flags>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag summonable="1"/>
        <flag convinceable="1"/>
        <flag illusionable="1"/>
        <flag pushable="1"/>
        <flag canpushitems="0"/>
        <flag canpushcreatures="0"/>
        <flag targetdistance="1"/>
        <flag staticattack="80"/>
        <flag runonhealth="5"/>
    </flags>
    <attacks>
        <attack name="melee" skill="15" attack="7"/>
    </attacks>
    <defenses armor="1" defense="3">
    </defenses>
    <elements>
    </elements>
    <immunities>
    </immunities>
    <voices interval="1000" chance="5">
    </voices>
    <loot>
        <item id="3976" chance="50000" countmax="3"/><!-- 3 50% worm -->
        <item id="2696" chance="40000"/><!-- 40% cheese -->
        <item id="2148" chance="70000" countmax="6"/><!-- 4 70% gold coin -->
    </loot>
</monster>
 
Warning: For everyone using it, it gets a little buggy in these cases:
  1. Players using mana shield
  2. Mana Drain Attacks
  3. Players using energy ring
In short: the monster level damage multiplier is not applied, I made some changes to my server to resolve these bugs, I will try to organize everything into a single commit to post here.
Has the issue been resolved? I'm waiting...
 
The monster is showing only.
You see a rat, it is level 0.

I dont have any error in console


XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Rat" nameDescription="a rat" race="blood" experience="5" speed="134" manacost="200">
    <level min="5" max="100" /> 
    <health now="20" max="20"/>
    <look type="21" corpse="2813"/>
    <targetchange interval="1000" chance="0"/>
    <targetstrategies nearest="100" health="0" damage="0" random="0"/>
    <flags>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag summonable="1"/>
        <flag convinceable="1"/>
        <flag illusionable="1"/>
        <flag pushable="1"/>
        <flag canpushitems="0"/>
        <flag canpushcreatures="0"/>
        <flag targetdistance="1"/>
        <flag staticattack="80"/>
        <flag runonhealth="5"/>
    </flags>
    <attacks>
        <attack name="melee" skill="15" attack="7"/>
    </attacks>
    <defenses armor="1" defense="3">
    </defenses>
    <elements>
    </elements>
    <immunities>
    </immunities>
    <voices interval="1000" chance="5">
    </voices>
    <loot>
        <item id="3976" chance="50000" countmax="3"/><!-- 3 50% worm -->
        <item id="2696" chance="40000"/><!-- 40% cheese -->
        <item id="2148" chance="70000" countmax="6"/><!-- 4 70% gold coin -->
    </loot>
</monster>
Fixed. i just forget to add

C++:
    floating[MLVL_BONUSDMG] = getGlobalFloat(L, "monsterBonusDamage", 0);
    floating[MLVL_BONUSSPEED] = getGlobalFloat(L, "monsterBonusSpeed", 0);
    floating[MLVL_BONUSHP] = getGlobalFloat(L, "monsterBonusHealth", 0);


its possible to increase the loot monster?
 
Fixed. i just forget to add

C++:
    floating[MLVL_BONUSDMG] = getGlobalFloat(L, "monsterBonusDamage", 0);
    floating[MLVL_BONUSSPEED] = getGlobalFloat(L, "monsterBonusSpeed", 0);
    floating[MLVL_BONUSHP] = getGlobalFloat(L, "monsterBonusHealth", 0);


its possible to increase the loot monster?
Yes, i do it by lua. Create a method for getting the monster level, look at for instance player:getLevel() in luascript, copy it and change it to get lvl from monster.

Then you can use that method to scale the loot rate in ondrop event.
 
Yes, i do it by lua. Create a method for getting the monster level, look at for instance player:getLevel() in luascript, copy it and change it to get lvl from monster.

Then you can use that method to scale the loot rate in ondrop event.
i'm lost. can you give an example? i will add this on events/player.lua or monsters.lua?
 
Last edited:
i'm lost. can you give an example? i will add this on events/player.lua or monsters.lua?
monster ondrop. If ur using eventcallback its in data/scriptseventcallbacks/monster/default_onDropLoot.lua

Then you call it like this ( when you have added a method in luscript.cpp)
Lua:
local monsterLvl = self:getLevel()
local customRate = 0.5
local newLootRate = monsterLvl * customRate -- Increase the chance based on monster level, adjust it with customRate


..
..

for i = 1, #monsterLoot do
            local default = monsterLoot[i]
            if default.chance < 100000 then
                default.chance = default.chance + (newLootRate * (default.chance / 100))
            end
 
monster ondrop. If ur using eventcallback its in data/scriptseventcallbacks/monster/default_onDropLoot.lua

Then you call it like this ( when you have added a method in luscript.cpp)
Lua:
local monsterLvl = self:getLevel()
local customRate = 0.5
local newLootRate = monsterLvl * customRate -- Increase the chance based on monster level, adjust it with customRate


..
..

for i = 1, #monsterLoot do
            local default = monsterLoot[i]
            if default.chance < 100000 then
                default.chance = default.chance + (newLootRate * (default.chance / 100))
            end
like this?


Lua:
local ec = EventCallback

ec.onDropLoot = function(self, corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local monsterLvl = self:getLevel()
    local customRate = 100
    local newLootRate = monsterLvl * customRate -- Increase the chance based on monster level, adjust it with customRate

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        for i = 1, #monsterLoot do
            local default = monsterLoot[i]
            if default.chance < 100000 then
                default.chance = default.chance + (newLootRate * (default.chance / 100))
            end
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
        end
    end
end

ec:register()
 
like this?


Lua:
local ec = EventCallback

ec.onDropLoot = function(self, corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local monsterLvl = self:getLevel()
    local customRate = 100
    local newLootRate = monsterLvl * customRate -- Increase the chance based on monster level, adjust it with customRate

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        for i = 1, #monsterLoot do
            local default = monsterLoot[i]
            if default.chance < 100000 then
                default.chance = default.chance + (newLootRate * (default.chance / 100))
            end
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
        end
    end
end

ec:register()

Yes, correct :)
 
After kill a Rat for example its possible to respawn another rat with different level? how can i do this? anyone can give my a tip
 
Back
Top