Left 4 Dead 2

Left 4 Dead 2

Bot AI Improvements
 This topic has been pinned, so it's probably important
T-Rizzle  [developer] Oct 14, 2022 @ 6:10am
Addon Features Explained
This is for anyone who want more details on the features of this addon and on how they work. This Features Explanation will change as I update the addon with new features or with changes to current features.

- Bots will pull out their melee weapons when a common infected get to close to them,

This was probably the easiest function to make. All I had to do was check the bot’s distance from the nearest common infected, check if the bot had a melee weapon or chainsaw and force them to pull out the melee weapon or chainsaw if they have one. Of course I made sure they weren’t using healing items and throwables before forcing the swap.

- Improved bot chainsaw behavior, "Bots will shove for two seconds after pulling out their chainsaw and will hold down their attack button when multiple commons are close to them."

This was not only the fix for the chainsaw.txt fix, but also allowed bots to shove common infected after pulling out their chainsaw.

- Bots will crouch when fighting far away common infected, there is a limit to how far away the common infected can be when deciding to crouch

This was a bit difficult to make mostly because I needed the bit number for the crouch button, other than that this was the second easiest function to make. The function checks a few things, first the distance from the closest human player, if it can’t find one it will be allowed to crouch whenever it wants, second check and make sure that the common infected isn’t too far away and finally checks to make sure the common infected isn’t too close.

- Bots with sniper rifles will scope in when crouching to improve their accuracy

This was one of the hardest functions to make mostly because the AIP documentation doesn’t say the bit number for the scope key. Thankfully slimzo showed me the bit number so I could make this possible.

- Attempted to fix bots when incapacitated and sb_allow_shoot_through_survivors is set to 0 not shooting through teammates

This wasn’t too hard to make, all I did though was check for a nearby common infected and force the bot to rapidly click their attack button.

- Attemped to fix bots walking though fire, “This bug happens all the time, bots for some reason love trying to reach you by walking straight through Molotovs and/or Gascans, “this is a major problem in expert mode where fire can easily kill you,” what I did to fix this is add a check for active fires and marked the area as blocked for the survivor bots, “infected will still walk into the fire,” making the bots take alternate routes to get to the player.”

This check runs on a few factors, first it makes sure there are no bots are currently in the fire, “for some reason if the area is marked as blocked the bots won’t walk out of the fire,” second then the nav_area around the fire should be blocked and finally the nav_area should be unblocked when the fire is gone.

- Bots can now attempt to dead stop hunters and jockeys

Bots will check for nearby hunters and jockeys and if they get to close the bots are forced to shove until either the jockey or hunter is staggering or if they get out of the shove range. And no I don’t force the bots to look at the special infected they are trying to dead stop for balancing reasons. Most of the time they are pretty good at automatically aiming at the jockey or hunter.

- Bots will stop reviving teammates if they are being attacked by a common infected and/or if a tank is nearby, “bots being bots will still attempt to revive teammates, but they will immediately stop the revive if the tank or common infected is too close.”

This was the hardest function to make, the beta version of this was to force the bot to shove, “because shoving while reviving interrupts the action,” but sometimes the bots would DISABLE THEIR STUPID SHOVE BUTTON WHEN A TANK IS NEARBY, so I found another way. First I check if the bot is currently reviving someone then I check two things, First if their is a common infected nearby the bot will cancel the revive and shove said common. Second, if their is a tank nearby I force the retreat command, “sometimes it fails to work,” and make the bot cancel the revive as well as force the bot to look at the tank. As for how I cancel the revive, I went into the bot’s and the person they are reviving Netprops and set the revive target and revive owner to -1, “basically null,” causing the revive to end and the bot temporarily following the retreat command.

- Bots will prioritize killing smokers that are trying to grab them

When a bot gets grabbed by a smoker I force the bot that was grabbed to aim at the smoker, “I do not force the attack key for balancing reasons most of the time the bot successfully kills the smoker before it starts pulling them in.”

- Bots will not drop melee weapons if they are controlling an idle player

This was easy to make, all I had to do was check each human player’s inventory and increase sb_max_team_melee_weapons by 1 for each player that has a melee weapon. This causes bots to not trade your melee weapon for a pistol or magnum.

- sb_melee_approach_victim is set based on the distance from the closest player

This checks the closest players distance and sets sb_melee_approach_distance to 0 if they stray too far from a human player and set sb_melee_approach_distance to 1 if they are close to a human player or their are no alive human players on the team.

- Bots with T1 shotguns and css snipers will shove after shooting to allow them to shoot faster

All I had to do was force bots to press their shove button after firing a T1 shotguns or css sniper.

- Bots with shotguns will reload for 2 seconds after emptying their weapon clip before firing again

When a bot reloads their weapon I check to see if the clip is empty and if it is I disable the bot's attack button for a few seconds.
Last edited by T-Rizzle; Dec 15, 2022 @ 12:52pm