664a5e3d02d16

664a5e3d031d0
1 Guest is here.
 

Topic: HUD Keypad Codes Read 741 times  

664a5e3d0373fZylonBane

664a5e3d0379c
With all the talk about keypad codes lately, I wanted to test an idea I had for displaying a keypad's code in its HUD use string after you've acquired it.
Code: [Select]
class zbKeycodeHUD extends SqRootScript {
function OnBeginScript() {
if (!IsDataSet("Done")) {
if (getQB()) {
Quest.SubscribeMsg(self, getQB(), eQuestDataType.kQuestDataCampaign);
checkQB();
}
else {
SetData("Done", true);
}
}
}

function OnEndScript() {
if (!IsDataSet("Done")) {
Quest.UnsubscribeMsg(self, getQB());
};
}

function OnQuestChange() {
checkQB();
}

function checkQB() {
if (Quest.Get(getQB()) == 1) {
SetProperty("HUDUse", ": \"" + Data.GetObjString(self, "huduse") + "\n" + format("%05d", GetProperty("KeypadCode")) + "\"");
OnEndScript();
SetData("Done", true);
}
}

function getQB() {
if (IsDataSet("CodeQB")) {
return GetData("CodeQB");
}
local deck, n, qb;
local code = format("%05d", GetProperty("KeypadCode"));
for (deck = 1; deck <= 9; deck++) {
for (n = 1; n <= 32; n++) {
qb = "Note_" + deck + "_" + n;
if (Data.GetString("notes", qb).find(code)) {
SetData("CodeQB", qb);
return qb;
}
}
}
}
}
With this script, on startup every keypad scans the quest note strings for the note that contains its code. If found, it listens for that quest note, and when it fires, adds its code to its HUD use string. Like so:


This theoretically allows this script to work with ANY mission or campaign. Note I say theoretically though. In practice, it only works when keypad codes are explicitly added to the notes, and only on keypads that are set to inherit scripts. Even in the OMs, some keypads are set to not inherit because they use an "unhackable" variant on the base keypad script (the medsci2 armory and all eng1 keypads). SCP will be removing all these because they aren't needed anymore, so at the very least this would work with SCP.

Beta attached if anyone would like to try it.

664a5e3d03addsarge945

664a5e3d03b3b
I swear I've seen this idea before somewhere....

Also, I take it this doesn't work for the Rec transmitter?

I tried this with Ponterbee, unfortunately it has the same issue with UnhackableKeypad scripts and not using inheritance, so it doesn't work there either.
« Last Edit: 25. September 2023, 04:53:52 by sarge945 »

664a5e3d03c05ZylonBane

664a5e3d03c69
It absolutely does not work for the Rec transmitter, because it shouldn't, and because it can't.

664a5e3d03dc4sarge945

664a5e3d03e22
By the way, I implemented a similar solution to this in No Keypad Cheese.

I hope you don't feel like I've stolen your work. Both mods have similar features and this solution is genius for supporting FMs, so I implemented my own version of it.

Also, I'm slightly confused. This works for the 12451 keypad in medsci1 (object 809). But the note associated with that keypad's log uses the QBvar wattsy, so it won't be found by the getQB function at all. And yet it works anyway? What gives? How exactly does this work?
« Last Edit: 25. September 2023, 06:36:10 by sarge945 »

664a5e3d03f24ZylonBane

664a5e3d03f7a
Wattsy is NOT the qvar that controls that quest note. Quest notes are controlled with a very standardized naming format that you can see in the code above and in notes.str. What wattsy is is a plot state tracking qvar, that is only used by various QB traps.
Acknowledged by: sarge945

664a5e3d040d2ZylonBane

664a5e3d04122
I thought it would be fun to play a little code golf with disabling keypads for which the code hasn't been found yet. This is the best I could come up with. Add to the keypad script.
Code: [Select]
function OnFrobWorldBegin() {
local c;
local code = GetProperty("KeypadCode");
local codes = [[45100, "2_4"], [12451, "2_7"], [98383, "2_8"], [59004, "1_11"], [34760, "1_10"], [15061, "1_8"], [94834, "1_12"], [11111, "5_8"], [34093, "5_6"], [13433, "4_6"], [83273, "6_11"]];
foreach (c in codes)
if (code == c[0] || code == c[0] * 10)
SetProperty("KeypadCode", c[0] * (Quest.Exists("Note_" + c[1]) ? 1 : 10));
}
Doesn't handle the Rec deck art codes, of course. That would require a few more lines.

Also, this setup can be extended to detect when a code is entered prematurely:
Code: [Select]
function OnKeypadDone() {
if (message().code == GetProperty("KeypadCode") / 10) {
print("cheater!");
}
}

Your name:
This box must be left blank:

____ at you, hacker: a pathetic creature of meat and bone!  (Fill in the missing word):
1 Guest is here.
She was seen as something like SHODAN’s secret police; brutal and intelligent enough to interrogate people
Contact SMF 2.0.19 | SMF © 2016, Simple Machines | Terms and Policies
FEEP
664a5e3d0421b