Call of Pripyat Weapon Creation

From Mod Wiki

Jump to: navigation, search

This tutorial serves as an introduction to creating a weapon based off of a 'blueprint' of a vanilla rifle, giving it another assault rifle's upgrades, and linking it so that it can function properly in game, and be upgraded by the technicians.

Some statistics and naming conventions are handled a slight bit differently then in Shadow of Chernobyl.


Starting Up

First off, we need to make sure that the game will load the necessary script. This is fairly simple to do:

Navigate to your gamedata\configs\weapons\ folder, and search for the weapons.ltx. This is the master file that tells the game which scripts to include as weapon scripts. If this file isn't modified, your gun won't load up properly - it might load up if you tell other #include files to load it, but it's best to encourage clean, tidy modification from the start.

All we have to do here is fairly simple. We make an #include reference, pointing to the script we'll be making for the rifle. Lets call it 'w_tester.ltx'. It should look something like this:

#include "w_tester.ltx"

Now we make the file. You can make a LTX file in notepad, by selecting "All File Types", and then defining it as w_tester.ltx, making sure to add the file extension.


Since this is your first weapon, you likely won't want to deal with all of the dirty, back-end scripting, such as animation references, attachment points, and bone placement. These are arduous, requiring a fair amount of work to get working properly. We'll cover the fun stuff - like rate of fire, damage, and durability - and the not-quite as fun stuff - accuracy, recoil management, and ammunition types. These are the most noticeable, and less trial-and-error then the other facets of scripting.

To get past the need for animation, bones, and other complicated areas, we'll use a reference. A reference in the LTX is essentially a way of telling the game that a gun is based off of another gun, and thus inherits all of the statistics of that weapon unless otherwise stated. In short, anything we add in will take priority in the finished product.

For simplicity, we'll base this off of the LR-300. Not the most popular weapon, but it's a solid all around weapon, letting you see what kind of effects your scripting has compared to the standard gun.

At the top of the w_tester.ltx, put in this:

[wpn_lr300_tester]:wpn_lr300 ; This tells the game our gun is based off of the LR-300.

Your weapon, as it is, should work. It'll behave just like an LR-300, and traders and techs won't know what on earth it is, but you can carry it by yourself without ruining the game. But we want our gun to work, and to be different.

For the next part of this tutorial, I'll be explaining various variables most commonly manipulated, and how to change them to your tastes.


$spawn                  = "weapons\lr-300"               ; option for Level Editor
$npc                 	= on           ; option for Level Editor
$prefetch               = 8
scheduled               = off                                ; option for ALife Simulator
cform                   = skeleton
class                   = WP_AK74
description             = st_wpn_lr300_descr
ef_main_weapon_type     = 2
ef_weapon_type          = 8
default_to_ruck         = false
sprint_allowed          = true

Fairly straight forward.

$spawn - The location when searching for it in the SDK Level Editor. Unnecessary, but it doesn't hurt to define it.

$npc - Whether or not npcs can use this weapon. For Call of Pripyat, it is highly recommended to leave this ON.

$prefetch - Not necessary to modify, unless you don't want it to preload.

scheduled - Again, not necessary to modify.

cform - Used for animations, another item you DO NOT modify.

class - Weapon class. All assault rifles use the WP_AK74 class.

description - The item's description. This points to your localization's weapons.xml file - name varies.

ef_main_weapon_type - The weapon type. All weapons in Call are '2', meaning they can be equipped in either inventory slot.

ef_weapon_type - Similar to main_weapon_type.

default_to_ruck - Can fire while sprinting?

sprint_allowed - Can the user sprint while wielding?

Upgrades & Cost

cost                 	= 6000
weapon_class            = assault_rifle
inv_weight              = 2.7
upgrades                = up_gr_firstab_lr300, up_gr_seconab_lr300, up_gr_thirdab_lr300, up_gr_fourtab_lr300, up_gr_fifthab_lr300
installed_upgrades      =
upgrade_scheme          = upgrade_scheme_lr300

cost - The cost in RU, not factoring in any discounts or randomization on the trader's part.

weapon_class - Where it will appear in the multiplayer buy menu. inv_weight - How much it weighs unloaded.

upgrades - A reference to the weapon's available upgrade trees - in no case will it exceed five. It's also encouraged to keep upgrades of the same weapon type, for simplicity and stability. Note that, no matter what you do with your values, you do not need to modify upgrades to ensure they have some kind of benefit - they're coded to add or multiply.

installed_upgrades - A bit more complicated, this can be used to ensure specific upgrades are always installed - examples of items using this are Joker's Respirator, Barge's Sunrise Suit, and Snag's gear.

upgrade_scheme - The scheme used for display purposes when visiting a technician.

Firepower & Ammunition

