-- Creation of Combat objects and setting the damage type as physical for combat1
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
-- Function to determine formula values for combat1
function onGetFormulaValues1(cid, level, maglevel)
local player = Player(cid)
local skill = player:getSkillLevel(3) --This skill number 3 is for Axe. 0 is for Fist, 1 for Club, 2 for Sword, 3 for Axe, 4 for Distance, 5 for Shield, 6 for SKILL_FISHING, and 7 for Magic Level (ml).
level = player:getLevel()
local min = -((skill * 15) + level * 6) --This is based on the level. You can adjust the numbers to make the damage stronger or weaker, etc. If it's too much damage, just decrease the numbers,
local max = -((skill * 21) + level * 6)
return min, max
end
-- Set the callback function to get formula values for combat1
combat1:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues1")
-- Creation of Combat objects with effect 173 and setting the damage type as physical for combat2
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_EFFECT, 173) --in this case, the effect with ID 173 is being set.
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
-- Function to determine formula values for combat2
function onGetFormulaValues2(cid, level, maglevel)
local player = Player(cid)
local skill = player:getSkillLevel(3)
level = player:getLevel()
local min = -((skill * 39) + level * 9)
local max = -((skill * 42) + level * 9)
return min, max
end
-- Set the callback function to get formula values for combat2
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")
-- Creation of Combat objects with effect 173 and setting the damage type as physical for combat3
local combat3 = Combat()
combat3:setParameter(COMBAT_PARAM_EFFECT, 173) --in this case, the effect with ID 173 is being set.
combat3:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
-- Function to determine formula values for combat3
function onGetFormulaValues3(cid, level, maglevel)
local player = Player(cid)
local skill = player:getSkillLevel(3)
level = player:getLevel()
local min = -((skill * 48) + level * 11)
local max = -((skill * 55) + level * 15)
return min, max
end
-- Set the callback function to get formula values for combat3
combat3:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues3")
-- Function called when the player uses the weapon
function onUseWeapon(cid, var)
local player = Player(cid)
local critical = math.random(1, 100) --This is the percentage that triggers the critical hit. You can increase or decrease it to make it happen more quickly or take longer, depending on your preference.
local life = 10 * player:getMaxHealth() / 100 --This is the one that will give life according to the critical, gaining random life.
local position = player:getPosition()
-- If the attack is critical, send animated text "Critical!" and execute combat2
if critical > 90 then
--Game.sendAnimatedText("Critical!", position, 215) --If you want an animated text in white or your preferred colors, simply uncomment it. If you don't want it, leave it commented, okay?
player:addHealth(life)
combat2:execute(cid, var)
-- If the attack is critical (less than 10%), send animated text "Critical!" and execute combat3
elseif critical < 10 then
--Game.sendAnimatedText("Critical!", position, 215) --If you want an animated text in white or your preferred colors, simply uncomment it. If you don't want it, leave it commented, okay?
player:addHealth(life)
combat3:execute(cid, var)
-- Otherwise, execute combat1
else
combat1:execute(cid, var)
end
end