
# --> Intelligence operations

# -> Add temp tag
tag @s add OverlyRealistic.Player.TempPlayer

# -> Nearby player intelligence gain RNG
execute if entity @p[tag=!OverlyRealistic.Player.TempPlayer,distance=..6] \
    if predicate overly_realistic:player/misc/intelligence_gain_rare_rng run \
        function overly_realistic:players/intelligence/add_1_intelligence

# -> Scribe intelligence buff
execute if score @s OverlyRealistic.Player.WisdomStats.Scribing matches 2 \
    if predicate overly_realistic:player/misc/intelligence_gain_general_rng \
    as @a[distance=..25] run \
        function overly_realistic:players/intelligence/add_1_intelligence

# -> Scribe intelligence buff
execute if score @s OverlyRealistic.Player.WisdomStats.Scribing matches 3.. \
    if predicate overly_realistic:player/misc/scribe_level_3_int_buff_rng \
    as @a[distance=..25] run \
        function overly_realistic:players/intelligence/add_1_intelligence

# -> Low mental health intelligence debuff
execute if score @s OverlyRealistic.Player.Stats.MentalHealth matches ..5 \
    if predicate overly_realistic:player/misc/intelligence_reduction_low_sanity_rng run \
        function overly_realistic:players/intelligence/remove_1_intelligence

# -> Remove temp tag
tag @s remove OverlyRealistic.Player.TempPlayer
