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 |
//============================================================================== // 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=GUIImage Name=SPCimgMap1 Image=Texture'2K4Menus.Controls.sectionback' ImageStyle=ISTY_Scaled WinTop=0.197531 WinLeft=0.022222 WinWidth=0.441667 WinHeight=0.312500 RenderWeight=0.150000 End Object imgMap1=GUIImage'GUI2K4.UT2K4SP_Challenge.SPCimgMap1' Begin Object Class=GUIImage Name=SPCimgMap2 Image=Texture'2K4Menus.Controls.sectionback' ImageStyle=ISTY_Scaled WinTop=0.197531 WinLeft=0.536111 WinWidth=0.441667 WinHeight=0.312500 RenderWeight=0.150000 End Object imgMap2=GUIImage'GUI2K4.UT2K4SP_Challenge.SPCimgMap2' Begin Object Class=GUIImage Name=SPCimgMapBg1 Image=Texture'2K4Menus.Controls.sectionback' ImageStyle=ISTY_Scaled WinTop=0.186308 WinLeft=0.020833 WinWidth=0.444444 WinHeight=0.333333 End Object imgMapBg1=GUIImage'GUI2K4.UT2K4SP_Challenge.SPCimgMapBg1' Begin Object Class=GUIImage Name=SPCimgMapBg2 Image=Texture'2K4Menus.Controls.sectionback' ImageStyle=ISTY_Scaled WinTop=0.186308 WinLeft=0.534722 WinWidth=0.444444 WinHeight=0.333333 End Object imgMapBg2=GUIImage'GUI2K4.UT2K4SP_Challenge.SPCimgMapBg2' Begin Object Class=GUIButton Name=SPMbtnOk Caption="ACCEPT" FontScale=FNS_Small WinTop=0.887731 WinLeft=0.710071 WinWidth=0.222222 WinHeight=0.044444 RenderWeight=0.200000 TabOrder=1 OnClick=UT2K4SP_Challenge.onOkClick OnKeyEvent=SPMbtnOk.InternalOnKeyEvent End Object btnOK=GUIButton'GUI2K4.UT2K4SP_Challenge.SPMbtnOk' Begin Object Class=GUIButton Name=SPCbtnCancel Caption="REFUSE" FontScale=FNS_Small WinTop=0.887731 WinLeft=0.050348 WinWidth=0.222222 WinHeight=0.044444 RenderWeight=0.200000 TabOrder=2 OnClick=UT2K4SP_Challenge.onCancelClick OnKeyEvent=SPCbtnCancel.InternalOnKeyEvent End Object btnCancel=GUIButton'GUI2K4.UT2K4SP_Challenge.SPCbtnCancel' Begin Object Class=GUILabel Name=SPClblTitle Caption="Challenge" TextAlign=TXTA_Center FontScale=FNS_Large StyleName="TextLabel" WinTop=0.017847 WinLeft=0.067813 WinWidth=0.862501 WinHeight=0.077500 RenderWeight=0.200000 End Object lblTitle=GUILabel'GUI2K4.UT2K4SP_Challenge.SPClblTitle' Begin Object Class=GUILabel Name=SPClblGameDescription TextAlign=TXTA_Center FontScale=FNS_Large StyleName="TextLabel" WinTop=0.101180 WinLeft=0.067813 WinWidth=0.862501 WinHeight=0.077500 RenderWeight=0.200000 End Object lblGameDescription=GUILabel'GUI2K4.UT2K4SP_Challenge.SPClblGameDescription' Begin Object Class=GUILabel Name=NoPreview Caption="No Preview Available" TextAlign=TXTA_Center TextColor=(B=0,G=255,R=247) TextFont="UT2HeaderFont" bTransparent=Falsch bMultiLine=Wahr VertAlign=TXTA_Center WinTop=0.197531 WinLeft=0.022222 WinWidth=0.441667 WinHeight=0.312500 End Object lblNoPreview1=GUILabel'GUI2K4.UT2K4SP_Challenge.NoPreview' lblNoPreview2=GUILabel'GUI2K4.UT2K4SP_Challenge.NoPreview' Begin Object Class=GUIComboBox Name=SPCcbGameType bReadOnly=Wahr FontScale=FNS_Large Hint="Select the game" WinTop=0.097830 WinLeft=0.019792 WinWidth=0.958334 WinHeight=0.079167 RenderWeight=0.210000 TabOrder=0 OnChange=UT2K4SP_Challenge.OnGameSelect OnKeyEvent=SPCcbGameType.InternalOnKeyEvent End Object cbGameType=GUIComboBox'GUI2K4.UT2K4SP_Challenge.SPCcbGameType' Begin Object Class=GUIGFXButton Name=SPCcbMap1 bCheckBox=Wahr WinTop=0.519641 WinLeft=0.020833 WinWidth=0.444444 WinHeight=0.062500 OnChange=UT2K4SP_Challenge.OnMapSelect OnKeyEvent=SPCcbMap1.InternalOnKeyEvent End Object cbMap1=GUIGFXButton'GUI2K4.UT2K4SP_Challenge.SPCcbMap1' Begin Object Class=GUIGFXButton Name=SPCcbMap2 bCheckBox=Wahr WinTop=0.519641 WinLeft=0.534722 WinWidth=0.444444 WinHeight=0.062500 OnChange=UT2K4SP_Challenge.OnMapSelect OnKeyEvent=SPCcbMap2.InternalOnKeyEvent End Object cbMap2=GUIGFXButton'GUI2K4.UT2K4SP_Challenge.SPCcbMap2' Begin Object Class=moComboBox Name=SPCcbEnemyTeam bReadOnly=Wahr Caption="Challenge team:" OnCreateComponent=SPCcbEnemyTeam.InternalOnCreateComponent Hint="Challenge this team for a match" WinTop=0.594780 WinLeft=0.024306 WinWidth=0.952779 WinHeight=0.059722 TabOrder=3 End Object cbEnemyTeam=moComboBox'GUI2K4.UT2K4SP_Challenge.SPCcbEnemyTeam' Begin Object Class=GUIScrollTextBox Name=SPCsbDetails bNoTeletype=Wahr OnCreateComponent=SPCsbDetails.InternalOnCreateComponent WinTop=0.667977 WinLeft=0.019792 WinWidth=0.958334 WinHeight=0.211111 RenderWeight=0.200000 TabOrder=1 End Object sbDetails=GUIScrollTextBox'GUI2K4.UT2K4SP_Challenge.SPCsbDetails' TeamRoleWindow="GUI2K4.UT2K4SP_TeamRoles" BasePrizeMoney=400 VarPrizeMoney=100 ChallengeGames(0)=(GameType="xGame.xTeamGame",maxbots=5,MapAcronym="DM",BaseGoalScore=20,VarGoalScore=5) ChallengeGames(1)=(GameType="xGame.xDeathmatch",maxbots=1,MapAcronym="DM",MapPrefix="DM-1on1",BaseGoalScore=10,VarGoalScore=5) ChallengeGames(2)=(GameType="BonusPack.xMutantGame",maxbots=4,MapAcronym="DM",BaseGoalScore=15,VarGoalScore=5) ChallengeGames(3)=(GameType="xGame.xTeamGame",ExtraUrl="?mutator=XGame.MutInstaGib",maxbots=7,MapAcronym="DM",BaseGoalScore=30,VarGoalScore=10) ChallengeGameNames(0)="Team DeathMatch" ChallengeGameNames(1)="1vs1 DeathMatch" ChallengeGameNames(2)="Mutant" ChallengeGameNames(3)="Instagib Team DeathMatch" 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." YouveBeenChallenged="You've been challenged!" PlayTitle="Play" DefaultUrl="?TeamScreen=true" OnClose=UT2K4SP_Challenge.OnWindowClose OnCanClose=UT2K4SP_Challenge.OnCanWindowClose WinTop=0.050000 WinLeft=0.050000 WinWidth=0.900000 WinHeight=0.900000 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |