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

Lua TFS add fishing skill to influence in fishing reward

Icaraii

Well-Known Member
Joined
Jan 5, 2020
Messages
469
Solutions
1
Reaction score
58
Hi guys,

I use this script on my server for player that fish to catch monster and/or fishes. It all work fine, I just wanted for the fishing skill also matter in the fishing the player is getting. For example, if the player has 10 fishing skill, he will get 10 shirmp out of 8 tries. If the player has 100 skill he will get 1 shirmp, 2 perchs and 7 sharks out of 10 tries.

Lua:
local waters = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4608, 4609, 4610, 4611, 4612, 4613, 7236, 10499, 15401, 15402, 4632, 4633, 4634, 4635, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4645, 4646, 4647, 4648, 4649, 4650, 4651, 4652, 4653, 4654, 4655, 4656, 4657, 4658, 4659, 4660, 4661, 4662, 4663, 4664, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825, 4828, 4829, 4830, 4831, 6627, 6628, 6629, 6630, 6631, 6632, 6633, 6634, 6635, 6636, 6637, 6638, 6639, 6640, 6641, 6642, 6643, 6644, 6645, 6646, 6647, 6648, 6649, 6650, 6651, 6652, 6653, 6654, 6655, 6656, 6657, 6658, 6659, 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6667, 6668, 6669, 6670, 6671, 6672, 6673, 6674, 6675, 6676, 6677, 6678, 6679, 6680, 6681, 6682, 6687, 6688, 6689, 6690, 6691, 6692, 6693, 6694, 7943, 7944, 7945, 7946, 7947, 7948, 7949, 7950, 7951, 7952, 7953, 7954, 8863}
local lava = {598, 599, 600, 601, 9883}
local swamp = {4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4752}

