@hotbunny/hackhub-content-sdk 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +55 -31
  2. package/index.d.ts +2 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -23,13 +23,12 @@ npm install @hotbunny/hackhub-content-sdk --save-dev
23
23
  Every mod needs a `Bootstrap` class decorated with `@RegisterModPackage`:
24
24
 
25
25
  ```typescript
26
- import { Bootstrap, RegisterModPackage, Storage } from "@hotbunny/hackhub-content-sdk";
26
+ import { Bootstrap, RegisterModPackage } from "@hotbunny/hackhub-content-sdk";
27
27
 
28
28
  @RegisterModPackage
29
29
  export default class MyMod extends Bootstrap {
30
30
  OnModPackageLoaded() {
31
- const difficulty = Storage.get<string>("difficulty");
32
- console.log(`Loaded with difficulty: ${difficulty}`);
31
+ console.log("Mod loaded!");
33
32
  }
34
33
 
35
34
  OnModPackageUnloaded() {
@@ -40,34 +39,32 @@ export default class MyMod extends Bootstrap {
40
39
 
41
40
  ## Quests
42
41
 
42
+ Quests use `CreateData()` to initialize data once when the quest is first claimed. After that, access the data via `this.Data`:
43
+
43
44
  ```typescript
44
- import { Quest, Network, RegisterQuest } from "@hotbunny/hackhub-content-sdk";
45
+ import { Quest, Events, Network, RegisterQuest } from "@hotbunny/hackhub-content-sdk";
45
46
 
46
47
  @RegisterQuest
