UE2 - UT2kX Setting to change playerController used in mod

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

LTC3869

New Member
Jan 23, 2008
10
0
0
Hi, Is there a setting I can change somewhere to say what PlayerController should be used in my mod?
Thanks
 

LTC3869

New Member
Jan 23, 2008
10
0
0
Hi, Can you explain how/where I can use that? Doesn't that only work if a level is loaded? I'm using that variable currently in my mutator but the hud is not picking up the new PC.
I want to set it to myPlayerController class before a map is loaded. I tried setting it under engine.gameinfo in default.ini but it not working. Thanks
 
Last edited:

eblade

New Member
Jan 29, 2006
113
0
0
There is always alevel loaded, if you want to change the controller, you want to make a new Gametype, and not do it from a Mutator. default.ini is not the INI file that the game uses, it's ut2004.ini for ut04.
 

meowcat

take a chance
Jun 7, 2001
803
3
18
You can change the playercontroller from a mutator, its just not usually a good idea as it can break compatibility with other mutators. Here is how it can be done though (if needed):
Code:
// add this function to your mutator
function BeginPlay(){
    if(Level.Game !=None){
	    Level.Game.PlayerControllerClass = class'yourCustomPlayerController';//add your player class name there
    }
    Super.BeginPlay();
}
 

LTC3869

New Member
Jan 23, 2008
10
0
0
Hi,
I'm already using the same kind of code in my mutator to replace the playerController. I'm getting lots of warnings in the log to do with the hud not being able to find the PC when I replace it. I'm not sure how to fix that though.

It's saying:
Warning: HudCDeathmatch DM-1on1-Albatross.HudCDeathmatch (Function XInterface.HudCDeathmatch.DrawSpectatingHud:029C) Accessed None 'Owner'
Warning: HudCDeathmatch DM-1on1-Albatross.HudCDeathmatch (Function XInterface.HudCDeathmatch.GetInfoString:00BC) Accessed None 'PlayerOwner'

About the Default.ini. I got all the settings I want to change in their and it merged with ut2004.ini to make myMod.ini when mod is loaded. I tried setting the player controller in there under engine.gameinfo but it doesn't use it.
Thanks
 

eblade

New Member
Jan 29, 2006
113
0
0
well, yes, you can change the playercontroller default from the mutator, but it's probably not a good idea, etc. :D
 

LTC3869

New Member
Jan 23, 2008
10
0
0
Code:
function BeginPlay(){
log("reached begin play function");
    if(Level.Game !=None){
ReplacePawnAndPC();
    }
    Super.BeginPlay();
}

function ReplacePawnAndPC() {
//replace pawn
    if(Level.Game.DefaultPlayerClassName~="xGame.xPawn") {
        Level.Game.DefaultPlayerClassName="AUTCore.xPawn_AUT";
log("pawn replaced and it is " $Level.Game.DefaultPlayerClassName);
}

//replace the bot class
    if(class'xPawn'.default.ControllerClass==class'XGame.XBot') {
        class'xPawn'.default.ControllerClass=class'AUTCore.xBot_AUT';
log("xBot replaced and it is " $class'xPawn'.default.ControllerClass);
}

//now replace the PlayerController
Level.Game.PlayerControllerClass = class'AUTCore.xPlayer_AUT';
Level.Game.PlayerControllerClassName = string(Level.Game.PlayerControllerClass);
log("player controller replaced and it is "$Level.Game.PlayerControllerClassName);
}
 

Czin

Ron Paul 2008
Feb 4, 2008
6
0
0
40
Melbourne, FL
When I had to do this in my 2k4 mod I just changed the information in the defaultproperties of the gametype. It didn't give me any hassle but I would assume the way you are doing it should work aswell. The only problem I might guess at is the old PC getting initialized before your new one takes effect though I haven't tested that to see if its true.

To change those classes with a gametype just add this information to the defaultproperties.


Code:
defaultproperties
{
	PlayerControllerClassName="MyPackage.MyPlayerController"
	BotControllerClass=class'MyBot'
	DefaultPlayerClassName="MyPackage.MyPawn"
}

Use this same method to force the game to use your own PRI, GRI, HUD, and scoreboard classes.
 
Last edited:

LTC3869

New Member
Jan 23, 2008
10
0
0
Hi, Yes that is what is happening. The old PC is being initialised then I'm replacing it with my own PC and the hud/scoreboard can no longer find the old PC.
I don't want to have to create my own gametype. I'd like the mutator to work with the existing game types.
This is part of a project I was working on 2 years back. I'm blind so I was trying to see if I could make the game playable for blind players. My programming skills aren't too good so I got a bit stuck. I'd like to fix this error with the hud/scoreboard and then upload it so if anyone else wants to work on it they can.
 
Last edited:

Czin

Ron Paul 2008
Feb 4, 2008
6
0
0
40
Melbourne, FL
hmm.. I was able to change the classtype of a flag on a flag base before the game started via mutator's CheckReplacement so that it initialized my flag class instead of the default one. It seems unlikely that you may access the gameinfo before it initializes itself since I believe gameinfo is the first actor to be created. That said gameinfo is an actor and mutator claims in its comments to be able to check any actor so try it anyway! ^^


I don't have ut2k4 installed but in UT3 "utgame" is the class that chooses the playercontroller. If ut2k4 is different replace below.
function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
if (Other.IsA('UTGame'))
{
Log("CheckReplacement(): ZOMG!");
UTGame(Other).PlayerControllerClassName="MyPackage.MyPlayerController";
}
return true; // true? false? I don't know
}

Even if this doesn't work I think duplicating each gametype might not be a bad solution. Your audience seems like they might be willing to deal with having duplicate gametypes. I don't think it would require anything more then "class MyDeathmatch extends UTDeathmatch" or whatever and changing the default properties. The gametype should function normally, assuming your changes to playercontroller are not destructive.
 

LTC3869

New Member
Jan 23, 2008
10
0
0
How do I make a custom game type appear in the list of available game types? and are there any tutorials on this topic?
Thanks