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

Lua Life drain spell

Shawno0

Member
Joined
Dec 12, 2009
Messages
101
Reaction score
8
I've been working on this spell for my custom vocation, i want it to deal damage based on skill + level but also to heal the caster for an amount equal to the damage delt, giving the appearance of draining life~ ^^ but so far the spell only hurts the caster.. any help would be very much appretiated :3

PHP:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat1, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat1, COMBAT_PARAM_AGGRESSIVE, 1)

function getCombatFormulas(cid, lv, skilllv)
	local formula_min = -((lv*0.75 + skilllv*1.75) * 2.8)
	local formula_max = -((lv*0.75 + skilllv*1.75) * 4.0)

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


setCombatCallback(combat1, CALLBACK_PARAM_LEVELMAGICVALUE, "getCombatFormulas")

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_BATS)
setCombatParam(combat2, COMBAT_PARAM_AGGRESSIVE, 0)

function getCombatFormulas(cid, lv, skilllv)
	local formula_min = -((lv*0.75 + skilllv*1.75) * 2.8)
	local formula_max = -((lv*0.75 + skilllv*1.75) * 4.0)

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

arr1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 3, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}

local area1 = createCombatArea(arr1)
setCombatArea(combat2, area1)
setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "getCombatFormulas")

local function onCastSpell1(parameters)
doCombat(parameters.cid, parameters.combat1, parameters.var)
end

local function onCastSpell2(parameters)
doCombat(parameters.cid, parameters.combat2, parameters.var)
end

function onCastSpell(cid, var)
local parameters = { cid = cid, var = var, combat1 = combat1, combat2 = combat2}
addEvent(onCastSpell1, 0, parameters)
addEvent(onCastSpell2, 100, parameters)
return TRUE
end
 
Back
Top