• 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.X+ Boosted Creature System

aqubjukr

Well-Known Member
Joined
Mar 13, 2013
Messages
200
Solutions
17
Reaction score
79
Location
Paraná, Brazil
Anyone have a script who changes the experience and loot of a monster randomly?

I've tried to adapt many scripts but i didn't got.

I'm using tfs 1.3.
 
I've trying to use this as a base: (for tfs 0.3.7)

Didn't appears any error on the console but the script didn't work (he didn't change the loot and the experience)

globalevents/scripts/daily_monster.lua:
Lua:
function onStartup()
local BOOSTED_MONSTER = 56404
local boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}
local randomMonster = math.random(#boostedMonstersList)
setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
    print("[Boosted Creature] Today's boosted monster is: " .. boostedMonstersList[randomMonster])
end


creaturescripts/scripts/daily_monster.lua
Lua:
function onLogin(cid)
local BOOSTED_MONSTER = 56404
local boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}
local boostedMonster = boostedMonstersList[getGlobalStorageValue(BOOSTED_MONSTER)]
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Today's monster boosted is: "..boostedMonster.."!")
return true
end


creaturescripts/scripts/daily_monster_bonus.lua
Lua:
loot_bonus = 50
ignoredList = {1987}
function addBonusLoot(position, name)
        for i = 0, 255 do
        position.stackpos = i
        corpse = getTileThingByPos(position)
        if corpse.uid > 0 and isCorpse(corpse.uid) then
            break
        end
    end
        local newRate = (1 + (loot_bonus/100)) * getConfigValue("rateLoot")
        local monsterLoot = getMonsterLootList(name)
        local mainbp = doCreateItemEx(1987, 1)
        for i, loot in pairs(monsterLoot) do
            if math.random(1, 100000) <= newRate * loot.chance then
                if #ignoredList > 0 then
                    if (not isInArray(ignoredList, loot.id)) then
                        doAddContainerItem(mainbp, loot.id, loot.countmax and math.random(1, loot.countmax) or 1)
                    end
                else
                    doAddContainerItem(mainbp, loot.id, loot.countmax and math.random(1, loot.countmax) or 1)
                end
            end
            doAddContainerItemEx(corpse.uid, mainbp)
        end
end

BOOSTED_MONSTER = 56404
boostedMonstersList = {"rat", "spider", "troll", "orc", "minotaur", "dwarf", "elf", "skeleton", "amazon", "valkirie", "dark apprentice", "ghoul", "cyclops", "dwarf guard", "necromancer", "vampire", "werewolf", "dragon", "dragon lord", "wyrm", "giant spider", "hydra", "warlock", "demon"}
 
Last edited:
to change the experience is easier to add the following to the function Player:eek:nGainExperience(source, exp, rawExp)

Lua:
local boostedMonster = boostedMonstersList[Game.getStorageValue(GlobalStorageKeys.BOOSTED_MONSTER)]
    if source:isMonster() and source:getName():lower() == boostedMonster then
        exp = exp * 1.3 -- 30%
    end
 
to change the experience is easier to add the following to the function Player:eek:nGainExperience(source, exp, rawExp)

Lua:
local boostedMonster = boostedMonstersList[Game.getStorageValue(GlobalStorageKeys.BOOSTED_MONSTER)]
    if source:isMonster() and source:getName():lower() == boostedMonster then
        exp = exp * 1.3 -- 30%
    end

I used your post as a base (there were some errors on the console), but modified it and managed to change the exp gained by killing the monster.
By the way, now i'll try to fix the loot.

Thx for helping man !
 
Back
Top