@hotbunny/hackhub-content-sdk 0.9.2 → 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.
- package/README.md +55 -31
- package/index.d.ts +27 -0
- 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
|
|
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
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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.
|
|
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,
|
|
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 =
|
|
188
|
-
const hints =
|
|
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.
|
|
@@ -1851,6 +1853,31 @@ export declare namespace Random {
|
|
|
1851
1853
|
export function sleep(ms: number): Promise<void>;
|
|
1852
1854
|
export {};
|
|
1853
1855
|
}
|
|
1856
|
+
/**
|
|
1857
|
+
* Mod settings API. Provides access to the values configured by
|
|
1858
|
+
* the player in the Mods menu (defined via Bootstrap.Settings).
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* ```ts
|
|
1862
|
+
* import { ModSettings } from "@hotbunny/hackhub-content-sdk";
|
|
1863
|
+
*
|
|
1864
|
+
* const difficulty = ModSettings.get<string>("difficulty");
|
|
1865
|
+
* const all = ModSettings.getAll();
|
|
1866
|
+
* ```
|
|
1867
|
+
*/
|
|
1868
|
+
export declare namespace ModSettings {
|
|
1869
|
+
/** Get a setting value by key. Returns the default if not changed by player. */
|
|
1870
|
+
export function get<T = any>(key: string): T | undefined;
|
|
1871
|
+
/** Get all setting values as a key-value map. */
|
|
1872
|
+
export function getAll(): Record<string, any>;
|
|
1873
|
+
/** Programmatically set a setting value. */
|
|
1874
|
+
export function set(key: string, value: any): void;
|
|
1875
|
+
/** Reset a setting to its default value. */
|
|
1876
|
+
export function reset(key: string): void;
|
|
1877
|
+
/** Reset all settings to their defaults. */
|
|
1878
|
+
export function resetAll(): void;
|
|
1879
|
+
export {};
|
|
1880
|
+
}
|
|
1854
1881
|
/**
|
|
1855
1882
|
* Marks a class as the mod's entry point.
|
|
1856
1883
|
* Each mod must have exactly one @RegisterModPackage class extending Bootstrap.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hotbunny/hackhub-content-sdk",
|
|
3
|
-
"version": "0.9.
|
|
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": {
|