• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

critical hit

foxkbt

Member
Joined
Sep 29, 2009
Messages
290
Reaction score
7
Location
Salvador
i have a idea
but i dnt know if its possible!
i think in creat a spell...

make add some percent with a chance to do critical hit

ex: in confing.lua
criticalHitChance = 10

when use the spell change to
criticalHitChance = 20

thx for advanced
 
Ofc, create 2 combats in the spell (combata & combatb)

then inside the onCast function make it a random chance that combatb(with crit dmg) is cast.

So like this:
-- normal exori mort
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end

would be this:
-- crit chance exori mort
LUA:
local combata = createCombatObject()
setCombatParam(combata, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combata, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combata, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combata, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)

local combatb = createCombatObject()
setCombatParam(combatb, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combatb, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combatb, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combatb, COMBAT_FORMULA_LEVELMAGIC, -2, -20, -2, -30, 9, 9, 1.4, 2.1)

function onCast(cid, var)
if math.random(1,100) <= 20 then -- 20% 
doCombat(cid, combatb, var)
else
doCombat(cid, combata, var)
end
return true
end

I guess the config part could be done like this: (untested and complicated)

LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

local FormulaType = CALLBACK_PARAM_SKILLVALUE

function getCombatFormulas(cid, lv, maglv)
local formula_min = ((lv*0.5 + maglv*0.6) * 1.0)
local formula_max = ((lv*0.5 + maglv*0.6) * 1.2)

if(formula_max < formula_min) then
local tmp = formula_max
formula_max = formula_min
formula_min = tmp
end
return formula_min, formula_max
end

if getConfigValue(SpellCrit) == yes then
if math.random(1,100) <= getConfigValue(SpellCritChance) then -- 20%
setCombatCallback(combat, FormulaType, "getCombatFormulas"*getConfigValue(SpellCritPercent))
else 
setCombatCallback(combat, FormulaType, "getCombatFormulas")
end
else
setCombatCallback(combat, FormulaType, "getCombatFormulas")
end

function onCast(cid, var)
return doCombat(cid, combat, var)
end

using these lines in config.lua

LUA:
SpellCrit = yes -- yes/no
SpellCritChance = 20 -- 20%
SpellCritPercent = 2 -- 2x normal dmg

You would still have to remake every spell thou.
 
Last edited:
Do you want a spell which increases the critical chance? If yes you will have to edit your sources. If you want a spell with critical use the post @up
 
Back
Top