local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)
local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)
function onGetFormulaValues(cid, level, skill, attack, factor)
local skillTotal, levelTotal = skill + attack, level / 5
return -(skillTotal * 0.5 + levelTotal), -(skillTotal * 1.5 + levelTotal)
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
-- add line with definition of storageID to keep exhaust, OTHER for every spell
-- if you add same ID in 2 spells that will block each other
-- (can be useful to block some spell combinations!)
local spellStorageID = 65300
-- maximum value was [in 0.3.6] '65515',
-- so you can use 65300 - 65515 [lower values can be used by other scripts/quests]
function onCastSpell(cid, var)
-- under 'onCastSpell(cid, var)' add these 4 lines --
if(exhaustion.check(cid, spellStorageID)) then -- is exhausted
doPlayerSendCancel(cid, "You can use one spell only once per 5 seconds.")
return false -- return false makes it does not remove player mana/rune
end
-- end --
-- replace 'return doCombat(cid, combat, var)' with:
return doCombat(cid, combat, var) and (exhaustion.set(cid, spellStorageID, 5) or true)
-- we add here ' and (exhaustion.set(cid, spellStorageID, 5) or true)',
-- because we want it add 5 seconds exhaust ONLY if player can execute spell
-- ex. if target is behind wall 'doCombat' will 'return false'
-- and at end is 'or true' because we must make it return 'true' to make spell remove mana/rune
end