Pick up the crowbar of research scientist Gordon Freeman, who finds himself on an alien-infested Earth being picked to the bone, its resources depleted, its populace dwindling. Freeman is thrust into the unenviable role of rescuing the world from the wrong he unleashed back at Black Mesa. And a lot of people, people he cares about, are counting on him.

Report article Easy Pickable Weapon System Tutorial By Morais PGSI

This is a really easy tutorial on how to make the E key in half life 2 ep 2 pick up weapons.

Posted by MoraisPGSI on Aug 16th, 2009 digg this super bookmark
Basic Client Side Coding.


 This is a tutorial that i wanted to share with peaple who dont know how to do a easy pickable weapon system.

Just open your solution and search for basecombatweapon_shared.cpp in Client episodic - Source Files.

In the file you will find this class function :
   void CBaseCombatWeapon::DefaultTouch( CBaseEntity *pOther )

All you need to do is comment everything inside this function:   /*   Everything inside    */

Heres how it should look like:    

  1. C++ code:
  1. void CBaseCombatWeapon::DefaultTouch( CBaseEntity *pOther )
  2. {
  3.  
  4. /*
  5. #if !defined( CLIENT_DLL )
  6.   // Can't pick up dissolving weapons
  7.   if ( IsDissolving() )
  8.     return;
  9.  
  10.   // if it's not a player, ignore
  11.   CBasePlayer *pPlayer = ToBasePlayer(pOther);
  12.   if ( !pPlayer )
  13.     return;
  14.  
  15.   if( UTIL_ItemCanBeTouchedByPlayer(this, pPlayer) )
  16.   {
  17.     // This makes sure the player could potentially take the object
  18.     // before firing the cache interaction output. That doesn't mean
  19.     // the player WILL end up taking the object, but cache interactions
  20.     // are fired as soon as you prove you have found the object, not
  21.     // when you finally acquire it.
  22.     m_OnCacheInteraction.FireOutput( pOther, this );
  23.   }
  24.  
  25.   if( HasSpawnFlags(SF_WEAPON_NO_PLAYER_PICKUP) )
  26.     return;
  27.  
  28.   if (pPlayer->BumpWeapon(this))
  29.   {
  30.     OnPickedUp( pPlayer );
  31.   }
  32. #endif
  33.  
  34. */
  35. }

 


If you want a simple hint hud just add the following code:
 

  1. C++ code:
  1. #if !defined( CLIENT_DLL )
  2.   CBasePlayer *pPlayer = ToBasePlayer(pOther);
  3.   if ( !pPlayer )
  4.     return;
  5.  
  6.  
  7.   UTIL_HudHintText( pPlayer, "Valve_Hint_PicKUp" );
  8.  
  9.  
  10. #endif

Now it should look like:

  1. C++ code:
  1. void CBaseCombatWeapon::DefaultTouch( CBaseEntity *pOther )
  2. {
  3.  
  4. //SIMPLE HUD IMPLEMENTATION
  5. #if !defined( CLIENT_DLL )
  6.   CBasePlayer *pPlayer = ToBasePlayer(pOther);
  7.   if ( !pPlayer )
  8.     return;
  9.  
  10.  
  11.   UTIL_HudHintText( pPlayer, "Valve_Hint_PicKUp" );
  12.  
  13. #endif
  14.  
  15.  
  16.  
  17.  
  18. /*
  19.  
  20. #if !defined( CLIENT_DLL )
  21.   // Can't pick up dissolving weapons
  22.   if ( IsDissolving() )
  23.     return;
  24.  
  25.   // if it's not a player, ignore
  26.   CBasePlayer *pPlayer = ToBasePlayer(pOther);
  27.   if ( !pPlayer )
  28.     return;
  29.  
  30.   if( UTIL_ItemCanBeTouchedByPlayer(this, pPlayer) )
  31.   {
  32.     // This makes sure the player could potentially take the object
  33.     // before firing the cache interaction output. That doesn't mean
  34.     // the player WILL end up taking the object, but cache interactions
  35.     // are fired as soon as you prove you have found the object, not
  36.     // when you finally acquire it.
  37.     m_OnCacheInteraction.FireOutput( pOther, this );
  38.   }
  39.  
  40.   if( HasSpawnFlags(SF_WEAPON_NO_PLAYER_PICKUP) )
  41.     return;
  42.  
  43.   if (pPlayer->BumpWeapon(this))
  44.   {
  45.     OnPickedUp( pPlayer );
  46.   }
  47. #endif
  48.  
  49. */
  50. }

