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

Solved Spells: Health regen scaling with level?

  • Thread starter Thread starter Icy
  • Start date Start date
I

Icy

Guest
This is my current spell, it heals for 10hp every 500ms (half second) and was wondering if there was any way to make the 10hp scale based on level using a callback of some sort.

Holy Regeneration.lua:
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_REGENERATION)
setConditionParam(condition, CONDITION_PARAM_SUBID, 1)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 25 * 1000)
setConditionParam(condition, CONDITION_PARAM_HEALTHGAIN, 10)
setConditionParam(condition, CONDITION_PARAM_HEALTHTICKS, 500)
setCombatCondition(combat, condition)

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

Thanks in advance!
 
As this is based on CONDITION_PARAM_HEALTHGAIN I think you have to create a combat for each 10 levels by looping and inserting them into a table and then check which level the player has and apply the correct combat obj based on that.
 
As this is based on CONDITION_PARAM_HEALTHGAIN I think you have to create a combat for each 10 levels by looping and inserting them into a table and then check which level the player has and apply the correct combat obj based on that.

So I'm assuming there's no way to do it properly?
 
LUA:
local function Heal(cid, amount, left)
doCreatureAddHealth(cid, amount);
if (left > 0)
addEvent(Heal,500,cid,amount,left-1)
end
end

function onCastSpell(cid, var)
Heal(cid, getPlayerLevel(cid)*10+100, 10);
return true
end
Do some effect or whatever the same way.
 
LUA:
local function Heal(cid, amount, left)
doCreatureAddHealth(cid, amount);
if (left > 0)
addEvent(Heal,500,cid,amount,left-1)
end
end

function onCastSpell(cid, var)
Heal(cid, getPlayerLevel(cid)*10+100, 10);
return true
end
Do some effect or whatever the same way.

On top of that, make sure to call isPlayer to check if player is still in-game to avoid error messages in the server console about player being not found.
 
On top of that, make sure to call isPlayer to check if player is still in-game to avoid error messages in the server console about player being not found.

Ah, that's true.

LUA:
local function Heal(cid, amount, left)
if (!isPlayer(cid)) return; end
doCreatureAddHealth(cid, amount);
if (left > 0)
addEvent(Heal,500,cid,amount,left-1)
end
end

function onCastSpell(cid, var)
Heal(cid, getPlayerLevel(cid)*10+100, 10);
return true
end
 
So I'm assuming there's no way to do it properly?

Not by using the condition on the combat obj, but recursive function calls like TGYoshi did it.

You should remove:
setConditionParam(condition, CONDITION_PARAM_HEALTHGAIN, 10)
setConditionParam(condition, CONDITION_PARAM_HEALTHTICKS, 500)

but nevertheless apply the combat to the player so he has the buff icon. :)
 
Back
Top