Eliot's Forum

Full Version: Scripting Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Eliot! Big fan of your work!

I just had a simple (but hard for me) uscripting question.

I'm trying to make a very small mutator that backs up the ultra best times mutator when playing trial maps.

Currently there is no code to change the Auto Balance Teams Boolean when it's a trial map vs. a standard assault map. I did create a mutator which fixes this problem. But it simple looks at the map name to see if it has the word "Trial" or for those mappers that misspelled "Trail" and configures the game accordingly. However I noticed that ultra best times can determine if its an assault map or trial map without the same method. I've been scanning the source code back and forth for days and I can't figure out how it's doing this.

Heres what I have and it works great unless the map name doesnt have "trial" in it.

Quote:class DexsTRModv1 extends Mutator;

var bool bTrialGame;
var string mapname;

function PostBeginPlay()
{
Local string mapname;

Super.PostBeginPlay();

mapname = caps(string(Level));

if ( InStr(mapname,"TRAIL") != -1 || InStr(mapname,"TRIAL") != -1 )
{
TeamGame(Level.Game).bPlayersBalanceTeams = false;
ASGameInfo(Level.Game).RoundTimeLimit = 100;
bTrialGame = true;
}
else
{
bTrialGame = false;
TeamGame(Level.Game).bPlayersBalanceTeams = true;
}
}

function ModifyPlayer(Pawn Obj)
{
if (bTrialGame)
{
Obj.SetCollision(true, false, false);
}
}

Also one more thing is ultra best times overrides my ASGameInfo(Level.Game).RoundTimeLimit = 100; I know this because it resets the time limit in the MatchStarting function. I didn't know if I can override this setting if ultra best times is initiated after my mutator.

Any help would be appreciated. Thanks in advance!
Actually, BTimes does not really care if it's a trial map or not, it will activate on any map where it's enabled.

Although the latest BTimes does have some checks to see if it's Solo, Regular or Group trials, here's the code:

Code:
static function bool DetectMode( MutBestTimes M )
{
    return super.DetectMode( M ) && (M.GroupManager != none || IsGroup( M.CurrentMapName ));
}

static function bool IsGroup( string mapName )
{
    return Left( Mid( mapName, 3 ), 5 ) ~= default.ModeName || Left( mapName, 3 ) ~= default.ModePrefix;
}

As you see in DetectMode it checks for super which is Solo if that's true, check for the following if a GroupManager actor exists or if the map has a prefix of either AS-Group or GTR-.

Code:
static function bool DetectMode( MutBestTimes M )
{
    // Not solo then were obviously a team mode
    return !Class'BTServer_SoloMode'.static.DetectMode( M );
}

This code tests if the map is for Regular trials by checking if it's not solo.

Code:
static function bool DetectMode( MutBestTimes M )
{
    return M.Objectives.Length == 1;
}

This code tests if the map is solo by the amount of objectives, the name does not matter at all.

To override BTimes timelimit, just override the MatchStarting() event in your mutator, then followed by calling SetTimer and overriding the event Timer() and change the time there.
Well I wound up renaming all the trial map prefixes with TR and creating a new map voting group. Seems to work ok but still having trouble overriding best times round time limit.

I tried with a timer, but still doesn't work. Works for like 1 second then it goes to 0.....

Any suggestions?

Code:
// MutDexsTRMod.
//=============================================================================
class MutDexsTRMod extends Mutator;

var() config bool bEnabled; // Whether all of this is pointless
var() config bool bNoPlayerCollisions; // If players can walk through each other
var() config int iRoundTimeLimit; // Time in minutes, 0 = Infinite

function PostBeginPlay()
{
    super.PostBeginPlay();
    if (bEnabled)
    {
        Log("Initializing Dex Trial Handler Configurations For Trial Map Selected... ");
        TeamGame(Level.Game).bPlayersBalanceTeams = false;
        ASGameInfo(Level.Game).RoundTimeLimit = iRoundTimeLimit;
    }
    else
    {
        Log("Dex Trial Handler has been disabled. Defaulting normal Assault settings. Re-enable in system INI.");
        return;
    }
}

function ModifyPlayer(Pawn Obj)
{
    super.ModifyPlayer(Obj);
    if (bNoPlayerCollisions)
    {
        Obj.SetCollision(true, false, false);
    }
}

function Reset()
{
    if (ASGameInfo(Level.Game).CurrentRound > 1)
    {
        SetTimer(10,false);
    }
}

