| Home Page | Recent Changes

RegularEngine/RegularBot

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'
}

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In