From 388ccfbee03010f0b3570f67934dcd93890f335b Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Fri, 8 Apr 2016 18:53:44 +0200 Subject: [PATCH] Fix helpful hints to be only shown once in a round. It turns out localized strings can not be used reliably in context of array indexing (or even debug printing). Here we switch to hardcoded strings ("name") in order to manage the "already seen hints" array. --- maps/mp/gametypes/hns.gsc | 28 ++++++++++++++-------------- maps/mp/mods/helpingHints.gsc | 19 ++++++++++++------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/maps/mp/gametypes/hns.gsc b/maps/mp/gametypes/hns.gsc index 83192eb..6576d0f 100644 --- a/maps/mp/gametypes/hns.gsc +++ b/maps/mp/gametypes/hns.gsc @@ -924,16 +924,16 @@ giveHelpfulHintsForHider() player thread clearHintsShownOnDisconnect(); player notifyOnPlayerCommand("hide_hint_for_disguise", "+attack"); - player showHintOnce(&"HIDEANDSEEK_HINT_HIDER_DISGUISE"); - player waittill("hide_hint_for_disguise"); + if (player showHintOnce("hider.disguise", &"HIDEANDSEEK_HINT_HIDER_DISGUISE")) + player waittill("hide_hint_for_disguise"); player notifyOnPlayerCommand("hide_hint_for_anglelock", "+melee"); - player showHintOnce(&"HIDEANDSEEK_HINT_HIDER_ANGLELOCK"); - player waittill("hide_hint_for_anglelock"); + if (player showHintOnce("hider.anglelock", &"HIDEANDSEEK_HINT_HIDER_ANGLELOCK")) + player waittill("hide_hint_for_anglelock"); player notifyOnPlayerCommand("hide_hint_for_thirdperson", "+actionslot 3"); - player showHintOnce(&"HIDEANDSEEK_HINT_HIDER_THIRDPERSON"); - player waittill("hide_hint_for_thirdperson"); + if (player showHintOnce("hider.thirdperson", &"HIDEANDSEEK_HINT_HIDER_THIRDPERSON")) + player waittill("hide_hint_for_thirdperson"); player hideHint(); } @@ -954,17 +954,17 @@ giveHelpfulHintsForSeeker() player thread clearHintsShownOnDisconnect(); - player notifyOnPlayerCommand("hide_hint_for_primaryweapon", "+actionslot 3"); - player showHintOnce(&"HIDEANDSEEK_HINT_SEEKER_PRIMARYWEAPON"); - player waittill("hide_hint_for_primaryweapon"); - player notifyOnPlayerCommand("hide_hint_for_reload", "+reload"); - player showHintOnce(&"HIDEANDSEEK_HINT_SEEKER_UNLIMITEDRELOAD"); - player waittill("hide_hint_for_reload"); + if (player showHintOnce("seeker.unlimitedreload", &"HIDEANDSEEK_HINT_SEEKER_UNLIMITEDRELOAD")) + player waittill("hide_hint_for_reload"); player notifyOnPlayerCommand("hide_hint_for_semtex", "+frag"); - player showHintOnce(&"HIDEANDSEEK_HINT_SEEKER_SEMTEX"); - player waittill("hide_hint_for_semtex"); + if (player showHintOnce("seeker.semtex", &"HIDEANDSEEK_HINT_SEEKER_SEMTEX")) + player waittill("hide_hint_for_semtex"); + + player notifyOnPlayerCommand("hide_hint_for_primaryweapon", "+actionslot 3"); + if (player showHintOnce("seeker.primaryweapon", &"HIDEANDSEEK_HINT_SEEKER_PRIMARYWEAPON")) + player waittill("hide_hint_for_primaryweapon"); player hideHint(); } diff --git a/maps/mp/mods/helpingHints.gsc b/maps/mp/mods/helpingHints.gsc index e7b47c1..9db03a0 100644 --- a/maps/mp/mods/helpingHints.gsc +++ b/maps/mp/mods/helpingHints.gsc @@ -43,7 +43,7 @@ clearHintsShown() /* * Displays a hint for the player (self) if it hasn't been shown before for him. */ -showHintOnce(text) +showHintOnce(name, text) { logString("showHintOnce called"); @@ -51,21 +51,26 @@ showHintOnce(text) if (!IsDefined(level.shownPlayerHints)) { + self IPrintLn("Level has no hint array"); level.shownPlayerHints = []; } if (!IsDefined(level.shownPlayerHints[id])) { + self IPrintLn("ID " + id + " has no hint array"); level.shownPlayerHints[id] = []; } - if (!IsDefined(level.shownPlayerHints[id][text]) || !level.shownPlayerHints[id][text]) + if (!IsDefined(level.shownPlayerHints[id][name]) || !level.shownPlayerHints[id][name]) { - level.shownPlayerHints[id][text] = true; + self IPrintLn("ID " + id + " has not seen hint yet"); + self IPrintLn(text); + level.shownPlayerHints[id][name] = true; self showHint(text); + return true; } - else - { - self hideHint(); - } + + self IPrintLn("ID " + id + " has already seen hint"); + self hideHint(); + return false; } /*