Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UT2k4Assault.ASGameReplicationInfo


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
//=============================================================================
// ASGameReplicationInfo.
//=============================================================================

class ASGameReplicationInfo extends GameReplicationInfo;

var int     RoundTimeLimit;     // in seconds, unlike ASGameInfo.RoundTimeLimit which is in minutes
var int     RoundStartTime, CurrentRound, MaxRounds, ReinforcementCountDown, PracticeTimeLimit;
var bool    bTeamZeroIsAttacking;                   // true when Red Team is Attacking
var int     RoundOverTime;  // time set when round is over (so all clients show the same time)
var int     MaxTeleportTime;

// Objective Progress
// Shown on HUD, and on briefing screen...
var byte    ObjectiveProgress, MaxObjectivePriority;

var GameObjective   Objectives;
var GameObject      GameObject;

enum ERoundWinner
{
    ERW_None,
    ERW_PracticeRoundEnded,
    ERW_RedAttacked,
    ERW_BlueAttacked,
    ERW_RedDefended,
    ERW_BlueDefended,
    ERW_RedMoreObjectives,
    ERW_BlueMoreObjectives,
    ERW_RedMoreProgress,
    ERW_BlueMoreProgress,
    ERW_RedGotSameOBJFaster,
    ERW_BlueGotSameOBJFaster,
    ERW_Draw,
};

var ERoundWinner RoundWinner;

var localized String ERW_PracticeRoundEndedStr, ERW_RedAttackedStr, ERW_BlueAttackedStr, ERW_RedDefendedStr, ERW_BlueDefendedStr;
var localized String ERW_DefendersStr, ERW_AttackersStr, ERW_RedMoreObjectivesStr, ERW_BlueMoreObjectivesStr; 
var localized String ERW_RedMoreProgressStr, ERW_BlueMoreProgressStr, ERW_RedGotSameOBJFasterStr, ERW_BlueGotSameOBJFasterStr;
var localized String ERW_DrawStr;

replication
{
    reliable if ( bNetDirty && (Role == ROLE_Authority) )
        RoundStartTime, CurrentRound, bTeamZeroIsAttacking, ObjectiveProgress,
        ReinforcementCountDown, RoundWinner, GameObject, RoundTimeLimit, RoundOverTime;

    reliable if ( bNetInitial && (Role==ROLE_Authority) )
        MaxRounds; 
}

simulated function PreBeginPlay()
{
    super.PreBeginPlay();
    SecondCount = Level.TimeSeconds;
    SetTimer(1, true);
}

simulated function PostNetBeginPlay()
{
    super.PostNetBeginPlay();
    SetupAssaultObjectivePriority();
}

/*
Converts default objective DefensePriority ordering (downwards)
to ordered upwards (without gaps) for easier handling
0 is the first objective, 1 the second and so on...
*/
simulated function SetupAssaultObjectivePriority()
{
    local GameObjective         GO, BestGO, NextBestGO;
    local byte                  CurrentPriority;

    log("## ASGRI::SetupAssaultObjectivePriority");

    // Caching GameObjectives
    foreach AllActors(class'GameObjective', GO)
    {
        if ( GO.bBotOnlyObjective ) // ignore bot only objectives
        {
            GO.ObjectivePriority = 255;
            continue;
        }
        if ( BestGO == None || GO.DefensePriority > BestGO.DefensePriority )
            BestGO = GO;
    }

    if ( BestGO == None )
        return;

    // Building Assault Priority Order...
    do
    {
        NextBestGO = None;
        foreach AllActors(class'GameObjective', GO)
        {   
            if ( GO.bBotOnlyObjective ) // ignore bot only objectives
                continue;

            // Current Assault Priority: Assign
            if ( GO.DefensePriority == BestGO.DefensePriority )
            {
                log( "  Assault Priority:" @ CurrentPriority @ "DefensePriority:" @ GO.DefensePriority 
                    @ "Info:" @ GO.Objective_Info_Attacker @ "Destruction:" @ GO.DestructionMessage );
                GO.ObjectivePriority = CurrentPriority;
            }
            else if ( (GO.DefensePriority < BestGO.DefensePriority)
                && ( NextBestGO == None || GO.DefensePriority > NextBestGO.DefensePriority ) )
            {
                NextBestGO = GO;    // Next Assault priority ( for next cycle )
            }
        }
        
        BestGO = NextBestGO;
        CurrentPriority++;
    }
    until ( NextBestGO == None )

    MaxObjectivePriority = CurrentPriority - 1;
}


simulated function Timer()
{
    if ( Level.NetMode != NM_DedicatedServer )
    {
        if ( Level.TimeSeconds - SecondCount >= Level.TimeDilation )
        {
            if ( ReinforcementCountDown > 0 ) // Reinforcements countdown..
                ReinforcementCountDown--;
        }
    }
    super.Timer();
}

/* round 0 is either practice round (in network) or intro cinematic (standalone only) */
simulated function bool IsPracticeRound()
{
    return ( CurrentRound == 0 );
}

simulated function bool IsDefender( byte Team )
{
    return ( Team == byte(bTeamZeroIsAttacking) );
}

simulated function String   GetRoundWinnerString()
{
    switch ( RoundWinner )
    {
        case ERW_None                       : return "";
        case ERW_PracticeRoundEnded         : return ERW_PracticeRoundEndedStr;
        case ERW_RedAttacked                : return ERW_RedAttackedStr;
        case ERW_BlueAttacked               : return ERW_BlueAttackedStr;
        case ERW_RedDefended                : return ERW_RedDefendedStr;
        case ERW_BlueDefended               : return ERW_BlueDefendedStr;
        case ERW_RedMoreObjectives          : return ERW_RedMoreObjectivesStr;
        case ERW_BlueMoreObjectives         : return ERW_BlueMoreObjectivesStr;
        case ERW_RedMoreProgress            : return ERW_RedMoreProgressStr;
        case ERW_BlueMoreProgress           : return ERW_BlueMoreProgressStr;
        case ERW_RedGotSameOBJFaster        : return ERW_RedGotSameOBJFasterStr;
        case ERW_BlueGotSameOBJFaster       : return ERW_BlueGotSameOBJFasterStr;
        case ERW_Draw                       : return ERW_DrawStr;
    }
}

defaultproperties
{
     MaxTeleportTime=7
     ERW_PracticeRoundEndedStr="Practice round over. Get ready!"
     ERW_RedAttackedStr="Red team successfully attacked!"
     ERW_BlueAttackedStr="Blue team successfully attacked!"
     ERW_RedDefendedStr="Red team successfully defended!"
     ERW_BlueDefendedStr="Blue team successfully defended!"
     ERW_RedMoreObjectivesStr="Red team scored (more objectives)."
     ERW_BlueMoreObjectivesStr="Blue team scored (more objectives)."
     ERW_RedMoreProgressStr="Red team scored (closer to completion)."
     ERW_BlueMoreProgressStr="Blue team scored (closer to completion)."
     ERW_RedGotSameOBJFasterStr="Red team scored (fastest)."
     ERW_BlueGotSameOBJFasterStr="Blue team scored (fastest)."
     ERW_DrawStr="Draw game."
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Tue 24/10/2006 17:00:14.000 - Creation time: Wed 7/2/2007 19:16:33.937 - Created with UnCodeX