• 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 Item give Critical, Lifeleach, Manaleach for 1 hours.

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
425
Solutions
1
Reaction score
44
Hello!
Is it possible to create an item that does not add a weapon bonus, but gives it to a particular player for, say, an hour?
I mean increasing critical chance, mana leach, life leach, etc.

There is no imubing in version 10.98, so I would like to create something similar, but which adds a bonus to the player and not his weapon.
 
I've created a basic script for you, test it and use as you like
Just add on the itemid that you want:

Inside actions.xml:
XML:
<action itemid="xxxx" script="buffs.lua" />

Then add a script buffs.lua inside actions/scripts:
Lua:
local config = {
    buffTime = 1, -- 1 hour buff
    manaLeech = 10, -- 10% mana leech amount
    lifeLeech = 20, -- 20% life leech amount
    critChance = 10, -- 10% critical hit chance
    critDamage = 50 -- 50% critical hit damage
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    for i = 155, 157 do
        if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, i) ~= nil then
            player:sendCancelMessage('You are already buffed.')
            return true
        end
    end

    -- Mana leech --
    local mana = Condition(CONDITION_ATTRIBUTES)
    mana:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT, config.manaLeech)
    mana:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE, 100)
    mana:setParameter(CONDITION_PARAM_SUBID, 155)
    mana:setTicks(buffTime * 60 * 60 * 1000)
    player:addCondition(mana)
   
    -- Life leech --
    local life = Condition(CONDITION_ATTRIBUTES)
    life:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT, config.lifeLeech)
    life:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE, 100)
    life:setParameter(CONDITION_PARAM_SUBID, 156)
    life:setTicks(buffTime * 60 * 60 * 1000)
    player:addCondition(life)
   
    -- Critical --
    local crit = Condition(CONDITION_ATTRIBUTES)
    crit:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT, config.critDamage)
    crit:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE, config.critChance)
    crit:setParameter(CONDITION_PARAM_SUBID, 157)
    crit:setTicks(buffTime * 60 * 60 * 1000)
    player:addCondition(crit)
   
    player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have increased your mana leech, life leech and critical chance for 1 hour.')
    item:remove(1)
   
    return true
end
 
Last edited:
Back
Top