Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:IsTargetValid

From RoR Wiki

UI Lua API · Ability functions
Version: WAR 1.4.8

Checks the player's current target against an ability.

isTargetValid, hasTarget = IsTargetValid(abilityId)

Arguments

abilityId
number – Id of the ability. It is converted to a 16-bit integer.

Returns

isTargetValid
boolean – true if the ability can be used on the current target.
hasTarget
boolean – true if the target slot the ability uses (hostile or friendly) holds an object.

Details

  • Which target slot is used depends on the ability's targetType (see GetAbilityData): target types 0, 2, 3 and 5 use the friendly target, all others the hostile target.
  • The first value comes from the client's target check: it looks at the target's state and type and at the ability's range. Abilities with target type 0 always pass.
  • Both values are false for an unknown ability and when there is no player object.
  • The stock morale bar shows the ability text in red only when a target exists and is not valid: isTargetValid or (hasTarget == false).

Errors

None besides the generic Invalid Parameters message when the argument is missing or not a number.

Example

From ea_moralewindow/source/moralewindow.lua:

local isTargetValid, hasRequiredUnitTypeTargeted = IsTargetValid (abilityId)

local isTargetValid = (isTargetValid or (hasRequiredUnitTypeTargeted == false))

See also