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

TFS 1.X+ Magic Shield (Utamo Vita) - Double DMG?

Galatea

Banned User
Joined
Sep 8, 2022
Messages
41
Reaction score
15
Location
Germany
Hello everyone, I discovered a strange bug on the server test lately. Namely, the point is that when a player has the utamo vita effect, whether from a spell or from the ring, it does not matter, he takes twice as much damage from players / monsters. Where should I look for the problem? This is the first time I've ever had something like this.

TFS 1.4.2 10.98
 
Solution
I don't really see a problem. Try using this..

Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker or not creature then 
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer()) then
        primaryDamage = 0
        if secondaryDamage > 0 then
            secondaryDamage = 0
        end
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end...
Check your creaturescripts for any

Lua:
onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)

Did you add anything using this?
 
Check your creaturescripts for any

Lua:
onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)

Did you add anything using this?
Yeah i found something like this in my dodgeCritical system:
Lua:
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
  
    if (not attacker or not creature) then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
  
    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer())  then
        primaryDamage = 0
        secondaryDamage = 0
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
how to make this both working well?
 
it's just a tip of an iceberg

tfs does weird looping through combat function, there is no clear distinction between pre-mitigation, post-mitigation and on-hit
onHealthChange doesn't even work properly together with mana shield.
 
it's just a tip of an iceberg

tfs does weird looping through combat function, there is no clear distinction between pre-mitigation, post-mitigation and on-hit
onHealthChange doesn't even work properly together with mana shield.
after working with TFS for a long time, I noticed that the damage on TFS is nice broken. Well, first I would have to deal with the problem with the double damage, then start to dig deeper step by step.
 
Check for any codes with healthChange also...

Lua:
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if (not attacker or not creature) then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
 
    if primaryType == COMBAT_HEALING then
         return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer())  then
        primaryDamage = 0
        if secondaryDamage > 0 then
              secondaryDamage = 0
        end
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Check for any codes with healthChange also...

Lua:
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if (not attacker or not creature) then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
 
    if primaryType == COMBAT_HEALING then
         return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer())  then
        primaryDamage = 0
        if secondaryDamage > 0 then
              secondaryDamage = 0
        end
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Its my full script
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)

    if (not attacker or not creature) then 
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer()) then
        primaryDamage = 0
        secondaryDamage = 0
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end

    if (attacker:isPlayer() and (attacker:getCriticalLevel() * 3) >= math.random (0, 1000)) then
        primaryDamage = primaryDamage + math.ceil(primaryDamage * CRITICAL.PERCENT)
        attacker:say("CRITICAL!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONHIT)
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    
    if (not attacker or not creature) then 
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    
    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer())  then
        primaryDamage = 0
        secondaryDamage = 0
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
I don't really see a problem. Try using this..

Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker or not creature then 
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer()) then
        primaryDamage = 0
        if secondaryDamage > 0 then
            secondaryDamage = 0
        end
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end

    if (attacker:isPlayer() and (attacker:getCriticalLevel() * 3) >= math.random (0, 1000)) then
        primaryDamage = primaryDamage + math.ceil(primaryDamage * CRITICAL.PERCENT)
        attacker:say("CRITICAL!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONHIT)
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker or not creature then 
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    
    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    
    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer())  then
        primaryDamage = 0
        if secondaryDamage > 0 then
            secondaryDamage = 0
        end
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end
    
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Solution
I don't really see a problem. Try using this..

Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker or not creature then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer()) then
        primaryDamage = 0
        if secondaryDamage > 0 then
            secondaryDamage = 0
        end
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end

    if (attacker:isPlayer() and (attacker:getCriticalLevel() * 3) >= math.random (0, 1000)) then
        primaryDamage = primaryDamage + math.ceil(primaryDamage * CRITICAL.PERCENT)
        attacker:say("CRITICAL!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONHIT)
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker or not creature then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
   
    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
   
    if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer())  then
        primaryDamage = 0
        if secondaryDamage > 0 then
            secondaryDamage = 0
        end
        creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
        creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
    end
   
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
I dont know how, but its working thank you! Could you help me understand your changes to the script?
 
It was probably this part

Lua:
if secondaryDamage > 0 then
            secondaryDamage = 0
        end

You were setting it to 0 even if secondaryType wasn't set which could cause a problem. Im not completely sure but I figured it was something like that.

So just added a check to see if its even being passed.

Then I added this because you don't want it to happen when healing is happening
Lua:
 if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
 
Back
Top