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

From the Portal Wiki
Jump to navigation Jump to search
N/A1DBG <- 0
N/A2 
N/A3m_nLocalBranch <- 0
N/A4 
N/A5START_MAP <- "mp_coop_start"
N/A6 
N/A7HUB_MAP <- "mp_coop_lobby_2"
N/A8HUB_MAP3 <- "mp_coop_lobby_3"
N/A9 
N/A10DAY_ONE_START_MAP <- "mp_coop_doors"
N/A11DAY_ONE_END_MAP <- "mp_coop_teambts"
N/A12DAY_ONE_LENGTH <- 1
N/A13 
N/A14DAY_TWO_START_MAP <- "mp_coop_fling_3"
N/A15DAY_TWO_END_MAP <- "mp_coop_fan"
N/A16DAY_TWO_LENGTH <- 1
N/A17 
N/A18DAY_THREE_START_MAP <- "mp_coop_wall_intro"
N/A19DAY_THREE_END_MAP <- "mp_coop_wall_5"
N/A20DAY_THREE_LENGTH <- 1
N/A21 
N/A22DAY_FOUR_START_MAP <- "mp_coop_tbeam_redirect"
N/A23DAY_FOUR_END_MAP <- "mp_coop_tbeam_end"
N/A24DAY_FOUR_LENGTH <- 1
N/A25 
N/A26DAY_FIVE_START_MAP <- "mp_coop_paint_come_along"
N/A27DAY_FIVE_END_MAP <- "mp_coop_paint_longjump_intro"
N/A28DAY_FIVE_LENGTH <- 1
N/A29 
N/A30DAY_SIX_START_MAP <- "mp_coop_separation_1"
N/A31DAY_SIX_END_MAP <- "mp_coop_paint_crazy_box"
N/A32DAY_SIX_LENGTH <- 1
N/A33 
N/A34DAY_SEVEN_START_MAP <- "mp_coop_credits" // We need this so that the length of day five is counted properly
N/A35DAY_SEVEN_END_MAP <- "mp_coop_credits"
N/A36DAY_SEVEN_LENGTH <- 1
N/A37 
N/A38LASTDLCMAP <- "mp_coop_paint_crazy_box"
N/A39 
N/A40MapPlayOrder<- [
N/A41// this is the order to play the multiplayer maps
N/A42 
N/A43//"mp_coop_mic_calibration",
N/A44 
N/A45// INTRO
N/A46"mp_coop_start", // small wave
N/A47"mp_coop_lobby_2",
N/A48"mp_coop_lobby_3",
N/A49//HUB - high-5
N/A50 
N/A51// DAY 1 Start
N/A52//----TEAMBUILDING----
N/A53"mp_coop_doors",
N/A54"mp_coop_race_2",
N/A55"mp_coop_laser_2",
N/A56"mp_coop_rat_maze", //- RPS
N/A57"mp_coop_laser_crusher",
N/A58"mp_coop_teambts",
N/A59//HUB - laugh
N/A60 
N/A61// DAY 2 Start
N/A62//----FLINGING----
N/A63// "Mass and Velocity"
N/A64"mp_coop_fling_3",
N/A65"mp_coop_infinifling_train",
N/A66"mp_coop_come_along",
N/A67"mp_coop_fling_1",
N/A68"mp_coop_catapult_1", //- robotDance
N/A69"mp_coop_multifling_1",
N/A70"mp_coop_fling_crushers",
N/A71"mp_coop_fan",
N/A72//HUB - teamtease
N/A73 
N/A74// DAY 3 Start
N/A75//----LIGHTBRIDGES----
N/A76// "Hard-Light Surfaces"
N/A77"mp_coop_wall_intro",
N/A78"mp_coop_wall_2",
N/A79"mp_coop_catapult_wall_intro",
N/A80"mp_coop_wall_block",
N/A81"mp_coop_catapult_2",
N/A82"mp_coop_turret_walls",
N/A83"mp_coop_turret_ball",
N/A84"mp_coop_wall_5", //- teamhug
N/A85 
N/A86// DAY 4 Start
N/A87//----TBEAM----
N/A88// "Excursion Funnels"
N/A89"mp_coop_tbeam_redirect",
N/A90"mp_coop_tbeam_drill",
N/A91"mp_coop_tbeam_catch_grind_1", //- trickfire
N/A92"mp_coop_tbeam_laser_1",
N/A93"mp_coop_tbeam_polarity",
N/A94"mp_coop_tbeam_polarity2",
N/A95"mp_coop_tbeam_polarity3",
N/A96"mp_coop_tbeam_maze",
N/A97"mp_coop_tbeam_end",
N/A98 
N/A99// DAY 5 Start
N/A100//----PAINT----
N/A101// "Mobility Gels"
N/A102"mp_coop_paint_come_along",
N/A103"mp_coop_paint_redirect",
N/A104"mp_coop_paint_bridge",
N/A105"mp_coop_paint_walljumps",
N/A106"mp_coop_paint_speed_fling",
N/A107"mp_coop_paint_red_racer",
N/A108"mp_coop_paint_speed_catch",
N/A109"mp_coop_paint_longjump_intro",
N/A110 
N/A111// DAY DLC1 Start
N/A112//----DLC1----
N/A113"mp_coop_separation_1",
N/A114"mp_coop_tripleaxis",
N/A115"mp_coop_catapult_catch",
N/A116"mp_coop_2paints_1bridge",
N/A117"mp_coop_paint_conversion",
N/A118"mp_coop_bridge_catch",
N/A119"mp_coop_laser_tbeam",
N/A120"mp_coop_paint_rat_maze",
N/A121"mp_coop_paint_crazy_box",
N/A122 
N/A123// END OF LINE
N/A124//----NOTHING----
N/A125"mp_coop_credits" // We need this so that the length of day five is counted properly
N/A126]
N/A127 
N/A128 
N/A129// --------------------------------------------------------
N/A130// OnPostSpawn
N/A131// --------------------------------------------------------
N/A132function OnPostSpawn()
N/A133{
N/A134 local nBranch = 0
N/A135 local daymapcount = 0
N/A136 local mapcount = 0
N/A137 
N/A138 if ( DBG )
N/A139 {
N/A140 printl("================DUMPING MAP PLAY ORDER")
N/A141 }
N/A142 
N/A143 AddBranchLevelName( 0, "CLEAR ALL" )
N/A144 
N/A145 foreach( index, map in MapPlayOrder )
N/A146 {
N/A147 if( MapPlayOrder[index] == DAY_ONE_START_MAP )
N/A148 {
N/A149 nBranch++
N/A150 daymapcount = 0
N/A151 
N/A152 if ( DBG )
N/A153 {
N/A154 printl( "=== Start of Track 1" )
N/A155 }
N/A156 }
N/A157 else if( MapPlayOrder[index] == DAY_TWO_START_MAP )
N/A158 {
N/A159 nBranch++
N/A160 DAY_ONE_LENGTH = daymapcount
N/A161 daymapcount = 0
N/A162 
N/A163 if ( DBG )
N/A164 {
N/A165 printl( "< " + DAY_ONE_LENGTH + " levels in Track 1 >" )
N/A166 printl( "=== Start of Track 2" )
N/A167 }
N/A168 }
N/A169 else if( MapPlayOrder[index] == DAY_THREE_START_MAP )
N/A170 {
N/A171 nBranch++
N/A172 DAY_TWO_LENGTH = daymapcount
N/A173 daymapcount = 0
N/A174 
N/A175 if ( DBG )
N/A176 {
N/A177 printl( "< " + DAY_TWO_LENGTH + " levels in Track 2 >" )
N/A178 printl( "=== Start of Track 3" )
N/A179 }
N/A180 }
N/A181 else if( MapPlayOrder[index] == DAY_FOUR_START_MAP )
N/A182 {
N/A183 nBranch++
N/A184 DAY_THREE_LENGTH = daymapcount
N/A185 daymapcount = 0
N/A186 
N/A187 if ( DBG )
N/A188 {
N/A189 printl( "< " + DAY_THREE_LENGTH + " levels in Track 3 >" )
N/A190 printl( "=== Start of Track 4" )
N/A191 }
N/A192 }
N/A193 else if( MapPlayOrder[index] == DAY_FIVE_START_MAP )
N/A194 {
N/A195 nBranch++
N/A196 DAY_FOUR_LENGTH = daymapcount
N/A197 daymapcount = 0
N/A198 
N/A199 if ( DBG )
N/A200 {
N/A201 printl( "< " + DAY_FOUR_LENGTH + " levels in Track 4 >" )
N/A202 printl( "=== Start of Track 5" )
N/A203 }
N/A204 }
N/A205 else if( MapPlayOrder[index] == DAY_SIX_START_MAP )
N/A206 {
N/A207 nBranch++
N/A208 DAY_FIVE_LENGTH = daymapcount
N/A209 daymapcount = 0
N/A210 
N/A211 if ( DBG )
N/A212 {
N/A213 printl( "< " + DAY_FIVE_LENGTH + " levels in Track 5 >" )
N/A214 printl( "=== Start of Track 6" )
N/A215 }
N/A216 }
N/A217 else if( MapPlayOrder[index] == DAY_SEVEN_START_MAP )
N/A218 {
N/A219 nBranch++
N/A220 DAY_SIX_LENGTH = daymapcount
N/A221 daymapcount = 0
N/A222 
N/A223 if ( DBG )
N/A224 {
N/A225 printl( "< " + DAY_SIX_LENGTH + " levels in Track 6 >" )
N/A226 printl( "=== Start of Track7" )
N/A227 }
N/A228 }
N/A229 
N/A230 
N/A231 if ( DBG )
N/A232 {
N/A233 if( GetMapName() == MapPlayOrder[index] )
N/A234 {
N/A235 printl( index + " " + MapPlayOrder[index] + " <--- You Are Here" )
N/A236 }
N/A237 else
N/A238 {
N/A239 printl( index + " " + MapPlayOrder[index] )
N/A240 }
N/A241 }
N/A242 
N/A243 AddBranchLevelName( nBranch, MapPlayOrder[index] )
N/A244 
N/A245 if( MapPlayOrder[index] == DAY_SEVEN_END_MAP )
N/A246 {
N/A247 nBranch++
N/A248 DAY_SEVEN_LENGTH = daymapcount+1
N/A249 daymapcount = 0
N/A250 
N/A251 if ( DBG )
N/A252 {
N/A253 printl( "< " + DAY_SEVEN_LENGTH + " levels in Track 7 >" )
N/A254 printl( "=== PLEASE DO NOT TEST ANY MAP BELOW THIS LINE ===" )
N/A255 }
N/A256 }
N/A257 
N/A258 mapcount++
N/A259 daymapcount++
N/A260 }
N/A261 
N/A262 if ( DBG )
N/A263 {
N/A264 printl( mapcount + " maps total." )
N/A265 
N/A266 printl("================END DUMP")
N/A267 }
N/A268}
N/A269 
N/A270function MapPostLoaded()
N/A271{
N/A272}
N/A273 
N/A274function SetMapBranchAndLevel()
N/A275{
N/A276 local nBranch = 0
N/A277 local daymapcount = 1
N/A278 
N/A279 foreach( index, map in MapPlayOrder )
N/A280 {
N/A281 local bResetDayMapCount = false
N/A282 //printl( "= Branch: " + nBranch + ", Level: " + daymapcount )
N/A283 
N/A284 if( MapPlayOrder[index] == DAY_ONE_START_MAP )
N/A285 {
N/A286 nBranch++
N/A287 bResetDayMapCount = true
N/A288 }
N/A289 else if( MapPlayOrder[index] == DAY_TWO_START_MAP )
N/A290 {
N/A291 nBranch++
N/A292 bResetDayMapCount = true
N/A293 }
N/A294 else if( MapPlayOrder[index] == DAY_THREE_START_MAP )
N/A295 {
N/A296 nBranch++
N/A297 bResetDayMapCount = true
N/A298 }
N/A299 else if( MapPlayOrder[index] == DAY_FOUR_START_MAP )
N/A300 {
N/A301 nBranch++
N/A302 bResetDayMapCount = true
N/A303 }
N/A304 else if( MapPlayOrder[index] == DAY_FIVE_START_MAP )
N/A305 {
N/A306 nBranch++
N/A307 bResetDayMapCount = true
N/A308 }
N/A309 else if( MapPlayOrder[index] == DAY_SIX_START_MAP )
N/A310 {
N/A311 nBranch++
N/A312 bResetDayMapCount = true
N/A313 }
N/A314 else if ( MapPlayOrder[index] == DAY_SEVEN_START_MAP )
N/A315 {
N/A316 nBranch++
N/A317 bResetDayMapCount = true
N/A318 }
N/A319 
N/A320 // reset the daymap count
N/A321 if ( bResetDayMapCount == true )
N/A322 {
N/A323 daymapcount = 1
N/A324 }
N/A325 
N/A326 if( GetMapName() == MapPlayOrder[index] )
N/A327 {
N/A328 //printl( "################=== This is TRACK #" + nBranch + ", level " + daymapcount )
N/A329 EntFire( "@command", "command", "lobby_select_day " + nBranch, 0 )
N/A330 EntFire( "@command", "Command", "coop_lobby_select_level " + nBranch + " " + daymapcount + " 1", 0)
N/A331 return
N/A332 }
N/A333 
N/A334 daymapcount++
N/A335 }
N/A336}
N/A337 
N/A338function SetCameFromLastDLCMapFlag()
N/A339{
N/A340 CoopSetCameFromLastDLCMap( LASTDLCMAP == GetMapName() )
N/A341}
N/A342 
N/A343// --------------------------------------------------------
N/A344// TransitionFromMap
N/A345// TAUNTS - highFive and smallWave already unlocked at the start in code
N/A346// robotDance and thumbsUp already unlocked in mp_coop_lobby.nut file
N/A347// --------------------------------------------------------
N/A348function RealTransitionFromMap()
N/A349{
N/A350 SaveMPStatsData()
N/A351 
N/A352 MarkMapComplete( GetMapName() )
N/A353 
N/A354 SetCameFromLastDLCMapFlag()
N/A355 
N/A356 if( GetMapName() == HUB_MAP || GetMapName() == HUB_MAP3 )
N/A357 {
N/A358 TransitionToSection()
N/A359 }
N/A360 else if( GetMapName() == START_MAP ||
N/A361 GetMapName() == DAY_ONE_END_MAP ||
N/A362 GetMapName() == DAY_TWO_END_MAP ||
N/A363 GetMapName() == DAY_THREE_END_MAP ||
N/A364 GetMapName() == DAY_FOUR_END_MAP ||
N/A365 GetMapName() == DAY_FIVE_END_MAP ||
N/A366 GetMapName() == DAY_SIX_END_MAP ||
N/A367 GetMapName() == DAY_SEVEN_END_MAP )
N/A368 {
N/A369 EntFire( "@command", "command", "go_to_hub", 1.0 )
N/A370 }
N/A371 else
N/A372 {
N/A373 local bInBranches = 0
N/A374 foreach( index, map in MapPlayOrder )
N/A375 {
N/A376 if( GetMapName() == MapPlayOrder[index] )
N/A377 {
N/A378 if( index + 1 >= MapPlayOrder.len() )
N/A379 {
N/A380 if(DBG) printl( "Map " + GetMapName() + " is the last map" )
N/A381 EntFire( "end_of_playtest_text", "display", 0 )
N/A382 EntFire( "@command", "command", "disconnect", 2.6 )
N/A383 }
N/A384 else
N/A385 {
N/A386 if(DBG) printl( "Map " + GetMapName() + " connects to " + MapPlayOrder[ index + 1 ] )
N/A387 EntFire( "@command", "command", "changelevel " + MapPlayOrder[index + 1], 1.3 )
N/A388 }
N/A389 return
N/A390 }
N/A391 }
N/A392 }
N/A393}
N/A394 
N/A395// --------------------------------------------------------
N/A396// TransitionFromMap
N/A397// --------------------------------------------------------
N/A398function TransitionFromMap()
N/A399{
N/A400 if( GetMapName() == HUB_MAP || GetMapName() == HUB_MAP3 || GetMapName() == START_MAP )
N/A401 {
N/A402 RealTransitionFromMap()
N/A403 }
N/A404 else
N/A405 {
N/A406 // hack hack: display portal stat UI before level transition
N/A407 EntFire( "portal_stats_controller", "OnLevelEnd", 5.0, 0 );
N/A408 }
N/A409}
N/A410 
N/A411// --------------------------------------------------------
N/A412// TransitionToLevelFromHub
N/A413// --------------------------------------------------------
N/A414function TransitionToLevelFromHub( nBranch )
N/A415{
N/A416 SaveMPStatsData()
N/A417 
N/A418 EntFire( "@command", "command", "lobby_select_day " + nBranch, 0 )
N/A419 
N/A420 // Start the counter at just before the first track's first map
N/A421 local nStartLevel = 0
N/A422 foreach( index, map in MapPlayOrder )
N/A423 {
N/A424 if( DAY_ONE_START_MAP == MapPlayOrder[index] )
N/A425 {
N/A426 nStartLevel--
N/A427 break
N/A428 }
N/A429 nStartLevel++
N/A430 }
N/A431 
N/A432 if ( nBranch > 1 )
N/A433 {
N/A434 nStartLevel = nStartLevel + DAY_ONE_LENGTH
N/A435 }
N/A436 
N/A437 if ( nBranch > 2 )
N/A438 {
N/A439 nStartLevel = nStartLevel + DAY_TWO_LENGTH
N/A440 }
N/A441 
N/A442 if ( nBranch > 3 )
N/A443 {
N/A444 nStartLevel = nStartLevel + DAY_THREE_LENGTH
N/A445 }
N/A446 
N/A447 if ( nBranch > 4 )
N/A448 {
N/A449 nStartLevel = nStartLevel + DAY_FOUR_LENGTH
N/A450 }
N/A451 
N/A452 if ( nBranch > 5 )
N/A453 {
N/A454 nStartLevel = nStartLevel + DAY_FIVE_LENGTH
N/A455 }
N/A456 
N/A457 if( nBranch > 6 )
N/A458 {
N/A459 nStartLevel = nStartLevel + DAY_SIX_LENGTH
N/A460 }
N/A461 
N/A462 if( nBranch > 7 )
N/A463 {
N/A464 nStartLevel = nStartLevel + DAY_SEVEN_LENGTH
N/A465 }
N/A466 
N/A467 if ( nBranch > 8 )
N/A468 {
N/A469 printl( "=== Branch is out of range!!!!!!!!!" )
N/A470 return
N/A471 }
N/A472 
N/A473 local nCurrentLevel = GetCoopBranchLevelIndex( nBranch )
N/A474 local index = nCurrentLevel + nStartLevel
N/A475 if ( DBG )
N/A476 {
N/A477 printl( "=== Branch = " + nBranch + ", named " + MapPlayOrder[index] )
N/A478 printl( "=== Going to Level #" + index + ", named " + MapPlayOrder[index] )
N/A479 }
N/A480 EntFire( "@command", "command", "changelevel " + MapPlayOrder[index], 0.5 )
N/A481}
N/A482 
N/A483 
N/A484// --------------------------------------------------------
N/A485// ReturnToHubFromLevel
N/A486// --------------------------------------------------------
N/A487function ReturnToHubFromLevel()
N/A488{
N/A489 if ( DBG )
N/A490 {
N/A491 printl( "=== RETURNING TO HUB" )
N/A492 }
N/A493 
N/A494 SetCameFromLastDLCMapFlag()
N/A495 
N/A496 SaveMPStatsData()
N/A497 
N/A498 EntFire( "@command", "command", "go_to_hub", 0.2 )
N/A499}
N/A500 
N/A501function CheckDayLights()
N/A502{
N/A503 local section = GetCoopSectionIndex()
N/A504 
N/A505 if( section == 1 )
N/A506 {
N/A507 EntFire( "light_day1", "TurnOn", "", 0.0 )
N/A508 }
N/A509 else
N/A510 {
N/A511 EntFire( "light_day1", "TurnOff", "", 0.0 )
N/A512 }
N/A513 
N/A514 if( section == 2 )
N/A515 {
N/A516 EntFire( "light_day2", "TurnOn", "", 0.0 )
N/A517 }
N/A518 else
N/A519 {
N/A520 EntFire( "light_day2", "TurnOff", "", 0.0 )
N/A521 }
N/A522 
N/A523 if( section == 3 )
N/A524 {
N/A525 EntFire( "light_day3", "TurnOn", "", 0.0 )
N/A526 }
N/A527 else
N/A528 {
N/A529 EntFire( "light_day3", "TurnOff", "", 0.0 )
N/A530 }
N/A531 
N/A532 if( section != 0 )
N/A533 {
N/A534 EntFire( "@exit_door_1", "Open", "", 0.0 )
N/A535 }
N/A536}
N/A537 
N/A538function TransitionToSection()
N/A539{
N/A540 local section = GetCoopSectionIndex()
N/A541 
N/A542 if ( DBG )
N/A543 {
N/A544 printl("Transitioning " + section )
N/A545 }
N/A546 
N/A547 if( section == 0 )
N/A548 {
N/A549 EntFire( "@command", "command", "go_to_hub", 1.3 )
N/A550 }
N/A551 else if( section == 1 )
N/A552 {
N/A553 TransitionToDayOne()
N/A554 }
N/A555 else if( section == 2 )
N/A556 {
N/A557 TransitionToDayTwo()
N/A558 }
N/A559 else if( section == 3 )
N/A560 {
N/A561 TransitionToDayThree()
N/A562 }
N/A563 else if( section == 4 )
N/A564 {
N/A565 TransitionToDayFour()
N/A566 }
N/A567 else if( section == 5 )
N/A568 {
N/A569 TransitionToDayFive()
N/A570 }
N/A571 else if( section == 6 )
N/A572 {
N/A573 TransitionToDaySix()
N/A574 }
N/A575 else if( section == 7 )
N/A576 {
N/A577 TransitionToDaySeven()
N/A578 }
N/A579}
N/A580 
N/A581 
N/A582function TransitionToDayOne()
N/A583{
N/A584 EntFire( "@command", "command", "changelevel " + DAY_ONE_START_MAP, 0.1 )
N/A585}
N/A586 
N/A587function TransitionToDayTwo()
N/A588{
N/A589 EntFire( "@command", "command", "changelevel " + DAY_TWO_START_MAP, 0.1 )
N/A590}
N/A591 
N/A592function TransitionToDayThree()
N/A593{
N/A594 EntFire( "@command", "command", "changelevel " + DAY_THREE_START_MAP, 0.1 )
N/A595}
N/A596 
N/A597function TransitionToDayFour()
N/A598{
N/A599 EntFire( "@command", "command", "changelevel " + DAY_FOUR_START_MAP, 0.1 )
N/A600}
N/A601 
N/A602function TransitionToDayFive()
N/A603{
N/A604 EntFire( "@command", "command", "changelevel " + DAY_FIVE_START_MAP, 0.1 )
N/A605}
N/A606 
N/A607function TransitionToDaySix()
N/A608{
N/A609 EntFire( "@command", "command", "changelevel " + DAY_SIX_START_MAP, 0.1 )
N/A610}
N/A611 
N/A612function TransitionToDaySeven()
N/A613{
N/A614 EntFire( "@command", "command", "changelevel " + DAY_SEVEN_START_MAP, 0.1 )
N/A615}
N/A616 
N/A617////////////////////////
N/A618// level select buttons
N/A619////////////////////////
N/A620 
N/A621function SubtractLevelSelect( nBranch )
N/A622{
N/A623 local nCurrentLevel = GetCoopBranchLevelIndex( nBranch )
N/A624 
N/A625 local nNewLevel = nCurrentLevel - 1
N/A626 local bContinue = true
N/A627 
N/A628 while ( bContinue && nNewLevel > 1 && !IsLevelComplete( nBranch-1, nNewLevel-1 ) )
N/A629 {
N/A630 if ( nNewLevel > 1 && IsLevelComplete( nBranch-1, nNewLevel-2 ) )
N/A631 {
N/A632 bContinue = false
N/A633 }
N/A634 else
N/A635 {
N/A636 nNewLevel--
N/A637 }
N/A638 }
N/A639 
N/A640 if ( DBG )
N/A641 {
N/A642 printl( "----@=== Selecting Day " + nBranch + ", Level " + (nCurrentLevel - 1) )
N/A643 }
N/A644 
N/A645 if ( nNewLevel < 1 )
N/A646 {
N/A647 return
N/A648 }
N/A649 
N/A650 EntFire( "@command", "Command", "coop_lobby_select_level " + nBranch + " " + nNewLevel, 0)
N/A651 
N/A652 local nMaxLevelsInDay = GetMaxLevelsInDay( nBranch )
N/A653 UpdateLevelSelectButtons( nBranch, nNewLevel, nMaxLevelsInDay )
N/A654}
N/A655 
N/A656function AddLevelSelect( nBranch )
N/A657{
N/A658 if ( nBranch < 1 )
N/A659 {
N/A660 return
N/A661 }
N/A662 
N/A663 local nCurrentLevel = GetCoopBranchLevelIndex( nBranch )
N/A664 local nMaxLevelsInDay = GetMaxLevelsInDay( nBranch )
N/A665 
N/A666 //printl( "=== Selecting Day " + nBranch + ", Level " + (nCurrentLevel + 1) )
N/A667 
N/A668 //printl( "=== nMaxLevelsInDay = " + nMaxLevelsInDay )
N/A669 
N/A670 local nNewLevel = nCurrentLevel + 1
N/A671 local bContinue = true
N/A672 
N/A673 while ( bContinue && nNewLevel <= nMaxLevelsInDay && !IsLevelComplete( nBranch-1, nNewLevel-1 ) )
N/A674 {
N/A675 if ( nNewLevel > 1 && IsLevelComplete( nBranch-1, nNewLevel-2 ) )
N/A676 {
N/A677 bContinue = false
N/A678 }
N/A679 else
N/A680 {
N/A681 nNewLevel++
N/A682 }
N/A683 }
N/A684 
N/A685 
N/A686 if ( nNewLevel > nMaxLevelsInDay )
N/A687 {
N/A688 if ( DBG )
N/A689 {
N/A690 printl( "nNewLevel (" + nNewLevel + ") > nMaxLevelsInDay (" + nMaxLevelsInDay + ")" )
N/A691 }
N/A692 return
N/A693 }
N/A694 
N/A695 UpdateLevelSelectButtons( nBranch, nNewLevel, nMaxLevelsInDay )
N/A696 
N/A697 EntFire( "@command", "Command", "coop_lobby_select_level " + nBranch + " " + nNewLevel, 0)
N/A698}
N/A699 
N/A700function SubtractDLCSelect()
N/A701{
N/A702 EntFire( "@command", "Command", "coop_lobby_select_course -1" )
N/A703 EntFire( "prop_button_L", "Skin", "1", 0 )
N/A704 EntFire( "prop_button_R", "Skin", "1", 0 )
N/A705}
N/A706 
N/A707function AddDLCSelect()
N/A708{
N/A709 EntFire( "@command", "Command", "coop_lobby_select_course 1" )
N/A710 EntFire( "prop_button_L", "Skin", "1", 0 )
N/A711 EntFire( "prop_button_R", "Skin", "1", 0 )
N/A712}
N/A713 
N/A714// --------------------------------------------------------
N/A715// Sets the local branch #
N/A716// --------------------------------------------------------
N/A717function SetLocalBranchNumber( nBranch )
N/A718{
N/A719 // this is to make sure that the client and server are on the same page
N/A720 // and sets the selected level to the last in the track or first uncompleted
N/A721 //printl( "^^^@=== SetLocalBranchNumber, setting to max in branch " + nBranch )
N/A722 EntFire( "@command", "Command", "coop_lobby_select_level " + nBranch + " " + 99, 0)
N/A723 
N/A724 if ( DBG )
N/A725 {
N/A726 printl( "Setting local branch to = " + nBranch )
N/A727 }
N/A728 
N/A729 m_nLocalBranch = nBranch
N/A730 InitLevelSelectButtons( m_nLocalBranch )
N/A731}
N/A732 
N/A733function InitLevelSelectButtons( nBranch )
N/A734{
N/A735 if ( nBranch < 1 && m_nLocalBranch < 1 )
N/A736 {
N/A737 printl( "nBranch and m_nLocalBranch is < 1 !!!!!" )
N/A738 return
N/A739 }
N/A740 
N/A741 if ( nBranch < 1 )
N/A742 {
N/A743 nBranch = m_nLocalBranch;
N/A744 }
N/A745 
N/A746 if ( DBG )
N/A747 {
N/A748 printl( "*********CALLING InitLevelSelectButtons( " + nBranch + " )" )
N/A749 }
N/A750 
N/A751 local nCurrentLevel = GetCoopBranchLevelIndex( nBranch )
N/A752 local nMaxLevelsInDay = GetMaxLevelsInDay( nBranch )
N/A753 
N/A754 UpdateLevelSelectButtons( nBranch, nCurrentLevel, nMaxLevelsInDay )
N/A755}
N/A756 
N/A757function UpdateLevelSelectButtons( nBranch, nCurrentLevel, nMaxLevelsInDay )
N/A758{
N/A759 if ( nCurrentLevel <= 1 )
N/A760 {
N/A761 // turn off the left light
N/A762 EntFire( EntityGroup[0].GetName(), "Skin", "1", 0)
N/A763 }
N/A764 else
N/A765 {
N/A766 // turn on the left light
N/A767 EntFire( EntityGroup[0].GetName(), "Skin", "0", 0)
N/A768 }
N/A769 
N/A770 //IsLevelComplete checks the data directly so we have to subtract one from the branch and level number
N/A771 local bCurrentLevelIsComplete = IsLevelComplete( nBranch-1, nCurrentLevel-1 )
N/A772 local bMoreLevelsComplete = false
N/A773 
N/A774 if ( !bCurrentLevelIsComplete )
N/A775 {
N/A776 for ( local j = nCurrentLevel + 1; j < nMaxLevelsInDay; j++ )
N/A777 {
N/A778 if ( IsLevelComplete( nBranch-1, j-1 ) )
N/A779 {
N/A780 bMoreLevelsComplete = true;
N/A781 }
N/A782 }
N/A783 }
N/A784 
N/A785 if ( DBG )
N/A786 {
N/A787 printl( "bCurrentLevelIsComplete = " + bCurrentLevelIsComplete + "-- nCurrentLevel = " + nCurrentLevel + "-- nMaxLevelsInDay = " + nMaxLevelsInDay )
N/A788 }
N/A789 
N/A790 if ( ( bCurrentLevelIsComplete == false && !bMoreLevelsComplete ) || nCurrentLevel >= nMaxLevelsInDay )
N/A791 {
N/A792 // turn off the right light
N/A793 EntFire( EntityGroup[1].GetName(), "Skin", "1", 0)
N/A794 }
N/A795 else
N/A796 {
N/A797 // turn on the right light
N/A798 EntFire( EntityGroup[1].GetName(), "Skin", "0", 0)
N/A799 }
N/A800 
N/A801}
N/A802 
N/A803function GetMaxLevelsInDay( nBranch )
N/A804{
N/A805 local nMaxLevelsInDay = DAY_ONE_LENGTH
N/A806 
N/A807 if ( nBranch == 2 )
N/A808 {
N/A809 nMaxLevelsInDay = DAY_TWO_LENGTH
N/A810 }
N/A811 else if ( nBranch == 3 )
N/A812 {
N/A813 nMaxLevelsInDay = DAY_THREE_LENGTH
N/A814 }
N/A815 else if ( nBranch == 4 )
N/A816 {
N/A817 nMaxLevelsInDay = DAY_FOUR_LENGTH
N/A818 }
N/A819 else if ( nBranch == 5 )
N/A820 {
N/A821 nMaxLevelsInDay = DAY_FIVE_LENGTH
N/A822 }
N/A823 else if ( nBranch == 6 )
N/A824 {
N/A825 nMaxLevelsInDay = DAY_SIX_LENGTH
N/A826 }
N/A827 else if ( nBranch == 7 )
N/A828 {
N/A829 nMaxLevelsInDay = DAY_SEVEN_LENGTH
N/A830 }
N/A831 
N/A832 return nMaxLevelsInDay
N/A833}