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 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 |
//============================================================================= // ScoreboardInfoManager.uc // $Author: Mfox $ // $Date: 10/04/02 3:24p $ // $Revision: 16 $ //============================================================================= class ScoreboardInfoManager extends DebugInfoManager config(User); /*----------------------------------------------------------------------------- A "scoreboard" for showing scores, health, states etc. mainly for debugging purposes. */ const NameFieldLen = 20; const HealthFieldLen = 4; const PowerSuitFieldLen = 7; const WeaponFieldLen = 2; const EnemyFieldLen = 20; const StateFieldLen = 24; const MetaStateFieldLen = 4; const OrdersFieldLen = 10; const OrdersObjectFieldLen = 20; const GoalFieldLen = 20; const MaxCountedPawns = 32; // number of PCs/NPCs which will be processed (for sorting by score, priority etc.) const MaxDisplayedPawns = 32; // number of PCs/NPCs which will be displayed (rest fall off the bottom of the list) enum ESBType { SB_None, SB_Client, SB_ServerMP, SB_ServerSP, }; var ESBType SBType; var string StaticHeaderStr; var PlayerReplicationInfo PRIArray[ MaxCountedPawns ]; //----------------------------------------------------------------------------- function Cleanup() { RemoveAllTimers(); Super.Cleanup(); } //----------------------------------------------------------------------------- function SetEnabled( byte bVal ) { Super.SetEnabled( bVal ); if( bVal > 0 ) { if( PCOwner.Level.NetMode != NM_Standalone ) { SBType = SB_Client; } else { // IsA used to break dependency on U2DeathMatch assets // NOTE: typos will cause IsA to fail silently. // Might be worth it to make a IsASafe() that checks for a valid class name if( PCOwner.Level.Game.IsA('U2DeathMatch') ) { SBType = SB_ServerMP; } else { SBType = SB_ServerSP; } } SetStaticHeaderStr(); } // !!mdf-tbr: PRIArray not getting correctly filled in (in // GameReplicationInfo.Timer?) so using timer to do this once per second. if( PCOwner.Level.NetMode != NM_Standalone ) { if( bVal == 0 ) RemoveTimer( 'UpdatePRIArrayTimer' ); else AddTimer( 'UpdatePRIArrayTimer', 1.0, true ); } } //----------------------------------------------------------------------------- // !!mdf-tbr: PRIArray not getting correctly filled in (in // GameReplicationInfo.Timer?) so using timer to do this once per second. function UpdatePRIArrayTimer() { local int ii; local PlayerReplicationInfo PRI; ii = 0; foreach PCOwner.DynamicActors( class'PlayerReplicationInfo', PRI ) PRIArray[ ii++ ] = PRI; } //----------------------------------------------------------------------------- function bool TeamGame() { return ( PCOwner.Level.Game != None && PCOwner.Level.Game.bTeamGame ); } //----------------------------------------------------------------------------- function SetStaticHeaderStr() { StaticHeaderStr = " " $ class'Util'.static.PadString( "Name", NameFieldLen ); if( SBType != SB_ServerSP ) StaticHeaderStr = StaticHeaderStr $ " Scor Sprd Dths"; // 1234 StaticHeaderStr = StaticHeaderStr $ " Team"; if( PCOwner.Level.NetMode == NM_Standalone ) { if( bEnabled > 1 ) { StaticHeaderStr = StaticHeaderStr $ " Hlth PwrSuit We"; StaticHeaderStr = StaticHeaderStr @ class'Util'.static.PadString( "Enemy", EnemyFieldLen ); StaticHeaderStr = StaticHeaderStr @ class'Util'.static.PadString( "State/Script", StateFieldLen ); StaticHeaderStr = StaticHeaderStr @ class'Util'.static.PadString( "Meta", MetaStateFieldLen ); StaticHeaderStr = StaticHeaderStr @ class'Util'.static.PadString( "Orders", OrdersFieldLen ); StaticHeaderStr = StaticHeaderStr @ class'Util'.static.PadString( "OrdersObject", OrdersObjectFieldLen ); StaticHeaderStr = StaticHeaderStr @ class'Util'.static.PadString( "Goal", 0 ); } } } //----------------------------------------------------------------------------- function AppendHeader( coerce string Str ) { InfoStrings[ InfoStrings.Length ] = StaticHeaderStr @ Str; } /*----------------------------------------------------------------------------- NOTE: afaict there isn't much that can be done to optimize this without moving to native code. The overhead for 30 or so NPCs is about 29ms per frame. About 5ms of this is due to the code in this function up to but not including the "extra debug info" section. The "extra debug info" accounts for about 18ms and about 11ms of that is due to the code near the bottom which concatenates all the strings together. The remaining 6ms or so is the rendering overhead. This component is only used for debugging so I'm not going to worry about this overhead for now. */ function SetPawnInfo( float BestScore, PlayerReplicationInfo PRI, optional Controller C ) { local string NameStr; local string PawnStr; local string BestScoreStr; local string ScoreStr; local string DeathsStr; local string TeamStr; local string HealthStr; local string PowerSuitStr; local string WeaponStr; local string EnemyStr; local string StateStr; local string MetaStateStr; local string OrdersStr; local string OrdersObjectStr; local string GoalStr; local Pawn CurrentEnemy; local name Orders; local U2NPCController U2NPC; if( (SBType == SB_ServerSP || TeamGame()) && C.Pawn != None ) TeamStr = string(C.Pawn.GetTeam()); else TeamStr = "XX"; if( SBType != SB_ServerSP ) { if( PRI != None ) { NameStr = PRI.PlayerName; BestScoreStr = string(int(PRI.Score - BestScore)); ScoreStr = string(int(PRI.Score)); DeathsStr = string(int(PRI.Deaths)); } else if( C != None ) { if( C.Pawn != None ) NameStr = Right( C.Pawn.Name, NameFieldLen); else NameStr = Right( C.Name, NameFieldLen); BestScoreStr = "NA"; ScoreStr = "NA"; DeathsStr = "NA"; } } else if( C != None ) { if( C.Pawn != None ) NameStr = Right( C.Pawn.Name, NameFieldLen); else NameStr = Right( C.Name, NameFieldLen); } if( C != None ) { if( C.bIsPlayer ) { if( C == PCOwner ) PawnStr = "* "; // player who owns scoreboard else if( PlayerController(C) != None ) PawnStr = "P "; // some other player else PawnStr = "B "; // some bot } else { // NPC if( C.bStasis ) PawnStr = "- "; // dormant NPC else if( StationaryPawn(C.Pawn) != None ) PawnStr = "S "; // active StationaryPawn else PawnStr = "N "; // active NPC } } else { PawnStr = "# "; // dead? } // main info if( SBType != SB_ServerSP ) { InfoStrings[InfoStrings.Length] = PawnStr $ // flag bots with * class'Util'.static.PadString( NameStr, NameFieldLen+1 ) $ // name class'Util'.static.PadString( ScoreStr, 5 ) $ // score class'Util'.static.PadString( BestScoreStr, 5 ) $ // spread class'Util'.static.PadString( DeathsStr, 5 ); // deaths } else { InfoStrings[InfoStrings.Length] = PawnStr $ // flag bots with * class'Util'.static.PadString( NameStr, NameFieldLen+1 ); // name } InfoStrings[InfoStrings.Length-1] = InfoStrings[InfoStrings.Length-1] $ class'Util'.static.PadString( TeamStr, 5 ); // team id if( C != None && bEnabled > 1 ) { // extra debug info if( C.Pawn != None ) HealthStr = string(Min( C.Pawn.Health, 9999 )); else HealthStr = "XXX"; if( U2Pawn(C.Pawn) != None ) PowerSuitStr = string(int(U2Pawn(C.Pawn).GetPowerSuit())) $ "/" $ string(int(U2Pawn(C.Pawn).GetPowerSuitMax())); else PowerSuitStr = "XXX"; if( C.Pawn != None && C.Pawn.Weapon != None ) WeaponStr = C.Pawn.Weapon.GetShortName(); else WeaponStr = "XX"; CurrentEnemy = C.ControllerEnemy; if( CurrentEnemy != None ) { if( CurrentEnemy.PlayerReplicationInfo != None ) EnemyStr = CurrentEnemy.PlayerReplicationInfo.PlayerName; else EnemyStr = string(CurrentEnemy.Name); EnemyStr = Right( EnemyStr, EnemyFieldLen ); } else EnemyStr = "--"; StateStr = Right( C.GetStateInfoString(), StateFieldLen ); U2NPC = U2NPCController(C); if( U2NPC != None ) { MetaStateStr = Right( U2NPC.GetMetaStateNameShort(), MetaStateFieldLen ); Orders = U2NPC.GetOrders(); if( Orders == '' ) OrdersStr = "--"; else OrdersStr = Left( Orders, OrdersFieldLen ); if( U2NPC.GetOrdersObject() != None ) OrdersObjectStr = Right( U2NPC.GetOrdersObject().Name, OrdersObjectFieldLen ); else OrdersObjectStr = "--"; if( U2NPC.GetSpecialGoal() != None ) GoalStr = Right( U2NPC.GetSpecialGoal().Name, GoalFieldLen ); else if( C.MoveTarget != None ) GoalStr = Right( string(C.MoveTarget.Name ), GoalFieldLen ); else GoalStr = "--"; } else { MetaStateStr = "NA"; GoalStr = "NA"; OrdersStr = "NA"; OrdersObjectStr = "NA"; } InfoStrings[InfoStrings.Length-1] = InfoStrings[InfoStrings.Length-1] $ class'Util'.static.PadString( HealthStr, HealthFieldLen+1 ) $ // health class'Util'.static.PadString( PowerSuitStr, PowerSuitFieldLen+1 ) $ // powersuit info class'Util'.static.PadString( WeaponStr, WeaponFieldLen+1 ) $ // weapon class'Util'.static.PadString( EnemyStr, EnemyFieldLen+1 ) $ // enemy name class'Util'.static.PadString( StateStr, StateFieldLen+1 ) $ // controller state class'Util'.static.PadString( MetaStateStr, MetaStateFieldLen+1 ) $ // behavior controller metastate class'Util'.static.PadString( OrdersStr, OrdersFieldLen+1 ) $ // NPC orders class'Util'.static.PadString( OrdersObjectStr, OrdersObjectFieldLen+1 )$ // NPC order object class'Util'.static.PadString( GoalStr, GoalFieldLen+1 ); // NPC special goal } } //----------------------------------------------------------------------------- function SetClientInfoStrings() { local PlayerReplicationInfo PRI; local PlayerReplicationInfo SortedPawns[ MaxCountedPawns ]; local int ii, jj; local int PawnIndex, NumPawns, TotalPawns; //local U2GameReplicationInfo GRI; // !!mdf-tbd: ignore in standalone games (is GRI None in these cases)? if( PCOwner.Level.NetMode != NM_Standalone ) { //GRI = U2GameReplicationInfo(PCOwner.GameReplicationInfo); //if( GRI != None ) //{ // get pawns from GRI for( PawnIndex=0; PawnIndex<MaxCountedPawns; PawnIndex++ ) { if( NumPawns < MaxCountedPawns ) { //PRI = GRI.PRIArray[ PawnIndex ]; PRI = PRIArray[ PawnIndex ]; if( PRI != None ) { // insert into list, highest scores first ii=0; while( ii<NumPawns && PRI.Score < SortedPawns[ii].Score ) ii++; // shift everyone else down for( jj=NumPawns-1; jj>ii; jj-- ) { if( jj < MaxCountedPawns ) SortedPawns[jj] = SortedPawns[jj-1]; } // insert new one SortedPawns[ii] = PRI; NumPawns++; } } TotalPawns++; } //} } if( NumPawns >= 1 ) { NumPawns = Min( NumPawns, MaxDisplayedPawns ); AppendHeader( "(shown:" $ NumPawns $ "/" $ TotalPawns $ ")" ); for( ii=0; ii<NumPawns; ii++ ) SetPawnInfo( SortedPawns[0].Score, SortedPawns[ii] ); } } //----------------------------------------------------------------------------- function SetServerInfoStringsMP() { local Controller C; local PlayerReplicationInfo PRI; local Controller SortedPawns[ MaxCountedPawns ]; local int ii, jj; local int NumPawns, TotalPawns; // sort pawns by decreasing score for( C=PCOwner.Level.ControllerList; C!=None; C=C.NextController ) { if( NumPawns < MaxCountedPawns ) { PRI = C.PlayerReplicationInfo; if( (C.bIsPlayer && PRI != None) || bEnabled > 1 ) { if( PRI == None ) { // insert into list after any NPCs with a PRI (for debugging help) ii=0; while( ii<NumPawns && SortedPawns[ii].PlayerReplicationInfo != None ) ii++; } else { // insert into list, highest scores first ii=0; while( ii<NumPawns && PRI.Score < SortedPawns[ii].PlayerReplicationInfo.Score ) ii++; } // shift everyone else down for( jj=NumPawns; jj>ii; jj-- ) { if( jj < MaxCountedPawns ) SortedPawns[jj] = SortedPawns[jj-1]; } // insert new one SortedPawns[ii] = C; NumPawns++; } } TotalPawns++; } if( NumPawns >= 1 ) { NumPawns = Min( NumPawns, MaxDisplayedPawns ); AppendHeader( "(shown: " $ NumPawns $ "/" $ TotalPawns $ ")" ); for( ii=0; ii<NumPawns; ii++ ) { C = SortedPawns[ii]; PRI = C.PlayerReplicationInfo; SetPawnInfo( SortedPawns[0].PlayerReplicationInfo.Score, PRI, C ); } } } //----------------------------------------------------------------------------- function SetServerInfoStringsSP() { local Controller C; local Controller SortedPawns[ MaxCountedPawns ]; local int ii, jj; local int NumPawns, TotalPawns, ActivePawns; for( C=PCOwner.Level.ControllerList; C!=None; C=C.NextController ) { if( C.Pawn == None || C.Pawn.Health <= 0 ) continue; if( C.bIsPlayer || bEnabled > 1 ) { ii=0; while( ii<NumPawns && SortedPawns[ ii ].bIsPlayer ) ii++; // skip to first non-player //Log( " first non player is at " $ ii ); if( StationaryPawn(C.Pawn) != None ) { // skip to first stationary pawn or bStasis NPC found while( ii<NumPawns && StationaryPawn(SortedPawns[ ii ].Pawn) == None && !SortedPawns[ ii ].bStasis ) ii++; //Log( " first SP / bStasis is at " $ ii ); } if( !C.bIsPlayer && C.bStasis ) { // skip to first bStasis NPC while( ii<NumPawns && !SortedPawns[ ii ].bStasis && C.Pawn != None && (StationaryPawn(C.Pawn) == None || StationaryPawn(SortedPawns[ ii ].Pawn) != None) ) ii++; //Log( " first bStasis is at " $ ii ); if( StationaryPawn(C.Pawn) != None ) { // skip to first bStasis stationary pawn while( ii<NumPawns && StationaryPawn(SortedPawns[ ii ].Pawn) == None ) ii++; //Log( " first bStasis SP is at " $ ii ); } } if( ii < MaxCountedPawns ) { // insert at ii after shifting everyone else down (possibly off the end of the list) for( jj=NumPawns; jj>ii; jj-- ) { if( jj < MaxCountedPawns ) SortedPawns[jj] = SortedPawns[jj-1]; } // insert new one SortedPawns[ii] = C; } if( NumPawns < MaxCountedPawns ) NumPawns++; } TotalPawns++; if( !C.Pawn.bStasis ) ActivePawns++; //Log( " current list" ); //for( jj=0; jj<NumPawns; jj++ ) //Log( " " $ jj @ SortedPawns[jj].Pawn ); } if( NumPawns >= 1 ) { NumPawns = Min( NumPawns, MaxDisplayedPawns ); AppendHeader( "(shown:" $ NumPawns $ "/" $ TotalPawns $ " active:" $ ActivePawns $ ")" ); for( ii=0; ii<NumPawns; ii++ ) SetPawnInfo( 0, None, SortedPawns[ii] ); } } //----------------------------------------------------------------------------- function SetInfoStrings() { switch( SBType ) { case SB_Client: SetClientInfoStrings(); break; case SB_ServerMP: SetServerInfoStringsMP(); break; case SB_ServerSP: SetServerInfoStringsSP(); break; } } //----------------------------------------------------------------------------- defaultproperties { YOffset=-20 MaxEnabled=2 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |