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

Healing monster

Slafesko

New Member
Joined
Jan 6, 2016
Messages
101
Reaction score
2
This script of monster that heal his master and party but there is something with it and i hope you help me
<event type="cast" name="curar" event="script" value="curar.lua"/>


-- summon heal master v1.1
-- by leyendario.
local config = {
heal = 1000,
mana = 1000, -- put 0 if you dont want him to recover mana.
condition = "yes", -- put no if you dont want him to remove the conditions (fire, poison, etc).
}
function onCast(cid, target)
local master = getCreatureMaster(cid)
if master then
local conditions = {CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_PARALYZE, CONDITION_DRUNK, CONDITION_DROWN, CONDITION_CURSED}
local party = getPartyMembers(master)
local pos = getCreaturePosition(master)
if not getPlayerParty(master) then
doCreatureAddHealth(master, config.heal)
doCreatureAddMana(master, config.mana)
doSendMagicEffect(pos, 12)
if (config.condition == "yes") then
for i, todos in ipairs(conditions) do
doRemoveCondition(master, todos)
end
end
return true
end
for _, miembros in pairs(party) do
doCreatureAddMana(miembros, config.mana)
doCreatureAddHealth(miembros, config.heal)
pos = getCreaturePosition(miembros)
doSendMagicEffect(pos, 12)
if (config.contidion == "yes") then
for i, todos in ipairs(conditions) do
doRemoveCondition(miembros, todos)
end
end
end
end
return true
end
the problem is this monster heal party members and its okey but when someone leave to somewhere he is still getting the heal from the monster like, if we did party in venore and a member from our team left us and goes to edron he will get heal from the monster so what i need is to if not isInArea of master do not heal
i tried to do it but i failed :(
tfs 0.4
 
This script of monster that heal his master and party but there is something with it and i hope you help me
Code:
<event type="cast" name="curar" event="script" value="curar.lua"/>

-- summon heal master v1.1
-- by leyendario.
   local config = {
   heal = 1000,
   mana = 1000, -- put 0 if you dont want him to recover mana.
   condition = "yes", -- put no if you dont want him to remove the conditions (fire, poison, etc).
   }
function onCast(cid, target)
   local master = getCreatureMaster(cid)
   if master then
     local conditions = {CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_PARALYZE, CONDITION_DRUNK, CONDITION_DROWN, CONDITION_CURSED}
     local party = getPartyMembers(master)
     local pos = getCreaturePosition(master)
     if not getPlayerParty(master) then
       doCreatureAddHealth(master, config.heal)
       doCreatureAddMana(master, config.mana)
       doSendMagicEffect(pos, 12)
       if (config.condition == "yes") then
         for i, todos in ipairs(conditions) do
           doRemoveCondition(master, todos)
         end
       end
       return true
     end
     for _, miembros in pairs(party) do
       doCreatureAddMana(miembros, config.mana)
       doCreatureAddHealth(miembros, config.heal)
       pos = getCreaturePosition(miembros)
       doSendMagicEffect(pos, 12)
       if (config.contidion == "yes") then
         for i, todos in ipairs(conditions) do
           doRemoveCondition(miembros, todos)
         end
       end
     end
   end
   return true
end
the problem is this monster heal party members and its okey but when someone leave to somewhere he is still getting the heal from the monster like, if we did party in venore and a member from our team left us and goes to edron he will get heal from the monster so what i need is to if not isInArea of master do not heal
i tried to do it but i failed :(
tfs 0.4

Maybe you can use a function to get the position of the master and the position of each member, then comparate both positions and apply the effect depending of the distance between them.

Here you can see more methods/functions for tfs 0.4:
https://otland.net/threads/lua-0-4-tfs-functions.149040/

You can use a getter for the master and a getter for each party member to get their position, and then compare both positions with getDistanceBetween(fromPosition, toPosition);finally you should put a valid max. distance to the condition; you get it?

Tell me if you have more trouble.
 
Code:
local c = {
    health = 1000,
    mana = 1000, -- put 0 if you dont want him to recover mana.
    condition = "yes", -- put no if you dont want him to remove the conditions (fire, poison, etc).
    conditions = {CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_PARALYZE, CONDITION_DRUNK, CONDITION_DROWN, CONDITION_CURSED},
    rangex = 7,
    rangey = 7,
    multifloor = false
}

function isInArray(array, value)
    if type(array) == 'table' then
        for _, v in pairs(array) do
            if v == value then
                return true
            end
        end
    end
    return false
end

function onCast(cid, target)
    local master = getCreatureMaster(cid)
    if master then
        local party = getPartyMembers(master)
        local masterPosition = getCreaturePosition(master)
        if party == nil or type(party) ~= "table" or #party <= 1 then
            doCreatureAddHealth(master, c.health)
            doCreatureAddMana(master, c.mana)
            doSendMagicEffect(masterPosition, 12)
            if (c.condition == "yes") then
                for i = 1, #c.conditions do
                    doRemoveCondition(master, c.condition[i])
                end
            end
            return true
        else
            local players = getSpectators(masterPosition, c.rangex, c.rangey, c.multifloor)
            for _, member pairs(party) do
                if isInArray(players, member) then
                    doCreatureAddMana(member, c.mana)
                    doCreatureAddHealth(member, c.health)
                    doSendMagicEffect(getCreaturePosition(member), 12)
                    if (c.condition == "yes") then
                        for i = 1, #c.conditions do
                            doRemoveCondition(member, c.condition[i])
                        end
                    end
                end
            end
        end
    end
    return true
end
 
Last edited:
Code:
local c = {
    health = 1000,
    mana = 1000, -- put 0 if you dont want him to recover mana.
    condition = "yes", -- put no if you dont want him to remove the conditions (fire, poison, etc).
    conditions = {CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_PARALYZE, CONDITION_DRUNK, CONDITION_DROWN, CONDITION_CURSED},
    rangex = 7,
    rangey = 7,
    multifloor = false
}

function isInArray(array, value)
    if type(array) == 'table' then
        for _, v in pairs(array) do
            if v == value then
                return true
            end
        end
    end
    return false
end

function onCast(cid, target)
    local master = getCreatureMaster(cid)
    if master then
        local party = getPartyMembers(master)
        local masterPosition = getCreaturePosition(master)
        if party == nil or type(party) ~= "table" or #party <= 1 then
            doCreatureAddHealth(master, c.health)
            doCreatureAddMana(master, c.mana)
            doSendMagicEffect(masterPosition, 12)
            if (c.condition == "yes") then
                for i = 1, #c.conditions do
                    doRemoveCondition(master, c.condition[i])
                end
            end
            return true
        else
            local players = getSpectators(masterPosition, c.rangex, c.rangey, c.multifloor)
            for _, member pairs(party) do
                if isInArray(players, member) then
                    doCreatureAddMana(member, c.mana)
                    doCreatureAddHealth(member, c.health)
                    doSendMagicEffect(getCreaturePosition(member), 12)
                    if (c.condition == "yes") then
                        for i = 1, #c.conditions do
                            doRemoveCondition(member, c.condition[i])
                        end
                    end
                end
            end
        end
    end
    return true
end
Well thanks for your help, i gonna try it when i get home.
 
Back
Top