Snarkpit Articles


Advanced Weapon Pickups


There are quite a few games around, resident evil for example, where you have to pickup weapons and items manually. This tutorial will show you how to do the same in HL2SP (not tried DM yet. Theoretically, it could be done using !activator for the game_player_equip entity, but I'd have to test it)

Step 1.
Create a prop_dynamic on the ground where you want your weapon to be. Name it <weaponname>_pickupmodel_1 where <weaponname> is the name of the weapon/item/whatever thats "used" to pick up. Set the model to that of the item or weapon to be collected. Make sure that all the flags are unchecked.

TUTORIAL EXAMPLE
For the purposes of this tutorial, we will be using the pistol. So the prop_dynamic would be named pistol_pickupmodel_1 and the model would be set to models/weapons/w_pistol.mdl.

Step 2.
Create a func_button covering the prop_dynamic. Texture it completly with the toolsinvisible texture (not the nodraw texture). Name it <weaponname>_pickupbutton_1 where <weaponname> is the name of the thingy being picked up. Make sure that the "Don't Move" and "Use Activates" flags are checked and all others are not.

TUTORIAL EXAMPLE
In this example the button would be named pistol_pickupbutton_1

Step 3.
Create a trigger_multiple over the prop_dynamic and func_button and texture it with the tools/trigger texture. Name it <weaponname>_pickupmessagetrigger_1 where <weaponname> is the name of the item to be collected. Make sure that only the "Only clients *not* in vehicles" flag is checked.

TUTORIAL EXAMPLE
In this example the trigger_multiple would be named pistol_pickupmessagetrigger_1

Step 4.
Create a game_text entity near to the pickup. Name it <weaponname>_pickupmessage_1 where <weaponname> is the name of the pickup. In the message box type in Press E to pickup item. In the y box type in 0.9. Make sure that the "All players flag is unchecked.

TUTORIAL EXAMPLE
In this example the game_text entity would be named pistol_pickupmessage_1

Step 5.
This is the tricky bit. Create a game_player_equip entity beside the pickup. Name it <weaponname>_pickupentity_1 where <weaponname> is the name of the pickup. Disable SmartEdit and add a new keyvalue. Name the keyvalue <sdkweaponname> where <sdkweaponname> is the sdk name of the pickup, ie weapon_ar2 for the Combine Rifle or item_healthkit for the healthkit. Give the keyvalue a value of 1. Make sure that the "Use Only" flag is checked so that the game_player_equip isn't activated by running over it.

TUTORIAL EXAMPLE
In this example the keyvalue would be named weapon_pistol and the game_player_equip entity would be named pistol_pickupentity_1

Step 6.
Inputs/Ouputs time.

Give the func_button an output: "OnPressed" "<weaponname>_pickupentity_1" (where <weaponname is the name of the pickup) "Use" (The "Use" input for the game_player_equip isn't in the fgd so Hammer won't like it. It works fine ingame however) with no delay and "!player" in the parameters box.

Give the func_button an Output: "OnPressed" "<weaponname>_pickupmodel_1" (where <weaponname is the name of the pickup) "TurnOff" with no delay or special parameters

Give the func_button an Output: "OnPressed" "<weaponname>_pickupmessagetrigger_1" (where <weaponname is the name of the pickup) "Disable" with no delay or special parameters

Give the func_button an Output: "OnPressed" "<weaponname>_pickupbutton_1" (where <weaponname is the name of the pickup) "Lock" with no delay or special parameters

Give the trigger_multiple an Output: "OnTrigger" "<weaponname>_pickupmessage_1" (where <weaponname is the name of the pickup) "Display" with no delay or special parameters

TUTORIAL EXAMPLE
The func_button's outputs:
"OnPressed" "pistol_pickupentity_1" "Use" "!player"
"OnPressed" "pistol_pickupmodel_1" "TurnOff"
"OnPressed" "pistol_pickupmessagetrigger_1" "Disable"
"OnPressed" "pistol_pickupbutton_1" "Lock"
The trigger_multiple's Output:
"OnTrigger" "pistol_pickupmessage_1" "Display"

Bugs/problems
1. NPCs will not be able to pick up the weapon/item
2. You won't be able to pull the weapon/item to you with the grav gun. I suppose it could be done using a prop_physics instead of prop_dynamic however.
3. The "Use" Input for the game_player_equip isn't in the fgd. It works ingame, its just Hammer won't like it.
4. The invisible button isn't passable. Make it as short as you can

Example vmf
Here


Post ReplyView Topic
Discussion
0 starsPosted by FIDDLER on Mon Jun 25th 2007 at 9:27am

Very good tutorial. I like the idea of having to instruct your character to pick something up instead of the &quot;magical&quot; pickup when you run over the top of something.
0 starsPosted by Flynn on Thu Jan 4th 2007 at 5:10pm

0 starsPosted by Kasc1990 on Sat Jan 28th 2006 at 2:22pm

Well infact to all you haters, this tutorial would be good, if you are making a mod, like resident evil.
If you dont understand the input/output then there4s a tutorial to learn.
Nicely organised, understood fully.
0 starsPosted by Captain P on Sun Dec 18th 2005 at 12:46pm

I understand the goal of this tutorial, but instead of immediatly jumping onto the technical details, I'd like to see a quick overview of the idea first, so I know where I'll be working towards to. All that technical stuff is more intimidating without some pictures and a rough idea of the methods behind it.
0 starsPosted by Biological Component on Wed Dec 14th 2005 at 2:04am

That's awesome! And as for the not being able to pull it with the grav gun...I think that could come in handy, and is not a problem as far as I'm concerned!
[author]
Posted by Guessmyname on Sun Dec 11th 2005 at 10:06am

Omega, this is a different way of doing weapon pickups. Instead of running over them to pick them up, you have to stop and press the use key on the weapon to pick it up. This is mainly for SP horror maps. For instance: You're running like hell from a load of zombies or whatever because you're out of ammo. Stop for a second, and they might catch you. With just a weapon_&lt;weaponname&gt; you could simply keep running, magically pick up a gun and blast them all. With this, you'd have to stop and try to grab it as quickly as you can. Simply put, it adds to the tension
0 starsPosted by omegaslayer on Fri Dec 9th 2005 at 6:11pm

I fail to see the point of this...... I mean why not use weapon_&lt;weapon name&gt;? This is just making an excessive amount of entities that arent needed. Why make 5 differenet enities when you can use just 1?
The only place I can see this being useful is if you want the player to select ONLY 1 weapon form a selection of others (eg: the player can only select the AR2 OR the SMG1, not both) May want to include that in the tut, otherwise the usefulness of this tut goes down the drain.
0 starsPosted by HazardGameR^ on Thu Dec 8th 2005 at 6:28pm

Sorry, but to be honest, this sucks... Need pictures. The Output part makes you confused if you are new at it. And lastly, and the most important for me in tutorials, you can't see the &quot;structure&quot; which means that you sometimes forget to give the reason why to set that value to that, or why to make that output, and what it does, why to use invisible texture instead of nodraw etc... It's like a step-on-step guide to make a motor, that teaches you how to make it, but you have no idea how/why it works.

What i like about it is that you (I) learned things from it if you understand it.
Either make it more newbie-friendly, or make some &quot;requirements&quot; in the top so that a newbie don't read through it, misunderstand it, get's frustrated and suicides because of his misserable life smiley And now that I'm at it, I am a little newbie myself, but i think i have stepped pretty much into the &quot;Intermediate&quot; stage now :P
0 starsPosted by parakeet on Mon Dec 5th 2005 at 2:57am

Wow , this is kinda neat

Pictures would be nice , but I think the example vmf kinda makes up for it =D.

Havent tried it yet , it sounds slightly haxy , but i like it that way..
Post ReplyView Topic