[Tutorial] Modifying Existing Weapons

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Benjamin

Grizzled Veteran
May 17, 2009
3,650
635
113
France
This tutorial it outdated. Please see the new version on the official wiki.

Spoiler!
 
Last edited:

Marco

Active member
May 23, 2009
644
232
43
Finland
On a note you have to be careful when editing default values. Clients may keep the modified values still after mapswitch (or server when switching between game modes).
Meaning client may get wrong fire rates/weapon names or such after connected to different server.
 

Benjamin

Grizzled Veteran
May 17, 2009
3,650
635
113
France
Thanks guys, I appreciate the comments. If I can find some time soon I'd like to write a tutorial on making weapons from scratch, but I'd need to do some more research first since I have no experience with media handling in UE.

On a note you have to be careful when editing default values. Clients may keep the modified values still after mapswitch (or server when switching between game modes).
Meaning client may get wrong fire rates/weapon names or such after connected to different server.

I hadn't thought of that, thanks. I'm not sure about the client retaining the default values, but I know for sure that after a map switch (and no doubt a game mode switch) a server still retains them after the mutator is disabled. Still, for the sake of the tutorial I think it works well since it's a clean and easy way to explain which classes contain which variables. I've modified the tutorial a little bit (including the code) to point out that the example method is for single-player.
 

justinas91

FNG / Fresh Meat
Oct 30, 2010
3
0
0
Can someone please cleare some things up
Do i have to create a mutator with this?
And could someone post an example of a moded weapon how should all the lines look?
Thankyou
 

Benjamin

Grizzled Veteran
May 17, 2009
3,650
635
113
France
Yes, it has to be created as a mutator. See the link to the tutorial on making a mutator at the top of my post.
 

RichardtheLionhart

FNG / Fresh Meat
Nov 7, 2010
13
0
0
Darn

Darn

Why doesn't this work when I put it on a server? It works fine on solo.
Great work Benjamin! This is helped me so much.
 
Last edited:

elrocker

FNG / Fresh Meat
Feb 9, 2011
22
0
0
m14ebrm

m14ebrm

I'm having problems with this, i have enter the info for a weapon (M14EBRM) which is a automatic m14. I am fairly new to coding, so i think the problem is format, or misplacement of {'s and }'s.
This is the .uc file code:
Code:
[class AlteredWeaponMut extends Mutator;
function PostBeginPlay()
{
 class'Single'.default.ItemName = "M14EBRBattleRifle";
}
weaponname
{
 class'Single'.default.ItemName = "M14EBRBattleRifle";
 class'SinglePickup'.default.Itemname = "M14EBR";
 class'SinglePickup'.default.ItemShortName = "M14EBR";
}
firetype
{
 class'SingleFire'.default.bWaitForRelease = false;
}
damage
{
 class'SingleFire'.default.DamageMax = 65;
 class'DamTypeM14EBR'.default.HeadShotDamageMult = 2.5;
}
firerate
{
 class'SingleFire'.default.FireRate = 0.175;
 class'SingleFire'.default.FireAnimRate = 2.0;
}
recoil
{
 class'SingleFire'.default.RecoilRate = 0.07;
 class'SingleFire'.default.MaxVerticalRecoilAngle = 25;
 class'SingleFire'.default.MaxHorizontalRecoilAngle = 5;
}
accuracy
{
 class'SingleFire'.default.Spread = 0.015;
 class'SingleFire'.default.MaxSpread = 0.12;
}
aiming
{
 class'Single'.default.bHasAimingMode = true;
 class'Single'.StandardDisplayFOV = 70.0;
 class'Single'.ZoomedDisplayFOV = 65.0;
 class'Single'.PlayerIronSightFOV = 75.0;
}
ammuntion
{
 class'SingleAmmo'.default.MaxAmmo = 200;
 class'SingleAmmo'.default.InitialAmount = 100;
 class'SingleAmmo'.default.AmmoPickupAmount = 40;
 class'SingleAmmoPickup'.default.AmmoAmount = 30;
}
pickupmessage
{
 class'SinglePickup'.default.PickupMessage = "You got the M14EBR";
}
trader
{
 class'SinglePickup'.default.Cost = 200;
 class'SinglePickup'.default.AmmoCost = 10;
 class'SinglePickup'.default.BuyClipSize = 30;
 class'SinglePickup'.default.PowerValue = 40;
 class'SinglePickup'.default.SpeedValue = 5;
 class'SinglePickup'.default.RangeValue = 35;
}
inventory
{
 class'Single'.default.InventoryGroup = 4;
 class'Single'.default.GroupOffset = 1;
 class'Single'.default.Priority = 3;
 class'Single'.default.Weight = 6;
 class'Single'.default.bKFNeverThrow = true;
}
defaultproperties
{
 GroupName="KFM14EBRM"
 FriendlyName="Altered Weapon Mutator"
 Description="Automatic M14EBR."
}/CODE]
My second one there may be one error in.
.bat file:
[CODE]del "C:\Program Files\Steam\steamapps\common\killingfloor\M14EBRM.u"
"C:\Program Files\Steam\steamapps\common\killingfloor\System\UCC.exe" make
del "C:\Program Files\Steam\steamapps\common\killingfloor\System\steam_appid.txt"
pause
thanks:confused:
 

