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

[TFS 1.4] Boosted Creatures

Alberto Cabrera

Well-Known Member
Joined
Sep 17, 2020
Messages
75
Solutions
17
Reaction score
74
Location
México
Hello, good evening!
I don't know if there is one here in the forum that works, anyway, here it is.

data/scripts/BoostedCreature.lua
Lua:
boosted = {}
boosted.creatures = {}
-- possible monsters
boosted.possible = {
    {
        {"Demon", "Hellhound", "Grim Reaper", "Juggernaut"}, -- exp list
        1.1 -- exp rate
    },
    {
        {"Dragon Lord", "Medusa", "Hydra", "Serpent Spawn"}, -- loot list
        1.2 -- loot rate
    },
    {
        {"Warlock", "Infernalist", "Demon Outcast", "Nightmare"}, -- extraloot list
        {{2494, 1, 25}, {2646, 1, 10}, {2469, 2, 15}, {2352, 1, 50}} -- items list
    }
}

function getBoostedCreature()
    local t = {
        monster = {exp = boosted.creatures[1], loot = boosted.creatures[2], extraloot = boosted.creatures[3]},
        rate = {exp = boosted.possible[1][2], loot = boosted.possible[2][2], extraloot = boosted.possible[3][2]}
    }
    return t
end

local boostedInfo = ""
local globalevent = GlobalEvent("boostedcreatures")

