Named Game of the Year by over 50 publications, Valve's début title blends action and adventure with award-winning technology to create a frighteningly realistic world where players must think to survive. Also includes an exciting multiplayer mode that allows you to play against friends and enemies around the world.

Post tutorial Report RSS Modding Weapons (Ammo, Weight etc)

This tutorial will teach you how to edit the ammo per clip, how fast you walk with a weapon and much more! Check it out... For Half-life 1

Posted by on - Basic Client Side Coding

[page=Introduction]
Okay Just click on a chapter/Subject you want to Change
also you are working in the weapon.h the whole tutorial
[page=Weapon Capacities]
open weapons.h and go to line 108

There you will see:

// weapon clip/carry ammo capacities
#define URANIUM_MAX_CARRY 100
#define _9MM_MAX_CARRY 200
#define _357_MAX_CARRY 36
#define BUCKSHOT_MAX_CARRY 125
#define BOLT_MAX_CARRY 50
#define ROCKET_MAX_CARRY 5
#define HANDGRENADE_MAX_CARRY 10
#define SATCHEL_MAX_CARRY 5
#define TRIPMINE_MAX_CARRY 5
#define SNARK_MAX_CARRY 15
#define HORNET_MAX_CARRY 100
#define M203_GRENADE_MAX_CARRY 10

**Remember, This is how much you can carry on you at a time for a reload. lets say you get a glock 7/200 <<< thats the number your changing

[page=Weight Factors(how fast you run with weapon etc)]

Okay, Line 92, search it... in the Weapon.h.

now you should see this...

// weap&#111;n weight fact&#111;rs &#40;f&#111;r aut&#111;-switching&#41;   &#40;-1 = n&#111;switch&#41;
#define CROWBAR_WEIGHT		0
#define GLOCK_WEIGHT		10
#define PYTHON_WEIGHT		15
#define MP5_WEIGHT			15
#define SHOTGUN_WEIGHT		15
#define CROSSBOW_WEIGHT		10
#define RPG_WEIGHT			20
#define GAUSS_WEIGHT		20
#define EGON_WEIGHT			20
#define HORNETGUN_WEIGHT	10
#define HANDGRENADE_WEIGHT	5
#define SNARK_WEIGHT		5
#define SATCHEL_WEIGHT		-10
#define TRIPMINE_WEIGHT		-10

Explanation: 0 = Normal Speed of running, the higher it gets the slower the player runs... if you go below zero -10 for say, you run faster then normal... So change it on your accord. 20 is the heaviest in this case.

[page=Ammo in a Clip]
This is abit easy all the Value changes are under each other heres the next one

// the maximum am&#111;unt &#111;f amm&#111; each weap&#111;n&#39;s clip can h&#111;ld
#define WEAPON_NOCLIP			-1

//#define CROWBAR_MAX_CLIP		WEAPON_NOCLIP
#define GLOCK_MAX_CLIP			17
#define PYTHON_MAX_CLIP			6
#define MP5_MAX_CLIP			50
#define MP5_DEFAULT_AMMO		25
#define SHOTGUN_MAX_CLIP		8
#define CROSSBOW_MAX_CLIP		5
#define RPG_MAX_CLIP			1
#define GAUSS_MAX_CLIP			WEAPON_NOCLIP
#define EGON_MAX_CLIP			WEAPON_NOCLIP
#define HORNETGUN_MAX_CLIP		WEAPON_NOCLIP
#define HANDGRENADE_MAX_CLIP	WEAPON_NOCLIP
#define SATCHEL_MAX_CLIP		WEAPON_NOCLIP
#define TRIPMINE_MAX_CLIP		WEAPON_NOCLIP
#define SNARK_MAX_CLIP			WEAPON_NOCLIP

Okay well simply Change the Glock to like a 7 so now it has 7 bullets per clip :P so change the number, unless you want it to have no clip there for you would use the Value WEAPON_NOCLIP

[page=Ammo in gun at pickup]

// the default am&#111;unt &#111;f amm&#111; that c&#111;mes with each gun when it spawns
#define GLOCK_DEFAULT_GIVE			17
#define PYTHON_DEFAULT_GIVE			6
#define MP5_DEFAULT_GIVE			25
#define MP5_DEFAULT_AMMO			25
#define MP5_M203_DEFAULT_GIVE		0
#define SHOTGUN_DEFAULT_GIVE		12
#define CROSSBOW_DEFAULT_GIVE		5
#define RPG_DEFAULT_GIVE			1
#define GAUSS_DEFAULT_GIVE			20
#define EGON_DEFAULT_GIVE			20
#define HANDGRENADE_DEFAULT_GIVE	5
#define SATCHEL_DEFAULT_GIVE		1
#define TRIPMINE_DEFAULT_GIVE		1
#define SNARK_DEFAULT_GIVE			5
#define HIVEHAND_DEFAULT_GIVE		8

