• 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/

Code [Tutorial] Modifying Existing Weapons

IT WAS SO EASY!! OH MY GOD!!!....

This was the problem.-

Code:
class KFAmmob extends Mutator;

simulated function PostBeginPlay()
{
	if (Level.NetMode != NM_DedicatedServer)
		class'SingleAmmo'.default.MaxAmmo = 250;
	class'SingleAmmo'.default.MaxAmmo = 250;
}

defaultproperties
{
	GroupName="KFAmmoB"
	FriendlyName="KFAmmoB"
	Description="XxXxX XxXxX XxXxX"

	RemoteRole=ROLE_SimulatedProxy
	bAlwaysRelevant=true
	bAddToServerPackages=true
}
 
Upvote 0
Nonono... But if..

Look..

Click Here..

I want to change what's in red...

For the 9mm in the SingleAmmo class is the MaxAmmo Default property.

Change that property for all your weapons.

Try opening some files up and matching up some values, MaxAmmo also having a value of 240 should of stood out like a beacon as the first thing to try.
 
Upvote 0
Can anybody help me with this simple mutator?

Code:
class M99slowerreload extends Mutator;

function PostBeginPlay()
{
    class'M99SniperRifle'.default.ReloadRate = 6.376000;
    class'M99SniperRifle'.default.ReloadAnimRate = 0,686323;
}

defaultproperties
{
    GroupName="M99slowerreload"
    FriendlyName="M99slowerreload"
    Description="M99slowerreload"

It just simply doesn't work. It compiles without issues. It works with other weapons like the 9mm pistol.
 
Upvote 0
Can anybody help me with this simple mutator?

Code:
class M99slowerreload extends Mutator;
 
function PostBeginPlay()
{
    class'M99SniperRifle'.default.ReloadRate = 6.376000;
    class'M99SniperRifle'.default.ReloadAnimRate = 0,686323;
}
 
defaultproperties
{
    GroupName="M99slowerreload"
    FriendlyName="M99slowerreload"
    Description="M99slowerreload"

It just simply doesn't work. It compiles without issues. It works with other weapons like the 9mm pistol.
What you mean it doesn't work? I can see a reason why it wouldn't show up in your mutators if that is what you mean?
 
Upvote 0
What you mean it doesn't work? I can see a reason why it wouldn't show up in your mutators if that is what you mean?

Oh, I posted the wrong script. This is the one I have compiled with.

Here:

Code:
class test extends Mutator;

function PostBeginPlay()
{
    class'M99SniperRifle'.default.ReloadRate = 6.376000;
    class'M99SniperRifle'.default.ReloadAnimRate = 0.686323;
}

defaultproperties
{
    GroupName="KFAlteredWeaponMut"
    FriendlyName="Altered Weapon Mutator"
    Description="Example mutator demonstrating how to alter existing weapons."
You have to be more specific than "it doesn't work". You mean the reload speed doesn't change? The mutator doesn't appear in-game? Your computer won't start up? Your keyboard has melted?

Sorry, I feel bad about my sloppiness. Well, it does show up in the mutator list. At the moment I am just testing it out using a listen server to keep it simpler for me until it works on that before trying with a dedicated server. I am also using ServerPeaks V6.01 with it. As I said, changing the Class 'Single' in the same way and with the same values that I am trying to use for the M99, did work. Anyhow, the reload speed and animation speed stays the same for the M99. It's not using the new overriding values.
 
Last edited:
Upvote 0
Only parameter FireRate, FireAnimRate in KFShotgunFire child classes with weapons that has 1 mag capacity - does the effect. ReloadRate isn't used when weapon has mag capacity = 1.

I see.

However, I don't comprehend what the solution is then, though. How can I use the Class 'KFShotgunFire' to achieve my goal? Could anybody give a practical example?
 
Upvote 0
You need to instead alter the M99Fire's FireRate and FireAnimRate variables, since the fire and reload animation are the same.

I see. The overrides does function now.

Okay, so here's something I am in doubt about.

If the M99's FireRate is at the standard base of '4.3760' then the FireAnimRate should be equal to '1.0', right? I mean, the FireAnimRate is always equal to '1.0' at the standard base of the FireRate, correct?

Further, I wouldn't need to tweak the FireAnimRate accordingly when I make a change to the FireRate? I mean, if the FireAnimRate is only modified by the FireRate which is then in turn only modified by the Perk levels, or?

Like, for an increase in reload time for the M99, as a example mutator:

Code:
class test extends Mutator;

function PostBeginPlay()
{
    class'M99Fire'.default.FireRate = 5.376000;
    class'M99Fire'.default.FireAnimRate = 1.0;
}

defaultproperties
{
    GroupName="KFAlteredWeaponMut"
    FriendlyName="Altered Weapon Mutator"
    Description="Example mutator demonstrating how to alter existing weapons."
I wouldn't even need to override FireAnimRate if what I am thinking is true, of course.

Else, I did find a post by poosh that said that ''ReloadAnimRate = default.ReloadRate / <new ReloadRate>;''. If those functions are actually the same, of course, I could then just do that. That'd make the new ReloadAnimRate = ~0.813988, or ~0.814000.
 
Last edited:
Upvote 0
No, the M99 HAS no reload anim. Nor does it technically reload at all. Same with the xbow.

The M99 fires and the new round being chambered is part of the fire anim.

Stop thinking about reloads.

Think rate of fire.

Right, I understand.

Still, about the relation between FireRate and FireAnimRate, how can I be sure they are in sync when I change the FireRate?
 
Last edited:
Upvote 0
They will not be in sync, think on how you can fire the Xbow before the actual animation finishes

I know that the animation rate doesn't matter technically. These weapons that has no reloading (technically) will fire anyway, even if the animation isn't played out to end.

However, It certainly does look better, makes more sense, if they are closer to being sync , look-wise, timing-wise.

The Xbow's animation rate is actually pretty much in perfect sync with its firing rate, as far as I can tell?

Anyhow,

So an example then:

If I decrease the firing rate for the M99 then the fire animation will be too fast. I will then need to slow down the fire animation to keep the original relation of the firing rate and fire animation intact.

What I need to know is how I can calculate the new animation rate that fits the new firing rate.

I am thinking that if I decrease the firing rate by 10%, I also need to decrease the animation rate by 10%, right?

10% to 4.37600 is = 4.8136

Now, I don't know what the original animation rate is, but let's say it is = '1'.

10% from 1 is = 0,9

However, the results is off. That is, that the animation rate doesn't fit like it does if I don't change the original firing rate/animation rate. So the issue could be that the animation rate isn't actually = '1', but another number. I don't know where to find this number.

Do I really not make any sense? Sorry if that is so. I don't understand why not, though. :)
 
Last edited:
Upvote 0
Benjamin, you could add this:
Code:
class'SinglePickup'.default.Weight = 1;
Adding "class'Single'.default.Weight = 1;" does indeed set the weight of 9mm to 1 and selecting it in your inventory at the trader shows "Weight: 1", but selecting it in the traders inventory still shows the default value.
So adding "class'SinglePickup'.default.Weight = 1;" shows the right value at the traders inventory. :)
 
Upvote 0
Do I really not make any sense? Sorry if that is so. I don't understand why not, though. :)
If you have firerate = 0.33 (for example) and fireanimrate = 1.00 (this variable is 1.00 mostly, this is equal to 1.00 in all official weapons), if you want to make firerate slower, if you do firerate * 1.5, you need fireanimrate / 1.5. And if you need increase firerate, you do firerate / 1.8 (80% faster) and fireanimrate * 1.8. I hope you will understand my bad english.
 
Upvote 0