Left 4 Dead 2

Left 4 Dead 2

48 ratings
Custom Weapon Lab [Info]
By devlos
A Infomartical guide and info roster for the CWL Base and framework.
   
Award
Favorite
Favorited
Unfavorite
Introduction Guide
Custom Weapon Lab Informational Guide


MOD INFO

Version - v0.76
Change Log - Updates
Mod Url - Workshop Page

NOTE

  • [DISCLAIMER] The LOD's for the worldmodels won't work if either off these video-settings are put on low.
    • Model / Texture Quality:
      • Reason [LOD's are not loaded to preserve model and texture memory]
    • Paged Pool Memory:
      • Reason [LOD's require CPU memory to shift their models based on distance]


This should not be a issue for a Huge portion off the community , unless you still run a 25 year old pentium 4 or have less then 256 M/b's off video memory. These settings should always be on medium they provide better performance overal aslong as you meet better system requirements then the minimal.
Creating a custom weapon [Introduction]
Disclaimer


Make sure you have permission to use and create these weapons i will use this weapon mod as a example


I will use the AKM Silencer mod from Cele , replacing the ak47.

Cele's AK47 MOD

Make sure the weapon works originally as a replacement for that weapon_class that means it should always be a functional weapon mod to begin with! If it does not work as a simple weapon mod , then it won't work as a custom weapon replacement.

End Result:





Viewmodel
When opening the .QC file for the viewmodel there are two things you would need to add or change.

A Custom Path

In the .QC the original path would look something like this , overriding the original viewmodel in the game , now since we are working with custom weapons we would need to change the modelname path to a custom directory for example.

From:
$modelname "v_models\v_rifle_ak47.mdl"
To:
$modelname "v_models\mycoolcustompath\v_rifle_ak47.mdl"

So We should now have something like this:

A New Sound Event [5004]:

By Default all sound events should be implemented on the _layers section , however for the custom weapon viewmodel there is a single event that is not handled by the mod and that is the shove sound that is required to be added in the melee_layer.

We put this in the layer like so:
{ event 5004 3 "Weapon.Swing" }


Compile with crowbar and there we go!

Congratulations , you made the viewmodel compatible with the custom weapon lab mod!








Worldmodel
When opening the .QC file for the wolrdmodel there are two things you would need to add or change.

A Custom Path

In the .QC the original path would look something like this , adding a new worldmodel in the game , now since we are working with custom weapons we would need to change the modelname path to a custom directory for example.

From:
$modelname "w_models\Weapons\w_rifle_ak47.mdl"
To:
$modelname "$modelname "w_models\mycoolcustompath\w_rifle_ak47.mdl"

Disclaimer: Make sure the $bodygroup is named "main"

So We should now have something like this:

A New LOD:

By Default the worldmodel does not have a LOD , the LOD is required to prevent the worldmodel rendering within your field off view , now before we can add it we need to create a seperate .smd just for the LOD and changing a couple things by editing your existing worldmodel.

first we duplicate the worldmodel .smd like so:


We then rename that .smd with _invisible at the end as the .smd name:
yourduplicatedworldmodel_invisible.smd


Now before we go back in the .QC we would need to edit the .smd file , by simply right clicking on it and clicking edit , use any text editing software off your choice.

Now by default it would look something like this:

It is each loosse mesh , that has a given amount off vertexes assigned per material , as you can see i have wood_diffuse but there are more.
Now what we want to do is find every material name used and write it up somewhere on the side or within the file temporarely.

I found all these materials being part off the .smd , in my instance.

wood_diffuse akm_diffuse silencer_col grip_d flash_d


Now all these materials beneath under triangles and set them up like so:

We then add a single vertex to each unique material , like so.


Here is a Copy & Paste version for the single vertex.

0 0.000001 0.000000 0.000001 0.000000 1.000000 0.000000 1.000000 0.000000 1 0 1.000000 0 -0.000001 0.000000 -0.000001 0.000000 1.000000 0.000000 0.000000 1.000000 1 0 1.000000 0 -0.000001 0.000000 0.000001 0.000000 1.000000 0.000000 0.000000 0.000000 1 0 1.000000


Now when done , save it and we then go back to the .qc

Here we will need to add a bodygroup and LOD like so , keep in mind the body hierachy is important has to be the same as the example!:


Compile with crowbar and there we go!

Congratulations , you made the worldmodel compatible with the custom weapon lab mod!
Custom Weapon Implementation
Adding a new custom weapon to the cfg

ems/custom_weapon_lab/custom_weaponlist.cfg

Now we need to Open up the ems configuration and add in your new weapon located in:
ems/custom_weapon_lab/custom_weaponlist.cfg

In the CustomWeaponlist array you would need to add in the weapon , we will call our weapon a weapon_aks_silenced and add it into the array to load like so:


Make sure to embed in a string "weaponname" and seperate it with a comma as seen in the original!

ems/custom_weapon_lab/weapons/yourweaponname/yourweaponname.cfg

Now , when we load the game a new CFG file will be generated with that weapon name , we now would need to fill in the worldmodel , viewmodel and class make sure to use "models/yourmodelpath" and save the changes. DO NOT EDIT THE SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING!


Reload the game or map , make sure you are the host and give yourself the weapon using the chat command /cwl create weaponname , in my case it is /cwl create weapon_aks_silenced , this will generate a new file the _settings.cfg located in the same folder

ems/custom_weapon_lab/weapons/yourweaponname/yourweaponname_settings.cfg

This file contains all the weapon settings , edit save and reload to see the changes make sure you edit the FIRE_SOUND to match the weapon and save! Have fun!

Congratulations , you made a custom weapon with the custom weapon lab mod!


To share , do not pack the custom_weapon_lab folder entirely only the weapon folder located in
ems/custom_weapon_lab/weapons/yourweaponname/ in the same hierachy in a .vpk file.
EMS Info
This section provides a overview off all variables in the script files that are required to set-up a functional custom weapon

  • [EMS] file to modify and spawn custom weapons.
    • [EMSFilePath] custom_weapon_lab/custom_weaponlist.cfg
      Variable
      Value
      Info
      ReplacePercentage
      100
      Amount off weapon spawns to replace by custom weapons.
      CustomWeaponList
      ["weapon_name" , "..."]
      A array list off current actively allowed custom weapons to spawn or create.
  • [EMS] file to set up weapon requirements to function.
    • [EMSFilePath] custom_weapon_lab/weapons/weapon_name.cfg
      Variable
      Value
      Info
      Script
      "weapon_logic_script"
      The Script that includes the weapon logic into the weapons scope
      WeaponClass
      "weapon_class_to_override"
      Weapon Class to replace and override as a spawn but also as the weapon the viewmodel is designed for
      CustomFPmodel
      ".../custom_viewmodel_path.mdl"
      Your custom first person viewmodel Path
      CustomTPmodel
      ".../custom_worldmodel_path.mdl"
      Your custom third person viewmodel path
  • [EMS] file to edit weapon settings.
    • [EMSFilePath] custom_weapon_lab/weapons/weapon_name_settings.cfg [Part 1]
      Variable
      Value
      Info
      DEBUG
      false
      Enable debugging for the weapon
      DEPLOY_TP_ANIM
      "ACT_DEPLOY_..."
      deploy third person animation to use
      DEPLOY_FP_ANIM
      "deploy_layer"
      deploy first person animation to use [_layer] sequences directly being called utlize events better like 5004
      DEPLOY_ANIM_FRAMES
      29
      deploy first person animation frames to calculate
      DEPLOY_ANIM_FRAMERATE
      48
      deploy first person animation framerate to use to calculate
      BASH_TP_ANIM
      "ACT_MELEE_Shove_..."
      bash third person animation to use
      BASH_FP_ANIM
      "melee_layer"
      bash first person animation to use [_layer] sequences directly being called utlize events better like 5004
      BASH_ANIM_FRAMES
      21
      bash first person animation frames to use to calculate
      BASH_ANIM_FRAMERATE
      30
      bash first person animation framerate to calculate
      RELOAD_TP_ANIM
      "ACT_RELOAD_..."
      reload third person animation to use
      RELOAD_FP_ANIM
      "reload_layer"
      reload first person animation to use [_layer] sequences directly being called utlize events better like 5004
      RELOAD_ANIM_FRAMES
      76
      reload first person animation frames to use to calculate
      RELOAD_ANIM_FRAMERATE
      34
      reload first person animation framerate to calculate
      FIRE_TP_ANIM
      "ACT_PRIMARYATTACK_..."
      fire third person animation to use
      FIRE_FP_ANIM
      "fire_layer"
      fire first person animation to use
      FIRE_ANIM_FRAMES
      3
      fire first person animation frames to use to calculate [NOTE: the frames value should be equal to the moment the weapon fires i nmost cases a value off 3]
      FIRE_ANIM_FRAMERATE
      30
      fire first person animation framerate to calculate
      FIRE_SOUND
      "ScriptSound"
      fire script sound name to use when firing the weapon

    • [EMSFilePath] custom_weapon_lab/weapons/weapon_name_settings.cfg [Part 2]
      Variable
      Value
      Info
      Weapon Data Value
      AMMO_CLIP1
      31
      ammo amount for the main clip
      ClipSize
      AMMO_CLIP2
      250
      ammo amount for the second clip
      CarryCapacity
      WOUNDTYPE
      0
      wound gore type to give [0:Normal , 1:Explosive , 2:Slash]
      DAMAGETYPE
      2
      damagetype to use
      SHOT_DISTANCE
      3000
      shot distance amount in hammer units
      Range
      SHOT_DAMAGE
      25
      overall weapon damage per shot
      Damage
      SHOT_IMPULSE
      20
      impulse on physics or other moveable objects when hit
      FIRE_RATE
      500
      rate off fire per minute
      CycleTime = [ 60.0 / FIRE_RATE = Bullets Fired Per Second]
      RECOIL
      3
      View punch shake intensity
      VerticalPunch[Less Sophisticated]
      HEADSHOT_DAMAGE_MULTIPLIER
      4.0
      damage amount being multiplied on a headshot
      CENTER_SPREAD_RADIUS
      0
      when firing the random spread off the bullet coming out the muzzle
      SHOT_SPREAD_RADIUS
      4
      when firing the random spread off the bullet
      SpreadPerShot
      NUM_SHOT
      1
      amount off bullet being fired per shot
      Bullets
      SHOT_SECTOR_SIZE
      60
      shot sector cone angle
      DUCKING_SPREAD
      0.5
      shot spread while crouching
      MinDuckingSpread
      STANDING_SPREAD
      1.0
      shot spread while standing
      MinStandingSpread
      AIR_SPREAD
      3.0
      shot spread while jumping or in air
      MinAirSpread
      MOVEMENT_SPREAD
      6.0
      shot spread while moving
      MinMovementSpread
      MAX_PENETRATIONS
      2
      amount off surfaces penetrated by each shot
      PenetrationNumLayers
      MAX_PENETRATIONS_DISTANCE
      512
      max distance to still hit after penetration
      PenetrationMaxDistance
      PENETRATION_DAMAGE_FACTOR
      0.97
      penetration damage left after penetrating
      PenetrationPower
      PENETRATION_OFFSET
      32
      penetration spread after penetrating a surface
      PROJECTILE
      false
      enable projectile logic [NOTE: this will ignore most settings and enable projectile behaviour based on grenade launcher projectiles]
Chat Commands
  • [COMMANDS] Chat Commands Available to use in-game.
    • [Requires to be in singleplayer and being the host to spawn and create weapons manually]
      Variable
      Value
      Info
      /cwl create
      custom_weapon_name
      giving or Creating a weapon to the player using the command [Usage: /cwl create custom_weapon_name]
      /cwl list
      Prints Weapons in Console Automaticly
      lists all custom weapons available and prints them out in console [Usage: /cwl list]
53 Comments
Xanadium 2 Aug @ 5:48pm 
Hi, attempted to follow the worldmodel part of the guide but my worldmodel is separated with three .smd files instead of only one like the example above. Tried to put new lines based on that .qc example above, but the end results always been one of the .smd worldmodel shows up and the other two parts missing in TP and vice versa in FP, is there a method for this kind of worldmodel?
What is the difference between damage force and shot impulse in EMS script?
bacorjohnray 8 Apr @ 11:51am 
@devlos sir i got a question? how i edit those ems files? everytime i edit those weapon Damage the gun goes invisible i dont have any clue what to do..
狼師檔案 17 Mar @ 8:31am 
how can i add own shoot sound?
I STAPLE TAPEWORMS ON MY 22 Feb @ 3:30am 
im having a problem where /cwl create "weapon name" just gives me the gun put in WeaponClass
I STAPLE TAPEWORMS ON MY 22 Feb @ 1:53am 
note for anyone doing shotguns: make the damage type '536870912'
cieja 14 Feb @ 1:21pm 
For me it just doesn't work. The cfg file doesn't appear at all , nor can I spawn weapons with chat command , even in LAN
Doc903 7 Dec, 2024 @ 11:21pm 
Or is this supposed to replace weapon spawns?
Doc903 7 Dec, 2024 @ 11:20pm 
Would admin system allow the use of [CWL] without having to activate cheats? I really like the idea of having more weapons spawn, but it kinda confuses me.
Krychur 6 Oct, 2024 @ 9:50am 
nvm, I didn't see the part where I was supposed to name it "main." my other problem is the arms are a little too far back when drawing and reloading a weapon.