# Spawn at beacon (beside +1X, +1Y so he falls)
execute as @e[type=armor_stand,nbt={CustomName:'{"text":"ScavengerBase"}'},limit=1,sort=nearest] at @s run summon villager ~1 ~1 ~ {Tags:["Scavenger"],CustomName:'{"text":"The Scavenger","color":"dark_green","bold":true}',VillagerData:{profession:weaponsmith,type:savanna,level:5},PersistenceRequired:1b,Silent:1b,Invulnerable:1b}
execute as @e[type=armor_stand,nbt={CustomName:'{"text":"ScavengerBase"}'}] at @s run tellraw @a[distance=..12] {"text":"Back from the wastes—don’t ask how it went.","bold":true,"color":"gold"}
execute as @e[type=armor_stand,nbt={CustomName:'{"text":"ScavengerBase"}'}] at @s unless entity @a[distance=..12] run tellraw @a {"text":"Back from the wastes—don’t ask how it went.","bold":true,"color":"gold"}

# Local spawn message anchored to beacon

# Flip state present
scoreboard players set state scav_state 1

# Build 7 random unique trades
execute as @e[type=armor_stand,nbt={CustomName:'{"text":"ScavengerBase"}'},limit=1,sort=nearest] at @s run execute as @e[type=villager,tag=Scavenger,limit=1,sort=nearest] run function scavenger:trades/build_random_7