• 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 Manarune show added mana/health after use

SalvaART

TriasOT.online
Joined
May 1, 2017
Messages
208
Solutions
1
Reaction score
122
Location
USA
Hello everyone, i have problem with manarune, someone can help me?

The point is that the power of use is dependent on the level and magic level, and instead of displaying the monster's text, I would like it to display the added mana and health.

TFS 1.5 DOWNGRADED BY NEKIRO 8.60.

manarune.lua
Lua:
local runeTest = Spell(SPELL_RUNE)
function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local maxMana = creature:getMaxMana() / 100
    target:addMana(math.random(maxMana * 10, maxMana * 15))
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    target:say("Ughhh hhh!")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2281)
runeTest:blockWalls(true)
runeTest:magicLevel(1)
runeTest:level(8)
runeTest:group("support")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()
 
Hello everyone, i have problem with manarune, someone can help me?

The point is that the power of use is dependent on the level and magic level, and instead of displaying the monster's text, I would like it to display the added mana and health.

TFS 1.5 DOWNGRADED BY NEKIRO 8.60.

manarune.lua
Lua:
local runeTest = Spell(SPELL_RUNE)
function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local maxMana = creature:getMaxMana() / 100
    target:addMana(math.random(maxMana * 10, maxMana * 15))
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    target:say("Ughhh hhh!")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2281)
runeTest:blockWalls(true)
runeTest:magicLevel(1)
runeTest:level(8)
runeTest:group("support")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()
Well you can use animatetext but only if you have otclient.
I don't know if this is what you looking for :p
Animated Text Support for OT Client 10.98/99 - TFS 1.3 (https://otland.net/threads/animated-text-support-for-ot-client-10-98-99-tfs-1-3.256419/#post-2537106)
 
I am not too familiar with 1.5, but we have a rune that does tell you what you gained:

Lua:
function onCastSpell(cid, var)

    local mana = getPlayerMana(cid)
        if var.number == nil or cid == var.number then
        local playerPos = getCreaturePosition(cid)
        local pos = variantToPosition(var)
        if(pos.x == playerPos.x and pos.y == playerPos.y and pos.z == playerPos.z) then
               
             doCombat(cid, combat, var)
             local mana2 = getPlayerMana(cid)
             doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You used an ultra mana rune and recovered ".. mana2 - mana  .. " mana points")
           
            return true
        end
    end
       
    doPlayerSendCancel(cid, "You can only use this rune on yourself.")
       
    return true
end

Could you use parts of this; it looks like you could get the mana amount before adding, then after, then send the player message. Oh, I think you mean display on the monster, not a message to the player about his mana level. This might not help so much, but I will leave the script just in case any parts are useful. Good luck!
 
Last edited:
Also can check this
Found it here: Compiling - How to show health and mana(healing numbers) (https://otland.net/threads/how-to-show-health-and-mana-healing-numbers.249219/#post-2425194)

Lua:
local ultimateHealthPot = 8473
local greatHealthPot = 7591
local greatManaPot = 7590
local greatSpiritPot = 8472
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local smallHealthPot = 8704
local antidotePot = 8474
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636

local antidote = Combat()
antidote:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
antidote:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
antidote:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
antidote:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
antidote:setParameter(COMBAT_PARAM_DISPEL, CONDITION_POISON)

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) +650))
-- 1000 - 100 due to exact condition timing. -100 doesn't hurt us, and players don't have reminding ~50ms exhaustion.

