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

RevScripts onHealthChange

alcapone

Member
Joined
Jan 13, 2021
Messages
246
Reaction score
19
I have some problems when the player is using imbu the damage that is reflected in the boss he is receiving the damage + the healing of the imbu

: attempt to index local 'attacker' (a nil value

and I'm getting this error in the log


edit
if the player is attacking the boss and uses exura vita for example the cure is sent to the boss

Lua:
local config = {
    {
   bossName = "The Pale Worm",
   bossPosition = Position(33805, 31505, 14)
    }
}

local function doCombat(creature, boss, combatType, damage)
    doTargetCombatHealth(creature, boss, combatType, -damage, -damage, CONST_ME_NONE, ORIGIN_SPELL)

end

local ThePaleWormReceiveDmg1 = CreatureEvent("ThePaleWormReceiveDmg")

function ThePaleWormReceiveDmg1.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)


    for _, info in pairs(config) do
        local foundBoss = Monster(info.foundBoss)
        if foundBoss then
            doCombat(attacker:getId(), foundBoss, primaryType, primaryDamage)
            doCombat(attacker:getId(), foundBoss, secondaryType, secondaryDamage)
           
        else
            local spectators =
             Game.getSpectators(info.bossPosition, false, false, 14, 14, 14, 14)
           
            for __, spectator in pairs(spectators) do
                if spectator ~= creature then
                    if spectator:getName() == info.bossName then
                             
                        doCombat(attacker:getId(), spectator, primaryType, primaryDamage)
                        doCombat(attacker:getId(), spectator, secondaryType, secondaryDamage)
                       
                        info.foundBoss = spectator:getId()
                        break
                    end

                end
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
ThePaleWormReceiveDmg1:register()
 
Last edited:
Thought it might be a behaviour OP would wanna avoid, but probably np xD
To avoid this behavior completely it is required to modify the sources, since you need to know beforehand how many creatures exist in the area affected by the spell, and then randomly take a monster that will be the one that triggers the feedback and adding the others monsters in a table and preventing them from going through the same process, basically the same thing i did in the script but in the sources
 
Back
Top