Left 4 Dead 2

Left 4 Dead 2

167 ratings
[not updated] How to Modify Weapon Stats / Scripts and Explanation
By salt サルト
This guide will explain the basic of each line found in Left 4 Dead 2 weapon scripts, additionally teaching you how to publish to Left 4 Dead 2 Workshop
4
   
Award
Favorite
Favorited
Unfavorite
IMPORTANT NOTES
Edit1 : I have received some reports on some scripts not working as intended. Until I verify the authencity of those reports, this guide is, possibly, outdated.
Edit2: I recently just tested some of the reports, everything seems just fine, make sure you test your scripts at local server / single player campaign.
Edit3: This guide might be outdated due to several complaints from users, I can't be bothered to check things out since I'm quite busy right now.
Tools
1. .txt files opener, Notepad or any text editor


2. .vpk files opener, GCFScape
I downloaded mine from here, http://nemesis.thewavelength.net/index.php?p=26


3. vpk.exe , make a shortcut or copy it to easily accessible place
Obtained from [[INSTALLATIONPATH]]\Steam\steamapps\common\Left 4 Dead 2\bin


4. Download Left 4 Dead 2 Authoring Tools from Tools section at Steam
Extracting Weapon Scripts
1. Locate pak01_dir.vpk and open it with GCFScape


2. Go to \scripts and locate the weapon script you want to extract.


3. There should be 19 weapon scripts you can extract from pak01_dir.vpk. Image shows that I extracted 15 weapon scripts (which is all firearms except German server weapons)

German server weapons :
  • weapon_rifle_ssg552
  • weapon_smg_mp5
  • weapon_sniper_awp
  • weapon_sniper_scout

EXCEPTION : It seems like you cannot extract M60/ Minigun weapon script ( weapon_rifle_m60 ), from the game data. I got mine from other people's workshop


4. Extract them and place them somewhere (I recommend making backup data for the extracted scripts, in case you messed up your value)
The Fun Part
You might have notice the scripts you extracted is in .txt format. That means you can open it right away and start modifying the weapons !
(BTW, from here onwards you will be only seeing texts, so prepare yourself ! )


Here is my weapon script for my custom AK47 (just scroll past this part if you want) :

