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 |
//============================================================================== // Challenge a team for a deathmatch (SP) // // Written by Michiel Hendriks // (c) 2003, Epic Games, Inc. All Rights Reserved //============================================================================== class UT2K4SP_Challenge extends LargeWindow; var automated GUIImage imgMap1, imgMap2, imgMapBg1, imgMapBg2; var automated GUIButton btnOk, btnCancel; var automated GUILabel lblTitle, lblGameDescription, lblNoPreview1, lblNoPreview2; var automated GUIComboBox cbGameType; var automated GUIGFXButton cbMap1, cbMap2; var automated moComboBox cbEnemyTeam; var automated GUIScrollTextBox sbDetails; var UT2K4GameProfile GP; /** team role selection window */ var string TeamRoleWindow; var UT2K4SP_TeamRoles RoleWindow; /** we have been challenged by this team */ var string ChallengedBy; /** the penalty we pay when we cancel the challenge */ var int CancelPenalty; var array<CacheManager.MapRecord> MapData; /** The two maps to choose from */ var CacheManager.MapRecord MapOptions[2]; /** PrizeMoney = enemy team size * this number */ var int BasePrizeMoney; /** This is added to the base price money after it has been multiplied with a random float */ var int VarPrizeMoney; struct ChallengeGameType { var string GameType; var string ExtraUrl; var int MaxBots; var string MapAcronym; var string MapPrefix; var int BaseGoalScore; var int VarGoalScore; }; /** Possible challenge matches */ var array<ChallengeGameType> ChallengeGames; /** localized names for the above types */ var localized array<string> ChallengeGameNames; var localized string PenaltyWarning, ChallengeDescription, ChallengedDescription, NotEnoughCash, YouveBeenChallenged, PlayTitle; /** always append this to the url */ var string DefaultUrl; function InitComponent(GUIController MyController, GUIComponent MyOwner) { local int i; Super.Initcomponent(MyController, MyOwner); GP = UT2K4GameProfile(PlayerOwner().Level.Game.CurrentGameProfile); for (i = 0; i < ChallengeGames.length; i++) { cbGameType.AddItem(ChallengeGameNames[i]); } for ( i = 0; i < Controls.Length; i++ ) { Controls[i].bScaleToParent=True; Controls[i].bBoundToParent=True; } cbGameType.SetIndex(rand(ChallengeGames.length)); // get an random game cbEnemyTeam.MyComboBox.List.Sort(); cbEnemyTeam.SetIndex(0); cbGameType.Edit.FontScale = cbGameType.FontScale; cbGameType.Edit.CaptionAlign = TXTA_Center; cbGameType.List.FontScale = cbGameType.FontScale; cbGameType.List.TextAlign = TXTA_Center; SetupNoPreview(lblNoPreview1, imgMap1); SetupNoPreview(lblNoPreview2, imgMap2); } function GetGame(int index, optional bool noRecreateEnemies) { local int j, n; local string tmp; local class<UT2K4TeamRoster> ET; GP.bIsChallenge = true; lblGameDescription.Caption = ChallengeGameNames[index]; // get two random maps MapData.length = 0; class'CacheManager'.static.GetMapList(MapData, ChallengeGames[index].MapAcronym); if (ChallengeGames[index].MapPrefix != "") // check optional prefix { for (n = MapData.length-1; n >= 0; n--) { if (Left(MapData[n].MapName, Len(ChallengeGames[index].MapPrefix)) ~= ChallengeGames[index].MapPrefix) { continue; } MapData.Remove(n, 1); } } for (n = 0; n < 2; n++) { do { if (MapData.length == 0) break; j = rand(MapData.length); MapOptions[n] = MapData[j]; //Log("Map select"@n@"="@MapOptions[n].MapName); //Log(MapOptions[n].PlayerCountMin@MapOptions[n].PlayerCountMax@ChallengeGames[index].MaxBots); MapData.Remove(j, 1); } until (((ChallengeGames[index].MaxBots+1) >= MapOptions[n].PlayerCountMin) && ((ChallengeGames[index].MaxBots+1) <= MapOptions[n].PlayerCountMax)); } if (MapOptions[0].ScreenshotRef != "") imgMap1.Image = Material(DynamicLoadObject(MapOptions[0].ScreenshotRef, class'Material')); else imgMap1.Image = None; imgMap1.SetVisibility(imgMap1.Image != None); lblNoPreview1.SetVisibility(imgMap1.Image == None); if (MapOptions[1].ScreenshotRef != "") imgMap2.Image = Material(DynamicLoadObject(MapOptions[1].ScreenshotRef, class'Material')); else imgMap2.Image = None; imgMap2.SetVisibility(imgMap2.Image != None); lblNoPreview2.SetVisibility(imgMap2.Image == None); cbMap1.Caption = PlayTitle@MapOptions[0].MapName; cbMap2.Caption = PlayTitle@MapOptions[1].MapName; GP.ChallengeInfo = new(GP) class'UT2K4MatchInfo'; GP.ChallengeInfo.NumBots = ChallengeGames[index].MaxBots; GP.ChallengeInfo.URLString = DefaultUrl$ChallengeGames[index].ExtraUrl; GP.ChallengeInfo.GameType = ChallengeGames[index].GameType; BasePrizeMoney += VarPrizeMoney*frand(); GP.ChallengeInfo.PrizeMoney = (GP.GetNumTeammatesForMatch()+1.5)*BasePrizeMoney; GP.ChallengeInfo.EntryFee = 0.5*BasePrizeMoney; // half the base price GP.ChallengeInfo.GoalScore = ChallengeGames[index].BaseGoalScore+(ChallengeGames[index].VarGoalScore*frand()); tmp = repl(ChallengeDescription, "%entryfee%", GP.MoneyToString(GP.ChallengeInfo.EntryFee)); tmp = repl(tmp, "%PrizeMoney%", GP.MoneyToString(GP.ChallengeInfo.PrizeMoney)); tmp = repl(tmp, "%balance%", GP.MoneyToString(GP.Balance)); sbDetails.SetContent(tmp); // Get enemies if (!noRecreateEnemies) { cbEnemyTeam.MyComboBox.List.Clear(); for (j = 0; j < GP.TeamStats.length; j++) { if (GP.TeamStats[j].Matches > 0) { if ((GP.TeamStats[j].Level >=3) && (GP.ChallengeInfo.NumBots == 1)) continue; // never add strong team in 1vs1 ET = class<UT2K4TeamRoster>(DynamicLoadObject(GP.TeamStats[j].Name, class'Class')); cbEnemyTeam.AddItem(ET.Default.TeamName,,GP.TeamStats[j].Name); } } } if (cbMap1.bChecked) OnMapSelect(cbMap1); else if (cbMap2.bChecked) OnMapSelect(cbMap2); GP.bIsChallenge = false; } event HandleParameters(string Param1, string Param2) { local string tmp; local int i, teampos; local GUIQuestionPage QPage; local GUIController MyController; if (GP.ChallengeInfo.EntryFee > GP.Balance) { MyController = Controller; Controller.CloseMenu(true); if (MyController.OpenMenu("GUI2K4.GUI2K4QuestionPage")) { QPage=GUIQuestionPage(MyController.TopPage()); QPage.SetupQuestion(NotEnoughCash, QBTN_Ok, QBTN_Ok); } return; } if (Param1 != "") { i = cbEnemyTeam.FindExtra(Param1); if (i > -1) { teampos = GP.GetTeamPosition(Param1); if (teampos > -1) { if (GP.TeamStats[teampos].Level >= 3) { while (GP.ChallengeInfo.NumBots == 1) GetGame(rand(ChallengeGames.length), true); // no 1vs1 against top team } } cbGameType.bVisible = false; cbEnemyTeam.SetIndex(i); lblTitle.Caption = YouveBeenChallenged; cbEnemyTeam.MenuStateChange(MSAT_Disabled); CancelPenalty = GP.ChallengeInfo.EntryFee; GP.ChallengeInfo.EntryFee = 0; tmp = repl(ChallengedDescription, "%entryfee%", GP.MoneyToString(GP.ChallengeInfo.EntryFee)); tmp = repl(tmp, "%PrizeMoney%", GP.MoneyToString(GP.ChallengeInfo.PrizeMoney)); tmp = repl(tmp, "%enemyteam%", cbEnemyTeam.GetText()); tmp = repl(tmp, "%cancelfee%", GP.MoneyToString(CancelPenalty)); tmp = repl(tmp, "%balance%", GP.MoneyToString(GP.Balance)); sbDetails.SetContent(tmp); } } } /** Play the selected match, first check if we need to assign team mates */ function bool onOkClick(GUIComponent Sender) { if (GP != none) { GP.bIsChallenge = true; GP.ChallengeInfo.EnemyTeamName = cbEnemyTeam.GetExtra(); GP.EnemyTeam = GP.ChallengeInfo.EnemyTeamName; // Difficulty = Team Level / 1.2 (strongest team is level 3 -> 2.5) GP.ChallengeInfo.DifficultyModifier = GP.TeamStats[GP.GetTeamPosition(GP.ChallengeInfo.EnemyTeamName)].Level/1.2; // 1vs1 -> make enemy 33% stronger if (GP.ChallengeInfo.NumBots == 1) GP.ChallengeInfo.DifficultyModifier *= 1.33; GP.ChallengeInfo.SpecialEvent = ""; if (GP.GetNumTeammatesForMatch() > 0) { if (Controller.OpenMenu(TeamRoleWindow)) { RoleWindow = UT2K4SP_TeamRoles(Controller.TopPage()); RoleWindow.OnOkClick = StartMatch; } } else StartMatch(); } else Warn("GP != none"); return true; } /** Start the selected match */ function StartMatch() { local LevelInfo myLevel; GP.Balance -= GP.ChallengeInfo.EntryFee; myLevel = PlayerOwner().Level; GP.StartNewMatch ( -1, myLevel ); Controller.CloseAll(false,true); } /** Cancel button pressed */ function bool onCancelClick(GUIComponent Sender) { if (OnCanWindowClose(true)) return Controller.CloseMenu(true); else return false; } /** Player accepts to pay the penalty */ function OnConfirmCancel(byte bButton) { if (bButton == QBTN_Yes) { GP.Balance -= CancelPenalty; CancelPenalty = 0; //PlayerOwner().Level.Game.SavePackage(GP.PackageName); Controller.CloseMenu(true); } } function OnMapSelect(GUIComponent Sender) { if (Sender == cbMap1) { GP.ActiveMap = MapOptions[0]; cbMap1.bChecked = true; cbMap2.bChecked = false; } else { GP.ActiveMap = MapOptions[1]; cbMap1.bChecked = false; cbMap2.bChecked = true; } GP.ChallengeInfo.LevelName = GP.ActiveMap.MapName; if ((GP.ChallengeInfo.LevelName != "") && (GP.Balance > GP.ChallengeInfo.EntryFee)) btnOk.MenuStateChange(MSAT_Blurry); else btnOk.MenuStateChange(MSAT_Disabled); return; } function OnGameSelect(GUIComponent Sender) { GetGame(cbGameType.GetIndex()); } function OnWindowClose(optional Bool bCancelled) { GP.bIsChallenge = !bCancelled; } function bool OnCanWindowClose(optional Bool bCancelled) { local GUIQuestionPage QPage; if (!bCancelled) return true; if (CancelPenalty > 0) { if (Controller.OpenMenu("GUI2K4.GUI2K4QuestionPage")) { QPage=GUIQuestionPage(Controller.TopPage()); QPage.SetupQuestion(repl(PenaltyWarning, "%cancelpenalty%", GP.MoneyToString(CancelPenalty)), QBTN_YesNo, QBTN_No); QPage.OnButtonClick = OnConfirmCancel; } return false; } return true; } event SetVisibility(bool bIsVisible) { Super.SetVisibility(bIsVisible); if ( imgMap1 != None ) { imgMap1.SetVisibility(imgMap1.Image != None); if ( lblNoPreview1 != None ) lblNoPreview1.SetVisibility(imgMap1.Image == None); } if ( imgMap2 != None ) { imgMap2.SetVisibility(imgMap2.Image != None); if ( lblNoPreview2 != None ) lblNoPreview2.SetVisibility(imgMap2.Image == None); } } protected function SetupNoPreview( GUILabel lbl, GUIImage img ) { if ( lbl == None || img == None ) return; lbl.WinLeft = img.WinLeft; lbl.WinTop = img.WinTop; lbl.WinWidth = img.WinWidth; lbl.WinHeight = img.WinHeight; } defaultproperties { Begin Object Class=GUIButton Name=SPMbtnOk Caption="ACCEPT" WinWidth=0.222222 WinHeight=0.044444 WinLeft=0.710071 WinTop=0.887731 OnClick=onOkClick RenderWeight=0.2 FontScale=FNS_Small TabOrder=1 MenuState=MSAT_Disabled End Object btnOk=SPMbtnOk Begin Object Class=GUIButton Name=SPCbtnCancel Caption="REFUSE" WinWidth=0.222222 WinHeight=0.044444 WinLeft=0.050348 WinTop=0.887731 OnClick=onCancelClick RenderWeight=0.2 FontScale=FNS_Small TabOrder=2 End Object btnCancel=SPCbtnCancel Begin Object Class=GUILabel Name=SPClblTitle Caption="Challenge" WinWidth=0.862501 WinHeight=0.077500 WinLeft=0.067813 WinTop=0.017847 RenderWeight=0.2 StyleName="TextLabel" FontScale=FNS_Large TextALign=TXTA_Center End Object lblTitle=SPClblTitle Begin Object class=GUIImage name=SPCimgMapBg1 WinWidth=0.444444 WinHeight=0.333333 WinLeft=0.020833 WinTop=0.186308 RenderWeight=0.1 Image=Material'2K4Menus.Controls.sectionback' ImageStyle=ISTY_Scaled End Object imgMapBg1=SPCimgMapBg1 Begin Object class=GUIImage name=SPCimgMapBg2 WinWidth=0.444444 WinHeight=0.333333 WinLeft=0.534722 WinTop=0.186308 RenderWeight=0.1 Image=Material'2K4Menus.Controls.sectionback' ImageStyle=ISTY_Scaled End Object imgMapBg2=SPCimgMapBg2 Begin Object class=GUIImage name=SPCimgMap1 WinWidth=0.441667 WinHeight=0.312500 WinLeft=0.022222 WinTop=0.197531 RenderWeight=0.15 Image=Material'2K4Menus.Controls.sectionback' ImageStyle=ISTY_Scaled End Object imgMap1=SPCimgMap1 Begin Object class=GUIImage name=SPCimgMap2 WinWidth=0.441667 WinHeight=0.312500 WinLeft=0.536111 WinTop=0.197531 RenderWeight=0.15 Image=Material'2K4Menus.Controls.sectionback' ImageStyle=ISTY_Scaled End Object imgMap2=SPCimgMap2 Begin Object Class=GUILabel Name=SPClblGameDescription Caption="" WinWidth=0.862501 WinHeight=0.077500 WinLeft=0.067813 WinTop=0.101180 RenderWeight=0.2 StyleName="TextLabel" FontScale=FNS_Large TextALign=TXTA_Center End Object lblGameDescription=SPClblGameDescription Begin Object class=GUIComboBox Name=SPCcbGameType Hint="Select the game" WinWidth=0.958334 WinHeight=0.079167 WinLeft=0.019792 WinTop=0.097830 RenderWeight=0.21 FontScale=FNS_Large bReadOnly=true TabOrder=0 OnChange=OnGameSelect End Object cbGameType=SPCcbGameType Begin Object class=GUIGFXButton Name=SPCcbMap1 Caption="" WinWidth=0.444444 WinHeight=0.062500 WinLeft=0.020833 WinTop=0.519641 bCheckBox=true OnChange=OnMapSelect End Object cbMap1=SPCcbMap1 Begin Object class=GUIGFXButton Name=SPCcbMap2 Caption="" WinWidth=0.444444 WinHeight=0.062500 WinLeft=0.534722 WinTop=0.519641 bCheckBox=true OnChange=OnMapSelect End Object cbMap2=SPCcbMap2 Begin Object class=moComboBox Name=SPCcbEnemyTeam Caption="Challenge team:" Hint="Challenge this team for a match" bAutoSizeCaption=true WinWidth=0.952779 WinHeight=0.059722 WinLeft=0.024306 WinTop=0.594780 bReadOnly=true TabOrder=3 End Object cbEnemyTeam=SPCcbEnemyTeam Begin Object Class=GUIScrollTextBox Name=SPCsbDetails WinWidth=0.958334 WinHeight=0.211111 WinLeft=0.019792 WinTop=0.667977 RenderWeight=0.2 TabOrder=1 bNoTeletype=true StyleName="NoBackground" End Object sbDetails=SPCsbDetails Begin Object Class=GUILabel Name=NoPreview TextFont="UT2HeaderFont" TextAlign=TXTA_Center VertAlign=TXTA_Center bMultiline=True bTransparent=False TextColor=(R=247,G=255,B=0,A=255) Caption="No Preview Available" WinWidth=0.441667 WinHeight=0.312500 WinLeft=0.022222 WinTop=0.197531 End Object lblNoPreview1=NoPreview lblNoPreview2=NoPreview WinWidth=0.9 WinHeight=0.9 WinLeft=0.05 WinTop=0.05 OnClose=OnWindowClose OnCanClose=OnCanWindowClose PlayTitle="Play" TeamRoleWindow="GUI2K4.UT2K4SP_TeamRoles" YouveBeenChallenged="You've been challenged!" PenaltyWarning="When you refuse you will have to pay a penalty of %cancelpenalty%.||Are you sure you want to refuse?" ChallengeDescription="To enter this challenge you have to pay the entry fee of %entryfee%.|You can win %PrizeMoney% when you win this match.|Your current balance is %balance%." ChallengedDescription="You have been challenged by %enemyteam%.|You can win %PrizeMoney% when you defeat them.|When you don't accept this challenge you have to pay %cancelfee% to the opposing team.|Your current balance is %balance%." NotEnoughCash="You do not have enough money to challenge another team." DefaultUrl="?TeamScreen=true" BasePrizeMoney=400 VarPrizeMoney=100 ChallengeGameNames[0]="Team DeathMatch" ChallengeGames[0]=(GameType="xGame.xTeamGame",ExtraUrl="",MaxBots=5,MapAcronym="DM",MapPrefix="",BaseGoalScore=20,VarGoalScore=5) ChallengeGameNames[1]="1vs1 DeathMatch" ChallengeGames[1]=(GameType="xGame.xDeathmatch",ExtraUrl="",MaxBots=1,MapAcronym="DM",MapPrefix="DM-1on1",BaseGoalScore=10,VarGoalScore=5) ChallengeGameNames[2]="Mutant" ChallengeGames[2]=(GameType="BonusPack.xMutantGame",ExtraUrl="",MaxBots=4,MapAcronym="DM",MapPrefix="",BaseGoalScore=15,VarGoalScore=5) ChallengeGameNames[3]="Instagib Team DeathMatch" ChallengeGames[3]=(GameType="xGame.xTeamGame",ExtraUrl="?mutator=XGame.MutInstaGib",MaxBots=7,MapAcronym="DM",MapPrefix="",BaseGoalScore=30,VarGoalScore=10) } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |