No problem with init.sqf or even trigger set to condition: true.
I can't reproduce the problem so far. If some remaining AT ammo, the tank will shift on this ammo if any incoming enemy armored.
l have a two line correction for some big mod adapt (roughly when hmg or canon is undefined). Nothing for your problem but could you confirm me if you're playing with some mods?
This script allows to shift for some anti-infantry ammo IF the nearest enemy is infantry.
This script doesn't decide some priority for targets. This is the work of Arma's engine.
l will test some scenarios again and try to modify some lines if I can.
I'm not at home right now. I can't go deeper in my script right now.