Legacy:RegularEngine/RegularBot - Unreal Wiki

# Legacy:RegularEngine/RegularBot

### From Unreal Wiki, The Unreal Engine Documentation Site

< Legacy:RegularEngine

RegularBot is the Bot Controller class. It's very simple, just a couple functions to handle the creation of the classes the bot will randomly choose.

UT2004 :: xBot >> RegularBot

    class RegularBot extends xBot;

    function Possess( Pawn aPawn )  //same as RgPlayer, just setup the pawn correctly from the PRI
    {
        local RegularPawn rp;

        rp = RegularPawn(aPawn);

        if (rp != none) {rp.PlayerClassName = RegularPRI(PlayerReplicationInfo).PlayerClassName;}

        Super.Possess( aPawn );
    }

    function SetPawnClass(string inClass, string inCharacter)
    {
        PawnSetupRecord = class'xUtil'.static.FindPlayerRecord(inCharacter);
        PlayerReplicationInfo.SetCharacterName(PawnSetupRecord.DefaultName);
    }

    // this looks complicated and messy, I know ... but it's really not.
    // basically it just gets a list of available classes based on team
    // and then picks the first one, and randomly selects the next one.
    // Keeps bots from only picking a few classes.

    function ChoosePlayerClass() {
            local int i;
            if(RegularPRI(PlayerReplicationInfo) != none) {
               for(i=0;i<RegularPRI(PlayerReplicationInfo).MaxClassNumber;i++) {
                   if(RegularPRI(PlayerReplicationInfo).PlayerClasses[i].TeamIndex == RegularPRI(PlayerReplicationInfo).Team.TeamIndex ||
                      RegularPRI(PlayerReplicationInfo).PlayerClasses[i].TeamIndex == 255 ) {
                                                                                            RegularPRI(PlayerReplicationInfo).PlayerClassName = RegularPRI(PlayerReplicationInfo).PlayerClasses[i].ClassTitle;

    if(Rand(10) > 5) {break;}
                                                                                            }
               }
            }

    }

    defaultproperties {
    PawnClass=class'RegularPawn'
    PlayerReplicationInfoClass=Class'RegularPRI'
    }

##### Views

- Legacy
- Discussion
- Current revision

##### Search