47
48
  class InfiltrationQuest extends Quest {
48
- definition = {
49
- name: "Infiltration",
50
- title: "Server Infiltration",
51
- description: "Hack into the target server and download the data.",
52
- employer: { name: "Mr. X", avatar: "mrx" },
53
- rewards: { money: 5000, xp: 200 },
54
- objectives: [
55
- {
56
- name: "scan",
57
- description: "Scan the target server",
58
- trigger: { event: "Terminal.NmapScan", condition: (data) => data.ip === this.Data.targetIp },
59
- },
60
- {
61
- name: "connect",
62
- description: "Connect via SSH",
63
- trigger: { event: "Terminal.SSH.Connected", condition: (data) => data.ip === this.Data.targetIp },
64
- },
65
- ],
66
- };
49
+ Name = "Infiltration";
50
+ Title = "Server Infiltration";
51
+ Description = "Hack into the target server and download the data.";
52
+ Employer = { name: "Mr. X", avatar: "mrx" };
53
+ Rewards = { money: 5000, xp: 200 };
54
+ Objectives = [
55
+ { name: "scan", description: "Scan the target server" },
56
+ {
57
+ name: "connect",
58
+ description: "Connect via SSH",
59
+ unlocksAfter: ["scan"],
60
+ },
61
+ ];
67
62
 
68
- Data = {
69
- targetIp: "10.0.0.50",
70
- };
63
+ CreateData() {
64
+ return {
65
+ targetIp: Network.randomIp(),
66
+ };
67
+ }
71
68
 
72
69
  OnStart() {
73
70
  Network.createSubnetNetwork({
@@ -77,6 +74,18 @@ class InfiltrationQuest extends Quest {
77
74
  users: [Network.createUser({ username: "admin", password: "secret123" })],
78
75
  children: [],
79
76
  });
77
+
78
+ Events.on("Terminal.NmapScan", (data) => {
79
+ if (data.ip === this.Data.targetIp) this.completeObjective("scan");
80
+ });
81
+
82
+ Events.on("Terminal.SSH.Connected", (data) => {
83
+ if (data.ip === this.Data.targetIp) this.completeObjective("connect");
84
+ });
85
+ }
86
+
87
+ OnComplete() {
88
+ Network.destroyNetwork(this.Data.targetIp);
80
89
  }
81
90
  }
82
91
  ```
@@ -88,7 +97,9 @@ Quests can send in-game emails and start phone call dialogs:
88
97
  ```typescript
89
98
  @RegisterQuest
90
99
  class StoryQuest extends Quest {
91
- // ... definition, Data ...
100
+ Name = "StoryQuest";
101
+ Title = "Story Quest";
102
+ Objectives = [{ name: "start", description: "Begin the mission" }];
92
103
 
93
104
  Mails = [
94
105
  { title: "Mission Briefing", content: "Your target is ready. Good luck." },
@@ -160,10 +171,10 @@ class MyApp extends App {
160
171
 
161
172
  ## Mod Settings
162
173
 
163
- Players can configure your mod from the in-game Mods menu. Settings values are accessible via `Storage.get(key)`.
174
+ Players can configure your mod from the in-game Mods menu. Use the `ModSettings` API to read and write setting values:
164
175
 
165
176
  ```typescript
166
- import { Bootstrap, ModSettingDefinition, RegisterModPackage, Storage } from "@hotbunny/hackhub-content-sdk";
177
+ import { Bootstrap, ModSettingDefinition, ModSettings, RegisterModPackage } from "@hotbunny/hackhub-content-sdk";
167
178
 
168
179
  @RegisterModPackage
169
180
  export default class MyMod extends Bootstrap {
@@ -184,8 +195,8 @@ export default class MyMod extends Bootstrap {
184
195
  ];
185
196
 
186
197
  OnModPackageLoaded() {
187
- const difficulty = Storage.get<string>("difficulty");
188
- const hints = Storage.get<boolean>("showHints");
198
+ const difficulty = ModSettings.get<string>("difficulty");
199
+ const hints = ModSettings.get<boolean>("showHints");
189
200
  console.log(`Difficulty: ${difficulty}, Hints: ${hints}`);
190
201
  }
191
202
  }
@@ -214,6 +225,7 @@ export default class MyMod extends Bootstrap {
214
225
  | `Mail` | Send in-game emails |
215
226
  | `Bank` | Bank accounts and transactions |
216
227
  | `Random` | Random generation (id, password, username, pick, etc.) |
228
+ | `ModSettings` | Read/write mod settings configured by the player |
217
229
  | `Storage` | Persistent key-value storage per mod |
218
230
  | `Variables` | Session-only variables (reset on game close) |
219
231
  | `SharedStorage` | Persistent storage shared between mods |
@@ -239,6 +251,18 @@ Random.pickMultiple(arr, 3); // 3 unique random elements
239
251
  await Random.sleep(2000); // Wait 2 seconds
240
252
  ```
241
253
 
254
+ ### ModSettings
255
+
256
+ ```typescript
257
+ import { ModSettings } from "@hotbunny/hackhub-content-sdk";
258
+
259
+ ModSettings.get<string>("difficulty"); // Read a setting value
260
+ ModSettings.getAll(); // All settings as key-value map
261
+ ModSettings.set("difficulty", "hard"); // Write a setting value
262
+ ModSettings.reset("difficulty"); // Reset to default
263
+ ModSettings.resetAll(); // Reset all to defaults
264
+ ```
265
+
242
266
  ### Events
243
267
 
244
268
  ```typescript
package/index.d.ts CHANGED
@@ -1129,6 +1129,8 @@ export declare abstract class Quest {
1129
1129
  Mails?: QuestMailDefinition[];
1130
1130
  /** Phone-call dialog tree for this quest. Use this.createDialog(branch) to start. */
1131
1131
  Dialog?: QuestDialogDefinition;
1132
+ /** Quest data created by CreateData(). Populated at runtime by the game engine. */
1133
+ Data: any;
1132
1134
  /**
1133
1135
  * Called when the quest is first claimed/started.
1134
1136
  * Use this to set up event listeners for objective completion.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotbunny/hackhub-content-sdk",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "Official modding SDK for HackHub - Ultimate Hacker Simulator on Steam. Create custom quests, websites, terminal commands, and desktop apps.",
5
5
  "types": "index.d.ts",
6
6
  "exports": {