
# -> If current skill level >= 5 then return
execute if score @s OverlyRealistic.Player.WisdomStats.Archery matches 5.. run \
    return run \
        scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Archery_XP = @s OverlyRealistic.Player.WisdomStats.Archery_XP_Max

# -> Reset XP level
scoreboard players set @s OverlyRealistic.Player.WisdomStats.Archery_XP 150

# -> Increase level
scoreboard players add @s OverlyRealistic.Player.WisdomStats.Archery 1

# -> Set XP cap
scoreboard players operation @s[scores={OverlyRealistic.Player.WisdomStats.Archery=0}] OverlyRealistic.Player.WisdomStats.Archery_XP_Max = #or.wisdom_max_xp_level_0 OverlyRealistic.General.ArbitraryData
scoreboard players operation @s[scores={OverlyRealistic.Player.WisdomStats.Archery=1}] OverlyRealistic.Player.WisdomStats.Archery_XP_Max = #or.wisdom_max_xp_level_1 OverlyRealistic.General.ArbitraryData
scoreboard players operation @s[scores={OverlyRealistic.Player.WisdomStats.Archery=2}] OverlyRealistic.Player.WisdomStats.Archery_XP_Max = #or.wisdom_max_xp_level_2 OverlyRealistic.General.ArbitraryData
scoreboard players operation @s[scores={OverlyRealistic.Player.WisdomStats.Archery=3}] OverlyRealistic.Player.WisdomStats.Archery_XP_Max = #or.wisdom_max_xp_level_3 OverlyRealistic.General.ArbitraryData
scoreboard players operation @s[scores={OverlyRealistic.Player.WisdomStats.Archery=4}] OverlyRealistic.Player.WisdomStats.Archery_XP_Max = #or.wisdom_max_xp_level_4 OverlyRealistic.General.ArbitraryData

# -> Scribe check
tag @s add OverlyRealistic.Player.CurrentPlayer
execute if entity @p[tag=!OverlyRealistic.Player.CurrentPlayer,scores={OverlyRealistic.Player.WisdomStats.Scribing=4..},distance=..16,sort=arbitrary] run \
    scoreboard players set @s OverlyRealistic.Player.WisdomStats.Scribing_XP 1000
tag @s remove OverlyRealistic.Player.CurrentPlayer

# -> Set advancements
function overly_realistic:players/wisdom/archery/set_advancements

# -> Set Highest_Skill_CanIncreaseStamina
execute unless score @s OverlyRealistic.Player.WisdomStats.Highest_Skill_CanIncreaseStamina matches 0.. run \
    scoreboard players set @s OverlyRealistic.Player.WisdomStats.Highest_Skill_CanIncreaseStamina 0
execute if score @s OverlyRealistic.Player.WisdomStats.Archery > @s OverlyRealistic.Player.WisdomStats.Highest_Skill_CanIncreaseStamina run \
    scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Highest_Skill_CanIncreaseStamina = @s OverlyRealistic.Player.WisdomStats.Archery

