Creating A Multiplayer Weapon: Difference between revisions
Steveukpwnz (talk | contribs) (Tidyup) |
|||
Line 3: | Line 3: | ||
== Creating A HL2 Multiplayer Weapon == | == Creating A HL2 Multiplayer Weapon == | ||
Tou're wanting to create a whole <b>new</b> weapon for your new Half-Life 2 multiplayer game, right? This tutorial will enable you to able to just that and make a basic weapon for your multiplayer mod. | |||
== weapon_rifle.cpp == | == weapon_rifle.cpp == | ||
First of all, we'll start by using an existing weapon, and change it to how we want it. | |||
*Open weapon_357.cpp [server/Source Files/hl2mp/weapons] | *Open weapon_357.cpp (or any other weapon you want to copy) [Located at server/Source Files/hl2mp/weapons in Visual Studio] | ||
*Hit CTRL A + CTRL C | *Hit CTRL A + CTRL C to copy the contents to the clipboard | ||
*In your solution just where your 357 is located, right click the Weapons folder then select Add> Add New Item. | *In your server's solution just where your 357 (or whatever you've used) is located, right click the Weapons folder then select Add > Add New Item. | ||
*Select CPP | *Select CPP as the file type and enter weapon_rifle.cpp as the filename. Please make sure you change the save location down the bottom to [mod dir]\src\game_shared\hl2mp as it is a common file between the server and client. | ||
*In the weapon_rifle.cpp hit CTRL + V hit save (ctrl + s) | *In the weapon_rifle.cpp hit CTRL + V hit save (ctrl + s) | ||
*Now for the tricky part. You need to replace every instant of '''CWeapon357''' with '''CWeaponRifle''' but not the parts which refer to sound files. | *Now for the tricky part. You need to replace every instant of '''CWeapon357''' with '''CWeaponRifle''' but not the parts which refer to sound files. This can be acheived with a basic find/replace procedure. | ||
All you need to do now is add the same file to the client side, open up the client/Source Files/hl2mp/weapons and right click on the folder and select add existing. Select the same file '''weapon_rifle.cpp''' that is in the game_share dir (from before) and click add. Compile and your done. | All you need to do now is add the same file to the client side, open up the client/Source Files/hl2mp/weapons and right click on the folder and select add existing. Select the same file '''weapon_rifle.cpp''' that is in the game_share dir (from before) and click add. Compile and your done. | ||
Line 21: | Line 21: | ||
== weapon_rifle.TXT == | == weapon_rifle.TXT == | ||
So now you're probably happy and dandy that theres no compile errors right? Well, there's still one last thing to do. Though, the hardest part has already been dealt with. So now we need to get the weapon so it works in-game. Open up weapon_357.txt, or the corrisponding weapon file you based your weapon off, the files are located in MyMod/Scripts/. Copy it all, and paste it into a new new text file and edit what you like. Here's an example of what you will end up with: | |||
<pre> | <pre> | ||
Line 103: | Line 103: | ||
== Other | == Other Useful Stuff == | ||
Do you want to spawn with your newly created weapon? Well all you need to do is open hl2mp_player.cpp in your server project and find: | |||
'''void CHL2MP_Player::GiveDefaultItems( void )''' | '''void CHL2MP_Player::GiveDefaultItems( void )''' | ||
If you | If you cannot find the above, press Ctrl + G and enter the line number 198, this should take you right to it. All you will need to do now is add your weapon like the others: | ||
i.e GiveNamedItem( "weapon_rifle" ); | i.e GiveNamedItem( "weapon_rifle" ); | ||
[[Category:Programming]] | [[Category:Programming]] |
Revision as of 09:53, 28 February 2007

For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
Creating A HL2 Multiplayer Weapon
Tou're wanting to create a whole new weapon for your new Half-Life 2 multiplayer game, right? This tutorial will enable you to able to just that and make a basic weapon for your multiplayer mod.
weapon_rifle.cpp
First of all, we'll start by using an existing weapon, and change it to how we want it.
- Open weapon_357.cpp (or any other weapon you want to copy) [Located at server/Source Files/hl2mp/weapons in Visual Studio]
- Hit CTRL A + CTRL C to copy the contents to the clipboard
- In your server's solution just where your 357 (or whatever you've used) is located, right click the Weapons folder then select Add > Add New Item.
- Select CPP as the file type and enter weapon_rifle.cpp as the filename. Please make sure you change the save location down the bottom to [mod dir]\src\game_shared\hl2mp as it is a common file between the server and client.
- In the weapon_rifle.cpp hit CTRL + V hit save (ctrl + s)
- Now for the tricky part. You need to replace every instant of CWeapon357 with CWeaponRifle but not the parts which refer to sound files. This can be acheived with a basic find/replace procedure.
All you need to do now is add the same file to the client side, open up the client/Source Files/hl2mp/weapons and right click on the folder and select add existing. Select the same file weapon_rifle.cpp that is in the game_share dir (from before) and click add. Compile and your done.
weapon_rifle.TXT
So now you're probably happy and dandy that theres no compile errors right? Well, there's still one last thing to do. Though, the hardest part has already been dealt with. So now we need to get the weapon so it works in-game. Open up weapon_357.txt, or the corrisponding weapon file you based your weapon off, the files are located in MyMod/Scripts/. Copy it all, and paste it into a new new text file and edit what you like. Here's an example of what you will end up with:
// Rifle - Wiki tutorial :D WeaponData { // Weapon data is loaded by both the Game and Client DLLs. "printname" "#HL2_Rifle" "viewmodel" "models/weapons/v_shotgun.mdl" "playermodel" "models/weapons/w_annabelle.mdl" "anim_prefix" "shotgun" "bucket" "2" "bucket_position" "1" "clip_size" "2" "primary_ammo" "357" "secondary_ammo" "None" "weight" "2" "item_flags" "0" // Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds) SoundData { "empty" "Weapon_Shotgun.Empty" "reload" "Weapon_Shotgun.Reload" "special1" "Weapon_Shotgun.Special1" "single_shot" "Weapon_Shotgun.Single" "double_shot" "Weapon_Shotgun.Double" // NPC WEAPON SOUNDS "reload_npc" "Weapon_Shotgun.NPC_Reload" "single_shot_npc" "Weapon_Shotgun.NPC_Single" } // Weapon Sprite data is loaded by the Client DLL. TextureData { "weapon" { "file" "sprites/w_icons2" "x" "0" "y" "128" "width" "128" "height" "64" } "weapon_s" { "file" "sprites/w_icons2b" "x" "0" "y" "128" "width" "128" "height" "64" } "ammo" { "file" "sprites/a_icons1" "x" "55" "y" "90" "width" "73" "height" "20" } "crosshair" { "file" "sprites/crosshairs" "x" "0" "y" "48" "width" "24" "height" "24" } "autoaim" { "file" "sprites/crosshairs" "x" "0" "y" "48" "width" "24" "height" "24" } } }
Other Useful Stuff
Do you want to spawn with your newly created weapon? Well all you need to do is open hl2mp_player.cpp in your server project and find:
void CHL2MP_Player::GiveDefaultItems( void )
If you cannot find the above, press Ctrl + G and enter the line number 198, this should take you right to it. All you will need to do now is add your weapon like the others:
i.e GiveNamedItem( "weapon_rifle" );