User:Shunt94
How to create new Ammo types for Custom Weapons
Very Basic method
Things you will need to know... C++ ( you don't need this, it will help if you know it) valve script
This tutorial will teach you how to add a new type of Ammo for your custom weapons. This will basicly be useful for modders who don't want to use the Ammo type 'SMG1' all the time. When you add a new type of Ammo you can set it to what you want. For example...
modname/scripts/weapon_smg1.txt note: this will work on most other weapon scripts as well
the weapon_smg1.txt is the easyest to explain this tutorial on.
About line 16- 19 you should find this line of script.
"default_clip" "45" "default_clip2" "-1" "primary_ammo" "SMG1" "secondary_ammo" "SMG1_Grenade"
Change that to
"default_clip" "45" "default_clip2" "-1" "primary_ammo" "WEAPON1" "secondary_ammo" "SMG1_Grenade"
Therefore not wasting the SMG1 ammo type on all of your guns.
The C++ Part
So lets learn how to do this.
first open up your project sln file. (You should get this when you create a mod)
Then goto hl2_gamerules.cpp located in the server Goto line 119 an you should be on "ConVar sk_plr_dmg_gun1" Just below that add
ConVar sk_plr_dmg_weapon1 ( "sk_plr_dmg_weapon1","0", FCVAR_REPLICATED ); ConVar sk_npc_dmg_weapon1 ( "sk_npc_dmg_weapon1","0", FCVAR_REPLICATED); ConVar sk_max_weapon1 ( "sk_max_weapon1","0", FCVAR_REPLICATED);
This is baiscly telling the game/mod that weapon1 is a type of ammo that we want to use.
After that goto line 1697 in the samefile, Just below the line that says def.AddAmmoType("SMG1" ........ Add
def.AddAmmoType("WEAPON1", DMG_BULLET, TRACER_LINE_AND_WHIZ, "sk_plr_dmg_weapon1", "sk_npc_dmg_weapon1", "sk_max_weapon1", BULLET_IMPULSE(200, 1225), 0 );
This is basicly defining the script that you put in youmod/cfg/skill.cfg
Now to make the ammo come up when you type "impulse 101" into the console. Goto player.cpp then goto line 5446 Add this line of code in after that " // Give the player everything!
GiveAmmo( 90, "GUN1");
Where my code says "90" put in the amount of bullets that you want the player to have everytime they put in impulse 101
And that is it. Compile your project and your weapon_smg1.txt will have a diffrent type of ammo. Then you can make you own weapons and put your new type of ammo in.
To make more just rename
weapon1
to
weapon2
and so on.
Thanks for reading
Shunt94