## XIIIMP
Class XIIIMPBotInteraction

source: C:\XIII\XIIIMP\Classes\XIIIMPBotInteraction.uc

    Core.Object
       |
       +--Engine.Interactions
          |
          +--Engine.Interaction
             |
             +--XIII.XIIIPlayerInteraction
                |
                +--XIIIMP.XIIIMPBotInteraction

Direct Known Subclasses:XIIIMPBombBotInteraction

class XIIIMPBotInteraction
extends XIII.XIIIPlayerInteraction

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`Array` | `BotControllerList`
`int` | `CurrentBot,CurrentOrder,OrderPhase,InitialOrder[16]`
`enum` | `ERenderStyle`
`Texture` | `Fond1,Fond2`
`int` | `GameType`
`color` | `HudBasicColor,BgkColor`
`float` | `InfoX,InfoY,InfoW,InfoH`
`bool` | `InitParams`
`bool` | `InputUp,InputDown,InputLeft,InputRight,InitInitialOrder`
`bool` | `IsInBotMnu,KeyIsRelease`
`sound` | `MnuValid,MnuCancel,MnuSelect`
`bool` | `RepeatInputUp,RepeatInputDown,RepeatInputLeft,RepeatInputRight`
`bool` | `Up,Down,Left,Right`
`string` | `strCTFRole[3],strBombDefendRole[3],strBombAttackRole[3]`
`string` | `strTeamRole[3],strAllBot,strResetOrder`

Function Summary
`void` | `AddIfoLine(Canvas C, string InfoTxt, bool AddBg)`
    //_________________________________________________________________________________
