Aeronx
Intermediate OT User
- Joined
- Dec 17, 2015
- Messages
- 746
- Solutions
- 9
- Reaction score
- 125
Hello everyone! I've been trying this custom spell.
It works fine! BUT, i want it to ONLY addskilltries if the spell damaged any player/creature, but dunno how to do it.
Also, is it possible to dissable the autoattack when you have a target?
Thank you all guys!
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)
function onGetFormulaValues(player, skill, attack, factor)
if player:getSlotItem(CONST_SLOT_LEFT) == nil then
return false
end
local item = player:getSlotItem(CONST_SLOT_LEFT)
local weapon = item:getType():getWeaponType()
local level = player:getLevel()
local hit = ((2 * (attack * (skill + 5.8) / 25 + (level - 1) / 10)) / factor)
if weapon == 1 then
local sword = math.ceil(player:getVocation():getRequiredSkillTries(SKILL_SWORD, player:getSkillLevel(SKILL_SWORD) + 1) / configManager.getNumber(configKeys.RATE_SKILL))
player:addSkillTries(SKILL_SWORD, sword)
elseif weapon == 2 then
local club = math.ceil(player:getVocation():getRequiredSkillTries(SKILL_CLUB, player:getSkillLevel(SKILL_CLUB) + 1) / configManager.getNumber(configKeys.RATE_SKILL))
player:addSkillTries(SKILL_CLUB, club)
elseif weapon == 3 then
local axe = math.ceil(player:getVocation():getRequiredSkillTries(SKILL_AXE, player:getSkillLevel(SKILL_AXE) + 1) / configManager.getNumber(configKeys.RATE_SKILL))
player:addSkillTries(SKILL_AXE, axe)
end
return -(0), -(hit)
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(creature, var)
return combat:execute(creature, var)
end
It works fine! BUT, i want it to ONLY addskilltries if the spell damaged any player/creature, but dunno how to do it.
Also, is it possible to dissable the autoattack when you have a target?
Thank you all guys!