function globalevent.onStartup()
    -- select monsters
    local monster1 = boosted.possible[1][1][math.random(#boosted.possible[1][1])]
    local monster2 = boosted.possible[2][1][math.random(#boosted.possible[2][1])]
    local monster3 = boosted.possible[3][1][math.random(#boosted.possible[3][1])]

    boosted.creatures[1] = monster1
    boosted.creatures[2] = monster2
    boosted.creatures[3] = monster3

    -- string for talkaction
    boostedInfo = boostedInfo .. ('Today daily creatures are: %s has extra exp %.1f\n%s has extra loot rate %.1f\n%s has extraloot, list of possible items:\n\n'):format(monster1, getBoostedCreature().rate.exp, monster2, getBoostedCreature().rate.loot, monster3)
    for index, value in ipairs(boosted.possible[3][2]) do
        boostedInfo = boostedInfo .. "[" .. ItemType(value[1]):getName() .. "]: count; " .. value[2] .. ", chance; " .. (not value and "100%" or value[3] .. "%") .. ((#boosted.possible[3][2] > 1 and index < #boosted.possible[3][2]) and "\n" or "")
    end

    -- in case you forget to register the event in monsterfile.xml
    MonsterType(monster1):registerEvent("BoostedDeath")
    MonsterType(monster2):registerEvent("BoostedDeath")
    MonsterType(monster3):registerEvent("BoostedDeath")
    return true
end

globalevent:register()

local creatureevent = CreatureEvent("BoostedLogin")

function creatureevent.onLogin(player)
    local boosted = getBoostedCreature()
    local message = "Today daily creatures are: " .. boosted.monster.exp .. " has extra exp rate " .. boosted.rate.exp .. "\n" .. boosted.monster.loot .. " has extra loot rate " .. boosted.rate.loot .. "\n" .. boosted.monster.extraloot .. " has extra loot: type !extraloot for more information \n\nEnjoy!"
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
    return true
end

creatureevent:register()

local creatureevent = CreatureEvent("BoostedDeath")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if not creature:isMonster() or not killer:isPlayer() or not corpse then
        return true
    end

    local BOOSTED = getBoostedCreature()
    -- exp
    if creature:getName():lower() == BOOSTED.monster.exp:lower() then
        local exp = math.floor(MonsterType(creature:getName()):experience() * (Game.getExperienceStage(killer:getLevel()) + BOOSTED.rate.exp))
        killer:addExperience(exp, true)

    -- loot
    elseif creature:getName():lower() == BOOSTED.monster.loot:lower() then
        local monsterloot = MonsterType(creature:getName()):getLoot()
        local bp = corpse:addItem(1987, 1)
        local str = ""
        local rate = BOOSTED.rate.loot * configManager.getNumber(configKeys.RATE_LOOT)
        for i, loot in pairs(monsterloot) do
            if math.random(100000) <= rate * loot.chance then
                local count = loot.maxCount > 1 and math.random(loot.maxCount) or 1
                bp:addItem(loot.itemId, count)
                str = str .. count .. " " .. ItemType(loot.itemId):getName() .. ", "
            end
        end
        if str ~= "" then
            if str:sub(-2, -2) == "," then
                str = str:sub(1, str:len() - 2)
            end
            killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Loot bonus [" .. creature:getName() .. "]: " .. str .. '.')
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
        end
    -- extraloot
    elseif creature:getName():lower() == BOOSTED.monster.extraloot:lower() then
        local bp = corpse:addItem(1987, 1)
        local str = ""
        for index, value in ipairs(boosted.possible[3][2]) do
            if not value[3] or math.random(100) <= value[3] then
                if ItemType(value[1]):isStackable() then
                    bp:addItem(value[1], value[2])
                else
                    for i = 1, value[2] do
                        bp:addItem(value[1], 1)
                    end
                end
                str = str .. value[2] .. " " .. ItemType(value[1]):getName() .. ", "
            end
        end
        if str ~= "" then
            if str:sub(-2, -2) == "," then
                str = str:sub(1, str:len() - 2)
            end
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
            killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Extra loot [" .. creature:getName() .. "]: " .. str .. '.')
        end
    end
    return true
end

creatureevent:register()

local talkaction = TalkAction('!extraloot')

function talkaction.onSay(player, words, param)
    player:popupFYI(boostedInfo)
    return false
end

talkaction:separator(" ")
talkaction:register()

Put in MonsterFile.xml

XML:
<script>
    <event name="BoostedDeath"/>
</script>


login.pnglootbonus.pngextraloot.pngcommand.png
 
Last edited:
Hello, good evening!
I don't know if there is one here in the forum that works, anyway, here it is.

data/scripts/BoostedCreature.lua
Lua:
boosted = {}
boosted.creatures = {}
-- possible monsters
boosted.possible = {
    {
        {"Demon", "Hellhound", "Grim Reaper", "Juggernaut"}, -- exp list
        1.1 -- exp rate
    },
    {
        {"Dragon Lord", "Medusa", "Hydra", "Serpent Spawn"}, -- loot list
        1.2 -- loot rate
    },
    {
        {"Warlock", "Infernalist", "Demon Outcast", "Nightmare"}, -- extraloot list
        {{2494, 1, 25}, {2646, 1, 10}, {2469, 2, 15}, {2352, 1, 50}} -- items list
    }
}

function getBoostedCreature()
    local t = {
        monster = {exp = boosted.creatures[1], loot = boosted.creatures[2], extraloot = boosted.creatures[3]},
        rate = {exp = boosted.possible[1][2], loot = boosted.possible[2][2], extraloot = boosted.possible[3][2]}
    }
    return t
end

local boostedInfo = ""
local globalevent = GlobalEvent("boostedcreatures")

function globalevent.onStartup()
    -- select monsters
    local monster1 = boosted.possible[1][1][math.random(#boosted.possible[1][1])]
    local monster2 = boosted.possible[2][1][math.random(#boosted.possible[2][1])]
    local monster3 = boosted.possible[3][1][math.random(#boosted.possible[3][1])]

    boosted.creatures[1] = monster1
    boosted.creatures[2] = monster2
    boosted.creatures[3] = monster3

    -- string for talkaction
    boostedInfo = boostedInfo .. ('Today daily creatures are: %s has extra exp %.1f\n%s has extra loot rate %.1f\n%s has extraloot, list of possible items:\n\n'):format(monster1, getBoostedCreature().rate.exp, monster2, getBoostedCreature().rate.loot, monster3)
    for index, value in ipairs(boosted.possible[3][2]) do
        boostedInfo = boostedInfo .. "[" .. ItemType(value[1]):getName() .. "]: count; " .. value[2] .. ", chance; " .. (not value and "100%" or value[3] .. "%") .. ((#boosted.possible[3][2] > 1 and index < #boosted.possible[3][2]) and "\n" or "")
    end

    -- in case you forget to register the event in monsterfile.xml
    MonsterType(monster1):registerEvent("BoostedDeath")
    MonsterType(monster2):registerEvent("BoostedDeath")
    MonsterType(monster3):registerEvent("BoostedDeath")
    return true
end

globalevent:register()

local creatureevent = CreatureEvent("BoostedLogin")

function creatureevent.onLogin(player)
    local boosted = getBoostedCreature()
    local message = "Today daily creatures are: " .. boosted.monster.exp .. " has extra exp rate " .. boosted.rate.exp .. "\n" .. boosted.monster.loot .. " has extra loot rate " .. boosted.rate.loot .. "\n" .. boosted.monster.extraloot .. " has extra loot: type !extraloot for more information \n\nEnjoy!"
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
    return true
end

creatureevent:register()

local creatureevent = CreatureEvent("BoostedDeath")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if not creature:isMonster() or not killer:isPlayer() or not corpse then
        return true
    end

    local BOOSTED = getBoostedCreature()
    -- exp
    if creature:getName():lower() == BOOSTED.monster.exp:lower() then
        local exp = math.floor(MonsterType(creature:getName()):experience() * (Game.getExperienceStage(killer:getLevel()) + BOOSTED.rate.exp))
        killer:addExperience(exp, true)

    -- loot
    elseif creature:getName():lower() == BOOSTED.monster.loot:lower() then
        local monsterloot = MonsterType(creature:getName()):getLoot()
        local bp = corpse:addItem(1987, 1)
        local str = ""
        local rate = BOOSTED.rate.loot * configManager.getNumber(configKeys.RATE_LOOT)
        for i, loot in pairs(monsterloot) do
            if math.random(100000) <= rate * loot.chance then
                local count = loot.maxCount > 1 and math.random(loot.maxCount) or 1
                bp:addItem(loot.itemId, count)
                str = str .. count .. " " .. ItemType(loot.itemId):getName() .. ", "
            end
        end
        if str ~= "" then
            if str:sub(-2, -2) == "," then
                str = str:sub(1, str:len() - 2)
            end
            killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Loot bonus [" .. creature:getName() .. "]: " .. str .. '.')
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
        end
    -- extraloot
    elseif creature:getName():lower() == BOOSTED.monster.extraloot:lower() then
        local bp = corpse:addItem(1987, 1)
        local str = ""
        for index, value in ipairs(boosted.possible[3][2]) do
            if not value[3] or math.random(100) <= value[3] then
                if ItemType(value[1]):isStackable() then
                    bp:addItem(value[1], value[2])
                else
                    for i = 1, value[2] do
                        bp:addItem(value[1], 1)
                    end
                end
                str = str .. value[2] .. " " .. ItemType(value[1]):getName() .. ", "
            end
        end
        if str ~= "" then
            if str:sub(-2, -2) == "," then
                str = str:sub(1, str:len() - 2)
            end
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
            killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Extra loot [" .. creature:getName() .. "]: " .. str .. '.')
        end
    end
    return true
end

creatureevent:register()

local talkaction = TalkAction('!extraloot')

function talkaction.onSay(player, words, param)
    player:popupFYI(boostedInfo)
    return false
end

talkaction:separator(" ")
talkaction:register()

Put in MonsterFile.xml

XML:
<script>
    <event name="BoostedDeath"/>
</script>


View attachment 62477View attachment 62480View attachment 62481View attachment 62482
hi bro I tried to use it but it throws an error, I use TFS 1.4 for tibia 7.72 how can I repair this?

Sin sdfdsfsdf.png

@Alberto Cabrera
 
Hi, im getting this error, the one in the image.

Any idea how i can solve it?, please help and thanks :D.

Btw, using TFS 1.4, client version 10.98.
 

Attachments

  • boosted creat.jpg
    boosted creat.jpg
    348.9 KB · Views: 46 · VirusTotal
Hello, good evening!
I don't know if there is one here in the forum that works, anyway, here it is.

data/scripts/BoostedCreature.lua
Lua:
boosted = {}
boosted.creatures = {}
-- possible monsters
boosted.possible = {
    {
        {"Demon", "Hellhound", "Grim Reaper", "Juggernaut"}, -- exp list
        1.1 -- exp rate
    },
    {
        {"Dragon Lord", "Medusa", "Hydra", "Serpent Spawn"}, -- loot list
        1.2 -- loot rate
    },
    {
        {"Warlock", "Infernalist", "Demon Outcast", "Nightmare"}, -- extraloot list
        {{2494, 1, 25}, {2646, 1, 10}, {2469, 2, 15}, {2352, 1, 50}} -- items list
    }
}

function getBoostedCreature()
    local t = {
        monster = {exp = boosted.creatures[1], loot = boosted.creatures[2], extraloot = boosted.creatures[3]},
        rate = {exp = boosted.possible[1][2], loot = boosted.possible[2][2], extraloot = boosted.possible[3][2]}
    }
    return t
end

local boostedInfo = ""
local globalevent = GlobalEvent("boostedcreatures")

function globalevent.onStartup()
    -- select monsters
    local monster1 = boosted.possible[1][1][math.random(#boosted.possible[1][1])]
    local monster2 = boosted.possible[2][1][math.random(#boosted.possible[2][1])]
    local monster3 = boosted.possible[3][1][math.random(#boosted.possible[3][1])]

    boosted.creatures[1] = monster1
    boosted.creatures[2] = monster2
    boosted.creatures[3] = monster3

    -- string for talkaction
    boostedInfo = boostedInfo .. ('Today daily creatures are: %s has extra exp %.1f\n%s has extra loot rate %.1f\n%s has extraloot, list of possible items:\n\n'):format(monster1, getBoostedCreature().rate.exp, monster2, getBoostedCreature().rate.loot, monster3)
    for index, value in ipairs(boosted.possible[3][2]) do
        boostedInfo = boostedInfo .. "[" .. ItemType(value[1]):getName() .. "]: count; " .. value[2] .. ", chance; " .. (not value and "100%" or value[3] .. "%") .. ((#boosted.possible[3][2] > 1 and index < #boosted.possible[3][2]) and "\n" or "")
    end

    -- in case you forget to register the event in monsterfile.xml
    MonsterType(monster1):registerEvent("BoostedDeath")
    MonsterType(monster2):registerEvent("BoostedDeath")
    MonsterType(monster3):registerEvent("BoostedDeath")
    return true
end

globalevent:register()

local creatureevent = CreatureEvent("BoostedLogin")

function creatureevent.onLogin(player)
    local boosted = getBoostedCreature()
    local message = "Today daily creatures are: " .. boosted.monster.exp .. " has extra exp rate " .. boosted.rate.exp .. "\n" .. boosted.monster.loot .. " has extra loot rate " .. boosted.rate.loot .. "\n" .. boosted.monster.extraloot .. " has extra loot: type !extraloot for more information \n\nEnjoy!"
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
    return true
end

creatureevent:register()

local creatureevent = CreatureEvent("BoostedDeath")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if not creature:isMonster() or not killer:isPlayer() or not corpse then
        return true
    end

    local BOOSTED = getBoostedCreature()
    -- exp
    if creature:getName():lower() == BOOSTED.monster.exp:lower() then
        local exp = math.floor(MonsterType(creature:getName()):experience() * (Game.getExperienceStage(killer:getLevel()) + BOOSTED.rate.exp))
        killer:addExperience(exp, true)

    -- loot
    elseif creature:getName():lower() == BOOSTED.monster.loot:lower() then
        local monsterloot = MonsterType(creature:getName()):getLoot()
        local bp = corpse:addItem(1987, 1)
        local str = ""
        local rate = BOOSTED.rate.loot * configManager.getNumber(configKeys.RATE_LOOT)
        for i, loot in pairs(monsterloot) do
            if math.random(100000) <= rate * loot.chance then
                local count = loot.maxCount > 1 and math.random(loot.maxCount) or 1
                bp:addItem(loot.itemId, count)
                str = str .. count .. " " .. ItemType(loot.itemId):getName() .. ", "
            end
        end
        if str ~= "" then
            if str:sub(-2, -2) == "," then
                str = str:sub(1, str:len() - 2)
            end
            killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Loot bonus [" .. creature:getName() .. "]: " .. str .. '.')
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
        end
    -- extraloot
    elseif creature:getName():lower() == BOOSTED.monster.extraloot:lower() then
        local bp = corpse:addItem(1987, 1)
        local str = ""
        for index, value in ipairs(boosted.possible[3][2]) do
            if not value[3] or math.random(100) <= value[3] then
                if ItemType(value[1]):isStackable() then
                    bp:addItem(value[1], value[2])
                else
                    for i = 1, value[2] do
                        bp:addItem(value[1], 1)
                    end
                end
                str = str .. value[2] .. " " .. ItemType(value[1]):getName() .. ", "
            end
        end
        if str ~= "" then
            if str:sub(-2, -2) == "," then
                str = str:sub(1, str:len() - 2)
            end
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
            killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Extra loot [" .. creature:getName() .. "]: " .. str .. '.')
        end
    end
    return true
end

creatureevent:register()

local talkaction = TalkAction('!extraloot')

function talkaction.onSay(player, words, param)
    player:popupFYI(boostedInfo)
    return false
end

talkaction:separator(" ")
talkaction:register()

Put in MonsterFile.xml

XML:
<script>
    <event name="BoostedDeath"/>
</script>


View attachment 62477View attachment 62480View attachment 62481View attachment 62482
I don't have a MonsterFIle.xml. Do you mean monsters.xml in monsters folder?
 
he means the xml monster file, for example: demon.xml etc
Thank you! So the exp bonus works but nothing about extra loot comes up. Here's my script, i have edited it to just be on Rats whilst i test it.

EDIT: I get this error too: [Warning - Monster::Monster] Unknown event name: BoostedDeath

Lua:
boosted = {}
boosted.creatures = {}
-- possible monsters
boosted.possible = {
    {
   --     {"Demon", "Hellhound", "Grim Reaper", "Juggernaut", "Amazon", "Valkyrie", "Carrion Worm", "Drillworm", "Rift Worm", "Rotworm", "Kongra", "Merlkin", "Sibang", "Yeti", }, -- exp list
        {"Rat", }, -- exp list
         0.2 -- exp rate
    },
    {
     --   {"Dragon Lord", "Medusa", "Hydra", "Serpent Spawn"}, -- loot list
        {"Rat", }, -- loot list
        0.2 -- loot rate
    },
    {
        {"Rat", }, -- extra loot items
       -- {"Warlock", "Infernalist", "Demon Outcast", "Nightmare"}, -- extraloot list
        {{2494, 1, 100}, {2646, 1, 100}, {2469, 2, 100}, {2352, 1, 100}} -- items list
    }
}

function getBoostedCreature()
    local t = {
        monster = {exp = boosted.creatures[1], loot = boosted.creatures[2], extraloot = boosted.creatures[3]},
        rate = {exp = boosted.possible[1][2], loot = boosted.possible[2][2], extraloot = boosted.possible[3][2]}
    }
    return t
end

local boostedInfo = ""
local globalevent = GlobalEvent("boostedcreatures")

function globalevent.onStartup()
    -- select monsters
    local monster1 = boosted.possible[1][1][math.random(#boosted.possible[1][1])]
    local monster2 = boosted.possible[2][1][math.random(#boosted.possible[2][1])]
    local monster3 = boosted.possible[3][1][math.random(#boosted.possible[3][1])]

    boosted.creatures[1] = monster1
    boosted.creatures[2] = monster2
    boosted.creatures[3] = monster3

    -- string for talkaction
    boostedInfo = boostedInfo .. ('Boosted monsters are: %s yield 20% extra experience.1f\n%s has extra loot rate %.1f\n%s has extraloot, list of possible items:\n\n'):format(monster1, getBoostedCreature().rate.exp, monster2, getBoostedCreature().rate.loot, monster3)
    for index, value in ipairs(boosted.possible[3][2]) do
        boostedInfo = boostedInfo .. "[" .. ItemType(value[1]):getName() .. "]: count; " .. value[2] .. ", chance; " .. (not value and "100%" or value[3] .. "%") .. ((#boosted.possible[3][2] > 1 and index < #boosted.possible[3][2]) and "\n" or "")
    end

    -- in case you forget to register the event in monsterfile.xml
    MonsterType(monster1):registerEvent("BoostedDeath")
    MonsterType(monster2):registerEvent("BoostedDeath")
    MonsterType(monster3):registerEvent("BoostedDeath")
    return true
end

globalevent:register()

local creatureevent = CreatureEvent("BoostedLogin")

function creatureevent.onLogin(player)
    local boosted = getBoostedCreature()
    local message = "Boosted monsters are: " .. boosted.monster.exp .. " give +20% experience \n" .. boosted.monster.loot .. " has extra loot rate " .. boosted.rate.loot .. "\n" .. boosted.monster.extraloot .. " has extra loot: type !extraloot for more information."
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
    return true
end

creatureevent:register()

local creatureevent = CreatureEvent("BoostedDeath")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if not creature:isMonster() or not killer:isPlayer() or not corpse then
        return true
    end

    local BOOSTED = getBoostedCreature()
    -- exp
    if creature:getName():lower() == BOOSTED.monster.exp:lower() then
        local exp = math.floor(MonsterType(creature:getName()):experience() * (Game.getExperienceStage(killer:getLevel()) * BOOSTED.rate.exp))
        killer:addExperience(exp, true)

    -- loot
    elseif creature:getName():lower() == BOOSTED.monster.loot:lower() then
        local monsterloot = MonsterType(creature:getName()):getLoot()
        local bp = corpse:addItem(1987, 1)
        local str = ""
        local rate = BOOSTED.rate.loot * configManager.getNumber(configKeys.RATE_LOOT)
        for i, loot in pairs(monsterloot) do
            if math.random(100000) <= rate * loot.chance then
                local count = loot.maxCount > 1 and math.random(loot.maxCount) or 1
                bp:addItem(loot.itemId, count)
                str = str .. count .. " " .. ItemType(loot.itemId):getName() .. ", "
            end
        end
        if str ~= "" then
            if str:sub(-2, -2) == "," then
                str = str:sub(1, str:len() - 2)
            end
            killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Loot bonus [" .. creature:getName() .. "]: " .. str .. '.')
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
        end
    -- extraloot
    elseif creature:getName():lower() == BOOSTED.monster.extraloot:lower() then
        local bp = corpse:addItem(1987, 1)
        local str = ""
        for index, value in ipairs(boosted.possible[3][2]) do
            if not value[3] or math.random(100) <= value[3] then
                if ItemType(value[1]):isStackable() then
                    bp:addItem(value[1], value[2])
                else
                    for i = 1, value[2] do
                        bp:addItem(value[1], 1)
                    end
                end
                str = str .. value[2] .. " " .. ItemType(value[1]):getName() .. ", "
            end
        end
        if str ~= "" then
            if str:sub(-2, -2) == "," then
                str = str:sub(1, str:len() - 2)
            end
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
            creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
            killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Extra loot [" .. creature:getName() .. "]: " .. str .. '.')
        end
    end
    return true
end

creatureevent:register()

local talkaction = TalkAction('!extraloot')

function talkaction.onSay(player, words, param)
    player:popupFYI(boostedInfo)
    return false
end

talkaction:separator(" ")
talkaction:register()
 
if you have this error then you most likely have an error at data/scripts/BoostedCreature.lua as well, do you?

Nothing comes up when server starts and boosted exp rate works fine. Is it because its trying to run the script 3 times with the same monster?

EDIT: The error came up in bulk like 5 minutes into the server being on
 
Last edited:
Nothing comes up when server starts and boosted exp rate works fine. Is it because its trying to run the script 3 times with the same monster?

EDIT: The error came up in bulk like 5 minutes into the server being on

I still cannot find the issue. I can't understand how only part of the scripts works without throwing up an error. A error/warning box only appears a long time AFTER the boosted monster has been killed.

EDIT: Ok so after killing a rat the extra exp works but this error comes up 3x:

[Warning - Monster::Monster] Unknown event name: BoostedDeath
[Warning - Monster::Monster] Unknown event name: BoostedDeath
[Warning - Monster::Monster] Unknown event name: BoostedDeath
 
Last edited:
I still cannot find the issue. I can't understand how only part of the scripts works without throwing up an error. A error/warning box only appears a long time AFTER the boosted monster has been killed.

EDIT: Ok so after killing a rat the extra exp works but this error comes up 3x:

[Warning - Monster::Monster] Unknown event name: BoostedDeath
[Warning - Monster::Monster] Unknown event name: BoostedDeath
[Warning - Monster::Monster] Unknown event name: BoostedDeath

unknown event name means the onDeath event is not registered so its not recognized
 
unknown event name means the onDeath event is not registered so its not recognized

I know that.. When a rat spawns into the game it brings up the error 3x but when it dies it gives the bonus exp. The number of errors matches the amount of times this is in the script, but without them nothing works?
Lua:
MonsterType(monster1):registerEvent("BoostedDeath")
    MonsterType(monster2):registerEvent("BoostedDeath")
    MonsterType(monster3):registerEvent("BoostedDeath")

In the script it registers the event so i don't know how to stop the errors and make the extra loot work because as far as i can see it is registering BoostedDeath in boostedCreature.lua

I cannot understand how i have followed this exactly and i am getting an error. This happens with nearly everything i find here its so underwhelming.
 
...
[Warning - Monster::Monster] Unknown event name: BoostedDeath
this is caused when the same monster is registered more than once, with same event name.
The reason it started spamming was the fact the rats were respawing. Spawing them in with /m resulted in instant console spam.

I "fixed" this by breaking the BoostedDeath into the 3 seperate boosts, BoostedDeathExp, BoostedDeathLootRate and BoostedDeathExtraLoot
and registering each one individually. If you were to have the same monster in each category and got unlucky enough that it registered more than once the monster would be broken. e.i. No exp given, no extra loot, and/or no loot increase.

EDIT2: Broken don't use. Only works with a single monster.
EDIT3: Turns out it works as long as your not a GOD 🤦‍♂️ ...
Lua:
boosted = {}
boosted.creatures = {}
-- possible monsters
boosted.possible = {
  {
    --{"Demon", "Hellhound", "Grim Reaper", "Juggernaut", "Amazon", "Valkyrie", "Carrion Worm", "Drillworm", "Rift Worm", "Rotworm", "Kongra", "Merlkin", "Sibang", "Yeti", }, -- exp list
    {"rat",}, -- exp list
      1.1 -- exp rate
  },
  {
    --{"Dragon Lord", "Medusa", "Hydra", "Serpent Spawn"}, -- loot list
    {"rat",}, -- loot list
    1.2 -- loot rate
  },
  {
    -- {"Warlock", "Infernalist", "Demon Outcast", "Nightmare"}, -- extraloot list
    {"rat",}, -- extraloot list
    {{2494, 1, 25}, {2646, 1, 10}, {2469, 2, 15}, {2352, 1, 50}} -- items list
  }
}

function getBoostedCreature()
  local t = {
    monster = {exp = boosted.creatures[1], loot = boosted.creatures[2], extraloot = boosted.creatures[3]},
    rate = {exp = boosted.possible[1][2], loot = boosted.possible[2][2], extraloot = boosted.possible[3][2]}
    }
  return t
end

local boostedInfo = ""
local globalevent = GlobalEvent("boostedcreatures")

function globalevent.onStartup()
-- select monsters
  local monster1 = boosted.possible[1][1][math.random(#boosted.possible[1][1])]
  local monster2 = boosted.possible[2][1][math.random(#boosted.possible[2][1])]
  local monster3 = boosted.possible[3][1][math.random(#boosted.possible[3][1])]

  boosted.creatures[1] = monster1
  boosted.creatures[2] = monster2
  boosted.creatures[3] = monster3
  -- string for talkaction
  boostedInfo = boostedInfo .. ('Today daily creatures are: %s has extra exp %.1f\n%s has extra loot rate %.1f\n%s has extraloot, list of possible items:\n\n'):format(monster1, getBoostedCreature().rate.exp, monster2, getBoostedCreature().rate.loot, monster3)
  for index, value in ipairs(boosted.possible[3][2]) do
    boostedInfo = boostedInfo .. "[" .. ItemType(value[1]):getName() .. "]: count; " .. value[2] .. ", chance; " .. (not value and "100%" or value[3] .. "%") .. ((#boosted.possible[3][2] > 1 and index < #boosted.possible[3][2]) and "\n" or "")
  end
  -- in case you forget to register the event in monsterfile.xml
  MonsterType(monster1):registerEvent("BoostedDeathExp")
  MonsterType(monster2):registerEvent("BoostedDeathLootRate")
  MonsterType(monster3):registerEvent("BoostedDeathExtraLoot")
    ------------------------------------------------------------
  return true
end
globalevent:register() --registering boostedcreatures

local creatureevent = CreatureEvent("BoostedLogin")
function creatureevent.onLogin(player)
  local boosted = getBoostedCreature()
  local message = "Today daily creatures are: " .. boosted.monster.exp .. " has extra exp rate " .. boosted.rate.exp .. "\n" .. boosted.monster.loot .. " has extra loot rate " .. boosted.rate.loot .. "\n" .. boosted.monster.extraloot .. " has extra loot: type !extraloot for more information \n\nEnjoy!"
  player:sendTextMessage(MESSAGE_INFO_DESCR, message)
  return true
end
creatureevent:register() -- registering BoostedLogin

local creatureevent = CreatureEvent("BoostedDeathExp")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
  if not creature:isMonster() or not killer:isPlayer() or not corpse then
    return true
  end
  local BOOSTED = getBoostedCreature()
  -- exp-------------------------------------------
  if creature:getName():lower() == BOOSTED.monster.exp:lower() then
    local exp = math.floor(MonsterType(creature:getName()):experience() * (Game.getExperienceStage(killer:getLevel()) + BOOSTED.rate.exp))
    killer:addExperience(exp, true)
  end
  return true
end
creatureevent:register()--registering BoostedDeathExp

    -- loot-------------------------------------------
local creatureevent = CreatureEvent("BoostedDeathLootRate")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
  if not creature:isMonster() or not killer:isPlayer() or not corpse then
    return true
  end
  local BOOSTED = getBoostedCreature()
  if creature:getName():lower() == BOOSTED.monster.loot:lower() then
    local monsterloot = MonsterType(creature:getName()):getLoot()
    local bp = corpse:addItem(1987, 1)
    local str = ""
    local rate = BOOSTED.rate.loot * configManager.getNumber(configKeys.RATE_LOOT)
    for i, loot in pairs(monsterloot) do
      if math.random(100000) <= rate * loot.chance then
        local count = loot.maxCount > 1 and math.random(loot.maxCount) or 1
        bp:addItem(loot.itemId, count)
        str = str .. count .. " " .. ItemType(loot.itemId):getName() .. ", "
      end
    end
    if str ~= "" then
      if str:sub(-2, -2) == "," then
        str = str:sub(1, str:len() - 2)
      end
      killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Loot bonus [" .. creature:getName() .. "]: " .. str .. '.')
      creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
      creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
    end
  end
  return true
end
creatureevent:register()--registering BoostedDeathLootRate

-- extraloot------------------------------------------------------
local creatureevent = CreatureEvent("BoostedDeathExtraLoot")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
  if not creature:isMonster() or not killer:isPlayer() or not corpse then
    return true
  end
  local BOOSTED = getBoostedCreature()
  if creature:getName():lower() == BOOSTED.monster.extraloot:lower() then
    local bp = corpse:addItem(1987, 1)
    local str = ""
    for index, value in ipairs(boosted.possible[3][2]) do
      if not value[3] or math.random(100) <= value[3] then
        if ItemType(value[1]):isStackable() then
          bp:addItem(value[1], value[2])
        else
          for i = 1, value[2] do
            bp:addItem(value[1], 1)
          end
        end
          str = str .. value[2] .. " " .. ItemType(value[1]):getName() .. ", "
      end
    end
    if str ~= "" then
      if str:sub(-2, -2) == "," then
        str = str:sub(1, str:len() - 2)
      end
      creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW, killer)
      creature:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE, killer)
      killer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Extra loot [" .. creature:getName() .. "]: " .. str .. '.')
    end
  end
  return true
end
creatureevent:register()--registering BoostedDeathExtraLoot

local talkaction = TalkAction('!extraloot')

function talkaction.onSay(player, words, param)
    player:popupFYI(boostedInfo)
    return false
end

talkaction:separator(" ")
talkaction:register() --registering !extraloot
Be aware that if the same monster gets Boosted with the lootrate and extraloot it's a lot of loot.
This is just from 9 rats. Although I do have my server rateLoot = 12 so 🤷‍♂️ your mileage will vary.
OT002.png

EDIT: If someone knows how to remove the bags from the loot that'd be great. 😊
 
Last edited:
hello
Is there any guide on how to add more monsters, loot rate and extra loot, it would be appreciated. Thank you
 
Back
Top