Core.Object | +--Engine.Actor | +--Engine.Menu | +--UnrealShare.UnrealMenu | +--UnrealShare.UnrealShortMenu | +--UnrealShare.UnrealIndivBotMenu
int
CurrentTeam
GameInfo
GameType
string
MenuValues[20]
Num
PlayerClassNum
RealName
Actor
RealOwner
RealTeam
byte
SkinNum
Teams[4]
float
ValuesFadeTimes[20]
bSetup,
bPulseDown
void
ChangeMesh()
Destroyed()
DrawFadeValues(Canvas Canvas, int Spacing, int StartX, int StartY)
DrawMenu(Canvas Canvas)
Menu
ExitMenu()
FindSkin(int Dir)
GotoBot(int BotNum)
InitConfig(GameInfo G)
MenuTick(float DeltaTime)
bool
ProcessLeft()
ProcessMenuEscape()
ProcessMenuInput(string InputString)
ProcessMenuUpdate(string InputString)
ProcessRight()
ProcessSelection()
SaveConfigs()
SetUpDisplay()
00001 //============================================================================= 00002 // UnrealIndivBotMenu 00003 //============================================================================= 00004 class UnrealIndivBotMenu extends UnrealShortMenu; 00005 00006 var actor RealOwner; 00007 var bool bSetup, bPulseDown; 00008 var int Num; 00009 var int PlayerClassNum; 00010 var string RealName; 00011 var int RealTeam; 00012 var int CurrentTeam; 00013 var() globalconfig string Teams[4]; 00014 var byte SkinNum; 00015 var string MenuValues[20]; 00016 var float ValuesFadeTimes[20]; 00017 var BotInfo BotConfig; 00018 var GameInfo GameType; 00019 00020 function InitConfig(GameInfo G) 00021 { 00022 GameType = G; 00023 if ( Level.Game.IsA('DeathMatchGame') ) 00024 BotConfig = DeathMatchGame(Level.Game).BotConfig; 00025 else 00026 BotConfig = Spawn(DeathMatchGame(GameType).Default.BotConfigType); 00027 } 00028 00029 function GotoBot(int BotNum) 00030 { 00031 local int i; 00032 local string SkinName; 00033 local texture NewSkin; 00034 00035 if ( (BotNum < 0) || (BotNum > 15) ) 00036 return; 00037 00038 SetUpDisplay(); 00039 00040 Num = BotNum; 00041 for ( i=0; i<BotConfig.NumClasses; i++ ) 00042 if( BotConfig.GetAvailableClasses(i) ~= BotConfig.GetBotClassName(Num) ) 00043 { 00044 PlayerClassNum = i; 00045 break; 00046 } 00047 SkinName = BotConfig.GetBotSkin(Num); 00048 ChangeMesh(); 00049 if ( SkinName != "" ) 00050 { 00051 NewSkin = texture(DynamicLoadObject(SkinName, class'Texture')); 00052 if ( NewSkin != None ) 00053 { 00054 Skin = NewSkin; 00055 BotConfig.SetBotSkin(SkinName, Num); 00056 } 00057 } 00058 } 00059 00060 function Destroyed() 00061 { 00062 Super.Destroyed(); 00063 if ( !Level.Game.IsA('DeathMatchGame') || (BotConfig != DeathMatchGame(Level.Game).BotConfig) ) 00064 BotConfig.Destroy(); 00065 } 00066 00067 function FindSkin(int Dir) 00068 { 00069 local string SkinName, SkinDesc; 00070 local texture NewSkin; 00071 00072 SkinName = BotConfig.GetBotSkin(Num);; 00073 if( SkinName == "" ) 00074 SkinName = string(Skin); 00075 GetNextSkin(GetItemName(string(Mesh)), SkinName, Dir, SkinName, SkinDesc); 00076 if( SkinName != "" ) 00077 { 00078 NewSkin = texture(DynamicLoadObject(SkinName, class'Texture')); 00079 if( NewSkin != None ) 00080 { 00081 Skin = NewSkin; 00082 BotConfig.SetBotSkin(SkinName, Num); 00083 } 00084 } 00085 } 00086 00087 function ProcessMenuInput( coerce string InputString ) 00088 { 00089 InputString = Left(InputString, 20); 00090 if ( selection == 2 ) 00091 BotConfig.SetBotName(InputString, Num); 00092 } 00093 00094 function ProcessMenuEscape() 00095 { 00096 if ( selection == 2 ) 00097 BotConfig.SetBotName(RealName, Num); 00098 else if ( selection == 6 ) 00099 BotConfig.SetBotTeam(RealTeam, Num); 00100 } 00101 00102 function ProcessMenuUpdate( coerce string InputString ) 00103 { 00104 InputString = Left(InputString, 19); 00105 if ( selection == 2 ) 00106 BotConfig.SetBotName(InputString$"_", Num); 00107 } 00108 00109 function Menu ExitMenu() 00110 { 00111 SetOwner(RealOwner); 00112 Super.ExitMenu(); 00113 } 00114 00115 function bool ProcessLeft() 00116 { 00117 local int i; 00118 local string SkinName; 00119 local texture NewSkin; 00120 00121 if ( Selection == 1 ) 00122 { 00123 Num--; 00124 if ( Num < 0 ) 00125 Num = 15; 00126 00127 for ( i=0; i<BotConfig.NumClasses; i++ ) 00128 if( BotConfig.GetAvailableClasses(i) ~= BotConfig.GetBotClassName(Num) ) 00129 { 00130 PlayerClassNum = i; 00131 break; 00132 } 00133 SkinName = BotConfig.GetBotSkin(Num); 00134 ChangeMesh(); 00135 if ( SkinName != "" ) 00136 { 00137 NewSkin = texture(DynamicLoadObject(SkinName, class'Texture')); 00138 if ( NewSkin != None ) 00139 { 00140 Skin = NewSkin; 00141 BotConfig.SetBotSkin(SkinName, Num); 00142 } 00143 } 00144 } 00145 else if ( Selection == 2 ) 00146 { 00147 RealName = BotConfig.GetBotName(Num); 00148 BotConfig.SetBotName("_", Num); 00149 PlayerOwner.Player.Console.GotoState('MenuTyping'); 00150 } 00151 else if ( selection == 3 ) 00152 { 00153 PlayerClassNum++; 00154 if ( PlayerClassNum == BotConfig.NumClasses ) 00155 PlayerClassNum = 0; 00156 BotConfig.SetBotClass(BotConfig.GetAvailableClasses(PlayerClassNum), Num); 00157 ChangeMesh(); 00158 } 00159 else if ( Selection == 4 ) 00160 FindSkin(-1); 00161 else if ( selection == 5 ) 00162 BotConfig.BotSkills[Num] = FMax(0, BotConfig.BotSkills[Num] - 0.2); 00163 else if ( Selection == 6 ) 00164 { 00165 CurrentTeam--; 00166 if (CurrentTeam < 0) 00167 CurrentTeam = 3; 00168 RealTeam = BotConfig.GetBotTeam(Num); 00169 BotConfig.SetBotTeam(CurrentTeam, Num); 00170 } 00171 else 00172 return false; 00173 00174 return true; 00175 } 00176 00177 function bool ProcessRight() 00178 { 00179 local int i; 00180 local string SkinName; 00181 local string Temp1, Temp2; 00182 local texture NewSkin; 00183 00184 if ( Selection == 1 ) 00185 { 00186 Num++; 00187 if ( Num > 15 ) 00188 Num = 0; 00189 00190 for ( i=0; i<BotConfig.NumClasses; i++ ) 00191 if ( BotConfig.GetAvailableClasses(i) ~= BotConfig.GetBotClassName(Num) ) 00192 { 00193 PlayerClassNum = i; 00194 break; 00195 } 00196 SkinName = BotConfig.GetBotSkin(Num); 00197 ChangeMesh(); 00198 if ( SkinName != "" ) 00199 { 00200 NewSkin = texture(DynamicLoadObject(SkinName, class'Texture')); 00201 if ( NewSkin != None ) 00202 { 00203 Skin = NewSkin; 00204 BotConfig.SetBotSkin(SkinName, Num); 00205 } 00206 } 00207 } 00208 else if ( Selection == 2 ) 00209 { 00210 RealName = BotConfig.GetBotName(Num); 00211 BotConfig.SetBotName("_", Num); 00212 PlayerOwner.Player.Console.GotoState('MenuTyping'); 00213 } 00214 else if ( selection == 3 ) 00215 { 00216 PlayerClassNum--; 00217 if ( PlayerClassNum < 0 ) 00218 PlayerClassNum = BotConfig.NumClasses - 1; 00219 BotConfig.SetBotClass(BotConfig.GetAvailableClasses(PlayerClassNum), Num); 00220 ChangeMesh(); 00221 } 00222 else if ( Selection == 4 ) 00223 FindSkin(1); 00224 else if ( selection == 5 ) 00225 BotConfig.BotSkills[Num] = FMin(3.0, BotConfig.BotSkills[Num] + 0.2); 00226 else if ( Selection == 6 ) 00227 { 00228 CurrentTeam++; 00229 if (CurrentTeam > 3) 00230 CurrentTeam = 0; 00231 RealTeam = BotConfig.GetBotTeam(Num); 00232 BotConfig.SetBotTeam(CurrentTeam, Num); 00233 } 00234 else 00235 return false; 00236 00237 return true; 00238 } 00239 00240 function bool ProcessSelection() 00241 { 00242 local Menu ChildMenu; 00243 00244 if ( Selection == 2 ) 00245 { 00246 RealName = BotConfig.GetBotName(Num); 00247 BotConfig.SetBotName("_", Num); 00248 PlayerOwner.Player.Console.GotoState('MenuTyping'); 00249 } 00250 else 00251 return false; 00252 00253 if ( ChildMenu != None ) 00254 { 00255 HUD(Owner).MainMenu = ChildMenu; 00256 ChildMenu.ParentMenu = self; 00257 ChildMenu.PlayerOwner = PlayerOwner; 00258 } 00259 return true; 00260 } 00261 00262 function SaveConfigs() 00263 { 00264 BotConfig.SaveConfig(); 00265 } 00266 00267 function MenuTick(float DeltaTime) 00268 { 00269 local int I; 00270 00271 Super.MenuTick(DeltaTime); 00272 00273 // Update FadeTimes. 00274 if (TitleFadeTime >= 0.0) 00275 TitleFadeTime += DeltaTime; 00276 for (I=0; I<24; I++) 00277 if (MenuFadeTimes[I] >= 0.0) 00278 MenuFadeTimes[I] += DeltaTime; 00279 for (I=0; I<20; I++) 00280 if (ValuesFadeTimes[I] >= 0.0) 00281 ValuesFadeTimes[I] += DeltaTime; 00282 } 00283 00284 function SetUpDisplay() 00285 { 00286 local int I; 00287 local string SkinName; 00288 local texture NewSkin; 00289 00290 bSetup = true; 00291 00292 // Init the FadeTimes. 00293 // -1.0 means not updated. 00294 TitleFadeTime = -1.0; 00295 for (I=0; I<24; I++) 00296 MenuFadeTimes[I] = -1.0; 00297 for (I=0; I<20; I++) 00298 ValuesFadeTimes[I] = -1.0; 00299 00300 for ( I=0; I<BotConfig.NumClasses; I++ ) 00301 if ( BotConfig.GetAvailableClasses(I) ~= BotConfig.GetBotClassName(Num) ) 00302 { 00303 PlayerClassNum = I; 00304 break; 00305 } 00306 00307 RealOwner = Owner; 00308 SetOwner(PlayerOwner); 00309 SkinName = BotConfig.GetBotSkin(Num); 00310 ChangeMesh(); 00311 if ( SkinName != "" ) 00312 { 00313 NewSkin = texture(DynamicLoadObject(SkinName, class'Texture')); 00314 if ( NewSkin != None ) 00315 { 00316 Skin = NewSkin; 00317 BotConfig.SetBotSkin(SkinName, Num); 00318 } 00319 } 00320 LoopAnim(AnimSequence); 00321 } 00322 00323 function DrawMenu(canvas Canvas) 00324 { 00325 local int i, StartX, StartY, Spacing; 00326 local vector DrawOffset; 00327 local rotator NewRot; 00328 00329 if (!bSetup) 00330 SetUpDisplay(); 00331 00332 // Set menu location. 00333 PlayerOwner.ViewRotation.Pitch = 0; 00334 PlayerOwner.ViewRotation.Roll = 0; 00335 DrawOffset = ((vect(10.0,-5.0,0.0)) >> PlayerOwner.ViewRotation); 00336 DrawOffset += (PlayerOwner.EyeHeight * vect(0,0,1)); 00337 SetLocation(PlayerOwner.Location + DrawOffset); 00338 NewRot = PlayerOwner.ViewRotation; 00339 NewRot.Yaw = Rotation.Yaw; 00340 SetRotation(NewRot); 00341 Canvas.DrawActor(Self, false); 00342 00343 // Draw title. 00344 DrawFadeTitle(Canvas); 00345 00346 Spacing = Clamp(0.04 * Canvas.ClipY, 12, 32); 00347 StartX = Canvas.ClipX/2; 00348 StartY = Max(40, 0.5 * (Canvas.ClipY - MenuLength * Spacing - 128)); 00349 00350 // Draw text. 00351 DrawFadeList(Canvas, Spacing, StartX, StartY); 00352 00353 MenuValues[1] = string(Num); 00354 MenuValues[2] = BotConfig.GetBotName(Num); 00355 MenuValues[3] = GetItemName(string(Mesh)); 00356 MenuValues[4] = GetItemName(string(Skin)); 00357 MenuValues[5] = string(BotConfig.BotSkills[Num]); 00358 MenuValues[6] = Teams[BotConfig.GetBotTeam(Num)]; 00359 DrawFadeValues(Canvas, Spacing, StartX+120, StartY); 00360 00361 // Draw help panel. 00362 Canvas.DrawColor.R = 0; 00363 Canvas.DrawColor.G = 255; 00364 Canvas.DrawColor.B = 0; 00365 DrawHelpPanel(Canvas, Canvas.ClipY - 64, 228); 00366 } 00367 00368 function DrawFadeValues(canvas Canvas, int Spacing, int StartX, int StartY) 00369 { 00370 local int i; 00371 local color DrawColor; 00372 00373 Canvas.Font = Font'WhiteFont'; 00374 for (i=0; i< MenuLength; i++ ) 00375 { 00376 if (i == Selection - 1) 00377 { 00378 DrawColor.R = PulseTime * 10; 00379 DrawColor.G = 255; 00380 DrawColor.B = PulseTime * 10; 00381 } else { 00382 DrawColor.R = 0; 00383 DrawColor.G = 150; 00384 DrawColor.B = 0; 00385 } 00386 DrawFadeString(Canvas, MenuValues[i + 1], ValuesFadeTimes[i + 1], StartX, StartY + Spacing * i, DrawColor); 00387 } 00388 Canvas.DrawColor = Canvas.Default.DrawColor; 00389 } 00390 00391 function ChangeMesh() 00392 { 00393 local class<pawn> NewPlayerClass; 00394 00395 NewPlayerClass = class<pawn>(DynamicLoadObject(BotConfig.GetAvailableClasses(PlayerClassNum), class'Class')); 00396 if ( NewPlayerClass != None ) 00397 { 00398 BotConfig.SetBotSkin(string(NewPlayerClass.Default.Skin), Num); 00399 mesh = NewPlayerClass.Default.mesh; 00400 skin = NewPlayerClass.Default.skin; 00401 } 00402 } 00403 00404 defaultproperties 00405 { 00406 Teams(0)="Red" 00407 Teams(1)="Blue" 00408 Teams(2)="Green" 00409 Teams(3)="Gold" 00410 MenuLength=6 00411 HelpMessage(1)="Which Bot Configuration is being edited. Use left and right arrows to change." 00412 HelpMessage(2)="Hit enter to edit the name of this bot." 00413 HelpMessage(3)="Use the left and right arrow keys to change the class of this bot." 00414 HelpMessage(4)="Use the left and right arrow keys to change the skin of this bot." 00415 HelpMessage(5)="Adjust the overall skill of this bot by this amount (relative to the base skill for bots)." 00416 HelpMessage(6)="Type in which team this bot plays on (Red, Blue, Green, or Yellow)." 00417 MenuList(1)="Configuration" 00418 MenuList(2)="Name" 00419 MenuList(3)="Class" 00420 MenuList(4)="Skin" 00421 MenuList(5)="Skill Adjust" 00422 MenuList(6)="Team" 00423 MenuTitle="Artificial Intelligence Configuration" 00424 bHidden=False 00425 bOnlyOwnerSee=True 00426 Physics=PHYS_Rotating 00427 AnimSequence=Walk 00428 DrawType=DT_Mesh 00429 DrawScale=0.100000 00430 bUnlit=True 00431 bFixedRotationDir=True 00432 RotationRate=(Yaw=8000) 00433 DesiredRotation=(Yaw=30000) 00434 }