// Assuming Best Time will override roundlimit, a little work around to that...
function MatchStarting()
{
    SetTimer(10,false);
}

function Timer()
{
    ASGameInfo(Level.Game).RoundTimeLimit = iRoundTimeLimit;
}

function GetServerDetails(out GameInfo.ServerResponseLine ServerState)
{
    super.GetServerDetails( ServerState );
    Level.Game.AddServerDetail( ServerState, "Trial Handler Enabled",  bEnabled);
}
I see what you did wrong there now Big Grin

You should edit the RoundTimeLimit from the GameReplicationInfo instance, not the GameInfo instance.

e.g.
Code:
ASGameReplicationInfo(Level.Game.GameReplicationInfo).RoundTimeLimit = iRoundTimeLimit;
Awsome, that does change the time. But I'm having trouble with the timer.

Apparently if I make the function Timer() it runs without SetTimer()

If I set the timer, I loose the ability to chat (text) in the game after a certain amount of time or inputted characters.

Also if I try to make a function with a different name and call it from the timer example SetTimer(1.0,false,'somefunction');

I get a compile error Error, Call to 'SetTimer': Bad ',' or missing ')'

Code:
class DexTRHandler extends ASGameInfo;

var() config bool bEnabled; // Whether all of this is pointless
var() config bool bNoPlayerCollisions; // If players can walk through each other
var() config int iRoundTimeLimit; // Time in seconds, 0 = Infinite


Function GetServerInfo( out ServerResponseLine ServerState )
{
    Super.GetServerInfo(ServerState);
    ServerState.GameType = "ASGameInfo";
    AddServerDetail( ServerState, "Trial Handler",  bEnabled );
}

Function PostBeginPlay()
{
    local int iConvSecMin;

    Super.PostBeginPlay();
    if ( bEnabled )
    {
        iConVSecMin = iRoundTimeLimit / 60;
        iConVSecMin = int(iConvSecMin + 0.5);

        Log("Initializing Dex Trial Handler Configurations For Trial Map Selected... ");
        TeamGame(Level.Game).bPlayersBalanceTeams = false;
        ASGameInfo(Level.Game).RoundTimeLimit = iConvSecMin;

//        ASGameInfo(Level.Game).RoundTimeLimit = iRoundTimeLimit;
    }
    else
    {
        Log("Dex Trial Handler has been disabled. Defaulting normal Assault settings. Re-enable in system INI.");
        return;
    }

    

}

Function Reset()
{
    if ( ASGameInfo(Level.Game).CurrentRound > 1 )
    {
        SetTimer(3,false);
    }

}


Function MatchStarting()
{

    Super.MatchStarting();
    SetTimer(3,false);
    if( !ASGameInfo(Level.Game).IsPracticeRound() )
    {
        ASGameReplicationInfo(Level.Game.GameReplicationInfo).RoundTimeLimit = iRoundTimeLimit;
    }

}

function Timer()
{

    if( !ASGameInfo(Level.Game).IsPracticeRound() )
    {
        Log("**** NOT PRACTICE ROUND **** Setting new round time limit...");
        ASGameReplicationInfo(Level.Game.GameReplicationInfo).RoundTimeLimit = iRoundTimeLimit;
        SetTimer(0,False,'SetRoundLimit');
    }
}

Function ModifyPlayer(Pawn Obj)
{
    if ( bNoPlayerCollisions )
    {
        Obj.SetCollision(true, false, false);
    }
}

Like I said this will compile, but I loose chatting ability into the after a minute or so.

Just one thing I noticed, the the value you input is seconds not minutes. So I had iRoundTimeLimit = 6000 for 100 minutes of game play. But none to matter.

Now if I can only get the map voter to work properly. I'd be golden. I posted a thread HERE
Ok well I noticed some incorrect things you are doing in your script.

1. ASGameInfo(Level.Game) is unnecessary because you are the Game instance. Just remove the whole thing.

2. ASGameInfo doesn't use the Reset event, take a look at the original code.

3. Don't use a Timer in your GameInfo, the timer is used by the original code, yours will overwrite this and break functionality!

4. ModifyPlayer doesn't exist in the GameInfo class, there's similar one, though I can't remember its name.

You're getting the compiler error because the third parameter doesn't exist in Unreal Engine 2, that's a feature from the Unreal Engine 3.