Ir para conteúdo
  • 0
Entre para seguir isso  
tira94

Scripting Reflection damage

Pergunta

tira94    0
tira94

Base:  The OTX Server Global - Version: (3.10)

Senhores, tudo rox por ai?

Então, eu estou com um problema no código abaixo, eu queria que o monstro refletisse o dano causa a ele, mas no caso abaixo ele não está causado dano ao monstro, como poderia ajustar para o dano causado no monstro pode-se ser retornado ao player?

 

Código:

Spoiler

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isMonster() and isInArray({ORIGIN_MELEE, ORIGIN_SPELL}, origin) and primaryType == COMBAT_PHYSICALDAMAGE then
            creature:getPosition():sendMagicEffect(173)
        return doTargetCombatHealth(creature,attacker, primaryDamage * 1, primaryType)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

3 respostass a esta questão

Recommended Posts

  • 0
tira94    0
tira94
Spoiler
Em 04/03/2019 em 10:37, underewar disse:

@tira94 Falta muita coisa para você chegar la ,mas não desanime vou deixar aqui o meu código de reflect caso não consiga instalar me fale para eu poder criar um topico



for i = 9, 16 do -- reflect
            if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                if not attacker then
                    return primaryDamage, primaryType, secondaryDamage, secondaryType
                end
                if primaryType == res[i][2] or i == 16 then
                    local a = math.floor(primaryDamage * (creature:getStorageValue(5) / 100))
                    if attacker:isMonster() then
                        local m = MonsterType(attacker:getName())
                        local e = m:getElementList()
                        local f = m:getCombatImmunities()
                        if type(f) == "number" then
                            if f == primaryType then
                                a = 0
                            end
                        else
                            for i, j in pairs(f) do
                                if i == primaryType then
                                    a = 0
                                end
                            end
                        end
                        if type(e) == "number" then
                            if e == primaryType then
                                if e > 0 then
                                    a = (a - (a * (e / 100)))
                                else
                                    a = (a + (a * ((e * -1) / 100)))
                                end
                            end
                        else
                            for i, j in pairs(e) do
                                if i == primaryType then
                                    if j > 0 then
                                        a = (a - (a * (j / 100)))
                                    else
                                        a = (a + (a * ((j * -1) / 100)))
                                    end
                                end
                            end
                        end
                    end
                    doTargetCombatHealth(creature, attacker, primaryType, a, a, refs[primaryType])
                end
            end
        end
        for i = 17, 24 do -- deflect
            if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                if not attacker then
                    return primaryDamage, primaryType, secondaryDamage, secondaryType
                end
                if primaryType == res[i][2] or i == 24 then
                    local a = math.floor(primaryDamage * (creature:getStorageValue(5) / 100))
                    if attacker:isMonster() then
                   
                        local m = MonsterType(attacker:getName())
                        local e = m:getElementList()
                        local f = m:getCombatImmunities()
                        if type(f) == "number" then
                            if f == primaryType then
                                a = 0
                            end
                        else
                            for i, j in pairs(f) do
                                if i == primaryType then
                                    a = 0
                                end
                            end
                        end
                        if type(e) == "number" then
                            if e == primaryType then
                                if e > 0 then
                                    a = (a - (a * (e / 100)))
                                else
                                    a = (a + (a * ((e * -1) / 100)))
                                end
                            end
                        else
                            for i, j in pairs(e) do
                                if i == primaryType then
                                    if j > 0 then
                                        a = (a - (a * (j / 100)))
                                    else
                                        a = (a + (a * ((j * -1) / 100)))
                                    end
                                end
                            end
                        end
                    end
                    doTargetCombatHealth(creature, attacker, primaryType, a, a, refs[primaryType])
                    primaryDamage = (primaryDamage - (primaryDamage * (creature:getStorageValue(5) / 100)))
                    secondaryDamage = (secondaryDamage - (secondaryDamage * (creature:getStorageValue(5) / 100)))
                end
            end
        end
        for i = 25, 32 do
            if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                if primaryType == res[i][2] or i == 32 then
                    local a = math.floor(primaryDamage * (creature:getStorageValue(5) / 100))
                    creature:addHealth(a)
                    primaryDamage = (primaryDamage - (primaryDamage * (creature:getStorageValue(5) / 100)))
                    secondaryDamage = (secondaryDamage - (secondaryDamage * (creature:getStorageValue(5) / 100)))
                end
            end
        end
    end
    if primaryDamage == 0 and secondaryDamage == 0 and creature:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

 

 

Eu não entendi quase nada desse código, sou muito leigo ainda, caso vc consiga me dar uma luz ai como se disponibilizou, agradeço!

