Azleh
Well-Known Member
As the title says, this is an edited fishing rod script for Nostalrius distro, it has the chance to summon monsters and items with the cipsoft chance (1 of 100k).
Java:
local WORMID = 3492 -- Nost: 3492
local fishableThings = {
[1] = {
thingId = 3032, -- Small Emerald
chance = 5,
monster = false,
},
[2] = {
thingId = 3030, -- Small Ruby
chance = 5,
monster = false,
},
[3] = {
thingId = "Rat",
chance = 10,
monster = true,
},
[4] = {
thingId = 3029, -- Small Saph
chance = 5,
monster = false,
},
[5] = {
thingId = 3028, -- Small Diamond
chance = 5,
monster = false,
},
[6] = {
thingId = 3027, -- Black Pearl
chance = 3,
monster = false,
},
[7] = {
thingId = 2874, -- Fluid
chance = 5,
monster = false,
},
[8] = {
thingId = 3578, -- Fish
chance = 15,
monster = false,
},
}
local water = {
4597, 4598, 4599, 4600, 4601, 4602,
4609, 4610, 4611, 4612, 4613, 4614,
4615, 4616, 4617, 4618, 4619, 4620,
622
}
local fishableWater = {
4597, 4598, 4599, 4600, 4601, 4602
}
function Player.fishRandom(self, fRepeat)
local fMonster = false
for i = 1, #fishableThings do
local chanceRandom = math.random(1, 100000)
if (chanceRandom < (fishableThings[i].chance * 1000)) then
if fishableThings[i].monster then
fMonster = true
end
fRepeat = false
self:finishFishing(fMonster, fishableThings[i].thingId)
break
end
end
if fRepeat then
self:fishRandom(true)
end
return true
end
function Player.finishFishing(self, fMonster, resultingId)
if fMonster then
Game.createMonster(resultingId, self:getPosition())
else
self:addItem(resultingId, 1)
end
return true
end
function onUse(player, item, fromPosition, target, toPosition)
if not target:isItem() then
return false
end
if not table.contains(water, target:getId()) then
return false
end
if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
if player:getItemCount(WORMID) >= 1 then
player:addSkillTries(SKILL_FISHING, 1)
player:fishRandom(true)
if target:getId() ~= 622 then
target:transform(4609, 1)
end
target:decay()
player:removeItem(WORMID, 1)
end
end
target:getPosition():sendMagicEffect(2)
return true
end