• 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

forgee

Veteran OT User
Joined
May 9, 2011
Messages
328
Solutions
18
Reaction score
286
Location
Sweden
GitHub
forgee
original thread: http://otland.net/threads/fishing-up-monsters.54905/ (Oct 27 2009)
original author: @soul4soul

Last updated: 2015.03.18

Update: merged with default TFS 1.1 fishing, so everything should work as usual. Please let me know if there are any issues.

Update 2: small optimization, fixed a bug with how the monster table is handled and added optional debug messages and validation of monsters through MonsterType("monster name"). If you are having issues, set debug = true and include the output in your post.
Monster verification is intended to help you spot misspelled monster names.
If you see "Monster fishing::Warning - Invalid monster name: Monster Name" for all your monsters, set verifyMonsters = false. Thanks to @Eldin for testing this, though I have no idea why it doesn't work. For me it works fine, but not for him, so I made the verification optional in case others run into the same issue.

Update3: Fixed typo.

When fishing you have a chance of catching a monster instead of a fish. The script uses the same formula as the official TFS 1.1 fishing script, when you catch something you will get either a monster or a fish.

Should be pretty easy to configure, just read the in-script comments.

actions.xml
Code:
<action itemid="2580" script="monsterFishing.lua" allowfaruse="1"/>

scripts/monsterFishing.lua
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", "Idontexist"},
        [150] = {"Quara Pincher", "Quara Predator"},
        [200] = {"Serpent Spawn", "Wyrm"},
        [300] = {"Sea Serpent"},
    },
    bosses = {
        -- Monsters that can only be caught with atleast "bossLevel" and "bossSkill"
        "Titan Goddess of Water",
    }
}

-- 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
            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, config.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

@Eldin
 
Last edited:
You can easily merge this script with default tfs fishing.
What was reason you removed other features such as water elementals fishing and obtaining a sand fish?

btw.
please include these information so people can use old version on 8.6 and original author will get credit

original thread: http://otland.net/threads/fishing-up-monsters.54905/ (Oct 27 2009)
original author: @soul4soul
 
Will be testing this the first thing in the morning, thank you @forgee ! :D

Kind Regards,
Eldin.
 
You can easily merge this script with default tfs fishing.
What was reason you removed other features such as water elementals fishing and obtaining a sand fish?
No particular reason other than I started over and just kept the config tables and the loops from the previous script I posted. In hindsight it probably would have been more prudent to just add it to the default script in the first place.
Will be testing this the first thing in the morning, thank you @forgee ! :D

Kind Regards,
Eldin.
Let me know how it goes. :)
 
Could it use action id to say only fish in a certain area?
Code:
<action itemid="2580" script="monsterFishing.lua" allowfaruse="1"/>
to
Code:
<action actionid="2580" script="monsterFishing.lua" allowfaruse="1"/>
 
@forgee - The script doesn't seem to take a worm nor get any fish, removed the original fish script and used this only as it should replace it all.
Any ideas? No errors at all in the log, I can fish and go up in fish lvl without a worm without getting a fish. (useworm = true)

Kind Regards,
Eldin.
 
Could it use action id to say only fish in a certain area?
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.

@forgee - The script doesn't seem to take a worm nor get any fish, removed the original fish script and used this only as it should replace it all.
Any ideas? No errors at all in the log, I can fish and go up in fish lvl without a worm without getting a fish. (useworm = true)

Kind Regards,
Eldin.
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.
 
@forgee - I believe its a Conspiracy against me within this script, schh, don't tell anyone.

The script is well written and easy to ready, yet it haunts me. The first worm part I mentioned should never be spoken about again, so lets bring up the next part.
I do not get any monsters. :eek: I set the part to lvl 10 simply to try it off before re-making it for my server. (Thats all I did and yes, my lvl was above 10)

Code:
  [10] = {"Quara Hydromancer", "Quara Constrictor", "Quara Mantassin"},
(Also gave it a shot with bear, Bear etc just to see if their was something else wrong, no errors in the log what so ever)

I am now officaly a fishing expert, my hands hurt, im out of Worms and I'll have to eat fish the entire month, yet, the monsters are laughing beneath the Surface.
Any idea how to lure these bas*ards?

Kind Regards,
Eldin.
 
@Eldin - As usual I can't reproduce the issue. :( Try bumping the chance to 100 and add:
Code:
print("#tmpMonsters: "..#tmpMonsters)
Above this line:
Code:
if #tmpMonsters > 0 and math.random(100) <= config.chance then
Then check your log for #tmpMonsters: X while fishing. X should be above 0, if it's not that means that it's not finding any monsters for your level.

Is Eldin the only one using this? Have anyone else tried it?
 
@Eldin - As usual I can't reproduce the issue. :( Try bumping the chance to 100 and add:
Code:
print("#tmpMonsters: "..#tmpMonsters)
Above this line:
Code:
if #tmpMonsters > 0 and math.random(100) <= config.chance then
Then check your log for #tmpMonsters: X while fishing. X should be above 0, if it's not that means that it's not finding any monsters for your level.

Is Eldin the only one using this? Have anyone else tried it?


I'll give it a try when I get home from school today.

@Eldin Forgee gave a great piece of advice, using print. I would put print with a special message after every check I could think of to see the scripts work-flow on the console, that way if I don't get a print, I know which one it was, and where the script stopped working...
 
I've tried it and it prints 0, I do understand why but im still abit confused, searching the code.

People may yet not began to use this script alot but it will be used for sure, their are loads of monster fishing scripting requests and searches.

Tell me if you get any results Codina.

Kind Regards,
Eldin.
 
Back
Top