[Tutorial] Creating a Basic Mutator

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

Colt .45 killer

Grizzled Veteran
May 19, 2006
3,997
775
113
Small Q

Im working on a small mod wanted to learn as I go. Followed the tutorial, Created a basic mutator and copied over the aa12 classes from kf mod and made some changes ( basic stuff just to get the compiling and into game process working ). Removes the old .u files just fine and compiles as well, I've added the mut to the .ini file and can access it from the list of mutators when hosting a game. However none of the changes I have made( weight and ammo in mag ) are displaying ingame..

I'm going to keep tinkering around, If anyone has any bright ideas or needs any more info to help with this problem please ask.. ;)

edit:

perhaps the equivalent of an include or an import in the mutator class to tell the mutator to include the aa12 files...?
 
Last edited:

Benjamin

Grizzled Veteran
May 17, 2009
3,650
635
113
France
Nice tutorial, but I think you shouldn't use "foreach DynamicActors" to get playerpawns:

Code:
function Timer()
{
    local Controller C;
    local KFHumanPawn Player;

    for (C = Level.ControllerList; C != None; C = C.NextController) {
        if (C.Pawn != None && KFHumanPawn(C.Pawn) != None) {
            Player = KFHumanPawn(C.Pawn);
            // stuff
        }
    }
}

Good point, although I thought I'd show something that allows general access of many types of actors. I was (or perhaps am...) planning to do a follow up which will explain accessing various types of actors the proper way. Thanks. :)

Small Q

Im working on a small mod wanted to learn as I go. Followed the tutorial, Created a basic mutator and copied over the aa12 classes from kf mod and made some changes ( basic stuff just to get the compiling and into game process working ). Removes the old .u files just fine and compiles as well, I've added the mut to the .ini file and can access it from the list of mutators when hosting a game. However none of the changes I have made( weight and ammo in mag ) are displaying ingame..

I'm going to keep tinkering around, If anyone has any bright ideas or needs any more info to help with this problem please ask.. ;)

edit:

perhaps the equivalent of an include or an import in the mutator class to tell the mutator to include the aa12 files...?

Are you actually replacing the weapon anywhere? Since simply compiling your own classes in a mutator won't actually change anything.
 

Colt .45 killer

Grizzled Veteran
May 19, 2006
3,997
775
113
No I don't think anything is getting replaced, I figured compiling it with the mutator then running the mut would run your weapon files over any standard ones.
 

Benjamin

Grizzled Veteran
May 17, 2009
3,650
635
113
France
No I don't think anything is getting replaced, I figured compiling it with the mutator then running the mut would run your weapon files over any standard ones.

If you want to add a weapon to the shop, you can do something like this (replacing the pickup class with your own):

Code:
KFGameType(Level.Game).KFLRules.ItemForSale[25] = class'KFMod.DeaglePickup';

If you want to overwrite an existing weapon in the shop check out KFLevelRules.uc to see which slot that weapon already occupies, and overwrite it.

Thanks for your tutorial!
But the Unreal Networking Architecture 's link had broken.
Hope you can fix it sooner.

Thanks for the heads up, I've updated the link.
 

FluX

Grizzled Veteran
Oct 26, 2010
5,395
234
63
www.fluxiserver.co.uk
Hi, im trying to see if I can make it so that the health regeneration is only applied to specific levels perk levels (any perk but up to level 4).

Code:
class RegenMut extends Mutator;
function PostBeginPlay()
{
 SetTimer(1, true);
}
function Timer()
{
  local KFHumanPawn Player;
  
  foreach DynamicActors(class 'KFHumanPawn', Player)
  {
   if (Player.Health + 2 <= Player.HealthMax) && (KFPRI.ClientVeteranSkillLevel <=4)
    return Player.Health += 2;
   else Player.Health = Player.HealthMax;
  }
}
defaultproperties
{
    GroupName="KFRegenMutator"
    FriendlyName="KF Health Regeneration"
    Description="Mutator that regenerates health depending on perk level."
}

For some reason it's coming up with an error saying

Code:
Error, '&&': Bad command or expression

Any help?
 

braindead

FNG / Fresh Meat
Aug 22, 2009
918
346
0
Merry Ol' England
Hey Flux, everything needs to be in brackets i.e.

Code:
   if ((Player.Health + 2 <= Player.HealthMax) && (KFPRI.ClientVeteranSkillLevel <=4)))

otherwise it doesn't see the && as a command
 

FluX

Grizzled Veteran
Oct 26, 2010
5,395
234
63
www.fluxiserver.co.uk
Hey Flux, everything needs to be in brackets i.e.

Code:
   if ( (Player.Health + 2 <= Player.HealthMax) && (KFPRI.ClientVeteranSkillLevel <=4) ))

otherwise it doesn't see the && as a command
Because that seemed like it had too many )'s at the end I tried like that before and it said the error
Code:
Error, Bad or missing expression in parenthesis
When I tried your version it still had same error.
 

braindead

FNG / Fresh Meat
Aug 22, 2009
918
346
0
Merry Ol' England
lol sorry flux, there should only be 2 closed brackets at the end

so it should be

((****) && (*****))

actually you could try the whole statement in just brackets i.e.

Code:
if ( Player.Health + 2 <= Player.HealthMax && KFPRI.ClientVeteranSkillLevel <=4 )
failing that try:

Code:
if ((Player.Health + 2) <= (Player.HealthMax) && KFPRI.ClientVeteranSkillLevel <= 4 )
 
Last edited:

FluX

Grizzled Veteran
Oct 26, 2010
5,395
234
63
www.fluxiserver.co.uk
Tried both and both come out with same error
Code:
Error, Bad or missing expression after '&&'

So far this all looks fine to me but it still wont have it.
 

FluX

Grizzled Veteran
Oct 26, 2010
5,395
234
63
www.fluxiserver.co.uk
Line 14 which was the one we're changing. Everything works with the changing but adding the bit im trying to do, it's not having it.

I think im doing it the right way but all im trying to do is make it so that the health is regenerated if the players perk is up to level 4.
 

braindead

FNG / Fresh Meat
Aug 22, 2009
918
346
0
Merry Ol' England
ok this compiled fine, you will have to try it to make sure it works

Code:
class RegenMut extends Mutator;
function PostBeginPlay()
{
 SetTimer(1, true);
}
function Timer()
{
  local KFHumanPawn Player;
      local KFPlayerReplicationInfo KFPRI;
  
  foreach DynamicActors(class 'KFHumanPawn', Player)
  {
   if (Player.Health + 2 <= Player.HealthMax && KFPRI.ClientVeteranSkillLevel <=4)
    
   (Player).Health += 2;
    
   else 
    
    Player.Health = Player.HealthMax;
    
  }
}
defaultproperties
{
    GroupName="KFRegenMutator"
    FriendlyName="KF Health Regeneration"
    Description="Mutator that regenerates health depending on perk level."
}