Ir para conteúdo

Pergunta

shocks    2
shocks

Base:  TFS 1.3 Custom

 

Pergunta: Estou com problema no life steal e mana steal no sistema de imbuement com armas de dano elemental, a life steal e mana steal está recuperando a % do nivel atual do imbuement apenas o dano fisico da arma dado 2x ao invez de recuperar 1x a % do dano fisico e 1x a % do dano elemental.

 

 

Parte do player.lua em events que acho que está o problema:

Spoiler

function Player:onUseWeapon(normalDamage, elementType, elementDamage)
    -- Imbuement
    local weapon = self:getSlotItem(CONST_SLOT_LEFT)
    if not weapon or weapon:getType():getWeaponType() == WEAPON_SHIELD then
        weapon = self:getSlotItem(CONST_SLOT_RIGHT)
        if not weapon or weapon:getType():getWeaponType() == WEAPON_SHIELD then
            weapon = nil
        end
    end

    for slot = 1, 10 do
        local nextEquip = self:getSlotItem(slot)
        if nextEquip and nextEquip:getType():getImbuingSlots() > 0 then
            for i = 1, nextEquip:getType():getImbuingSlots() do
                local slotEnchant = nextEquip:getSpecialAttribute(i)
                if (slotEnchant and type(slotEnchant) == 'string') then
                    local percentDamage, enchantPercent = 0, nextEquip:getImbuementPercent(slotEnchant)
                    local typeEnchant = nextEquip:getImbuementType(i) or ""
                    if (typeEnchant ~= "" and typeEnchant ~= "skillShield" and not typeEnchant:find("absorb") and typeEnchant ~= "speed") then
                        useStaminaImbuing(self:getId(), nextEquip:getUniqueId())
                    end

                    if (typeEnchant ~= "hitpointsleech" and typeEnchant ~= "manapointsleech" and typeEnchant ~= "criticaldamage" 
                        and typeEnchant ~= "skillShield" and typeEnchant ~= "magiclevelpoints" and not typeEnchant:find("absorb") and typeEnchant ~= "speed") then
                        local weaponType = nextEquip:getType():getWeaponType()
                        if weaponType ~= WEAPON_NONE and weaponType ~= WEAPON_SHIELD and weaponType ~= WEAPON_AMMO then
                            percentDamage = normalDamage*(enchantPercent/100)
                            normalDamage = normalDamage - percentDamage
                            elementDamage = nextEquip:getType():getAttack()*(enchantPercent/100)
                        end
                    end

                    if (typeEnchant == "hitpointsleech") then
                        local healAmountHP = normalDamage*(enchantPercent/100)
                        self:addHealth(math.abs(healAmountHP))
                    elseif (typeEnchant == "manapointsleech") then
                        local healAmountMP = normalDamage*(enchantPercent/100)
                        self:addMana(math.abs(healAmountMP))
                    end

                    if (typeEnchant == "firedamage") then
                        elementType = COMBAT_FIREDAMAGE
                    elseif (typeEnchant == "earthdamage") then
                        elementType = COMBAT_EARTHDAMAGE
                    elseif (typeEnchant == "icedamage") then
                        elementType = COMBAT_ICEDAMAGE
                    elseif (typeEnchant == "energydamage") then
                        elementType = COMBAT_ENERGYDAMAGE
                    elseif (typeEnchant == "deathdamage") then
                        elementType = COMBAT_DEATHDAMAGE
                    end
                end
            end
        end
    end
    
    return normalDamage, elementType, elementDamage
end

function Player:onCombatSpell(normalDamage, elementDamage, elementType, changeDamage)
    -- Imbuement
    local weapon = self:getSlotItem(CONST_SLOT_LEFT)
    if not weapon or weapon:getType():getWeaponType() == WEAPON_SHIELD then
        weapon = self:getSlotItem(CONST_SLOT_RIGHT)
        if not weapon or weapon:getType():getWeaponType() == WEAPON_SHIELD then
            weapon = nil
        end
    end

    if normalDamage < 0 then
        for slot = 1, 10 do
            local nextEquip = self:getSlotItem(slot)
            if nextEquip and nextEquip:getType():getImbuingSlots() > 0 then
                for i = 1, nextEquip:getType():getImbuingSlots() do
                    local slotEnchant = nextEquip:getSpecialAttribute(i)
                    if (slotEnchant and type(slotEnchant) == 'string') then
                        local percentDamage, enchantPercent = 0, nextEquip:getImbuementPercent(slotEnchant)
                        local typeEnchant = nextEquip:getImbuementType(i) or ""
                        if (typeEnchant ~= "" and typeEnchant ~= "skillShield" and not typeEnchant:find("absorb") and typeEnchant ~= "speed") then
                            useStaminaImbuing(self:getId(), nextEquip:getUniqueId())
                        end

                        if (typeEnchant == "firedamage" or typeEnchant == "earthdamage" or typeEnchant == "icedamage" or typeEnchant == "energydamage" or typeEnchant == "deathdamage") then
                            local weaponType = nextEquip:getType():getWeaponType()
                            if weaponType ~= WEAPON_NONE and weaponType ~= WEAPON_SHIELD and weaponType ~= WEAPON_AMMO then
                                percentDamage = normalDamage*(enchantPercent/100)
                                normalDamage = normalDamage - percentDamage
                                elementDamage = nextEquip:getType():getAttack()*(enchantPercent/100)
                            end
                        end

                        if (typeEnchant == "firedamage") then
                            elementType = COMBAT_FIREDAMAGE
                        elseif (typeEnchant == "earthdamage") then
                            elementType = COMBAT_EARTHDAMAGE
                        elseif (typeEnchant == "icedamage") then
                            elementType = COMBAT_ICEDAMAGE
                        elseif (typeEnchant == "energydamage") then
                            elementType = COMBAT_ENERGYDAMAGE
                        elseif (typeEnchant == "deathdamage") then
                            elementType = COMBAT_DEATHDAMAGE
                        end
                    end
                end
            end
        end
    end

    return normalDamage, elementDamage, elementType, changeDamage
