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

New Fishing system for TFS 1.1

Andréew

Humble mapper.
Joined
Apr 14, 2015
Messages
833
Solutions
2
Reaction score
1,929
Location
Sweden
I use TFS 1.1

Hey guys!
I would like to have a script or several (if needed) that will change the fishing system, i will describe to you what i had in mind :)

When you fish, you will be able to randomly get different kinds of fish.
2667 - Fish
2669 - Northern pike
7158 - Rainbow trout
7159 - Green perch
When you caught a fish weight will be determined randomly and the heavier the fish the more it sells for by an NPC, for example if i catch a Rainbow trout which weight 0.3 oz it sells for 30gp (sells for 10gp/0.1 oz. )

Depending on which rod you use and which fishing skill you got its easier to get heavier fish.
2580 - fishing rod
10223 - mechanical fishing rod
if it makes it easier then maybe mech rod should just add +10 fishing skill

and being able to fish up monsters ( Crab, Tortoise and Blood crab) but rarely happens

I dont know if all this is possible but it would be awesome if it was.
Interested in helping me out? send me a PM and maybe we can strike a deal :)
 
Last edited:
The quote was for my response to you "Exactly, also unnecessary." regarding the change he suggest in items.xml to make fish unstackable, thats why i referred to him as "he" not "you"
had to download capturing program and set up stuff
http://jarx.s-ul.eu/ZVNqEcC1
Code:
local fishes = {
    [2226] = {chance = {0,50}, weight = {10, 100}, skillTriesBonus = 5},
    [2227] = {chance = {51,100}, weight = {20, 200}, skillTriesBonus = 10},
    }

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local targetId = target.itemid
    if not isInArray(waterIds, target.itemid) then
        return false
    end
   
    local rand = math.random(100)
    for pos, val in pairs(fishes) do
        if rand >= val.chance[1] and rand <= val.chance[2] then
            local item = player:addItem(pos)
            local weight = math.random(val.weight[1], val.weight[2])
            print(weight)
            item:setAttribute(ITEM_ATTRIBUTE_WEIGHT, (weight*player:getSkillLevel(SKILL_FISHING)))
            player:addSkillTries(math.floor(weight*val.skillTriesBonus))
            toPosition:sendMagicEffect(CONST_ME_WATERSPLASH)
        end
    end   
    return true
end
obv code can be made a lot better with chances / skill level and what not, but nothing significant
 
had to download capturing program and set up stuff
http://jarx.s-ul.eu/ZVNqEcC1
Code:
local fishes = {
    [2226] = {chance = {0,50}, weight = {10, 100}, skillTriesBonus = 5},
    [2227] = {chance = {51,100}, weight = {20, 200}, skillTriesBonus = 10},
    }

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local targetId = target.itemid
    if not isInArray(waterIds, target.itemid) then
        return false
    end
 
    local rand = math.random(100)
    for pos, val in pairs(fishes) do
        if rand >= val.chance[1] and rand <= val.chance[2] then
            local item = player:addItem(pos)
            local weight = math.random(val.weight[1], val.weight[2])
            print(weight)
            item:setAttribute(ITEM_ATTRIBUTE_WEIGHT, (weight*player:getSkillLevel(SKILL_FISHING)))
            player:addSkillTries(math.floor(weight*val.skillTriesBonus))
            toPosition:sendMagicEffect(CONST_ME_WATERSPLASH)
        end
    end
    return true
end
obv code can be made a lot better with chances / skill level and what not, but nothing significant
And the npc that will buy all the fish based on their weight? Assuming not one by one, as that would take forever, so you'll need the npc to read all the fish and add up their weight and offer a payment based on the added weight, and the chance to fish up monsters? And making them stackable if by same weight amount? Of course writing a small portion of what he asked for is a small portion of lua :p
 
And the npc that will buy all the fish based on their weight? Assuming not one by one, as that would take forever, so you'll need the npc to read all the fish and add up their weight and offer a payment based on the added weight, and the chance to fish up monsters? And making them stackable if by same weight amount? Of course writing a small portion of what he asked for is a small portion of lua :p
npc -> sell all fish of X type
go through all instances of X type in players inventory and sell and give money based on attribute
fishing up monsters is like 3 more lines to add
allowing stacking if they weigh same amount if a few lines in onMoveItem in events only aswell

actually just realized, creating 2 fish that weigh 5 oz and 2 that weigh 10 oz, you cant stack 5 & 10 oz, but the 5/5 and 10/10 stack automatically, so dont even need any code to do that lul

@Sir Knighter
Code:
local goldPerOz = 10
local fishes = {7159}

function onSay(player, words, param)
    local money = 0
    for i=1,#fishes do
        while player:getItemById(fishes[i], true) do
            local fish = player:getItemById(fishes[i], true)
            if fish then
                local weight = (fish:getAttribute(ITEM_ATTRIBUTE_WEIGHT) > 0 and (fish:getAttribute(ITEM_ATTRIBUTE_WEIGHT)/100*fish:getCount())) or (fish:getType():getWeight()*fish:getCount())/100
                money = money + weight*goldPerOz
                fish:remove()
            end
        end
    end
    player:addMoney(money)
    return true
end
oh no, what a giant piece of code to sell all valid types of fishes aswell.....

not going to post code for how to use attributes without setting them in tfs (so you can actually stack fishes weighing diff and stuff), im not that helpful/nice
 
Last edited:
npc -> sell all fish of X type
go through all instances of X type in players inventory and sell and give money based on attribute
fishing up monsters is like 3 more lines to add
allowing stacking if they weigh same amount if a few lines in onMoveItem in events only aswell

actually just realized, creating 2 fish that weigh 5 oz and 2 that weigh 10 oz, you cant stack 5 & 10 oz, but the 5/5 and 10/10 stack automatically, so dont even need any code to do that lul

@Sir Knighter
Code:
local goldPerOz = 10
local fishes = {7159}

function onSay(player, words, param)
    local money = 0
    for i=1,#fishes do
        while player:getItemById(fishes[i], true) do
            local fish = player:getItemById(fishes[i], true)
            if fish then
                local weight = (fish:getAttribute(ITEM_ATTRIBUTE_WEIGHT) > 0 and (fish:getAttribute(ITEM_ATTRIBUTE_WEIGHT)/100*fish:getCount())) or (fish:getType():getWeight()*fish:getCount())/100
                money = money + weight*goldPerOz
                fish:remove()
            end
        end
    end
    player:addMoney(money)
    return true
end
oh no, what a giant piece of code to sell all valid types of fishes aswell.....

not going to post code for how to use attributes without setting them in tfs (so you can actually stack fishes weighing diff and stuff), im not that helpful/nice
Nice work, now you supplied the scripts he was asking for :) @Andréew

I will admit I stand corrected, i guess you did a much better job than one of our coders, assuming it all works without any issues.
 
Last edited by a moderator:
Back
Top