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

USARBotAPI.BotDeathMatch


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
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
class BotDeathMatch extends DeathMatch
    config(USARBotAPI);

var class<VizServer>    VizServerClass;
var VizServer           theVizServer;
var class<BotServer>    BotServerClass;
var BotServer           theBotServer;
var bool                bServerLoaded;
var class<RemoteBotInfo> RemoteBotConfigClass;
var class<RemoteBot>    RemoteBotClass;
var RemoteBotInfo       RemoteBotConfig;
var int                 NumRemoteBots;
var ComServer           theComServer;
var class<ComServer>    ComServerClass;


function PostBeginPlay()
{
    Super.PostBeginPlay();

    if(!bServerLoaded)
    {
        theVizServer = spawn(VizServerClass, self);
        theVizServer.gameClass = "BotDeathMatch";
        
        theBotServer = spawn(BotServerClass);
        theBotServer.gameClass = "BotDeathMatch";
        
        theComServer = spawn(ComServerClass,self);
        theComServer.gameClass = "BotDeathMatch";
        
        bServerLoaded = true;
    }
    RemoteBotConfig = spawn(RemoteBotConfigClass);
}

function RemoteBot AddRemoteBot(BotConnection theConnection, string clientName, int teamNum, vector startLocation, rotator startRotation, string className)
{
    local RemoteBot NewBot;
    local NavigationPoint startSpot;

    startSpot = FindPlayerStart(NewBot);

    newBot = Spawn(RemoteBotClass, self, ,startLocation, startRotation);

    newBot.bIsPlayer = true;
    newBot.bHidden = false;
    if ( NewBot != None ) {
        NewBot.myConnection = theConnection;
        NewBot.as = theConnection.as;
        NewBot.ae = theConnection.ae;
        NewBot.ib = theConnection.ib;
        NewBot.PlayerReplicationInfo.PlayerID = CurrentID++;
        NumRemoteBots++;
        NumPlayers++;
        if(clientName == "") {
            newBot.PlayerReplicationInfo.PlayerName = "Unnamed_Bot_" $ NumRemoteBots;
        } else {
            newBot.PlayerReplicationInfo.PlayerName = clientName;
        }

        if(className != "") {
            newBot.PawnClass = class<Pawn>(DynamicLoadObject(className, class'Class'));
        } else if(newBot.PawnClass == None) {
            log("newBot.PawnClass is None");
            newBot.PawnClass = class<Pawn>(DynamicLoadObject("xGame.xPawn", class'Class'));
        }

        SpawnPlayer(newBot, startLocation, startRotation);
    } else {
        log("NewBot was none");
    }

    return NewBot;
}

function SpawnPlayer(RemoteBot newBot, optional vector startLocation, optional rotator startRotation) {
    local NavigationPoint startSpot;

    if(NewBot == None) {
        log("NewBot was none");
        return;
    }
    if(NewBot.Pawn != None) {
        log("Already had pawn");
        return;
    }

    startSpot = FindPlayerStart(NewBot);

    if(startLocation == vect(0,0,0)) {
        NewBot.Pawn = Spawn(GetDefaultPlayerClass(NewBot),,,StartSpot.Location,StartSpot.Rotation);
    } else {
        NewBot.Pawn = Spawn(NewBot.PawnClass,,,startLocation,startRotation);
    }
    log("PawnClass: "$NewBot.PawnClass);

    if ( NewBot.Pawn == None )
    {
        log("Couldn't spawn player of type "$NewBot.PawnClass$" at "$StartSpot);
        return;
    } else {
        log("Spawned player of type "$NewBot.PawnClass$" at "$StartSpot);
    }

    NewBot.Pawn.Anchor = startSpot;
    NewBot.Pawn.LastStartSpot = PlayerStart(startSpot);
    NewBot.Pawn.LastStartTime = Level.TimeSeconds;
    NewBot.PreviousPawnClass = NewBot.Pawn.Class;

    NewBot.Possess(NewBot.Pawn);
    NewBot.PawnClass = NewBot.Pawn.Class;

    NewBot.Squad = spawn(DeathMatch(Level.Game).DMSquadClass);
    if(NewBot.Squad == None) log("NewBot.Squad == None");

    NewBot.Pawn.PlayTeleportEffect(true, true);
    //	NewBot.ClientSetRotation(NewBot.Pawn.Rotation);
    AddDefaultInventory(NewBot.Pawn);
    TriggerEvent( StartSpot.Event, StartSpot, NewBot.Pawn );
    BroadcastLocalizedMessage(GameMessageClass, 1, NewBot.PlayerReplicationInfo);
    NewBot.GotoState('StartUp', 'Begin');
}

function string GetGameStatus()
{
    local string ib, as, ae;
    local string outStr;
    local Controller P;
    
    ib = theBotServer.ib;
    as = theBotServer.as;
    ae = theBotServer.ae;
    
    outStr = "GAM";
            
    outStr = ( outStr $ib$as$ "PlayerScores" );
    for ( P=Level.ControllerList; P!=None; P=P.NextController )
    {
        if( !P.PlayerReplicationInfo.bIsSpectator )
            outStr = ( outStr $ib$as$ P $ib$ P.PlayerReplicationInfo.Score $ae );
    }
    
    outStr = ( outStr $ae );                
                    
    return outStr;
}

function string GetGameInfo()
{
    local string ib, as, ae;
    local string outStr;
    
    ib = theBotServer.ib;
    as = theBotServer.as;
    ae = theBotServer.ae;
    
    //outStr = (ib$as$ "FragLimit" $ib$ $ae$ib$as$ "TimeLimit" $ib$ $ae);	
    outStr = (ib$as$ "TimeLimit" $ib$ TimeLimit $ae);   
                    
    return outStr;
}

function RestartPlayer( Controller aPlayer )
{
    if(aPlayer.IsA('RemoteBot')) {
        if(aPlayer.IsInState('Dying')) {
            log("BOTRESTRTPLAYER"@aPlayer);
            SpawnPlayer(RemoteBot(aPlayer));    
        }
    } else if (aPlayer.IsA('Player')){
        log("RESTARTPLAYER"@aPlayer);
        Super.RestartPlayer(aPlayer);
    }
}

function Killed( Controller Killer, Controller Killed, Pawn KilledPawn, class<DamageType> damageType )
{
    local string ib, as, ae;
    
    ib = theBotServer.ib;
    as = theBotServer.as;
    ae = theBotServer.ae;

    Killer.PlayerReplicationInfo.Score += 1.0;

    if(!Killed.IsA('RemoteBot')) {
        Super.Killed(Killer, Killed, KilledPawn, damageType);
    } else  if(Killed != None) 
        RemoteBot(Killed).myConnection.SendLine("DIE" $ib$as$ "Killer" $ib$ Killer $ae$ib$as$
                            "DamageType" $ib$ damageType $ae);
}

defaultproperties
{
     BotServerClass=USARBotAPI.BotServer
     VizServerClass=USARBotAPI.VizServer
     ComServerClass=USARBotAPI.ComServer
     RemoteBotConfigClass=USARBotAPI.RemoteBotInfo
     RemoteBotClass=USARBotAPI.RemoteBot;    
     NetWait=0
     CountDown=0
     DefaultEnemyRosterClass="XGame.xDMRoster"
     bPauseable=True
     AutoAim=0.930000
     GameSpeed=1.500000
     MaxPlayers=16
     GameName="Remote Bot DeathMatch"
     PlayerControllerClassName="USARBotAPI.ViewTestPlayerController"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 26.12.2006 23:18:16.000 - Creation time: Mo 16.4.2007 11:20:45.031 - Created with UnCodeX