Skip to content

Character

The Character library contains utility methods relating to characters. The vast majority of them are available on both contexts.

CharacterLib Class

Inherits from Library.

Events and Hooks

StatusApplied (event)

TODO move somewhere else, since victim could be an item

@field SourceHandle EntityHandle

@field Victim Character|Item

@field Status EclStatus|EsvStatus

ItemEquipped (event)

@field Character Character

@field Item Item

@field Slot ItemSlot

CreateEquipmentVisuals (hook)

Client-only.

@field Character EclCharacter

@field Item EclItem

@field Request EclEquipmentVisualSystemSetParam Hookable.

@field RawEvent EclLuaCreateEquipmentVisualsRequestEvent

GetSkillAPCost (hook)

Fired from Character.GetSkillAPCost() if Ext.Stats.Math.GetSkillAPCost() is unavailable.

@field Character CDivinityStats_Character

@field Skill StatsLib_StatsEntry_SkillData

@field AiGrid EocAiGrid

@field Position vec3 WorldPos of the character.

@field Radius number AI bounds size of the character.

@field AP integer Hookable. Defaults to the value from `Game.Math.GetSkillAPCost()`

@field ElementalAffinity boolean Hookable. Defaults to the value from `Game.Math.GetSkillAPCost()`

Methods

CanUseSkill
function CharacterLib.CanUseSkill(char, skillID, itemSource)
   -> boolean

Returns whether char can enter preparation state for a skill.

@param char Character

@param skillID string

@param itemSource Item?

Get
function CharacterLib.Get(identifier, isFlashHandle)
   -> Character

@param identifier GUID|PrefixedGUID|NetId|EntityHandle

@param isFlashHandle boolean? If true, the identifier will be passed through DoubleToHandle() first.

GetActionPoints
function CharacterLib.GetActionPoints(char)
   -> integer, integer -- Current, maximum

@param char Character

GetCombatID
function CharacterLib.GetCombatID(char)
   -> integer?, integer? -- The combat ID and team ID. `nil` if the character is not in combat. This is different from the osi query, which returns a reserved value.

Returns the combat ID and team ID of char, if any.

@param char Character

GetCurrentSkill
function CharacterLib.GetCurrentSkill(char)
   -> string? -- `nil` if the character has no active skill state.

Returns the ID of the skill that char is preparing or casting.

@param char Character

GetDynamicStat
function CharacterLib.GetDynamicStat(char, statName)

@param char Character

@param statName string

GetEquippedItems
function CharacterLib.GetEquippedItems(char)
   -> table<ItemSlot, EclItem>

Returns the equipped items of char, per slot.

@param char Character

GetExperience
function CharacterLib.GetExperience(char)
   -> integer

Returns the current experience points of char.

@param char Character

GetExperienceRequiredForLevel
function CharacterLib.GetExperienceRequiredForLevel(targetLevel)
   -> integer -- Experience points.

Returns the cumulative experience required to reach a level.

@param targetLevel integer

GetGender
function CharacterLib.GetGender(char)
   -> Gender

Returns the gender of char.

@param char Character

GetHighestPartyAbility
function CharacterLib.GetHighestPartyAbility(char, ability)
   -> integer

Gets the highest stat score of all characters in char's party.

@param char Character

@param ability string Needs to be a property indexable in char.Stats

GetInitiative
function CharacterLib.GetInitiative(char)
   -> integer

Returns the initiative of char.

@param char Character

GetLevel
function CharacterLib.GetLevel(char)
   -> integer

Returns the level of char.

@param char Character

GetMaxCarryWeight
function CharacterLib.GetMaxCarryWeight(char)
   -> integer -- In "grams"

Returns the maximum carry weight of char.

@param char Character

GetMovement
function CharacterLib.GetMovement(char)
   -> number -- In centimeters.

Returns the calculated movement stat of a character.

@param char Character

GetOwner
function CharacterLib.GetOwner(char)
   -> Character?

Returns the character's owner, if it is a summon or party follower(?).

@param char Character

GetPartyMembers
function CharacterLib.GetPartyMembers(char) -- (Server-only)
   -> EsvCharacter[] Includes the char passed per param.-- the char passed per param.

Returns a list of party members of char's party. Char must be a player.

@param char EsvCharacter

GetPartyMembers
function CharacterLib.GetPartyMembers(char) -- (Client-only)
   -> EclCharacter[] Includes the char passed per param.-- the char passed per param.

Returns a list of party members of char's party. Char must be a player.

Depends on PlayerInfo.

@param char EclCharacter

GetRace
function CharacterLib.GetRace(char)
   -> Race?

Returns the current race of char.

Checks racial tags.

@param char Character

GetRacePreset
function CharacterLib.GetRacePreset(char)
   -> Character_creationRaceDesc? -- `nil` if the character has no PlayerData.

Returns the race preset ID of a character.

@param char Character Should be a player.

GetRealRace
function CharacterLib.GetRealRace(char)
   -> Race?

Returns the original race of a player char, before any transforms.

@param char Character Must be tagged with "REALLY_{Race}"

GetResistance
function CharacterLib.GetResistance(char, damageType, baseValuesOnly)
   -> integer

Returns the computed resistance value of char.

@param char Character

@param damageType DamageType

@param baseValuesOnly boolean? If `true`, base value will be returned. Defaults to `false`.

GetSkill
function CharacterLib.GetSkill(char, skillID)
   -> (EclSkill|EsvSkill)? -- `nil` if the character does not have the skill in any way.

Returns the record for a skill.

@param char Character

@param skillID skill

