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

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

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

# -> Increase XP cap
scoreboard players add @s OverlyRealistic.Player.WisdomStats.Combat_XP_Max 1200

# -> Scribe check
tag @s add OverlyRealistic.Player.CurrentPlayer
execute if entity @p[tag=!OverlyRealistic.Player.CurrentPlayer,scores={OverlyRealistic.Player.WisdomStats.Scribing=4..},distance=..32,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/combat/set_advancements

# --> Buffs

# -> Reset buffs
attribute @s attack_damage modifier remove overly_realistic:wisdom_combat_skill_buff
attribute @s attack_speed modifier remove overly_realistic:wisdom_combat_skill_buff
attribute @s entity_interaction_range modifier remove overly_realistic:wisdom_combat_skill_buff

# -> Level 1 buff
execute if score @s OverlyRealistic.Player.WisdomStats.Combat matches 1..2 run \
    attribute @s attack_damage modifier add overly_realistic:wisdom_combat_skill_buff 0.08 add_multiplied_base

# -> Level 2 buff
execute if score @s OverlyRealistic.Player.WisdomStats.Combat matches 2..3 run \
    attribute @s attack_speed modifier add overly_realistic:wisdom_combat_skill_buff 0.05 add_value

# -> Level 3 buff
execute if score @s OverlyRealistic.Player.WisdomStats.Combat matches 3..4 run \
    attribute @s attack_damage modifier add overly_realistic:wisdom_combat_skill_buff 0.15 add_multiplied_base
execute if score @s OverlyRealistic.Player.WisdomStats.Combat matches 3..4 run \
    attribute @s entity_interaction_range modifier add overly_realistic:wisdom_combat_skill_buff 0.5 add_value

# -> Level 4 buff
execute if score @s OverlyRealistic.Player.WisdomStats.Combat matches 4 run \
    attribute @s attack_speed modifier add overly_realistic:wisdom_combat_skill_buff 0.1 add_value

# -> Level 5 buff
execute unless score @s OverlyRealistic.Player.WisdomStats.Combat matches 5 run \
    return fail
attribute @s attack_damage modifier add overly_realistic:wisdom_combat_skill_buff 0.2 add_multiplied_base
attribute @s attack_speed modifier add overly_realistic:wisdom_combat_skill_buff 0.2 add_value
attribute @s entity_interaction_range modifier add overly_realistic:wisdom_combat_skill_buff 1.25 add_value
attribute @s attack_knockback modifier add overly_realistic:wisdom_combat_skill_buff 0.5 add_value
