Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:GetMoralePercentForLevel

From RoR Wiki

UI Lua API · Ability functions
Version: WAR 1.4.8

Returns how full the morale bar must be, in percent, to reach a morale level.

percent = GetMoralePercentForLevel(level)

Arguments

level
number – Morale level, 1 to 4.

Returns

percent
number – Percentage, a whole number. 0 if level is outside 1 to 4.

Details

  • The client divides a fixed threshold for the level by the player's maximum morale and rounds down: threshold × 100 / maximum. The built-in thresholds are 360, 720, 1800 and 3600. When the player's maximum morale is 0, 3600 is used, which gives 10, 20, 50 and 100.
  • If there is no player object, or the Lua state is not available, the function returns nothing.

Errors

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

Example

From ea_moralewindow/source/moralewindow.lua:

for level = 1, GameData.NUM_MORALE_LEVELS
do
    moraleBar.m_Buttons[level]              = MoraleButton:Create (windowName.."ContentsButton"..level, windowName.."Contents", level)
    moraleBar.m_PercentagesForLevel[level]  = GetMoralePercentForLevel (level)
    moraleBar.m_FillAmountsForLevel[level]  = (MORALE_PERCENT_MAX / GameData.NUM_MORALE_LEVELS) * level
end

See also