• 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 Special rune charge remover

darkmu

Well-Known Member
Joined
Aug 26, 2007
Messages
274
Solutions
1
Reaction score
50
Location
Paraná,Brazil
I created several special runes on my server, but I would like to leave them not infinite, that is, using it will spend loads, however, using the creature: removeItem (X, 1) function it will only remove the runes if it has in the backpack and if he uses it on the floor it will remain infinite, what can I do?

Example my special rune.
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BIGCLOUDS)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + maglevel + 6
    local max = (level / 5) + (maglevel * 2.6) + 16
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant, isHotkey)
    creature:removeItem(2312, 1)
    return combat:execute(creature, variant)
end


remarks: I do not want to change the config in the config.lua, because the ancient runes remained infinite.
 
One of the ways to do what you say is by modifying the fonts, since by default it cannot be achieved from a spell script, but you can also emulate this with an action script
 
I believe that in spells.xml you can set the attribute "charges".

Here is an example as to how sudden death rune works:

The actual spell script:

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 4) + (magicLevel * 6.3) + 32
    local max = (level / 4) + (magicLevel * 7.4) + 48
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant, isHotkey)
    return combat:execute(creature, variant)
end

And in spells.xml:

XML:
<rune group="attack" spellid="21" name="Sudden Death Rune" id="2268" allowfaruse="1" charges="3" level="45" magiclevel="15" cooldown="2000" groupcooldown="2000" needtarget="1" blocktype="solid" script="attack/sudden_death_rune.lua" />

Try converting your spell to look like this, perhaps it will work?

Otherwise, share the row for identiying your rune here on OTLand, and I can have a look :)
 
Do you say convert all runes to action script? Could you give me a very simple example?
that
Lua:
local config = {
    level = 200,
    magicLevel = 15,
    manaCost = 100,
    remove = true
}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 4) + (magicLevel * 6.3) + 32
    local max = (level / 4) + (magicLevel * 7.4) + 48
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local rune = Action()
function rune.onUse(player, item, fromPos, target, toPos, isHotkey)
    if player:getLevel() < config.level then
        player:sendCancelMessage(RETURNVALUE_NOTENOUGHLEVEL)
        return true
    end
    if player:getMagicLevel() < config.magicLevel then
        player:sendCancelMessage(RETURNVALUE_NOTENOUGHLEVEL)
        return true
    end
    if player:getMana() < config.manaCost then
        player:sendCancelMessage(RETURNVALUE_NOTENOUGHLEVEL)
        return true
    end
    if target and target:isCreature() and target ~= player then
        if combat:execute(player, Variant(target:getId())) then
            player:addMana(-config.manaCost)
            player:addManaSpent(config.manaCost)
            if config.remove then
                item:remove(1)
            end
            return true
        end
    end
    player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    return true
end
rune:allowFarUse(true)
rune:id(2306)
rune:register()

GIF 28-12-2020 11-33-19 a. m..gif
 
Last edited:
Well I changed in the config to remove the rune charges and the runes in the specials I removed the spells.xml charges and it worked for both, thanks
 
Back
Top