From d51e711b7a59f76f39f27f0464c86459ef6a55d6 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Sun, 3 Apr 2016 13:18:22 +0200 Subject: [PATCH] Added helpful hints for first-time players! TODO: Localize that! --- maps/mp/gametypes/hns.gsc | 64 ++++++++++++- maps/mp/mods/helpingHints.gsc | 170 ++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 maps/mp/mods/helpingHints.gsc diff --git a/maps/mp/gametypes/hns.gsc b/maps/mp/gametypes/hns.gsc index e32f2e3..b758108 100644 --- a/maps/mp/gametypes/hns.gsc +++ b/maps/mp/gametypes/hns.gsc @@ -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() } } -} \ No newline at end of file +/* + * 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(); +} diff --git a/maps/mp/mods/helpingHints.gsc b/maps/mp/mods/helpingHints.gsc new file mode 100644 index 0000000..f1a1d9f --- /dev/null +++ b/maps/mp/mods/helpingHints.gsc @@ -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; +} \ No newline at end of file