Eu fiz dessa forma abaixo e até o momento parece que funcionou, mas caso possa me ajudar a melhorar também, fico muito agradecido.

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
	if creature:isMonster() and primaryType == COMBAT_PHYSICALDAMAGE then
	local absorb = math.ceil(primaryDamage * 1)
	doCreatureAddHealth(attacker, -absorb)
	doCreatureAddHealth(cid, absorb)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
underewar    32
underewar

@tira94 Falta muita coisa para você chegar la ,mas não desanime vou deixar aqui o meu código de reflect caso não consiga instalar me fale para eu poder criar um topico

Spoiler

for i = 9, 16 do -- reflect
            if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                if not attacker then
                    return primaryDamage, primaryType, secondaryDamage, secondaryType
                end
                if primaryType == res[i][2] or i == 16 then
                    local a = math.floor(primaryDamage * (creature:getStorageValue(5) / 100))
                    if attacker:isMonster() then
                        local m = MonsterType(attacker:getName())
                        local e = m:getElementList()
                        local f = m:getCombatImmunities()
                        if type(f) == "number" then
                            if f == primaryType then
                                a = 0
                            end
                        else
                            for i, j in pairs(f) do
                                if i == primaryType then
                                    a = 0
                                end
                            end
                        end
                        if type(e) == "number" then
                            if e == primaryType then
                                if e > 0 then
                                    a = (a - (a * (e / 100)))
                                else
                                    a = (a + (a * ((e * -1) / 100)))
                                end
                            end
                        else
                            for i, j in pairs(e) do
                                if i == primaryType then
                                    if j > 0 then
                                        a = (a - (a * (j / 100)))
                                    else
                                        a = (a + (a * ((j * -1) / 100)))
                                    end
                                end
                            end
                        end
                    end
                    doTargetCombatHealth(creature, attacker, primaryType, a, a, refs[primaryType])
                end
            end
        end
        for i = 17, 24 do -- deflect
            if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                if not attacker then
                    return primaryDamage, primaryType, secondaryDamage, secondaryType
                end
                if primaryType == res[i][2] or i == 24 then
                    local a = math.floor(primaryDamage * (creature:getStorageValue(5) / 100))
                    if attacker:isMonster() then
                   
                        local m = MonsterType(attacker:getName())
                        local e = m:getElementList()
                        local f = m:getCombatImmunities()
                        if type(f) == "number" then
                            if f == primaryType then
                                a = 0
                            end
                        else
                            for i, j in pairs(f) do
                                if i == primaryType then
                                    a = 0
                                end
                            end
                        end
                        if type(e) == "number" then
                            if e == primaryType then
                                if e > 0 then
                                    a = (a - (a * (e / 100)))
                                else
                                    a = (a + (a * ((e * -1) / 100)))
                                end
                            end
                        else
                            for i, j in pairs(e) do
                                if i == primaryType then
                                    if j > 0 then
                                        a = (a - (a * (j / 100)))
                                    else
                                        a = (a + (a * ((j * -1) / 100)))
                                    end
                                end
                            end
                        end
                    end
                    doTargetCombatHealth(creature, attacker, primaryType, a, a, refs[primaryType])
                    primaryDamage = (primaryDamage - (primaryDamage * (creature:getStorageValue(5) / 100)))
                    secondaryDamage = (secondaryDamage - (secondaryDamage * (creature:getStorageValue(5) / 100)))
                end
            end
        end
        for i = 25, 32 do
            if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                if primaryType == res[i][2] or i == 32 then
                    local a = math.floor(primaryDamage * (creature:getStorageValue(5) / 100))
                    creature:addHealth(a)
                    primaryDamage = (primaryDamage - (primaryDamage * (creature:getStorageValue(5) / 100)))
                    secondaryDamage = (secondaryDamage - (secondaryDamage * (creature:getStorageValue(5) / 100)))
                end
            end
        end
    end
    if primaryDamage == 0 and secondaryDamage == 0 and creature:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
underewar    32
underewar
19 hours ago, tira94 said:

Eu não entendi quase nada desse código, sou muito leigo ainda, caso vc consiga me dar uma luz ai como se disponibilizou, agradeço!

Eu fiz dessa forma abaixo e até o momento parece que funcionou, mas caso possa me ajudar a melhorar também, fico muito agradecido.


function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
	if creature:isMonster() and primaryType == COMBAT_PHYSICALDAMAGE then
	local absorb = math.ceil(primaryDamage * 1)
	doCreatureAddHealth(attacker, -absorb)
	doCreatureAddHealth(cid, absorb)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

 

@tira94 claro que sim oque voce quer melhorar em seu código
?

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×