execute if entity @s[tag=red] run summon zombie ~ ~ ~ {DeathLootTable:"none",Team:"red",Health:50f,Tags:["new","not_damaged","mega"],CustomName:{"color":"red","italic":false,"text":"Zombie"},equipment:{legs:{id:"minecraft:sunflower",count:1,components:{"minecraft:item_name":{color:"blue",italic:false,text:"Blue Coin"},"minecraft:custom_data":{coin:1b,blue:1b}}},chest:{id:"minecraft:leather_chestplate",count:1,components:{"minecraft:dyed_color":16720932}},head:{id:"minecraft:leather_helmet",count:1,components:{"minecraft:dyed_color":16720932}}},drop_chances:{legs:2.000,chest:-327.000,head:-327.000},attributes:[{id:"minecraft:attack_damage",base:8},{id:"minecraft:attack_knockback",base:4},{id:"minecraft:max_health",base:50},{id:"minecraft:scale",base:3},{id:"minecraft:step_height",base:2}]}
execute if entity @s[tag=blue] run summon zombie ~ ~ ~ {DeathLootTable:"none",Team:"blue",Health:50f,Tags:["new","not_damaged","mega"],CustomName:{"color":"blue","italic":false,"text":"Zombie"},equipment:{legs:{id:"minecraft:sunflower",count:1,components:{"minecraft:item_name":{color:"red",italic:false,text:"Red Coin"},"minecraft:custom_data":{coin:1b,red:1b}}},chest:{id:"minecraft:leather_chestplate",count:1,components:{"minecraft:dyed_color":1011711}},head:{id:"minecraft:leather_helmet",count:1,components:{"minecraft:dyed_color":1011711}}},drop_chances:{legs:2.000,chest:-327.000,head:-327.000},attributes:[{id:"minecraft:attack_damage",base:8},{id:"minecraft:attack_knockback",base:4},{id:"minecraft:max_health",base:50},{id:"minecraft:scale",base:3},{id:"minecraft:step_height",base:2}]}

execute as @n[type=zombie,tag=new] run attribute @s minecraft:knockback_resistance base set 1

execute as @n[type=zombie,team=red,tag=new] at @s run damage @n[type=zombie,team=blue] 0 minecraft:mob_attack by @s
execute as @n[type=zombie,team=blue,tag=new] at @s run damage @n[type=zombie,team=red] 0 minecraft:mob_attack by @s

tag @n[type=zombie,tag=new] remove new

kill @s