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.
master
Icedream 2016-04-08 18:53:44 +02:00
parent 1e19f035f2
commit 388ccfbee0
2 changed files with 26 additions and 21 deletions

View File

@ -924,16 +924,16 @@ giveHelpfulHintsForHider()
player thread clearHintsShownOnDisconnect(); player thread clearHintsShownOnDisconnect();
player notifyOnPlayerCommand("hide_hint_for_disguise", "+attack"); player notifyOnPlayerCommand("hide_hint_for_disguise", "+attack");
player showHintOnce(&"HIDEANDSEEK_HINT_HIDER_DISGUISE"); if (player showHintOnce("hider.disguise", &"HIDEANDSEEK_HINT_HIDER_DISGUISE"))
player waittill("hide_hint_for_disguise"); player waittill("hide_hint_for_disguise");
player notifyOnPlayerCommand("hide_hint_for_anglelock", "+melee"); player notifyOnPlayerCommand("hide_hint_for_anglelock", "+melee");
player showHintOnce(&"HIDEANDSEEK_HINT_HIDER_ANGLELOCK"); if (player showHintOnce("hider.anglelock", &"HIDEANDSEEK_HINT_HIDER_ANGLELOCK"))
player waittill("hide_hint_for_anglelock"); player waittill("hide_hint_for_anglelock");
player notifyOnPlayerCommand("hide_hint_for_thirdperson", "+actionslot 3"); player notifyOnPlayerCommand("hide_hint_for_thirdperson", "+actionslot 3");
player showHintOnce(&"HIDEANDSEEK_HINT_HIDER_THIRDPERSON"); if (player showHintOnce("hider.thirdperson", &"HIDEANDSEEK_HINT_HIDER_THIRDPERSON"))
player waittill("hide_hint_for_thirdperson"); player waittill("hide_hint_for_thirdperson");
player hideHint(); player hideHint();
} }
@ -954,17 +954,17 @@ giveHelpfulHintsForSeeker()
player thread clearHintsShownOnDisconnect(); 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 notifyOnPlayerCommand("hide_hint_for_reload", "+reload");
player showHintOnce(&"HIDEANDSEEK_HINT_SEEKER_UNLIMITEDRELOAD"); if (player showHintOnce("seeker.unlimitedreload", &"HIDEANDSEEK_HINT_SEEKER_UNLIMITEDRELOAD"))
player waittill("hide_hint_for_reload"); player waittill("hide_hint_for_reload");
player notifyOnPlayerCommand("hide_hint_for_semtex", "+frag"); player notifyOnPlayerCommand("hide_hint_for_semtex", "+frag");
player showHintOnce(&"HIDEANDSEEK_HINT_SEEKER_SEMTEX"); if (player showHintOnce("seeker.semtex", &"HIDEANDSEEK_HINT_SEEKER_SEMTEX"))
player waittill("hide_hint_for_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(); player hideHint();
} }

View File

@ -43,7 +43,7 @@ clearHintsShown()
/* /*
* Displays a hint for the player (self) if it hasn't been shown before for him. * Displays a hint for the player (self) if it hasn't been shown before for him.
*/ */
showHintOnce(text) showHintOnce(name, text)
{ {
logString("showHintOnce called"); logString("showHintOnce called");
@ -51,21 +51,26 @@ showHintOnce(text)
if (!IsDefined(level.shownPlayerHints)) if (!IsDefined(level.shownPlayerHints))
{ {
self IPrintLn("Level has no hint array");
level.shownPlayerHints = []; level.shownPlayerHints = [];
} }
if (!IsDefined(level.shownPlayerHints[id])) if (!IsDefined(level.shownPlayerHints[id]))
{ {
self IPrintLn("ID " + id + " has no hint array");
level.shownPlayerHints[id] = []; 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); self showHint(text);
return true;
} }
else
{ self IPrintLn("ID " + id + " has already seen hint");
self hideHint(); self hideHint();
} return false;
} }
/* /*