hit_power         = 0.3, 0.3, 0.3, 0.3       ; The amount of damage incurred by the bullet. .3 equals roughly a third of an unprotected Stalker's health.
hit_impulse       = 100                      ; The physical force of a round. Higher values cause more dramatic ragdoll deaths.
hit_type          = fire_wound               ; The type of wound - you can create chemical, electrical, and 'slash' weapons by modifying this.
fire_distance        = 200                   ; The distance in meters before the bullet 'dies' - anything beyond this range will not be hit.
bullet_speed         = 600                   ; The velocity, in meters per second.
rpm                  = 685                   ; The rate of fire, in rounds per minute.
rpm_empty_click      = 200                   ; The rate at which the 'empty' sound file will play, if one tries to fire while empty.
use_aim_bullet          = false              ; The 'railgun' effect of the gauss rifle.
time_to_aim             = 2.0                ; The time it takes for a player to zoom in.
hud                        = wpn_lr300_hud   ; The model displayed on the HUD when using the weapon. What you're holding.
misfire_probability             =       ; The probability of a misfire occurring at ANY time.
misfire_start_condition		=       ; The point at which the misfire chance starts to rise.
misfire_end_condition		=       ; The point where misfire chance stops rising.
misfire_start_prob	     	=       ; The starting chance of misfiring.
misfire_end_prob	     	=       ; The ending chance of misfire.
condition_shot_dec      	=       ; How much condition is lost per shot.
condition_queue_shot_dec	=       ; How much condition is lost per shot in full-auto fire.
ammo_elapsed            = 30                 ; The size of the magazine.
ammo_mag_size        	= 30                 ; This number must equal the 'elapsed' variable - otherwise the value may not be either!
fire_modes          	= 1, 3, -1           ; Firing modes. 1, 2, 3 equal semi-automatic, double-burst, and triple-burst. -1 is fully automatic.
ammo_class	= ammo_5.56x45_ss190, ammo_5.56x45_ap ; Ammo class for the standard rifle.
grenade_class	= ammo_m209                           ; Ammo class for the undermounted grenade launcher - this ammo must be a grenade or it will crash.
launch_speed            = 0                  ; Launch speed modifier of the grenades. 0 is default, higher becomes unreliable.
hand_dependence         = 1                  ; True/false, effects the weapon on ladders and in vehicles.
single_handed           = 0                  ; True/false, effects whether or not you can carry a detector - with normally two-handed weapons, can lead to amusing three-hands or awkward hand animations.

Recoil & Accuracy

zoom_dof             = 0.5, 1.0, 180         ; Depth of field modifier when using iron-sights.
reload_dof           = 0.0, 0.5, 5, 2        ; Depth of field during reload.
;áàçîâàÿ äèñïåðñèÿ
fire_dispersion_base	= 0.25	             ; The basic cone of fire in degrees - how accurate the gun's first burst will be. Affects basic accuracy, and displayed accuracy statistic.
control_inertion_factor	= 1.2f               ; The amount of 'brakes' applied to the gun - how difficult it is to turn quickly and reliably. Notable on the PKm and SVD. Affects handling statistic.
crosshair_inertion		= 5.25       ; The amount of inertia from maneuvering the camera - how likely your aim is to drift off target if you jerk. Affects handling statistic.
cam_return				= 0  ; Does the camera return to your target afterwards?
cam_relax_speed         = 5	             ; The speed at which your crosshairs return to 'neutral'
cam_relax_speed_ai      = 360                ; How quickly the AI's aim restores after a burst. They're supermen.
cam_dispersion          = 0.3	             ; Dispersion when zoomed into ironsights.
cam_dispersion_inc      = 0.15	             ; How much is added to dispersion with each shot.
cam_dispersion_frac     = 0.7	             ; Another factor into dispersion.
cam_max_angle        	= 50.0 	             ; The maximum angle recoil can carry your crosshair from origin - in this case, 50 degrees up.
cam_max_angle_horz      = 10.0	             ; Maximum horizontal offset
cam_step_angle_horz     = 3.0	             ; Horizontal recoil caused by firing. 0 will cause a vertical recoil, negative will recoil to the left.
PDM_disp_base 				= 0.5
PDM_disp_vel_factor 		= 2.0
PDM_disp_accel_factor 		= 2.0
PDM_disp_crouch	 			= 1.0
PDM_disp_crouch_no_acc 		= 1.0
zoom_cam_relax_speed        = 5              ; The speed at which your ironsights/scopes return to neutral.
zoom_cam_relax_speed_ai     = 360            ; The speed at which an AI restores aim after firing in ironsights/scopes.
zoom_cam_dispersion         = 0.25           ; Same as above, only affecting ironsights/scopes.
zoom_cam_dispersion_inc     = 0.12           ; Same as above, only affecting ironsight/scopes.
zoom_cam_dispersion_frac    = 1.0            ; Guess.
zoom_cam_max_angle          = 50.0           ; Guess again!
zoom_cam_max_angle_horz     = 10.0           ; Guess again!
zoom_cam_step_angle_horz    = 2              ; Again, the same.
fire_dispersion_condition_factor = 17        ; How much condition effects dispersion - higher numbers result in more dramatic degradation

