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

Monster Fishing TFS 1.2

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,334
Solutions
68
Reaction score
1,012
I know there are a bunch of these but I wanted to give one with more options.. Also, you can use !catchs talkaction to see how many catch you have.


Action Script
Code:
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4665, 4664, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236, 10499, 15401, 15402}

local use_bait, bait, bait_chance = false, 3976, 1 --Will remove bait every time, if you put 10 its 1/10 chance.

local monsters = {
--monster name, storage for talkaction, chance to catch, level to catch, fishing level to catch, bc message, msg to broadcast, magicEffect sent to player, ME sent to monster, Monster msg when spawn
[1] = {name = "Dragon", storage = 30000, chance = 1, level = 1, fishing = 1, bc = true, msg = "|PLAYER| has caught a Dragon!", magic_effect_player = 9, magic_effect_monster = 10, monster_say_when_spawn = "Time to die."},
[2] = {name = "Dragon Lord", storage = 30001, chance = 1250, level = 45, fishing = 30, bc = true, msg = "A Dragon Lord is attacking |PLAYER|!", magic_effect_player = 11, magic_effect_monster = 13, monster_say_when_spawn = "Time to die."}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if getTilePzInfo(player:getPosition()) then return player:sendCancelMessage("You cannot use the fishing rod in a protection zone.") end
    if not isInArray(waterIds, target.itemid) then return false end

if use_bait and player:getItemCount(bait) < 1 then return player:sendCancelMessage("You must have worms to fish.")
    elseif player:getItemCount(bait) >= 1 then
        if math.random(1, bait_chance) == 1 then
            player:removeItem(bait, 1)
        end
end

for i = 1, #monsters do
    if player:getLevel() >= monsters[i].level and player:getSkillLevel(6) >= monsters[i].fishing then
        if math.random(1, monsters[i].chance) == 1 then
            EVENT = monsters[i]
            MONS = Game.createMonster(EVENT.name, player:getPosition())
            createFishingMonster(player, MONS, toPosition, EVENT)
            break
        end
    end
end

doSendMagicEffect(toPosition, 2)
doPlayerAddSkillTry(player, 6, 1, true)
return true
end

function createFishingMonster(player, MONS, toPosition, EVENT)
if not MONS then return false end
MONS:say(EVENT.monster_say_when_spawn, TALKTYPE_MONSTER_SAY, 0, 1, MONS:getPosition())
doSendMagicEffect(MONS:getPosition(), EVENT.magic_effect_monster)
doSendMagicEffect(player:getPosition(), EVENT.magic_effect_player)
doSendMagicEffect(toPosition, CONST_ME_WATERCREATURE)
if EVENT.bc then
    text = string.gsub(EVENT.msg, "|PLAYER|", player:getName())
    Game.broadcastMessage(text)
end
end


Talkaction script
Code:
local monsters = {
[1] = {name = "Dragon", storage = 30000},
[2] = {name = "Dragon Lord", storage = 30001}
}

function onSay(player, words, param)
for i = 1, #monsters do
        if player:getStorageValue(monsters[i].storage) < 0 then
            player:setStorageValue(monsters[i].storage, 0)
        end
    end

    text = ""

    for i = 1, #monsters do
        text = text.."["..monsters[i].name.."]: "..player:getStorageValue(monsters[i].storage).."\n"
    end

    doShowTextDialog(player, 2580, text)
    return false
end
 
Last edited:
This is really cool man love it! what is the idea behind the worms though?
 
This script has been done so many times to death.. lets stop re-inventing the wheel, besides what did you do just change a value or table and called it your own?

Actually it looks like you did write (some of it).. all that excessive code.
 
Last edited:
I don't like the way you did this because clearly in this code if you have monster with 100% chance it won't fish any others (if this monster is at the top of the table).
One solution would be to store every monster that was successfully randomed and then get a random one from those.

Or you could get the indexes in a random order instead of that for.
 
I don't like the way you did this because clearly in this code if you have monster with 100% chance it won't fish any others (if this monster is at the top of the table).
One solution would be to store every monster that was successfully randomed and then get a random one from those.

Or you could get the indexes in a random order instead of that for.

It was only set to catch every time to test. I assumed it would be changed.
 
It was only set to catch every time to test. I assumed it would be changed.
But even if you change, the chance of the last monster of the list being selected is highly afected by the ones above it.
 
Giving the ideal it would be the hardest monster to catch.
 
Back
Top