• 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 [TFS 0.2] How can I call a local value for this?

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
Hey guys straight to the point, on all my manarunes I have the simple effect that it shows an animated text of the value it heals, this is the script:

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onCastSpell(cid, var)
    	local mana = math.random(8000, 11000)
    	doPlayerAddMana(cid, mana)
	doSendAnimatedText(getPlayerPosition(cid), '+' .. mana, TEXTCOLOR_YELLOW)
	return doCombat(cid, combat, var)
end

However, its easy because the local value is already set to 8k~11k, but I wanted to make for example the spell "Exura" to show the value too, but with a value based on lvl/maglvl, not a set one, this is the script of Exura:

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_DISPEL, CONDITION_PARALYZE)
[B]setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0.08, 0, 0.33, 0)[/B]

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

So my question is, how can I call this:
Code:
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0.08, 0, 0.33, 0)

A "local" value so the animated text shows it when I heal? Ive tried some stuff but none works, Im sure a lot of ppl here knows better than me.

Im using TFS 0.2.

Thanks in advance.
~Guitar Freak
 
You could make a callback which returns a number. Here's an example of Light Healing spell using formula callback:
PHP:
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_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid, level, maglevel)
	local min = ((level/5)+(maglevel*1.5))
	local max = ((level/5)+(maglevel*2))
	return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

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

I'm not sure how to make it return the exact value.
 
You could make a callback which returns a number. Here's an example of Light Healing spell using formula callback:
PHP:
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_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid, level, maglevel)
	local min = ((level/5)+(maglevel*1.5))
	local max = ((level/5)+(maglevel*2))
	return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

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

I'm not sure how to make it return the exact value.

Yeh I already tried that one when I was testing with exura san which is like that but Im not quite sure either on how to use it to return the value or to call it a "local" or something..

Thanks anyways :)

Anyone knows about this?
 
By using custom formula, you will only be able to define the min/max values right?

Then... If you'd make your own math.random and display it, it would differ from the real healing, hmm... Then how about you DECIDE the random value for it?
PHP:
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_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid, level, maglevel)
    local min = ((level/5)+(maglevel*1.5))
    local max = ((level/5)+(maglevel*2))

    local val = math.random(min, max)
    --// send effect crap here with 'val' as healing damage :)
    return val, val
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

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

Now as you can see, we decided the random value inside of the function and lured it a bit to send it 2 equal values, meaning the values won't be changed :)

Imagination is the source to success.
 
By using custom formula, you will only be able to define the min/max values right?

Then... If you'd make your own math.random and display it, it would differ from the real healing, hmm... Then how about you DECIDE the random value for it?
PHP:
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_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid, level, maglevel)
    local min = ((level/5)+(maglevel*1.5))
    local max = ((level/5)+(maglevel*2))

    local val = math.random(min, max)
    --// send effect crap here with 'val' as healing damage :)
    return val, val
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

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

Now as you can see, we decided the random value inside of the function and lured it a bit to send it 2 equal values, meaning the values won't be changed :)

Imagination is the source to success.

People werent wrong about you dude.

I know this wasnt too hard for you, but I do believe you really are the best on this, thanks a LOT.
++Rep

Btw how come your site OTLua from your signature isnt working? :(
 
Back
Top