User talk:Leonidus

From Valve Developer Community
Jump to navigation Jump to search

Making a Weapon in HL2 Single Player

To start you'll need to come up with a weapon you want to copy from. I'll choose the shotgun because it's one of my personal favorites.


ServerSide

-Under Server -> HL2DLL -(right click)-> add -> new item -> code -> C++ File (.cpp)

-Title it weapon_jackhammer.cpp

-Copy all the code in weapon_shotgun.cpp into weapon_jackhammer.cpp

-now change all instances or weaponshotgun to weaponjackhammer (find and replace makes quick work of this) *NOTE: not all instances of shotgun need to be changed to jackhammer. Don't touch lines 101-147, 249.

-next find SequenceDuration() which no doubt returns some form of double or float. replace the function call with .005. this changed the delay between whatever the line does to .005 seconds i believe.

-On Line 434 make m_bNeedPump = false; this will make it so we dont have to pump the shotgun inbetween shots

ClientSide

-Under Client -> HL2DLL -> c_weapon__stubs_hl2.cpp (don't ask me why they have 2 underscores...)

-Copy Line 32 (should be teh shotgun line) and paste it right below

-change shotgun to jackhammer


ScriptSide

- Goto SourceMods\Your Mod Name\Scripts

- Copy weapon_shotgun.txt and paste it

- rename is weapon_jackhammer.txt

- replace this with the appropriot section

"printname"	        "#HL2_Jackhammer" 
"viewmodel"	        "models/weapons/v_shotgun.mdl"
"playermodel"	        "models/weapons/w_shotgun.mdl"
"anim_prefix"		"shotgun"
"bucket"		"3"
"bucket_position"	"2"

"clip_size"		"15"
"primary_ammo"		"Buckshot"
"secondary_ammo"	"None"

"weight"		"4"
"item_flags"		"0"

- "printname" is what the name of the weapon will be when selecting it from the hud

- "viewmodel" is what you will see when you are carrying the weapon

- "playermodel" is what others will see when you have the weapon out

- "anim_prefix" i assume is something to do with the animation of the weapon

- "bucket" its catagory in the hud (starts at 0) example gravity gun is in bucket 0

- "bucket_position" how far down it is in that catagory (starts at 0) example the crowbar is the 1st weapon in display

- "clip_size" how much ammo per clip

- "primary_ammo" type of ammo the weapon uses

- "secondary_ammo" if it uses a secondary ammo like the smg using grenades

- "weight" unknown, seems to effect kickback

- "item_flags" unknown


Debugging

-after you have this saved up run your game.

-when in a map go into consol (~) and type give weapon_Jackhammer

-this should give you the weapon

-to test to see if it is fire it

-it should have a very fast fire rate