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

Action [TFS 1.1] Fishing monsters

my config is your config in the post
my erros is here
if level >= config.bossLevel and skill >= config.bossSkill then
for i = 1, #config.bosses do
table.insert(tmpMonsters, bosses)
end
end
in the console say that "attempt to global index at line ..........." don't remember, my server is closed now, but is this
Code:
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236, 10499, 15401, 15402}
local lootTrash = {2234, 2238, 2376, 2509, 2667}
local lootCommon = {2152, 2167, 2168, 2669, 7588, 7589}
local lootRare = {2143, 2146, 2149, 7158, 7159}
local lootVeryRare = {7632, 7633, 10220}
local useWorms = true

-- Config for monster fishing
local config = {
    enabled = true, -- enable or disable monster fishing
    debug = false, -- enable debug messages in console
    verifyMonsters = true, -- disable this if you are having problems with Monster fishing::Warning - Invalid monster name
    chance = 50, -- chance to catch a monster in % - 50 means you have a 50/50 chance of getting a monster or a fish
    bossLevel = 300, -- min level to catch a "boss"
    bossSkill = 90, -- min fishing skill to catch a "boss"
    monsters = {
        -- [minLevel] = {"monster", "names", "for", "level"}
        [100] = {"Quara Hydromancer", "Quara Constrictor", "Quara Mantassin"},
        [150] = {"Water Elemental", "Massive Water Elemental"},
        [200] = {"Quara Pincher", "Quara Predator"},
        [300] = {"Sea Serpent"},
    },
    bosses = {
        -- Monsters that can only be caught with atleast "bossLevel" and "bossSkill"
        "Leviathan",
    }
}

