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

From the Portal Wiki
Jump to navigation Jump to search
N/A1TauntList<- [
N/A2//0
N/A3"smallWave",
N/A4"highFive",
N/A5"not_used",
N/A6"rps",
N/A7//4
N/A8"laugh",
N/A9"robotDance",
N/A10//6
N/A11"teamtease",
N/A12"not_used",
N/A13"teamhug",
N/A14"trickfire",
N/A15]
N/A16 
N/A17 
N/A18function OpenHUBAreas()
N/A19{
N/A20 local numHighestActiveBranch = GetHighestActiveBranch();
N/A21 local numReturnToHub = GetGladosSpokenFlags(2);
N/A22 local bCameFromLastDLCMap = GetCameFromLastDLCMap();
N/A23 
N/A24 // If we transitioned from the last DLC map AND the num highest branch tells us we've not completed everything
N/A25 if( bCameFromLastDLCMap && numHighestActiveBranch != 7 )
N/A26 {
N/A27 // Remove the glados return speech relay so glados wont jeer the players for quitting
N/A28 // since they're returning to the hub after completing the DLC
N/A29 EntFire( "relay_ret_glados", "kill" )
N/A30 }
N/A31 
N/A32 if( GetHaveSeenDLCTubesReveal() == false )
N/A33 {
N/A34 EntFire( "relay_reveal_extra", "Enable", 0, 0 )
N/A35 SetHaveSeenDLCTubesReveal()
N/A36 }
N/A37 else
N/A38 {
N/A39 EntFire( "relay_quick_glados_extra", "Enable", 0, 0 )
N/A40 }
N/A41 
N/A42 EntFire( "counter_screen_flip", "SetMaxValueNoFire", numHighestActiveBranch, 0 )
N/A43 
N/A44 if ( numHighestActiveBranch == 1 )
N/A45 {
N/A46 if ( numReturnToHub & (1 << 0) )
N/A47 {
N/A48 //quick way
N/A49 EntFire( "counter_return_to_hub", "SetValue", "1", 0 )
N/A50 }
N/A51 else
N/A52 {
N/A53 //slow way
N/A54 EntFire( "counter_choose_course", "SetValue", "1", 0 )
N/A55 // remember we saw it
N/A56 AddGladosSpokenFlags( 2, 1 << 0 )
N/A57 }
N/A58 
N/A59 EntFire( "counter_music", "SetValue", "1", 0 )
N/A60 }
N/A61 else if ( numHighestActiveBranch == 2 )
N/A62 {
N/A63 if ( numReturnToHub & (1 << 1) )
N/A64 {
N/A65 //quick way
N/A66 EntFire( "counter_return_to_hub", "SetValue", "2", 0 )
N/A67 }
N/A68 else
N/A69 {
N/A70 //slow way
N/A71 EntFire( "counter_choose_course", "SetValue", "2", 0 )
N/A72 // remember we saw it
N/A73 AddGladosSpokenFlags( 2, 1 << 1 )
N/A74 }
N/A75 
N/A76 EntFire( "texture_course_01", "SetTextureIndex", "1", 3 )
N/A77 EntFire( "counter_music", "SetValue", "2", 0 )
N/A78 }
N/A79 else if ( numHighestActiveBranch == 3 )
N/A80 {
N/A81 if ( numReturnToHub & (1 << 2) )
N/A82 {
N/A83 //quick way
N/A84 EntFire( "counter_return_to_hub", "SetValue", "3", 0 )
N/A85 }
N/A86 else
N/A87 {
N/A88 //slow way
N/A89 EntFire( "counter_choose_course", "SetValue", "3", 0 )
N/A90 // remember we saw it
N/A91 AddGladosSpokenFlags( 2, 1 << 2 )
N/A92 }
N/A93 
N/A94 EntFire( "texture_course_01", "SetTextureIndex", "2", 3 )
N/A95 EntFire( "texture_course_02", "SetTextureIndex", "1", 4 )
N/A96 EntFire( "counter_music", "SetValue", "3", 0 )
N/A97 }
N/A98 else if ( numHighestActiveBranch == 4 )
N/A99 {
N/A100 if ( numReturnToHub & (1 << 3) )
N/A101 {
N/A102 //quick way
N/A103 EntFire( "counter_return_to_hub", "SetValue", "4", 0 )
N/A104 }
N/A105 else
N/A106 {
N/A107 //slow way
N/A108 EntFire( "counter_choose_course", "SetValue", "4", 0 )
N/A109 // remember we saw it
N/A110 AddGladosSpokenFlags( 2, 1 << 3 )
N/A111 }
N/A112 
N/A113 EntFire( "texture_course_01", "SetTextureIndex", "2", 3 )
N/A114 EntFire( "texture_course_02", "SetTextureIndex", "2", 4 )
N/A115 EntFire( "texture_course_03", "SetTextureIndex", "1", 5 )
N/A116 EntFire( "counter_music", "SetValue", "4", 0 )
N/A117 }
N/A118 else if ( numHighestActiveBranch == 5 )
N/A119 {
N/A120 if ( numReturnToHub & (1 << 4) )
N/A121 {
N/A122 //quick way
N/A123 EntFire( "counter_return_to_hub", "SetValue", "5", 0 )
N/A124 }
N/A125 else
N/A126 {
N/A127 //slow way
N/A128 EntFire( "counter_choose_course", "SetValue", "5", 0 )
N/A129 // remember we saw it
N/A130 AddGladosSpokenFlags( 2, 1 << 4 )
N/A131 }
N/A132 
N/A133 EntFire( "texture_course_01", "SetTextureIndex", "2", 3 )
N/A134 EntFire( "texture_course_02", "SetTextureIndex", "2", 4 )
N/A135 EntFire( "texture_course_03", "SetTextureIndex", "2", 5 )
N/A136 EntFire( "texture_course_04", "SetTextureIndex", "1", 6 )
N/A137 EntFire( "counter_music", "SetValue", "5", 0 )
N/A138 }
N/A139 else if ( numHighestActiveBranch >= 6 )
N/A140 {
N/A141 EntFire( "counter_return_to_hub", "SetValue", "6", 0 )
N/A142 EntFire( "texture_course_01", "SetTextureIndex", "2", 3 )
N/A143 EntFire( "texture_course_02", "SetTextureIndex", "2", 4 )
N/A144 EntFire( "texture_course_03", "SetTextureIndex", "2", 5 )
N/A145 EntFire( "texture_course_04", "SetTextureIndex", "2", 6 )
N/A146 
N/A147 if ( numHighestActiveBranch == 6 )
N/A148 {
N/A149 EntFire( "counter_music", "SetValue", "6", 0 )
N/A150 }
N/A151 else
N/A152 {
N/A153 EntFire( "counter_music", "SetValue", "7", 0 )
N/A154 }
N/A155 }
N/A156 
N/A157 // now grant taunts to players if they are playing with a partner who has unocked more courses than they have
N/A158 // they would have gotten the taunt when the course was unlocked for the first time,
N/A159 // but since it's skipped when playing with a more experienced partner, we need to give them silently here
N/A160 // check for the teamtease first
N/A161 if ( numHighestActiveBranch >= 3 )
N/A162 {
N/A163 // check if mp_coop_fan is NOT complete in course 2 by either player
N/A164 if ( IsPlayerLevelComplete( 0, 1, 7 ) == false || IsPlayerLevelComplete( 1, 1, 7 ) == false )
N/A165 {
N/A166 EntFire( "@command", "command", "mp_earn_taunt teamtease 1", 1.0 )
N/A167 //printl("!!=== SCRIPT trying to grant teamtease silently" )
N/A168 }
N/A169 }
N/A170 // now check the same thing for the laugh taunt
N/A171 if ( numHighestActiveBranch >= 2 )
N/A172 {
N/A173 // check if mp_coop_teambts is NOT complete in course 1
N/A174 if ( IsPlayerLevelComplete( 0, 0, 5 ) == false || IsPlayerLevelComplete( 1, 0, 5 ) == false )
N/A175 {
N/A176 EntFire( "@command", "command", "mp_earn_taunt laugh 1", 1.0 )
N/A177 //printl("!!=== SCRIPT trying to grant laugh silently" )
N/A178 }
N/A179 }
N/A180 
N/A181 EntFire( "counter_music", "GetValue", "", 1 )
N/A182 
N/A183 if ( numHighestActiveBranch >= 2 )
N/A184 {
N/A185 EntFire( "hint_zoom", "Enable", "", 0 )
N/A186 }
N/A187 
N/A188 // give each player an achievement if they finished the prior branch
N/A189 //TEAM_BUILDING
N/A190 if ( IsPlayerBranchComplete( 0, 0 ) )
N/A191 {
N/A192 RecordAchievementEvent( "ACH.TEAM_BUILDING", GetBluePlayerIndex() )
N/A193 }
N/A194 if ( IsPlayerBranchComplete( 1, 0 ) )
N/A195 {
N/A196 RecordAchievementEvent( "ACH.TEAM_BUILDING", GetOrangePlayerIndex() )
N/A197 }
N/A198 //MASS_AND_VELOCITY
N/A199 if ( IsPlayerBranchComplete( 0, 1 ) )
N/A200 {
N/A201 RecordAchievementEvent( "ACH.MASS_AND_VELOCITY", GetBluePlayerIndex() )
N/A202 }
N/A203 if ( IsPlayerBranchComplete( 1, 1 ) )
N/A204 {
N/A205 RecordAchievementEvent( "ACH.MASS_AND_VELOCITY", GetOrangePlayerIndex() )
N/A206 }
N/A207 //LIGHT BRIDGES
N/A208 if ( IsPlayerBranchComplete( 0, 2 ) )
N/A209 {
N/A210 RecordAchievementEvent( "ACH.HUG_NAME", GetBluePlayerIndex() )
N/A211 }
N/A212 if ( IsPlayerBranchComplete( 1, 2 ) )
N/A213 {
N/A214 RecordAchievementEvent( "ACH.HUG_NAME", GetOrangePlayerIndex() )
N/A215 }
N/A216 //EXCURSION_FUNNELS
N/A217 if ( IsPlayerBranchComplete( 0, 3 ) )
N/A218 {
N/A219 RecordAchievementEvent( "ACH.EXCURSION_FUNNELS", GetBluePlayerIndex() )
N/A220 }
N/A221 if ( IsPlayerBranchComplete( 1, 3 ) )
N/A222 {
N/A223 RecordAchievementEvent( "ACH.EXCURSION_FUNNELS", GetOrangePlayerIndex() )
N/A224 }
N/A225 
N/A226 for ( local i = 0; i < 5; i++ )
N/A227 {
N/A228 for ( local j = 0; j < 16; j++ )
N/A229 {
N/A230 if ( IsLevelComplete( i, j ) )
N/A231 {
N/A232 EntFire( "texture_level_complete" + i + "" + j, "SetTextureIndex", "1", 0 )
N/A233 }
N/A234 }
N/A235 
N/A236 local branch = i + 1
N/A237 
N/A238 if ( IsBranchComplete( i ) )
N/A239 {
N/A240 EntFire( "track" + branch + "-texture_toggle_door", "SetTextureIndex", "1", i + 3 )
N/A241 }
N/A242 }
N/A243 
N/A244 GrantGameCompleteAchievementHUB()
N/A245}
N/A246 
N/A247function CompleteFinalMap()
N/A248{
N/A249 MarkMapComplete( GetMapName() )
N/A250}
N/A251 
N/A252function GrantGameCompleteAchievementHUB()
N/A253{
N/A254 local bGameCompleteB = true
N/A255 local bGameCompleteO = true
N/A256 for ( local i = 0; i < 5; i++ )
N/A257 {
N/A258 if ( IsPlayerBranchComplete( 0, i ) == false )
N/A259 {
N/A260 bGameCompleteB = false
N/A261 //printl("!!=== bGameCompleteB = false --- not completed branch " + i )
N/A262 }
N/A263 if ( IsPlayerBranchComplete( 1, i ) == false )
N/A264 {
N/A265 bGameCompleteO = false
N/A266 }
N/A267 }
N/A268 
N/A269 if ( bGameCompleteB )
N/A270 {
N/A271 RecordAchievementEvent( "ACH.NEW_BLOOD", GetBluePlayerIndex() )
N/A272 RecordAchievementEvent( "AV_SHIRT1", GetBluePlayerIndex() )
N/A273 //printl("!!!!!!!!=== AWARDING END GAME ACHIEVEMENT!!!" )
N/A274 }
N/A275 if ( bGameCompleteO )
N/A276 {
N/A277 RecordAchievementEvent( "ACH.NEW_BLOOD", GetOrangePlayerIndex() )
N/A278 RecordAchievementEvent( "AV_SHIRT1", GetOrangePlayerIndex() )
N/A279 }
N/A280}
N/A281 
N/A282function GrantGameCompleteAchievement()
N/A283{
N/A284 // this was moved from the last map because the toast caused the bink movie's sound to echo on the 360!
N/A285 // it now lives in credits_coop.nut in CreditsGrantGameCompleteAchievement
N/A286}
N/A287 
N/A288function EarnTaunt( nTaunt )
N/A289{
N/A290 local TauntName = TauntList[nTaunt];
N/A291 if ( TauntName == "not_used" )
N/A292 return;
N/A293 
N/A294 local bGrantTauntB = true
N/A295 local bGrantTauntO = true
N/A296 
N/A297 if ( TauntName == "laugh" || TauntName == "teamtease" )
N/A298 {
N/A299 local nCourse = 0
N/A300 
N/A301 if ( TauntName == "laugh" )
N/A302 {
N/A303 nCourse = 1
N/A304 }
N/A305 else if ( TauntName == "teamtease" )
N/A306 {
N/A307 nCourse = 2
N/A308 }
N/A309 
N/A310 for ( local j = 0; j < 16; j++ )
N/A311 {
N/A312 if ( IsPlayerLevelComplete( 0, nCourse, j ) )
N/A313 {
N/A314 bGrantTauntB = false
N/A315 //printl("bGrantTauntB = false")
N/A316 }
N/A317 if ( IsPlayerLevelComplete( 1, nCourse, j ) )
N/A318 {
N/A319 bGrantTauntO = false
N/A320 //printl("bGrantTauntB = false")
N/A321 }
N/A322 }
N/A323 }
N/A324 
N/A325 if ( bGrantTauntB == false && bGrantTauntO == false )
N/A326 {
N/A327 //printl("Not granting " + TauntName + " because both players already have it")
N/A328 return
N/A329 }
N/A330 
N/A331 //printl("Earning " + TauntName)
N/A332 EntFire( "@command", "command", "mp_earn_taunt " + TauntName, 0.0 )
N/A333}
N/A334 
N/A335function TransitionToCredits()
N/A336{
N/A337 if ( IsLocalSplitScreen() )
N/A338 {
N/A339 EntFire( "@command", "Command", "changelevel mp_coop_credits", 0.1 )
N/A340 }
N/A341 else
N/A342 {
N/A343 EntFire( "@command", "Command", "changelevel mp_coop_credits", 0.0 )
N/A344 }
N/A345}
N/A346 
N/A347function CheckForNewTaunts()
N/A348{
N/A349}
0350 + true