AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=109)
-   -   [L4D2] Survivor Bot AI Improver (https://forums.alliedmods.net/showthread.php?t=342872)

Emana202 05-24-2023 06:41

[L4D2] Survivor Bot AI Improver
 
3 Attachment(s)
What's This?

This plugin attempts to improve the behavior of Survivor Bots as much as possible without giving them the huge cheat-like advantages, like godmode, infinite ammo, etc.

Demonstration Video #1
Demonstration Video #2
Noteable Features:
  • Bots now properly approach their melee target and switch between normal swings and bashing + ability for them to use chainsaws.
  • Bots can now pickup and use Tier 3 weapons without having to modify weapon scripts via addons and plugins.
  • You can set the weapon preferences for each survivor type (Coach, Zoey, etc.) using the "l4d2_improvedbots_weapon_preference_*" convars in the game console or plugin's config.
  • Bots that are near witches will slowwalk if the witch isn't close to become enraged.
  • You can make bots that carry props like gnome or gascans to not drop them in any circumstances whatsoever, unless they're incapacitated or grabbed by SI.
  • If the survivor team has too many same types of grenades or sub-types of weapons, they will swap their to the one that isn't.
  • Improved and configurable item scavenging system
  • Bots now avoid moving through areas that are covered in spit or fire and try to find another way to get to their destination. They also react faster to getting spit under them and escape much efficiently.
  • Bots will try to dodge the chargin' chargers and tank's rock that are thrown at them.
  • Bots now will deploy ammopacks if they have any primary weapon and defib dead survivors if they can.
  • Bots with shotguns will switch to their pistols if the target is too far away from them. Also, bots with sniper rifles now don't switch to pistols if target is close to them.
  • Bots with pump shotguns and CSS sniper rifles can shove upon firing to boost their firerate.
  • Bots shouldn't now completely ignore targets that are directly behind them and shoot at witch's feet at close range.
  • If the optional plugin is enabled, bots shouldn't now try to save a survivor if tanks are near them
  • Bots can now throw grenades at huge mob and tanks.
  • And other features that I forgot about due to too much work. Many of the features above can be disabled or tweaked in the config file.

ConVars:
PHP Code:

// If enabled, survivor bot will keep holding the prop it currently has unless it's swarmed by a mob, every teammate needs help, or it wants to use an item.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_alwayscarryprop "1"

// Makes survivor bots automatically shove every nearby infected. <0: Disabled, 1: All infected, 2: Only if infected is behind them>
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "2.000000"
l4d2_improvedbots_autoshove_enabled "1"

// If bots should avoid and retreat from tanks that are nearby punchable props like cars.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_avoidtanksnearpunchableprops "1"

// Makes survivor bots change their grenade type if there's too much of the same one, Ex. Pipe-Bomb to Molotov.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_changeweaponiftoomanysubtype_grenades "1"

// Makes survivor bots change their primary weapon subtype if there's too much of the same one, Ex. change AK-47 to M16 or SPAS-12 to Autoshotgun.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_changeweaponiftoomanysubtype_primaries "1"

// Enables survivor bots's charger dodging behavior.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_chargerevasion "1"

// Range at which survivor's dead body should be for bot to consider it reviveable.
// -
// Default: "2000"
// Minimum: "0.000000"
l4d2_improvedbots_defib_revive_distance "2000"

// Enable bots reviving dead players with defibrillators if they have one available.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_defib_revive_enabled "1"

// If bots should deploy their upgrade pack when available and not in combat.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_deployupgradepacks "1"

// If bots shouldn't switch to their pistol while they have sniper rifle equiped.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_dontswitchtopistol "1"

// Enables survivor bots' improved spitter acid evasion
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_evadespitteracids "1"

// Chance at which survivor bot may shove after firing a bolt-action sniper rifle. <0: Disabled, 1: Always>
// -
// Default: "3"
// Minimum: "0.000000"
l4d2_improvedbots_fireshove_chance_css_sniperrifles "3"

// Chance at which survivor bot may shove after firing a pump-action shotgun. <0: Disabled, 1: Always>
// -
// Default: "4"
// Minimum: "0.000000"
l4d2_improvedbots_fireshove_chance_pumpshotguns "4"

// Enables survivor bots throwing grenades.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_grenadethrowing_enabled "1"

// What grenades should survivor bots throw? <1: Pipe-Bomb, 2: Molotov, 4: Bile Bomb. Add numbers together.>
// -
// Default: "7"
// Minimum: "1.000000"
// Maximum: "7.000000"
l4d2_improvedbots_grenadethrowing_grenadetypes "7"

// Infected count required to throw grenade Multiplier (Value * SurvivorCount).
// -
// Default: "3.75"
// Minimum: "1.000000"
l4d2_improvedbots_grenadethrowing_horde_size_multiplier "3.75"

// Second number to pick to randomize next grenade throw time.
// -
// Default: "30"
// Minimum: "0.000000"
l4d2_improvedbots_grenadethrowing_next_throw_time_max "30"

// First number to pick to randomize next grenade throw time.
// -
// Default: "20"
// Minimum: "0.000000"
l4d2_improvedbots_grenadethrowing_next_throw_time_min "20"

// Range at which target needs to be for bot to throw grenade at it.
// -
// Default: "1500"
l4d2_improvedbots_grenadethrowing_throw_range "1500"

// Makes survivor bots force attack pinned survivor's SI if possible. <0: Disabled, 1: Shoot at attacker, 2: Shove the attacker if close enough. Add numbers together.>
// -
// Default: "3"
// Minimum: "0.000000"
// Maximum: "3.000000"
l4d2_improvedbots_help_pinnedfriend_enabled "3"

// Range at which bots will start firing at SI.
// -
// Default: "2000"
// Minimum: "0.000000"
l4d2_improvedbots_help_pinnedfriend_shootrange "2000"

// Range at which bots will start to bash SI.
// -
// Default: "75"
l4d2_improvedbots_help_pinnedfriend_shoverange "75"

// Enable improved bot item scavenging for specified items. <0: Disable, 1: Pipe Bomb, 2: Molotov, 4: Bile Bomb, 8: Medkit, 16: Defibrillator, 32: UpgradePack, 64: Pain Pills, 128: Adrenaline, 256: Laser Sights, 512: Ammopack, 1024: Ammopile, 2048: Chainsaw
// -
// Default: "16383"
// Minimum: "0.000000"
// Maximum: "16383.000000"
l4d2_improvedbots_itemscavenge_enabled "16383"

// How close should the item be to the survivor bot to able to count it when searching?
// -
// Default: "2500"
// Minimum: "0.000000"
l4d2_improvedbots_itemscavenge_mapsearchdistance "2500"

// The bots' scavenge distance is multiplied to this value when there's no human players left in the team.
// -
// Default: "3.0"
// Minimum: "0.000000"
l4d2_improvedbots_itemscavenge_nohumans_rangemultiplier "3.0"

// Distance at which item should be for bot to able to pick it up.
// -
// Default: "100"
// Minimum: "0.000000"
l4d2_improvedbots_itemscavenge_pickup_distance "100"

// Distance at which item should be for bot to move it.
// -
// Default: "300"
// Minimum: "0.000000"
l4d2_improvedbots_itemscavenge_scavenge_distance "300"

// Distance at which a visible item should be for bot to move it.
// -
// Default: "600"
// Minimum: "0.000000"
l4d2_improvedbots_itemscavenge_scavenge_visible_distance "600"

// If bots shouldn't stop moving in combat when there's no human players in team.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_keepmovingincombat "1"

// Range at which bot's target should be to start taking aim at it.
// -
// Default: "125"
// Minimum: "0.000000"
l4d2_improvedbots_melee_aim_range "125"

// Range at which bot's target should be to approach it. <0: Disable Approaching>
// -
// Default: "400"
// Minimum: "0.000000"
l4d2_improvedbots_melee_approach_range "400"

// Range at which bot's target should be to start attacking it.
// -
// Default: "70"
// Minimum: "0.000000"
l4d2_improvedbots_melee_attack_range "70"

// The total number of chainsaws allowed on the team. <0: Bots never use chainsaw>
// -
// Default: "1"
// Minimum: "0.000000"
l4d2_improvedbots_melee_chainsaw_limit "1"

// The nearby infected count required for bot to switch to chainsaw.
// -
// Default: "6"
// Minimum: "1.000000"
l4d2_improvedbots_melee_chainsaw_switch_count "6"

// Enables survivor bots' improved melee behaviour.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_melee_enabled "1"

// The total number of melee weapons allowed on the team. <0: Bots never use melee>
// -
// Default: "1"
// Minimum: "0.000000"
l4d2_improvedbots_melee_max_team "1"

// Chance for bot to bash target instead of attacking with melee. <0: Disable Bashing>
// -
// Default: "4"
// Minimum: "0.000000"
l4d2_improvedbots_melee_shove_chance "4"

// The nearby infected count required for bot to switch to their melee weapon.
// -
// Default: "3"
// Minimum: "1.000000"
l4d2_improvedbots_melee_switch_count "3"

// Range at which bot's target should be to switch to melee weapon.
// -
// Default: "250"
// Minimum: "0.000000"
l4d2_improvedbots_melee_switch_range "250"

// If enabled, survivor bots won't take fall damage if they were climbing a ladder just before that.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_nofalldmgonladderfail "1"

// Bots' data computing time delay (infected count, nearby friends, etc). Increasing the value might help increasing the game performance, but slow down bots.
// -
// Default: "0.1"
// Minimum: "0.033000"
l4d2_improvedbots_process_time "0.1"

// Enables survivor bots shooting tank's thrown rocks.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_shootattankrocks_enabled "1"

// Range at which rock needs to be for bot to start shooting at it.
// -
// Default: "1500"
// Minimum: "0.000000"
l4d2_improvedbots_shootattankrocks_range "1500"

// If bots should change their primary weapon to other one if they're using CSS weapons.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_switchoffcssweapon "1"

// If bots should take cover from tank's thrown rocks.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_takecoverfromtankrocks "1"

// Enables survivor bots' improved target selection.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_targetselection_enabled "1"

// If bots shouldn't target common infected that are currently not attacking survivors.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_targetselection_ignoredociles "1"

// Range at which target need to be for bots to start firing at it.
// -
// Default: "2000"
// Minimum: "0.000000"
l4d2_improvedbots_targetselection_shootrange "2000"

// Range at which target need to be for bots to start firing at it with secondary weapon.
// -
// Default: "1500"
// Minimum: "0.000000"
l4d2_improvedbots_targetselection_shootrange_pistol "1500"

// Range at which target need to be for bots to start firing at it with shotgun.
// -
// Default: "750"
// Minimum: "0.000000"
l4d2_improvedbots_targetselection_shootrange_shotgun "750"

// Range at which target need to be for bots to start firing at it with sniper rifle.
// -
// Default: "3000"
// Minimum: "0.000000"
l4d2_improvedbots_targetselection_shootrange_sniperrifle "3000"

// The total number of grenade launchers allowed on the team. <0: Bots never use grenade launcher>
// -
// Default: "1"
// Minimum: "0.000000"
l4d2_improvedbots_tier3weaponlimit_grenadelauncher "1"

// The total number of M60s allowed on the team. <0: Bots never use M60>
// -
// Default: "1"
// Minimum: "0.000000"
l4d2_improvedbots_tier3weaponlimit_m60 "1"

// The field of view of survivor bots.
// -
// Default: "60.0"
// Minimum: "0.000000"
// Maximum: "180.000000"
l4d2_improvedbots_vision_fieldofview "60.0"

// The time required for bots to notice enemy target is multiplied to this value.
// -
// Default: "1.1"
// Minimum: "0.000000"
// Maximum: "4.000000"
l4d2_improvedbots_vision_noticetimescale "1.1"

// Bot Bill's weapon preference. <0: Default, 1: Assault Rifle, 2: Shotgun, 3: Sniper Rifle, 4: SMG, 5: Secondary Weapon>
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "5.000000"
l4d2_improvedbots_weapon_preference_bill "1"

// Bot Coach's weapon preference. <0: Default, 1: Assault Rifle, 2: Shotgun, 3: Sniper Rifle, 4: SMG, 5: Secondary Weapon>
// -
// Default: "2"
// Minimum: "0.000000"
// Maximum: "5.000000"
l4d2_improvedbots_weapon_preference_coach "2"

// Bot Ellis's weapon preference. <0: Default, 1: Assault Rifle, 2: Shotgun, 3: Sniper Rifle, 4: SMG, 5: Secondary Weapon>
// -
// Default: "3"
// Minimum: "0.000000"
// Maximum: "5.000000"
l4d2_improvedbots_weapon_preference_ellis "3"

// Bot Francis's weapon preference. <0: Default, 1: Assault Rifle, 2: Shotgun, 3: Sniper Rifle, 4: SMG, 5: Secondary Weapon>
// -
// Default: "2"
// Minimum: "0.000000"
// Maximum: "5.000000"
l4d2_improvedbots_weapon_preference_francis "2"

// Bot Louis's weapon preference. <0: Default, 1: Assault Rifle, 2: Shotgun, 3: Sniper Rifle, 4: SMG, 5: Secondary Weapon>
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "5.000000"
l4d2_improvedbots_weapon_preference_louis "1"

// If every survivor bot should only use magnum instead of regular pistol if possible.
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d2_improvedbots_weapon_preference_magnums_only "0"

// Bot Nick's weapon preference. <0: Default, 1: Assault Rifle, 2: Shotgun, 3: Sniper Rifle, 4: SMG, 5: Secondary Weapon>
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "5.000000"
l4d2_improvedbots_weapon_preference_nick "1"

// Bot Rochelle's weapon preference. <0: Default, 1: Assault Rifle, 2: Shotgun, 3: Sniper Rifle, 4: SMG, 5: Secondary Weapon>
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "5.000000"
l4d2_improvedbots_weapon_preference_rochelle "1"

// Bot Zoey's weapon preference. <0: Default, 1: Assault Rifle, 2: Shotgun, 3: Sniper Rifle, 4: SMG, 5: Secondary Weapon>
// -
// Default: "3"
// Minimum: "0.000000"
// Maximum: "5.000000"
l4d2_improvedbots_weapon_preference_zoey "3"

// Allows survivor bots to crown witch on their path if they're holding any shotgun type weapon. <0: Disabled; 1: Only if survivor team doesn't have any human players; 2:Enabled>
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "2.000000"
l4d2_improvedbots_witchbehavior_allowcrowning "1"

// Survivor bots will start walking near witch if they're this range near her and she's not disturbed. <0: Disabled>
// -
// Default: "500"
// Minimum: "0.000000"
l4d2_improvedbots_witchbehavior_walkwhennearby "500" 


Change Log:
Code:

1.5 (14-June-2023)
    - Changed how the "l4d2_improvedbots_alwayscarryprop" convar functions on bots. Check the convar's description in the config for info.
    - Implemented the map start checks from Silvers' edit. Should prevent the NavAreaBuildPath related crashes from happening.
    - Bots should now use the melee weapons against distracted SI more frequently.
    - Slightly adjusted where survivor bots aim at tongue'd teammate when the smoker is not on sight.

1.4 (6-June-2023)
    - Slightly tweaked the default ConVar values.
    - Added a setting that makes survivor bots to not take any fall damage if they previously were on a ladder seconds ago.
    - Added a setting that controls the range survivors bots scan the map for items and weapons.
    - Optimized some variable that contain ConVar distances by squaring them at the change
    - Replaced the redundant GetMass SDKCall with a new found way to detect tank props.
    - Bots shouldn't melee approach targets that are behind their flow's path or if they're in any checkpoint.
    - Fixed bots going after witch that too far from them, causing major performance issues due to path building.
    - Bots' avoid range for infected are slightly increased, plus doubled if they're carrying a prop in their hands.
    - Slightly improved bots' spitter acid escape method.
    - Fixed bots dropping of the ladders due to their behavior still running during that.

1.3 (1-June-2023)
    - Fixed target selection and other SI-related stuff not working due to their data not being updated in the code.
    - Applied the witch arraylist optimization suggested by Silvers earlier.
    - Slightly increased the safe area search range when under spitter acid.

1.2 (26-May-2023)
    - Applied some code optimization changes suggested by Silvers. Plugin should now work slightly faster than before.

1.1 (24-May-2023)
    - Fixed an issue with some edicts being counted as survivor's inventory weapon.

1.0 (24-May-2023)
    - Initial release.


Requirements:

Installation:
  1. Download the .smx file and put into the \addons\sourcemod\plugins folder.
  2. Download the .txt gamedata file and put into the \addons\sourcemod\gamedata folder.

Emana202 05-24-2023 14:24

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by Maur0 (Post 2804923)
Excellent plugin. The only thing that bothers me are these messages that repeatedly come out and do not stop coming out. I don't know what error it can cause:

Code:

L 05/24/2023 - 14:55:22: [SM] Blaming: left4dhooks.smx
L 05/24/2023 - 14:55:22: [SM] Call stack trace:
L 05/24/2023 - 14:55:22: [SM]  [0] ThrowNativeError
L 05/24/2023 - 14:55:22: [SM]  [1] Line 174, l4dd\l4dd_natives.sp::ValidateAddress
L 05/24/2023 - 14:55:22: [SM]  [2] Line 1740, l4dd\l4dd_natives.sp::Native_GetCurrentFinaleStage
L 05/24/2023 - 14:55:22: [SM]  [4] L4D2_GetCurrentFinaleStage
L 05/24/2023 - 14:55:22: [SM]  [5] Line 3944, F:\Games\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d2_sb_ai_improver.sp::ShouldUseFlowDistance
L 05/24/2023 - 14:55:22: [SM]  [6] Line 1347, F:\Games\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d2_sb_ai_improver.sp::SurvivorBotThink
L 05/24/2023 - 14:55:22: [SM]  [7] Line 1256, F:\Games\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d2_sb_ai_improver.sp::OnPlayerRunCmd
L 05/24/2023 - 14:55:22: [SM] Exception reported: g_pScriptedEventManager not available (WIN/2/1.130).

And half that the function of the command to allow them to change the weapon does not work or is affected.

Do you have the latest version of Left 4 DHooks? If so, have you updated its gamedata with the one provided in the plugin's post?

Maur0 05-24-2023 15:05

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by Emana202 (Post 2804924)
Do you have the latest version of Left 4 DHooks? If so, have you updated its gamedata with the one provided in the plugin's post?

Oh God! Since I haven't checked it before. I'm sorry, my bad. I had updated the version to date, but I didn't see about the new gamedate. Thank you very much and your plugin is great, it improves the bots much better. :D

For now, I don't see anything wrong. I'll let you know if I notice something strange. :up: :)

