Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)

local area = createCombatArea(AREA_CROSS5X5)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    local pos = getCreaturePosition(cid) 
    local targets = getCreaturesInArea(pos, area)

    for _, target in ipairs(targets) do
        if isCreature(target) then
            if isPlayer(target) or isMonster(target) then
                local first = getCreatureHealth(target)
                doSetCreatureTarget(target, cid) 
                if doCombat(target, combat, var) then
                    local second = getCreatureHealth(target)
                    local damage = first - second
                    if damage > 0 then
                        local addhealth = damage * 0.5
                        doCreatureAddHealth(cid, addhealth)
					-- doSendAnimatedText(getPlayerPosition(target), "+"..addhealth.."", TEXTCOLOR_GREEN) -- Você pode enviar um texto animado para cada alvo, se desejar.
                        doSendMagicEffect(getThingPos(target), CONST_ME_MAGIC_GREEN)
                        doSendDistanceShoot(getThingPos(target), getThingPos(cid), 40)
                    end
                end
            end
        end
    end

    return true
end

 

Editado por GM Vortex (veja o histórico de edições)

  • Respostas 11
  • Visualizações 1.8k
  • Created
  • Última resposta

Top Posters In This Topic

Postado
3 horas atrás, GM Vortex disse:

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)

local area = createCombatArea(AREA_CROSS5X5)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    local pos = getCreaturePosition(cid) 
    local targets = getCreaturesInArea(pos, area)

    for _, target in ipairs(targets) do
        if isCreature(target) then
            if isPlayer(target) or isMonster(target) then
                local first = getCreatureHealth(target)
                doSetCreatureTarget(target, cid) 
                if doCombat(target, combat, var) then
                    local second = getCreatureHealth(target)
                    local damage = first - second
                    if damage > 0 then
                        local addhealth = damage * 0.5
                        doCreatureAddHealth(cid, addhealth)
					-- doSendAnimatedText(getPlayerPosition(target), "+"..addhealth.."", TEXTCOLOR_GREEN) -- Você pode enviar um texto animado para cada alvo, se desejar.
                        doSendMagicEffect(getThingPos(target), CONST_ME_MAGIC_GREEN)
                        doSendDistanceShoot(getThingPos(target), getThingPos(cid), 40)
                    end
                end
            end
        end
    end

    return true
end

 

[Error - Spell Interface] 

data/spells/scripts/attack/rage of the blood.lua:onCastSpell

Description: 

data/spells/scripts/attack/rage of the blood.lua:12: attempt to call global 'getCreaturesInArea' (a nil value)

stack traceback:

 data/spells/scripts/attack/rage of the blood.lua:12: in function 

              

20120329195100.jpg
Postado
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)

local area = createCombatArea(AREA_CIRCLE3X3)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    local target = getCreatureTarget(cid)
    if target and (isPlayer(target) or isMonster(target)) then
        local first = getCreatureHealth(target)
        doCreatureSay(cid, "Prepare to be drained!", TALKTYPE_MONSTER)
        doCreatureSay(target, "Uh-oh, I'm getting drained!", TALKTYPE_MONSTER)
        if doCombat(cid, combat, var) == LUA_NO_ERROR then
            local second = getCreatureHealth(target)
            local damage = first - second
            if damage > 0 then
                local addhealth = damage * 0.5
                doCreatureAddHealth(cid, addhealth)
                doSendAnimatedText(getCreaturePosition(target), "+" .. addhealth, TEXTCOLOR_GREEN)
                doSendMagicEffect(getCreaturePosition(target), CONST_ME_MAGIC_GREEN)
                doSendDistanceShoot(getCreaturePosition(target), getCreaturePosition(cid), 40)
            end
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Nenhum alvo válido encontrado.")
    end
    return true
end

tenta ai! deve funcionar

Postado
1 hora atrás, GM Vortex disse:

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)

local area = createCombatArea(AREA_CIRCLE3X3)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    local target = getCreatureTarget(cid)
    if target and (isPlayer(target) or isMonster(target)) then
        local first = getCreatureHealth(target)
        doCreatureSay(cid, "Prepare to be drained!", TALKTYPE_MONSTER)
        doCreatureSay(target, "Uh-oh, I'm getting drained!", TALKTYPE_MONSTER)
        if doCombat(cid, combat, var) == LUA_NO_ERROR then
            local second = getCreatureHealth(target)
            local damage = first - second
            if damage > 0 then
                local addhealth = damage * 0.5
                doCreatureAddHealth(cid, addhealth)
                doSendAnimatedText(getCreaturePosition(target), "+" .. addhealth, TEXTCOLOR_GREEN)
                doSendMagicEffect(getCreaturePosition(target), CONST_ME_MAGIC_GREEN)
                doSendDistanceShoot(getCreaturePosition(target), getCreaturePosition(cid), 40)
            end
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Nenhum alvo válido encontrado.")
    end
    return true
end

tenta ai! deve funcionar

Funcionou, mas não dá maneira correta. Problemas:

1. Precisa ter target para usar a magia.

2. Suga a vida apenas do target, e não de todos os afetados.

 

O que preciso:

1. Soltar a magia sem a necessidade de estar atacando alguém (target).

2. Sugar a vida de todos atingidos por ela.

 

Será isso possível?

20120329195100.jpg
Postado

vamos tentar aqui:

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)

local area = createCombatArea(AREA_CIRCLE3X3)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    local pos = getCreaturePosition(cid) 
    local creatures = {}  

    for _, target in ipairs(getSpectators(pos, -1, -1, false)) do
        if isCreature(target) and (isPlayer(target) or isMonster(target)) then
            table.insert(creatures, target)  
        end
    end

    if #creatures > 0 then
        doCreatureSay(cid, "Prepare to be drained!", TALKTYPE_MONSTER)
        for _, target in ipairs(creatures) do
            local first = getCreatureHealth(target)
            doCreatureSay(target, "Uh-oh, I'm getting drained!", TALKTYPE_MONSTER)
            if doCombat(cid, combat, var) == LUA_NO_ERROR then
                local second = getCreatureHealth(target)
                local damage = first - second
                if damage > 0 then
                    local addhealth = damage * 0.5
                    doCreatureAddHealth(cid, addhealth)
                    doSendAnimatedText(getCreaturePosition(target), "+" .. addhealth, TEXTCOLOR_GREEN)
                    doSendMagicEffect(getCreaturePosition(target), CONST_ME_MAGIC_GREEN)
                    doSendDistanceShoot(getCreaturePosition(target), pos, 40)
                end
            end
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Nenhum alvo válido encontrado.")
    end

    return true
end

 

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.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo