
# --> Mental health operations

# -> Do operations
function overly_realistic:players/mental_health/mental_health_looping_operate

# --> Hygiene operations

# -> Reset vars
scoreboard players set #or.global OverlyRealistic.General.ArbitraryData 0

# -> Outside check
execute if score @s OverlyRealistic.PredicateValue.IsExposedToSkyLight matches 1 \
    if score #or.WorldTime OverlyRealistic.General.ArbitraryData matches 13000..23460 run \
        scoreboard players add #or.global OverlyRealistic.General.ArbitraryData 15

# -> Dirtyness check
execute if items entity @s weapon.* #overly_realistic:dirty_blocks run \
    scoreboard players add #or.global OverlyRealistic.General.ArbitraryData 10
execute if block ~ ~-1 ~ #overly_realistic:dirty_blocks \
    unless items entity @s armor.feet * run \
        scoreboard players add #or.global OverlyRealistic.General.ArbitraryData 15

# -> Blood check
execute if entity @n[type=item_display,tag=OverlyRealistic.GroundBloodSplatter,distance=..10,sort=arbitrary] run \
    scoreboard players add #or.global OverlyRealistic.General.ArbitraryData 15

# -> Swamp check
execute if biome ~ ~ ~ #overly_realistic:swamps run \
    scoreboard players add #or.global OverlyRealistic.General.ArbitraryData 8

# -> No-armor check
execute unless items entity @s armor.* * run \
    scoreboard players add #or.global OverlyRealistic.General.ArbitraryData 20

# -> Function tag
function #overly_realistic:mechanics/player_hygiene_value_operate

# -> RNG check
execute store result score #or.global OverlyRealistic.Player.Stats.Hygiene run \
    random value 0..100
execute if score @s OverlyRealistic.Player.Stats.Hygiene matches 1.. \
    if score #or.global OverlyRealistic.General.ArbitraryData >= #or.global OverlyRealistic.Player.Stats.Hygiene run \
        function overly_realistic:players/hygiene/remove_1_hygiene

# --> Intelligence attribute operations
attribute @s attack_damage modifier remove overly_realistic:low_intelligence_attack_damage_debuff
execute unless score @s OverlyRealistic.Player.Stats.Intelligence matches 70.. \
    if predicate overly_realistic:player/misc/intelligence_gain_general_rng run \
        attribute @s attack_damage modifier add overly_realistic:low_intelligence_attack_damage_debuff -0.75 add_value