Sev 05-24-2023 16:28

Re: [L4D2] Survivor Bot AI Improver
 
Good work.

TypicalType 05-24-2023 18:45

Re: [L4D2] Survivor Bot AI Improver
 
This plugin makes my server lag alot on the first level of Hard Rain and on the first and second levels of Dark Carnival and i don't know why that happens, only advancing further in the level makes the lag stop. And even removing some plugins doesn't help, maybe you could check it out?

Franco20 05-25-2023 12:12

Re: [L4D2] Survivor Bot AI Improver
 
This addon is Compatible with the mod "Left 4 Bots (Improved A.I.)" from steam?

Emana202 05-25-2023 12:57

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by TypicalType (Post 2804931)
This plugin makes my server lag alot on the first level of Hard Rain and on the first and second levels of Dark Carnival and i don't know why that happens, only advancing further in the level makes the lag stop. And even removing some plugins doesn't help, maybe you could check it out?

I checked on both of these campaigns and I didn't encounter any lags or issues. Maybe a dependency addon is outdated or something like that?

Emana202 05-25-2023 12:58

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by Franco20 (Post 2804990)
This addon is Compatible with the mod "Left 4 Bots (Improved A.I.)" from steam?

It's compatible, but you have to adjust some settings from either this plugin or the mod in order for them to work without any conflicts.

