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

Reverse Damage Mechanic

azzmckay6

Member
Joined
Aug 30, 2020
Messages
59
Reaction score
10
Hello guys, im looking for some help to create a script that is as in the title. Id like to have a script that reverses usual damage, for example:

When a player attacks said monster, the usual damage infact heals the monster for however much the player hits. The only way for the player to kill the monster is to infact HEAL it, for example using UH/IH or mass healing spell.

many thanks
 
Hello guys, im looking for some help to create a script that is as in the title. Id like to have a script that reverses usual damage, for example:

When a player attacks said monster, the usual damage infact heals the monster for however much the player hits. The only way for the player to kill the monster is to infact HEAL it, for example using UH/IH or mass healing spell.

many thanks
You should always state what version of server you are using so we know what function we can use. That said if you're using newer server versions, easiest way I can see to do this is to use onHealthChange creaturescript and just reverse the negative to a positive with a function like math.abs and change the damage type.
 
Last edited:
You should always state what version of server you are using so we know what function we can use. That said if you're using newer server versions, easiest way I can see to do this is to use onHealthChange creaturescript and just reverse the negative to a positive with a function like math.abs.
Using tfs 1.4 mate.

Would appreciate any help possible
 
Try something like this
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    
    if creature:getName() == 'Demon' then
        if primaryType == COMBAT_HEALING then
            primaryType = COMBAT_ENERGYDAMAGE -- choose the damage that you want here
        else
            primaryType = COMBAT_HEALING
            creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            creature:addHealth(primaryDamage)
        end
    end
    
    return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end

Then add this to creaturescript.xml
XML:
<event type="healthchange" name="ReverseDamage" script="ReverseDamage.lua" />

And this inside login.lua
Lua:
player:registerEvent("ReverseDamage")
 
Back
Top