ssiwyy158
Member
- Joined
- Jan 24, 2011
- Messages
- 128
- Solutions
- 2
- Reaction score
- 13
Hello ! How to change the code to make it work on a principle great spirit potion ?
The code adds the same hp and mana. How change it to make it act like spirit potion?and it depended on lvl and magic lvl ? (Sorry i use google translate) ! Thanks !
Lua:
function onUse(cid, item, frompos, itemEx, topos)
local playerinfo = -- Please don't touch
{
level = getPlayerLevel(cid),
mlevel = getPlayerMagLevel(cid),
voc = getPlayerVocation(cid)
}
local config =
{
strenght = "template", ---Values: template (strenght dependent on level and magic level), constant (on all level adding same mana)
template = {min = (((playerinfo.level * 3) + (playerinfo.mlevel * 2)) / 1.5) , max =(((playerinfo.level * 3.5) + (playerinfo.mlevel * 2)) / 1.5)}, -- liczymy - lvl * 4 /1.5 = x m lvl * 2 /1.5 = x lvl + m lvl = Minimum, lvl * 6 /1.5 = x m lvl * 4 /1.5 = x lvl + m lvl = Maximum
constant = {min = 300, max = 500},--only if strenght is constant
exhaustion = 1,--exhaustion in secs
exhaustion_value = 56792, --exhaustion storage value
minimum_level = 200,--minimum level to use manarune
minimum_mlevel = 10,--minimum magic level to use manarune
cannot_use_voc = {1,2,4,5,6,8,9,10,12} --id vocation which cannot use
}
local rand = 0
if(isPlayer(itemEx.uid) == false) then
return true
end
if(playerinfo.level < config.minimum_level) then
return true
end
if(playerinfo.mlevel < config.minimum_mlevel) then
return true
end
if(isInArray(config.cannot_use_voc, playerinfo.voc)) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "This rune is only useable on Paladins")
return true
end
if(config.strenght ~= "template" and config.strenght ~= "constant") then
config.strenght = "constant"
end
if(getPlayerStorageValue(cid, config.exhaustion_value) > os.time()) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You are exhausted.")
return true
end
if(config.strenght == "template") then
rand = math.random(config.template.min, config.template.max)
elseif (config.strenght == "constant") then
rand = math.random(config.constant.min, config.constant.max)
end
doCreatureAddHealth(cid, rand)
doPlayerAddMana(cid, rand)
setPlayerStorageValue(cid, config.exhaustion_value, (os.time() + config.exhaustion))
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_RED)
return true
end
The code adds the same hp and mana. How change it to make it act like spirit potion?and it depended on lvl and magic lvl ? (Sorry i use google translate) ! Thanks !