Ramirow
Veteran OT User
- Joined
- Aug 22, 2009
- Messages
- 584
- Solutions
- 15
- Reaction score
- 301
- Location
- Argentina
- YouTube
- ramirogrant
As the title says, an Herblore Skill created using the custom skill system by Codex NG!
You NEED the system for this script to work!
Here: https://otland.net/threads/player-spell-experience-1-2.238208/
Also, remember to add the skill storages to the player (With firstitems.lua) or whatever method you see fit.
Well, there you go!
HOW IT WORKS:
1) You use for example a machete on the plant you wish to harvest.
2) You have a chance to fail or succeed. (The chance of success as well as the amount of powders gathered increases with your Herblore Skill)
3) If you succeed the plant will be destroyed, when you fail, the plant has a chance to also be destroyed (50% chance)
4) After some time the plant will be recreated in it's original position ONLY if there's no player in that spot. (If a player is standing there at the time of creation, it will just reset the creation event.)
-- Additional Information on HERBLORE Here --
https://otland.net/threads/herblore-mining-skill-tfs-1-1.242309/#post-2347207
Mining Skill
Here's the script:
It's really similar to the Herblore Skill.
HOW IT WORKS:
1) You use for example a pick or dwarven pickaxe (Or whatever item you assign this script to) on the rock you wish to mine.
2) You have a chance to fail or succeed. (The chance of success as well as the amount of small rubies / Small Enchanted Rubies -In this case- mined increases with your Mining Skill)
3) If you succeed the rock will be destroyed, when you fail, the rock has a chance to also be destroyed (50% chance). In addition to this, if your skill is high enough for a particular rock, you have a chance to mine better items. (Small Enchanted Rubies in the lower tier stone, and Red Gems in the higher tier stone in this case.)
4) After some time the rock will be recreated in it's original position ONLY if there's no player in that spot. (If a player is standing there at the time of creation, it will just reset the creation event.)
-- Additional Information on MINING Here --
https://otland.net/threads/herblore-mining-skill-tfs-1-1.242309/#post-2347208
Enjoy!
You NEED the system for this script to work!
Here: https://otland.net/threads/player-spell-experience-1-2.238208/
Also, remember to add the skill storages to the player (With firstitems.lua) or whatever method you see fit.
Well, there you go!
Code:
-- Herblore Skill by Ramirow
-- Script optimized and system created by Codex NG -THANKS! (https://otland.net/members/codex-ng.213653/)
-- For TFS version 1.1
local name = "Herblore" -- Name of the Custom Skill
local storage = 15000 -- Storage used to store Custom Skill Levels
local seconds = 30 -- Time to recreate the plant
function doCreateBush(pos, itemid) -- Recreates the plant after some time
local tile = Tile(pos)
if tile:getTopCreature() then
pos:sendMagicEffect(CONST_ME_POFF)
return addEvent(doCreateBush, seconds * 1000, pos, itemid)
else
Game.createItem(itemid, 1, pos)
pos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
end
local powders = { -- Contains all plants and their data
[2743] = {
itemid = 2743,
herbtype = 'red',
item = 8303,
level = {min = 1, max = 30},
roundChance = {min = 1, max = 2},
chance = 2,
round = 8,
xp = 1
},
[4135] = {
itemid = 4135,
herbtype = 'red',
item = 8303,
level = {min = 15, max = 30},
roundChance = {min = 4, max = 5},
chance = 6,
round = 3,
xp = 5
}
}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local player = type(cid) == 'number' and Player(cid) or cid
local herbSkill = player:getCustomSkill(storage)
if powders[target.itemid] then
local herbLevel = powders[target.itemid].level
if herbSkill >= herbLevel.min then
local chance = math.floor((math.random(1, 100)) - (herbSkill / powders[target.itemid].chance))
if chance <= herbLevel.max then
local loop = powders[target.itemid].xp
local roundChance = powders[target.itemid].roundChance
local amount = math.floor((math.random(roundChance.min, roundChance.max)) + (herbSkill / powders[target.itemid].round))
player:addItem(powders[target.itemid].item, amount)
toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
target:remove()
addEvent(doCreateBush, seconds * 1000, toPosition, target.itemid)
for i = loop, 1, -1 do
player:addCustomSkillTry(name, storage)
end
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You gathered " .. amount .. " " .. powders[target.itemid].herbtype .. " powders.")
else
local failure = math.random(1,100)
if failure <= 50 then
toPosition:sendMagicEffect(CONST_ME_POFF)
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You failed.")
target:remove()
addEvent(doCreateBush, seconds * 1000, toPosition, target.itemid)
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You failed.")
toPosition:sendMagicEffect(CONST_ME_POFF)
end
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need level " .. herbLevel.min .. " of " .. name .. " to harvest.")
end
end
return true
end
HOW IT WORKS:
1) You use for example a machete on the plant you wish to harvest.
2) You have a chance to fail or succeed. (The chance of success as well as the amount of powders gathered increases with your Herblore Skill)
3) If you succeed the plant will be destroyed, when you fail, the plant has a chance to also be destroyed (50% chance)
4) After some time the plant will be recreated in it's original position ONLY if there's no player in that spot. (If a player is standing there at the time of creation, it will just reset the creation event.)
-- Additional Information on HERBLORE Here --
https://otland.net/threads/herblore-mining-skill-tfs-1-1.242309/#post-2347207
Mining Skill
Here's the script:
Code:
-- Mining Skill by Ramirow
-- Skill System created by Codex NG -THANKS! (https://otland.net/members/codex-ng.213653/)
-- For TFS version 1.1
local name = "Mining" -- Name of the Custom Skill
local storage = 15002 -- Storage used to store Custom Skill Levels
local minutes = 1 -- Minutes to recreate the stone
function doCreateStone(pos, itemid) -- Recreates the stone after given time
local tile = Tile(pos)
if tile:getTopCreature() then
pos:sendMagicEffect(CONST_ME_POFF)
return addEvent(doCreateStone, minutes * 60 * 1000, pos, itemid)
else
Game.createItem(itemid, 1, pos)
pos:sendMagicEffect(CONST_ME_MAGIC_RED)
end
end
local stones = { -- Contains all stones and their data
[8639] = {
itemid = 8639,
stonetype = 'small ruby',
stonetype2 = 'small enchanted ruby',
item = 2147,
item2 = 7760,
level = {min = 1, max = 30},
bonusLevel = 15,
bonusChance = 20,
roundChance = {min = 1, max = 2},
chance = 2,
round = 8,
xp = 1,
xp2 = 2
},
[8635] = {
itemid = 8635,
stonetype = 'small enchanted ruby',
stonetype2 = 'red gem',
item = 7760,
item2 = 2156,
level = {min = 15, max = 30},
bonusLevel = 25,
roundChance = {min = 1, max = 2},
chance = 4,
round = 10,
xp = 3,
xp2 = 5
}
}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local player = type(cid) == 'number' and Player(cid) or cid
local miningSkill = player:getCustomSkill(storage)
if stones[target.itemid] then
local miningLevel = stones[target.itemid].level
if miningSkill >= miningLevel.min then
local chance = math.floor((math.random(1, 100)) - (miningSkill / stones[target.itemid].chance))
if chance <= miningLevel.max then
local roundChance = stones[target.itemid].roundChance
local amount = math.floor((math.random(roundChance.min, roundChance.max)) + (miningSkill / stones[target.itemid].round))
if miningSkill >= stones[target.itemid].bonusLevel and math.random(1,100) <= stones[target.itemid].bonusChance then
local loop2 = stones[target.itemid].xp2
player:addItem(stones[target.itemid].item2, amount)
toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
target:remove()
addEvent(doCreateStone, minutes * 60 * 1000, toPosition, target.itemid)
for i = loop2, 1, -1 do
player:addCustomSkillTry(name, storage)
end
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You mined " .. amount .. " " .. stones[target.itemid].stonetype2 .. ".")
else
local loop = stones[target.itemid].xp
player:addItem(stones[target.itemid].item, amount)
toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
target:remove()
addEvent(doCreateStone, minutes * 60 * 1000, toPosition, target.itemid)
for i = loop, 1, -1 do
player:addCustomSkillTry(name, storage)
end
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You mined " .. amount .. " " .. stones[target.itemid].stonetype .. ".")
end
else
local failure = math.random(1,100)
if failure <= 50 then
toPosition:sendMagicEffect(CONST_ME_POFF)
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You failed and the rock was destroyed.")
target:remove()
addEvent(doCreateStone, minutes * 60 * 1000, toPosition, target.itemid)
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You couldn't mine anything.")
toPosition:sendMagicEffect(CONST_ME_HITAREA)
end
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need a " .. name .. " level of " .. miningLevel.min .. " to mine this stone.")
end
end
return true
end
It's really similar to the Herblore Skill.
HOW IT WORKS:
1) You use for example a pick or dwarven pickaxe (Or whatever item you assign this script to) on the rock you wish to mine.
2) You have a chance to fail or succeed. (The chance of success as well as the amount of small rubies / Small Enchanted Rubies -In this case- mined increases with your Mining Skill)
3) If you succeed the rock will be destroyed, when you fail, the rock has a chance to also be destroyed (50% chance). In addition to this, if your skill is high enough for a particular rock, you have a chance to mine better items. (Small Enchanted Rubies in the lower tier stone, and Red Gems in the higher tier stone in this case.)
4) After some time the rock will be recreated in it's original position ONLY if there's no player in that spot. (If a player is standing there at the time of creation, it will just reset the creation event.)
-- Additional Information on MINING Here --
https://otland.net/threads/herblore-mining-skill-tfs-1-1.242309/#post-2347208
Enjoy!
Last edited: