Left 4 Dead 2

Left 4 Dead 2

42 oy
Custom Weapon Lab [Info]
devlos tarafından
A Infomartical guide and info roster for the CWL Base and framework.
   
Ödül
Favorilere Ekle
Favorilere Eklendi
Favorilerden Çıkar
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 = []
      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]
44 Yorum
Krychur 6 Eki @ 9:50 
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.
Krychur 6 Eki @ 9:45 
I'm having an odd issue. when in first person, I see the w_model floating in the air and playing third person animations. did I break something?
valenoarm 4 Eki @ 22:32 
In the file where the list of weapons should be placed, words in Chinese appear and when I put the weapons in the file and start a game, the weapons are not found in the game, then when I return to the file, all the weapons I had added were deleted and only those words remain as in Chinese, which are ൻऊ敒汰捡健牥散瑮条⁥‽〵਍䌉獵潴坭慥潰䱮獩⁴‽≛敷灡湯獟整特Ⱒ∠敷灡湯獟潨杴湵慟瑵≯眢慥潰彮档湩彡慬敫Ⱒ∠敷灡湯灟浫崢਍}
Felix the Cat 3 Tem @ 15:14 
is there a list of the act third person animations?
SWAMPY 1 Tem @ 15:19 
@devlos the last update fixed the spawning issue I was having which is great :) just wondered is there a limit to how many guns you can add to the list? sometimes it seems some weapons never spawn despite me being able to create them with the "/cwl create" command
ChapCanai 22 Haz @ 21:23 
@devlos Thanks, I ordered all the sequences the same as in the vanilla qc and its fixed
devlos  [yaratıcı] 22 Haz @ 12:10 
@Alex_D thanks for noticing this , must have been a oversight while drinking beer. lol
devlos  [yaratıcı] 22 Haz @ 12:09 
@koutome it's a older development build wher ei recorded the video from , everything is really the same the only difference is the weapon_names in the custom_weapon list array
devlos  [yaratıcı] 22 Haz @ 12:08 
@ChapCanai You copied over a weapon_model from a different class without actually porting it to the new weapon_class. The sequences are not in order that way. So you can't just take a weapon_rifle custom model and apply it to a weapon_sg552 for example , first you would need to properly port it.
Koutome 22 Haz @ 10:52 
@devios The files are not the same, and I got quite confused, I didn't understand where to get the weapons from, and I already understood, but it was because of the video, not because of the written guide.