Hooks called by Character Stats

Summary

Hooks

Lets plugins change a roll of a stat or a skill before it is rolled, for example to add a situational bonus or to roll with advantage.
Called on both realms when an attribute definition is registered, after its missing fields have been given their defaults and before it is stored.
Lets plugins hide an attribute from a player, for example one that the faction of the player has no use for.
Lets plugins hide a skill from a player, for example one that the faction of the player has no use for.
Called on the client when the server has answered a roll that the local player made from the character sheet, after the result has been stored for Stats:get_roll.
Called on the server after the level of an attribute of a player's character has changed and the change has been networked, however it came about: through Player:set_attribute and the methods built on it, the staff commands or the points the Levels plugin lets players spend.
Called on the server after the rank of a skill of a player's character has changed and the change has been networked, however it came about: through Player:set_skill and the methods built on it, the CharSetSkill command or the points the Levels plugin lets players spend.
Called on both realms when a skill definition is registered, after its missing fields have been given their defaults and before it is stored.

Hooks

AdjustAttributeRoll(actor, roll_data)

shared plugins/stats/plugin/lib/sh_rolls.lua:204

Lets plugins change a roll of a stat or a skill before it is rolled, for example to add a situational bonus or to roll with advantage. Called in the realm that rolls, which is the server for the rolls that are shown in the chat, once for every call of Player:roll_attribute and Player:roll_skill. Every handler may change the table, so a handler should return nothing to let the others run.

function PLUGIN:AdjustAttributeRoll(actor, roll_data)
  if roll_data.id == 'stealth' and actor:Crouching() then
    roll_data.formula = roll_data.formula..' + 2'
  end
end

Parameters

  • actor Player The player who rolls
  • roll_data Map The roll, modified in place: id (String ID of the stat or the skill), kind (String 'attribute' or 'skill'), modifier (Number the modifier of the player) and formula (String the Dice formula that is rolled, '1d20 + modifier'; change it to change the roll)

Called from

  • roll

Call sites

AttributeRegistered(id, data)

shared plugins/stats/plugin/lib/sh_attributes.lua:77

Called on both realms when an attribute definition is registered, after its missing fields have been given their defaults and before it is stored. A handler may change the definition.

Parameters

  • id String Attribute ID
  • data AttributeBase The attribute definition

Called from

Call sites

IsAttributeVisible(target, attribute)

shared plugins/stats/plugin/lib/sh_attributes.lua:136

Lets plugins hide an attribute from a player, for example one that the faction of the player has no use for. Called on the client for every registered attribute that does not have its hidden field set, when the tab menu is opened and twice a second while the character sheet is open, so that the sheet follows a changed answer.

Parameters

  • target Player The player whose attributes are being shown, the local player
  • attribute AttributeBase The attribute definition

Returns

  • Boolean Return false to hide the attribute

Called from

Call sites

IsSkillVisible(target, skill)

shared plugins/stats/plugin/lib/sh_skills.lua:104

Lets plugins hide a skill from a player, for example one that the faction of the player has no use for. Called on the client for every registered skill that does not have its hidden field set, when the tab menu is opened and twice a second while the character sheet is open, so that the sheet follows a changed answer.

Parameters

  • target Player The player whose skills are being shown, the local player
  • skill SkillBase The skill definition

Returns

  • Boolean Return false to hide the skill

Called from

Call sites

OnStatRollResult(id, result)

client plugins/stats/plugin/cl_hooks.lua:160

Called on the client when the server has answered a roll that the local player made from the character sheet, after the result has been stored for Stats:get_roll.

Parameters

  • id String ID of the stat or the skill
  • result Map formula, total, natural, critical and rolls of the Dice result

Call sites

PlayerAttributeChanged(target, attribute_id, level, old_level)

server plugins/stats/plugin/lib/sh_attributes.lua:452

Called on the server after the level of an attribute of a player's character has changed and the change has been networked, however it came about: through Player:set_attribute and the methods built on it, the staff commands or the points the Levels plugin lets players spend. Boosts do not run it.

Parameters

  • actor Player The player whose character the attribute belongs to
  • attribute_id String Attribute ID
  • level Number New level, without boosts
  • old_level Number Level before the change

Called from

Call sites

PlayerSkillChanged(target, skill_id, rank, old_rank)

server plugins/stats/plugin/lib/sh_skills.lua:234

Called on the server after the rank of a skill of a player's character has changed and the change has been networked, however it came about: through Player:set_skill and the methods built on it, the CharSetSkill command or the points the Levels plugin lets players spend.

Parameters

  • actor Player The player whose character the skill belongs to
  • skill_id String Skill ID
  • rank Number New rank
  • old_rank Number Rank before the change

Called from

Call sites

SkillRegistered(id, data)

shared plugins/stats/plugin/lib/sh_skills.lua:72

Called on both realms when a skill definition is registered, after its missing fields have been given their defaults and before it is stored. A handler may change the definition.

Parameters

  • id String Skill ID
  • data SkillBase The skill definition

Called from

Call sites

Defined in