Template:PatchDiff/October 4, 2011 Patch/update/scripts/vscripts/debug scripts/mp coop transition list.nut

N/A 1 DBG <- 0  N/A 2    N/A 3 m_nLocalBranch <- 0   N/A 4    N/A 5 START_MAP <- "mp_coop_start"   N/A 6    N/A 7 HUB_MAP <- "mp_coop_lobby_2"   N/A 8 HUB_MAP3 <- "mp_coop_lobby_3"   N/A 9    N/A 10 DAY_ONE_START_MAP <- "mp_coop_doors"   N/A 11 DAY_ONE_END_MAP <- "mp_coop_teambts"   N/A 12 DAY_ONE_LENGTH <- 1   N/A 13    N/A 14 DAY_TWO_START_MAP <- "mp_coop_fling_3"   N/A 15 DAY_TWO_END_MAP <- "mp_coop_fan"   N/A 16 DAY_TWO_LENGTH <- 1   N/A 17    N/A 18 DAY_THREE_START_MAP <- "mp_coop_wall_intro"   N/A 19 DAY_THREE_END_MAP <- "mp_coop_wall_5"   N/A 20 DAY_THREE_LENGTH <- 1   N/A 21    N/A 22 DAY_FOUR_START_MAP <- "mp_coop_tbeam_redirect"   N/A 23 DAY_FOUR_END_MAP <- "mp_coop_tbeam_end"   N/A 24 DAY_FOUR_LENGTH <- 1   N/A 25    N/A 26 DAY_FIVE_START_MAP <- "mp_coop_paint_come_along"   N/A 27 DAY_FIVE_END_MAP <- "mp_coop_paint_longjump_intro"   N/A 28 DAY_FIVE_LENGTH <- 1   N/A 29    N/A 30 DAY_SIX_START_MAP <- "mp_coop_separation_1"   N/A 31 DAY_SIX_END_MAP <- "mp_coop_paint_crazy_box"   N/A 32 DAY_SIX_LENGTH <- 1   N/A 33    N/A 34 DAY_SEVEN_START_MAP <- "mp_coop_credits"        // We need this so that the length of day five is counted properly   N/A 35 DAY_SEVEN_END_MAP <- "mp_coop_credits"   N/A 36 DAY_SEVEN_LENGTH <- 1   N/A 37    N/A 38 LASTDLCMAP <- "mp_coop_paint_crazy_box"   N/A 39    N/A 40 MapPlayOrder<- [   N/A 41 // this is the order to play the multiplayer maps   N/A 42    N/A 43 //"mp_coop_mic_calibration",   N/A 44    N/A 45 // INTRO   N/A 46 "mp_coop_start",        // small wave   N/A 47 "mp_coop_lobby_2",          N/A 48 "mp_coop_lobby_3",          N/A 49 //HUB - high-5   N/A 50    N/A 51 // DAY 1 Start   N/A 52 //TEAMBUILDING   N/A 53 "mp_coop_doors",   N/A 54 "mp_coop_race_2",   N/A 55 "mp_coop_laser_2",   N/A 56 "mp_coop_rat_maze", //- RPS   N/A 57 "mp_coop_laser_crusher",   N/A 58 "mp_coop_teambts",   N/A 59 //HUB - laugh   N/A 60    N/A 61 // DAY 2 Start   N/A 62 //FLINGING   N/A 63 // "Mass and Velocity"   N/A 64 "mp_coop_fling_3",   N/A 65 "mp_coop_infinifling_train",   N/A 66 "mp_coop_come_along",   N/A 67 "mp_coop_fling_1",   N/A 68 "mp_coop_catapult_1", //- robotDance   N/A 69 "mp_coop_multifling_1",   N/A 70 "mp_coop_fling_crushers",   N/A 71 "mp_coop_fan",   N/A 72 //HUB - teamtease   N/A 73    N/A 74 // DAY 3 Start   N/A 75 //LIGHTBRIDGES   N/A 76 // "Hard-Light Surfaces"   N/A 77 "mp_coop_wall_intro",   N/A 78 "mp_coop_wall_2",   N/A 79 "mp_coop_catapult_wall_intro",   N/A 80 "mp_coop_wall_block",   N/A 81 "mp_coop_catapult_2",   N/A 82 "mp_coop_turret_walls",   N/A 83 "mp_coop_turret_ball",   N/A 84 "mp_coop_wall_5", //- teamhug   N/A 85    N/A 86 // DAY 4 Start   N/A 87 //TBEAM   N/A 88 // "Excursion Funnels"   N/A 89 "mp_coop_tbeam_redirect",   N/A 90 "mp_coop_tbeam_drill",   N/A 91 "mp_coop_tbeam_catch_grind_1", //- trickfire   N/A 92 "mp_coop_tbeam_laser_1",   N/A 93 "mp_coop_tbeam_polarity",   N/A 94 "mp_coop_tbeam_polarity2",   N/A 95 "mp_coop_tbeam_polarity3",   N/A 96 "mp_coop_tbeam_maze",   N/A 97 "mp_coop_tbeam_end",   N/A 98    N/A 99 // DAY 5 Start   N/A 100 //PAINT   N/A 101 // "Mobility Gels"   N/A 102 "mp_coop_paint_come_along",   N/A 103 "mp_coop_paint_redirect",   N/A 104 "mp_coop_paint_bridge",   N/A 105 "mp_coop_paint_walljumps",   N/A 106 "mp_coop_paint_speed_fling",   N/A 107 "mp_coop_paint_red_racer",   N/A 108 "mp_coop_paint_speed_catch",   N/A 109 "mp_coop_paint_longjump_intro",   N/A 110    N/A 111 // DAY DLC1 Start   N/A 112 //DLC1   N/A 113 "mp_coop_separation_1",   N/A 114 "mp_coop_tripleaxis",   N/A 115 "mp_coop_catapult_catch",   N/A 116 "mp_coop_2paints_1bridge",   N/A 117 "mp_coop_paint_conversion",   N/A 118 "mp_coop_bridge_catch",   N/A 119 "mp_coop_laser_tbeam",   N/A 120 "mp_coop_paint_rat_maze",   N/A 121 "mp_coop_paint_crazy_box",   N/A 122    N/A 123 // END OF LINE   N/A 124 //NOTHING   N/A 125 "mp_coop_credits"        // We need this so that the length of day five is counted properly   N/A 126 ]   N/A 127    N/A 128    N/A 129 //   N/A 130 // OnPostSpawn   N/A 131 //   N/A 132 function OnPostSpawn   N/A 133 {   N/A 134        local nBranch = 0   N/A 135        local daymapcount = 0   N/A 136        local mapcount = 0   N/A 137    N/A 138        if ( DBG )   N/A 139        {   N/A 140                printl("================DUMPING MAP PLAY ORDER")   N/A 141        }   N/A 142    N/A 143        AddBranchLevelName( 0, "CLEAR ALL" )   N/A 144    N/A 145        foreach( index, map in MapPlayOrder )   N/A 146        {          N/A 147                if( MapPlayOrder[index] == DAY_ONE_START_MAP )   N/A 148                {   N/A 149                        nBranch++   N/A 150                        daymapcount = 0   N/A 151    N/A 152                        if ( DBG )   N/A 153                        {   N/A 154                                printl( "=== Start of Track 1" )   N/A 155                        }   N/A 156                }   N/A 157                else if( MapPlayOrder[index] == DAY_TWO_START_MAP )   N/A 158                {   N/A 159                        nBranch++   N/A 160                        DAY_ONE_LENGTH = daymapcount   N/A 161                        daymapcount = 0   N/A 162    N/A 163                        if ( DBG )   N/A 164                        {   N/A 165                                printl( "< " + DAY_ONE_LENGTH + " levels in Track 1 >" )   N/A 166                                printl( "=== Start of Track 2" )   N/A 167                        }   N/A 168                }   N/A 169                else if( MapPlayOrder[index] == DAY_THREE_START_MAP )   N/A 170                {   N/A 171                        nBranch++   N/A 172                        DAY_TWO_LENGTH = daymapcount   N/A 173                        daymapcount = 0   N/A 174    N/A 175                        if ( DBG )   N/A 176                        {   N/A 177                                printl( "< " + DAY_TWO_LENGTH + " levels in Track 2 >" )   N/A 178                                printl( "=== Start of Track 3" )   N/A 179                        }   N/A 180                }   N/A 181                else if( MapPlayOrder[index] == DAY_FOUR_START_MAP )   N/A 182                {   N/A 183                        nBranch++   N/A 184                        DAY_THREE_LENGTH = daymapcount   N/A 185                        daymapcount = 0   N/A 186    N/A 187                        if ( DBG )   N/A 188                        {   N/A 189                                printl( "< " + DAY_THREE_LENGTH + " levels in Track 3 >" )   N/A 190                                printl( "=== Start of Track 4" )   N/A 191                        }   N/A 192                }   N/A 193                else if( MapPlayOrder[index] == DAY_FIVE_START_MAP )   N/A 194                {   N/A 195                        nBranch++   N/A 196                        DAY_FOUR_LENGTH = daymapcount   N/A 197                        daymapcount = 0   N/A 198    N/A 199                        if ( DBG )   N/A 200                        {   N/A 201                                printl( "< " + DAY_FOUR_LENGTH + " levels in Track 4 >" )   N/A 202                                printl( "=== Start of Track 5" )   N/A 203                        }   N/A 204                }   N/A 205                else if( MapPlayOrder[index] == DAY_SIX_START_MAP )   N/A 206                {   N/A 207                        nBranch++   N/A 208                        DAY_FIVE_LENGTH = daymapcount   N/A 209                        daymapcount = 0   N/A 210    N/A 211                        if ( DBG )   N/A 212                        {   N/A 213                                printl( "< " + DAY_FIVE_LENGTH + " levels in Track 5 >" )   N/A 214                                printl( "=== Start of Track 6" )   N/A 215                        }   N/A 216                }   N/A 217                else if( MapPlayOrder[index] == DAY_SEVEN_START_MAP )   N/A 218                {   N/A 219                        nBranch++   N/A 220                        DAY_SIX_LENGTH = daymapcount   N/A 221                        daymapcount = 0   N/A 222    N/A 223                        if ( DBG )   N/A 224                        {   N/A 225                                printl( "< " + DAY_SIX_LENGTH + " levels in Track 6 >" )   N/A 226                                printl( "=== Start of Track7" )   N/A 227                        }   N/A 228                }   N/A 229    N/A 230    N/A 231                if ( DBG )   N/A 232                {   N/A 233                        if( GetMapName == MapPlayOrder[index] )   N/A 234                        {   N/A 235                                printl( index + " " + MapPlayOrder[index] + " <--- You Are Here" )   N/A 236                        }   N/A 237                        else   N/A 238                        {   N/A 239                                printl( index + " " + MapPlayOrder[index] )   N/A 240                        }   N/A 241                }   N/A 242    N/A 243                AddBranchLevelName( nBranch, MapPlayOrder[index] )   N/A 244    N/A 245                if( MapPlayOrder[index] == DAY_SEVEN_END_MAP )   N/A 246                {   N/A 247                        nBranch++   N/A 248                        DAY_SEVEN_LENGTH = daymapcount+1   N/A 249                        daymapcount = 0   N/A 250    N/A 251                        if ( DBG )   N/A 252                        {   N/A 253                                printl( "< " + DAY_SEVEN_LENGTH + " levels in Track 7 >" )   N/A 254                                printl( "=== PLEASE DO NOT TEST ANY MAP BELOW THIS LINE ===" )   N/A 255                        }   N/A 256                }   N/A 257    N/A 258                mapcount++   N/A 259                daymapcount++          N/A 260        }   N/A 261    N/A 262        if ( DBG )   N/A 263        {   N/A 264                printl( mapcount + " maps total." )  N/A 265    N/A 266                printl("================END DUMP")   N/A 267        }   N/A 268 }   N/A 269    N/A 270 function MapPostLoaded   N/A 271 {   N/A 272 }   N/A 273    N/A 274 function SetMapBranchAndLevel   N/A 275 {   N/A 276        local nBranch = 0   N/A 277        local daymapcount = 1   N/A 278    N/A 279        foreach( index, map in MapPlayOrder )   N/A 280        {   N/A 281                local bResetDayMapCount = false   N/A 282                //printl( "= Branch: " + nBranch + ", Level: " + daymapcount )   N/A 283    N/A 284                if( MapPlayOrder[index] == DAY_ONE_START_MAP )   N/A 285                {   N/A 286                        nBranch++   N/A 287                        bResetDayMapCount = true   N/A 288                }   N/A 289                else if( MapPlayOrder[index] == DAY_TWO_START_MAP )   N/A 290                {   N/A 291                        nBranch++   N/A 292                        bResetDayMapCount = true   N/A 293                }   N/A 294                else if( MapPlayOrder[index] == DAY_THREE_START_MAP )   N/A 295                {   N/A 296                        nBranch++   N/A 297                        bResetDayMapCount = true   N/A 298                }   N/A 299                else if( MapPlayOrder[index] == DAY_FOUR_START_MAP )   N/A 300                {   N/A 301                        nBranch++   N/A 302                        bResetDayMapCount = true   N/A 303                }   N/A 304                else if( MapPlayOrder[index] == DAY_FIVE_START_MAP )   N/A 305                {   N/A 306                        nBranch++   N/A 307                        bResetDayMapCount = true   N/A 308                }   N/A 309                else if( MapPlayOrder[index] == DAY_SIX_START_MAP )   N/A 310                {   N/A 311                        nBranch++   N/A 312                        bResetDayMapCount = true   N/A 313                }   N/A 314                else if ( MapPlayOrder[index] == DAY_SEVEN_START_MAP )   N/A 315                {   N/A 316                        nBranch++   N/A 317                        bResetDayMapCount = true   N/A 318                }   N/A 319    N/A 320                // reset the daymap count   N/A 321                if ( bResetDayMapCount == true )   N/A 322                {   N/A 323                        daymapcount = 1   N/A 324                }   N/A 325    N/A 326                if( GetMapName == MapPlayOrder[index] )   N/A 327                {   N/A 328                        //printl( "################=== This is TRACK #" + nBranch + ", level " + daymapcount )   N/A 329                        EntFire( "@command", "command", "lobby_select_day " + nBranch, 0 )   N/A 330                        EntFire( "@command", "Command", "coop_lobby_select_level " + nBranch + " " + daymapcount + " 1", 0)          N/A 331                        return   N/A 332                }   N/A 333    N/A 334                daymapcount++   N/A 335        }   N/A 336 }   N/A 337    N/A 338 function SetCameFromLastDLCMapFlag   N/A 339 {   N/A 340        CoopSetCameFromLastDLCMap( LASTDLCMAP == GetMapName )   N/A 341 }   N/A 342    N/A 343 //   N/A 344 // TransitionFromMap   N/A 345 // TAUNTS -         highFive and smallWave already unlocked at the start in code   N/A 346 //                robotDance and thumbsUp already unlocked in mp_coop_lobby.nut file   N/A 347 //   N/A 348 function RealTransitionFromMap   N/A 349 {   N/A 350        SaveMPStatsData   N/A 351    N/A 352        MarkMapComplete( GetMapName )   N/A 353    N/A 354        SetCameFromLastDLCMapFlag   N/A 355    N/A 356        if( GetMapName == HUB_MAP || GetMapName == HUB_MAP3 )   N/A 357        {   N/A 358                TransitionToSection   N/A 359        }   N/A 360        else if( GetMapName == START_MAP ||   N/A 361                         GetMapName == DAY_ONE_END_MAP ||   N/A 362                         GetMapName == DAY_TWO_END_MAP ||   N/A 363                         GetMapName == DAY_THREE_END_MAP ||   N/A 364                         GetMapName == DAY_FOUR_END_MAP ||   N/A 365                         GetMapName == DAY_FIVE_END_MAP ||   N/A 366                         GetMapName == DAY_SIX_END_MAP ||   N/A 367                         GetMapName == DAY_SEVEN_END_MAP )   N/A 368        {   N/A 369                EntFire( "@command", "command", "go_to_hub", 1.0 )   N/A 370        }   N/A 371        else   N/A 372        {   N/A 373                local bInBranches = 0   N/A 374                foreach( index, map in MapPlayOrder )   N/A 375                {          N/A 376                        if( GetMapName == MapPlayOrder[index] )   N/A 377                        {                                  N/A 378                                if( index + 1 >= MapPlayOrder.len )   N/A 379                                {   N/A 380                                        if(DBG) printl( "Map " + GetMapName + " is the last map" )   N/A 381                                        EntFire( "end_of_playtest_text", "display", 0 )   N/A 382                                        EntFire( "@command", "command", "disconnect", 2.6 )   N/A 383                                }   N/A 384                                else   N/A 385                                {   N/A 386                                        if(DBG) printl( "Map " + GetMapName + " connects to " + MapPlayOrder[ index + 1 ] )   N/A 387                                        EntFire( "@command", "command", "changelevel " + MapPlayOrder[index + 1], 1.3 )   N/A 388                                }   N/A 389                                return   N/A 390                        }   N/A 391                }   N/A 392        }   N/A 393 }   N/A 394    N/A 395 //   N/A 396 // TransitionFromMap   N/A 397 //   N/A 398 function TransitionFromMap   N/A 399 {   N/A 400        if( GetMapName == HUB_MAP || GetMapName == HUB_MAP3 || GetMapName == START_MAP )   N/A 401        {   N/A 402                RealTransitionFromMap   N/A 403        }   N/A 404        else   N/A 405        {   N/A 406                // hack hack: display portal stat UI before level transition   N/A 407                EntFire( "portal_stats_controller", "OnLevelEnd", 5.0, 0 );   N/A 408        }   N/A 409 }   N/A 410    N/A 411 //   N/A 412 // TransitionToLevelFromHub   N/A 413 //   N/A 414 function TransitionToLevelFromHub( nBranch )   N/A 415 {   N/A 416        SaveMPStatsData   N/A 417    N/A 418        EntFire( "@command", "command", "lobby_select_day " + nBranch, 0 )   N/A 419    N/A 420        // Start the counter at just before the first track's first map   N/A 421        local nStartLevel = 0          N/A 422        foreach( index, map in MapPlayOrder )   N/A 423        {   N/A 424                if( DAY_ONE_START_MAP == MapPlayOrder[index] )   N/A 425                {   N/A 426                        nStartLevel--   N/A 427                        break   N/A 428                }   N/A 429                nStartLevel++   N/A 430        }   N/A 431    N/A 432        if ( nBranch > 1 )   N/A 433        {   N/A 434                nStartLevel = nStartLevel + DAY_ONE_LENGTH   N/A 435        }   N/A 436    N/A 437        if ( nBranch > 2 )   N/A 438        {   N/A 439                nStartLevel = nStartLevel + DAY_TWO_LENGTH   N/A 440        }   N/A 441    N/A 442        if ( nBranch > 3 )   N/A 443        {   N/A 444                nStartLevel = nStartLevel + DAY_THREE_LENGTH   N/A 445        }   N/A 446    N/A 447        if ( nBranch > 4 )   N/A 448        {   N/A 449                nStartLevel = nStartLevel + DAY_FOUR_LENGTH   N/A 450        }   N/A 451    N/A 452        if ( nBranch > 5 )   N/A 453        {   N/A 454                nStartLevel = nStartLevel + DAY_FIVE_LENGTH   N/A 455        }   N/A 456    N/A 457        if( nBranch > 6 )   N/A 458        {   N/A 459                nStartLevel = nStartLevel + DAY_SIX_LENGTH   N/A 460        }   N/A 461    N/A 462        if( nBranch > 7 )   N/A 463        {   N/A 464                nStartLevel = nStartLevel + DAY_SEVEN_LENGTH   N/A 465        }   N/A 466    N/A 467        if ( nBranch > 8 )   N/A 468        {   N/A 469                printl( "=== Branch is out of range!!!!!!!!!" )  N/A 470                return   N/A 471        }   N/A 472    N/A 473        local nCurrentLevel = GetCoopBranchLevelIndex( nBranch )   N/A 474        local index = nCurrentLevel + nStartLevel   N/A 475        if ( DBG )   N/A 476        {   N/A 477                printl( "=== Branch = " + nBranch + ", named " + MapPlayOrder[index] )   N/A 478                printl( "=== Going to Level #" + index + ", named " + MapPlayOrder[index] )   N/A 479        }   N/A 480        EntFire( "@command", "command", "changelevel " + MapPlayOrder[index], 0.5 )   N/A 481 }   N/A 482    N/A 483    N/A 484 //   N/A 485 // ReturnToHubFromLevel   N/A 486 //   N/A 487 function ReturnToHubFromLevel   N/A 488 {   N/A 489        if ( DBG )   N/A 490        {   N/A 491                printl( "=== RETURNING TO HUB" )   N/A 492        }   N/A 493    N/A 494        SetCameFromLastDLCMapFlag   N/A 495    N/A 496        SaveMPStatsData   N/A 497    N/A 498        EntFire( "@command", "command", "go_to_hub", 0.2 )   N/A 499 }   N/A 500    N/A 501 function CheckDayLights   N/A 502 {          N/A 503        local section = GetCoopSectionIndex   N/A 504    N/A 505        if( section == 1 )   N/A 506        {   N/A 507                EntFire( "light_day1", "TurnOn", "", 0.0 )   N/A 508        }   N/A 509        else   N/A 510        {   N/A 511                EntFire( "light_day1", "TurnOff", "", 0.0 )          N/A 512        }   N/A 513    N/A 514        if( section == 2 )   N/A 515        {   N/A 516                EntFire( "light_day2", "TurnOn", "", 0.0 )   N/A 517        }   N/A 518        else   N/A 519        {   N/A 520                EntFire( "light_day2", "TurnOff", "", 0.0 )          N/A 521        }   N/A 522    N/A 523        if( section == 3 )   N/A 524        {   N/A 525                EntFire( "light_day3", "TurnOn", "", 0.0 )   N/A 526        }   N/A 527        else   N/A 528        {   N/A 529                EntFire( "light_day3", "TurnOff", "", 0.0 )          N/A 530        }   N/A 531    N/A 532        if( section != 0 )   N/A 533        {   N/A 534                EntFire( "@exit_door_1", "Open", "", 0.0 )   N/A 535        }   N/A 536 }   N/A 537    N/A 538 function TransitionToSection   N/A 539 {          N/A 540        local section = GetCoopSectionIndex   N/A 541    N/A 542        if ( DBG )   N/A 543        {   N/A 544                printl("Transitioning " + section )   N/A 545        }   N/A 546    N/A 547        if( section == 0 )   N/A 548        {   N/A 549                EntFire( "@command", "command", "go_to_hub", 1.3 )   N/A 550        }   N/A 551        else if( section == 1 )   N/A 552        {   N/A 553                TransitionToDayOne   N/A 554        }   N/A 555        else if( section == 2 )   N/A 556        {   N/A 557                TransitionToDayTwo   N/A 558        }   N/A 559        else if( section == 3 )   N/A 560        {   N/A 561                TransitionToDayThree   N/A 562        }          N/A 563        else if( section == 4 )   N/A 564        {   N/A 565                TransitionToDayFour   N/A 566        }          N/A 567        else if( section == 5 )   N/A 568        {   N/A 569                TransitionToDayFive   N/A 570        }          N/A 571        else if( section == 6 )   N/A 572        {   N/A 573                TransitionToDaySix   N/A 574        }   N/A 575        else if( section == 7 )   N/A 576        {   N/A 577                TransitionToDaySeven   N/A 578        }   N/A 579 }   N/A 580    N/A 581    N/A 582 function TransitionToDayOne   N/A 583 {   N/A 584        EntFire( "@command", "command", "changelevel " + DAY_ONE_START_MAP, 0.1 )   N/A 585 }   N/A 586    N/A 587 function TransitionToDayTwo   N/A 588 {   N/A 589        EntFire( "@command", "command", "changelevel " + DAY_TWO_START_MAP, 0.1 )   N/A 590 }   N/A 591    N/A 592 function TransitionToDayThree   N/A 593 {   N/A 594        EntFire( "@command", "command", "changelevel " + DAY_THREE_START_MAP, 0.1 )   N/A 595 }   N/A 596    N/A 597 function TransitionToDayFour   N/A 598 {   N/A 599        EntFire( "@command", "command", "changelevel " + DAY_FOUR_START_MAP, 0.1 )   N/A 600 }   N/A 601    N/A 602 function TransitionToDayFive   N/A 603 {   N/A 604        EntFire( "@command", "command", "changelevel " + DAY_FIVE_START_MAP, 0.1 )   N/A 605 }   N/A 606    N/A 607 function TransitionToDaySix   N/A 608 {   N/A 609        EntFire( "@command", "command", "changelevel " + DAY_SIX_START_MAP, 0.1 )   N/A 610 }   N/A 611    N/A 612 function TransitionToDaySeven   N/A 613 {   N/A 614        EntFire( "@command", "command", "changelevel " + DAY_SEVEN_START_MAP, 0.1 )   N/A 615 }   N/A 616    N/A 617 ////////////////////////   N/A 618 // level select buttons   N/A 619 ////////////////////////   N/A 620    N/A 621 function SubtractLevelSelect( nBranch )   N/A 622 {   N/A 623        local nCurrentLevel = GetCoopBranchLevelIndex( nBranch )   N/A 624    N/A 625        local nNewLevel = nCurrentLevel - 1   N/A 626        local bContinue = true   N/A 627    N/A 628        while ( bContinue && nNewLevel > 1 && !IsLevelComplete( nBranch-1, nNewLevel-1 ) )   N/A 629        {   N/A 630                if ( nNewLevel > 1 && IsLevelComplete( nBranch-1, nNewLevel-2 ) )   N/A 631                {   N/A 632                        bContinue = false   N/A 633                }   N/A 634                else   N/A 635                {   N/A 636                        nNewLevel--   N/A 637                }   N/A 638        }   N/A 639    N/A 640        if ( DBG )   N/A 641        {   N/A 642                printl( "@=== Selecting Day " + nBranch + ", Level " + (nCurrentLevel - 1) )   N/A 643        }   N/A 644    N/A 645        if ( nNewLevel < 1 )   N/A 646        {   N/A 647                return   N/A 648        }   N/A 649    N/A 650        EntFire( "@command", "Command", "coop_lobby_select_level " + nBranch + " " + nNewLevel, 0)          N/A 651    N/A 652        local nMaxLevelsInDay = GetMaxLevelsInDay( nBranch )   N/A 653        UpdateLevelSelectButtons( nBranch, nNewLevel, nMaxLevelsInDay )   N/A 654 }   N/A 655    N/A 656 function AddLevelSelect( nBranch )   N/A 657 {   N/A 658        if ( nBranch < 1 )   N/A 659        {   N/A 660                return   N/A 661        }   N/A 662    N/A 663        local nCurrentLevel = GetCoopBranchLevelIndex( nBranch )   N/A 664        local nMaxLevelsInDay = GetMaxLevelsInDay( nBranch )   N/A 665    N/A 666        //printl( "=== Selecting Day " + nBranch + ", Level " + (nCurrentLevel + 1) )   N/A 667    N/A 668        //printl( "=== nMaxLevelsInDay = " + nMaxLevelsInDay )   N/A 669    N/A 670        local nNewLevel = nCurrentLevel + 1   N/A 671        local bContinue = true   N/A 672    N/A 673        while ( bContinue && nNewLevel <= nMaxLevelsInDay && !IsLevelComplete( nBranch-1, nNewLevel-1 ) )   N/A 674        {   N/A 675                if ( nNewLevel > 1 && IsLevelComplete( nBranch-1, nNewLevel-2 ) )   N/A 676                {   N/A 677                        bContinue = false   N/A 678                }   N/A 679                else   N/A 680                {   N/A 681                        nNewLevel++   N/A 682                }   N/A 683        }   N/A 684    N/A 685    N/A 686        if ( nNewLevel > nMaxLevelsInDay )   N/A 687        {   N/A 688                if ( DBG )   N/A 689                {   N/A 690                        printl( "nNewLevel (" + nNewLevel + ") > nMaxLevelsInDay (" + nMaxLevelsInDay + ")" )   N/A 691                }   N/A 692                return   N/A 693        }   N/A 694    N/A 695        UpdateLevelSelectButtons( nBranch, nNewLevel, nMaxLevelsInDay )   N/A 696    N/A 697        EntFire( "@command", "Command", "coop_lobby_select_level " + nBranch + " " + nNewLevel, 0)   N/A 698 }   N/A 699    N/A 700 function SubtractDLCSelect   N/A 701 {   N/A 702        EntFire( "@command", "Command", "coop_lobby_select_course -1" )   N/A 703        EntFire( "prop_button_L", "Skin", "1", 0 )   N/A 704        EntFire( "prop_button_R", "Skin", "1", 0 )   N/A 705 }   N/A 706    N/A 707 function AddDLCSelect   N/A 708 {   N/A 709        EntFire( "@command", "Command", "coop_lobby_select_course 1" )   N/A 710        EntFire( "prop_button_L", "Skin", "1", 0 )   N/A 711        EntFire( "prop_button_R", "Skin", "1", 0 )   N/A 712 }   N/A 713    N/A 714 //   N/A 715 // Sets the local branch #   N/A 716 //   N/A 717 function SetLocalBranchNumber( nBranch )   N/A 718 {   N/A 719        // this is to make sure that the client and server are on the same page   N/A 720        // and sets the selected level to the last in the track or first uncompleted   N/A 721        //printl( "^^^@=== SetLocalBranchNumber, setting to max in branch " + nBranch )   N/A 722        EntFire( "@command", "Command", "coop_lobby_select_level " + nBranch + " " + 99, 0)          N/A 723    N/A 724        if ( DBG )   N/A 725        {   N/A 726                printl( "Setting local branch to = " + nBranch )   N/A 727        }   N/A 728    N/A 729        m_nLocalBranch = nBranch   N/A 730        InitLevelSelectButtons( m_nLocalBranch )   N/A 731 }   N/A 732    N/A 733 function InitLevelSelectButtons( nBranch )   N/A 734 {   N/A 735        if ( nBranch < 1 && m_nLocalBranch < 1 )   N/A 736        {   N/A 737                printl( "nBranch and m_nLocalBranch is < 1 !!!!!" )  N/A 738                return   N/A 739        }   N/A 740    N/A 741        if ( nBranch < 1 )   N/A 742        {   N/A 743                nBranch = m_nLocalBranch;   N/A 744        }   N/A 745    N/A 746        if ( DBG )   N/A 747        {   N/A 748                printl( "*********CALLING InitLevelSelectButtons( " + nBranch + " )" )   N/A 749        }   N/A 750    N/A 751        local nCurrentLevel = GetCoopBranchLevelIndex( nBranch )   N/A 752        local nMaxLevelsInDay = GetMaxLevelsInDay( nBranch )   N/A 753    N/A 754        UpdateLevelSelectButtons( nBranch, nCurrentLevel, nMaxLevelsInDay )   N/A 755 }   N/A 756    N/A 757 function UpdateLevelSelectButtons( nBranch, nCurrentLevel, nMaxLevelsInDay )   N/A 758 {   N/A 759        if ( nCurrentLevel <= 1 )   N/A 760        {   N/A 761                // turn off the left light   N/A 762                EntFire( EntityGroup[0].GetName, "Skin", "1", 0)   N/A 763        }   N/A 764        else   N/A 765        {   N/A 766                // turn on the left light   N/A 767                EntFire( EntityGroup[0].GetName, "Skin", "0", 0)   N/A 768        }   N/A 769    N/A 770        //IsLevelComplete checks the data directly so we have to subtract one from the branch and level number   N/A 771        local bCurrentLevelIsComplete = IsLevelComplete( nBranch-1, nCurrentLevel-1 )   N/A 772        local bMoreLevelsComplete = false   N/A 773    N/A 774        if ( !bCurrentLevelIsComplete )   N/A 775        {   N/A 776                for ( local j = nCurrentLevel + 1; j < nMaxLevelsInDay; j++ )   N/A 777                {   N/A 778                        if ( IsLevelComplete( nBranch-1, j-1 ) )   N/A 779                        {   N/A 780                                bMoreLevelsComplete = true;   N/A 781                        }   N/A 782                }   N/A 783        }   N/A 784    N/A 785        if ( DBG )   N/A 786        {   N/A 787                printl( "bCurrentLevelIsComplete = " + bCurrentLevelIsComplete + "-- nCurrentLevel = " + nCurrentLevel + "-- nMaxLevelsInDay = " + nMaxLevelsInDay )   N/A 788        }   N/A 789    N/A 790        if ( ( bCurrentLevelIsComplete == false && !bMoreLevelsComplete ) || nCurrentLevel >= nMaxLevelsInDay )   N/A 791        {   N/A 792                // turn off the right light   N/A 793                EntFire( EntityGroup[1].GetName, "Skin", "1", 0)   N/A 794        }   N/A 795        else   N/A 796        {   N/A 797                // turn on the right light   N/A 798                EntFire( EntityGroup[1].GetName, "Skin", "0", 0)   N/A 799        }   N/A 800    N/A 801 }   N/A 802    N/A 803 function GetMaxLevelsInDay( nBranch )   N/A 804 {   N/A 805        local nMaxLevelsInDay = DAY_ONE_LENGTH   N/A 806    N/A 807        if ( nBranch == 2 )   N/A 808        {   N/A 809                nMaxLevelsInDay = DAY_TWO_LENGTH   N/A 810        }   N/A 811        else if ( nBranch == 3 )   N/A 812        {   N/A 813                nMaxLevelsInDay = DAY_THREE_LENGTH   N/A 814        }   N/A 815        else if ( nBranch == 4 )   N/A 816        {   N/A 817                nMaxLevelsInDay = DAY_FOUR_LENGTH   N/A 818        }   N/A 819        else if ( nBranch == 5 )   N/A 820        {   N/A 821                nMaxLevelsInDay = DAY_FIVE_LENGTH   N/A 822        }   N/A 823        else if ( nBranch == 6 )   N/A 824        {   N/A 825                nMaxLevelsInDay = DAY_SIX_LENGTH   N/A 826        }   N/A 827        else if ( nBranch == 7 )   N/A 828        {   N/A 829                nMaxLevelsInDay = DAY_SEVEN_LENGTH   N/A 830        }   N/A 831    N/A 832        return nMaxLevelsInDay   N/A 833 }