okay this is the next line, this just shows or repersents how much ammo is given with the gun when you first pick it up. this can be changed, by simply changing the numbers.

[page=Ammo Box Pick ups]

// The am&#111;unt &#111;f amm&#111; given t&#111; a player by an amm&#111; item.
#define AMMO_URANIUMBOX_GIVE	20
#define AMMO_GLOCKCLIP_GIVE		GLOCK_MAX_CLIP
#define AMMO_357BOX_GIVE		PYTHON_MAX_CLIP
#define AMMO_MP5CLIP_GIVE		MP5_MAX_CLIP
#define AMMO_CHAINBOX_GIVE		200
#define AMMO_M203BOX_GIVE		2
#define AMMO_BUCKSHOTBOX_GIVE	12
#define AMMO_CROSSBOWCLIP_GIVE	CROSSBOW_MAX_CLIP
#define AMMO_RPGCLIP_GIVE		RPG_MAX_CLIP
#define AMMO_URANIUMBOX_GIVE	20
#define AMMO_SNARKBOX_GIVE		5

Okay this is the last one. but it speaks for itself, you pick up bullets or a box of bullets and it adds the amount that you have typed in here

[page=Disabling Weapons you dont want used]
Okay this is a quick explanation how you can stop a weapon from being used. ill use some codes from here and ill disable the RPG ill do them in according chapter order to!

//First line t&#111; edit t&#111; disable weap&#111;n
//default is 5 im changing it t&#111; 0
#define ROCKET_MAX_CARRY 0  

heres a little punishment for those people who use amx and make the rocket accesible

#define RPG_WEIGHT			90

that i just defined is practically, well not moving

and the last code to change...

#define RPG_MAX_CLIP			1 

change t&#111;

#define RPG_MAX_CLIP			0

Now your done when they get the weapon it will show up
but they cannot pull it out or use it. and if amx modders get by that. they have to worry about weight issues, you wont be able to walk. but thats something i pulled on my friend, he tried to fix the rpg weight for days, then i told him :D

ANYWAYS HOPE YOU ENJOYED IT its easy as hell a newb could understand this.

Post comment Comments  (0 - 50 of 76)
Kiith-Somtaaw
Kiith-Somtaaw - - 1,067 comments

(buried)

Hmm... its a good enough tut. HOWEVER you did not specify what game it is (I assume Half-Life 2?) and what editor you are using to make it (Hammer?) and because of that, this is useless.

Reply Good karma Bad karma-49 votes
:Jack
:Jack - - 2,079 comments

u r really sily, u ******.

Reply Good karma Bad karma+9 votes
djjonastybe
djjonastybe - - 141 comments

retarded...

Reply Good karma Bad karma+6 votes
deathparadeNL
deathparadeNL - - 2,061 comments

hey says if you CAN read for half-life 1

Reply Good karma Bad karma+6 votes
Admer456
Admer456 - - 826 comments

Alright, i will do the man's job.
This is meant for the game Half Life (not 2).
You must use a piece of C++ programming language software which can compile dll files. Therefore, it's not useless, unless you don't have a C++ software (like Dev-C++), or Half Life (which i'm assuming, you have).
And the guy above me said you can't read, but if you wrote that comment, it makes no sense, because anybody who can read, can write, and the opposite, and the negative (who can't read, can't write, but i'm not sure).

Reply Good karma Bad karma+6 votes
IjazzCM3
IjazzCM3 - - 30 comments

Wow Admer thank you,very cool!

Reply Good karma Bad karma+4 votes
Admer456
Admer456 - - 826 comments

You're welcome, mate. But this is an old post of mine, I'd better update it.
Since I cannot edit old posts, I'm gonna have to post one here:

