• 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+ onHealthChange bypasses creature resistances/immunities and 50% PVP Damage

Leo32

Getting back into it...
Joined
Sep 21, 2007
Messages
987
Solutions
14
Reaction score
532
Title.
Basically I have a crit/elemental damage system all rigged around onHealthChange()

The issue is this seems to be making damage absolute, bypassing monster resistances/immunities and even the halving of damage against other players.

Anyone got insight as to why?
My best guess is that primaryDamage and secondaryDamage already have adjusted numbers for monster resistences/immunities before entering onHealthChange.

So I'd need to recalculate resistences and whatnot in the script itself? is that even possible?

If you would like to see this yourself:
add this to creaturescripts.xml
Code:
<event type="healthchange" name="CombatModifiers" script="combatmodifiers.lua"/>

add combatmodifiers.lua to /scripts and start messing with the output:
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    print(primaryDamage)
    -- primaryDamage = 10
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Post automatically merged:


Solved.
Can get monster resistance data.

List all resistances:
Lua:
local resistances = creature:getType():getElementList()
        for k,v in pairs(resistances) do
            print(k .. ' ' .. v)
        end

Because the element types are represented by a number that aligns with the COMBAT_ELEMENTDAMAGE
You can use the following to find a specific resistance:

Find resistance for specific element:
Lua:
local resistances = creature:getType():getElementList()
print(resistances[COMBAT_FIREDAMAGE])
print(resistances[COMBAT_ICEDAMAGE])
print(resistances[COMBAT_ENERGYDAMAGE])
 
Last edited:
Back
Top