Hello! I've had some issues with merging the neccessity of a certain weapon ID on yourself whilst also setting a storage that sets a cooldown for a spell.
For example , I have this spell:
And i'd love to add this part, not sure how tho:
I've managed to create a spell that has few events and it's working, but this problem solution is a mystery for me - hope some good souls could give me a lesson on that?
(the spell that i've managed to create in case someone wants to use that system in the future and can't figure out how)
Have a nice day dear reader!
For example , I have this spell:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 34)
function onGetFormulaValues(player, skill, attack, factor)
local distanceSkill = player:getEffectiveSkillLevel(SKILL_DEXTERITY)
local min = (player:getLevel() / 5) + distanceSkill * 0.7
local max = (player:getLevel() / 5) + distanceSkill + 5
return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(creature, variant)
return combat:execute(creature, variant)
end
function onCastSpell(creature, var)
local weapons = {26649, 26657, 26661, 26665, 26669, 26673, 26677}
local slotWeapon = CONST_SLOT_LEFT
local playerWeapon = creature:getSlotItem(slotWeapon)
if playerWeapon and table.contains(weapons, playerWeapon:getId()) then
return combat:execute(creature, var)
end
creature:sendTextMessage(MESSAGE_STATUS_SMALL, "You need at least a tier 2 bow type weapon in your left hand to use that technique.")
return false
end
Lua:
local player = Player(creature)
if player:getStorageValue(55555) >= os.time() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are exhausted")
return false
end
player:setStorageValue(55555, os.time() + 2) -- last number "2" is the cooldown in seconds
return combat:execute(creature, variant)
end
I've managed to create a spell that has few events and it's working, but this problem solution is a mystery for me - hope some good souls could give me a lesson on that?
(the spell that i've managed to create in case someone wants to use that system in the future and can't figure out how)
Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BOLT)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_DRAWBLOOD)
setCombatParam(combat1, COMBAT_PARAM_USECHARGES, true)
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BOLT)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_DRAWBLOOD)
setCombatParam(combat2, COMBAT_PARAM_USECHARGES, true)
local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BOLT)
setCombatParam(combat3, COMBAT_PARAM_EFFECT, CONST_ME_DRAWBLOOD)
setCombatParam(combat3, COMBAT_PARAM_USECHARGES, true)
local area1 = createCombatArea(AREA_BEAM1)
local area2 = createCombatArea(AREA_BEAM1)
local area3 = createCombatArea(AREA_BEAM1)
setCombatArea(combat1, area1)
setCombatArea(combat2, area2)
setCombatArea(combat3, area3)
function onGetFormulaValues1(player, skill, attack, factor)
local attackTotal = (attack/2)
local min = (player:getLevel() / 2) + (skill * attackTotal * 0.02) + 2
local max = (player:getLevel() / 2) + (skill * attackTotal * 0.025) + 5
return -min, -max
end
function onGetFormulaValues2(player, skill, attack, factor)
local attackTotal = (attack/2)
local min = (player:getLevel() / 2) + (skill * attackTotal * 0.02) + 2
local max = (player:getLevel() / 2) + (skill * attackTotal * 0.025) + 5
return -min, -max
end
function onGetFormulaValues3(player, skill, attack, factor)
local attackTotal = (attack/2)
local min = (player:getLevel() / 2) + (skill * attackTotal * 0.02) + 2
local max = (player:getLevel() / 2) + (skill * attackTotal * 0.025) + 5
return -min, -max
end
setCombatCallback(combat1, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues1")
setCombatCallback(combat2, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues2")
setCombatCallback(combat3, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues3")
function onCastSpell(creature, variant)
local weapons = {26662, 26666, 26670, 26674, 26678}
local slotWeapon = CONST_SLOT_LEFT
local playerWeapon = creature:getSlotItem(slotWeapon)
if playerWeapon and table.contains(weapons, playerWeapon:getId()) then
addEvent(doCombat, 0, creature:getId(), combat1, variant)
addEvent(doCombat, 170, creature:getId(), combat2, variant)
addEvent(doCombat, 340, creature:getId(), combat3, variant)
return true
else
creature:sendTextMessage(MESSAGE_STATUS_SMALL, "You need at least a tier 3 crossbow type weapon in your left hand to use that technique.")
return false
end
end
Have a nice day dear reader!