
# -> Reset adv trigger
advancement revoke @s only overly_realistic:player/player_attacked_entity

# -> Reduce stamina
execute unless score @s OverlyRealistic.Player.Stats.Stamina matches ..0 run \
    scoreboard players remove @s OverlyRealistic.Player.Stats.Stamina 2

# -> Set attack cooldown
scoreboard players add @s OverlyRealistic.Player.GeneralTickingCooldown 10
scoreboard players set @s OverlyRealistic.Player.GTC_PlayerAttackCooldown 10

attribute @s attack_damage modifier add overly_realistic:gtc_attack_damage_cooldown -999 add_multiplied_total

# -> Altitude checks
execute if entity @s[y=100,dy=9999] run \
    scoreboard players remove @s OverlyRealistic.Player.Stats.Stamina 1
execute if entity @s[y=200,dy=9999] run \
    scoreboard players remove @s OverlyRealistic.Player.Stats.Stamina 1
execute if entity @s[y=300,dy=9999] run \
    scoreboard players remove @s OverlyRealistic.Player.Stats.Stamina 1

# -> Add to strength timer
scoreboard players add @s OverlyRealistic.Player.StrengthTimer 1

# -> If strength timer >= 500 then add to strength stat
execute if score @s OverlyRealistic.Player.StrengthTimer matches 500.. run \
    function overly_realistic:players/misc/strength/add_to_strength_from_timer

# -> Tag player
tag @s add OverlyRealistic.Player.PlayerAttackedEntity

# -> Check for hurt animals
execute as @e[type=#overly_realistic:common_animals,tag=!OverlyRealistic.Animal.IsAnimalCorpse,distance=..16] at @s run \
    function overly_realistic:animals/animal_damaged

# -> Untag player
tag @s remove OverlyRealistic.Player.PlayerAttackedEntity

# -> Add to hit counters
execute unless items entity @s weapon.mainhand #overly_realistic:combat_xp_is_tools run \
    scoreboard players add @s OverlyRealistic.Player.WisdomSpecialized.FistHits 1
execute if score @s OverlyRealistic.Player.WisdomSpecialized.FistHits matches 10.. run \
    return run \
        function overly_realistic:players/wisdom/combat/add_to_skill_xp_c_fist_hit_10
execute if items entity @s weapon.mainhand #overly_realistic:combat_xp_is_tools run \
    scoreboard players add @s OverlyRealistic.Player.WisdomSpecialized.ToolHits 1
execute if score @s OverlyRealistic.Player.WisdomSpecialized.ToolHits matches 10.. run \
    function overly_realistic:players/wisdom/combat/add_to_skill_xp_c_tool_hit_10
