execute unless entity @e[name=EscapeLadder,type=minecraft:armor_stand] run data merge block ~ ~ ~ {auto:0b}
scoreboard players add @e[name=EscapeLadder] EscapeLadder 1
kill @e[name=EscapeLadder,tag=!Upgraded,scores={EscapeLadder=105..}]
kill @e[name=EscapeLadder,tag=Upgraded,scores={EscapeLadder=255..}]

execute as @e[name=EscapeLadder] run execute at @s run tp @s ~ ~1 ~
execute as @e[name=EscapeLadder] run execute at @s unless block ~ ~ ~ air run fill ~ ~ ~ ~ ~ ~ ladder destroy
execute as @e[name=EscapeLadder,tag=Upgraded] run execute at @s if block ~ ~ ~ air run fill ~ ~ ~ ~ ~ ~ ladder destroy
execute at @e[name=EscapeLadder,scores={EscapeLadder=1..6}] run playsound minecraft:entity.ender_dragon.flap ambient @a[distance=..25] ~ ~ ~ 3 0.5 1


execute as @e[name=EscapeLadder] run execute at @s run execute if entity @e[type=marker,distance=..30,tag=KyuBigPyramid] run tellraw @a[distance=..100] ["",{"text":"A mysterious force destroys the escape ladder.","color":"gold"}]
execute as @e[name=EscapeLadder] run execute at @s run execute if entity @e[type=marker,distance=..30,tag=KyuBigPyramid] run kill @s


