#reset
execute if score @s health > @s health_max run scoreboard players operation @s health = @s health_max

#class
scoreboard players set @s[tag=classless] health_max 100
scoreboard players set @s[tag=gunner] health_max 300
scoreboard players set @s[tag=brawler] health_max 550
scoreboard players set @s[tag=sniper] health_max 200
scoreboard players set @s[tag=assassin] health_max 200
scoreboard players set @s[tag=engineer] health_max 150
scoreboard players set @s[tag=archer] health_max 300
scoreboard players set @s[tag=knight] health_max 200
scoreboard players set @s[tag=sorcerer] health_max 300
scoreboard players set @s[tag=reaper] health_max 400

#relics
execute if score .deadmans_helmet relics matches 1.. run scoreboard players add @a health_max 30
execute if score .burning_heart relics matches 1.. run scoreboard players add @a health_max 5
execute if score .wooden_cross relics matches 1.. run scoreboard players add @a health_max 20

execute if score @s health_10 matches -1 run function main:mechanics/artifacts/id/green/id2/heal

#flat

#multiplier
scoreboard players set @s health_multiplier 100
##items
execute if score .lump_of_meat artifact matches 1.. run scoreboard players operation .lump_of_meat artifact *= .10 number
execute if score .lump_of_meat artifact matches 1.. run scoreboard players operation @s health_multiplier += .lump_of_meat artifact
execute if score .lump_of_meat artifact matches 1.. run scoreboard players operation .lump_of_meat artifact /= .10 number

#artifacts
#purple
#id4
execute if score .combat_discipline artifact matches 1.. run scoreboard players add @a health_multiplier 15

#id11
execute if score .panic_amulet artifact matches 1.. run scoreboard players add @a health_multiplier 30

#id7
execute if score .blood_strengthening_stacks artifact matches 1.. run scoreboard players operation @s health_multiplier += .blood_strengthening_hp artifact

#set
scoreboard players operation @s health_max *= @s health_multiplier
scoreboard players operation @s health_max /= .100 number

#artifacts
#purple
#id24
execute if score .beetle_juice artifact matches 1.. run function main:mechanics/artifacts/id/purple/id24/calculation


execute if score @s health_10 matches 1.. run function main:mechanics/artifacts/id/green/id2/heal_1

#low hpi
scoreboard players set @s health_1 1
scoreboard players operation @s health_1 *= @s health_max
scoreboard players operation @s health_1 /= .100 number

scoreboard players operation @s health_3 = @s health_1
scoreboard players operation @s health_3 *= .3 number

scoreboard players operation @s health_25 = @s health_max
scoreboard players operation @s health_25 /= .4 number

scoreboard players operation @s health_50 = @s health_max
scoreboard players operation @s health_50 /= .2 number

scoreboard players set @s health_total 0
scoreboard players operation @s health_total += @s health
scoreboard players operation @s health_total += @s shield

execute as @s[tag=!main_menu] if score @s health_total <= @s health_25 run worldborder warning distance 599999701

execute if score @s hit_vignette matches 1.. run worldborder warning distance 599999701
execute if score @s hit_vignette matches 1.. run scoreboard players remove @s hit_vignette 1

execute if score @s hit_vignette matches ..0 if score @s health_total > @s health_25 run worldborder warning distance 0