Raised This Month: $32 Target: $400
 8% 

[TF2] Give Bots Weapons (04.01.2023)


Post New Thread Reply   
 
Thread Tools Display Modes
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 08-31-2022 , 03:28   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #111

Quote:
Originally Posted by Markus_Wyand View Post
Oh, forget about it, i actually found a work around it to make it work properly.
I just had to experiment and tweak the code a little.
**ORIGINAL BY YOU**:
case TFClass_Soldier:
{
int rnd = GetRandomUInt(0,3);
if(rnd != 0)
{
TF2_RemoveWeaponSlot(client, 0);
}
switch (rnd)
{
case 1:
{
CreateWeapon(client, "tf_weapon_rocketlauncher_directhit", 127, 1);
}
**WHAT I DID**:
case TFClass_Soldier:
{
int rnd = GetRandomUInt(1,3);
{
switch (rnd)
{
case 1:
{
TF2_RemoveWeaponSlot(client, 0);
CreateWeapon(client, "tf_weapon_rocketlauncher", 1; **<-- this supposed to be 18**
}

Basically removed the " if(rnd != 0) ", changed the order of some stuff, forced the bot to pick from 1,3 instead of 0,3 and add the Default Weapon (in this case the rocket launcher [18]) for the bot to choose it.
This way they are forced to pick one of the 3 weapons, and dont go A pose or missing weapons anymore.
Works like a charm. But thanks for answering, didn't expect to get attention since the last reply was 1 year ago...
the if statement is there so we dont remove the default weapon because based on the random int generator, that was chosen and the bot already has the stock weapon. removing the if statement just makes the performance worse, since youre removing the stock weapon the bot has and then giving them the same weapon afterwards(unless you dont bother with stock weapons at all). a better thing to do would be to find the source of the problem.
__________________
luki1412 is offline
Markus_Wyand
Junior Member
Join Date: Aug 2022
Old 09-18-2022 , 01:29   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #112

Alright, still cant find a solution, so i better re-download the .sp and start from 0.
I need to know how can i FORCE a bot to use a weapon.
For example i want demomen bots to always use the ali baba booties.

Last edited by Markus_Wyand; 09-18-2022 at 01:30.
Markus_Wyand is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 09-18-2022 , 15:29   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #113

Quote:
Originally Posted by Markus_Wyand View Post
Alright, still cant find a solution, so i better re-download the .sp and start from 0.
I need to know how can i FORCE a bot to use a weapon.
For example i want demomen bots to always use the ali baba booties.
You'd have to edit the code to remove the random weapons, then insert the one weapon you want the class to always use. I took the liberty of editing the attached code to do what you want. In this case the DemoMan will always wear the Ali Baba Booties and equip the Chargin' Targe shield.

Note: Tested. Works.
Attached Files
File Type: sp Get Plugin or Get Source (GiveBotsWeapons.sp - 41 views - 35.7 KB)

Last edited by PC Gamer; 09-20-2022 at 01:32.
PC Gamer is offline
Markus_Wyand
Junior Member
Join Date: Aug 2022
Old 09-18-2022 , 15:42   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #114

Quote:
Originally Posted by PC Gamer View Post
You'd have to edit the code to remove the random weapons, then insert the one weapon you want the class to always use. I took the liberty of editing the attached code to do what you want. In this case the DemoMan will always wear the Ali Baba Booties.

Note: Not tested.
I will test it out
later then i want to check out how to continue the code, like to make demos use Chargin targe and Eyelander
After that, i just need to replicate this code for the other classes?
EDIT: It doesnt work :/

Last edited by Markus_Wyand; 09-18-2022 at 15:58.
Markus_Wyand is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 09-18-2022 , 17:02   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #115

Quote:
Originally Posted by Markus_Wyand View Post
Alright, still cant find a solution, so i better re-download the .sp and start from 0.
I need to know how can i FORCE a bot to use a weapon.
For example i want demomen bots to always use the ali baba booties.
I cannot replicate the problem either but if u want a specific weapon only then remove the switch statement and just do Remove weapon slot and Create weapon
__________________
luki1412 is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 09-18-2022 , 18:33   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #116

Quote:
Originally Posted by Markus_Wyand View Post
EDIT: It doesnt work :/
Saying 'it doesn't work' is rarely helpful.

I just tested the plugin edited for you and it works as you requested. Every Demoman was wearing the booties as their primary weapon with random weapons for secondary and melee. Other classes were getting random weapons.

Since it doesn't work for you I can only speculate that you aren't using the latest gamedata file (give.bots.weapons.txt) available in the original post which is needed to give Bots wearable weapons. It may also be possible that you are using some sort of cosmetic plugin which may be the replacing the booties with other footwear.

Note: gamedata files can often become outdated when TF2 is updated. If the gamedata file is outdated the plugin will not fully work as intended. In the case of this plugin if you have an outdated gamedata file the bots will not be able to receive wearable weapons but other weapons can be equipped. If you see that happening look for a new gamedata file.

Last edited by PC Gamer; 09-18-2022 at 18:40.
PC Gamer is offline
Markus_Wyand
Junior Member
Join Date: Aug 2022
Old 09-18-2022 , 21:10   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #117

Quote:
Originally Posted by PC Gamer View Post
Saying 'it doesn't work' is rarely helpful.

I just tested the plugin edited for you and it works as you requested. Every Demoman was wearing the booties as their primary weapon with random weapons for secondary and melee. Other classes were getting random weapons.

Since it doesn't work for you I can only speculate that you aren't using the latest gamedata file (give.bots.weapons.txt) available in the original post which is needed to give Bots wearable weapons. It may also be possible that you are using some sort of cosmetic plugin which may be the replacing the booties with other footwear.

Note: gamedata files can often become outdated when TF2 is updated. If the gamedata file is outdated the plugin will not fully work as intended. In the case of this plugin if you have an outdated gamedata file the bots will not be able to receive wearable weapons but other weapons can be equipped. If you see that happening look for a new gamedata file.
Yeah, i tried both the original and your edited version, none of those work for me now.
I guess something went wrong with my sourcemod, ill try reinstalling and test the plugin again.
EDIT: Reinstalled BOTH sourcemod and the plugin/s, and the give.bots.weapons.txt and something is wrong with my game, bots aren't using any unlockable.
I will look for a solution.
EDIT2: Funny thing... apparently starting tf2 with +map "mvm map" makes bots not equip weapons, that is weird.
The edited plugin works as intended, and i also forced demos to use chargin targe shield and eyelander sword after the booties.
Many thanks for the patience, sure i did lots of mistakes.

Last edited by Markus_Wyand; 09-19-2022 at 02:55.
Markus_Wyand is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 09-19-2022 , 03:00   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #118

Quote:
Originally Posted by Markus_Wyand View Post
Yeah, i tried both the original and your edited version, none of those work for me now.
I guess something went wrong with my sourcemod, ill try reinstalling and test the plugin again.
EDIT: Reinstalled BOTH sourcemod and the plugin/s, and the give.bots.weapons.txt and something is wrong with my game, bots aren't using any unlockable.
I will look for a solution.
EDIT2: Funny thing... apparently starting tf2 with +map "mvm map" makes bots not equip weapons, that is weird.
The edited plugin works as intended, and i also forced demos to use chargin targe shield and eyelander sword after the booties.
Many thanks for the patience, sure i did lots of mistakes.
You never mentioned MVM lmao. Theres a cvar for mvm on the front page!
__________________
luki1412 is offline
Markus_Wyand
Junior Member
Join Date: Aug 2022
Old 09-19-2022 , 03:46   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #119

Quote:
Originally Posted by luki1412 View Post
You never mentioned MVM lmao. Theres a cvar for mvm on the front page!
No, i didn't use it for MVM, i just had my launch parameter set to "mvm coaltown"
And apparently that made the plugin impossible to load, even if i switched maps through console/create server.
EDIT: I give up, i can't seem to modify properly the plugin without corrupting it or something.
After 1 ROUND some bots stop receiving certain weapon slots (For example medic gets its secondary slot removed and gets no medigun whatsoever, i try to inspect his weapons with F and only the syringe gun (primary) and ubersaw (melee) appear... creepy.)
If you had the time, i wish to upload my version of the .SP file so you can check out what i am doing wrong...
Attached Files
File Type: sp Get Plugin or Get Source (GiveBotsWeapons.sp - 41 views - 31.4 KB)

Last edited by Markus_Wyand; 09-19-2022 at 03:55.
Markus_Wyand is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 09-19-2022 , 04:34   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #120

Quote:
Originally Posted by Markus_Wyand View Post
No, i didn't use it for MVM, i just had my launch parameter set to "mvm coaltown"
And apparently that made the plugin impossible to load, even if i switched maps through console/create server.
EDIT: I give up, i can't seem to modify properly the plugin without corrupting it or something.
After 1 ROUND some bots stop receiving certain weapon slots (For example medic gets its secondary slot removed and gets no medigun whatsoever, i try to inspect his weapons with F and only the syringe gun (primary) and ubersaw (melee) appear... creepy.)
If you had the time, i wish to upload my version of the .SP file so you can check out what i am doing wrong...
You're changing the values for GetRandomInt incorrectly.
Remember, it's generating a random number from the specified range, inclusively. 0 means the stock weapon. The game gives them stock weapons and I have to remove them and give them different ones. Stock weapons the game gives them sometimes dont show up correctly when pressing F. If we get a 0 from GetRandomInt, I dont do anything and just move to another slot, if we get a nonzero, we Remove their weapon from that slot and the switch statement gives them another weapon based on the value. So the range in GetRandomInt HAS to have corresponding cases in the switch statement(excluding 0).

I do not know what exactly are you trying to achieve with my plugin. Are you trying to give them all melee weapons only?
__________________
luki1412 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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