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