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

Solved I can only see healing value on 5 monsters

lexus21

Active Member
Joined
Dec 14, 2022
Messages
88
Reaction score
25
I have scripts for healing monsters within 3 squares around the player. I stand in the middle of, say, 20 monsters, only the first 5 show the healing value (in orange)

I also checked mass heal (slightly modified - so that it heals monsters) and exactly the same behavior.

How to make all monsters within the player's range that the player heals show their healing value? Let's say I heal 10 monsters, then 10 shows the healing value.

Lua:
function getCustomSpectators(position, multifloor, showPlayers, showMonsters, showNPCs, minRangeX, maxRangeX, minRangeY, maxRangeY)
    -- getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]])
    local spectators = Game.getSpectators(position, multifloor, false, minRangeX, maxRangeX, minRangeY, maxRangeY)
    customSpectatorsList = {}
    for _, spectatorCreature in ipairs(spectators) do
        if (showPlayers and spectatorCreature:isPlayer()) or
            (showMonsters and spectatorCreature:isMonster()) or
            (showNPCs and spectatorCreature:isNpc()) then
            table.insert(customSpectatorsList, spectatorCreature)
        end
    end
    return customSpectatorsList
end

Code:
function healMonstersNearPlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end

    player:setStorageValue(PlayerStorageKeys.healingBool, addEvent(healMonstersNearPlayer, 1000, player:getId())) 
    local position = player:getPosition() 
    local healingRadius = 3
    local healingAmount =  10 
    local monsters = getCustomSpectators(position, false, false, true, false, healingRadius, healingRadius, healingRadius, healingRadius)
    for _, monster in ipairs(monsters) do
        monster:addHealth(healingAmount)
    end
    return true

end
Post automatically merged:

solved
optimization level to --> None
 
Back
Top