Added helpful hints for first-time players!

TODO: Localize that!
master
Icedream 2016-04-03 13:18:22 +02:00
parent 8c86e26997
commit d51e711b7a
2 changed files with 233 additions and 1 deletions

View File

@ -3,6 +3,7 @@
#include maps\mp\perks\_perks;
#include maps\mp\gametypes\_hud_util;
#include maps\mp\mods\disableClassMenu;
#include maps\mp\mods\helpingHints;
// Rallypoints should be destroyed on leaving your team/getting killed
// Doesn't seem to be setting angle on spawn so that you are facing your rallypoint
@ -623,6 +624,7 @@ handleSeeker() {
player thread enableUnlimitedReload();
player thread enableWeaponDicing("+actionslot 3");
player thread giveHelpfulHintsForSeeker();
}
handleHider() {
@ -653,6 +655,7 @@ handleHider() {
player thread enableThirdPersonSwitch("+actionslot 3", 1);
player thread enableModelChange("+attack");
player thread giveHelpfulHintsForHider();
player thread revealWhenGameEnds();
if (!gameFlag("seekers_released"))
@ -898,4 +901,63 @@ revealWhenGameEnds()
}
}
/*
* Shows gametype-specific hints for the hider in order to teach them how to play.
*/
giveHelpfulHintsForHider()
{
player = self;
player endon("death");
player endon("disconnect");
level endon("game_ended");
gameFlagWait("prematch_done");
player thread clearHintsShownOnDisconnect();
player notifyOnPlayerCommand("hide_hint_for_disguise", "+attack");
player showHintOnce("Disguise yourself in the environment by changing into a prop on the map.\nLook at a prop and use [{+attack}] to do so.");
player waittill("hide_hint_for_disguise");
player notifyOnPlayerCommand("hide_hint_for_anglelock", "+melee");
player showHintOnce("Get into position then use [{+melee}] to lock your pose.\nUse [{+melee}] again later to unlock.");
player waittill("hide_hint_for_anglelock");
player notifyOnPlayerCommand("hide_hint_for_thirdperson", "+actionslot 3");
player showHintOnce("Toggle between first-person and third-person view using [{+actionslot 3}],\nthis will help you to change into other models.");
player waittill("hide_hint_for_thirdperson");
player hideHint();
}
/*
* Shows gametype-specific hints for the seeker in order to teach them how to play.
*/
giveHelpfulHintsForSeeker()
{
player = self;
player endon("death");
player endon("disconnect");
level endon("game_ended");
gameFlagWait("prematch_done");
gameFlagWait("seekers_released");
player thread clearHintsShownOnDisconnect();
player notifyOnPlayerCommand("hide_hint_for_primaryweapon", "+actionslot 3");
player showHintOnce("You can use [{+actionslot 3}] to get a new primary weapon.");
player waittill("hide_hint_for_primaryweapon");
player notifyOnPlayerCommand("hide_hint_for_reload", "+reload");
player showHintOnce("No need to care about ammo, you can reload endlessly as needed.");
player waittill("hide_hint_for_reload");
player notifyOnPlayerCommand("hide_hint_for_semtex", "+frag");
player showHintOnce("You have one Semtex on [{+frag}], don't waste it!");
player waittill("hide_hint_for_semtex");
player hideHint();
}

View File

@ -0,0 +1,170 @@
#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");
id = self getEntityNumber();
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(text)
{
logString("showHintOnce called");
id = self getEntityNumber();
if (!IsDefined(level.shownPlayerHints))
{
level.shownPlayerHints = [];
}
if (!IsDefined(level.shownPlayerHints[id]))
{
level.shownPlayerHints[id] = [];
}
if (!IsDefined(level.shownPlayerHints[id][text]) || !level.shownPlayerHints[id][text])
{
level.shownPlayerHints[id][text] = true;
self showHint(text);
}
else
{
self hideHint();
}
}
/*
* 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;
}