Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:GetUpdatedTargets

From RoR Wiki

UI Lua API · Target functions
Version: WAR 1.4.8

Returns information about the player's hostile, friendly and mouse-over targets.

targets = GetUpdatedTargets()

Arguments

None.

Returns

targets
table – Table keyed by target slot name. Nothing is returned if no target slot has an update.

The keys are:

  • "selfhostiletarget" – the player's hostile target.
  • "selffriendlytarget" – the player's friendly target.
  • "mouseovertarget" – the object under the mouse.

Each value is a target table with these fields:

Key Type Meaning
entityid number Object id of the target. 0 when the slot is empty.
name wstring Name of the target. L"" when the slot is empty.
healthPercent number Health percentage.
type number Object type. The stock UI compares it with SystemData.TargetObjectType values.
level number Level.
battleLevel number Battle (bolstered) level. For players, equal to level when there is no separate battle level.
tier number –
conType number –
isPvP boolean –
isNPC boolean –
mapPinType number –
difficultyMask number –
career number Career line of a player target. The stock UI reads it with TargetInfo:UnitCareer.
careerName wstring Career name of a player target.
npcTitle wstring Title of an NPC target, from the NPCTitles string table. L"" otherwise.
showHealthBar boolean –
sigilEntryId number –
relationshipColor table Table with r, g and b (number, 0–255).

Details

  • The client keeps four target slots; three of them are reported. A slot is only included when the client has an update for it.
  • When a target slot is empty, its table is still built, with entityid 0 and an empty name. The stock UI tests name ~= L"" to see whether a target exists.
  • If no slot has an update, nothing is returned. The stock TargetInfo:UpdateFromClient then clears all its cached units.
  • If there is no player object, or the Lua state is not available, the function returns nothing.
  • A comment in easystem_targetinfo/source/targetinfo.lua says the function returns no data until the next PLAYER_TARGET_UPDATED event.

Errors

None.

Example

From easystem_targetinfo/source/targetinfo.lua:

function TargetInfo:UpdateFromClient ()
    local targets = GetUpdatedTargets ()

    if (targets ~= nil) then
        for unitId, targetData in pairs (targets) do
            self:SetUnitInfo (unitId, targetData)
        end
    else
        self:ClearUnits ()
    end
end

See also