local water_monsters = {
    [1] = {name = "crab", chance = 75000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a crab!", broadcastToServer = false},
    [2] = {name = "calamary", chance = 50000, fishing = 10, level = 15, tries = 2, msg = "|PLAYERNAME| has caught a calamary!", broadcastToServer = false},
    [3] = {name = "fish", chance = 35000, fishing = 10, level = 20, tries = 3, msg = "|PLAYERNAME| has caught a small fish!", broadcastToServer = false},
    [4] = {name = "northern pike", chance = 25000, fishing = 10, level = 10, tries = 5, msg = "|PLAYERNAME| has caught a perch!", broadcastToServer = false},
    [5] = {name = "jellyfish", chance = 15000, fishing = 10, level = 10, tries = 3, msg = "|PLAYERNAME| has caught a jellyfish!", broadcastToServer = false},
}

local lava_monsters = {
    [1] = {name = "Fire Elemental", chance = 35000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a fire elemental!", broadcastToServer = false},
    [2] = {name = "Fire Devil", chance = 35000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a fire devil!", broadcastToServer = false},
    [3] = {name = "Dragon Lord", chance = 15000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a dragon lord!", broadcastToServer = false}
}

local swap_monsters = {
    [1] = {name = "rat", chance = 100000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a rat!", broadcastToServer = false}
}

local chance = 500000

local catchFishStorage = 15000 --This is used to so players can turn catching regular fish off or on.
local chanceCatchShrimp = 70 --20% chance to catch normal fish
local chanceCatchSmallfish = 70 --20% chance to catch normal fish
local chanceCatchCommonfish = 50 --20% chance to catch normal fish
local chanceCatchWaterfallfish = 40 --20% chance to catch normal fish
local chanceCatchCatfish = 30 --20% chance to catch normal fish
local chanceCatchCarp = 30 --20% chance to catch normal fish
local chanceCatchPerch = 20 --20% chance to catch normal fish
local chanceCatchOctopus = 10 --20% chance to catch normal fish
local chanceCatchShark = 10 --20% chance to catch normal fish
local shrimpId = 2670 -- Item id of normal fish
local smallfishId = 27905 -- Item id of normal fish
local commonfishId = 27892 -- Item id of normal fish
local waterfallfishId = 27903 -- Item id of normal fish
local catfishId = 27904 -- Item id of normal fish
local carpId = 27900 -- Item id of normal fish
local perchId = 7159 -- Item id of normal fish
local octopusId = 27887 -- Item id of normal fish
local sharkId = 27897 -- Item id of northern pike
exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) + 1))
 
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if player:getCondition(CONDITION_EXHAUST_HEAL) then
            return player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        end
      
    if Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
        return player:sendCancelMessage("You may not fish from protection zone.")
    end
    if not isInArray(waters, target.itemid) and not isInArray(lava, target.itemid) and not isInArray(swamp, target.itemid) then
        return false
    end
 
    local tmp_table = {}
 
    if isInArray(waters, target.itemid) then
        tmp_table = water_monsters
        toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
    elseif isInArray(lava, target.itemid) then
        tmp_table = lava_monsters
        toPosition:sendMagicEffect(CONST_ME_HITBYFIRE)
    elseif isInArray(swamp, target.itemid) then
        tmp_table = swap_monsters
        toPosition:sendMagicEffect(9)
    end
 
    for i = 1, #tmp_table do
        if (player:getLevel() >= tmp_table[i].level and player:getSkillLevel(SKILL_FISHING) >= tmp_table[i].fishing) then
            local catchChance = math.random(1, chance)
        local fishSkill = player:getSkillLevel(SKILL_FISHING)       
            if catchChance <= (tmp_table[i].chance + ((fishSkill - 10)* 1000)) then
                local MONS = Game.createMonster(tmp_table[i].name, player:getPosition())
        player:addSkillTries(SKILL_FISHING, tmp_table[i].tries)             
                if MONS then
                    if tmp_table[i].broadcastToServer then
                        local text = string.gsub(tmp_table[i].msg, "|PLAYERNAME|", player:getName())
                        Game.broadcastMessage(text)
                    end
                end
            break
            end
        end
    end
 
    if isInArray(waters, target.itemid) then

            if math.random(1, 100) <= chanceCatchShrimp then
                player:addItem(shrimpId, 1, true)
            else
                if math.random(1, 100) <= chanceCatchSmallfish then
                    player:addItem(smallfishId, 1, true)
            else
                if math.random(1, 100) <= chanceCatchCommonfish then
                    player:addItem(commonfishId, 1, true)
            else
                if math.random(1, 100) <= chanceCatchWaterfallfish then
                    player:addItem(waterfallfishId, 1, true)
            else
                if math.random(1, 100) <= chanceCatchCatfish then
                    player:addItem(catfishId, 1, true)
            else
                if math.random(1, 100) <= chanceCatchCarp then
                    player:addItem(carpId, 1, true)
            else
                if math.random(1, 100) <= chanceCatchPerch then
                    player:addItem(perchId, 1, true)
            else
                if math.random(1, 100) <= chanceCatchOctopus then
                    player:addItem(octopusId, 1, true)
            else
                if math.random(1, 100) <= chanceCatchShark then
                    player:addItem(sharkId, 1, true)
                end
            end
        end
    end
    end
    end
    end
    end
    end
    end

    player:addCondition(exhaust)
return true
end
 
Solution
It took me about 30 minutes to understand and I made some corrections, adapted it to RevScripts... I tested it in the game and I'm already really enjoying it. I'm sure I'll use it on my server. :)


I tested it with fishing skills, testing it in the river to catch some monsters, and it's working. I put 100 fishing skills and a stronger monster appeared, I liked it. I'm going to implement it for some cool quests... Keep bringing some scripts so I can analyze and adapt. xD


Note: I included information in the script according to percentage and skills. If you want to increase or decrease it according to your preference.

Lua:
local fishingAction = Action()

local waters = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623...
It took me about 30 minutes to understand and I made some corrections, adapted it to RevScripts... I tested it in the game and I'm already really enjoying it. I'm sure I'll use it on my server. :)


I tested it with fishing skills, testing it in the river to catch some monsters, and it's working. I put 100 fishing skills and a stronger monster appeared, I liked it. I'm going to implement it for some cool quests... Keep bringing some scripts so I can analyze and adapt. xD


Note: I included information in the script according to percentage and skills. If you want to increase or decrease it according to your preference.

Lua:
local fishingAction = Action()

local waters = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4608, 4609, 4610, 4611, 4612, 4613, 7236, 10499, 15401, 15402, 4632, 4633, 4634, 4635, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4645, 4646, 4647, 4648, 4649, 4650, 4651, 4652, 4653, 4654, 4655, 4656, 4657, 4658, 4659, 4660, 4661, 4662, 4663, 4664, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825, 4828, 4829, 4830, 4831, 6627, 6628, 6629, 6630, 6631, 6632, 6633, 6634, 6635, 6636, 6637, 6638, 6639, 6640, 6641, 6642, 6643, 6644, 6645, 6646, 6647, 6648, 6649, 6650, 6651, 6652, 6653, 6654, 6655, 6656, 6657, 6658, 6659, 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6667, 6668, 6669, 6670, 6671, 6672, 6673, 6674, 6675, 6676, 6677, 6678, 6679, 6680, 6681, 6682, 6687, 6688, 6689, 6690, 6691, 6692, 6693, 6694, 7943, 7944, 7945, 7946, 7947, 7948, 7949, 7950, 7951, 7952, 7953, 7954, 8863}
local lava = {598, 599, 600, 601, 9883}
local swamp = {4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4752}

local water_monsters = {
    {name = "crab", chance = 75000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a crab!", broadcastToServer = false, itemId = 2670},
    {name = "calamary", chance = 50000, fishing = 10, level = 15, tries = 2, msg = "|PLAYERNAME| has caught a calamary!", broadcastToServer = false, itemId = 27905},
    {name = "fish", chance = 35000, fishing = 10, level = 20, tries = 3, msg = "|PLAYERNAME| has caught a small fish!", broadcastToServer = false, itemId = 27892},
    {name = "northern pike", chance = 25000, fishing = 10, level = 10, tries = 5, msg = "|PLAYERNAME| has caught a perch!", broadcastToServer = false, itemId = 7159},
    {name = "jellyfish", chance = 15000, fishing = 10, level = 10, tries = 3, msg = "|PLAYERNAME| has caught a jellyfish!", broadcastToServer = false, itemId = 27887},
}

local lava_monsters = {
    {name = "Fire Elemental", chance = 35000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a fire elemental!", broadcastToServer = false},
    {name = "Fire Devil", chance = 35000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a fire devil!", broadcastToServer = false},
    {name = "Dragon Lord", chance = 15000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a dragon lord!", broadcastToServer = false}
}

local swap_monsters = {
    {name = "rat", chance = 100000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a rat!", broadcastToServer = false}
}

local chance = 500000

local catchFishStorage = 15000
local chanceCatchShrimp = 70
local chanceCatchSmallfish = 70
local chanceCatchCommonfish = 50
local chanceCatchWaterfallfish = 40
local chanceCatchCatfish = 30
local chanceCatchCarp = 30
local chanceCatchPerch = 20
local chanceCatchOctopus = 10
local chanceCatchShark = 10
local shrimpId = 2670
local smallfishId = 27905
local commonfishId = 27892
local waterfallfishId = 27903
local catfishId = 27904
local carpId = 27900
local perchId = 7159
local octopusId = 27887
local sharkId = 27897

function fishingAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getCondition(CONDITION_EXHAUST_HEAL) then
        return player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
    end

    if Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
        return player:sendCancelMessage("You may not fish from a protection zone.")
    end

    if not isInArray(waters, target.itemid) and not isInArray(lava, target.itemid) and not isInArray(swamp, target.itemid) then
        return false
    end

    local tmp_table = {}

    if isInArray(waters, target.itemid) then
        tmp_table = water_monsters
        toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
    elseif isInArray(lava, target.itemid) then
        tmp_table = lava_monsters
        toPosition:sendMagicEffect(CONST_ME_HITBYFIRE)
    elseif isInArray(swamp, target.itemid) then
        tmp_table = swap_monsters
        toPosition:sendMagicEffect(9)
    end

    local fishSkill = player:getSkillLevel(SKILL_FISHING)

    for i = 1, #tmp_table do
        if (player:getLevel() >= tmp_table[i].level and fishSkill >= tmp_table[i].fishing) then
            local catchChance = math.random(1, chance)
            local fish_weight = 0

            -- Find the weight of the current fish species
            for j = 1, #tmp_table do
                if tmp_table[j].name == tmp_table[i].name then
                    fish_weight = tmp_table[j].weight or 0
                    break
                end
            end

            local numFishCaught = 0
            local numTries = tmp_table[i].tries

           -- Calculate the number of fish based on fishing skill
            if fishSkill >= 100 then
                numFishCaught = math.floor(numTries * (fishSkill / 100))
            else
                numFishCaught = math.floor(numTries * 0.1 * fishSkill)
            end

            if catchChance <= (tmp_table[i].chance + ((fishSkill - 10) * 1000) - fish_weight) then
                local MONS = Game.createMonster(tmp_table[i].name, player:getPosition())
                player:addSkillTries(SKILL_FISHING, numTries)
                if MONS then
                    if tmp_table[i].broadcastToServer then
                        local text = string.gsub(tmp_table[i].msg, "|PLAYERNAME|", player:getName())
                        Game.broadcastMessage(text)
                    end
                end

              -- Add the correct amount of fish to the player
                for k = 1, numFishCaught do
                    if isInArray(waters, target.itemid) then
                        player:addItem(tmp_table[i].itemId, 1, true)
                    end
                end

                break
            end
        end
    end

    player:addCondition(exhaust)
    return true
end

fishingAction:id(39187)
fishingAction:register()
 
Solution
It took me about 30 minutes to understand and I made some corrections, adapted it to RevScripts... I tested it in the game and I'm already really enjoying it. I'm sure I'll use it on my server. :)


I tested it with fishing skills, testing it in the river to catch some monsters, and it's working. I put 100 fishing skills and a stronger monster appeared, I liked it. I'm going to implement it for some cool quests... Keep bringing some scripts so I can analyze and adapt. xD


Note: I included information in the script according to percentage and skills. If you want to increase or decrease it according to your preference.

Lua:
local fishingAction = Action()

local waters = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4608, 4609, 4610, 4611, 4612, 4613, 7236, 10499, 15401, 15402, 4632, 4633, 4634, 4635, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4645, 4646, 4647, 4648, 4649, 4650, 4651, 4652, 4653, 4654, 4655, 4656, 4657, 4658, 4659, 4660, 4661, 4662, 4663, 4664, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825, 4828, 4829, 4830, 4831, 6627, 6628, 6629, 6630, 6631, 6632, 6633, 6634, 6635, 6636, 6637, 6638, 6639, 6640, 6641, 6642, 6643, 6644, 6645, 6646, 6647, 6648, 6649, 6650, 6651, 6652, 6653, 6654, 6655, 6656, 6657, 6658, 6659, 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6667, 6668, 6669, 6670, 6671, 6672, 6673, 6674, 6675, 6676, 6677, 6678, 6679, 6680, 6681, 6682, 6687, 6688, 6689, 6690, 6691, 6692, 6693, 6694, 7943, 7944, 7945, 7946, 7947, 7948, 7949, 7950, 7951, 7952, 7953, 7954, 8863}
local lava = {598, 599, 600, 601, 9883}
local swamp = {4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4752}

local water_monsters = {
    {name = "crab", chance = 75000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a crab!", broadcastToServer = false, itemId = 2670},
    {name = "calamary", chance = 50000, fishing = 10, level = 15, tries = 2, msg = "|PLAYERNAME| has caught a calamary!", broadcastToServer = false, itemId = 27905},
    {name = "fish", chance = 35000, fishing = 10, level = 20, tries = 3, msg = "|PLAYERNAME| has caught a small fish!", broadcastToServer = false, itemId = 27892},
    {name = "northern pike", chance = 25000, fishing = 10, level = 10, tries = 5, msg = "|PLAYERNAME| has caught a perch!", broadcastToServer = false, itemId = 7159},
    {name = "jellyfish", chance = 15000, fishing = 10, level = 10, tries = 3, msg = "|PLAYERNAME| has caught a jellyfish!", broadcastToServer = false, itemId = 27887},
}

local lava_monsters = {
    {name = "Fire Elemental", chance = 35000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a fire elemental!", broadcastToServer = false},
    {name = "Fire Devil", chance = 35000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a fire devil!", broadcastToServer = false},
    {name = "Dragon Lord", chance = 15000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a dragon lord!", broadcastToServer = false}
}

local swap_monsters = {
    {name = "rat", chance = 100000, fishing = 10, level = 10, tries = 1, msg = "|PLAYERNAME| has caught a rat!", broadcastToServer = false}
}

local chance = 500000

local catchFishStorage = 15000
local chanceCatchShrimp = 70
local chanceCatchSmallfish = 70
local chanceCatchCommonfish = 50
local chanceCatchWaterfallfish = 40
local chanceCatchCatfish = 30
local chanceCatchCarp = 30
local chanceCatchPerch = 20
local chanceCatchOctopus = 10
local chanceCatchShark = 10
local shrimpId = 2670
local smallfishId = 27905
local commonfishId = 27892
local waterfallfishId = 27903
local catfishId = 27904
local carpId = 27900
local perchId = 7159
local octopusId = 27887
local sharkId = 27897

function fishingAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getCondition(CONDITION_EXHAUST_HEAL) then
        return player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
    end

    if Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
        return player:sendCancelMessage("You may not fish from a protection zone.")
    end

    if not isInArray(waters, target.itemid) and not isInArray(lava, target.itemid) and not isInArray(swamp, target.itemid) then
        return false
    end

    local tmp_table = {}

    if isInArray(waters, target.itemid) then
        tmp_table = water_monsters
        toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
    elseif isInArray(lava, target.itemid) then
        tmp_table = lava_monsters
        toPosition:sendMagicEffect(CONST_ME_HITBYFIRE)
    elseif isInArray(swamp, target.itemid) then
        tmp_table = swap_monsters
        toPosition:sendMagicEffect(9)
    end

    local fishSkill = player:getSkillLevel(SKILL_FISHING)

    for i = 1, #tmp_table do
        if (player:getLevel() >= tmp_table[i].level and fishSkill >= tmp_table[i].fishing) then
            local catchChance = math.random(1, chance)
            local fish_weight = 0

            -- Find the weight of the current fish species
            for j = 1, #tmp_table do
                if tmp_table[j].name == tmp_table[i].name then
                    fish_weight = tmp_table[j].weight or 0
                    break
                end
            end

            local numFishCaught = 0
            local numTries = tmp_table[i].tries

           -- Calculate the number of fish based on fishing skill
            if fishSkill >= 100 then
                numFishCaught = math.floor(numTries * (fishSkill / 100))
            else
                numFishCaught = math.floor(numTries * 0.1 * fishSkill)
            end

            if catchChance <= (tmp_table[i].chance + ((fishSkill - 10) * 1000) - fish_weight) then
                local MONS = Game.createMonster(tmp_table[i].name, player:getPosition())
                player:addSkillTries(SKILL_FISHING, numTries)
                if MONS then
                    if tmp_table[i].broadcastToServer then
                        local text = string.gsub(tmp_table[i].msg, "|PLAYERNAME|", player:getName())
                        Game.broadcastMessage(text)
                    end
                end

              -- Add the correct amount of fish to the player
                for k = 1, numFishCaught do
                    if isInArray(waters, target.itemid) then
                        player:addItem(tmp_table[i].itemId, 1, true)
                    end
                end

                break
            end
        end
    end

    player:addCondition(exhaust)
    return true
end

fishingAction:id(39187)
fishingAction:register()
Nice man, thanks a lot.

I have several script I gather over the years and I would be glad to share with you. The server I have is one in development for myself, only local usage, that I believe it's a better version of tibia RPG, it has mining elements, craft itens, mixed potions and other stuff.
 
@Mateus Robeerto, I only had time to test it today and I'm having problem with "allow far use" I have no idea how to add this to the script. When I use the script abouve in revscript it says "there is no way"
 
Back
Top