• 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 only Healing Party

Devlinn

Member
Joined
Mar 25, 2015
Messages
295
Reaction score
6
hey, i dont know someone made something like this? look down. if not, its possible to do this? if yes can someone made it for me? thanks

Healing only Party Members, skill working by 12 second all party members got every second 50 health points before spell end

tfs 1.x

bump
 
Last edited by a moderator:
Lua:
function startHealingMembers(members, health_amount, rands)
   for i = 1, members do
       members[i]:addHealth(health_amount)
       members[i]:sendMagicEffect(CONST_ME_GREEN)
   end
   addEvent(startHealingMembers, 1000, members, health_amount, rands - 1)
end

function onCastSpell(creature, var, isHotkey)

   local health_amount = 50
   local rands = 12

   if not creature:getParty() then
       creature:sendCancelMessage("You are not in the party.")
       return false
   end
   local members = creature:getParty():getMemberCount()
   startHealingMembers(members, health_amount, rands)
   return true
end
 
Last edited:
Lua:
function startHealingMembers(members, health_amount, rands)
   for i = 1, members do
       members[i]:addHealth(health_amount)
       members[i]:sendMagicEffect(CONST_ME_GREEN)
   end
   addEvent(startHealingMembers, 1000, members, health_amount, rands - 1)
end

function onCastSpell(creature, var, isHotkey)

   local health_amount = 50
   local rands = 12

   if not creature:getParty() then
       creature:sendCancelMessage("You are not in the party.")
       return false
   end
   local members = creature:getParty():getMembers()
   startHealingMembers(members, health_amount, rands)
   return true
end

error:
Screen_Shot_10-25-17_at_02.54_PM.png
 
GetMemberCount() returns only the number of party members.
You need to use getMembers() that returns the metadata of the party members
 
Bad code

I think I was going to use the listPartyMembers function for something else like indexing the names none the less it looks like it will work :)

I just realized the previous post would cause an infinite loop.
This is another rough draft.
Lua:
local health_amount = 50
local times = 12

function listPartyMembers(cid)
    local creature = Creature(cid)
    local party = {}
    if creature then
        local members = creature:getParty():getMembers()
        if next(members) and #members > 0 then
            for _, member in pairs(members) do
                if member:isCreature() then
                    table.insert(party, member:getId())
                end
            end
        end
    end
    return party
end

function startHealingMembers(members, health_amount)
    if next(members) then
        for _, mid in pairs(members) do
            local creature = Creature(mid)
            if creature then
                creature:addHealth(health_amount)
                creature:sendMagicEffect(CONST_ME_GREEN)
            end
        end
    end
end

function onCastSpell(creature, var, isHotkey)
    if not creature:getParty() then
        creature:sendCancelMessage("You are not in the party.")
        return false
    end
    for i = 1, times do
        addEvent(startHealingMembers, i * 1000, listPartyMembers(creature:getId()), health_amount)
    end
    return true
end
 
Last edited by a moderator:
Back
Top