The tutorial is clearly meant for Half-Life 1. You can compile the source code into a DLL using an IDE like Visual Studio (compilers other than MSVC are hardly gonna work IIRC - so don't do Dev-C++, Codeblocks or anything like that).

For any (absolute) beginner who happens to be reading the comments: before compiling, make sure to open the project file or a solution file. If you got SDK 2.3, it's likely a .dsp file which is meant for Visual Studio 6.0. The official HL SDK 2.4 on GitHub is meant for Visual Studio 2010 and there you'll find a .sln file.

Once in the solution file, you can finally try to compile. If all you do is open the weapons.h file alone (not from within the project), it's not gonna compile, lol.

People have also asked *where* weapons.h is at: it's in the Half-Life SDK code. Comments are pretty old so they mention SDK 2.3. But the latest is 2.4, and can be found on GitHub. Have fun. :)

Reply Good karma Bad karma+4 votes
Guest
Guest - - 689,205 comments

This comment is currently awaiting admin approval, join now to view.

Chunky
Chunky - - 1,415 comments

Why do you think there's a big Half-Life 1 logo in front of the title :P

Reply Good karma Bad karma+4 votes
l0d1z
l0d1z - - 239 comments

how about adding new weapons then?

Reply Good karma Bad karma+1 vote
sbc_hs520
sbc_hs520 - - 1 comments

i have steam and can't find the "weapon.h" file

Reply Good karma Bad karma0 votes
Ian50028
Ian50028 - - 571 comments

(buried)

You need to download the Half Life Source SDK 1.3

Reply Good karma Bad karma-7 votes
blocklandrunner
blocklandrunner - - 26 comments

source SDK?
i thought this was for the GoldSrc Version?

Reply Good karma Bad karma+1 vote
YodaLife
YodaLife - - 4 comments

SBC, the weapon.h file is in the half life sdk. Just google "half life sdk 2.3." You'll also have to get a c++ compiler.

Reply Good karma Bad karma0 votes
bobby0415
bobby0415 - - 21 comments

(buried)

this is probly the most easy mod there is on the face of the world..... if you cannot do this mod... you are clearly a dumb*** lol

Reply Good karma Bad karma-7 votes
bobby0415
bobby0415 - - 21 comments

Need a C++ Compiler? Get "DevC++" (Google it. It is free and it has one of the best c++ environments..... and yes this compiler can open .h files :) and .cpp and many more...... and also very easy to use..... :)

Reply Good karma Bad karma+1 vote
bobby0415
bobby0415 - - 21 comments

No... in order to add weapons your gonna need some knowledge in DX.... if you need help on that kind of subject, check this page out. This page does not tell you about DX it just basicaly talks about a guy wanted to creat a mod for hl and ppl are telling him what is what...... Halflife2.net

that page is only helpful to find y u need DX :)

Reply Good karma Bad karma+1 vote
bobby0415
bobby0415 - - 21 comments

