I changed the delays so that it always waits at least 5 seconds after equipping a weapon before performing the next check. That should work around your issues, even though it sounds like the core problem is the bot's if-stuck behaviour (I haven't verified whether what you say is true though).