end

 

Acho que o problema seria a parte de : 

 

if (typeEnchant == "hitpointsleech") then
                        local healAmountHP = normalDamage*(enchantPercent/100)
                        self:addHealth(math.abs(healAmountHP))
                    elseif (typeEnchant == "manapointsleech") then
                        local healAmountMP = normalDamage*(enchantPercent/100)
                        self:addMana(math.abs(healAmountMP))
                    end


Porem ja tentei alterar umas coisas com um amigo e nada funcionou.

 

Imagem:

Spoiler

HsSWQKh.png

B5wONvW.png

Se alguem puder dar uma ajuda a resolver este problema agradeço.

Compartilhar este post


Link para o post
Compartilhar em outros sites

6 respostass a esta questão

Recommended Posts

  • 0
shocks    2
shocks

Pronto, correção no weapons.cpp

Troquei este:

damage.primary.type = params.combatType;
damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier) / 100;
damage.secondary.type = getElementType();
int32_t tmpDamage = 0;
if (damage.origin == ORIGIN_MELEE) {
	g_events->eventPlayerOnUseWeapon(player, damage.primary.value, damage.secondary.type, tmpDamage);
}

damage.secondary.value = getElementDamage(player, target, item, tmpDamage, damage.secondary.type);
Combat::doCombatHealth(player, target, damage, params);


Por este:
 

damage.primary.type = params.combatType;
damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier) / 100;
damage.secondary.value = getElementDamage(player, target, item, 0, damage.secondary.type);
damage.secondary.type = getElementType();
if ((damage.origin == ORIGIN_MELEE) + (damage.origin == ORIGIN_RANGED)) {
    g_events->eventPlayerOnUseWeapon(player, damage.primary.value, damage.secondary.type, damage.secondary.value);
}

Combat::doCombatHealth(player, target, damage, params);



E em data/events/players.lua

Troquei este:

if (typeEnchant == "hitpointsleech") then
                        local healAmountHP = normalDamage*(enchantPercent/100)
                        self:addHealth(math.abs(healAmountHP))
                    elseif (typeEnchant == "manapointsleech") then
                        local healAmountMP = normalDamage*(enchantPercent/100)
                        self:addMana(math.abs(healAmountMP))
                    end



Por este:

 

if (typeEnchant == "hitpointsleech") then
	local elementHealHP = elementDamage*(enchantPercent/100)
	local healHP = elementHealHP
  	self:addHealth(math.abs(healHP))
elseif (typeEnchant == "manapointsleech") then
	local elementHealMP = elementDamage*(enchantPercent/100)
	local healMP = elementHealMP
  	self:addMana(math.abs(healMP))
end



 

 

@GryLLo Obrigado pela ajuda!!! xD

Editado por shocks
Acrescimo de de Range Attack

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 1
GryLLo    19
GryLLo

Coé @shocks belê?

O parâmetro onde vem o dano elemental nessas funções aí é o elementDamage.
Se o problema for só esse aí, é só fazer assim:

if (typeEnchant == "hitpointsleech") then
  	local normalHealHP = normalDamage*(enchantPercent/100)
  	local elementHealHP = elementDamage*(enchantPercent/100)
	local healHP = normalHealHP + elementHealHP
  	self:addHealth(math.abs(healHP))
elseif (typeEnchant == "manapointsleech") then
  	local normalHealMP = normalDamage*(enchantPercent/100)
	local elementHealMP = elementDamage*(enchantPercent/100)
	local healMP = normalHealMP + elementHealMP
  	self:addMana(math.abs(healMP))
end

