• 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 Get target from a Healing rune cast

tklucas

New Member
Joined
Jul 20, 2009
Messages
30
Reaction score
0
Well, i'm currently implementing a sound extension for my server and i just can't get the right target of a healing rune cast.

That should work right?

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setHealingFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 5, 6)

function onCastSpell(cid, var)
	if doCombat(cid, combat, var) then
		local f = variantToNumber(var)

		if f ~= 0 then
			local obj = SoundData:new(HEAL_CH, nil, nil, 1000, 900, false, nil)
			obj:sendToSpectators(getCreaturePosition(f))
		end

	end
end

But, i just the get the right position of the target when i choose they by battlelist. If i heal my self i also don't get my own pos.
Don't mind about my custom code, he works fine. I just can't understand why i can't get the target properly.

PS: I've made a quickly search on the sources and didn't find nothing.
 
I've just get a tip (getThingFromPos) from a friend. Short solution:

in constants lua:
Code:
VARIANT_NONE = 0
VARIANT_NUMBER = 1
VARIANT_POSITION = 2
VARIANT_TARGETPOSITION = 3
VARIANT_STRING = 4

in functions lua:
Code:
function variantToTarget(var)
	if var.type == VARIANT_NUMBER then return variantToNumber(var)
	elseif	var.type == VARIANT_POSITION then return getThingFromPos(var.pos).uid
	else return 0
	end
end

then you use in any script:
Code:
local f = variantToTarget(var)

I hope it helps more ppl also.
 
Last edited:
Back
Top