Creating A Multiplayer Weapon: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
(not very useful, really)
 
(17 intermediate revisions by 9 users not shown)
Line 1: Line 1:
== Creating A HL2 Multiplayer Weapon ==
#redirect [[Authoring a weapon entity]]
<blockquote>
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
</blockquote>
 
== weapon_357.cpp ==
 
<blockquote>
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
</blockquote>
 
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 ok? Follow exactly what i do. 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 click
 
ok now it will be created and in there ready and 2003 edition is what i use, open's the new
 
file up for you straight away. NOW in the weapon_rifle.cpp hit CTRL + V hit save (ctrl + s)
 
now don't be silly and go save the 357 file just hit CTRL + Z until the instanes are all
 
the same, or just close it and if it ask's you to save say <b>No</b> Wow, we're getting
 
somewhere now aint we =D. Now if you were to compile this in game you'll get a database
 
error in your console which is what we do not want at all, open back up your compiler for
 
me it's Microsoft Visual Studio .NET 2003 (best imo) now right click on your new weapon
 
item, click Copy move over to the Client side, locate where your weapons are there same
 
folder i guess sourcefiles/weapons right click the weapons folder and click Paste now if
 
you were to run the game now it wont work you'll see soon enough, Compiled fine? no errors?
 
Boom move onto the next part.
 
== 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 :)
 
<blockquote>
// Rifle - Wiki tutorial :D<br />
 
WeaponData<br />
{<br />
// Weapon data is loaded by both the Game and Client DLLs.<br />
"printname" "#HL2_Rifle"<br />
"viewmodel" "models/weapons/v_shotgun.mdl"<br />
"playermodel" "models/weapons/w_annabelle.mdl"<br />
"anim_prefix" "shotgun"<br />
"bucket" "2"<br />
"bucket_position" "1"<br />
"clip_size" "2"<br />
"primary_ammo" "357"<br />
"secondary_ammo" "None"<br />
<br />
"weight" "2"<br />
"item_flags" "0"<br />
<br />
// Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16
 
"single_shot" sounds)<br />
SoundData<br />
{<br />
<br />
"empty" "Weapon_Shotgun.Empty"<br />
"reload" "Weapon_Shotgun.Reload"<br />
"special1" "Weapon_Shotgun.Special1"<br />
"single_shot" "Weapon_Shotgun.Single"<br />
"double_shot" "Weapon_Shotgun.Double"<br />
// NPC WEAPON SOUNDS<br />
"reload_npc" "Weapon_Shotgun.NPC_Reload"<br />
"single_shot_npc" "Weapon_Shotgun.NPC_Single"<br />
}<br />
<br />
// Weapon Sprite data is loaded by the Client DLL.<br />
TextureData<br />
{<br />
"weapon"<br />
{<br />
"file" "sprites/w_icons2"<br />
"x" "0"<br />
"y" "128"<br />
"width" "128"<br />
"height" "64"<br />
}<br />
"weapon_s"<br />
{ <br />
"file" "sprites/w_icons2b"<br />
"x" "0"<br />
"y" "128"<br />
"width" "128"<br />
"height" "64"<br />
}<br />
"ammo"<br />
{<br />
"file" "sprites/a_icons1"<br />
"x" "55"<br />
"y" "90"<br />
"width" "73"<br />
"height" "20"<br />
}<br />
"crosshair"<br />
{<br />
"file" "sprites/crosshairs"<br />
"x" "0"<br />
"y" "48"<br />
"width" "24"<br />
"height" "24"<br />
}<br />
"autoaim"<br />
{<br />
"file" "sprites/crosshairs"<br />
"x" "0"<br />
"y" "48"<br />
"width" "24"<br />
"height" "24"<br />
}<br />
}<br />
}<br />
</blockquote>
 
 
== Other Usefull Stuff ==
 
Want it to be a default weapon? Open up Hl2mp_player.cpp Find this function<br />
 
'''void CHL2MP_Player::GiveDefaultItems( void )'''<br />
<br />
Add your weapon to the list.<br />
 
i.e GiveNamedItem( "weapon_rifle" );<br />
 
 
== Enjoy Your New Weapon ==
 
Hey, thanks for viewing my tutorial and i hope it helps and teaches your for the future my
 
friends =D

Latest revision as of 03:57, 20 February 2010