Hey Folks, is there a way I can create a donation mana rune that will give players a stable number, for example, 3k mana each time. instead of a range based on the character level and magic level.
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1000) -- Change the time here ( 1000 means = 1 sec )
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local mana = 3000
targetPlayer = Player(target)
if not targetPlayer then
player:SendTextMessage(MESSAGE_INFO_DESCR, "You may only use this on players!")
return true
end...
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 = "constant", ---Values: template (strenght dependent on level and magic level), constant (on all level adding same mana)
template = {min = (((playerinfo.level * 2.3) + (playerinfo.mlevel * 5)) / 3.2) , max =(((playerinfo.level * 2.6) + (playerinfo.mlevel * 5.5)) / 3.2)}, -- 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 = 3000, max = 3000},--only if strenght is constant
exhaustion = 1,--exhaustion in secs
exhaustion_value = 56789, --exhaustion storage value
minimum_level = 15,--minimum level to use manarune
minimum_mlevel = 1,--minimum magic level to use manarune
cannot_use_voc = {0} --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, "Cant use.")
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
doPlayerAddMana(cid, rand)
setPlayerStorageValue(cid, config.exhaustion_value, (os.time() + config.exhaustion))
doCreatureSay(cid, "+"..math.floor(rand).." mana", TALKTYPE_ORANGE_1)
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
return true
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or not target:isPlayer() then
return false
end
local mana = 1000
target:addMana(mana)
toPosition:sendMagicEffect(CONST_ME_HOLYAREA)
item:remove(1)
return true
end
please avoid making runes with action script, use spell system instead
Spell - Mana Rune, Intense Mana Rune, and Ultimate Mana Rune
change the ids: 2298, 2270, and 2307 in your items.xml to this 2298 2270 2307 -- this one might come grouped as "spell rune" from 2306-2307, so heres the code to replace both Now go to spells.xml and add these...otland.net
you can use all the functionality of spells.xml filewhy if i can ask?
Hey Folks, is there a way I can create a donation mana rune that will give players a stable number, for example, 3k mana each time. instead of a range based on the character level and magic level.
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1000) -- Change the time here ( 1000 means = 1 sec )
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local mana = 3000
targetPlayer = Player(target)
if not targetPlayer then
player:SendTextMessage(MESSAGE_INFO_DESCR, "You may only use this on players!")
return true
end
local pos = targetPlayer:getPosition() -- getThingPos(itemEx.uid)
targetPlayer:addMana(mana)
pos:sendMagicEffect(50) -- You can change the effect as you want
player:addCondition(exhaust)
return true
end
data/actions/scripts
actions.xml
<action itemid="yourruneid" script="yourscriptnamehere.lua"/>
with mine you need to add an entry to spells.xml@DoktorHolzbein I would love if a player can heal another player. I tried the other previous codes but for some reason, I don't see any change.
the way I do it : data > spells > scripts > runes > donationmana.lua. do I also have to change any other script than that?
I get this error in the log:The one I posted should be added indata/actions/scripts
and then add this toactions.xml
I did nothing special to it, Just a rune adding mana but it can be edited if you gave more details about what exactly you need.XML:<action itemid="yourruneid" script="yourscriptnamehere.lua"/>
Or you can go for Evil Puncker's one.