Left 4 Dead 2

Left 4 Dead 2

Left 4 Bots 2
Sniper Bots Fix
I know Bot Primary Weapon Enforcer exist but I was thinking if there is a way to make the bots use snipers like they do with the rest of the weapons, rifles or something so they don't switch up to pistols every time they use snipers
< >
Showing 1-15 of 27 comments
smilzo  [developer] 17 Mar @ 9:00am 
I think via vscript you can only do what Primary Weapon Enforcer already does, i don't know if there is another way to do it. Maybe a cvar or some property in the weapon scripts, i don't know.
4512369781  [developer] 17 Mar @ 10:05am 
Originally posted by smilzo:
I think via vscript you can only do what Primary Weapon Enforcer already does, i don't know if there is another way to do it. Maybe a cvar or some property in the weapon scripts, i don't know.
Maybe can modify the "m_hOwner" props of the secondary weapon like you did before with carry items, I thinks this is the only way to do it via vscript.
Pensie 17 Mar @ 10:12am 
The weird part is sometimes they use it without problems and sometimes not so much, if it is possible sure if not, that's ok too.
smilzo  [developer] 17 Mar @ 11:12am 
Originally posted by 4512369781:
Originally posted by smilzo:
I think via vscript you can only do what Primary Weapon Enforcer already does, i don't know if there is another way to do it. Maybe a cvar or some property in the weapon scripts, i don't know.
Maybe can modify the "m_hOwner" props of the secondary weapon like you did before with carry items, I thinks this is the only way to do it via vscript.
It may work but you also need to handle the logics to let/not let switch to secondary. My idea was lazier lol, it was to force the vanilla AI to use the sniper rifles like it does with the assault ones. Unless Valve hardcoded the weapon names for that behavior, which is also possible.
Pensie 17 Mar @ 4:18pm 
Originally posted by smilzo:
Originally posted by 4512369781:
Maybe can modify the "m_hOwner" props of the secondary weapon like you did before with carry items, I thinks this is the only way to do it via vscript.
It may work but you also need to handle the logics to let/not let switch to secondary. My idea was lazier lol, it was to force the vanilla AI to use the sniper rifles like it does with the assault ones. Unless Valve hardcoded the weapon names for that behavior, which is also possible.
Exactly what I was thinking, and if that doesn't work, maybe force bots to use primary weapon until they run out of ammo ( clip not the whole reserve ) and that way work
4512369781  [developer] 18 Mar @ 3:59am 
Originally posted by Pensie:
Originally posted by smilzo:
It may work but you also need to handle the logics to let/not let switch to secondary. My idea was lazier lol, it was to force the vanilla AI to use the sniper rifles like it does with the assault ones. Unless Valve hardcoded the weapon names for that behavior, which is also possible.
Exactly what I was thinking, and if that doesn't work, maybe force bots to use primary weapon until they run out of ammo ( clip not the whole reserve ) and that way work

I think it's worth a try, simple logic is best, and "Primary Weapon Enforcer" also has Reload problem.
Pensie 18 Mar @ 7:28am 
Originally posted by 4512369781:
Originally posted by Pensie:
Exactly what I was thinking, and if that doesn't work, maybe force bots to use primary weapon until they run out of ammo ( clip not the whole reserve ) and that way work

I think it's worth a try, simple logic is best, and "Primary Weapon Enforcer" also has Reload problem.
Well there is an edit of the mod by a guy named RF or something like that, didn't seem to have that problem, but I might need to test it more
4512369781  [developer] 18 Mar @ 9:35am 
Originally posted by Pensie:
Well there is an edit of the mod by a guy named RF or something like that, didn't seem to have that problem, but I might need to test it more
We are talking about the same mod, there is this comment "Reload bug where they reset their reload timer again when they attempt to switch is still here tho" in the mod, but it doesn't happen often.
for me I just don't let bots use sniper, actually I have never thought about how to handle the sniper problems before, lol.
smilzo  [developer] 19 Mar @ 2:45am 
Guys i did a quick test yesterday, apparently this behavior is hardcoded in the vanilla AI and it's linked to the WeaponType parameter of the weapon script.
I got the vanilla scripts of the ak47 and the hunting rifle and i swapped their WeaponType param in a test vpk. The bot with the ak started switching to the pistols when i spawned infected nearby and the bot with the hunting rifle did not.
So maybe the solution is make a weapon script addon with just the sniper rifles with their WeaponType parameter set to "rifle" instead of "sniper_rifle", but i don't know if that will affect anything else.
Last edited by smilzo; 19 Mar @ 2:45am
4512369781  [developer] 19 Mar @ 3:47am 
Originally posted by smilzo:
Guys i did a quick test yesterday, apparently this behavior is hardcoded in the vanilla AI and it's linked to the WeaponType parameter of the weapon script.
I got the vanilla scripts of the ak47 and the hunting rifle and i swapped their WeaponType param in a test vpk. The bot with the ak started switching to the pistols when i spawned infected nearby and the bot with the hunting rifle did not.
So maybe the solution is make a weapon script addon with just the sniper rifles with their WeaponType parameter set to "rifle" instead of "sniper_rifle", but i don't know if that will affect anything else.

wow, what an easy trick!, all I can think of is that it will conflict with other weapon script mods.
Pensie 19 Mar @ 4:19am 
Originally posted by 4512369781:
Originally posted by smilzo:
Guys i did a quick test yesterday, apparently this behavior is hardcoded in the vanilla AI and it's linked to the WeaponType parameter of the weapon script.
I got the vanilla scripts of the ak47 and the hunting rifle and i swapped their WeaponType param in a test vpk. The bot with the ak started switching to the pistols when i spawned infected nearby and the bot with the hunting rifle did not.
So maybe the solution is make a weapon script addon with just the sniper rifles with their WeaponType parameter set to "rifle" instead of "sniper_rifle", but i don't know if that will affect anything else.

wow, what an easy trick!, all I can think of is that it will conflict with other weapon script mods.
Well, Honestly I can't believe I didn't think of that, I mostly thought it was something foe the game to recognize. I already have a mod that makes guns more realistic, If I make this change no one will ever know either way hahahahah
Pensie 19 Mar @ 4:21am 
Originally posted by smilzo:
Guys i did a quick test yesterday, apparently this behavior is hardcoded in the vanilla AI and it's linked to the WeaponType parameter of the weapon script.
I got the vanilla scripts of the ak47 and the hunting rifle and i swapped their WeaponType param in a test vpk. The bot with the ak started switching to the pistols when i spawned infected nearby and the bot with the hunting rifle did not.
So maybe the solution is make a weapon script addon with just the sniper rifles with their WeaponType parameter set to "rifle" instead of "sniper_rifle", but i don't know if that will affect anything else.
From working with scripts like this, it shouldn't affect anything, game already uses %change for spawning, RNG type stuff, and I don't think it will affect spawns and if it does we will see more sniper ones, which I don't mind, but I will test this
Pensie 19 Mar @ 4:46am 
I could kiss you guys! Well yea, changing the weapontype in scripts is what fixed it and I will update my own mod with the change, it doesn't seem to change anything else, bots work as intended!
4512369781  [developer] 19 Mar @ 7:43am 
I made this for test.
enforce sniper or shotgun[drive.google.com]
smilzo  [developer] 19 Mar @ 7:47am 
Nevermind guys, i think the weapontype trick does affect the weapon spawns. Not all of them, probably the ones that are set to spawn only sniper rifles. For example in c2m2, on the table next to the gnome there is only one weapon instead of the usual two.
Last edited by smilzo; 19 Mar @ 7:51am
< >
Showing 1-15 of 27 comments
Per page: 1530 50