WeaponData
{
// Terror-specific Data --------------------
"VerticalPunch" "2.36"
"SpreadPerShot" "1.16"
"MaxSpread" "10"
"SpreadDecay" "5"
"MinDuckingSpread" "0.1"
"MinStandingSpread" "0.5"
"MinInAirSpread" "2"
"MaxMovementSpread" "1.75"
"ReloadDuration" "1.66"
"DualReloadDuration" "1.66"
"DeployDuration" "0.66"
"DualDeployDuration" "0.66"
"AddonAttachment" "primary"
"Team" "Survivor"

"Tier" "2" // valid entries are 0, 1, 2

"ResponseRulesName" "Rifle_AK47"

// particle muzzle flash effect to play when fired
"MuzzleFlashEffect_1stPerson" "weapon_muzzle_flash_smg_FP"
"MuzzleFlashEffect_3rdPerson" "weapon_muzzle_flash_smg"

// model for the shell casing to eject when we fire bullets
"EjectBrassEffect" "weapon_shell_casing_rifle"

// Used in the music system when this weapon fires
"MusicDynamicSpeed" "0.35"

"DisplayName" "#L4D_Weapon_Rifle_AK47"
"DisplayNameAllCaps" "#L4D_Weapon_Rifle_AK47_CAPS"

"NewInL4D2" "1"

// 360 Terror Data
"MaxAutoAimDeflection1" "10.0"
"MaxAutoAimRange1" "0"
//This value determins how "big" a target is for auto aim. If a target is 10.0 units big then it is considered 10.0*scale.
//You can think about this value controlling a falloff value on distant targets, the smaller the value the harder it is to hit at a distance.
"WeaponAutoAimScale" "1.0"
// End Terror-specific Data ----------------

"Rumble" "4"

"MaxPlayerSpeed" "230"
"WeaponType" "rifle"
"WeaponPrice" "3100"
"WeaponArmorRatio" "1.4"
"CrosshairMinDistance" "4"
"CrosshairDeltaDistance" "3"
"BuiltRightHanded" "1"
"PlayerAnimationExtension" "m4"

"CanEquipWithShield" "0"


// Weapon characteristics:
"PenetrationNumLayers" "4"
"PenetrationPower" "0.75"
"PenetrationMaxDistance" "2000" // none

"Damage" "83" //was 33
"Range" "7500"
"RangeModifier" "0.95"
"GainRange" "3000" // range at which to use a gain curve to fall off to zero
"Bullets" "1"
"CycleTime" "0.08"

"TimeToIdle" "1.5"
"IdleInterval" "60"

// Weapon data is loaded by both the Game and Client DLLs.
"printname" "Assault Rifle"

"playermodel" "models/w_models/weapons/w_rifle_ak47.mdl"

"viewmodel" "models/v_models/v_rifle_AK47.mdl"
"CharacterViewmodelAddon"
{
"Coach" "models/weapons/arms/v_arms_coach_new.mdl"
"Mechanic" "models/weapons/arms/v_arms_mechanic_new.mdl"
"Producer" "models/weapons/arms/v_arms_producer_new.mdl"
"Gambler" "models/weapons/arms/v_arms_gambler_new.mdl"
}

"anim_prefix" "anim"
"bucket" "0"
"bucket_position" "0"

"clip_size" "20" //was 50

"primary_ammo" "AMMO_TYPE_SNIPERRIFLE"
"secondary_ammo" "None"

"weight" "25"
"item_flags" "0"

"LoadoutSlots" "2"

// Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds)
SoundData
{
"single_shot" "AK47.Fire"
"shoot_incendiary" "AK47.FireIncendiary"
}

// Weapon Sprite data is loaded by the Client DLL.
TextureData
{
"weapon"
{
"file" "vgui/hud/iconsheet2"
"x" "128"
"y" "384"
"width" "192"
"height" "64"
}
"ammo"
{
"file" "vgui/hud/iconsheet"
"x" "384"
"y" "448"
"width" "64"
"height" "64"
}
"crosshair"
{
"file" "sprites/crosshairs"
"x" "0"
"y" "48"
"width" "24"
"height" "24"
}
"autoaim"
{
"file" "sprites/crosshairs"
"x" "0"
"y" "48"
"width" "24"
"height" "24"
}
}
ModelBounds
{
Viewmodel
{
Mins "-10 -2 -13"
Maxs "30 10 0"
}
World
{
Mins "-8 -9 -6"
Maxs "29 9 8"
}
}
}
DISCLAIMER & NOTES
DISCLAIMER : All of my knowledges regarding theses scripts are self-taught and personal testing. Therefore, some of these lines MIGHT be misinterpret by me.

