Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:GetSalvagingDifficulty

From RoR Wiki

UI Lua API · Crafting functions
Version: WAR 1.4.8

Returns how hard it is for the player to salvage an item of a given item level.

difficultyClass, chance = GetSalvagingDifficulty(itemLevel)

Arguments

itemLevel
number – Item level (the iLevel field of an item data table).

Returns

difficultyClass
number – 0 to 4. 0 is the easiest, 4 means the item cannot be salvaged. The stock UI looks it up in CraftingUtils.SalvagingDifficulty and compares it with GameData.Salvaging.IMPOSSIBLE.
chance
number – A percentage, 0 to 100. The stock UI shows it next to the difficulty text.

Details

  • The result is calculated from itemLevel and the player's base salvaging level (trade skill 6). Bonuses are not included.
  • The item level is capped at 45. With skill as the salvaging level:
Condition difficultyClass chance
skill ≥ 200 0 100
itemLevel × 5 ≥ skill + 50 4 0
skill ≥ (itemLevel + 3) × 5 0 100
otherwise, with chance = skill + (17 − itemLevel) × 5 3 if chance < 60, 2 if 60–79, 1 if 80 or more chance
The rows are checked from top to bottom.
  • If there is no player object or the Lua state is not available, nothing is returned.
  • The function needs at least one argument and only reads the last one.

Errors

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

Example

From default/ea_craftingwindow/source/salvagingwindow.lua:

function SalvagingWindow.PlayerHasSufficientSkillToSalvageItem( itemData )
    local difficultyClass = GetSalvagingDifficulty( itemData.iLevel )
    return( difficultyClass ~= GameData.Salvaging.IMPOSSIBLE )
end
local difficultyClass, difficultyPercent = GetSalvagingDifficulty( itemData.iLevel )
local difficultyString = CraftingUtils.SalvagingDifficulty[difficultyClass].string

See also