Zombiegod
Active Member
- Joined
- Oct 22, 2009
- Messages
- 198
- Solutions
- 1
- Reaction score
- 25
So i have this super old manarune script that i like, however i get errors with the animated text, but if i remove it the script crashes the server.
Lua:
-- >>CONFIG<< --
local MIN_MANA_GAIN = 500 -- How much is the lowest mana you can possibly gain (If your heal less than that amount of mana you will get that mana instead) ?
local MIN_MANA_RAND = 1500 -- The minimum amount of mana to be given (random)
local MAX_MANA_RAND = 3000 -- The maximum amount of mana to be given (random)
local ACCEPT_LUCK = true -- Should it be possible to get lucky and receive extra mana? true, false
local MAG_LEVEL_MULTI = 2 -- How many times should Magic Level be multiplied, to be added to the mana formula? 1 = same, 0 = nothing etc
local LEVEL_MULTI = 2 -- How many times should Level be multiplied, to be added to the mana formula? 1 = same, 0 = nothing etc
local MAGIC_EFFECT = CONST_ME_MAGIC_BLUE -- Magic effect that will be casted on the player each time it heals the mana.
local ANIMATION_COLOR = 41 -- What animation color will there be when you heal (Comes over player showing how much mana you healed) 1 - 255 (?)
local HEAL_TIMES = 3 -- How many times should you be healed when using the manarune once? Atleast 1
local FIRST_HEAL_DELAY = 0 -- How long time will it take before it heals FIRST time? In milliseconds
local HEAL_DELAY = 1000 -- How long time will it take before it heals one? In milliseconds
-- >>CONFIG<< --
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, HEAL_TIMES * HEAL_DELAY + FIRST_HEAL_DELAY)
function onCastSpell(cid, var)
doTargetCombatCondition(0, cid, exhaust, CONST_ME_NONE)
local function doHealMana(parameters)
local random = math.random(MIN_MANA_RAND, MAX_MANA_RAND)
if ACCEPT_LUCK == true then
local luck = math.random(1, 100)
if luck >= 90 then
random = random * 2
elseif luck == 50 then
random = random * 3
end
end
local formula = (getPlayerLevel(cid) * LEVEL_MULTI) + (getPlayerMagLevel(cid) * MAG_LEVEL_MULTI) + random
local manaGain = math.max(MIN_MANA_GAIN, formula)
doPlayerAddMana(cid, manaGain)
doSendAnimatedText(getPlayerPosition(cid), manaGain, ANIMATION_COLOR)
doSendMagicEffect(getPlayerPosition(cid), MAGIC_EFFECT)
doCombat(parameters.cid, parameters.combat, parameters.var)
end
local times = HEAL_TIMES
local parameters = {cid = cid, combat = combat, var = var}
while times > 0 do
if times == HEAL_TIMES then
addEvent(doHealMana, FIRST_HEAL_DELAY, parameters)
else
addEvent(doHealMana, HEAL_DELAY * times, parameters)
end
times = times - 1
end
end