for Half-Life 2 » Scenery and Setting
updated Sun Dec 4th 2005 at 1:48pm
0 faves
0 ratings
8303 views
Weapon Pickups
updated Sun Dec 4th 2005 at 1:48pm
0 faves
0 ratings
8303 views
by Guessmyname (view all articles)

unrated

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