• 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!

Spell [TFS 1.X] Heal Party

Leo32

Getting back into it...
Joined
Sep 21, 2007
Messages
987
Solutions
14
Reaction score
532
This is a replacement for exura sio on my server.

It behaves just like exura sio, players must be on-screen and not obstructed by walls etc.
But it heals everyone in your party instead (if they have health missing).
Healing amount is identical to exura sio, mana costs are 140 for a single target + 40 for each additional target.

uzWnB8c.gif


spells.xml
XML:
<instant group="healing" name="Heal Party" words="heal party" lvl="28" mana="140" prem="1" aggressive="0" selftarget="1" exhaustion="1000" groupcooldown="1000" script="party/heal.lua">
    <vocation name="..." />
</instant>

spells\scripts\party\heal.lua
Lua:
function onCastSpell(creature, var)

    local baseMana = 140
    local additionalTargetMana = 40
    local healerPos = creature:getPosition()
    local healerId = creature:getId()
    local party = creature:getParty()
    local membersList = {}

    -- Check if caster is in a party
    if party then
        -- Insert Members
        membersList = party:getMembers()
        -- Insert Leader
        table.insert(membersList, party:getLeader())
        if membersList == nil then
            creature:sendTextMessage(MESSAGE_STATUS_SMALL, "There are no party members in range with missing health.")
            healerPos:sendMagicEffect(CONST_ME_POFF)
            return false
        end
    else
        creature:sendTextMessage(MESSAGE_STATUS_SMALL, "You are not in a party.")
        return false
    end

    -- Check collate all members and add to valid target list if in range
    local affectedList = {}
    for _, partyMember in ipairs(membersList) do
        local partyMemberId = partyMember:getId()
        if partyMemberId ~= creature:getId() then
            local partyMemberPos = partyMember:getPosition()
            local distanceX = math.abs(partyMemberPos.x - healerPos.x)
            local distanceY = math.abs(partyMemberPos.y - healerPos.y)
            if distanceX <= 7 and distanceY <= 5 and partyMemberPos.z == healerPos.z and partyMemberPos:isSightClear(healerPos, true) and partyMember:getHealth() < partyMember:getMaxHealth() then
                table.insert(affectedList, partyMember)
            end
        end
    end

    -- Get check if valid Party Members in range
    local tmp = 0
    if affectedList ~= nil then
        tmp = #affectedList
    end
    if tmp < 1 then
        creature:sendTextMessage(MESSAGE_STATUS_SMALL, "There are no party members in range with missing health.")
        healerPos:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    -- Calculate mana costs
    local mana = baseMana + (additionalTargetMana * (tmp - 1))
    if(creature:getMana() < mana) then
        creature:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
        healerPos:sendMagicEffect(CONST_ME_POFF)
        return false
    end
 
    -- Don't reduce mana if GM or GOD because it sends CONST_ME_POFF animation
    --if not creature:getGroup():getAccess() then
        creature:addMana(-(mana - baseMana), FALSE)
        creature:addManaSpent((mana - baseMana))
    --end
 
    local level = creature:getLevel()
    local magiclevel = creature:getMagicLevel()
    local min = (level / 5) + (magiclevel * 6.3) + 45
    local max = (level / 5) + (magiclevel * 14.4) + 90
 
    -- Healer Animation
    healerPos:sendMagicEffect(CONST_ME_MAGIC_GREEN)
 
    -- Apply Heal/Animation to Party Member
    for _, partyMember in ipairs(affectedList) do
        local healAmount = math.random(min,max)
        partyMember:addHealth(healAmount)
        partyMember:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end

    return true
end

EDIT: Script edited to only target players if they are missing health, this conserves mana costs.

line 34:
Lua:
and partyMember:getHealth() < partyMember:getMaxHealth()
 
Last edited:
Back
Top