• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Advanced Mana Rune - TFS 0.3.6+

Shinmaru

エロルアー Scripter!
Joined
Aug 20, 2007
Messages
1,988
Reaction score
88
Location
Puerto Rico
well, here I made a script that has been made MANY times, but mine's "balanced" and will take some hp in order to use the rune, post bugs and it is only for TFS 0.3.6 to TFS 0.4:

LUA:
--CONFIGURATION//--	
local cfg = {
	lvl = 12, -- Level required to use the rune.
	ml = 8, -- Magic Level required to use rune.
	count = false, -- if 'false' it will heal 6 times, if 'true' it heals according to your level. << Look at count table.
	charge = true, -- if 'true' it will remove one charge from the rune untill none are left, if 'false' it becomes infinite to use.
	loss = 0.15, -- Add only in decimals 1 = All your health points = death.
	manaDivMn = 8, -- Formula min
	manaDivMx = 6, -- Formula max
	regenTicks = 5 -- How many times it heals per second. Note: default is 5 seconds.
}
--//CONFIGURATION--	
function manaRegen(cid, cnt, value)
	if cnt > 0 then
		doCreatureAddMana(cid, value)
		doSendMagicEffect(getCreaturePosition(cid), 12)
		cnt = cnt - 1
		v1 = math.floor((getPlayerLevel(cid)/cfg.manaDivMn)*(getPlayerMagLevel(cid)/cfg.manaDivMn))
		v2 = math.floor((getPlayerLevel(cid)/cfg.manaDivMx)*(getPlayerMagLevel(cid)/cfg.manaDivMx))
		value = math.random(v1, v2)
		addEvent(manaRegen, cfg.regenTicks*1000, cid, cnt, value)
	else 
		return true
	end
end	
local count = {
	[{1, 50}] = (2),
	[{51, 100}] = (4),
	[{101, 150}] = (6),
	[{151, 200}] = (8),
	[{201, 250}] = (10),
	[{251, 300}] = (12)
	}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v1 = math.floor((getPlayerLevel(cid)/cfg.manaDivMn)*(getPlayerMagLevel(cid)/cfg.manaDivMn))
local v2 = math.floor((getPlayerLevel(cid)/cfg.manaDivMx)*(getPlayerMagLevel(cid)/cfg.manaDivMx))
local value = math.random(v1, v2)
local toLose = math.ceil(getCreatureMaxHealth(cid)*cfg.loss)
	if getPlayerLevel(cid) >= cfg.lvl and getPlayerMagLevel(cid) >= cfg.ml and getCreatureHealth(cid) > toLose then
		doCreatureAddHealth(cid, -toLose)
		if cfg.count then	
			for v, c in pairs(count) do
				if getPlayerLevel(cid) >= v[1] and getPlayerLevel(cid) <= v[2] then
					local cnt = c
					manaRegen(cid, cnt, value)
				break
				else
					local cnt = 14
					manaRegen(cid, cnt, value)
				end
			end	
		else
			local cnt = 6
			manaRegen(cid, cnt, value)
		end
		if cfg.charge then
			if item.type > 1 then
				doChangeTypeItem(item.uid, item.type - 1)
			else
				doRemoveItem(item.uid)
			end	
		end	
	else	
		doPlayerSendCancel(cid, (getCreatureHealth(cid) > toLose and "You require "..(getPlayerLevel(cid) < cfg.lvl and "level "..cfg.lvl or "").. (getPlayerLevel(cid) < cfg.lvl and getPlayerMagLevel(cid) < cfg.ml and " and " or "").. (getPlayerMagLevel(cid) < cfg.ml and "magic level "..cfg.ml or "").. (getCreatureHealth(cid) < toLose and "." or " to use manarune.") or "You lack health to use manarune.")) 
	end		
return true
end
Fixed and running perfect!
More configurations and a slightly better formula.
 
Last edited:
Back
Top