
# -> Random event RNG
execute store result score #or.torso_hit_event_rng OverlyRealistic.General.ArbitraryData run \
    random value 0..100

# -> Armor checks
execute if items entity @s armor.head chainmail_helmet run \
    scoreboard players add #or.head_hit_event_rng OverlyRealistic.General.ArbitraryData 30
execute if items entity @s armor.head iron_helmet run \
    scoreboard players add #or.head_hit_event_rng OverlyRealistic.General.ArbitraryData 60

# -> Tag attacker
execute on attacker run \
    tag @s add OverlyRealistic.Player.TempPlayerAttacker

# -> Extra knockback
attribute @s knockback_resistance modifier add overly_realistic:temp_no_kb 0.375 add_value
damage @s 0.0001 overly_realistic:player_head_hit by @p[tag=OverlyRealistic.Player.TempPlayerAttacker,distance=..64]
attribute @s knockback_resistance modifier remove overly_realistic:temp_no_kb

# -> Untag attacker
execute on attacker run \
    tag @s remove OverlyRealistic.Player.TempPlayerAttacker

# -> Random event
execute if score #or.torso_hit_event_rng OverlyRealistic.General.ArbitraryData matches 0..25 run \
    return run \
        scoreboard players remove @s OverlyRealistic.Animal.Stamina 3
execute if score #or.torso_hit_event_rng OverlyRealistic.General.ArbitraryData matches 26..46 run \
    effect give @s hunger 3 1 true

#say HIT TORSO