Benjamin

Grizzled Veteran
May 17, 2009
3,650
635
113
France
You don't split it into sections like that, you can just put all lines in the PostBeginPlay function.

Why doesn't this work when I put it on a server? It works fine on solo.

This method works a certain way that isn't meant for online play. If you want to make weapons that work online I'd suggest subclassing existing weapons and adding them to the trader.
 
Last edited:

Scyther

FNG / Fresh Meat
Apr 13, 2011
3
0
0
This method works a certain way that isn't meant for online play. If you want to make weapons that work online I'd suggest subclassing existing weapons and adding them to the trader.

How would I go about doing this? I'm new to making mutators for KF and want to make custom weapons (or edit current ones) for online play with some friends.

(Oh and great guide, worked perfectly in SP :D)
 

Entangler

FNG / Fresh Meat
Jul 12, 2009
474
216
0
33
Sydney, Australia
The method described in the OP does in fact work for multiplayer mutators, if:

  • PostBeginPlay is declared simulated and
  • the mutator is replicated to clients (bAlwaysRelevant = true).
 

Benjamin

Grizzled Veteran
May 17, 2009
3,650
635
113
France
The method described in the OP does in fact work for multiplayer mutators, if:

  • PostBeginPlay is declared simulated and
  • the mutator is replicated to clients (bAlwaysRelevant = true).

Right, but it's not a good idea since when you run such a mutator on a server the values will stick even when the mutator is disabled, unless you manually restore them yourself.
 

Dave_Scream

FNG / Fresh Meat
Jan 24, 2010
160
12
0
35
Russia, Rostov-on-Don
vkontakte.ru
Hi.
I want to make vampire Katana for berserker.
When berserker player hit some enemy it heal himself.

from where I can start to dig?
I think the start point is KFMeleeFire -> Timer() function where HitActor.TakeDamage function calls are.
but how I can access Player healths and Player veterancy type from this section of code? how to access Owner? and how to make mutator of KFMeleeFire
----
ok. I have step 1
this function is placed in KFMeleeFire.uc -> Timer() and it deals damage to enemy
HitActor.TakeDamage(MyDamage, Instigator, HitLocation, vector(PointRot), hitDamageClass) ;

so for "Vampire" effect, after Enemy TakeDamage
I must somehow make somethink like this
if (Instigator.VeterancyType=class<'KFVetBerserker'>)
{
Instigator.GiveHealth(MyDamage*coefficient);
}

need help!)
 
Last edited: