
# -> Drop inventory
function overly_realistic:general/downing/death_item_drop/item_drop_start

# -> Decrease nearby players' mental health
scoreboard players set #or.central_value_set_mental_health OverlyRealistic.General.ArbitraryData 35
execute as @a[distance=..16] run \
    function overly_realistic:players/mental_health/decrease_mental_health

# -> Decrease attacker's mental health
scoreboard players set #or.central_value_set_mental_health OverlyRealistic.General.ArbitraryData 5
execute on attacker run \
    function overly_realistic:players/mental_health/decrease_mental_health

# -> Remove physical traumas
function overly_realistic:main/debug/stats/remove_physical_trauma

# -> Reset onDeath stats
function overly_realistic:main/debug/stats/reset_ondeath_stats

# -> Tag player with needing attributes
tag @s add OverlyRealistic.Player.NeedsAttributeRestoration

# -> Schedule attribute restoration
scoreboard players set #or.player_death_restoration_loop OverlyRealistic.General.ArbitraryData 0
schedule function overly_realistic:general/downing/attribute_restoration/normal_respawn_restore_attributes 1t append

# -> Schedule redundancy check
schedule function overly_realistic:general/downing/attribute_restoration/attribute_redundancy_check_0 2s

# -> If 'Randomized Respawning' is enabled then return and respawn player randomly
execute if score #or.setting.randomized_respawning OverlyRealistic.Settings.ArbitrarySetting matches 1 run \
    function overly_realistic:players/revive/randomized_respawning/respawn_player