Please, do not get the "Dev C++" It does not compile the source code... (and no, I don't mean source as in hl2 or cs:s, source as in the source code "sc" like in SDK) Just download or buy Microsoft Visual C++ ....works like a charm..

And great guide!!!! Helped soo much.....

Reply Good karma Bad karma0 votes
DeadlyContagion
DeadlyContagion - - 194 comments

you could use codeblocks, search for it on the VERC forums

Reply Good karma Bad karma+1 vote
Chuto
Chuto - - 37 comments

nice, but i can't find weapon.h, the closest thing to it is skill.cfg...

Reply Good karma Bad karma+2 votes
Kiith-Somtaaw
Kiith-Somtaaw - - 1,067 comments

Whoo, Jesus I sounded like an idiot back then, eh?
(No comments on "lol u always sound leik an idiot")

Good tut now that I actually came to need it, by the way.

Reply Good karma Bad karma+1 vote
Minekiller33
Minekiller33 - - 5 comments

yes, yes you did.

Reply Good karma Bad karma+2 votes
hlnerd
hlnerd - - 281 comments

i have won version of half-life. but i can not find Weapons.h file

Reply Good karma Bad karma+1 vote
hlnerd
hlnerd - - 281 comments

i know how to change weapon damage in half-life. My glock makes more damage than the shotgun

Reply Good karma Bad karma-1 votes
Admer456
Admer456 - - 826 comments

Let me guess, you edited the skill.cfg file?

Reply Good karma Bad karma+3 votes
deathparadeNL
deathparadeNL - - 2,061 comments

this can be done too in skill.cfg but than you can make enemy's bad etc.

Reply Good karma Bad karma0 votes
hlnerd
hlnerd - - 281 comments

i have edited the file with notepad. and what the hell should i do now? where should i put the damn file?

Reply Good karma Bad karma-1 votes
deathparadeNL
deathparadeNL - - 2,061 comments

hl1 tut but were is weapons.h located.

Reply Good karma Bad karma0 votes
Admer456
Admer456 - - 826 comments

You have to download half life sdk first, then go to it, find a folder named Single-Player Source, and then go into a folder called dlls, and find weapons.h

Reply Good karma Bad karma+1 vote
blocklandrunner
blocklandrunner - - 26 comments

i can't find "Single Player Source" as a folder, i have SDK 2.3 installed...

Reply Good karma Bad karma+1 vote
Admer456
Admer456 - - 826 comments

Do you have the SDK which comes with the source code, or just the SDK with tools?

BTW it's better to get SDK 2.4 on GitHub:
Github.com

Reply Good karma Bad karma+1 vote
blocklandrunner
blocklandrunner - - 26 comments

i wasnt sure if if it came with either the source code or the tools since i downloaded it from steam, but thanks for the github download.

Reply Good karma Bad karma+1 vote
Admer456
Admer456 - - 826 comments

If you downloaded HL SDK from Steam, then you don't have the source code.
It only comes with some (outdated) tools and some assets.

There is a HL SDK 2.3 on ModDB which has the source code, but the latest is 2.4 which I've linked up there, which is source code only.

Reply Good karma Bad karma+1 vote
seanmcknight357
seanmcknight357 - - 33 comments

You seem to know what to do, i downloaded the github, the HL SDK from steam tools put the github files in the HL SDK then opened it... i am completely lost, i could use some help.

Reply Good karma Bad karma+1 vote
Admer456
Admer456 - - 826 comments

I could help you out on Discord in more detail if you wanna.

But first I'd steer you to TWHL:
Twhl.info

There is no need to download HL SDK from Steam at all BTW. You really really don't need that one.

In order to change weapon stats, you need to build the code. Building the code is done in Visual Studio. You can get Visual Studio 2022 Community Edition (cuz' it's free), and Solokiller's Half-Life SDK, updated for VS2022, because the OG SDK is meant for Visual Studio 2010 at best.

Reply Good karma Bad karma+1 vote
thedeathrunner
thedeathrunner - - 232 comments

So I can see how to get this to work for normal HL1
But how would I go about doing this for an actually fully made mod?
All Im doing is trying to edit max ammo carry values and nothing more.

Reply Good karma Bad karma+1 vote
crazyb2000
crazyb2000 - - 684 comments

hey can someone help me with my coding problem. I have the source code of half-life and I really want to code. but without doing anything to it I compiled it and it had about 200 errors, so it failed. any suggestions

Reply Good karma Bad karma+1 vote
m82sniper
m82sniper - - 1,490 comments

A better compiler.

Reply Good karma Bad karma+3 votes
EDOC32
EDOC32 - - 242 comments

Hello. as is called the file??? greetings

Reply Good karma Bad karma0 votes
hlnerd
hlnerd - - 281 comments

i now have the c++ compiler but in wich file format should i save it?

Reply Good karma Bad karma+1 vote
Admer456
Admer456 - - 826 comments

Well, the weapon.h is an ".h" file, so you should compile the same thing.

Reply Good karma Bad karma+2 votes
PeterHat
PeterHat - - 731 comments

does enyone know how to add custom weapons to half-life?

Reply Good karma Bad karma0 votes
Admer456
Admer456 - - 826 comments

twhl.info/articulator.php?art=31

I think this is what you're looking for.
Also add http stuff at the beginning.

Reply Good karma Bad karma+3 votes
Wazza999111
Wazza999111 - - 47 comments

Anyone who wants to know where the weapon.h is?U have to download hl sdk v2.3.

Reply Good karma Bad karma0 votes
X-LAyer2
X-LAyer2 - - 232 comments

So i got the sdk i modified what i wanted in weapons.h but now where do I put it do i leave it where it is or put it into half-life's dlls folder

Reply Good karma Bad karma0 votes
X-LAyer2
X-LAyer2 - - 232 comments

Do I need WON Half-life

Reply Good karma Bad karma0 votes
Timm64
Timm64 - - 2 comments

where do we put weapons.h when we finish coding?

Reply Good karma Bad karma0 votes
masquedios
masquedios - - 212 comments

thanks

Reply Good karma Bad karma0 votes
TheUnbeholden
TheUnbeholden - - 3,602 comments

What about weapon damage? In particular, increasing the headshot damage some of them can do?

Reply Good karma Bad karma0 votes
siftheadz
siftheadz - - 155 comments

You can modify the damage from the skill file in the folder. This includes hits to various parts of the enemy body, such as head, chest, arms, etc...

Reply Good karma Bad karma0 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: