• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Tfs 1.2 Spell that heals everyone around

Tbol

Well-Known Member
Joined
Apr 7, 2019
Messages
625
Reaction score
71
Anyone got a spell when you cast it it executes effect that heals everyone in party for x period of time with x interval with x amount of heal and its 1 tile range around the caster and also has a limit how many heals if there are already two heals, a third one would not trigger or wont heal the player that stands in those tiles
 
Solution
Anyone got a spell when you cast it it executes effect that heals everyone in party for x period of time with x interval with x amount of heal and its 1 tile range around the caster and also has a limit how many heals if there are already two heals, a third one would not trigger or wont heal the player that stands in those tiles

Not tested..

LUA:
local config = {
    healAmount = 50,       -- how much per tick
    interval = 2000,       -- ms between heals
    duration = 10000,      -- ms total duration
    radius = 1,            -- tiles around caster
    maxInstances = 2       -- maximum active auras
}

local activeAuras = {}

local function doHealingAura(cid, position, ticksLeft)
    local player = Player(cid)
    if not...
Anyone got a spell when you cast it it executes effect that heals everyone in party for x period of time with x interval with x amount of heal and its 1 tile range around the caster and also has a limit how many heals if there are already two heals, a third one would not trigger or wont heal the player that stands in those tiles

Not tested..

LUA:
local config = {
    healAmount = 50,       -- how much per tick
    interval = 2000,       -- ms between heals
    duration = 10000,      -- ms total duration
    radius = 1,            -- tiles around caster
    maxInstances = 2       -- maximum active auras
}

local activeAuras = {}

local function doHealingAura(cid, position, ticksLeft)
    local player = Player(cid)
    if not player then
        activeAuras[cid] = nil
        return
    end

    local spectators = Game.getSpectators(position, false, true, config.radius, config.radius, config.radius, config.radius)
    for _, target in ipairs(spectators) do
        if target:isPlayer() then
            target:addHealth(config.healAmount)
            position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        end
    end

    if ticksLeft > 0 then
        addEvent(doHealingAura, config.interval, cid, position, ticksLeft - 1)
    else
        activeAuras[cid] = nil
    end
end

function onCastSpell(creature, var)
    local cid = creature:getId()

    local activeCount = 0
    for _, _ in pairs(activeAuras) do
        activeCount = activeCount + 1
    end
    if activeCount >= config.maxInstances then
        creature:sendCancelMessage("Too many healing auras are already active.")
        return false
    end

    activeAuras[cid] = true
    local ticks = math.floor(config.duration / config.interval)
    doHealingAura(cid, creature:getPosition(), ticks)

    return true
end
 
Solution
Back
Top