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

Lua Creaturescripts affects player

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
201
Reaction score
15
Hello good evening, I have this script that is causing me problems in the otbr tfs 1.3 canary version

The function of the script is for the monster that when hitting them with the determined element in this case energy, heals the monster.

But it is also affecting the player's, when hitting a player with energy what it does is heal them

script.lua
Lua:
local healEnergyDamage = CreatureEvent("healEnergyDamage")

function healEnergyDamage.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if primaryType == COMBAT_ENERGYDAMAGE or secondaryType == COMBAT_ENERGYDAMAGE then
        primaryType = COMBAT_HEALING
        primaryDamage = (primaryDamage + secondaryDamage)
        secondaryType = COMBAT_NONE
        secondaryDamage = 0
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
healEnergyDamage:register()
 
Solution
Lua:
local healEnergyDamage = CreatureEvent("healEnergyDamage")

function healEnergyDamage.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker:isPlayer() and creature:isMonster() then
        if primaryType == COMBAT_ENERGYDAMAGE then
            primaryType = COMBAT_HEALING
        end
        if secondaryType == COMBAT_ENERGYDAMAGE then
            secondaryType = COMBAT_HEALING
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

healEnergyDamage:register()
Lua:
local healEnergyDamage = CreatureEvent("healEnergyDamage")

function healEnergyDamage.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker:isPlayer() and creature:isMonster() then
        if primaryType == COMBAT_ENERGYDAMAGE then
            primaryType = COMBAT_HEALING
        end
        if secondaryType == COMBAT_ENERGYDAMAGE then
            secondaryType = COMBAT_HEALING
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

healEnergyDamage:register()
 
Solution
Back
Top