NOTES :
  • The only thing matters is the value inside the quotation marks ( " ) and brackets
  • I suggest to not mess with any of the brackets and focus on the value inside quotation marks
Modifying Stability, Recoil and Spreads
Refer to these lines :

"VerticalPunch" "2.36"
"SpreadPerShot" "1.16"
"MaxSpread" "10"
"SpreadDecay" "5"
"MinDuckingSpread" "0.1"
"MinStandingSpread" "0.5"
"MinInAirSpread" "2"
"MaxMovementSpread" "6"

  • Vertical Punch - Defines how strong your weapon's recoil vertically (forces that make your reticle goes upward )
    REFERENCE : 1 is normal, 2 is average, 4 is high

  • SpreadPerShot - Defines how much spreads your weapon produce each shot
    REFERENCE : Value < 0.5 is normal for auto-fire weapons, value 1 ~ 3 is quite normal for single-fire weapons, value > 4 is high even for single-fire weapons

  • MaxSpread - The maximum spreads your weapon can get (spreads being produced by SpreadPerShot)
    REFERENCE : Original AK is 35, original Uzi is 20, original Auto Shotgun is 10

  • SpreadDecay - The amount at which your weapon recover from its accumulated spread per second (I assume)
    REFERENCE : HALF the amount of MaxSpread for rapid fire weapons, QUARTER the amount of MaxSpread for slow firing weapons

  • MinDuckingSpread, MinStandingSpread, MinAirSpread, MaxMovementSpread - Your current spreads multiplied by one of this amount, depending your current states ( crouching, standing still, jumping, moving ). That means your current spread can go lower or higher depending on the value
    REFERENCE : 0 is dead accurate, 0.1 ~ 0.9 being accurate, 1 ~ 1.5 being normal , 2+ is inaccurate


SHOTGUN EXCLUSIVE LINES ( still can be applied to other weapons tho )
Refer to these lines :

"PelletScatterPitch" "4.0"
"PelletScatterYaw" "8.5"

  • PelletScatterPitch, PelletScatterYaw - These values determine your shotgun spreads in a seemingly circular shape. PITCH determine the vertical spreads. YAW determines the horizontal spreads.
    REFERENCE : 0 value in PelletScatterYaw results in no vertical spreads and vice versa, 4 ~ 8 being normal for normal shotguns
Modifying Damage, Range and Penetrations
Refer to these lines :

"PenetrationNumLayers" "2"
"PenetrationPower" "50"
"PenetrationMaxDistance" "0"

"Damage" "58"
"Range" "3000"
"RangeModifier" "0.97"
"GainRange" "1500"
"Bullets" "1"
"CycleTime" "0.13"

  • Damage - Self-explanatory, damage dealt per bullet ( per pellets for shotguns )
    REFERENCE : 50 one-shot (body shot) Commons on Normal, 67 on Hard, 100 on Expert ; go to "Reference" section of this guide for more information

  • Range - How far your bullets / projectiles will travel before going to fall off
    REFERENCE : 500 is close, 3000 is medium range, 8000 is far

  • GainRange - Range your bullets will travel after they have gone past the "Range" value
    REFERENCE : See "Range"

  • RangeModifier - Your bullets damage multiplier after they have travelled past "Range" value
    REFERENCE : 0 being no damage, 1 being full damage, 0.5 being half damage

  • Bullets - Amount of bullets / pellets your weapon fires each click or each shot. Each bullets / pellets deal damage according to "Damage" value. (thats mean "Damage" x "Bullets" )
    REFERENCE : 10 pellets each shot on Pump Shotgun ( equates to "Damage" x 10 ) , 1 bullet on non-shotgun weapons

  • CycleTime - Time taken to fire each shots ( in second )
    REFERENCE : 0.1 is 10 shots in one second ( 10 RPS , 600 RPM ) , 0.05 is being EXTREMELY FAST ( 20 RPS, 1200 RPM )

  • PenetrationNumLayers - How many layers your bullets will travel through before it stops ( each object has different thickness )
    REFERENCE : 2 is normal , 4 is decent, 8 is good penetration

  • PenetrationPower - Damage multiplier after your bullets pass through an object
    REFERENCE : 0 is no damage, 50 is half damage, 100 is full damage

  • PenetrationMaxDistance - How far your bullets will travel after it passes through an object
    REFERENCE : See "Range"
Modifying Clip Size and Reserve Ammo
Refer to these lines:

"clip_size" "20"
"primary_ammo" "AMMO_TYPE_SNIPERRIFLE"
"secondary_ammo" "None"

  • clip_size - The maximum amount of shots your weapon can fire before it needs to reload
    REFERENCE : Original AK has 40, Original SMG has 50, Original Pistol has 15

  • primary_ammo - The reserve ammo, the maximum ammo you can carry before running out of ammo. Can only be replenished at Ammo packs or Ammo Piles. M60 and Grenade Launcher cannot be replenished. Pistol, Dual and Magnum have infinite reserver ammo.

    Notes : You can't edit this value to your liking, you can only give your weapon a set amount of reserve ammo. IDK why but I can't seems to edit it too much

    REFERENCE :
    • "AMMO_TYPE_PISTOL" infinite reserve ammo
    • "AMMO_TYPE_MAGNUM" infinite reserve ammo
    • "AMMO_TYPE_GRENADELAUNCHER" 30 reserve ammo
    • "AMMO_TYPE_SHOTGUN" 56 reserve ammo
    • "AMMO_TYPE_AUTOSHOTGUN" 90 reserve ammo
    • "AMMO_TYPE_HUNTINGRIFLE" 150 reserve ammo
    • "AMMO_TYPE_SNIPERRIFLE" 180 reserve ammo
    • "AMMO_TYPE_MINIGUN" 300 reserve ammo
    • "AMMO_TYPE_ASSAULTRIFLE" 360 reserve ammo
    • "AMMO_TYPE_SMG" 650 reserve ammo

  • secondary_ammo - Haven't tried this out, tell me if you know what it is
Modifying Reload Speed, Deploy Time
Refer to these lines :
(if there is none, add it yourself)

"ReloadDuration" "1.66"
"DualReloadDuration" "1.66"
"DeployDuration" "0.66"
"DualDeployDuration" "0.66"

  • ReloadDuration - How long it takes to reload and replenish your clip_size ( in second ). Shotguns reload each bullet individually so it takes "ReloadDuration" x "clip_size" to reload an entire clip from empty
    REFERENCE : 0.3 is normal for shotgun, 2.5 is normal for rifle

  • Deploy Duration - How long it takes to draw/ take out your weapon after switching ( in second)
    REFERENCE : 0.5 is fast, 1 is ok , 2 is long

  • DualReloadDuration, DualDeployDuration - Like above, but only applies to Dual Pistol ( to my knowledge )
Modifying Misc Stuff
Refer to these lines :

"MaxPlayerSpeed" "230"
"weight" "25"

  • MaxPlayerSpeed - Self-explanatory, set your movement speed when the weapon is equipped
    REFERENCE : 250 is normal

  • weight - Haven't realy tried this, might matter
    REFERENCE : 20 is normal
Modifying Etc Stuff
Please refer to these lines :

"Team" "Survivor"
"Tier" "2"
"MaxAutoAimDeflection1" "10.0"
"MaxAutoAimRange1" "0"
"Rumble" "4"
"BuiltRightHanded" "1"
"TimeToIdle" "1.5"
"IdleInterval" "60"
"LoadoutSlots" "2"

  • Tier - Weapons has three tiers ( 0 , 1 and 2 )

    REFERENCE :
    • Tier 0 : Pistol, Dual, Magnum, Melee, M60 and Grenade Launcher
    • Tier 1 : SMG, Silenced SMG, Chrome Shotgun and Pump Shotgun
    • Tier 2 : AK, SCAR, M16, Hunting Rifle, Military Sniper, SPAS and Auto Shotgun


All of the other seems to be self-explanatory and some of them even I don't understand what they do. If you know what these other etc stuff do, feel free to tell me
Reference
Most of this datas are gathered from Left 4 Dead 2 Wiki, I just want to sum it up

http://left4dead.wikia.com/wiki/Weapons

DAMAGE REFERENCE
  • Damage needed to kill Common Infected ( HP = 50 ) :
    25 on Easy
    50 on Normal
    67 on Hard
    100 on Expert

  • Specials' HP:
    Boomer : 50
    Spitter : 100
    Hunter, Smoker : 250
    Jockey : 325
    Charger : 600
    Witch : 1000
    Tank : 3000 on Easy, 4000 on Normal, 8000 on Advanced and Expert

  • Body parts multiplier :
    Headshot instantly kill Commons
    Headshot deals 4x damage to Hunter, Smoker, Boomer, Jockey, Charger, Spitter. (1.25x if shotgun)
    Bodyshot deals 1.25x damage to Hunter, Smoker, Boomer
    Armshot deals 1.25x on Jockey, Charger, Spitter
    Legshot deals 0.75x damage to Hunter, Smoker, Boomer

  • Special rules :
    M60 instantly kills Commons
    Explosives instantly kills Commons
    Explosives deals 4x damage to Tank
    Shotguns deals 15% less damage to Tank
    Shotguns has 5x damage multiplier against witch at point-blank range

  • You can read the rest at Left 4 Dead 2 Wiki
Testing and Adding Your Weapon Scripts to Workshop
After you have finished modifying your weapons, you need to compile into .vpk ( Valve Package FIles )
To do that you need recreate the same path from where you extract the data.

In case of modifying weapon's script
  • Create one new folder ( name it whatever )
  • Create folder named scripts
  • Copy and paste your weapon script inside
  • EXAMPLE : [[PATH]]\MY CUSTOM AK47\scripts\weapon_rifle_ak

  • Drag the named folder to vpk.exe
  • There should be .vpk files appeared at the same folder
  • EXAMPLE : Drag "MY CUSTOM AK47" into vpk.exe, there should be "MY CUSTOM AK47.vpk" in the same folder afterward.

Now you have the .vpk files, you need to upload it into workshop using Left 4 Dead 2 Authoring Tools



  • Open Left 4 Dead 2 Authoring Tools
  • Open Workshop Manager
  • Click Publish New Add-on
  • Fill in the gaps and follow the procedure
  • Click Upload

Now, you can Suscribe to your weapon script anytime you want and anybody can do that also !
Closing Words
Thanks for reading this guide, if you have any question or if I did mistakes, feel free to tell me in the comment section.
English is not my first language, so I feel like there is some grammatical error here and there

Also, if you feel like it, please check my custom weapons script that I made :
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=975654995
200 Comments
Pemarces273 5 Jul @ 9:10pm 
@KeizerDawn in that particular weapon script
Pemarces273 5 Jul @ 9:09pm 
@KeizerDawn Add this in the character viewmodel addon,

"CharacterViewmodelAddon"
{
"Coach" "models/weapons/arms/v_arms_coach_new.mdl"
"Mechanic" "models/weapons/arms/v_arms_mechanic_new.mdl"
"Producer" "models/weapons/arms/v_arms_producer_new.mdl"
"Gambler" "models/weapons/arms/v_arms_gambler_new.mdl"

"Manager" "models/weapons/arms/v_arms_louis.mdl"
"Biker" "models/weapons/arms/v_arms_francis.mdl"
"TeenGirl" "models/weapons/arms/v_arms_zoey.mdl"
"NamVet" "models/weapons/arms/v_arms_bill.mdl"
}
KeizerDawn 14 May @ 7:33pm 
noticed some hands go missing when using an edited weapon script anyone know a fix for this?
D.Toshimura 5 May @ 3:18pm 
fire rate?
BundyIsHome 5 Feb @ 7:19pm 
Some interesting stuff I've discovered

Changing the "primary_ammo" line doesn't only change the reserve ammo, apparently it also affects some sort of mechanics.

for instance, the recent ak47 script I made. I changed it to "AMMO_TYPE_AUTOSHOTGUN" and what happened next was that the headshot mechanic on Special Infected was lost. The same amount of bullets spent on body shots are also spent on headshots

Now when I tested it using "AMMO_TYPE_HUNTINGRIFLE" instead, complete 1-shot kill to the head on SI.
BundyIsHome 25 Jan @ 9:17am 
For new modders, did the math for cycling time.

Formula goes like this:

RoundsperMin ÷ 60 = N
1 ÷ N = Cycletime

sample:
700 / 60 = 11.66 (round off to 11.7)
--> 1 / 11.7 = 0.08547 (round off to .0855)
I microwaved my son 17 Jan @ 1:19pm 
work for melee? (Note: I didn't read all of it, im just looking to buff the frying pan to ungodly damage levels)
WHERE DO YOU GET THE M60???
JohnsonCereal986 11 Oct, 2024 @ 8:59pm 
So I can't edited css weapons bevause it will look fucked up? huh.
Pwnage Peanut 2 Jul, 2024 @ 9:31pm 
Helpful guide is helpful