Ir para conteúdo

Featured Replies

Postado

.Galera essa é uma Spell de Summon que heala o Invocador e quem esta na party, porém, mesmo que os Membros da party estejam a 20,50,80,150,200,500SQM de Distância Heala os membros da party mesmo assim.

Eu queria colocar um limite de SQM (tipo um IsRange), pra que não de Healing em que estiver Longe do summon/invocador.

 

Segue o Script:

 

local config = {
health = 3000,
mana = 1000
}


function onCastSpell(cid, var)

if getCreatureMaster(cid) then
local master = getCreatureMaster(cid)
    if isInParty(master) then
        local members = getPartyMembers(getPlayerParty(master))
        local health = math.ceil( config.health / #members )
        local mana = math.ceil( config.mana / #members )
        for i = 1, #members do
        doCreatureAddHealth(members[i], health)
        doCreatureAddMana(members[i], mana)
        doSendAnimatedText(getCreaturePosition(members[i]), "+"..health, 18)    
        doSendMagicEffect(getCreaturePosition(members[i]), 5)        
        end
    else
        doCreatureAddHealth(master, config.health)
        doCreatureAddMana(master, config.mana)
        doSendAnimatedText(getCreaturePosition(master), "+"..config.health, 18)        
        doSendMagicEffect(getCreaturePosition(master), 5)    
    end

    end

return true
end

Resolvido por 139

Ir para solução
Postado
  • Solução
Em 11/02/2021 em 14:35, Garoto Prodigio disse:

.Galera essa é uma Spell de Summon que heala o Invocador e quem esta na party, porém, mesmo que os Membros da party estejam a 20,50,80,150,200,500SQM de Distância Heala os membros da party mesmo assim.

Eu queria colocar um limite de SQM (tipo um IsRange), pra que não de Healing em que estiver Longe do summon/invocador.

 

Segue o Script:

 

local config = {
health = 3000,
mana = 1000
}


function onCastSpell(cid, var)

if getCreatureMaster(cid) then
local master = getCreatureMaster(cid)
    if isInParty(master) then
        local members = getPartyMembers(getPlayerParty(master))
        local health = math.ceil( config.health / #members )
        local mana = math.ceil( config.mana / #members )
        for i = 1, #members do
        doCreatureAddHealth(members[i], health)
        doCreatureAddMana(members[i], mana)
        doSendAnimatedText(getCreaturePosition(members[i]), "+"..health, 18)    
        doSendMagicEffect(getCreaturePosition(members[i]), 5)        
        end
    else
        doCreatureAddHealth(master, config.health)
        doCreatureAddMana(master, config.mana)
        doSendAnimatedText(getCreaturePosition(master), "+"..config.health, 18)        
        doSendMagicEffect(getCreaturePosition(master), 5)    
    end

    end

return true
end


Adicionei o range,
 

Spoiler

 

local config = {
health = 3000,
mana = 1000
}

local range = 20

local function getDistanceBetween(fromPosition, toPosition)
  local x, y = math.abs(fromPosition.x - toPosition.x), math.abs(fromPosition.y - toPosition.y)
  local diff = math.max(x, y)
  if(fromPosition.z ~= toPosition.z) then
    diff = diff + 9 + 6
  end

  return diff
end

function onCastSpell(cid, var)

if getCreatureMaster(cid) then
local master = getCreatureMaster(cid)
local c_pos = getCreaturePosition(cid)
local m_pos = getCreaturePosition(master)
local p_pos = {}

    if isInParty(master) then
        local members = getPartyMembers(getPlayerParty(master))
        local health = math.ceil( config.health / #members )
        local mana = math.ceil( config.mana / #members )
        for i = 1, #members do
            p_pos = getCreaturePosition(members[i])
            if getDistanceBetween(c_pos, p_pos) < range or getDistanceBetween(m_pos, p_pos) < range then
                doCreatureAddHealth(members[i], health)
                doCreatureAddMana(members[i], mana)
                doSendAnimatedText(p_pos, "+"..health, 18)    
                doSendMagicEffect(p_pos, 5) 
            end            
        end
    else
        doCreatureAddHealth(master, config.health)
        doCreatureAddMana(master, config.mana)
        doSendAnimatedText(getCreaturePosition(master), "+"..config.health, 18)        
        doSendMagicEffect(getCreaturePosition(master), 5)    
    end

    end

return true
end

 

 

Postado
  • Autor
Em 15/02/2021 em 00:58, 139 disse:


Adicionei o range,
 

  Mostrar conteúdo oculto

 

local config = {
health = 3000,
mana = 1000
}

local range = 20

local function getDistanceBetween(fromPosition, toPosition)
  local x, y = math.abs(fromPosition.x - toPosition.x), math.abs(fromPosition.y - toPosition.y)
  local diff = math.max(x, y)
  if(fromPosition.z ~= toPosition.z) then
    diff = diff + 9 + 6
  end

  return diff
end

function onCastSpell(cid, var)

if getCreatureMaster(cid) then
local master = getCreatureMaster(cid)
local c_pos = getCreaturePosition(cid)
local m_pos = getCreaturePosition(master)
local p_pos = {}

    if isInParty(master) then
        local members = getPartyMembers(getPlayerParty(master))
        local health = math.ceil( config.health / #members )
        local mana = math.ceil( config.mana / #members )
        for i = 1, #members do
            p_pos = getCreaturePosition(members[i])
            if getDistanceBetween(c_pos, p_pos) < range or getDistanceBetween(m_pos, p_pos) < range then
                doCreatureAddHealth(members[i], health)
                doCreatureAddMana(members[i], mana)
                doSendAnimatedText(p_pos, "+"..health, 18)    
                doSendMagicEffect(p_pos, 5) 
            end            
        end
    else
        doCreatureAddHealth(master, config.health)
        doCreatureAddMana(master, config.mana)
        doSendAnimatedText(getCreaturePosition(master), "+"..config.health, 18)        
        doSendMagicEffect(getCreaturePosition(master), 5)    
    end

    end

return true
end

 

 

Reputado 2x! Funcionando Perfeitamente! Obrigado! :D

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo