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

[L4D2] Weapon, Survivor, Gamemode identification includes (Trie)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 06-21-2011 , 13:11   [L4D2] Weapon, Survivor, Gamemode identification includes (Trie)
Reply With Quote #1

Description
There are a lot of plugins that don't take full advantage of the wonderful ADT_Trie Sourcemod provides us. I've made three includes that will help L4D2 plugin makers take advantage of the efficiency of Tries. These will also help people simplify identification of survivors, weapons, and gamemodes.

survivors.inc
Very simply, survivors.inc allows you to identify survivors quicky based on their player model. It also contains string arrays that will let you lookup the character names and models from a character ID.

weapons.inc
This will help you identify weapons quickly based on their classname. It works on weapon_spawn, weapon_X_spawn, and weapon_X style entities. As far as I know, it can identify any weapon entity.

Also included is a function to "convert" a weapon spawn. If you want to, say, convert all SMGs into M60s, it is very simple. You can also lookup weapon names and models from the arrays in the .inc.

gamemodes.inc
This will help you identify gamemodes and base gamemodes. Right now, the content is static, but I may eventually switch it to read from the live gamemodes.txt on the system. Basically, if you're writing a plugin that will behave differently on different gamemodes, then this is very useful. Instead of doing 20+ string compares in a row, you can simply do GameModeStringToId(), and maybe follow up with GetBaseGameMode(), and determine your plugin behavior from there.

Headers
The .incs are short and well commented, so I'm not sure there's use to put these here. I'll consider it later.

Examples
I'll put up more of these later, but for now, here's a Test Plugin I've been using to test out these .incs:
https://bitbucket.org/ProdigySim/mis.../testplugin.sp
L4D2 Double-standup fix

Installation/Usage
Place these .incs in your sourcemod/scripting/include/ folder and then include them in your project with
#include <survivors>
#include <weapons>
#include <gamemodes>

You can also place them in a local directory and use #include "survivors.inc" if you want.

tl; dr - If you need to identify gamemodes, weapons, or survivors in your plugins, you should use these .incs or something similar!
Attached Files
File Type: inc gamemodes.inc (4.5 KB, 353 views)
File Type: inc survivors.inc (2.6 KB, 460 views)
File Type: inc weapons.inc (10.1 KB, 417 views)

Last edited by ProdigySim; 06-22-2011 at 13:21.
ProdigySim is offline
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 06-22-2011 , 13:18   Re: [L4D2] Weapon, Survivor, Gamemode identification includes (Trie)
Reply With Quote #2

Here's a diff of a plugin of DieTeeTasse's that I adapted to use survivors.inc.

https://bitbucket.org/ProdigySim/mis...d2_getupfix.sp

Notice how GetSurvivorIndex(), a series of string compares, has been completely replaced by IdentifySurvivor().
ProdigySim is offline
ZzZombo
Member
Join Date: May 2012
Location: Ravenholm
Old 05-20-2012 , 03:41   Re: [L4D2] Weapon, Survivor, Gamemode identification includes (Trie)
Reply With Quote #3

I don't like your way of determining survivor characters by model name, you should check m_survivorCharacter netprop instead.
ZzZombo is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-20-2012 , 03:59   Re: [L4D2] Weapon, Survivor, Gamemode identification includes (Trie)
Reply With Quote #4

It depends what you want the check for... the netprop will allow them to vocalize as that character, but the model could be different... look at CSM. I think the model check is best, since people will most likely want to do something with the character they look like, and not some other character because their voice is different. For example some plugins use Bill model only to prevent crashes.

Edit: Regarding the gamemodes, I personally create the info_gamemode entity and fire it's PostSpawnActivate input, to determine gamemode. Regardless of the mp_gamemode (for example mutation12 is still Versus), it reports back if the mode is: Coop,Survival,Versus,Scavenge. Not realism.
__________________

Last edited by Silvers; 05-20-2012 at 04:02.
Silvers is offline
ZzZombo
Member
Join Date: May 2012
Location: Ravenholm
Old 06-03-2012 , 03:02   Re: [L4D2] Weapon, Survivor, Gamemode identification includes (Trie)
Reply With Quote #5

Quote:
Originally Posted by Silvers View Post
It depends what you want the check for... the netprop will allow them to vocalize as that character, but the model could be different... look at CSM. I think the model check is best, since people will most likely want to do something with the character they look like, and not some other character because their voice is different. For example some plugins use Bill model only to prevent crashes.
You should check netprop just because tehnically it's possible to change model to any other model.
ZzZombo is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-03-2012 , 11:21   Re: [L4D2] Weapon, Survivor, Gamemode identification includes (Trie)
Reply With Quote #6

Quote:
Originally Posted by ZzZombo View Post
You should check netprop just because tehnically it's possible to change model to any other model.
So for Incapped Crawling, instead of taking the model name and creating a clone of that, I should use the netprop and create the clone of another Survivor? No, it all depends on what you want to do.
__________________
Silvers is offline
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 06-10-2012 , 05:34   Re: [L4D2] Weapon, Survivor, Gamemode identification includes (Trie)
Reply With Quote #7

There could be a use for having both of those detection methods. Using the model was needed for what I used this inc for originally.

Now the functionality of these are being moved to other projects so I probably won't be updating them directly.

Others interested can check out https://github.com/Jahze/l4d2util
ProdigySim 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 06:02.


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