And if you wanna add a custom hint hud use the following code:

  1. C++ code:
  1. void CBaseCombatWeapon::DefaultTouch( CBaseEntity *pOther )
  2. {
  3.  
  4.  
  5. #if !defined( CLIENT_DLL )
  6.   CBasePlayer *pPlayer = ToBasePlayer(pOther);
  7.   if ( !pPlayer )
  8.     return;
  9.  
  10.  
  11.   UTIL_HudHintText( pPlayer, "Valve_Hint_PicKUpWeapon" );//Valve_Hint_PickUpWeapon does not exists yet
  12.  
  13. #endif
  14.  
  15. /*
  16.  
  17. #if !defined( CLIENT_DLL )
  18.   // Can't pick up dissolving weapons
  19.   if ( IsDissolving() )
  20.     return;
  21.  
  22.   // if it's not a player, ignore
  23.   CBasePlayer *pPlayer = ToBasePlayer(pOther);
  24.   if ( !pPlayer )
  25.     return;
  26.  
  27.   if( UTIL_ItemCanBeTouchedByPlayer(this, pPlayer) )
  28.   {
  29.     // This makes sure the player could potentially take the object
  30.     // before firing the cache interaction output. That doesn't mean
  31.     // the player WILL end up taking the object, but cache interactions
  32.     // are fired as soon as you prove you have found the object, not
  33.     // when you finally acquire it.
  34.     m_OnCacheInteraction.FireOutput( pOther, this );
  35.   }
  36.  
  37.   if( HasSpawnFlags(SF_WEAPON_NO_PLAYER_PICKUP) )
  38.     return;
  39.  
  40.   if (pPlayer->BumpWeapon(this))
  41.   {
  42.     OnPickedUp( pPlayer );
  43.   }
  44. #endif
  45.  
  46. */
  47. }

