Zombiegod
Active Member
- Joined
- Oct 22, 2009
- Messages
- 198
- Solutions
- 1
- Reaction score
- 25
Okay so i wanted to make a monster fishing script a lot nicer.
So the idea for the changes was to make it so that fishing had luck, was based on fishing level and prestige, and was easy to add additional prestiges and monster per prestige
Granted i know little scripting so a lot of this is pieced together from other scripts in a way that i hope it works.
However its not working i am having issues and i am atm tired of making it work, so i want fresh experienced eyes to check it over
It loads up with no issues
So the idea for the changes was to make it so that fishing had luck, was based on fishing level and prestige, and was easy to add additional prestiges and monster per prestige
Granted i know little scripting so a lot of this is pieced together from other scripts in a way that i hope it works.
However its not working i am having issues and i am atm tired of making it work, so i want fresh experienced eyes to check it over
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local config = {
waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625},
rateSkill = getConfigValue("rateSkill"),
allowFromPz = false,
useWorms = true
}
local MIN_RAND = 1 -- The minimum amount of mana to be given (random)
local MAX_RAND = 100 -- The maximum amount of mana to be given (random)
local ACCEPT_LUCK = true -- Should it be possible to get lucky and receive extra mana? true, false
local FISH_LEVEL_MULTI = 2 -- How many times should Magic Level be multiplied, to be added to the mana formula? 1 = same, 0 = nothing etc
local LEVEL_MULTI = 2 -- How many times should Level be multiplied, to be added to the mana formula? 1 = same, 0 = nothing etc
local MAGIC_EFFECT = CONST_ME_LOSEENERGY -- Magic effect that will be casted on the player each time it heals the mana.
local prestige = getCreatureStorage(cid, 85987)
local FISHING_MONSTER = {
[One] = {prestige = 1, chance = 30,
Monsters = {"Monk",
"Deer"
}
},
[Two] = {prestige = 2, chance = 30,
Monsters = {"Demon",
"Rabbit"
}
}
}
local random = math.random(MIN_RAND, MAX_RAND)
if ACCEPT_LUCK == true then
local luck = math.random(1, 100)
if luck >= 90 then
random = random * 2
elseif luck == 50 then
random = random * 3
end
end
local formula = (getPlayerLevel(cid) * LEVEL_MULTI) + (getPlayerSkill(cid, SKILL_FISHING) * FISH_LEVEL_MULTI) + random
if(not isInArray(config.waterIds, itemEx.itemid)) then
return false
end
if((config.allowFromPz
or not getTileInfo(getCreaturePosition(cid)).protection)
and itemEx.itemid ~= 493
and math.random(1, formula)
and (not config.useWorms or (getPlayerItemCount(cid, ITEM_WORM) > 0
and doPlayerRemoveItem(cid, ITEM_WORM, 1))))
then
if math.random(100) <= FISHING_MONSTER.chance then
doSendMagicEffect(toPosition, MAGIC_EFFECT)
doCreateMonster(monsters[math.random], getCreaturePosition(cid))
doPlayerAddSkillTry(cid, SKILL_FISHING, config.rateSkill)
else
doPlayerAddSkillTry(cid, SKILL_FISHING, config.rateSkill)
end
return true
end
end
It loads up with no issues