Raised This Month: $51 Target: $400
 12% 

[TF2] Give Bots Weapons (04.01.2023)


Post New Thread Reply   
 
Thread Tools Display Modes
MasterKiller777
Junior Member
Join Date: Jun 2016
Old 04-25-2020 , 15:09   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #91

nice~! I'll be looking forward to it.
MasterKiller777 is offline
89night
Junior Member
Join Date: Aug 2020
Old 08-07-2020 , 14:53   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #92

I had some questions that while yes, they could be answered by simply looking up the information myself, I felt could be answered more thoroughly by you. I'm new to things like plugins and I'd be lying if I said I wasn't intimidated by the sheer amount of files, commands, and code that all seem like random jargon to me.
Now on to the actual questions.

Regarding the Give Bots Weapons plugin, I was wondering how to make bots switch to a specific unlockable weapon/weapon slot and only use said weapon. In my case, I would like both teams consisting of snipers to use the Cleaner's Carbine for the entire game.

Reading the replies in this thread, I saw a few people mention that they were looking to do things similar to what I'm trying to do and your response was for them to simply configure the plugin to their custom preferences. How do I do that exactly?

I'd like to thank you for making this plugin as well, it's been a blast fighting bots that use weapons other than stock. I hope to hear from you soon!
89night is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 08-07-2020 , 23:30   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #93

89night... you can download the .sp file, and edit it to suit your needs.

In this case, you want all snipers to only have/use one weapon, the Cleaner's Carbine, which according to the item definition index wiki has an index of 751 (link: https://wiki.alliedmods.net/Team_For....5BSlot_1.5D_8)

Basic steps:
1. download givebotsweapons.sp file
2. edit it using editor such as notepad++
3. search for sniper in plugin.
4. remove all the code in the Sniper section since it currently gives the Sniper random primary, secondary, and melee weapons. We don't want random weapons for Sniper
5. add new code in sniper section that removes current primary, melee, and secondary weapon slots to remove currently equipped weapons
6. add new code in sniper section that gives the Sniper a Cleaner's Carbine secondary weapon (item index number 751)
7. add new code/function that forces the sniper to switch to/use the Cleaner's Carbine weapon slot
8. save newly edited .sp file
9. compile .sp file. It will create a .smx plugin file
10. put new .smx plugin file in plugin directory
11. change map or restart server
12. you are done

edit sniper section:
PHP Code:
            case TFClass_Sniper:
                {
                    
TF2_RemoveWeaponSlot(client0);
                    
TF2_RemoveWeaponSlot(client1);
                    
                    
CreateWeapon(client"tf_weapon_charged_smg"751);
                    
                    
TF2_RemoveWeaponSlot(client2);
                    
                    
TF2_SwitchtoSlot(client1);
                } 
add function to switch active slot:
PHP Code:
stock void TF2_SwitchtoSlot(int clientint slot)
{
    if (
slot >= && slot <= && IsClientInGame(client) && IsPlayerAlive(client))
    {
        
char wepclassname[64];
        
int wep GetPlayerWeaponSlot(clientslot);
        if (
wep MaxClients && IsValidEdict(wep) && GetEdictClassname(wepwepclassnamesizeof(wepclassname)))
        {
            
FakeClientCommandEx(client"use %s"wepclassname);
            
SetEntPropEnt(clientProp_Send"m_hActiveWeapon"wep);
        }
    }

I did this in the attached file for your review.

Enjoy!
Attached Files
File Type: sp Get Plugin or Get Source (GiveBotsWeapons_sniper_edit.sp - 245 views - 34.7 KB)
PC Gamer is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 10-10-2020 , 21:20   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #94

Any news on the new version?
__________________
manicogaming is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 10-11-2020 , 15:07   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #95

Luki1312 said he was working on a combined version. I had difficulty making a version of this that combined weapons and outfits for Bots. For some reason it kept crashing the server. Very strange.

I say very strange because I made a similar plugin that combines outfits and weapons for Human players and it works fairly well. One minor glitch that I haven't solved is that the HUD display of weapon inventory (when you scroll the mouse) doesn't always show your currently equipped weapons. When you touch locker you get a different random outfit and weapons for your current class. When you die you respawn as a random different class with random outfit and weapons for the new class. See video below.

Human Randomizer example with HUD bug:
PC Gamer is offline
war100ck
Senior Member
Join Date: Oct 2010
Old 12-16-2020 , 06:17   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #96

Hi, please tell me what the second 20 value after the index 155 is responsible for?

For example:
PHP Code:
{
   
CreateWeapon(client"tf_weapon_wrench"15520);

__________________

Last edited by war100ck; 12-16-2020 at 06:30.
war100ck is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-16-2020 , 12:47   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #97

Quote:
Originally Posted by war100ck View Post
Hi, please tell me what the second 20 value after the index 155 is responsible for?

For example:
PHP Code:
{
   
CreateWeapon(client"tf_weapon_wrench"15520);

It depends on the function. In this case 20 is the item level. More specifically, the client would receive a level 20 Southern Hospitality wrench (item Definition 155)
PC Gamer is offline
Dragonisser
AlliedModders Donor
Join Date: Jan 2014
Location: Germany
Old 06-22-2021 , 15:15   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #98

Updated gamedata for todays(2021.06.22) update

Code:
"Games"
{
	/* Team Fortress 2 */
	"tf"
	{
		"Offsets"
		{
			"WeaponEquip"
			{
				"windows"	"265"
				"linux"		"266"
				"mac"		"266"
			}
			
			"EquipWearable"
			{
				"windows"	"431"
				"linux"		"432"
				"mac"		"432"
			}
		}
	}
}
Dragonisser is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 06-30-2021 , 11:53   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #99

Quote:
Originally Posted by Dragonisser View Post
Updated gamedata for todays(2021.06.22) update

Code:
"Games"
{
	/* Team Fortress 2 */
	"tf"
	{
		"Offsets"
		{
			"WeaponEquip"
			{
				"windows"	"265"
				"linux"		"266"
				"mac"		"266"
			}
			
			"EquipWearable"
			{
				"windows"	"431"
				"linux"		"432"
				"mac"		"432"
			}
		}
	}
}
Thanks
__________________
luki1412 is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 10-10-2021 , 12:12   Re: [TF2] Give Bots Weapons (10.10.2021)
Reply With Quote #100

Updated to v1.2

Here's some background info:
-I have noticed that bots sometimes do not get any different weapons. I assumed that it was just random chance not giving them anything, but then i noticed multiple bots in one spawn wave not getting any weapons. That felt strange so I started testing and debugging. Although my code for the delay is correct, it assumes the bots just spawn and work. That seems to be false, sometimes these bots respawn multiple times and it happens within milliseconds. I modified how the plugin handles the delay when giving weapons. Now it works as intended. Now it doesn't matter how many times they respawn.
-I gave engie Windowmaker because even if he cant hit anything, he can switch to his pistol if he runs out of metal
-The mvm cvar was added if anyone wants to use this plugin in the mode however I do not recommend it still. Use at your own risk

I do recommend everyone using my plugin to update their copy.
__________________

Last edited by luki1412; 10-10-2021 at 12:13.
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 12:22.


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