• 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!

Looking for mining system

armyman

Member
Joined
Feb 15, 2014
Messages
318
Reaction score
13
Someone have a simple mining system for the forgotten server 1.2?

No need get skills, just use (x item id)on x (stone 1 id), have a chance for get (x id item)"ore" the stone transform in other (stone 2 id) and back for (stone 1 id) after x time configured.

Thanks

up
 
Last edited by a moderator:
I have an idea of how the scripts could be. Try with the obsidian knife action script editing the item id of the corpses for the stone ids you desire to add to the system and then post this script and I can help you with the details that would be missing for the minning system. I have no time to make what I told you, but I will follow this post until you're done. Good Luck!
 
make for tfs 0.4 :(
I made one for our server, but we never ended up finishing the server, so I'll just release it.
It's not like it's difficult to make anyway.

From memory.. the system basically works like this..

You have 'tiers' of rocks, and when you break them, they turn into the lesser tier of rock, until you finally hit the smallest rock, and you can't mine it anymore.

The system is meant to have an automatic timer along with it, which would make the rocks 'grow' at random intervals, until it became the highest tier rock.
This means that the longer you let the rocks grow, the better items you could potentially get out it.

So the player has to make a choice, mine it now, or wait for it to grow more, but risk other players mining the rock before you come back to see how much it's grown.

You can also script in 'random events', like a special dwarf spawning and running away with the rock, as an example.

If you need help making the globalevent to spawn and grow the rocks when the server starts, let me know.
(You could also just make it so the rocks can only be harvested once per server save.. without creating the 'grow' script, and just place all of the rocks manually, but that's up to you.)

Lua:
local config = {
    [3608] = {text = {"Please no!", "Go find another rock.\nI'm not giving out today.", "Why me?", "Please.. stop.", "Haven't you beaten me enough?", "Leave me alone to grow.", "I'm only a little little rock!", "Ow! That was my left ovary!", "Ouch! My.. My right testicle! You monster!", "Please.. I just need some time..", "I'll give you your materials, just please..\nDon't hit me anymore.", "I gave you the materials already!\nWhat more do you want from me!?", "Your hammer is bigger then mine, Okay? Okay!?", "Please stop hitting my wife.\nI think she's starting to like it.", "Hit me again. I dare you.", "Enough already!", "What do I have to do..\nto make you leave?", "Your mother is a rock loving whore.", "Would you hit your mother like that?", "Puny human. Give me the hammer..\nI'll show you how to beat off properly."}},
    [3609] = {break_chance = 50, loot_chance = 20, lower_tier = 3608, -- 100 = break every try | 1 = 1/100 chance to break
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [3616] = {break_chance = 55, loot_chance = 18, lower_tier = 3609,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [3607] = {break_chance = 60, loot_chance = 16, lower_tier = 3616,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [1356] = {break_chance = 65, loot_chance = 14, lower_tier = 3607,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [1285] = {break_chance = 70, loot_chance = 12, lower_tier = 1356,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [3615] = {break_chance = 75, loot_chance = 10, lower_tier = 1285,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [1357] = {break_chance = 80, loot_chance = 8, lower_tier = 3615,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
 
    local object = config[itemEx.itemid]
 
    if object then
 
        if object.text then
            local rand_text = math.random(#object.text)
            doCreatureSay(cid, object.text[rand_text], TALKTYPE_ORANGE_1, nil, nil, toPosition)
            doSendMagicEffect(toPosition, CONST_ME_POFF)
            return true
        end
 
        -- random events
        local rand_event = math.random(200)
        if rand_event == 200 then
            --print("Random Special Event executed!")
            doSendMagicEffect(toPosition, 33)
            return true
        end
     
        -- rock break
        local rand_break = math.random(100)
        if rand_break <= object.break_chance then
            doTransformItem(itemEx.uid, object.lower_tier)
            doSendMagicEffect(toPosition, CONST_ME_POFF)
        end
 
        local rand_reward = math.random(100)
        if rand_reward > (object.loot_chance + 10) then
            doSendMagicEffect(toPosition, CONST_ME_HITAREA)
            return true
        end
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
     
        -- give loot     
        local multiple = 1
        local rand_multiple = math.random(15)
        if rand_multiple == 15 then
            multiple = math.random(2, 3)
        end
        for i = 1, multiple do
            local loot_table = object.normal_loot_table
            local rand_loot = math.random(100)
            if rand_loot < 6 then
                loot_table = object.rare_loot_table
            elseif rand_loot < 21 then
                loot_table = object.semi_rare_loot_table
            end
            local rand_item = math.random(#loot_table)
            rand_item = loot_table[rand_item]
            if rand_item.count == 1 then
                doPlayerAddItem(cid, rand_item.item_id, 1, true)
            else
                local new_count = math.random(rand_item.count)
                doPlayerAddItem(cid, rand_item.item_id, new_count, true)
            end
        end
 
    end
 
    return true
end
 
Post how you added it in your actions, and post if there are any errors in your console onuse and also which TFS version are you using.
 
How about actions.xml line? you should add it there.
XML:
<action itemid="2553" script="mining.lua" />
 
iam already using this one and its working in my ot 100%
all credits goes to @Infernum, just changed a line because it wasn't working when there is another detailing items on the same square as the vein or the stone.
Code:
local cfg = {
	chance = 4,            -- chance that the player will succeed in getting the ore
	skill = SKILL_FIST,      -- skill required to mine
	skillStr = ' FIST',      -- string for skill name | note: add a space before skill name
	stage2Regen = 60 * 1000, -- 3 seconds
	stage3Regen = 120 * 1000, -- 2 seconds
	ores = {
		{effect = CONST_ME_BLOCKHIT, ore = 5880, amount = {1, 3}, skillReq = 10, veins = {
				{id = 8636, lv = 75},
				{id = 8640, lv = 50}
			}
		}
	}
}

local function isInTable(value)
	for i = 1, #cfg.ores do
		for j = 1, #cfg.ores[i].veins do
			if cfg.ores[i].veins[j].id == value then
				return i, j -- Return ore row and vein index
			end
		end
	end
	return false
end

local regenerating = {}

local function regenVein(pos, id, row, index)
	local item = Tile(pos):getItemById(id)
	if not item then
		return false
	end
	local currVein = cfg.ores[row].veins
	local transformId = currVein[index].id
	item:transform(transformId)
	if currVein[index-1] and currVein[index-1].id then
		regenerating[pos] = addEvent(regenVein, cfg.stage3Regen, pos, transformId, row, index-1)
	end
end

exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) + 275))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
		if player:getCondition(CONDITION_EXHAUST_HEAL) then
			return player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
		end
	local row, vein = isInTable((Tile(toPosition):getTopVisibleThing()):getId())
	if (row and vein) then
		local playerPos = player:getPosition()
		local currOre = cfg.ores[row]
		local currVein = currOre.veins[vein]
		local skillLevel = player:getSkillLevel(cfg.skill)

		-- Check player skill level
		if not (skillLevel >= currOre.skillReq) then
			player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You must have '.. currOre.skillReq .. cfg.skillStr ..' before you may mine.')
			return true
		end
		 
		-- Check player level
		if not (player:getLevel() >= currVein.lv) then
			player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You must have '.. cfg.level ..' level before you may mine.')
			return true
		end

		-- If the vein is at the last stage, tell the player to wait
		if #currOre.veins == vein then
			player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You must wait for this vein to regen.')
			playerPos:sendMagicEffect(CONST_ME_POFF)
			return true
		end

		-- Stop current regeneration process (since the player hit the rock again)
		if regenerating[toPosition] then
			stopEvent(regenerating[toPosition])
		end

		-- If chance is correct, add the item to the player and start regeneration process
		if math.random(100) <= (cfg.chance) then
			local nextId = currOre.veins[vein+1].id
			local it = player:addItem(currOre.ore, math.random(currOre.amount[1], currOre.amount[2]))
			local count = it:getCount()
			local name = count > 1 and it:getPluralName() or it:getName()
			player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have mined '.. count .. ' '.. name)
			player:addSkillTries(cfg.skill, math.random(3000, 5000) / skillLevel)
	player:addCondition(exhaust)
			toPosition:sendMagicEffect(currOre.effect)
			regenerating[toPosition] = addEvent(regenVein, (vein == 2) and cfg.stage2Regen or cfg.stage3Regen, toPosition, nextId, row, vein)
			target:transform(nextId)
		else
			playerPos:sendMagicEffect(CONST_ME_POFF)
	player:addCondition(exhaust)
		end

	end
	return true
end
 
@M0ustafa can you tell me a tutorial for regeneration of the stones? i tried a old script and didn't work from another site, i don't know where i can find one here :p View attachment 43260
You can play with decayTo attribute within items.xml. Make used crystal to decay to the mineable stone every 15 min or 900 seconds for example. So when you mine the stone it will be turned back into an used crystal. The easiest way I can think of.
 
I made one for our server, but we never ended up finishing the server, so I'll just release it.
It's not like it's difficult to make anyway.

From memory.. the system basically works like this..

You have 'tiers' of rocks, and when you break them, they turn into the lesser tier of rock, until you finally hit the smallest rock, and you can't mine it anymore.

The system is meant to have an automatic timer along with it, which would make the rocks 'grow' at random intervals, until it became the highest tier rock.
This means that the longer you let the rocks grow, the better items you could potentially get out it.

So the player has to make a choice, mine it now, or wait for it to grow more, but risk other players mining the rock before you come back to see how much it's grown.

You can also script in 'random events', like a special dwarf spawning and running away with the rock, as an example.

If you need help making the globalevent to spawn and grow the rocks when the server starts, let me know.
(You could also just make it so the rocks can only be harvested once per server save.. without creating the 'grow' script, and just place all of the rocks manually, but that's up to you.)

Lua:
local config = {
    [3608] = {text = {"Please no!", "Go find another rock.\nI'm not giving out today.", "Why me?", "Please.. stop.", "Haven't you beaten me enough?", "Leave me alone to grow.", "I'm only a little little rock!", "Ow! That was my left ovary!", "Ouch! My.. My right testicle! You monster!", "Please.. I just need some time..", "I'll give you your materials, just please..\nDon't hit me anymore.", "I gave you the materials already!\nWhat more do you want from me!?", "Your hammer is bigger then mine, Okay? Okay!?", "Please stop hitting my wife.\nI think she's starting to like it.", "Hit me again. I dare you.", "Enough already!", "What do I have to do..\nto make you leave?", "Your mother is a rock loving whore.", "Would you hit your mother like that?", "Puny human. Give me the hammer..\nI'll show you how to beat off properly."}},
    [3609] = {break_chance = 50, loot_chance = 20, lower_tier = 3608, -- 100 = break every try | 1 = 1/100 chance to break
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [3616] = {break_chance = 55, loot_chance = 18, lower_tier = 3609,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [3607] = {break_chance = 60, loot_chance = 16, lower_tier = 3616,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [1356] = {break_chance = 65, loot_chance = 14, lower_tier = 3607,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [1285] = {break_chance = 70, loot_chance = 12, lower_tier = 1356,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [3615] = {break_chance = 75, loot_chance = 10, lower_tier = 1285,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    },
    [1357] = {break_chance = 80, loot_chance = 8, lower_tier = 3615,
        normal_loot_table = { -- 80%
            [1] = {item_id = 2148, count = 1}, -- count = MAX amount person receives of the item
            [2] = {item_id = 2148, count = 1}  -- randomises 1 to count.
        },
        semi_rare_loot_table = { -- 15%
            [1] = {item_id = 2152, count = 1},
            [2] = {item_id = 2152, count = 1}
        },
        rare_loot_table = { -- 5%
            [1] = {item_id = 2160, count = 1},
            [2] = {item_id = 2160, count = 1}
        }
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

    local object = config[itemEx.itemid]

    if object then

        if object.text then
            local rand_text = math.random(#object.text)
            doCreatureSay(cid, object.text[rand_text], TALKTYPE_ORANGE_1, nil, nil, toPosition)
            doSendMagicEffect(toPosition, CONST_ME_POFF)
            return true
        end

        -- random events
        local rand_event = math.random(200)
        if rand_event == 200 then
            --print("Random Special Event executed!")
            doSendMagicEffect(toPosition, 33)
            return true
        end
    
        -- rock break
        local rand_break = math.random(100)
        if rand_break <= object.break_chance then
            doTransformItem(itemEx.uid, object.lower_tier)
            doSendMagicEffect(toPosition, CONST_ME_POFF)
        end

        local rand_reward = math.random(100)
        if rand_reward > (object.loot_chance + 10) then
            doSendMagicEffect(toPosition, CONST_ME_HITAREA)
            return true
        end
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
    
        -- give loot    
        local multiple = 1
        local rand_multiple = math.random(15)
        if rand_multiple == 15 then
            multiple = math.random(2, 3)
        end
        for i = 1, multiple do
            local loot_table = object.normal_loot_table
            local rand_loot = math.random(100)
            if rand_loot < 6 then
                loot_table = object.rare_loot_table
            elseif rand_loot < 21 then
                loot_table = object.semi_rare_loot_table
            end
            local rand_item = math.random(#loot_table)
            rand_item = loot_table[rand_item]
            if rand_item.count == 1 then
                doPlayerAddItem(cid, rand_item.item_id, 1, true)
            else
                local new_count = math.random(rand_item.count)
                doPlayerAddItem(cid, rand_item.item_id, new_count, true)
            end
        end

    end

    return true
end

hi @Xikini, sorry to relive that. I saw your script and i want to take this in my project.

Could you help me make a global event to summon the stones in random positions? I would not like to leave them in fixed positions, as this would facilitate the use of bot to mining.

Many thanks!!
 
Back
Top