Oneda
Aspiring Spriter
Hey guys, I just modified a berserk spell so it can only be cast if you have a Winged Helmet or a Warrior Helmet in your CONST_SLOT_HEAD.
Have in mind, this is just a base spell so you can check out how to limit spells to be used only if you have X item equipped on X slottype.
Have in mind, this is just a base spell so you can check out how to limit spells to be used only if you have X item equipped on X slottype.
Lua:
local combat = Combat()
local equip = {2475, 2474} -- Items which will allow the player to cast the spell
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SQUARE1X1))
function onGetFormulaValues(player, skill, attack, factor)
local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(creature, variant)
if isInArray(equip, getPlayerSlotItem(creature, CONST_SLOT_HEAD).itemid) then -- This line is checking if the equipped helmet ID is on the table ontop of the script. [Change: CONST_SLOT_HEAD for other slottypes.]
return combat:execute(creature, variant) -- If the SLOT_TYPE item which is equipped is listed at the table above, the spell will be cast.
else creature:sendTextMessage(MESSAGE_STATUS_WARNING, "You need some kind of equipment to be able to cast this spell.") -- Otherwise it will give an error.
end
end