| 
									
										
										
										
											2016-04-03 11:18:22 +00:00
										 |  |  | #include common_scripts\utility; | 
					
						
							|  |  |  | #include maps\mp\_utility; | 
					
						
							|  |  |  | #include maps\mp\gametypes\_hud_util; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * Clears the memory of shown hints for a player once he disconnects. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | clearHintsShownOnDisconnect() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	logString("clearHintsShownOnDisconnect called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (IsDefined(self.clearHintsShownOnDisconnectThreadRunning) && self.clearHintsShownOnDisconnectThreadRunning) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	self.clearHintsShownOnDisconnectThreadRunning = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	id = self getEntityNumber(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	self waittill("disconnect"); | 
					
						
							|  |  |  | 	self clearHintsShownOnDisconnect(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * Clears the memory of shown hints for the player. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | clearHintsShown() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	logString("clearHintsShown called"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-07 15:36:21 +00:00
										 |  |  | 	id = self.guid; | 
					
						
							| 
									
										
										
										
											2016-04-03 11:18:22 +00:00
										 |  |  | 	if (!IsDefined(level.shownPlayerHints)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		level.shownPlayerHints = []; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (IsDefined(level.shownPlayerHints[id])) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		level.shownPlayerHints[id] = undefined; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * Displays a hint for the player (self) if it hasn't been shown before for him. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-04-08 16:53:44 +00:00
										 |  |  | showHintOnce(name, text) | 
					
						
							| 
									
										
										
										
											2016-04-03 11:18:22 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	logString("showHintOnce called"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-07 15:36:21 +00:00
										 |  |  | 	id = self.guid; | 
					
						
							| 
									
										
										
										
											2016-04-03 11:18:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (!IsDefined(level.shownPlayerHints)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		level.shownPlayerHints = []; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!IsDefined(level.shownPlayerHints[id])) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		level.shownPlayerHints[id] = []; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-08 16:53:44 +00:00
										 |  |  | 	if (!IsDefined(level.shownPlayerHints[id][name]) || !level.shownPlayerHints[id][name]) | 
					
						
							| 
									
										
										
										
											2016-04-03 11:18:22 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-04-08 16:53:44 +00:00
										 |  |  | 		level.shownPlayerHints[id][name] = true; | 
					
						
							| 
									
										
										
										
											2016-04-03 11:18:22 +00:00
										 |  |  | 		self showHint(text); | 
					
						
							| 
									
										
										
										
											2016-04-08 16:53:44 +00:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2016-04-03 11:18:22 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-08 16:53:44 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	self hideHint(); | 
					
						
							|  |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2016-04-03 11:18:22 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * Displays a small hint for the player (self) at the bottom of the screen. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | showHint(text) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	logString("showHint called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	player = self; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	player notify("hint_about_to_be_changed"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!IsDefined(player.hudHintElement)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		player.hudHintElement = createFontString("default", 1.5, player); // "default" | 
					
						
							|  |  |  | 		player.hudHintElement setPoint("BOTTOMRIGHT", "BOTTOMRIGHT", -96, -72); | 
					
						
							|  |  |  | 		player.hudHintElement.alpha = 0; | 
					
						
							|  |  |  | 		player.hudHintElement.hideWhenInMenu = true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		player fadeHint(0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	player.hudHintElement setText(text); | 
					
						
							|  |  |  | 	player fadeHint(1); | 
					
						
							|  |  |  | 	player thread hideHintInSeconds(15); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | hideHintInSeconds(time) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	logString("hideHintInSeconds called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	player = self; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	player endon("hint_about_to_be_changed"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	wait time; | 
					
						
							|  |  |  | 	player hideHint(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * Hides the hint message for the player (self). | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | hideHint() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	logString("hideHint called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	player = self; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!IsDefined(player.hudHintElement)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	player fadeHint(0); | 
					
						
							|  |  |  | 	player.hudHintElement destroyElem(); | 
					
						
							|  |  |  | 	player.hudHintElement = undefined; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | fadeHint(alpha, length) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	logString("fadeHint called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	player = self; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!IsDefined(player.hudHintElement)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (length == undefined) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		length = 0.33; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	interval = 0.05; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (player.hudHintElement.alpha < alpha) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// fade in | 
					
						
							|  |  |  | 		step = (alpha - player.hudHintElement.alpha) / (length / interval); | 
					
						
							|  |  |  | 		for (a = player.hudHintElement.alpha; a < alpha; a += step) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			player.hudHintElement.alpha = a; | 
					
						
							|  |  |  | 			wait interval; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// fade out | 
					
						
							|  |  |  | 		step = (player.hudHintElement.alpha - alpha) / (length / interval); | 
					
						
							|  |  |  | 		for (a = player.hudHintElement.alpha; a > alpha; a -= step) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			player.hudHintElement.alpha = a; | 
					
						
							|  |  |  | 			wait interval; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	player.hudHintElement.alpha = alpha; | 
					
						
							|  |  |  | } |