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

Spell Cooldown Effect (specific exhaust)

@up
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setHealingFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 1.5, 2)

function onCastSpell(cid, var)
	if exhaustion.check(cid, 23000) == false then
		if getCreatureStorage(cid, 23001) == -1 then
			exhaustion.set(cid,23000, 100)
		else
			exhaustion.set(cid,23000, 50)
		end
		return doCombat(cid, combat, var)
	else
		doPlayerSendCancel(cid, "Cooldown[" ..exhaustion.get(cid,23000).."]")
	end
end

hope I don't need to explain it, try to figure out the config.

don't worry i imagined something like that, thus i didn't knew that getCreatureStorage was a new function lol xD because i have tried this before but the engine didn't recognized me the getPlayer... thank you anyways
 
you may use getCreatureStorage or getPlayerStorageValue, the first is the newest but in compat.lua it supports either.
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setHealingFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 1.5, 0, 2, 0)

local exhaustion =
{
	check = function (cid, storage)
		if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION) == TRUE) then
			return false
		end

		return getPlayerStorageValue(cid, storage) >= os.time(t)
	end,

	get = function (cid, storage)
		if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION) == TRUE) then
			return false
		end

		local exhaust = getPlayerStorageValue(cid, storage)
		if(exhaust > 0) then
			local left = exhaust - os.time(t)
			if(left >= 0) then
				return left
			end
		end

		return false
	end,

	set = function (cid, storage, time)
		setPlayerStorageValue(cid, storage, os.time(t) + time)
	end,

	make = function (cid, storage, time)
		local exhaust = exhaustion.get(cid, storage)
		if(not exhaust) then
			exhaustion.set(cid, storage, time)
			return true
		end

		return false
	end
}

function onCastSpell(cid, var)
	return not exhaustion.check(cid, 23000) and exhaustion.set(cid, 23000, getPlayerStorageValue(cid, 23001) < 0 and 100 or 50) and doCombat(cid, combat, var) or doPlayerSendCancel(cid, "Cooldown[" ..exhaustion.get(cid,23000).."]")
end

It's a great job very nice but i have some problems with this, when i spam them it continue casting but the cooldown still down.. :S
 
cooldown rox you get also exhaust if gm/god
well that happened to me :p and finnaly a exhaust function that works inside a spell script or actions
 
This not work for me , TSF 0.3.6 , no errors in console but i can use spell free all time !

Maybe i bad edited spell ? How add to agresive spell line rage of skies ?
 
This is an action script. What is wrong with it? The exhaust does not work at all. I can spam it as much as I want:

Lua:
function onUse(cid, item, frompos, item2, topos) 
local hp = math.random(150,250)
local mp = math.random(150,250)
	if(exhaustion.check(cid, 23000) == false) or getPlayerGroupId(cid) < 3 then
		if doPlayerRemoveItem(cid, item.itemid, 1) == TRUE then
			exhaustion.set(cid, 23000, 100)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
			doCreatureAddHealth(cid, hp)
			doPlayerAddMana(cid, mp)
			doSendAnimatedText(getCreaturePosition(cid), "Herbal H" , 192)
		else
			doPlayerSendCancel(cid, "Sorry, not possible!")
		end
	else
		doPlayerSendCancel(cid, "Cooldown[" ..exhaustion.get(cid, 23000).."]")
	end
	return TRUE
end
 
Ahahaha, thank you! So typical to do such mistakes. x)
 
cooldown sux if you die with the cooldown exhaust you have the exhaust forever unless you put manualy the storage away!

mine cooldown script used in 0.3.5pl the exhaust won't go away after death if you died while exhaust of the cooldown

PHP:
local function cooldown()
setPlayerStorageValue(cid, 58362, -1)
end

addEvent(cooldown, 1500)
setPlayerStorageValue(cid, 58362, 1)
else
doPlayerSendCancel(cid, "You are exhausted.")
end
 
Last edited:
@up I dont understand you but this isnt a thread to post your scripts.
 
well that is mine cooldown script wich DOES work on tfs 0.3.5 for action scripts etc
but the problem is if you have the cooldown and you die or log it won't go away
 
mine works with any script, action, creature etc. He simply had the wrong operator.
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setHealingFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 1.5, 0, 2, 0)

local exhaustion =
{
	check = function (cid, storage)
		if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION) == TRUE) then
			return false
		end

		return getPlayerStorageValue(cid, storage) >= os.time(t)
	end,

	get = function (cid, storage)
		if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION) == TRUE) then
			return false
		end

		local exhaust = getPlayerStorageValue(cid, storage)
		if(exhaust > 0) then
			local left = exhaust - os.time(t)
			if(left >= 0) then
				return left
			end
		end

		return false
	end,

	set = function (cid, storage, time)
		setPlayerStorageValue(cid, storage, os.time(t) + time)
	end,

	make = function (cid, storage, time)
		local exhaust = exhaustion.get(cid, storage)
		if(not exhaust) then
			exhaustion.set(cid, storage, time)
			return true
		end

		return false
	end
}

function onCastSpell(cid, var)
	return not exhaustion.check(cid, 23000) and exhaustion.set(cid, 23000, getPlayerStorageValue(cid, 23001) < 0 and 100 or 50) and doCombat(cid, combat, var) or doPlayerSendCancel(cid, "Cooldown[" ..exhaustion.get(cid,23000).."]")
end

Best answer, yet to add further explanation, yet not required.
Self explanatory, rep++
 
Ok ive seen this requested enough so here you go. This is just an example using the spell "Light healing" so take from this and apply to all your spells.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setHealingFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 1.5, 2)

function onCastSpell(cid, var)
        if exhaustion.check(cid, 23000) == false then
                exhaustion.set(cid, 23000, 100)
                return doCombat(cid, combat, var)
        else
                doPlayerSendCancel(cid, "Cooldown[" ..exhaustion.get(cid, 23000).."]")
        end
end

You need to change 23000 to another storage value for each spell, each spell needs a different value. 100 is the time of cooldown. Thats all you need to know basically.


Hello,

Spell one ( exhaustion 8 sec )
Spell two ( exhaustion 1 minute )
Spell three ( no exhaustion )

There is no problem casting spell three since it doesn't make use of your script. It has no cooldown so i can use it without any waiting time.
But if i use spell one then it says ( cool-down 8 sec ) <-- that's alright yes? It's the point of the script. But when i use spell two right after that
then spell two shares the cool-down with one. Do you know what the problem is? I want them both to be "individual" spells.

Example: If spell one is on cool-down for 8 seconds then i could still use spell two. They both have their own cool-down. Is this hard to remake, or did i do something wrong?

It would really appreciate your help!

Thanks in advance,

Ch@os,
 
Back
Top