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

[TF2] Set Player's Weapon & Force Fire


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
flintb
Junior Member
Join Date: Mar 2009
Old 07-12-2010 , 07:12   [TF2] Set Player's Weapon & Force Fire
Reply With Quote #1

I'm making a plugin that allows me to control bots. Right now I'm trying to figure out how to force a bot to change to a specific weapon. I'm also trying to figure out how to force him to shoot. I've been searching through the wiki, forums, existing plugins, and other sites and I can't find anything that would work (for TF2 at least). Any suggestions would be greatly appreciated!
flintb is offline
noodleboy347
AlliedModders Donor
Join Date: Mar 2009
Old 07-13-2010 , 13:34   Re: [TF2] Set Player's Weapon & Force Fire
Reply With Quote #2

bot_forceattack 1

bot_selectweaponslot <0-2> use to work before the Engi Update, I don't think it does anymore though.
noodleboy347 is offline
flintb
Junior Member
Join Date: Mar 2009
Old 07-15-2010 , 04:04   Re: [TF2] Set Player's Weapon & Force Fire
Reply With Quote #3

Thanks for the idea, but this isn't what I was looking for. I want to control bots individually and bot_forceattack forces all the bots to shoot. Also, these commands require sv_cheats 1 and I'd like cheats to be off so plays can receive achievements. Is there a way to do this at the plugin level such as FireEvent()?
flintb is offline
DarkEnergy
SourceMod Donor
Join Date: Apr 2008
Location: Georgia Tech, MSECE
Old 07-15-2010 , 12:10   Re: [TF2] Set Player's Weapon & Force Fire
Reply With Quote #4

Quote:
Originally Posted by flintb View Post
Thanks for the idea, but this isn't what I was looking for. I want to control bots individually and bot_forceattack forces all the bots to shoot. Also, these commands require sv_cheats 1 and I'd like cheats to be off so plays can receive achievements. Is there a way to do this at the plugin level such as FireEvent()?
srs? get a friend and an achievement server
DarkEnergy is offline
flintb
Junior Member
Join Date: Mar 2009
Old 07-17-2010 , 03:12   Re: [TF2] Set Player's Weapon & Force Fire
Reply With Quote #5

Wow... these forums are extremely useless... Or at the very least the last two posts are useless. I'm not trying to get my own achievements. If that was my goal, I wouldn't be posting in a forum that is for people developing SM plugins for servers... I'm trying to make my own achievement server and I plan on having features that I haven't found in any other server (or in some cases only 1 or 2 servers, but still). If I wanted help playing TF2 I'd post in the Steam forums. If I wanted to understand server commands I'd Google it. I'm trying to get help with sm plugin functions. Now that I've (hopefully) made that clear, can anyone help me achieve what I'm ACTUALLY trying to do?
flintb is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 07-17-2010 , 03:37   Re: [TF2] Set Player's Weapon & Force Fire
Reply With Quote #6

you can try to create your own NPC and control him like that
__________________
Peoples Army is offline
flintb
Junior Member
Join Date: Mar 2009
Old 07-17-2010 , 04:11   Re: [TF2] Set Player's Weapon & Force Fire
Reply With Quote #7

Let me clarify my last statement. I no way to I want to insult anyone who help me. I'm simply getting angry because I don't think I've really received any actual help yet. I just want to make some quality plugins and I ask for help with the code any everyone starts giving me ideas that have anything to do with writing code. That's where I'm coming from.
flintb is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-17-2010 , 05:21   Re: [TF2] Set Player's Weapon & Force Fire
Reply With Quote #8

I understand your frustration flintb.

Now hopefully I can help you out.

Look in sdktools_functions.inc and find EquipPlayerWeapon(client, weapon); I think that should help you force a bot to use a weapon. You can combine that with SDKHooks' WeaponEquip hook to prevent them from switching away to the weapon you want them to use.

As for forcing them to attack you can try this, but I don't know if it works:

Code:
new flags = GetEntityFlags(client);
if (!(flags & IN_ATTACK))  // if you know bitwise operators better than me then you can do it the right way.  i think its (flags ~& IN_ATTACK)
{
    SetEntProp(client, Prop_Data, "m_fFlags", flags|IN_ATTACK);
}
I don't know if flags were meant to be set like that, but it's worth a try. You might have to repeat this every game frame. (public OnGameFrame)
__________________

Last edited by Greyscale; 07-18-2010 at 03:53.
Greyscale is offline
flintb
Junior Member
Join Date: Mar 2009
Old 07-17-2010 , 05:31   Re: [TF2] Set Player's Weapon & Force Fire
Reply With Quote #9

Thank you for the help! That's what I was looking for. I looked into EquipPlayerWeapon some but I only found how to equip CSS weapons. Do you know where I might be able to find a TF2 weapon index list? I haven't found one yet. I guess I can also do trial and error if worst comes to worst (although that might take a while). Also, the weapon flag description says "CBaseCombatWeapon entity index.". What exectly does "CBase" in "CBaseCombatWeapon" mean (if anything)?
flintb is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-17-2010 , 05:38   Re: [TF2] Set Player's Weapon & Force Fire
Reply With Quote #10

Code:
GetPlayerWeaponSlot(client, slot);
0 is primary, 1 secondary and so on. This will return the weapon entity index in the client's loadout.

Also, by your wording it seems you think that each weapon as an assigned index. Each weapon in game has a unique entity index. So there can be 10 eyelanders in use in the game, each with their own index. The function above will return that index for you.

"CBase" means it exists for all source games. It's a classname in the engine's source code. There are game-specific classes as well such as CCS and CTF, which is CS:S and TF2 specific, respectively.
__________________
Greyscale is offline
Reply


Thread Tools
Display Modes

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 03:33.


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