AI Stats

holder_range_modifier   = 1.0                ; An AI's effective seeing range when carrying the weapon.
holder_fov_modifier     = 1.0                ; An AI's field of view when carrying the weapon. 1.0 gives it a roughly 180 field of view.
min_radius              = 0                  ; Minimum radius in which you can be seen, in meters. Can cause interesting hijinks.
max_radius              = 100                ; Maximum radius at which AI can distinguish friend or foe.
hit_probability_gd_novice  = 0.80            ; Probability of a bullet getting full damage on Novice.
hit_probability_gd_stalker = 0.80            ; Probability of a bullet getting full damage on Stalker.
hit_probability_gd_veteran = 0.80            ; Probability of a bullet getting full damage on Veteran.
hit_probability_gd_master  = 0.80            ; Probability of a bullet getting full damage on Master.
                                             ; Unlike Shadow of Chernobyl and Clear Sky, this is a one-way road: players' bullets always hit their targets. Can be used to crank up the difficulty on all levels.

Add-ons & Attachments

scope_status               = 2               ; 0 means it can not be attached. 1 means it's a permanent, integral attachment. 2 is an attachment point.
silencer_status            = 2               ;
grenade_launcher_status    = 2               ;

At this point, you know how to modify the basic stats and performance of a weapon. Other things such as integral scopes, silencers, animations, HUD effects, will be covered in another, more advanced article.

Adding it to the Game

Unlike Shadow of Chernobyl, more needs to be done to get your gun to work in game. For one, while you can probably use it in game, it probably crashes when you take it to a trader, or drop it in the open. Not very pleasant bugs, and you probably notice you can't get it repaired or upgraded!

There are three more items that need to be modified;

1. Navigate to your configs\mp directory, and go to mp_ranks.ltx - the weapon name needs to be added to the 'available items' field of the corresponding rank. The higher the rank number, the higher AI stalkers prioritize it in looting and equipment.

2. Navigate to the configs\misc directory, and open the inventory_upgrades.ltx - this file defines what items are upgradeable. Add the weapon name into the document.

3. In the misc directory, open stalkers_upgrade_info. A long, long file will open. Even if your weapon borrows upgrades from another rifle, technicians will not know how to upgrade it if the weapon isn't listed amongst those in the document. Each technician has their own list - only the first two can upgrade weapons.

After your weapon's name has been added to these three files, the weapon should work perfectly - the only remaining issue is acquiring it.

Adding it to traders

This is fairly simple;

In the same misc folder, go to the trade directory. Select the appropriate trader - you can guess which is which from the 'zat' 'jup' and 'prp' tags. We'll use Owl, the Zaton trader, as our reference. Open the 'trade_zat_b30_stalker_trader.ltx'.

The first long line of articles - it takes up about half the article - are sales modifiers. While Owl will take your weapon off your hands, if it's not mentioned here he won't be able to sell it back. Go ahead and add it underneath the other weapons, keeping the same variables.

To buy it from him, hit Ctrl+F and find '[supplies_generic]'. These are the items Owl will always sell regardless of faction and wealth - his starting inventory, essentially. Add the bottom, add this:

wpn_lr300_tester          = 1, 1

This tells Owl he will sell one of your guns, with a 100% chance of stocking it.

Start up a new game, walk up to Owl, and hopefully you have enough rubles to purchase the weapon!

Adding it to your inventory

Adding it to your starting inventory is even more straight forward.

Navigate to the configs\gameplay folder, and open the 'character_desc_general.xml'. The first listing is your own character, his name, starting inventory, and cash.

Here's what the supplies category should look like:

			[spawn] \n
			device_torch \n
			wpn_binoc \n
			wpn_knife \n
			detector_basic \n
			helm_respirator \n
			stalker_outfit \n
   			grenade_rgd5 = 2 \n
			wpn_pm_actor  \n
   			ammo_9x18_fmj = 3 \n
   			wpn_lr300_tester \n
			bandage = 2 \n
			antirad = 1 \n
			medkit = 4 \n
			bread = 1 \n
			kolbasa = 1 \n
			conserva = 2 \n

Congratz! Your character will now spawn with the 'Tester LR300' in his inventory upon starting a new game. You've created your first modified weapon!

Personal tools