`void` | `InitCtrlParams()`
    //_________________________________________________________________________________

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class XIIIMPBotInteraction extends XIIIPlayerInteraction;
    00005
    00006	var Array<BotController> BotControllerList;
    00007	var bool IsInBotMnu,KeyIsRelease;
    00008	var localized string strTeamRole[3],strAllBot,strResetOrder;
    00009	var localized string strCTFRole[3],strBombDefendRole[3],strBombAttackRole[3];
    00010	var int CurrentBot,CurrentOrder,OrderPhase,InitialOrder[16];
    00011	var bool Up,Down,Left,Right;
    00012	var bool InputUp,InputDown,InputLeft,InputRight,InitInitialOrder;
    00013	var bool RepeatInputUp,RepeatInputDown,RepeatInputLeft,RepeatInputRight;
    00014	var texture Fond1,Fond2;
    00015	var color HudBasicColor,BgkColor;
    00016	var float InfoX,InfoY,InfoW,InfoH;
    00017	var sound MnuValid,MnuCancel,MnuSelect;
    00018	var bool InitParams;
    00019	var int GameType;
    00020
    00021	var enum ERenderStyle
    00022	{
    00023		STY_None,
    00024		STY_Normal,
    00025		STY_Masked,
    00026		STY_Translucent,
    00027		STY_Modulated,
    00028		STY_Alpha,
    00029		STY_Particle
    00030	} Style;
    00031
    00032	//_____________________________________________________________________________
    00033	// EndMap - Prevent actor references before to change of map.
    00034	event EndMap()
    00035	{
    00036	    local int i;
    00037
    00038	    Super.EndMap();
    00039	    Master.RemoveInteraction(self);
    00040	    for( i=0 ; i<BotControllerList.Length ; i++)
    00041	    {
    00042	      BotControllerList[i] = none;
    00043	    }
    00044	}
    00045
    00046	//_________________________________________________________________________________
    00047
    00048	function InitCtrlParams()
    00049	{
    00050	    local int Loop;
    00051
    00052	    InitParams = true;
    00053
    00054	    if( GameType == 0 )
    00055	    {
    00056	        // CTF
    00057
    00058	        for( Loop=0 ; Loop < 3 ; Loop++ )
    00059	             strTeamRole[ Loop ] = strCTFRole[ Loop ];
    00060	    }
    00061	    else if( GameType == 1 )
    00062	    {
    00063	        // Bomb Defend
    00064
    00065	        for( Loop=0 ; Loop < 3 ; Loop++ )
    00066	             strTeamRole[ Loop ] = strBombDefendRole[ Loop ];
    00067	    }
    00068	    else if( GameType == 2 )
    00069	    {
    00070	        // Bomb Attack
    00071
    00072	        for( Loop=0 ; Loop < 3 ; Loop++ )
    00073	             strTeamRole[ Loop ] = strBombAttackRole[ Loop ];
    00074	    }
    00075	}
    00076
    00077	//_________________________________________________________________________________
    00078	/*
    00079	event bool KeyEvent( EInputKey Key, EInputAction Action, FLOAT Delta )
    00080	{
    00081	    local int Loop;
    00082	    local int OldOrder;
    00083
    00084	    if( MyPC.IsInState('GameEnded') )
    00085	    {
    00086	        OrderPhase = -1;
    00087	        return false;
    00088	    }
    00089
    00090	    if ( (Level.NetMode != NM_StandAlone) || (BotControllerList.Length == 0) )
    00091	      return false;
    00092
    00093	    InputLeft = false;
    00094	    InputRight = false;
    00095	    InputUp = false;
    00096	    InputDown = false;
    00097
    00098	    Left = false;
    00099	    Right = false;
    00100	    Up = false;
    00101	    Down = false;
    00102
    00103	    switch( XIIIGameInfo(Level.Game).Plateforme )
    00104	    {
    00105	        case PF_PC :
    00106	                if( Key == IK_Joy13 ) Up = true;
    00107	                if( Key == IK_Joy15 ) Down = true;
    00108	                if( Key == IK_Joy16 ) Left = true;
    00109	                if( Key == IK_Joy14 ) Right = true;
    00110
    00111	                if( OrderPhase == -1 )
    00112	                {
    00113	                    if( Key == 222 ) Left = true;
    00114	                }
    00115	                else
    00116	                {
    00117	                    if( Key == 222 ) Left = true;
    00118	                    if( Key == 27 ) Left = true;
    00119	                }
    00120
    00121	                if( Key == 38 ) Up = true;
    00122	                if( Key == 40 ) Down = true;
    00123
    00124	                if( Key == 13 ) Right = true;
    00125
    00126	                break;
    00127	        case PF_PS2 :
    00128	                if( Key == IK_Joy13 ) Up = true;
    00129	                if( Key == IK_Joy15 ) Down = true;
    00130	                if( Key == IK_Joy16 ) Left = true;
    00131	                if( Key == IK_Joy14 ) Right = true;
    00132	                break;
    00133	        case PF_GC :
    00134	                if( Key == IK_Joy10 ) Up = true;
    00135	                if( Key == IK_Joy11 ) Down = true;
    00136	                if( Key == IK_Joy8  ) Left = true;
    00137	                if( Key == IK_Joy9  ) Right = true;
    00138	                break;
    00139	        case PF_XBOX :
    00140	                if( Key == IK_Joy9  ) Up = true;
    00141	                if( Key == IK_Joy10 ) Down = true;
    00142	                if( Key == IK_Joy11 ) Left = true;
    00143	                if( Key == IK_Joy12 ) Right = true;
    00144	                break;
    00145	    }
    00146
    00147	    if( Action==IST_Press )
    00148	    {
    00149	        if( Left )
    00150	        {
    00151	            if( !RepeatInputLeft )
    00152	            {
    00153	                InputLeft = true;
    00154	                RepeatInputLeft = true;
    00155	            }
    00156	        }
    00157	        else if( Right )
    00158	        {
    00159	            if( !RepeatInputRight )
    00160	            {
    00161	                InputRight = true;
    00162	                RepeatInputRight = true;
    00163	            }
    00164	        }
    00165	        else if( Up )
    00166	        {
    00167	            if( !RepeatInputUp )
    00168	            {
    00169	                InputUp = true;
    00170	                RepeatInputUp = true;
    00171	            }
    00172	        }
    00173	        else if( Down )
    00174	        {
    00175	            if( !RepeatInputDown )
    00176	            {
    00177	                InputDown = true;
    00178	                RepeatInputDown = true;
    00179	            }
    00180	        }
    00181	    }
    00182	    else if( Action==IST_Release )
    00183	    {
    00184	        if( Left )
    00185	        {
    00186	            RepeatInputLeft = false;
    00187	        }
    00188	        else if( Right )
    00189	        {
    00190	            RepeatInputRight = false;
    00191	        }
    00192	        else if( Up )
    00193	        {
    00194	            RepeatInputUp = false;
    00195	        }
    00196	        else if( Down )
    00197	        {
    00198	            RepeatInputDown = false;
    00199	        }
    00200	    }
    00201
    00202	    if( OrderPhase == -1 )
    00203	    {
    00204	        if( InputLeft )
    00205	        {
    00206	            if( ! InitInitialOrder )
    00207	            {
    00208	                InitInitialOrder = true;
    00209
    00210	                for( Loop=0;Loop<BotControllerList.Length;Loop++)
    00211	                     InitialOrder[Loop] = BotControllerList[ Loop ].TeamRole;
    00212
    00213	                if( ! InitParams )
    00214	                    InitCtrlParams();
    00215	            }
    00216
    00217	            OrderPhase = 0;
    00218
    00219	            MyPC.Pawn.PlaySound( MnuValid );
    00220	        }
    00221	    }
    00222	    else if( OrderPhase == 0 )
    00223	    {
    00224	        if( InputLeft )
    00225	        {
    00226	            OrderPhase = -1;
    00227	            MyPC.Pawn.PlaySound( MnuCancel );
    00228	        }
    00229	        else if( InputRight )
    00230	        {
    00231	            OrderPhase = 1;
    00232	            MyPC.Pawn.PlaySound( MnuValid );
    00233	        }
    00234	        else if( InputDown )
    00235	        {
    00236	            CurrentBot++;
    00237
    00238	            MyPC.Pawn.PlaySound( MnuSelect );
    00239
    00240	            if( CurrentBot == BotControllerList.Length)
    00241	                CurrentBot = -1;
    00242	        }
    00243	        else if( InputUp )
    00244	        {
    00245
CurrentBot--; 00246 00247 MyPC.Pawn.PlaySound( MnuSelect ); 00248 00249 if( CurrentBot == -2) 00250 CurrentBot = BotControllerList.Length-1; 00251 } 00252 } 00253 else if( OrderPhase == 1 ) 00254 { 00255 if( InputLeft ) 00256 { 00257 OrderPhase = 0; 00258 MyPC.Pawn.PlaySound( MnuCancel ); 00259 } 00260 else if( InputRight ) 00261 { 00262 if( CurrentOrder != -1 ) 00263 { 00264 MyPC.Pawn.PlaySound( MnuValid ); 00265 00266 if( CurrentBot == -1 ) 00267 { 00268 for( Loop=0;Loop<BotControllerList.Length;Loop++) 00269 { 00270 OldOrder = BotControllerList[ Loop ].TeamRole; 00271 BotControllerList[ Loop ].UpDateOrder( OldOrder,CurrentOrder ); 00272 } 00273 } 00274 else 00275 { 00276 OldOrder = BotControllerList[ CurrentBot ].TeamRole; 00277 BotControllerList[ CurrentBot ].UpDateOrder( OldOrder,CurrentOrder ); 00278 } 00279 } 00280 else 00281 { 00282 MyPC.Pawn.PlaySound( MnuValid ); 00283 00284 if( CurrentBot == -1 ) 00285 { 00286 for( Loop=0;Loop<BotControllerList.Length;Loop++) 00287 { 00288 OldOrder = BotControllerList[ Loop ].TeamRole; 00289 BotControllerList[ Loop ].UpDateOrder( OldOrder,InitialOrder[Loop] ); 00290 } 00291 } 00292 else 00293 { 00294 OldOrder = BotControllerList[ CurrentBot ].TeamRole; 00295 BotControllerList[ CurrentBot ].UpDateOrder( OldOrder,InitialOrder[CurrentBot] ); 00296 } 00297 } 00298 00299 OrderPhase = -1; 00300 } 00301 else if( InputDown ) 00302 { 00303 CurrentOrder++; 00304 00305 MyPC.Pawn.PlaySound( MnuSelect ); 00306 00307 if( CurrentOrder == 3) 00308 CurrentOrder = -1; 00309 00310 if( ( GameType == 0 ) && ( CurrentOrder == 2 ) ) 00311 CurrentOrder = -1; 00312 } 00313 else if( InputUp ) 00314 { 00315 CurrentOrder--; 00316 00317 MyPC.Pawn.PlaySound( MnuSelect ); 00318 00319 if( CurrentOrder == -2) 00320 { 00321 if( GameType == 0 ) 00322 CurrentOrder = 1; 00323 else 00324 CurrentOrder = 2; 00325 } 00326 } 00327 } 00328 00329 return false; 00330 } 00331 */ 00332 //_________________________________________________________________________________ 00333 00334 function AddIfoLine( Canvas C, string InfoTxt , bool AddBg ) 00335 { 00336 local color MsgColor; 00337 00338 if( AddBg ) 00339 MsgColor = HudBasicColor; 00340 else 00341 MsgColor = BgkColor; 00342 00343 C.SpaceX = 0; 00344 00345 // BackGround Icon + Text 00346 00347 C.bUseBorder = false; 00348 C.Style = ERenderStyle.STY_Alpha; 00349 C.DrawColor = MsgColor; 00350 00351 // BackGround Part 1 00352 00353 C.SetPos(InfoX,InfoY); 00354 00355 C.DrawTile(Fond2, InfoH-4,InfoH-4, 1, 0, Fond2.USize-1, Fond2.VSize); 00356 00357 // BackGround Part 2 00358 00359 C.DrawTile(Fond1, InfoW,InfoH-4, 0, 0, Fond1.USize, Fond1.VSize); 00360 00361 // BackGround Part 3 00362 00363 C.DrawTile(Fond2, InfoH-4,InfoH-4, -1, 0, -(Fond2.USize-1), Fond2.VSize ); 00364 00365 if( AddBg ) 00366 { 00367 C.Style = ERenderStyle.STY_Translucent; 00368 00369 C.DrawColor = MsgColor; 00370 C.DrawColor.A = 200; 00371 00372 // BackGround Part 1 00373 00374 C.SetPos(InfoX,InfoY); 00375 C.DrawTile(Fond2, InfoH-4,InfoH-4, 1, 0, Fond2.USize-1, Fond2.VSize); 00376 00377 // BackGround Part 2 00378 00379 C.DrawTile(Fond1, InfoW,InfoH-4, 0, 0, Fond1.USize, Fond1.VSize); 00380 00381 // BackGround Part 3 00382 00383 C.DrawTile(Fond2, InfoH-4,InfoH-4, -1, 0, -(Fond2.USize-1), Fond2.VSize ); 00384 } 00385 00386 // Text 00387 00388 C.SpaceX = 1; 00389 00390 C.Style=ERenderStyle.STY_Normal; 00391 00392 C.DrawColor = BgkColor; 00393 C.DrawColor.R *= 0.3; 00394 C.DrawColor.G *= 0.3; 00395 C.DrawColor.B *= 0.3; 00396 C.SetPos(InfoX+InfoH-4+1,InfoY-1); 00397 C.DrawText(InfoTxt, false); 00398 00399 C.DrawColor = HudBasicColor; 00400 C.SetPos(InfoX+InfoH-4,InfoY-2); 00401 C.DrawText(InfoTxt, false); 00402 00403 InfoY += InfoH; 00404 } 00405 00406 //_________________________________________________________________________________ 00407 00408 simulated event MyPCPostRender(Canvas C) 00409 { 00410 local string Txt; 00411 local int Loop; 00412 local float H,W,TmpW,TmpH; 00413 00414 super.MyPCPostRender(C); 00415 00416 if( BotControllerList.Length == 0 ) 00417 return; 00418 00419 if( OrderPhase == 0 ) 00420 { 00421 C.Font = C.SmallFont; 00422 C.SpaceX = 1; 00423 00424 C.strLen( strAllBot,InfoW,InfoH); 00425 00426 for( Loop=0;Loop<BotControllerList.Length;Loop++) 00427 { 00428 Txt = BotControllerList[ Loop ].MyName@"-"@strTeamRole[BotControllerList[ Loop ].TeamRole]; 00429 00430 C.strLen( Txt,TmpW,InfoH); 00431 00432 if( TmpW > InfoW ) 00433 InfoW=TmpW; 00434 } 00435 00436 InfoX = C.ClipX/2-InfoW/2-InfoH+4; 00437 InfoY = C.ClipY/2-InfoH*(BotControllerList.Length+1)/2; 00438 00439 if( CurrentBot == -1 ) 00440 AddIfoLine( C, strAllBot , true ); 00441 else 00442 AddIfoLine( C, strAllBot , false ); 00443 00444 for( Loop=0;Loop<BotControllerList.Length;Loop++) 00445 { 00446 Txt = BotControllerList[ Loop ].MyName@"-"@strTeamRole[BotControllerList[ Loop ].TeamRole]; 00447 00448 if( Loop == CurrentBot ) 00449 AddIfoLine( C, Txt , true ); 00450 else 00451 AddIfoLine( C, Txt , false ); 00452 } 00453 } 00454 if( OrderPhase == 1 ) 00455 { 00456 C.Font = C.SmallFont; 00457 C.SpaceX = 1; 00458 00459 C.strLen( strResetOrder,InfoW,InfoH); 00460 00461 if( GameType == 0 ) 00462 { 00463 for( Loop=0;Loop<2;Loop++) 00464 { 00465 C.strLen( strTeamRole[Loop],TmpW,InfoH); 00466 00467 if( TmpW > InfoW ) 00468 InfoW=TmpW; 00469 } 00470 } 00471 else 00472 { 00473 for( Loop=0;Loop<3;Loop++) 00474 { 00475 C.strLen( strTeamRole[Loop],TmpW,InfoH); 00476 00477 if( TmpW > InfoW ) 00478 InfoW=TmpW; 00479 } 00480 } 00481 00482 InfoX = C.ClipX/2-InfoW/2-InfoH+4; 00483 InfoY = C.ClipY/2-InfoH*3/2; 00484 00485 if( CurrentOrder == -1 ) 00486 AddIfoLine( C , strResetOrder , true ); 00487 else 00488 AddIfoLine( C , strResetOrder , false ); 00489 00490 if( GameType == 0 ) 00491 { 00492 for( Loop=0;Loop<2;Loop++) 00493 { 00494 if( Loop == CurrentOrder ) 00495 AddIfoLine( C , strTeamRole[Loop] , true ); 00496 else 00497 AddIfoLine( C , strTeamRole[Loop] , false ); 00498 } 00499 } 00500 else 00501 { 00502 for( Loop=0;Loop<3;Loop++) 00503 { 00504 if( Loop == CurrentOrder ) 00505 AddIfoLine( C , strTeamRole[Loop] , true ); 00506 else 00507 AddIfoLine( C , strTeamRole[Loop] , false ); 00508 } 00509 } 00510 } 00511 } 00512 00513 00514 00515 defaultproperties 00516 { 00517 KeyIsRelease=True 00518 strAllBot="All" 00519 strResetOrder="Reset" 00520 strCTFRole(0)="Attack" 00521 strCTFRole(1)="Defense" 00522 strCTFRole(2)="Support" 00523 strBombDefendRole(0)="Defend Point 1" 00524 strBombDefendRole(1)="Defend Point 2" 00525 strBombDefendRole(2)="Defend Point 3" 00526 strBombAttackRole(0)="Attack Point 1" 00527 strBombAttackRole(1)="Attack Point 2" 00528 strBombAttackRole(2)="Attack Point 3" 00529 CurrentBot=-1 00530 CurrentOrder=-1 00531 OrderPhase=-1 00532 Fond1=Texture'XIIIMenu.HUD.FondMsg' 00533 Fond2=Texture'XIIIMenu.HUD.fondmsg2' 00534 HudBasicColor=(B=210,G=252,R=255,A=230) 00535 BgkColor=(B=63,G=76,R=77,A=90) 00536 MnuValid=Sound'XIIIsound.Interface.MnValid' 00537 MnuCancel=Sound'XIIIsound.Interface.MnAnnul' 00538 MnuSelect=Sound'XIIIsound.Interface.MnCurseur' 00539 }

End Source Code