Silvers 05-25-2023 15:06

Re: [L4D2] Survivor Bot AI Improver
 
Since some players are mentioning performance issues I thought I would have a look and recommend some changes.


- You have some "FindConVar" within the think function and other places in code that you could place in plugin start to optimize the performance. Hooking the convar for change and using a variable instead of retrieving the value from the convar each time.


- "if (hWeaponList == null)delete hWeaponList;" and "if (hWepArray == null)delete hWepArray;" is not necessary, it's already null, no need to use delete here. Remove the whole line. Maybe there are other null checks you should remove, I only saw these skimming through.


- You should probably re-write "GetSurvivorTeamItemCount" and store the equipped weapons/items each player has when they equip it, instead of constantly looping through all clients and weapons checking what they have. Use SDKHook_WeaponEquipPost and store the weapon type in an array such as: "int g_iPlayerItems[MAXPLAYERS+1][6]" and instead of checking for the string, check for the weapon type ID instead. A list of weapon types and IDs can be found in left4dhooks.


- In some functions that are accessed a lot, especially from Think functions you could optimize the strings by changing "char" to "static char" so it's not re-created each time, unless (which I doubt anyway) you're expecting an empty string without writing data to it first before reading. You could probably change all the strings to this to save some CPU cycles.


- You don't need to use "strcopy" when assigning a string to something, for example:
PHP Code:

