Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 |
//=================================================================== // ROTeamAI // // Copyright (C) 2005 John "Ramm-Jaeger" Gibson // // Custom Team AI for Red Orchestra //=================================================================== class ROTeamAI extends TeamAI; //Jonathan@psyonix.com //This is called when the map is loaded and should setup all the info the team //should know about the objectives. function SetObjectiveLists() { local ROObjective O; foreach AllActors(class'ROObjective',O) { if ( O.bFirstObjective ) Objectives = O; } } /* SetBotOrders - based on RosterEntry recommendations Just calls the Super for now. Add code here if we want to change the way attack/defend/freelance squads are set up - Ramm */ function SetBotOrders(Bot NewBot, RosterEntry R) { if ( Objectives == None ) SetObjectiveLists(); // pick orders if ( Team.Size == 0 ) OrderOffset = 0; DefendHere(NewBot, GetLeastDefendedObjective()); } function bool DefendHere(Bot B, GameObjective O) { local SquadAI S; for ( S=Squads; S!=None; S=S.NextSquad ) { if(S.SquadObjective == O && (S.Size < S.MaxSquadSize)) { S.AddBot(B); return true; } } if (O.DefenderTeamIndex == Team.TeamIndex) O.DefenseSquad = AddSquadWithLeader(B, O); else AddSquadWithLeader(B, O); return true; } function bool PutOnDefense(Bot B) { local GameObjective O; O = GetLeastDefendedObjective(); if ( O != None ) { //we need this because in RO, unlike other gametypes, two defending squads (possibly from different teams!) //could be headed to the same objective if ( O.DefenseSquad == None || O.DefenseSquad.Team != Team ) { O.DefenseSquad = AddSquadWithLeader(B, O); // MergeTODO: Investigate this //ONSSquadAI(O.DefenseSquad).bDefendingSquad = true; } else O.DefenseSquad.AddBot(B); return true; } return false; } // Modified so when the round resets bots will get objectives again function FindNewObjectives(GameObjective DisabledObjective) { local SquadAI S; for ( S=Squads; S!=None; S=S.NextSquad ) { if ( S.SquadObjective == DisabledObjective || S.SquadObjective == none ) { FindNewObjectiveFor(S,true); } } } // This will force all squads on this team to switch to this objective. function SetAllSquadObjectivesTo(int NewObjective) { local GameObjective O; local SquadAI S; for ( O=Objectives; O!=None; O=O.NextObjective ) { if( ROObjective(O).ObjNum == NewObjective) { for ( S=Squads; S!=None; S=S.NextSquad ) { S.SetObjective(O, true); } } } } function SetSquadObjectivesTo(int NewObjective, PlayerReplicationInfo SquadLeader) { local GameObjective O; local SquadAI S; for (O=Objectives; O!=None; O=O.NextObjective) { if (ROObjective(O).ObjNum == NewObjective) { for (S=Squads; S!=None; S=S.NextSquad) { if (S.LeaderPRI == SquadLeader) S.SetObjective(O, true); } } } } // Tell the bots what the highest priority objective for them to attack is // Overriden to support the ROObjective structure function GameObjective GetPriorityAttackObjectiveFor(SquadAI AttackSquad) { // local GameObjective O; // local ROObjective ROObj; // if ( (PickedObjective != None) && (!PickedObjective.bActive || Team.TeamIndex == ROObjective(PickedObjective).ObjState)) // PickedObjective = None; // for ( O=Objectives; O!=None; O=O.NextObjective ) // { // ROObj = ROObjective(O); // // if ( (ROObj != None) && ROObj.bActive && Team.TeamIndex != ROObj.ObjState && // ( (PickedObjective == none) || (ROObj.IsHigherPriority(PickedObjective, Team.TeamIndex))) ) // { // PickedObjective = O; // } // } //jonathan@psyonix There's No deference betwen attack and defense objectives in RO // if (PickedObjective == none) // PickedObjective = GetLeastDefendedObjective(); //log("Objective:"$PickedObjective); return GetLeastDefendedObjective(); } // Tell the bots which objective is the least defended (highest priority) so they // will go and defend it function GameObjective GetLeastDefendedObjective() { local GameObjective O, Best; local ROObjective ROObj; local int NumBestSquads, NumCurSquads; local SquadAI S; NumBestSquads = 10000; for ( O=Objectives; O!=None; O=O.NextObjective ) { ROObj = ROObjective(O); if ( (ROObj != None) && ROObj.bActive ) { NumCurSquads = 0; for ( S=Squads; S!=None; S=S.NextSquad ) { if(S.SquadObjective == O) NumCurSquads += S.Size; } if(NumCurSquads<NumBestSquads) { Best = O; NumBestSquads = NumCurSquads; } } } return Best; } //TODO:: Jonathan Remove this when I'm sure we have everything from it // ROObj = ROObjective(O); // // if ( (ROObj != None) && ROObj.bActive && Team.TeamIndex == ROObj.ObjState && // ( (Best == none) || (ROObj.IsHigherPriority(Best, Team.TeamIndex))) ) // { // Best = O; // } // Tell the bots which objective is the most defended (lowest priority) function GameObjective GetMostDefendedObjective() { local GameObjective O, Best; for ( O=Objectives; O!=None; O=O.NextObjective ) { if ( !O.bDisabled && O.bActive && (Team.TeamIndex == ROObjective(O).ObjState) && ((Best == None) || (ROObjective(O).IsHigherPriority(Best, Team.TeamIndex)) || ((ROObjective(O).IsEqualPriority(Best,Team.TeamIndex)) && (Best.GetNumDefenders() < O.GetNumDefenders()))) ) Best = O; } return Best; } // Returns true if this team has nothing to defend. Not used right now function bool NothingToDefend() { local ROObjective ROObj; local GameObjective O; for ( O=Team.AI.Objectives; O!=None; O=O.NextObjective ) { ROObj = ROObjective(O); if ( (ROObj != None) && ROObj.bActive && Team.TeamIndex == ROObj.ObjState) { return false; } } return true; } defaultproperties { SquadType=Class'ROEngine.ROSquadAI' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |