
Hopefully I added all the code corretly. Things do seem to be working much better. The bots indeed switch to a shotgun or something else when they are too far away. There are only two things I noticed after observing the bots for a bit:
-The range could be increased a bit more for the grenade launcher. I know you probably have the range set at the exact physical distance it can shoot, but I think the bots should switch to the grenade launcher a bit sooner when they are engaging in battle. Grenades also bounce, so there is a chance the first grenade might hit, even if they are slightly out of range.
-I'm not sure if you can fix this or not, but I noticed that once bots engage in a battle, they don't really switch their weapon until the battle is over. For example: Bot A spots Bot B across a large map. Bot A has a grenade launcher in his inventory, but is out of range of Bot B. Bot A switches to the standard shotgun since Bot B is out of range. However, as Bot A gets closer to Bot B, he continues using the shotgun instead of switching to the better choice of the grenade launcher. I think bots get "stuck" using whatever weapon they start with during a battle, and refuse to switch based on conditions (unless they pick up a weapon during a battle, which auto-switches for them). Bots don't use the grenade launcher often in a large open maps even if they get close enough to other bots, because they start the battle with some other weapon.
Otherwise, the code is indeed much better.