local function sendManaNumbers(player, mana)
    player:sendTextMessage(MESSAGE_HEALED, ("You gained %d mana."):format(mana), player:getPosition(), mana, TEXTCOLOR_BLUE)
    local name = player:getName()
    for _, spectator in ipairs(Game.getSpectators(player:getPosition(), false, true)) do
        if spectator ~= player then
            spectator:sendTextMessage(MESSAGE_HEALED, ("%s gained %d mana."):format(name, mana), player:getPosition(), mana, TEXTCOLOR_BLUE)
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target == nil or not target:isPlayer() then
        return true
    end

    if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    local itemId = item:getId()
    if itemId == antidotePot then
        if not antidote:execute(target, numberToVariant(target:getId())) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    elseif itemId == smallHealthPot then
        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 500, 500, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    elseif itemId == healthPot then
        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 2000, 2700, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    elseif itemId == manaPot then
        local mana = math.random(2000, 2700)
        if not doTargetCombatMana(0, target, mana, mana, CONST_ME_MAGIC_BLUE) then
            return false
        end
        sendManaNumbers(player, mana)
        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    elseif itemId == strongHealthPot then
        if (not isInArray({1,2,3,4,5,6,7,8}, target:getVocation():getId()) or target:getLevel() < 1000) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("Para level 1000+.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 7400, 7600, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    elseif itemId == strongManaPot then
        if (not isInArray({1,2,3,4,5,6,7,8}, target:getVocation():getId()) or target:getLevel() < 1000) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("Para level 1000+.", TALKTYPE_MONSTER_SAY)
            return true
        end
        local mana = math.random(7400, 7600)
        if not doTargetCombatMana(0, target, mana, mana, CONST_ME_MAGIC_BLUE) then
            return false
        end
        sendManaNumbers(player, mana)
        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    elseif itemId == greatSpiritPot then
        if (not isInArray({1,2,3,4,5,6,7,8}, target:getVocation():getId()) or target:getLevel() < 41000) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("Para level 41000+.", TALKTYPE_MONSTER_SAY)
            return true
        end
        local mana = math.random(33000, 35000)
        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 33000, 35000, CONST_ME_MAGIC_BLUE) or not doTargetCombatMana(0, target, mana, mana, CONST_ME_MAGIC_BLUE) then
            return false
        end
        sendManaNumbers(player, mana)
        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    elseif itemId == greatHealthPot then
        if (not isInArray({1,2,3,4,5,6,7,8}, target:getVocation():getId()) or target:getLevel() < 6000) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("Para level 6000+.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 13000, 15000, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    elseif itemId == greatManaPot then
        if (not isInArray({1,2,3,4,5,6,7,8}, target:getVocation():getId()) or target:getLevel() < 6000) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("Para level 6000+.", TALKTYPE_MONSTER_SAY)
            return true
        end
        local mana = math.random(13000, 15000)
        if not doTargetCombatMana(0, target, mana, mana, CONST_ME_MAGIC_BLUE) then
            return false
        end
        sendManaNumbers(player, mana)
        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    elseif itemId == ultimateHealthPot then
        if (not isInArray({1,2,3,4,5,6,7,8}, target:getVocation():getId()) or target:getLevel() < 41000) and not getPlayerFlagValue(player, PlayerFlag_IgnoreSpellCheck) then
            player:say("Para level 41000+.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if not doTargetCombatHealth(0, target, COMBAT_HEALING, 33000, 35000, CONST_ME_MAGIC_BLUE) then
            return false
        end

        player:addCondition(exhaust)
        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    end
    return true
end
 
I am not too familiar with 1.5, but we have a rune that does tell you what you gained:

Lua:
function onCastSpell(cid, var)

    local mana = getPlayerMana(cid)
        if var.number == nil or cid == var.number then
        local playerPos = getCreaturePosition(cid)
        local pos = variantToPosition(var)
        if(pos.x == playerPos.x and pos.y == playerPos.y and pos.z == playerPos.z) then
             
             doCombat(cid, combat, var)
             local mana2 = getPlayerMana(cid)
             doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You used an ultra mana rune and recovered ".. mana2 - mana  .. " mana points")
         
            return true
        end
    end
     
    doPlayerSendCancel(cid, "You can only use this rune on yourself.")
     
    return true
end

Could you use parts of this; it looks like you could get the mana amount before adding, then after, then send the player message. Oh, I think you mean display on the monster, not a message to the player about his mana level. This might not help so much, but I will leave the script just in case any parts are useful. Good luck!
hello, didnt work for me :(
 
If this is you meant?
SFHTeTI.png


If yes just use this then

Lua:
local runeTest = Spell(SPELL_RUNE)
function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local maxMana = creature:getMaxMana() / 100
    target:addMana(math.random(maxMana * 10, maxMana * 15))
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    target:say("+ "..maxMana.." mana")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2307)
runeTest:blockWalls(true)
runeTest:magicLevel(1)
runeTest:level(8)
runeTest:group("support")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(false)
runeTest:register()
 
If this is you meant?
SFHTeTI.png


If yes just use this then

Lua:
local runeTest = Spell(SPELL_RUNE)
function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local maxMana = creature:getMaxMana() / 100
    target:addMana(math.random(maxMana * 10, maxMana * 15))
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    target:say("+ "..maxMana.." mana")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2307)
runeTest:blockWalls(true)
runeTest:magicLevel(1)
runeTest:level(8)
runeTest:group("support")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(false)
runeTest:register()
Exactly that, I only have a request, could you please change it to me so that it does not give +9999.99 mana, it still only varies? Depends on the level and magic level
 
Oh, I only posted the middle part of the script showing the method we used to get the amount to display. It looks like what dewral is posting is far more appropriate for your version; I hope you can get it working, good luck!
 
Not tested.

Lua:
function calculateMana(creature)
    local level = creature:getLevel()
    local magicLevel = creature:getMagicLevel()

    return math.random(level, level * 2) + math.random(magicLevel, magicLevel * 3)
end

function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local manaBefore = target:getMana()

    local mana = calculateMana(creature)
    target:addMana(mana)
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)

    local manaAdded = target:getMana() - manaBefore
    target:say("+ "..manaAdded.." mana")
    return true
