Creating A Multiplayer Weapon: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(not very useful, really)
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{cleanup}}
#redirect [[Authoring a weapon entity]]
 
 
== Creating A HL2 Multiplayer Weapon ==
Ok so let's get this straight, you're wanting to create a Whole <b>NEW</b> weapon for your new Half Life 2 Multiplayer game right? Now your stuck and need a little tutorial which will tell you what to do right? Well luck is here as i shall teach you how to impliment a new weapon ready to use for your multiplayer game =D
 
== weapon_357.cpp ==
 
Ok so what i first of like to do is open up weapon_357.cpp on the server side, and once that's open i hit <b>CTRL + H</b> which brings up the Replace box/tab (depending on how you have it) now what i first of all do is this
 
Replace all instances of <b>CWeapon357</b> with <b>CWeaponRifle</b>    In total i get a result of 15 replaced accurances which seem's good to me but you might think thats it right?
 
<b>WRONG!</b>
 
Look for where ever the Weapon357 is replace it with WeaponRifle becareful, C++ syntax is very case sensitive Once you've got that done move on to the next part =D
 
== weapon_rifle.cpp ==
 
Ok, this is main part so be very careful here.
 
*Hit CTRL A + CTRL C  now in your solution just where your 357 is located, right click the Weapons folder then select Add> Add New Item.
*Now select CPP in the name part add weapon_rifle.cpp 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.
*NOW in the weapon_rifle.cpp hit CTRL + V hit save (ctrl + s)
 
== weapon_rifle.TXT ==
 
Ok so now your probabley happy and dandy that theres no errors right? WELL YOU SHOULD BE! that's probabley the hardest part over and done with in my opinion. Right so let's get the weapon in game now shall we? open up weapon_357.txt which is located in MyMod/Scripts/weapon_357.txt. Copy it all, and paste it into a new notepad document edit what you like in here here's mine for this tutorial :)
 
<pre>
// 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"
}
}
}
</pre>
 
 
== Other Usefull Stuff ==
 
Want it to be a default weapon? Open up Hl2mp_player.cpp Find this function
 
'''void CHL2MP_Player::GiveDefaultItems( void )'''
Add your weapon to the list.
 
i.e GiveNamedItem( "weapon_rifle" );
 
== Enjoy Your New Weapon ==
 
Hey, thanks for viewing my tutorial and i hope it helps and teaches your for the future my
 
friends =D
 
[[Category:Programming]]

Latest revision as of 03:57, 20 February 2010