hide-and-seek/maps/mp/mods/helpingHints.gsc

170 lines
3.1 KiB
Plaintext
Raw Normal View History

#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;
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.
*/
showHintOnce(name, text)
{
logString("showHintOnce called");
2016-04-07 15:36:21 +00:00
id = self.guid;
if (!IsDefined(level.shownPlayerHints))
{
level.shownPlayerHints = [];
}
if (!IsDefined(level.shownPlayerHints[id]))
{
level.shownPlayerHints[id] = [];
}
if (!IsDefined(level.shownPlayerHints[id][name]) || !level.shownPlayerHints[id][name])
{
level.shownPlayerHints[id][name] = true;
self showHint(text);
return true;
}
self hideHint();
return false;
}
/*
* 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;
}