É nósssssssssssssss! :)

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 1
GryLLo    19
GryLLo

Bom, acredito que o problema esteja no .cpp então, weapons.cpp, pra ser mais específico.
Nos seu servidor parece que não chega o valor pra elementDamage, lembro de ter mexido nisso há um tempo atrás.

Vá até o weapons.cpp e procure por eventPlayerOnUseWeapon, e se não encontrar, bicho, vai ter que vasculhar até achar onde o OnUseWeapon está sendo chamado no .cpp e onde o .cpp tá chamando o OnUseWeapon do .lua, prosseguindo, se encontrar, faça essa alteração:


Isso aqui:

damage.primary.type = params.combatType;
damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier) / 100;
damage.secondary.type = getElementType();
int32_t tmpDamage = 0;
if (damage.origin == ORIGIN_MELEE) {
	g_events->eventPlayerOnUseWeapon(player, damage.primary.value, damage.secondary.type, tmpDamage);
}

damage.secondary.value = getElementDamage(player, target, item, tmpDamage, damage.secondary.type);
Combat::doCombatHealth(player, target, damage, params);


Vira isso aqui:

damage.primary.type = params.combatType;
damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier) / 100;
damage.secondary.type = getElementType();
damage.secondary.value = getElementDamage(player, target, item, 0, damage.secondary.type);
if (damage.origin == ORIGIN_MELEE) {
	g_events->eventPlayerOnUseWeapon(player, damage.primary.value, damage.secondary.type, damage.secondary.value);
}

Combat::doCombatHealth(player, target, damage, params);


Eu não testei a alteração aí acima, se ele estiver batendo pouco no dano elemental ou estiver saindo algo errado ou estranho, faça testes no valor de: damage.secondary.value e verifique também o funcionamento da função getElementDamage e vai vasculhando aí.

Uns abraços!

Editado por GryLLo

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
shocks    2
shocks

Sem sucesso 

27 minutos atrás, GryLLo disse:

Coé @shocks belê?

O parâmetro onde vem o dano elemental nessas funções aí é o elementDamage.
Se o problema for só esse aí, é só fazer assim:


if (typeEnchant == "hitpointsleech") then
  	local normalHealHP = normalDamage*(enchantPercent/100)
  	local elementHealHP = elementDamage*(enchantPercent/100)
	local healHP = normalHealHP + elementHealHP
  	self:addHealth(math.abs(healHP))
elseif (typeEnchant == "manapointsleech") then
  	local normalHealMP = normalDamage*(enchantPercent/100)
	local elementHealMP = elementDamage*(enchantPercent/100)
	local healMP = normalHealMP + elementHealMP
  	self:addMana(math.abs(healMP))
end

É nósssssssssssssss! :)

se não foi isso pode ser que o problema seja na formula do elemental damage??

 

if (typeEnchant ~= "hitpointsleech" and typeEnchant ~= "manapointsleech" and typeEnchant ~= "criticaldamage" 
                        and typeEnchant ~= "skillShield" and typeEnchant ~= "magiclevelpoints" and not typeEnchant:find("absorb") and typeEnchant ~= "speed") then
                        local weaponType = nextEquip:getType():getWeaponType()
                        if weaponType ~= WEAPON_NONE and weaponType ~= WEAPON_SHIELD and weaponType ~= WEAPON_AMMO then
                            percentDamage = normalDamage*(enchantPercent/100)
                            normalDamage = normalDamage - percentDamage
                            elementDamage = nextEquip:getType():getAttack()*(enchantPercent/100)
                        end

 e aqui 

 

if (typeEnchant == "firedamage" or typeEnchant == "earthdamage" or typeEnchant == "icedamage" or typeEnchant == "energydamage" or typeEnchant == "deathdamage") then
                            local weaponType = nextEquip:getType():getWeaponType()
                            if weaponType ~= WEAPON_NONE and weaponType ~= WEAPON_SHIELD and weaponType ~= WEAPON_AMMO then
                                percentDamage = normalDamage*(enchantPercent/100)
                                normalDamage = normalDamage - percentDamage
                                elementDamage = nextEquip:getType():getAttack()*(enchantPercent/100)
                            end

??

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
GryLLo    19
GryLLo

Não, não é aí o problema, era pra funcionar o que te enviei.

Tenta utilizar um print(elementDamage) no início de ambas as funções:

8 horas atrás, shocks disse:

onUseWeapon

 

8 horas atrás, shocks disse:

onCombatSpell

O cálculo de dano real e o imbuiment são feitos nos arquivos em .cpp, esse aí é um incremento pra que o admin consiga alterar os danos caso queira com mais praticidade, tenta printar o que está vindo nos parâmetros NormalDamage e no ElementDamage, ataques com WANDS/RODS são considerados full normal damage, sempre que for mudar algo aí, mude em ambas as funções acima.

Compartilhar este post


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

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×