After doing that go to modfoldier\resource\modname_english.txt. If you dont have it use the following(it is already finished):
 

  1. Text code:
  1. "lang"
  2. {
  3. "Language" "English"
  4. "Tokens"
  5. {
  6. "Valve_Listen_MapName"      "Map"
  7. "Valve_Movement_Title"      "MOVEMENT"
  8. "Valve_Move_Forward"      "Move forward"
  9. "Valve_Move_Back"     "Move back"
  10. "Valve_Turn_Left"     "Turn left"
  11. "Valve_Turn_Right"      "Turn right"
  12. "Valve_Move_Left"     "Move left (strafe)"
  13. "Valve_Move_Right"      "Move right (strafe)"
  14. "Valve_Jump"        "Jump"
  15. "Valve_Duck"        "Duck"
  16. "Valve_Swim_Up"       "Swim up"
  17. "Valve_Swim_Down"     "Swim down"
  18. "Valve_Look_Up"       "Look up"
  19. "Valve_Look_Down"     "Look down"
  20. "Valve_Look_Straight_Ahead"   "Look straight ahead"
  21. "Valve_Strafe_Modifier"     "Strafe modifier"
  22. "Valve_Mouse_Look_Modifier"   "Mouse look modifier"
  23. "Valve_Keyboard_Look_Modifier"    "Keyboard look modifier"
  24. "Valve_Use_Items"     "Use item (buttons, machines, ...)"
  25. "Valve_Communication_Title"   "COMMUNICATION"
  26. "Valve_Use_Voice_Communication"   "Use voice communication"
  27. "Valve_Chat_Message"      "Chat message"
  28. "Valve_Team_Message"      "Team message"
  29. "Valve_Combat_Title"      "COMBAT"
  30. "Valve_Primary_Attack"      "Primary attack"
  31. "Valve_Secondary_Attack"    "Secondary attack"
  32. "Valve_Reload_Weapon"     "Reload weapon"
  33. "Valve_Walk"        "Walk (Move Slowly)"
  34. "Valve_Flashlight"      "Flashlight"
  35. "Valve_Spray_Logo"      "Spray logo"
  36. "Valve_Weapon_Category_1"   "Weapon category 1"
  37. "Valve_Weapon_Category_2"   "Weapon category 2"
  38. "Valve_Weapon_Category_3"   "Weapon category 3"
  39. "Valve_Weapon_Category_4"   "Weapon category 4"
  40. "Valve_Weapon_Category_5"   "Weapon category 5"
  41. "Valve_Weapon_Category_6"   "Weapon category 6"
  42. "Valve_Weapon_Category_7"   "Weapon category 7"
  43. "Valve_Weapon_Category_8"   "Weapon category 8"
  44. "Valve_Weapon_Category_9"   "Weapon category 9"
  45. "Valve_Weapon_Category_0"   "Weapon category 0"
  46. "Valve_Previous_Weapon"     "Previous weapon"
  47. "Valve_Next_Weapon"     "Next weapon"
  48. "Valve_Last_Weapon_Used"    "Last weapon used"
  49. "Valve_Miscellaneous_Title"   "MISCELLANEOUS"
  50. "Valve_Display_Scores"      "Display multiplayer scores"
  51. "Valve_Take_Screen_Shot"    "Take screen shot"
  52. "Valve_Quick_Save"      "Quick save"
  53. "Valve_Quick_Load"      "Quick load"
  54. "Valve_Pause_Game"      "Pause game"
  55. "Valve_Quit_Game"     "Quit game"
  56. "Valve_Accept_Redirect"     "Accept redirect to another server"
  57. "Valve_ServerOfferingToConnect"   "The server is offering to connect you to:"
  58. "Valve_PressKeyToAccept"    "Press %s1 to accept."
  59. "Valve_BindKeyToAccept"     "Please configure a key to accept."
  60. "Valve_Cheer"       "Cheer"
  61. "Valve_Activate_In_Game_GUI"    "Activate in-game GUI"
  62. "Valve_Change_Team"     "Change team"
  63. "Valve_Change_Class"      "Change class"
  64. "Valve_Use_Special_Skill"   "Use special skill"
  65. "Valve_Multiplayer_Decal_Limit"   "Multiplayer decal limit"
  66. "Valve_Valid_Teams"     "Valid teams, leave blank for all"
  67. "Valve_Frag_Limit"      "Frag Limit"
  68. "Valve_Time_Limit"      "Time Limit (Min.)"
  69. "Valve_Falling_Damage"      "Falling Damage"
  70. "Valve_Normal"        "Normal"
  71. "Valve_Realistic"     "Realistic"
  72. "Valve_Teamplay"      "Teamplay"
  73. "Valve_Friendly_Fire"     "Friendly Fire"
  74. "Valve_Weapons_Stay"      "Weapons Stay"
  75. "Valve_Force_Respawn"     "Force Respawn"
  76. "Valve_Footsteps"     "Footsteps"
  77. "Valve_Autocrosshair"     "Autocrosshair"
  78. "Valve_Center_Player_Names"   "Center player names"
  79. "Valve_Switch_Weapons_Immediately"  "Switch weapons immediately"
  80. "Valve_Automatic_Screenshots"   "Automatically take end-game screenshots"
  81. "Valve_Observer_Crosshair"    "Observer crosshair"
  82.  
  83. "Spec_Slow_Motion" "Slow Motion"
  84. "Spec_No_PIP" "
  85. Picture-In-Picture is not available
  86. in First-Person mode while playing.
  87. "
  88.  
  89. "Spec_Replay" "Instant Replay"
  90. "Spec_Auto" "Auto"
  91. "Spec_Time" "Time"
  92. "Spec_Map" "Map: %s1"
  93. "Spectators" "Spectators"
  94. "Spec_PlayerItem_Health" "%s1 (%s2)"
  95. "Spec_PlayerItem" "%s1"
  96. "Spec_PlayerItem_Team" "%s1 (%s2)"
  97. "Spec_Duck" "Press DUCK for Spectator Menu"
  98. "Spec_Help_Title" "Spectator Mode"
  99. "Spec_Help_Text"  "
  100. Use the following keys to change view styles:
  101.  
  102.  FIRE1 - Chase next player
  103.  FIRE2 - Chase previous player
  104.  JUMP - Change view modes
  105.  USE - Change inset window mode
  106.  
  107.  DUCK  - Enable spectator menu
  108.  
  109. In Overview Map Mode move around with:
  110.  
  111.  MOVELEFT - move left
  112.  MOVERIGHT - move right
  113.  FORWARD - zoom in
  114.  BACK - zoom out
  115.  MOUSE - rotate around map/target
  116. "
  117.  
  118. "Spec_Modes"  "Camera Options"
  119. "Spec_Mode0"  "Camera Disabled"
  120. "Spec_Mode1"  "Death Camera"
  121. "Spec_Mode2"  "Fixed View"
  122. "Spec_Mode3"  "First Person"
  123. "Spec_Mode4"  "Chase Camera"
  124. "Spec_Mode5"  "Free Look"
  125. "Spec_Mode6" "Chase Map Overview"
  126. "Spec_NoTarget" "No valid targets. Cannot switch Camera Mode."
  127. "Spec_Options"  "Options"
  128. "OBS_NONE" "Camera Options"
  129. "OBS_CHASE_LOCKED" "Locked Chase Camera"
  130. "OBS_CHASE_FREE" "Free Chase Camera"
  131. "OBS_ROAMING" "Free Look"
  132. "OBS_IN_EYE" "First Person"
  133. "OBS_MAP_FREE" "Free Map Overview"
  134. "OBS_MAP_CHASE" "Chase Map Overview"
  135. "SPECT_OPTIONS" "Options"
  136. "CAM_OPTIONS" "Camera Options"
  137.  
  138. "PlayerName"  "Name"
  139. "PlayerScore" "Score"
  140. "PlayerDeath" "Deaths"
  141. "PlayerPing"  "Latency"
  142. "PlayerVoice" "Voice"
  143. "PlayerTracker" "Friend"
  144.  
  145. "T0A0TITLE" "HAZARD COURSE"
  146. "C0A0TITLE" "BLACK MESA INBOUND"
  147. "C0A1TITLE" "ANOMALOUS MATERIALS"
  148. "C1A1TITLE" "UNFORESEEN CONSEQUENCES"
  149. "C1A2TITLE" "OFFICE COMPLEX"
  150. "C1A3TITLE" "WE'VE GOT HOSTILES"
  151. "C1A4TITLE" "BLAST PIT"
  152. "C2A1TITLE" "POWER UP"
  153. "C2A2TITLE" "ON A RAIL"
  154. "C2A3TITLE" "APPREHENSION"
  155. "C2A4TITLE1"  "RESIDUE PROCESSING"
  156. "C2A4TITLE2"  "QUESTIONABLE ETHICS"
  157. "C2A5TITLE" "SURFACE TENSION"
  158. "C3A1TITLE" "FORGET ABOUT FREEMAN!"
  159. "C3A2TITLE" "LAMBDA CORE"
  160. "C4A1TITLE" "XEN"
  161. "C4A1ATITLE"  "INTERLOPER"
  162. "C4A2TITLE" "GONARCH'S LAIR"
  163. "C4A3TITLE" "NIHILANTH"
  164. "C5TITLE" "ENDGAME"
  165.  
  166. "Valve_Hostname"  "Hostname"
  167. "Valve_Max_Players" "Max. players"
  168. "Valve_Server_Password" "Server password"
  169.  
  170. "Valve_Close"   "Close"
  171. "Valve_Help"    "Help"
  172. "Valve_Settings"  "Settings"
  173. "Valve_Chat_Messages" "Chat Messages"
  174. "Valve_Show_Status" "Show Status"
  175. "Valve_View_Cone" "View Cone"
  176. "Valve_Player_Names"  "Player Names"
  177. "Valve_PIP"   "Picture-In-Picture"
  178. "Valve_Overview"  "Overview"
  179. "Valve_Overview_Off"  "No Map"
  180. "Valve_Overview_Small"  "Small Map"
  181. "Valve_Overview_Large"  "Large Map"
  182. "Valve_Overview_ZoomIn" "Zoom In"
  183. "Valve_Overview_Zoomout" "Zoom Out"
  184. "Valve_Overview_Locked" "No Rotation"
  185. "Valve_Overview_Names"  "Show Names"
  186. "Valve_Overview_Health" "Show Health"
  187. "Valve_Overview_Tracks" "Show Tracks"
  188. "Valve_Auto_Director" "Auto Director"
  189. "Valve_Show_Scores" "Show Scores"
  190. "Valve_Game_Saved"  "Game Saved"
  191.  
  192. "Valve_Orange"    "Orange"
  193. "Valve_Yellow"    "Yellow"
  194. "Valve_Blue"    "Blue"
  195. "Valve_Ltblue"    "Ltblue"
  196. "Valve_Green"   "Green"
  197. "Valve_Red"   "Red"
  198. "Valve_Brown"   "Brown"
  199. "Valve_Ltgray"    "Ltgray"
  200. "Valve_Dkgray"    "Dkgray"
  201.  
  202. "Valve_Playing"   "Playing"
  203. "Valve_Stopped"   "Stopped"
  204. "Valve_Paused"    "Paused"
  205.  
  206. "Valve_x_1_4"   "x1/4"
  207. "Valve_x_1_2"   "x1/2"
  208. "Valve_x_1"   "x1"
  209. "Valve_x_2"   "x2"
  210. "Valve_x_4"   "x4"
  211.  
  212. "Valve_ViewDemoStatus"  "%s1  %s2  %s3"
  213.  
  214. "Valve_Hint_Zoom" "%+zoom% ZOOM VIEW"
  215. "Valve_Hint_machinegun" "%+USE% TO USE MOUNTED GUN"
  216. "Valve_Hint_Flashlight" "%impulse 100% FLASHLIGHT"
  217. "Valve_Hint_PhysSwap" "%phys_swap% TO SWAP GRAVITY GUN\n WITH PREVIOUS GUN"
  218. "Valve_Hint_Command_send"  "%impulse 50% SEND YOUR SQUAD TO A LOCATION"
  219. "Valve_Hint_Command_recall"  "%impulse 50% TWICE TO RECALL YOUR SQUAD"
  220. "Valve_Hint_CraneKeys"  "%+forward% EXTEND ARM %+back% RETRACT ARM %+moveleft% TURN LEFT %+moveright% TURN RIGHT %+attack% PICKUP OR DROP OBJECT"
  221. "Valve_Hint_BoatKeys" "%+forward% SPEED UP %+back% SLOW DOWN %+moveleft% TURN LEFT %+moveright% TURN RIGHT\nUSE MOUSE TO LOOK"
  222. "Valve_Hint_JeepKeys" "%+speed% TURBO %+jump% HANDBRAKE"
  223. "Valve_Hint_JeepTurbo"  "%+speed% TURBO"
  224. "Valve_Hint_HEVcharger" "%+use% HOLD DOWN TO CHARGE SUIT"
  225. "Valve_Hint_AirboatGun" "%+attack% FIRE AIRBOAT GUN"
  226. "Valve_Hint_AmmoCrate" "%+use% GET AMMO FROM CRATE"
  227. "Valve_Hint_USEPickup"  "%+use% PICKUP OBJECT"
  228. "Valve_Hint_ThrowHeld"  "%+attack% THROW HELD OBJECT"
  229. "Valve_Hint_MomentaryButton"  "%+use% HOLD DOWN TO TURN WHEEL"
  230. "Valve_Hint_ThrowBait"  "%+attack% THROW BUGBAIT"
  231. "Valve_Hint_SqueezeBait"  "%+attack2% CALL ANTLIONS"
  232. "Valve_Hint_PicKUpWeapon" "%+use% TO PICK UP WEAPON"
  233.  
  234. "Valve_Miscellaneous_Keyboard_Keys_Title"  "MISCELLANEOUS MOVEMENT"
  235. "Valve_Chapter"   "Chapter"
  236.  
  237. "Valve_HudPoisonDamage" "NEUROTOXIN DETECTED\nADMINISTERING ANTIDOTE"
  238.  
  239. "Valve_CreatingCache" "Creating sound caches..."
  240. "Valve_CreatingSpecificSoundCache"  "Processing:  %s1"
  241.  
  242. "Valve_UpdatingSteamResources" "Updating Steam resources..."
  243.  
  244. "Valve_Sprint"    "Sprint (Move Quickly)"
  245. "Valve_Suit_Zoom" "Suit Zoom"
  246. "Valve_Commander_Mode"  "Send/Recall Squad"
  247. "Valve_Gravity_Gun" "Gravity Gun"
  248. "Valve_CC_Toggle" "Toggle close caption sound effects"
  249.  
  250. "Valve_Hud_HEALTH"    "HEALTH"
  251. "Valve_Hud_AMMO"    "AMMO"
  252. "Valve_Hud_SUIT"    "SUIT"
  253. "Valve_Hud_AUX_POWER"   "AUX POWER"
  254. "Valve_Hud_OXYGEN"    "OXYGEN"
  255. "Valve_Hud_FLASHLIGHT"    "FLASHLIGHT"
  256. "Valve_Hud_SPRINT"    "SPRINT"
  257.  
  258. "Valve_Hud_SQUAD_FOLLOWING" "SQUAD FOLLOWING"
  259. "Valve_Hud_SQUAD_STATIONED" "SQUAD STATIONED"
  260.  
  261. "Valve_HDRDEMO_LeftTitle" "Fixed Aperture"
  262. "Valve_HDRDEMO_RightTitle"  "High-Dynamic Range"
  263.  
  264. "Valve_Hud_CamFOV"    "FOV"
  265. "Valve_Hud_CamHeight" "Cam Height"
  266. "Valve_CamArmLength"  "Arm Length"
  267.  
  268. "Valve_FilmDemo_FilmGrain_LeftTitle"  "No Film Grain"
  269. "Valve_FilmDemo_FilmGrain_RightTitle" "Film Grain"
  270.  
  271. "Valve_FilmDemo_ColorCorrection_LeftTitle"  "No Color Correction"
  272. "Valve_FilmDemo_ColorCorrection_RightTitle" "Color Correction"
  273.  
  274. }
  275. }
  276.  

