
# -> Randomized value
execute store result score #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData run \
    random value 5..60

# -> Intelligence reduction from randomized value (intelligence / 10 - randomValue)
scoreboard players operation #or.intelligence_reduction_buff OverlyRealistic.General.ArbitraryData = @s OverlyRealistic.Player.Stats.Intelligence
scoreboard players operation #or.intelligence_reduction_buff OverlyRealistic.General.ArbitraryData /= #or.static_num_10 OverlyRealistic.General.ArbitraryData
scoreboard players operation #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData -= #or.intelligence_reduction_buff OverlyRealistic.General.ArbitraryData

# -> If randomized value <= 0 then return
execute if score #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData matches ..0 run \
    return fail

# -> Equitation
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Equitation_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Equitation_XP matches ..-1 run \
    function overly_realistic:players/wisdom/equitation/reduce_level

# -> Fishing
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Fishing_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Fishing_XP matches ..-1 run \
    function overly_realistic:players/wisdom/fishing/reduce_level

# -> Mining
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Mining_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Mining_XP matches ..-1 run \
    function overly_realistic:players/wisdom/mining/reduce_level

# -> Combat
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Combat_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Combat_XP matches ..-1 run \
    function overly_realistic:players/wisdom/combat/reduce_level

# -> Husbandry
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Husbandry_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Husbandry_XP matches ..-1 run \
    function overly_realistic:players/wisdom/husbandry/reduce_level

# -> Building
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Building_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Building_XP matches ..-1 run \
    function overly_realistic:players/wisdom/building/reduce_level

# -> Archery
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Archery_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Archery_XP matches ..-1 run \
    function overly_realistic:players/wisdom/archery/reduce_level

# -> Cookery
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Cookery_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Cookery_XP matches ..-1 run \
    function overly_realistic:players/wisdom/cookery/reduce_level

# -> Healthcare
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Healthcare_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Healthcare_XP matches ..-1 run \
    function overly_realistic:players/wisdom/healthcare/reduce_level

# -> Scribing
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Scribing_XP -= #or.randomized_xp_decrease OverlyRealistic.General.ArbitraryData
execute if score @s OverlyRealistic.Player.WisdomStats.Scribing_XP matches ..-1 run \
    function overly_realistic:players/wisdom/scribing/reduce_level
