• 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 0.X Monster of the day 0.4

newby

Active Member
Joined
Jun 11, 2016
Messages
183
Reaction score
43
How to when opens the server
random("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") to make the monster of the day

When players login shows the monster of day

And when kill the monster of the day give 50% more exp

bump

bump

bump

bump

bump

bump

bump

bump

bump

bump
 
Solution
Wrote a little snippet.
Note: this is not a fully working code, but might help you find a workaround.
data/global.lua:
Lua:
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"}

data/globalevents/scripts/init.lua
Add this anywhere below function onStartup():
Lua:
local randomMonster = math.random(#boostedMonsterList)
setGlobalStorageValue(BOOSTED_MONSTER, randomMonster)
print("Today's boosted monster is: " .. boostedMonsterList[randomMonster])

New file...
Added loot to corpse & exp bonus based on monster deathlist (deathlist / i)

Lua:
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 experienceBonus = 0.5

function onDeath(cid, corpse, deathList)

local master = getCreatureMaster(cid)
  if (master and master ~= cid) then
    return true
  end

  local boostedMonster = boostedMonstersList[getGlobalStorageValue(BOOSTED_MONSTER)]
    if getCreatureName(cid):lower() == boostedMonster then
    
for i = 1, #deathList do
    
-- exp bonus
    local bonusExperience = getMonsterInfo(getCreatureName(cid)).experience/i * getPlayerRates(deathList[i])[SKILL__LEVEL] * experienceBonus
    doPlayerAddExperience(deathList[i], bonusExperience)
    doSendAnimatedText(getPlayerPosition(deathList[i]), bonusExperience, 215)
    
-- loot bonus
    local lootList = getMonsterLootList(getCreatureName(cid))
    for i, _ in pairs(lootList) do
        if lootList[i].count > 1 then
            local numb = math.random(1, lootList[i].count)
            doAddContainerItem(corpse.uid, lootList[i].id, numb)
        elseif math.random(1,100000) <= lootList[i].chance then
            doAddContainerItem(corpse.uid, lootList[i].id, 1)
        end
    end
    
end
    
    end
    return true
end
 
Added loot to corpse & exp bonus based on monster deathlist (deathlist / i)

Lua:
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 experienceBonus = 0.5

function onDeath(cid, corpse, deathList)

local master = getCreatureMaster(cid)
  if (master and master ~= cid) then
    return true
  end

  local boostedMonster = boostedMonstersList[getGlobalStorageValue(BOOSTED_MONSTER)]
    if getCreatureName(cid):lower() == boostedMonster then
    
for i = 1, #deathList do
    
-- exp bonus
    local bonusExperience = getMonsterInfo(getCreatureName(cid)).experience/i * getPlayerRates(deathList[i])[SKILL__LEVEL] * experienceBonus
    doPlayerAddExperience(deathList[i], bonusExperience)
    doSendAnimatedText(getPlayerPosition(deathList[i]), bonusExperience, 215)
    
-- loot bonus
    local lootList = getMonsterLootList(getCreatureName(cid))
    for i, _ in pairs(lootList) do
        if lootList[i].count > 1 then
            local numb = math.random(1, lootList[i].count)
            doAddContainerItem(corpse.uid, lootList[i].id, numb)
        elseif math.random(1,100000) <= lootList[i].chance then
            doAddContainerItem(corpse.uid, lootList[i].id, 1)
        end
    end
    
end
    
    end
    return true
end

OnPlayer die?
Code:
[12:58:52.896] [Error - CreatureScript Interface] 
[12:58:52.896] data/creaturescripts/scripts/monsteroftheday_onkill.lua:onDeath
[12:58:52.896] Description: 
[12:58:52.896] ...a/creaturescripts/scripts/monsteroftheday_onkill.lua:8: attempt to index global 'boostedMonstersList' (a nil value)
[12:58:52.896] stack traceback:
[12:58:52.896]     ...a/creaturescripts/scripts/monsteroftheday_onkill.lua:8: in function <...a/creaturescripts/scripts/monsteroftheday_onkill.lua:1>
[12:58:52.002] Dark Inside has logged out.
[12:58:54.780] Dark Inside has logged in.

OnPlayer kill the monster?
Code:
[12:59:23.163] [Error - CreatureScript Interface] 
[12:59:23.163] data/creaturescripts/scripts/monsteroftheday_onkill.lua:onDeath
[12:59:23.163] Description: 
[12:59:23.163] ...a/creaturescripts/scripts/monsteroftheday_onkill.lua:8: attempt to index global 'boostedMonstersList' (a nil value)
[12:59:23.163] stack traceback:
[12:59:23.163]     ...a/creaturescripts/scripts/monsteroftheday_onkill.lua:8: in function <...a/creaturescripts/scripts/monsteroftheday_onkill.lua:1>
 
Paste whole script to file with:
Lua:
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 experienceBonus = 0.5
 
Dont print the print('boost')

Code:
<event type="death" name="monsteroftheday_onkill" event="script" value="monsteroftheday_onkill.lua"/>

Code:
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 experienceBonus = 0.5

function onDeath(cid, corpse, deathList)

local master = getCreatureMaster(cid)
  if (master and master ~= cid) then
    return true
  end

  local boostedMonster = boostedMonstersList[getGlobalStorageValue(BOOSTED_MONSTER)]
    if getCreatureName(cid):lower() == boostedMonster then
    
for i = 1, #deathList do
    
-- exp bonus
    local bonusExperience = getMonsterInfo(getCreatureName(cid)).experience/i * getPlayerRates(deathList[i])[SKILL__LEVEL] * experienceBonus
    doPlayerAddExperience(deathList[i], bonusExperience)
    doSendAnimatedText(getPlayerPosition(deathList[i]), bonusExperience, 215)
    print('boost')
    
-- loot bonus
    local lootList = getMonsterLootList(getCreatureName(cid))
    for i, _ in pairs(lootList) do
        if lootList[i].count > 1 then
            local numb = math.random(1, lootList[i].count)
            doAddContainerItem(corpse.uid, lootList[i].id, numb)
        elseif math.random(1,100000) <= lootList[i].chance then
            doAddContainerItem(corpse.uid, lootList[i].id, 1)
        end
    end
    
end
    
    end
    return true
end
 
Add to boosted monster:
Lua:
<script>
        <event name="monsteroftheday_onkill"/>
</script>
Because it works for me.
7fa3ca165576db11373f14fe206e350e.png
 
There's a way to save monster boosted in a storage (maybe?) and print monster looktype in main page of Gesior? I dont know why but here its not saving global_storage, but giving more exp.
 
Last edited:
Back
Top