If you have it search for "Valve_Hint_SqueezeBait"  "%+attack2% CALL ANTLIONS" and add bellow that:
"Valve_Hint_PicKUpWeapon" "%+use% TO PICK UP WEAPON"

And your done. If you want to edit the hint text consider that the "%+use%" have to be in one of the sides for exemple:
   "%+use% TO DO SOMETHING"
      or
    "DO SOMETHING: %+use%"


Hope you guys like it.

Use E key to pick them up and have fun :)

-This only Apply for weapons not for items.

Comments
Jokerme
Jokerme Aug 17 2009, 4:45am replied:

Use point_message entity or env_message entity. If you don'T know how to use them go to Valve Developer Community.

+1 vote     reply to comment
MoraisPGSI
MoraisPGSI Aug 17 2009, 6:33am replied:

Ok now you have all you need :)

+1 vote     reply to comment
Post a Comment

Only registered members can share their thoughts. So come on! Join the community today (totally free) and do things you never thought possible.

Track this game Profile
Icon
Half-Life 2
Platforms
PC, X360, PS3, XBOX
Developer & Publisher
Valve
Engine
Source
Contact
Send Message
Official Page
Half-life2.com
Release Date
Released Nov 16, 2004
Game Watch
Track this game
Bookmark
Digg Super bookmark
Tutorial
Browse
Tutorials
Report Abuse
Report article
Bookmark
Digg Super bookmark
Related Games
Half-Life 2
Half-Life 2
Single & Multiplayer First Person Shooter
Related Engines
Source
Source
Commercial Released Nov 1, 2004
Related Groups
Valve
Valve
Developer & Publisher