GetSkillAPCost
function CharacterLib.GetSkillAPCost(char, skillID)
   -> integer, boolean -- AP cost and whether elemental affinity was applied.

Returns the character's AP cost to cast a skill.

@param char Character

@param skillID skill

GetSkillBarRowContents
function CharacterLib.GetSkillBarRowContents(char, row, slotsPerRow)
   -> EocSkillBarItem[]

Returns the contents of a character's skillbar row.

@param char Character Must be a player.

@param row integer

@param slotsPerRow integer? Defaults to 29.

GetSkillState
function CharacterLib.GetSkillState(char)
   -> (EclSkillState|EsvSkillState)?

Returns the current skill state of char.

On the server, this can only return the state while using the skill. Preparation state cannot be accessed.

@param char Character

GetSourcePoints
function CharacterLib.GetSourcePoints(char)
   -> integer, integer -- Current and maximum points.

Returns the current and maximum source points of char.

@param char Character

GetStatusByHandle
function CharacterLib.GetStatusByHandle(char, handle)
   -> EclStatus|EsvStatus

Returns a status by handle.

@param char Character

@param handle EntityHandle

GetStatusByNetID
function CharacterLib.GetStatusByNetID(char, netID)
   -> EclStatus|EsvStatus

Returns a status on char by its net ID.

@param char Character

@param netID NetId

GetStatusesFromItems
function CharacterLib.GetStatusesFromItems(char) -- (Client-only)
   -> CharacterLib_StatusFromItem[]

Returns a list of statuses the character has from its equipped items.

@param char Character

HasDagger
function CharacterLib.HasDagger(char)
   -> boolean

Returns whether char has a dagger equipped in either slot.

@param char Character

HasImmunity
function CharacterLib.HasImmunity(char, immunityName)
   -> boolean

Returns wether char has a certain immunity.

@param char Character

@param immunityName StatsLib_ImmunityID

HasMeleeWeapon
function CharacterLib.HasMeleeWeapon(char)
   -> boolean

Returns whether char has a melee weapon equipped in either slot.

@param char Character

HasOwner
function CharacterLib.HasOwner(char)
   -> boolean

Returns whether char has an owner.

@param char Character

HasRangedWeapon
function CharacterLib.HasRangedWeapon(char)
   -> boolean

Returns whether char has a bow or crossbow equipped.

@param char Character

HasShield
function CharacterLib.HasShield(char)
   -> boolean

Returns whether char has a shield equipped.

@param char Character

IsActive
function CharacterLib.IsActive()
   -> boolean

Returns whether char is currently the active character of any player.

IsCastingSkill
function CharacterLib.IsCastingSkill(char)
   -> boolean

Returns whether char is casting a skill.

@param char Character

IsDead
function CharacterLib.IsDead(char)
   -> boolean

Returns true if the character is dead.

@param char Character

IsDisarmed
function CharacterLib.IsDisarmed(char)
   -> boolean

Returns whether char is disarmed.

@param char Character

IsIgnoredByAI
function CharacterLib.IsIgnoredByAI(char)
   -> boolean

Returns whether char is ignored by AI.

@param char Character

IsInCombat
function CharacterLib.IsInCombat(char)
   -> boolean

Returns whether the character is in a combat.

@param char Character

IsInStealth
function CharacterLib.IsInStealth(char)
   -> boolean

Returns whether char is sneaking or invisible.

@param char Character

IsInvisible
function CharacterLib.IsInvisible(char)
   -> boolean

Returns whether char is invisible - as in, has the INVISIBLE status.

@param char Character

IsMale
function CharacterLib.IsMale(char)
   -> boolean

Returns true if char is male.

@param char Character

IsMuted
function CharacterLib.IsMuted(char)
   -> boolean

Returns whether char is muted.

@param char Character

IsOrigin
function CharacterLib.IsOrigin(char)
   -> boolean

Returns whether char is a non-generic origin.

@param char Character

IsPlayer
function CharacterLib.IsPlayer(char)
   -> boolean

Returns whether char is a player.

A player is any character that is controllable by the users,

including summons and party followers.

@param char Character

IsPreferredByAI
function CharacterLib.IsPreferredByAI(char)
   -> boolean

@param char Character

IsPreparingSkill
function CharacterLib.IsPreparingSkill(char)
   -> boolean

Returns whether char is preparing a skill.

@param char Character

IsSkillInnate
function CharacterLib.IsSkillInnate(char, skillID)
   -> boolean

Returns whether a skill is innate to a character.

Returns false if the character doesn't have the skill in any way.

@param char Character

@param skillID string

IsSkillLearnt
function CharacterLib.IsSkillLearnt(char, skillID)
   -> boolean

Returns whether char has a skill learnt. Returns true for innate skills.

@param char Character

@param skillID string

IsSkillMemorized
function CharacterLib.IsSkillMemorized(char, skillID)
   -> boolean

Returns whether char has a skill memorized. Returns true for innate skills.

@param char Character

@param skillID string

IsSneaking
function CharacterLib.IsSneaking(char)
   -> boolean

Returns whether char is sneaking.

@param char Character

IsSummon
function CharacterLib.IsSummon(char)
   -> boolean

Returns true if char is a summon.

@param char Character

IsUndead
function CharacterLib.IsUndead(char)
   -> boolean

Returns true if char is undead.

@param char Character

IsUnpreferredByAI
function CharacterLib.IsUnpreferredByAI(char)
   -> boolean

Returns whether char is unpreferred by AI.

@param char Character

IsUnsheathed
function CharacterLib.IsUnsheathed(char)
   -> boolean

Returns whether char has their weapon(s) unsheathed.

@param char Character