-- Validate monsters configuration
if config.verifyMonsters then
    local m = {}
    for minLevel, monsters in pairs(config.monsters) do
        m[minLevel] = {}
        if config.debug then print("#monsters", #monsters) end
        for i = 1, #monsters do
            if MonsterType(monsters[i]) then
                table.insert(m[minLevel], monsters[i])
            else
                print("Monster fishing::Warning - Invalid monster name:", monsters[i])
            end
        end
        if config.debug then print("Monster fishing::Debug - #monsters added", #m[minLevel]) end
    end
    config.monsters = m
end

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local targetId = itemEx.itemid
    if not isInArray(waterIds, itemEx.itemid) then
        return false
    end

    if targetId == 10499 then
        local targetItem = Item(itemEx.uid)
        local owner = targetItem:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER)
        if owner ~= 0 and owner ~= player:getId() then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are not the owner.")
            return true
        end

        toPosition:sendMagicEffect(CONST_ME_WATERSPLASH)
        targetItem:remove()

        local rareChance = math.random(1, 100)
        if rareChance == 1 then
            player:addItem(lootVeryRare[math.random(#lootVeryRare)], 1)
        elseif rareChance <= 3 then
            player:addItem(lootRare[math.random(#lootRare)], 1)
        elseif rareChance <= 10 then
            player:addItem(lootCommon[math.random(#lootCommon)], 1)
        else
            player:addItem(lootTrash[math.random(#lootTrash)], 1)
        end
        return true
    end

    if targetId ~= 7236 then
        toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
    end

    if targetId == 493 or targetId == 15402 then
        return true
    end

    player:addSkillTries(SKILL_FISHING, 1)
    if math.random(1, 100) <= math.min(math.max(10 + (player:getEffectiveSkillLevel(SKILL_FISHING) - 10) * 0.597, 10), 50) then
        if useWorms and not player:removeItem("worm", 1) then
            return true
        end

        if targetId == 15401 then
            local targetItem = Item(itemEx.uid)
            targetItem:transform(targetId + 1)
            targetItem:decay()

            if math.random(1, 100) >= 97 then
                player:addItem(15405, 1)
                return true
            end
        elseif targetId == 7236 then
            local targetItem = Item(itemEx.uid)
            targetItem:transform(targetId + 1)
            targetItem:decay()

            local rareChance = math.random(1, 100)
            if rareChance == 1 then
                player:addItem(7158, 1)
                return true
            elseif rareChance <= 4 then
                player:addItem(2669, 1)
                return true
            elseif rareChance <= 10 then
                player:addItem(7159, 1)
                return true
            end
        end
        if config.enabled and math.random(100) <= config.chance then
            print("#tmpMonsters: "..#tmpMonsters)
        local level = player:getLevel()
            local skill = player:getSkillLevel(SKILL_FISHING)
            local tmpMonsters = {}

            for minLevel, monsters in pairs(config.monsters) do
                if config.debug then print("Monster fishing::Debug - Level check:", level, ">=", minLevel) end
                if level >= minLevel then
                    if config.debug then print("Monster fishing::Debug - Level check passed - #monsters:", #monsters) end
                    for i = 1, #monsters do
                        if config.debug then print("Monster fishing::Debug - Found monster:", monsters[i]) end
                        table.insert(tmpMonsters, monsters[i])
                    end
                end
            end

            if level >= config.bossLevel and skill >= config.bossSkill then
                for i = 1, #config.bosses do
                    table.insert(tmpMonsters, bosses[i])
                end
            end
            if config.debug then print("Monster fishing::Debug - #tmpMonsters: "..#tmpMonsters) end
            if #tmpMonsters > 0 then
                local pos = player:getPosition()
                Game.createMonster(tmpMonsters[math.random(1, #tmpMonsters)], pos)
                return true
            end
        end
        player:addItem("fish", 1)
    end
    return true
end
 
my config is your config in the post
my erros is here
if level >= config.bossLevel and skill >= config.bossSkill then
for i = 1, #config.bosses do
table.insert(tmpMonsters, bosses)
end
end
in the console say that "attempt to global index at line ..........." don't remember, my server is closed now, but is this
Code:
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236, 10499, 15401, 15402}
local lootTrash = {2234, 2238, 2376, 2509, 2667}
local lootCommon = {2152, 2167, 2168, 2669, 7588, 7589}
local lootRare = {2143, 2146, 2149, 7158, 7159}
local lootVeryRare = {7632, 7633, 10220}
local useWorms = true

-- Config for monster fishing
local config = {
    enabled = true, -- enable or disable monster fishing
    debug = false, -- enable debug messages in console
    verifyMonsters = true, -- disable this if you are having problems with Monster fishing::Warning - Invalid monster name
    chance = 50, -- chance to catch a monster in % - 50 means you have a 50/50 chance of getting a monster or a fish
    bossLevel = 300, -- min level to catch a "boss"
    bossSkill = 90, -- min fishing skill to catch a "boss"
    monsters = {
        -- [minLevel] = {"monster", "names", "for", "level"}
        [100] = {"Quara Hydromancer", "Quara Constrictor", "Quara Mantassin"},
        [150] = {"Water Elemental", "Massive Water Elemental"},
        [200] = {"Quara Pincher", "Quara Predator"},
        [300] = {"Sea Serpent"},
    },
    bosses = {
        -- Monsters that can only be caught with atleast "bossLevel" and "bossSkill"
        "Leviathan",
    }
}

-- Validate monsters configuration
if config.verifyMonsters then
    local m = {}
    for minLevel, monsters in pairs(config.monsters) do
        m[minLevel] = {}
        if config.debug then print("#monsters", #monsters) end
        for i = 1, #monsters do
            if MonsterType(monsters[i]) then
                table.insert(m[minLevel], monsters[i])
            else
                print("Monster fishing::Warning - Invalid monster name:", monsters[i])
            end
        end
        if config.debug then print("Monster fishing::Debug - #monsters added", #m[minLevel]) end
    end
    config.monsters = m
end

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local targetId = itemEx.itemid
    if not isInArray(waterIds, itemEx.itemid) then
        return false
    end

    if targetId == 10499 then
        local targetItem = Item(itemEx.uid)
        local owner = targetItem:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER)
        if owner ~= 0 and owner ~= player:getId() then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are not the owner.")
            return true
        end

        toPosition:sendMagicEffect(CONST_ME_WATERSPLASH)
        targetItem:remove()

        local rareChance = math.random(1, 100)
        if rareChance == 1 then
            player:addItem(lootVeryRare[math.random(#lootVeryRare)], 1)
        elseif rareChance <= 3 then
            player:addItem(lootRare[math.random(#lootRare)], 1)
        elseif rareChance <= 10 then
            player:addItem(lootCommon[math.random(#lootCommon)], 1)
        else
            player:addItem(lootTrash[math.random(#lootTrash)], 1)
        end
        return true
    end

    if targetId ~= 7236 then
        toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
    end

    if targetId == 493 or targetId == 15402 then
        return true
    end

    player:addSkillTries(SKILL_FISHING, 1)
    if math.random(1, 100) <= math.min(math.max(10 + (player:getEffectiveSkillLevel(SKILL_FISHING) - 10) * 0.597, 10), 50) then
        if useWorms and not player:removeItem("worm", 1) then
            return true
        end

        if targetId == 15401 then
            local targetItem = Item(itemEx.uid)
            targetItem:transform(targetId + 1)
            targetItem:decay()

            if math.random(1, 100) >= 97 then
                player:addItem(15405, 1)
                return true
            end
        elseif targetId == 7236 then
            local targetItem = Item(itemEx.uid)
            targetItem:transform(targetId + 1)
            targetItem:decay()

            local rareChance = math.random(1, 100)
            if rareChance == 1 then
                player:addItem(7158, 1)
                return true
            elseif rareChance <= 4 then
                player:addItem(2669, 1)
                return true
            elseif rareChance <= 10 then
                player:addItem(7159, 1)
                return true
            end
        end
        if config.enabled and math.random(100) <= config.chance then
            print("#tmpMonsters: "..#tmpMonsters)
        local level = player:getLevel()
            local skill = player:getSkillLevel(SKILL_FISHING)
            local tmpMonsters = {}

            for minLevel, monsters in pairs(config.monsters) do
                if config.debug then print("Monster fishing::Debug - Level check:", level, ">=", minLevel) end
                if level >= minLevel then
                    if config.debug then print("Monster fishing::Debug - Level check passed - #monsters:", #monsters) end
                    for i = 1, #monsters do
                        if config.debug then print("Monster fishing::Debug - Found monster:", monsters[i]) end
                        table.insert(tmpMonsters, monsters[i])
                    end
                end
            end

            if level >= config.bossLevel and skill >= config.bossSkill then
                for i = 1, #config.bosses do
                    table.insert(tmpMonsters, bosses[i])
                end
            end
            if config.debug then print("Monster fishing::Debug - #tmpMonsters: "..#tmpMonsters) end
            if #tmpMonsters > 0 then
                local pos = player:getPosition()
                Game.createMonster(tmpMonsters[math.random(1, #tmpMonsters)], pos)
                return true
            end
        end
        player:addItem("fish", 1)
    end
    return true
end
I apparently forgot config. before bosses, it should be:
Code:
table.insert(tmpMonsters, config.bosses[i])
Thanks for letting me know! :)

First post has been updated.
 
bro have to put in monsters too
table.insert(tmpMonsters, config.monsters)
and have an error, when I have level and Boss skill, I always catch a boss...
edit the if, put one math random :D
 
bro have to put in monsters too
table.insert(tmpMonsters, config.monsters)
and have an error, when I have level and Boss skill, I always catch a boss...
edit the if, put one math random :D
There is nothing wrong with the monsters part, it's not working on config.monsters directly. If you changed that you broke it.
I do not have any problem with always catching bosses, it's properly randomized.
If you did what you said and changed
Code:
table.insert(tmpMonsters, monsters[i])
to
Code:
table.insert(tmpMonsters, config.monsters[i])
then that would be why you don't catch any regular monsters. Looks like you introduced the problem yourself.

If you have any problems, turn on debugging (debug = true) and let me know what it says.
 
no have problems now, in
from: table.insert(tmpMonsters, config.monsters)
to:
table.insert(tmpMonsters, monsters)
now is very nice :3
:3
 
d
What @Himii said will let you use any item with that action id to fish with.
If you want to make it possible to catch monsters only from water tiles with a certain action id, then change this line:
Code:
if config.enabled then
To:
Code:
if config.enabled and Item(itemEx.uid):getActionId() == 1234 then
Replace 1234 with the action id you you want to use and add that action id to the water tiles you want to catch monsters from in your map editor.


Looking at the default script, gaining fishing skill without worms is normal, however you will never be able to get a fish that way (with useWorms = true). Are you sure you had worms in your backpack? I just tried it again and it works fine for me.
i don`t see the line
if config.enabled then
 
I updated the script since that post, it is now as StreamSide said above.
Code:
if config.enabled and math.random(100) <= config.chance then
If you need any more help, please provide a detailed description of how you want it to work.
 
want it to work as an action id not a item id like monsters can only be fished with water actionid xxxx also is thear a way to broadcast when a boss is cuaght?
 
want it to work as an action id not a item id like monsters can only be fished with water actionid xxxx also is thear a way to broadcast when a boss is cuaght?
Replace this line
Code:
if config.enabled and math.random(100) <= config.chance then
With this (remember to enter your actionid)
Code:
if config.enabled and Item(itemEx.uid):getActionId() == YOUR_ACTIONID and math.random(100) <= config.chance then

To add a broadcast when a boss is caught you could replace this part
Code:
if #tmpMonsters > 0 then
    local pos = player:getPosition()
    Game.createMonster(tmpMonsters[math.random(1, #tmpMonsters)], pos)
    return true
end
With something like this
Code:
if #tmpMonsters > 0 then
    local pos = player:getPosition()
    local name = tmpMonsters[math.random(1, #tmpMonsters)]
    Game.createMonster(name, pos)
    if isInArray(config.bosses, name) then
        Game.broadcastMessage(player:getName() .. " caught " .. name .. "!", MESSAGE_STATUS_WARNING)
    end
    return true
end
 
thnaks so much also could it be configured for diffrent lvl bosses? such as this
bosses = {
-- Monsters that can only be caught with atleast "bossLevel" and "bossSkill"
[100] = "Orshabaal",
[150] ="Morgaroth",
}
}
 
Last edited:
thnaks so much also could it be configured for diffrent lvl bosses? such as this
bosses = {
-- Monsters that can only be caught with atleast "bossLevel" and "bossSkill"
[100] = "Orshabaal",
[150] ="Morgaroth",
}
}
well that don`t seem to do anything
 
I have a problem where it seems to only catch the same monster every time and only once. I tried to log out and back in and still, no monsters. It also still consumes worms and doesn't give me a fish. ( I set the rate to 100% to test, Also I am sure that I set to to 100% and not 1%)

Other than that this seems like an amazing tool, I can see many great things coming of this!
Thank you so much,
-tys
 
[11:53:22.610] [Error - Test Interface]
[11:53:22.613] data/actions/scripts/other/monsterFishing.lua
[11:53:22.614] Description:
[11:53:22.616] data/actions/scripts/other/monsterFishing.lua:37: attempt to call global 'MonsterType' (a nil value)
[11:53:22.618] [Error - Event::checkScript] Cannot load script (data/actions/scripts/other/monsterFishing.lua)
 
[11:53:22.610] [Error - Test Interface]
[11:53:22.613] data/actions/scripts/other/monsterFishing.lua
[11:53:22.614] Description:
[11:53:22.616] data/actions/scripts/other/monsterFishing.lua:37: attempt to call global 'MonsterType' (a nil value)
[11:53:22.618] [Error - Event::checkScript] Cannot load script (data/actions/scripts/other/monsterFishing.lua)
Which TFS version are you using?
This script does not work on 0.x.
 
Back
Top