underewar
Banned User
Its a basic onEquip Change storage script.
If you have a magic sword your storage value will be 1 and you can use a single spell.
If value below 1 you cant use that single spell.
data/scripts/movement/xml
data/scripts/movement/yourscript.lua
data/spells/script/yourscript.lua
If you have a magic sword your storage value will be 1 and you can use a single spell.
If value below 1 you cant use that single spell.
data/scripts/movement/xml
XML:
<movevent event="DeEquip" itemid="2400" slot="hand" function="onDeEquipItem" scripts = "yourscript.lua">
<movevent event="Equip" itemid="2400" slot="hand" function="onEquipItem" script="yourscript.lua"/>
data/scripts/movement/yourscript.lua
LUA:
local stor = 12345 -- storage
function onEquip(cid, item, slot)
setPlayerStorageValue(cid, stor, 1) -- já que é no callback de equipar, ele recebe o valor de ID 1 (como sendo positivo para a checagem do uso da spell)
player:sendTextMessage(MESSAGE_INFO_DESCR, "onEquip.")
return true
end
function onDeEquip(cid, item, slot)
setPlayerStorageValue(cid, stor, -1) -- ao remover o item, ele recebe o valor de ID -1 (como sendo negativo para a checagem do uso da spell)
player:sendTextMessage(MESSAGE_INFO_DESCR, "onDeEquip.")
return true
end
data/spells/script/yourscript.lua
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
function onGetFormulaValues(player, skill, attack, factor)
local min = (player:getLevel() / 5) + (skill * attack * 0.02) + 4
local max = (player:getLevel() / 5) + (skill * attack * 0.04) + 9
return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(player, variant)
if player:getStorageValue(12345) < 1 then
player:sendCancelMessage("You can't cast the spell without using the item that allows it.")
return false
end
return combat:execute(player, variant)
end