strcopy(sAimBonesizeof(sAimBone), (bIsUsingOldSkeleton "ValveBiped.Bip01_Head1" "bip_head")); 

you could just do:
PHP Code:

sAimBone = (bIsUsingOldSkeleton "ValveBiped.Bip01_Head1" "bip_head"); 


- In "OnPlayerRunCmd" you should probably move "if (!IsClientSurvivor(iClient)) return Plugin_Continue;" to the top before pulling the origin/nav area data.


- I don't know if the compiler optimizes for things like this, but instead of "500.0*500.0" just write "250000.0", there are multiple others like this.


- "GetWeaponMaxAmmo" could be optimized using a StringMap to search for the string and return the weapon ID instead, although I'm not sure the string checks are even necessary since you're using "GetWeaponAmmoType", looks like all the types are covered here. Again FindConVar here could be put into plugin start.


- "CheckEntityForItem" could be optimized to remove all the string checks, and match by weapon/item ID instead.


- "ShouldUseFlowDistance" could be optimized slightly to avoid calling the same native twice, by changing it to:
PHP Code:

bool ShouldUseFlowDistance()
{
    if( (!
L4D_IsSurvivalMode() && !L4D2_IsScavengeMode() )
    {
        
int stage L4D2_GetCurrentFinaleStage();
        if( (
stage == 18 || stage == 0) )
        {
            return 
true;
        }
    }

    return 
false;


Maybe applicable to other parts of the code to store a temporary variable instead of calling the same natives multiple times, I didn't check.


- It might be better to use "OnEntityCreated" instead of "ScanMapForEntities" in a timer since you're only checking for "witch" and "weapon_*" entities. Also: "FindEntityByClassname(-1, "*")" would probably be faster than looping through all entities as the function is currently doing. Or maybe: FindEntityByClassname(-1, "witch"); and: FindEntityByClassname(-1, "weapon*);
Might be a good idea to benchmark test and see which is the faster method.


- "g_hWitchList" could be initialized with "g_hWitchList = new ArrayList(2);" and set witch ref into index 0 and userid into index 1, instead of nesting multiple ArrayLists within the g_hWitchList ArrayList:
For example:
PHP Code:

int index g_hWitchList.Push(EntIndexToEntRef(iEntity));
g_hWitchList.Set(indexhEvent.GetInt("userid")); // or set to "0" as done when you initialize the array. 


- You might want to call "ClearEntityArrayLists" on "round_end" event too, for round restarts or versus 2nd round


- "Event_OnWeaponFire" could be optimized to use StringMap.ContainsKey or StringMap.GetValue to check if the weapon classname is correct. It might be optimized further by calling "GetRandomInt" for shotgun/sniper first then checking the strings if the value is 1. I would benchmark test if that's faster than comparing 2 strings that don't match. Also "static char" since its called often and you're filling the string data first before reading. The return within the if statement is unnecessary.


There are probably other areas that could be optimized, this is just what I noticed skimming through.

:up:

Kanashimi 05-25-2023 16:26

Re: [L4D2] Survivor Bot AI Improver
 
I keep getting this error on the command console. I have the latest DHooks and Actions installed.

Code:

L 05/25/2023 - 16:24:25: [SM] Exception reported: Native is not bound
L 05/25/2023 - 16:24:25: [SM] Blaming: g-misc\l4d2_sb_ai_improver.smx
L 05/25/2023 - 16:24:25: [SM] Call stack trace:
L 05/25/2023 - 16:24:25: [SM]  [0] __action_setlistener
L 05/25/2023 - 16:24:25: [SM]  [1] Line 901, actions_processors::BehaviorActionListeners.OnUpdatePost.set
L 05/25/2023 - 16:24:25: [SM]  [2] Line 5624, F:\Games\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d2_sb_ai_improver.sp::OnActionCreated


liquidplasma 05-25-2023 17:01

Re: [L4D2] Survivor Bot AI Improver
 
any way to make bots less of insta-death aimbot killing machines?

Mystik Spiral 05-25-2023 20:45

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by liquidplasma (Post 2805005)
any way to make bots less of insta-death aimbot killing machines?

Use this to adjust how long it takes the bots to react/notice an enemy:

// The time required for bots to notice enemy target is multiplied to this value.
// -
// Default: "1.0"
// Minimum: "0.000000"
// Maximum: "4.000000"
l4d2_improvedbots_vision_noticetimescale "1.0"

Use this to to give the bots less compute time (helps performance too):

// Bots' data computing time delay (infected count, nearby friends, etc). Increasing the value might help increasing the game performance, but slow down bots.
// -
// Default: "0.1"
// Minimum: "0.033000"
l4d2_improvedbots_process_time "0.1"

I have been using this plugin for some time and love it! The bots are not totally useless now, and depending on how you configure them, they can survive a campaign almost as well as a typical expert player.

Franco20 05-26-2023 12:19

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by Emana202 (Post 2804995)
It's compatible, but you have to adjust some settings from either this plugin or the mod in order for them to work without any conflicts.

What configurations are you referring to so that there is no conflict?

Emana202 05-26-2023 13:13

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by Franco20 (Post 2805061)
What configurations are you referring to so that there is no conflict?

Set those variables in the addon's settings.txt file:
Code:

throw_molotov = 0
throw_pipe_bomb = 0
throw_vomitjar = 0
spit_block_nav = 0
pickup_medkit = 0
pickup_molotov = 0
pickup_pills_adrenaline = 0
pickup_pipe_bomb = 0
pickup_vomitjar = 0
dodge_charger = 0
deploy_upgrades = 0


f1993062317 05-28-2023 13:32

Re: [L4D2] Survivor Bot AI Improver
 
sorry for my poor english
After l4d2 server crash,i get the Accelerator - Crash Reporting

https://crash.limetech.org/7h6bxp7q5fy4
https://crash.limetech.org/tzznp7joweqc

The following message is displayed in some information of the stack page, so I speculate that this plugin may cause the crash

PHP Code:

11sourcepawn.jit.x86.dll!sp::ScriptedInvoker::Invoke(int *) [ scripted-invoker.cpp:290 0x21 ]
      
https://github.com/alliedmodders/sourcepawn/blob/9cf9f31d4560fe7e76c6be75a2245088d03a3937/vm/scripted-invoker.cpp#L290
      
eip0x7c2a3925  esp0x0073d260  ebp0x0073d74c  

      0073d260  a5 01 00 00 c8 d6 73 00  c4 d7 73 00 3c 2c 23 00  
......s...s.<,#.
      
0073d270  fc 6c 34 64 32 5f 73 62  5f 61 69 5f 69 6d 70 72    l4d2_sb_ai_impr
      0073d280  6f 76 65 72 2e 73 6d 78  3a 3a 4f 6e 50 6c 61 79  over
.smx::OnPlay
      0073d290  65 72 52 75 6e 43 6d 64  00 e9 ba 29 00 fe 4e 2c  erRunCmd
...)..N,
      
0073d2a0  c7 38 2a 7c 70 09 23 0f  d0 fe 4e 2c d0 fe 4e 2c  .8*|p.#...N,..N,
      
0073d2b0  c4 d7 73 00 08 ff 4e 2c  70 d2 73 00 0b 00 00 00  ..s...N,p.s.....
      
0073d2c0  a0 9c 4c 2c 4e 5e d1 01  83 ef 04 b8 00 00 00 00  ..L,N^..........
      
0073d2d0  89 47 fc 83 ef 04 b8 00  01 00 00 89 47 fc 83 ef  .G..........G...
      
0073d2e0  04 b8 98 26 00 00 89 47  01 00 00 00 01 bc 26 00  ...&...G......&.
      
0073d2f0  bc e8 22 00 dc e8 ba 29  e4 f9 44 07 01 00 00 00  .."....)..D.... 


noto3 05-29-2023 20:47

Re: [L4D2] Survivor Bot AI Improver
 
Lastest l4dhooks

L 05/30/2023 - 02:42:49: [SM] Blaming: l4d2_sb_ai_improver.smx
L 05/30/2023 - 02:42:49: [SM] Call stack trace:
L 05/30/2023 - 02:42:49: [SM] [0] __action_setlistener
L 05/30/2023 - 02:42:49: [SM] [1] Line 901, actions_processors::BehaviorActionListeners.O nUpdatePost.set
L 05/30/2023 - 02:42:49: [SM] [2] Line 5736, F:\Games\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d2_ sb_ai_improver.sp::OnActionCreated

Silvers 05-30-2023 05:17

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by noto3 (Post 2805240)
Lastest l4dhooks

L 05/30/2023 - 02:42:49: [SM] Blaming: l4d2_sb_ai_improver.smx
L 05/30/2023 - 02:42:49: [SM] Call stack trace:
L 05/30/2023 - 02:42:49: [SM] [0] __action_setlistener
L 05/30/2023 - 02:42:49: [SM] [1] Line 901, actions_processors::BehaviorActionListeners.O nUpdatePost.set
L 05/30/2023 - 02:42:49: [SM] [2] Line 5736, F:\Games\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d2_ sb_ai_improver.sp::OnActionCreated

You're missing the first part of the error message: "Exception reported" line

noto3 05-30-2023 19:44

Re: [L4D2] Survivor Bot AI Improver
 
05/31/2023 - 01:44:28: [SM] Exception reported: Native is not bound

Kanashimi 06-01-2023 01:14

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by noto3 (Post 2805240)
Lastest l4dhooks

L 05/30/2023 - 02:42:49: [SM] Blaming: l4d2_sb_ai_improver.smx
L 05/30/2023 - 02:42:49: [SM] Call stack trace:
L 05/30/2023 - 02:42:49: [SM] [0] __action_setlistener
L 05/30/2023 - 02:42:49: [SM] [1] Line 901, actions_processors::BehaviorActionListeners.O nUpdatePost.set
L 05/30/2023 - 02:42:49: [SM] [2] Line 5736, F:\Games\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d2_ sb_ai_improver.sp::OnActionCreated

I figured out the problem, You need to download Actions. It's practically a requirement despite OP saying it's optional. Or, if you do have it downloaded, DL it again and replace. Otherwise, the game will continue stutter every 5 seconds when it spams that error code.

valedar 06-04-2023 14:15

Re: [L4D2] Survivor Bot AI Improver
 
PHP Code:

L 06/04/2023 21:32:37SourceMod error session started
L 06
/04/2023 21:32:37Info (map "c1m3_mall") (file "/game/left4dead2/addons/sourcemod/logs/errors_20230604.log")
L 06/04/2023 21:32:37: [SMException reportedEntity 448 (448is invalid
L 06
/04/2023 21:32:37: [SMBlamingl4d2_sb_ai_improver.smx
L 06
/04/2023 21:32:37: [SMCall stack trace:
L 06/04/2023 21:32:37: [SM]   [0GetEntProp
L 06
/04/2023 21:32:37: [SM]   [1Line 2216C:\compilation\l4d2_sb_ai_improver.sp::SurvivorBotThink
L 06
/04/2023 21:32:37: [SM]   [2Line 1399C:\compilation\l4d2_sb_ai_improver.sp::OnPlayerRunCmd
L 06
/04/2023 21:32:37: [SMException reportedProperty "m_nUpgradedPrimaryAmmoLoaded" not found (entity 77/weapon_spawn)
L 06/04/2023 21:32:37: [SMBlamingl4d2_sb_ai_improver.smx
L 06
/04/2023 21:32:37: [SMCall stack trace:
L 06/04/2023 21:32:37: [SM]   [0GetEntProp
L 06
/04/2023 21:32:37: [SM]   [1Line 2216C:\compilation\l4d2_sb_ai_improver.sp::SurvivorBotThink
L 06
/04/2023 21:32:37: [SM]   [2Line 1399C:\compilation\l4d2_sb_ai_improver.sp::OnPlayerRunCmd
L 06
/04/2023 21:38:54Error log file session closed


noto3 06-04-2023 16:39

Re: [L4D2] Survivor Bot AI Improver
 
Crash: ABQI-OXP4-GBRF

JLmelenchon 06-06-2023 22:02

Re: [L4D2] Survivor Bot AI Improver
 
You're touching something that result in distance points not counting correctly sometimes in versus, first time i have that and it is since i have this plugin. I noticed that you do not add EventHookMode_PostNoCopy to round start even, it can create bugs.

Edison1318 06-07-2023 13:16

Re: [L4D2] Survivor Bot AI Improver
 
The survivor bots seem to unable to throw grenades or deploy upgrade ammo packs. They just repeatedly equip it without using it. Then goes back to their firearms and does it again.

Zuriii 06-07-2023 14:39

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by Edison1318 (Post 2805670)
The survivor bots seem to unable to throw grenades or deploy upgrade ammo packs. They just repeatedly equip it without using it. Then goes back to their firearms and does it again.

I was noticing the same issue I had to turn off that feature in the config because of that. They just spam swap between their primary weapon and grenade when attempting to throw a grenade and sometimes they get stuck in a loop until they die.

kooper990 06-08-2023 01:36

Re: [L4D2] Survivor Bot AI Improver
 
Does this conflict with Gear Transfer? I was considering disabling/removing that other plugin until I notice you did not programmed the bots to optionally give and receive items from players.

NeoTM 06-08-2023 06:38

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by kooper990 (Post 2805714)
Does this conflict with Gear Transfer? I was considering disabling/removing that other plugin until I notice you did not programmed the bots to optionally give and receive items from players.

It deem to work fine for me for the moment but i only tested it for 2 days.

I have set it to grab only the chainsaw and it seem to work fine.

i tested a bit with and without "Action" and didn't see much different for now, but i let Action installed for now for testing if there is crash people are playing on it.

However, since i have this plugin installed, Source Admin tool didn't show the rules and their value and it also don't show the metamod and sourcemod revision.

I also found my server restarting in loop yesterday and the error was "accelerator dump limit reached".

I erased the dump file in sourcemod/data/dump and it seem to have fix the issue.

I will see tonight if the server is still up

kooper990 06-08-2023 10:04

Re: [L4D2] Survivor Bot AI Improver
 
who knows, things did change with the improver version. I think I will wait it out and see replies from others

NeoTM 06-08-2023 15:27

Re: [L4D2] Survivor Bot AI Improver
 
I completely forgot to say to the author that his plugin is top.
The only thing I was not able to set was the bots behavior.
My servers was too hard to play with bots but a real pleasure to play with good players (which is rare), so i had to set it less hard because it was too painful to play solo.
Now, because of this mod, I can set my servers as hard as I wanted them and after a little setting for the process time to 1,5 and vision notice time scale to 1,8, bots are far better and useful.
But i must admit that the default settings made the bots too good (I was able to stand in place and do nothing and almost never get hurt while without the mod it was a real pain to stay alive).

kooper990 06-08-2023 15:50

Re: [L4D2] Survivor Bot AI Improver
 
I also experience other user's issue with bots stuttering with throwable items

NeoTM 06-08-2023 18:00

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by kooper990 (Post 2805750)
I also experience other user's issue with bots stuttering with throwable items

I had no problems in almost 4 hours of test but i found that the bots was kind of wasting pipe or bile bomb because they didn't throw them at the best moment or at the best place.

I prefer to use bots as storage as i use gear transfert.

But i set them to use the chainsaw and to deploy special ammo.

3 bots with chainsaw is really fun :)

kooper990 06-08-2023 20:29

Re: [L4D2] Survivor Bot AI Improver
 
that is also true. BTW, I wish for another feature for this plugin; we can set the options to allow what items for bots to throw at the tank, and perhaps change where they exactly throw the item -- like say at the general direction of the incoming horde?-- otherwise, they made the strategy worse

NeoTM 06-09-2023 15:48

Re: [L4D2] Survivor Bot AI Improver
 
I did few tests yesterday and i had 2 times my server crashing ans stuck in a restart loop.

I reboot my computer ans start the server but it was restarting every 10 sec and the console write a segmentation core error (or something like that)

I had to uninstall the plugin to be able to have my server to start.

I will do more tests tonight (with and without "action" and without gear transfert.

Update:

My server crashed again and i manage to copy the content of the console.

Spoiler

and i had to remove the plugin or my server keep restarting with this message:
Spoiler

valedar 06-11-2023 11:00

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by NeoTM (Post 2805797)
I did few tests yesterday and i had 2 times my server crashing ans stuck in a restart loop.

I reboot my computer ans start the server but it was restarting every 10 sec and the console write a segmentation core error (or something like that)

I had to uninstall the plugin to be able to have my server to start.

I will do more tests tonight (with and without "action" and without gear transfert.

Update:

My server crashed again and i manage to copy the content of the console.

Spoiler

and i had to remove the plugin or my server keep restarting with this message:
Spoiler

I also get a server crash once a day.
./srcds_run: line 341: 25707 Segmentation fault (core dumped) $HL_CMD

valedar 06-11-2023 11:03

Re: [L4D2] Survivor Bot AI Improver
 
author, thanks for your wonderful plugin, really, but please, please correct your mistakes properly, the server really crashes because of it :D the plugin is really great)

Mystik Spiral 06-11-2023 14:05

Re: [L4D2] Survivor Bot AI Improver
 
I am afraid I am going to jinx myself by saying this, but I have been using this plugin since before it was posted on AlliedModders and I have never had it crash my server on Windows (but I have had plenty of exceptions reported). I wonder if those of you getting server crashes are all running Linux?

chungocanh12 06-13-2023 00:31

Re: [L4D2] Survivor Bot AI Improver
 
thanks for your wonderful plugin

Silvers 06-13-2023 07:38

Re: [L4D2] Survivor Bot AI Improver
 
1 Attachment(s)
This is a modified version of 1.4 - I sent to someone and they reported it no longer crashes.

Author: please compare to see the changes.

Calling some natives before OnMapStart seems to be the crash. The next left4dhooks update will simply block the calls but for now you can add these checks into your plugin (and since some others maybe slow in updating left4dhooks). L4D2_NavAreaBuildPath and other NavArea natives, and a few other things.

There are more things that could be optimized, I haven't had time to go through and write anything about it.

kooper990 06-15-2023 10:29

Re: [L4D2] Survivor Bot AI Improver
 
Does anyone have a potential bug where the bots never picks up the Grenade launcher and or M60? there is no weapon pref. option for them, so....

Mystik Spiral 06-15-2023 19:53

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by kooper990 (Post 2806052)
Does anyone have a potential bug where the bots never picks up the Grenade launcher and or M60? there is no weapon pref. option for them, so....

I have seen them pick up tier3 weapons.

Run these two commands on the server console to verify the values:

sm_cvar l4d2_improvedbots_tier3weaponlimit_grenadelau ncher
sm_cvar l4d2_improvedbots_tier3weaponlimit_m60

kooper990 06-16-2023 10:53

Re: [L4D2] Survivor Bot AI Improver
 
Quote:

Originally Posted by Mystik Spiral (Post 2806068)
I have seen them pick up tier3 weapons.

Run these two commands on the server console to verify the values:

sm_cvar l4d2_improvedbots_tier3weaponlimit_grenadelau ncher
sm_cvar l4d2_improvedbots_tier3weaponlimit_m60

Yes, the grenade launcher is ON 1. The M60 is disabled on my behalf.

] sm_cvar l4d2_improvedbots_tier3weaponlimit_grenadelau ncher
[SM] Value of cvar "l4d2_improvedbots_tier3weaponlimit_grenadela uncher": "1"


All times are GMT -4. The time now is 18:19.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.