This tutorial it outdated. Please see the new version on the official wiki.
Spoiler!
Prerequisites: Creating a basic mutator
Modifying Existing Weapons
This tutorial is designed to give users the ability to modify existing weapons with minimal coding knowledge required. It is written from the perspective of modifying default weapon attributes from a single-player mutator, as follows:
This tutorial covers most of the essential attributes that can be changed. If anything is missing, don't hesitate to inform me.
Class Explanation
I'd like to take a brief moment to give you an explanation of the various classes used for weapons (and general inventory items) and how they are related:
Changing the weapon name
In order to rename a weapon you will want to alter several variables, as they are all used in different places:
Automatic & Semi-automatic Firing
Changing between automatic and semi-automatic is just a case of modifying a variable indicating if the trigger should be released before a consecutive shot can be fired (true = semi-automatic, false = automatic):
It is an attribute of a fire mode class (not of the weapon itself), meaning you can choose independently whether either primary or alt-fire are automatic or semi-automatic.
Damage
Damage is determined depending on whether the fire mode is an instant-hit (such as the 9mm's primary fire) or whether the weapon fires a projectile which deals damage itself (such as the crossbow and its arrow projectile):
Headshot damage is a little more complicated since several weapons implement this differently:
Rate Of Fire
You may want to alter both of these variables since they are related:
Recoil
If altering the rate of fire you will especially want to alter the recoil:
Accuracy
A couple of spread variables are used to affect the accuracy of the weapon. Generally since Killing Floor doesn't have crosshairs, the initial spread value is low in order to make at least the first shot very accurate:
Aiming
Any weapon can have the ability to zoom (ironsights or scope), and these variables affect the intensity (and whether the weapon can zoom):
Ammunition
Several ammunition variables are used to specify:
Pickup Message
This message appears when you pick up this weapon:
Trader
Here are the important variables used by the shop (trader):
Additionally there are three variables to control the displayed statistics, with a maximum value of 100:
Inventory Information
While these are not the most important variables to change when modifying existing weapons, I've included them here nonetheless:
Modifying Existing Weapons
This tutorial is designed to give users the ability to modify existing weapons with minimal coding knowledge required. It is written from the perspective of modifying default weapon attributes from a single-player mutator, as follows:
Code:
class AlteredWeaponMut extends Mutator;
function PostBeginPlay()
{
class'Single'.default.ItemName = "Handgun";
}
defaultproperties
{
GroupName="KFAlteredWeaponMut"
FriendlyName="Altered Weapon Mutator"
Description="Example mutator demonstrating how to alter existing weapons."
}
This tutorial covers most of the essential attributes that can be changed. If anything is missing, don't hesitate to inform me.
Class Explanation
I'd like to take a brief moment to give you an explanation of the various classes used for weapons (and general inventory items) and how they are related:
- Weapon - This is the inventory class of the weapon, and contains general information such as where the item should appear in the inventory, what its name is, and how much it weighs. It contains references to the associated WeaponPickup class, WeaponAttachment class, and FireMode classes. It also manages how the weapon appears in 1st person view. A typical example of this class is 'Single'.
- WeaponPickup - Handles the weapon when it is sitting about in the game world outside of anyone's inventory (also in the trader). It contains information about the name of the weapon, how much the weapon (and its ammunition) costs, and so on. A typical example of this class is 'SinglePickup'.
- WeaponAttachment - Manages how the weapon appears in 3rd person view (and thus to all other players). A typical example of this class is 'SingleAttachment'.
- FireMode - Handles how a particular mode fires, what kind of ammo it uses, how much damage it does, and other related things. A weapon may have two fire modes, and a fire mode doesn't necessarily need to be offensive (for example, the 9mm's alt-fire switches on the flashlight). A typical example of this class is 'SingleFire'.
- Ammo - Handles how much ammunition a weapon can hold, how much ammunition it initially contains, and how much ammunition you gain when picking up a generic ammo crate. A typical example of this class is 'SingleAmmo'.
- AmmoPickup - Simply used to indicate how much ammunition a weapon gains when picking up a particular ammo crate (for example 9mm rounds). A typical example of this class is 'SingleAmmoPickup'.
- Projectile - Used by weapons that fire projectiles (shotgun, crossbow, etc.) and describes the speed at which the projectile travels as well as damage and other information. A typical example of this class is 'CrossbowArrow'.
Changing the weapon name
In order to rename a weapon you will want to alter several variables, as they are all used in different places:
- The HUD itself where the current weapon name is displayed.
Code:class'Single'.default.ItemName = "9mm Tactical";
- The purchase panel in the shop.
Code:class'SinglePickup'.default.ItemName = "9mm Pistol";
- The inventory panel in the shop. This is meant to be a short version of the name due to the reduced area the text is displayed in.
Code:class'SinglePickup'.default.ItemShortName = "9mm Pistol";
Automatic & Semi-automatic Firing
Changing between automatic and semi-automatic is just a case of modifying a variable indicating if the trigger should be released before a consecutive shot can be fired (true = semi-automatic, false = automatic):
Code:
class'SingleFire'.default.bWaitForRelease = true;
It is an attribute of a fire mode class (not of the weapon itself), meaning you can choose independently whether either primary or alt-fire are automatic or semi-automatic.
Damage
Damage is determined depending on whether the fire mode is an instant-hit (such as the 9mm's primary fire) or whether the weapon fires a projectile which deals damage itself (such as the crossbow and its arrow projectile):
- If the fire mode is instant-hit (such as is the case with pistols):
Code:class'SingleFire'.default.DamageMax = 32;
- If the fire mode uses a projectile, the damage is specified in the projectile class itself. For example, the crossbow arrow:
Code:class'CrossbowArrow'.default.Damage = 300;
Headshot damage is a little more complicated since several weapons implement this differently:
- Projectiles that are derived from ShotgunBullet:
Code:class'BoomStickBullet'.default.HeadShotDamageMult = 1.5;
- The crossbow's arrow projectile also uses the same variable, but is not derived from ShotgunBullet:
Code:class'CrossbowArrow'.default.HeadShotDamageMult = 6.0;
- Other weapons define a headshot multiplier in the damage class itself:
Code:class'DamTypeM14EBR'.default.HeadShotDamageMult = 2.0;
Rate Of Fire
You may want to alter both of these variables since they are related:
- Rate of fire. This is actually how many seconds between each shot (0.5 is 2 rounds a second):
Code:class'SingleFire'.default.FireRate = 0.175;
- Animation speed for the firing animation. It is used as a multiplier for the animation's default speed (0.5 is half speed, 1 is full speed, 2 is double speed):
Code:class'SingleFire'.default.FireAnimRate = 1.5;
Recoil
If altering the rate of fire you will especially want to alter the recoil:
- Rate of recoil itself. This is how often the recoil is applied (again, it's the amount of seconds between applying recoil), and should be less than the rate of fire:
Code:class'SingleFire'.default.RecoilRate = 0.07;
- Maximum vertical recoil angle:
Code:class'SingleFire'.default.MaxVerticalRecoilAngle = 300;
- Maximum horizontal recoil angle. This is generally less than the vertical recoil:
Code:class'SingleFire'.default.MaxHorizontalRecoilAngle = 50;
Accuracy
A couple of spread variables are used to affect the accuracy of the weapon. Generally since Killing Floor doesn't have crosshairs, the initial spread value is low in order to make at least the first shot very accurate:
- Spread base value. This is how much initial spread is applied when the weapon starts firing:
Code:class'SingleFire'.default.Spread = 0.015;
- Maximum spread. This affects the limit that the spread can reach. After each consecutive shot within 0.5 seconds this value divided by six is added to the current spread value, meaning within 6 shots (if they all have less than a half-second gap between each other) you will reach the maximum spread:
Code:class'SingleFire'.default.MaxSpread = 0.12;
This value is not modified on a per-weapon basis (it is in fact only set in a base class), and applies to all weapons (however some weapons may calculate their own spread, ignoring this value).
Aiming
Any weapon can have the ability to zoom (ironsights or scope), and these variables affect the intensity (and whether the weapon can zoom):
- Whether the weapon (or other item, such as binoculars) has zooming capability.
Code:class'Single'.default.bHasAimingMode = true;
- How the weapon appears while not zoomed in. This affects how much of the weapon (and attached arms) is in view, and consequently affects the apparent size of the weapon. It is defined as an angle describing the field-of-view of the weapon. A higher value results in the weapon being displayed further from the camera, and thus more of the model will be shown.
Code:class'Single'.StandardDisplayFOV = 70.0;
- Intensity of the zoom effect (how far it zooms). Again, defined as a FOV angle. A lower value results in a higher magnification zoom.
Code:class'Single'.ZoomedDisplayFOV = 65.0;
- How the weapon appears when zoomed in. Again, defined as a FOV angle. Usually it's best to have this at least slightly higher than the original view angle, meaning the weapon won't take up as much room on the screen, making it easier to aim.
Code:class'Single'.PlayerIronSightFOV = 75.0;
Ammunition
Several ammunition variables are used to specify:
- Maximum ammo for the weapon.
Code:class'SingleAmmo'.default.MaxAmmo = 240;
- Initial ammo when the weapon is spawned or purchased.
Code:class'SingleAmmo'.default.InitialAmount = 120;
- How much ammo the weapon gains when you pick up a generic ammo container.
Code:class'SingleAmmo'.default.AmmoPickupAmount = 30;
- How much ammo the weapon gains when you pick up a specific ammo container (9mm rounds for example)
Code:class'SingleAmmoPickup'.default.AmmoAmount = 20;
Pickup Message
This message appears when you pick up this weapon:
Code:
class'SinglePickup'.default.PickupMessage = "You got the 9mm handgun";
Trader
Here are the important variables used by the shop (trader):
- Amount of cash required to purchase this weapon (required weapons usually have no cost).
Code:class'SinglePickup'.default.Cost = 0;
- Cost for an ammo clip.
Code:class'SinglePickup'.default.AmmoCost = 10;
- Size of a purchased ammo clip.
Code:class'SinglePickup'.default.BuyClipSize = 30;
Additionally there are three variables to control the displayed statistics, with a maximum value of 100:
- Power value - how much damage the weapon deals.
Code:class'SinglePickup'.default.PowerValue = 20;
- Speed value - how often the weapon can fire.
Code:class'SinglePickup'.default.SpeedValue = 50;
- Range value - the effective range of the weapon.
Code:class'SinglePickup'.default.RangeValue = 35;
Inventory Information
While these are not the most important variables to change when modifying existing weapons, I've included them here nonetheless:
- An inventory item's group determines which set of items it will appear in. A group value of 1 will put the item with the melee weapons, while a group value of 2 will put it with pistols, and so on.
Code:class'Single'.default.InventoryGroup = 2;
- In order to control where in the group the inventory item appears (and thus the order of items when cycling through them) you can simply set a variable to indicate the offset.
Code:class'Single'.default.GroupOffset = 1;
- Weapon priority determines whether a weapon will be switched to when picked up. If you pick up a weapon with a higher priority than the current weapon, it will be equiped. Additionally, this controls which weapon will be first equiped when you pick a new weapon group (for example, if you have your knife equiped and you switch to the pistols category, it will pick the weapon with the highest priority - the deagle if you have it).
Code:class'Single'.default.Priority = 3;
- Weight. Standard equipment such as the knife, 9mm, syringe, and welder usually has a weight of zero.
Code:class'Single'.default.Weight = 0;
- Whether or not the item cannot be dropped or sold (true means it cannot, false means it can). All standard equipment sets this to true:
Code:class'Single'.default.bKFNeverThrow = true;
Last edited: