How to replace KFHumanPawn with 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/

Phada

FNG / Fresh Meat
Aug 24, 2010
190
62
0
France
phada.2ya.com
Is there a clean way to replace the default KFHumanPawn class with a mutator?
I've tried to change Level.Game.DefaultPlayerClassName, this doesn't seems to work.
The value is correctly applied but still spawning with KFHumanPawn.
 

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,459
2,502
0
Canada
in KFPlayerController, there's a function that sets the pawn class to KFHumanPawn, maybe overriding that function with a new controller class extending KFPlayerController you can get it to work.
 

Phada

FNG / Fresh Meat
Aug 24, 2010
190
62
0
France
phada.2ya.com
Thanks I didn't notice that the SetPawnClass is overrided in KFPlayerController that's why DefaultPlayerClassName doesn't works.
Damn it, I don't even wanted to modify pawn to keep compatibility, and now I will have to modify controller to do that.
I must fix my mod to make it work correctly online without using any custom pawn and controller >__<
 

Phada

FNG / Fresh Meat
Aug 24, 2010
190
62
0
France
phada.2ya.com
I post a simple solution if someone having trouble to change pawn:

1) in mutator:

Code:
class MyMutator extends Mutator;

function PostBeginPlay() {
    level.Game.PlayerControllerClass = class'MyPackage.MyPlayerController';
    level.Game.PlayerControllerClassName = "MyPackage.MyPlayerController"; // just in case
}
2) in my player controller, override setpawnclass as YoYoBatty said (Level.Game.DefaultPlayerClassName to change directly the pawn is obsolete in this game because of KFPlayerController):

Code:
class MyPlayerController extends KFPlayerController;

function SetPawnClass(string inClass, string inCharacter) {
    PawnClass = Class'MyPackage.MyPawn'; // your pawn class here
    inCharacter = Class'KFGameType'.Static.GetValidCharacter(inCharacter);
    PawnSetupRecord = class'xUtil'.static.FindPlayerRecord(inCharacter);
    PlayerReplicationInfo.SetCharacterName(inCharacter);
}
I don't recommend to change the pawn or controller without a really good reason, this will break the compatibility with other mutators that doing the same.