Changing max ammo in HL2: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
mNo edit summary
 
(10 intermediate revisions by 9 users not shown)
Line 1: Line 1:
== Changing maximum ammo in HL2 ==
{{orphan}}
Many people that make a total conversion mod will want to change the ammunition settings in Half-Life 2. This small tutorial will tell you just how to do that.
{{Tutorial Skill Level | skill=2}}
Many people that make a total conversion mod will want to change the maximum ammunition settings in Half-Life 2. This small tutorial will tell you just how to do that.


== Editing ammo settings ==
# Using {{GCFScape|3.1}}, open the GCF file called ''source engine.gcf''.
Before we can change the values in our mod, we need to get a file from one of the gcf's.
# In this file, browse to <code>Root/hl2/cfg/</code> and extract the file called ''skill.cfg''.
Using [http://nemesis.thewavelength.net/index.php?p=26 GCFscape] we open the GCF called source engine.gcf. in this file, browse to Root/hl2/cfg/ and extract the file called skill.cfg.
# Place the extracted file in <code>Steam/Steamapps/Sourcemods/yourmodname/cfg/</code>.
Place the file in Steam/Steamapps/Sourcemods/yourmodname/cfg/. Then go down to the Weapons part, and edit the lines starting with sk_max_*, where * is the name of the weapon (such as pistol, 357, ar2, etc).</br>
# In this file, open it using any text editor, then go down to the ''Weapons'' part, and edit the lines starting with <code>sk_max_*</code>, where <code>*</code> is the name of the weapon (such as pistol, 357, ar2, etc).
[[User:Solokiller|Solokiller]] 13:03, 12 November 2006 (UTC)
 
If you follow those steps and they do not work, follow these as well:
# In {{file|hl2mp_gamerules|cpp}} (or equivalent), in the function <code>*GetAmmoDef()</code>, find the <code>AddAmmoType()</code> function for the ammo you want to change, and change the sixth parameter.
 
Example <code>AddAmmoType()</code> from {{hl2dm|3.1}} code (shotgun):
def.AddAmmoType("Buckshot", DMG_BULLET | DMG_BUCKSHOT, TRACER_LINE, 0, 0, '''30''', BULLET_IMPULSE(400, 1200), 0 );
                                                                          ^^ Change the 30.
Though the actual line has lots of tabs in it (to align it neatly with the other <code>AddAmmoType()</code>s and their parameters).


[[Category:Programming]]
[[Category:Programming]]
[[Category:Weapons programming]]

Latest revision as of 07:18, 30 October 2024

Skill Level

This tutorial expects you to have this amount of knowledge within the topic to follow along smoothly.

Novice Familiar Competent Proficient Expert

Many people that make a total conversion mod will want to change the maximum ammunition settings in Half-Life 2. This small tutorial will tell you just how to do that.

  1. Using GCFScape, open the GCF file called source engine.gcf.
  2. In this file, browse to Root/hl2/cfg/ and extract the file called skill.cfg.
  3. Place the extracted file in Steam/Steamapps/Sourcemods/yourmodname/cfg/.
  4. In this file, open it using any text editor, then go down to the Weapons part, and edit the lines starting with sk_max_*, where * is the name of the weapon (such as pistol, 357, ar2, etc).

If you follow those steps and they do not work, follow these as well:

  1. In 🖿hl2mp_gamerules.cpp (or equivalent), in the function *GetAmmoDef(), find the AddAmmoType() function for the ammo you want to change, and change the sixth parameter.

Example AddAmmoType() from Half-Life 2: Deathmatch code (shotgun):

def.AddAmmoType("Buckshot", DMG_BULLET | DMG_BUCKSHOT, TRACER_LINE, 0, 0, 30, BULLET_IMPULSE(400, 1200), 0 );
                                                                          ^^ Change the 30.

Though the actual line has lots of tabs in it (to align it neatly with the other AddAmmoType()s and their parameters).