end
 
Not tested.

Lua:
function calculateMana(creature)
    local level = creature:getLevel()
    local magicLevel = creature:getMagicLevel()

    return math.random(level, level * 2) + math.random(magicLevel, magicLevel * 3)
end

function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local manaBefore = target:getMana()

    local mana = calculateMana(creature)
    target:addMana(mana)
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)

    local manaAdded = target:getMana() - manaBefore
    target:say("+ "..manaAdded.." mana")
    return true
end
Thank you for your help!!!! but i have error

Code:
Lua Script Error: [Scripts Interface]
/home/*/data/scripts/actions/others/manarune.lua
/home/*/data/scripts/actions/others/manarune.lua:8: attempt to index global 'runeTest' (a nil value)
stack traceback:
        [C]: in function '__newindex'
        /home/*/data/scripts/actions/others/manarune.lua:8: in main chunk
        [C]: in function 'reload'
        data/talkactions/scripts/reload.lua:81: in function <data/talkactions/scripts/reload.lua:59>
> manarune.lua [error]

Lua:
function calculateMana(creature)
    local level = creature:getLevel()
    local magicLevel = creature:getMagicLevel()

    return math.random(level, level * 2) + math.random(magicLevel, magicLevel * 3)
end

function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local manaBefore = target:getMana()

    local mana = calculateMana(creature)
    target:addMana(mana)
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)

    local manaAdded = target:getMana() - manaBefore
    target:say("+ "..manaAdded.." mana")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2281)
runeTest:blockWalls(true)
runeTest:magicLevel(1)
runeTest:level(8)
runeTest:group("support")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()
 
Thank you for your help!!!! but i have error

Code:
Lua Script Error: [Scripts Interface]
/home/*/data/scripts/actions/others/manarune.lua
/home/*/data/scripts/actions/others/manarune.lua:8: attempt to index global 'runeTest' (a nil value)
stack traceback:
        [C]: in function '__newindex'
        /home/*/data/scripts/actions/others/manarune.lua:8: in main chunk
        [C]: in function 'reload'
        data/talkactions/scripts/reload.lua:81: in function <data/talkactions/scripts/reload.lua:59>
> manarune.lua [error]

Lua:
function calculateMana(creature)
    local level = creature:getLevel()
    local magicLevel = creature:getMagicLevel()

    return math.random(level, level * 2) + math.random(magicLevel, magicLevel * 3)
end

function runeTest.onCastSpell(creature, variant)
    local target = Tile(variant:getPosition()):getTopVisibleCreature(creature)
    if not target or not target:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local manaBefore = target:getMana()

    local mana = calculateMana(creature)
    target:addMana(mana)
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)

    local manaAdded = target:getMana() - manaBefore
    target:say("+ "..manaAdded.." mana")
    return true
end

runeTest:name("ManaRune#1")
runeTest:isAggressive(false)
runeTest:runeId(2281)
runeTest:blockWalls(true)
runeTest:magicLevel(1)
runeTest:level(8)
runeTest:group("support")
runeTest:id(24)
runeTest:cooldown(1 * 1000)
runeTest:groupCooldown(1 * 1000)
runeTest:isPremium(true)
runeTest:register()

I only posted the functions i changed. You are missing
Lua:
local runeTest = Spell(SPELL_RUNE)
at the top
 
Back
Top