• 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 resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action TFS 1.x Water, Lava, and swamp monster fishing

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,339
Solutions
68
Reaction score
1,024
Lua:
local waters = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825, 4608, 4609, 4610, 4611, 4612, 4613, 7236}
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}

local water_monsters = {
    [1] = {name = "Monster One", chance = 1000, fishing = 100, level = 500, msg = "|PLAYERNAME| has caught a Monster One!", broadcastToServer = true}
}

local lava_monsters = {
    [1] = {name = "Monster One", chance = 1000, fishing = 100, level = 500, msg = "|PLAYERNAME| has caught a Monster One!", broadcastToServer = true}
}

local swap_monsters = {
    [1] = {name = "Monster One", chance = 1000, fishing = 100, level = 500, msg = "|PLAYERNAME| has caught a Monster One!", broadcastToServer = true}
}

local chance = 500000000

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    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(CONST_ME_POISONHIT)
    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)
           
            if catchChance <= tmp_table[i].chance then
                local MONS = Game.createMonster(tmp_table[i].name, player:getPosition())
               
                if MONS then
                    if tmp_table[i].broadcast then
                        local text = string.gsub(tmp_table[i].msg, "|PLAYERNAME|", player:getName())
                        Game.broadcastMessage(text)
                    end
                end
            break
            end
        end
    end
   
    player:addSkillTry(SKILL_FISHING, 1)
return true
end
 
Is this code used as a replacement for the old fishing code?
Im not a coder so i wouldn't know but from what i can see, there is no getting fish in this script? someone might want that to be added :)
Thank you for release tho!
 
Is this code used as a replacement for the old fishing code?
Im not a coder so i wouldn't know but from what i can see, there is no getting fish in this script? someone might want that to be added :)
Thank you for release tho!
You could9 add 'Fish' monster to the table.
 
Okay here is the code with catching normal fish possible. Also I added a spell so players can make it so they will not catch any normal fish only fishing monsters.

ACTIONSCRIPT
Lua:
local waters = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825, 4608, 4609, 4610, 4611, 4612, 4613, 7236}
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}

local water_monsters = {
    [1] = {name = "Monster One", chance = 1000, fishing = 100, level = 500, msg = "|PLAYERNAME| has caught a Monster One!", broadcastToServer = true}
}

local lava_monsters = {
    [1] = {name = "Monster One", chance = 1000, fishing = 100, level = 500, msg = "|PLAYERNAME| has caught a Monster One!", broadcastToServer = true}
}

local swap_monsters = {
    [1] = {name = "Monster One", chance = 1000, fishing = 100, level = 500, msg = "|PLAYERNAME| has caught a Monster One!", broadcastToServer = true}
}

local chance = 500000000

local catchFishStorage = 15000 --This is used to so players can turn catching regular fish off or on.
local chanceCatchNormalFish = 20 --20% chance to catch normal fish
local chanceCatchNorthernPike = 10 --10% chance to catch northerpike
local fishId = 1111 -- Item id of normal fish
local NorthernPikeId = 1111 -- Item id of northern pike

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    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(CONST_ME_POISONHIT)
    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)
           
            if catchChance <= tmp_table[i].chance then
                local MONS = Game.createMonster(tmp_table[i].name, player:getPosition())
               
                if MONS then
                    if tmp_table[i].broadcast 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 player:getStorageValue(catchFishStorage) == 1 then
            if math.random(1, 100) <= chanceCatchNormalFish then
                player:addItem(fishId, 1, true)
            else
                if math.random(1, 100) <= chanceCatchNorthernPike then
                    player:addItem(northernPikeId, 1, true)
                end
            end
        end
    end
   
    player:addSkillTry(SKILL_FISHING, 1)
return true
end

SPELL
Lua:
local catchFishStorage = 15000 --This is used to so players can turn catching regular fish off or on.

function onCastSpell(creature, variant)
    if creature:getStorageValue(catchFishStorage) == 1 then
        creature:setStorageValue(catchFishStorage, 0)
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You will now catch normal fish and fishing monsters.")
    else
        creature:setStorageValue(catchFishStorage, 1)
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You will no longer catch normal fish. You will only catch monsters.")
    end
return true
end
 
PLEASE DELETE THIS THREAD MODS IM GOING TO MAKE A MORE "ADVANCED" SYSTEM
 

Similar threads

Back
Top