• 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!

Critical Chance on Magic [REP++]

Synthetic_

deathzot.net
Joined
Dec 30, 2008
Messages
2,535
Reaction score
574
Well I was wondering if anyone could make the code so that spells also have a chance to crit sometimes, thanks.
 
Well I'm notsure if everyones out there to have a real tibia like OTServ, because I am certainly not... Can anyone help me?
 
Im using this in a shitty way, but working one xP
My example attack spell:
Lua:
local damage = { min = 1.25, max = 1.7, mul = getConfigInfo('criticalHitMultiplier') }

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, - damage.min, -30, - damage.max, 0)

local criticalCombat = createCombatObject()
setCombatParam(criticalCombat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(criticalCombat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(criticalCombat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(criticalCombat, COMBAT_FORMULA_LEVELMAGIC, - damage.min * damage.mul, -30, - damage.max * damage.mul, 0)

function onCastSpell(cid, var)
	if isCriticalHit() == TRUE then
		if getConfigInfo('displayCriticalHitNotify') == "yes" then
			doSendAnimatedText(getPlayerPosition(cid), "CRITICAL!", TEXTCOLOR_SPELL_OFFENSIVE_CRITICAL)
		end
		return doCombat(cid, criticalCombat, var)
	else
		return doCombat(cid, combat, var)
	end
end

isCriticalHit():
Lua:
function isCriticalHit()
	return (getConfigInfo("criticalHitChance") >= math.random(1, 100)) and TRUE or FALSE
end

Also, textcolor:
Lua:
TEXTCOLOR_SPELL_OFFENSIVE_CRITICAL = 81
 
Back
Top