Skeletons fire volleys of arrows at approaching enemies from afar before automatically drawing swords and shields for close-quarters combat.
Custom MobsMedievalDarkGoldWhiteBlackAdventure MapMini-gameMap MakingSummoned mobsSoundsGlowing outlines21+ commands
Standard skeletons in Minecraft keep trying to shoot arrows even when you are standing right in their face. With the Adaptive Arsenal Undead command setup, skeletons dynamically evaluate the distance to their enemies and switch weapons on the fly.
In this scene, a squad of gilded skeletons fires enchanted arrow volleys at advancing iron golems from across the battlefield. As soon as a golem closes the gap, the skeletons swap their bows for golden swords and shields with a burst of magical particles, charging into melee combat.
/scoreboard objectives add c9_timer dummy/team add c9_undead/team modify c9_undead color gold/team modify c9_undead friendlyFire false/summon marker ~ ~ ~ {Tags:["c9_ctrl"]}/summon skeleton ~-6 ~ ~-3 {Tags:["c9_skel","c9_ranged"],Glowing:1b,PersistenceRequired:1b,CustomName:'{"text":"Adaptive Vanguard","color":"gold"}',equipment:{mainhand:{id:"minecraft:bow",count:1,components:{"minecraft:enchantments":{power:3}}},head:{id:"minecraft:golden_helmet",count:1},chest:{id:"minecraft:chainmail_chestplate",count:1}},attributes:[{id:"minecraft:max_health",base:60.0},{id:"minecraft:movement_speed",base:0.28}],Health:60.0f}/summon skeleton ~-7 ~ ~ {Tags:["c9_skel","c9_ranged"],Glowing:1b,PersistenceRequired:1b,CustomName:'{"text":"Adaptive Vanguard","color":"gold"}',equipment:{mainhand:{id:"minecraft:bow",count:1,components:{"minecraft:enchantments":{power:3}}},head:{id:"minecraft:golden_helmet",count:1},chest:{id:"minecraft:golden_chestplate",count:1}},attributes:[{id:"minecraft:max_health",base:60.0},{id:"minecraft:movement_speed",base:0.28}],Health:60.0f}/summon skeleton ~-6 ~ ~3 {Tags:["c9_skel","c9_ranged"],Glowing:1b,PersistenceRequired:1b,CustomName:'{"text":"Adaptive Vanguard","color":"gold"}',equipment:{mainhand:{id:"minecraft:bow",count:1,components:{"minecraft:enchantments":{power:3}}},head:{id:"minecraft:golden_helmet",count:1},chest:{id:"minecraft:chainmail_chestplate",count:1}},attributes:[{id:"minecraft:max_health",base:60.0},{id:"minecraft:movement_speed",base:0.28}],Health:60.0f}/summon iron_golem ~7 ~ ~-2 {Tags:["c9_golem"],Glowing:1b,PersistenceRequired:1b,attributes:[{id:"minecraft:max_health",base:60.0},{id:"minecraft:movement_speed",base:0.26}],Health:60.0f}/summon iron_golem ~7 ~ ~2 {Tags:["c9_golem"],Glowing:1b,PersistenceRequired:1b,attributes:[{id:"minecraft:max_health",base:60.0},{id:"minecraft:movement_speed",base:0.26}],Health:60.0f}/team join c9_undead @e[tag=c9_skel]/scoreboard players add @e[tag=c9_ctrl] c9_timer 1/execute as @e[tag=c9_skel,tag=c9_ranged] at @s if entity @e[tag=c9_golem,distance=..5.5] run tag @s add c9_to_melee/execute as @e[tag=c9_skel,tag=c9_to_melee] at @s run item replace entity @s weapon.mainhand with golden_sword[enchantments={sharpness:4,knockback:1}]/execute as @e[tag=c9_skel,tag=c9_to_melee] at @s run item replace entity @s weapon.offhand with shield/execute as @e[tag=c9_skel,tag=c9_to_melee] at @s run particle sweep_attack ~ ~1.2 ~ 0.3 0.3 0.3 0 3 force/execute as @e[tag=c9_skel,tag=c9_to_melee] at @s run particle flame ~ ~1 ~ 0.3 0.5 0.3 0.05 15 force/execute as @e[tag=c9_skel,tag=c9_to_melee] at @s run playsound entity.item.break master @a ~ ~ ~ 1 1.5/execute as @e[tag=c9_skel,tag=c9_to_melee] run tag @s remove c9_ranged/execute as @e[tag=c9_skel,tag=c9_to_melee] run tag @s add c9_melee/execute as @e[tag=c9_skel,tag=c9_to_melee] run tag @s remove c9_to_melee/execute as @e[tag=c9_skel,tag=c9_melee] at @s unless entity @e[tag=c9_golem,distance=..6.5] run item replace entity @s weapon.mainhand with bow[enchantments={power:3}]/execute as @e[tag=c9_skel,tag=c9_melee] at @s unless entity @e[tag=c9_golem,distance=..6.5] run item replace entity @s weapon.offhand with air/execute as @e[tag=c9_skel,tag=c9_melee] at @s unless entity @e[tag=c9_golem,distance=..6.5] run particle enchant ~ ~1.5 ~ 0.4 0.4 0.4 0.5 20 forcesetup #6 Summons an Adaptive Vanguard skeleton tagged with <code>c9_skel</code> and <code>c9_ranged</code>, equipped with a Power III bow and golden armor.loop #3 Checks every ranged skeleton to see if an iron golem has stepped within 5.5 blocks. If so, it flags the skeleton with <code>c9_to_melee</code> to trigger a weapon swap.loop #4 Uses <code>/item replace</code> to swap the skeleton's bow for a Sharpness IV, Knockback I golden sword, automatically changing the skeleton's AI from ranged shooting to melee rushing.loop #12 If all targets are knocked back or defeated beyond 6.5 blocks, the skeleton re-equips its enchanted bow to resume firing from a distance.


Recorded on our own test server: 58 frames at about 9.7 fps. Our image check saw: Three glowing golden-armored skeletons fight two iron golems at night, switching from bows to swords and shields as the golems get close.
Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.
To make the skeletons adapt to real survival players instead of only iron golems, replace tag=c9_golem inside loop commands 3, 12, 13, and 14 with type=player,gamemode=!spectator,gamemode=!creative. You will also need to finish the state transition back to ranged by adding two chain command blocks that remove c9_melee and add c9_ranged when no players are within 6.5 blocks.
/kill @e[tag=c9_skel]/kill @e[tag=c9_golem]/kill @e[tag=c9_ctrl]/kill @e[type=arrow]/kill @e[type=item]/team remove c9_undead/scoreboard objectives remove c9_timerIn vanilla Minecraft, a skeleton's combat AI depends directly on the item in its main hand. Holding a bow activates ranged strafing AI, while holding any other item activates melee charging AI.
Having a slightly wider distance to switch back to the bow prevents the skeleton from rapidly flickering between sword and bow when an enemy stands right on the boundary.
▶Stealth Assassins vs Armored Champions ArenaCustom MobsMedium24 cmds
▶Awakened Mimic Chest MobCustom MobsMedium24 cmds
▶Fangs of the Arrow-Proof WarlordCustom MobsMedium21 cmds
▶Fury of the Sentient GreatswordCustom MobsHard20 cmds
▶PvP Pro-Bot ZombieCustom MobsHard16 cmds
▶Tactical Skeleton Duelist Boss in Vanilla MinecraftCustom MobsMedium24 cmds