• 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] Creating a Basic Mutator

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:
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0
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:
Upvote 0
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."
}
 
Upvote 0