kill-switch-mcp 1.1.9 → 1.1.10
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/dist/server.js +47 -32
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -4111,19 +4111,16 @@ execute it by sending code to the game via execute_code.
|
|
|
4111
4111
|
- bot.attackNpc("name" or /pattern/i) — attack an NPC
|
|
4112
4112
|
- bot.walkTo(x, z) — pathfind and walk (complex, uses server pathfinding)
|
|
4113
4113
|
|
|
4114
|
-
### sdk methods (low-level
|
|
4115
|
-
|
|
4116
|
-
|
|
4114
|
+
### sdk methods (low-level):
|
|
4115
|
+
State (sync): sdk.getState(), sdk.getInventory(), sdk.getEquipment(), sdk.getNearbyPlayers(), sdk.getGroundItems()
|
|
4116
|
+
Search (sync): sdk.findInventoryItem(/pat/i), sdk.findGroundItem(/pat/i), sdk.findNearbyPlayer(/pat/i)
|
|
4117
|
+
Commands (async): sdk.sendWalk(x, z), sdk.sendPickup(x, z, itemId), sdk.sendInteractLoc(x, z, locId, option)
|
|
4118
|
+
Timing (async): await sdk.waitForTicks(n) — each tick ~0.6s
|
|
4119
|
+
|
|
4120
|
+
Key state paths:
|
|
4117
4121
|
- sdk.getState().player.worldX / .worldZ — your position
|
|
4118
|
-
- sdk.getState().player.hp — your
|
|
4119
|
-
-
|
|
4120
|
-
- sdk.getInventory() — array of inventory items (each has .name)
|
|
4121
|
-
- sdk.getEquipment() — array of equipment items
|
|
4122
|
-
- sdk.findInventoryItem(/pattern/i) — find item in inventory
|
|
4123
|
-
- sdk.findGroundItem(/pattern/i) — find item on ground (returns { name, x, z, distance } — NOT .worldX!)
|
|
4124
|
-
- sdk.getGroundItems() — all nearby ground items (each has .name, .x, .z, .distance, .id, .count)
|
|
4125
|
-
- sdk.getNearbyPlayers() — nearby players (each has .name, .combatLevel, .distance, .x, .z)
|
|
4126
|
-
- sdk.waitForTicks(n) — wait n game ticks (~0.6s each)
|
|
4122
|
+
- sdk.getState().player.hp / .maxHp — your hitpoints
|
|
4123
|
+
- Ground items use .x / .z (NOT .worldX)
|
|
4127
4124
|
|
|
4128
4125
|
### actions (pre-built strategies, await each one):
|
|
4129
4126
|
Actions are loaded from your bot's actions/ directory at login. Default actions:
|
|
@@ -4181,7 +4178,7 @@ Wrap in try/catch if you want to handle failures gracefully.
|
|
|
4181
4178
|
- \`await bot.talkTo(nameOrPattern)\` — Talk to an NPC.
|
|
4182
4179
|
- \`await bot.interactLoc(nameOrPattern, option)\` — Interact with a game object.
|
|
4183
4180
|
- \`await bot.interactNpc(nameOrPattern, option)\` — Interact with an NPC.
|
|
4184
|
-
- \`await bot.openDoor(
|
|
4181
|
+
- \`await bot.openDoor(target)\` — Open a door. Pass a NearbyLoc object, string name, or RegExp. With no args, opens nearest door.
|
|
4185
4182
|
|
|
4186
4183
|
### Dialog
|
|
4187
4184
|
- \`await bot.navigateDialog(choices)\` — Navigate through NPC dialog.
|
|
@@ -4199,10 +4196,10 @@ Wrap in try/catch if you want to handle failures gracefully.
|
|
|
4199
4196
|
- \`sdk.getState()\` — Returns the full game state object. See "State Object Shape" below.
|
|
4200
4197
|
- \`sdk.getInventory()\` — Array of inventory items. Each has: \`.name\`, \`.id\`, \`.count\`, \`.slot\`
|
|
4201
4198
|
- \`sdk.getEquipment()\` — Array of equipped items. Each has: \`.name\`, \`.id\`, \`.slot\`
|
|
4202
|
-
- \`sdk.getNearbyPlayers()\` — Array of nearby players. Each has: \`.name\`, \`.combatLevel\`, \`.distance\`, \`.x\`, \`.z\`
|
|
4199
|
+
- \`sdk.getNearbyPlayers()\` — Array of nearby players. Each has: \`.index\`, \`.name\`, \`.combatLevel\`, \`.distance\`, \`.x\`, \`.z\`
|
|
4203
4200
|
- \`sdk.getGroundItems()\` — Array of ground items. Each has: \`.name\`, \`.id\`, \`.count\`, \`.x\`, \`.z\`, \`.distance\`
|
|
4204
|
-
- \`sdk.getNearbyLocs()\` — Array of nearby game objects.
|
|
4205
|
-
- \`sdk.getNearbyNpcs()\` — Array of nearby NPCs.
|
|
4201
|
+
- \`sdk.getNearbyLocs()\` — Array of nearby game objects. Each has: \`.id\`, \`.name\`, \`.x\`, \`.z\`, \`.distance\`, \`.options\`
|
|
4202
|
+
- \`sdk.getNearbyNpcs()\` — Array of nearby NPCs. Each has: \`.index\`, \`.name\`, \`.combatLevel\`, \`.x\`, \`.z\`, \`.distance\`, \`.hp\`, \`.maxHp\`, \`.inCombat\`
|
|
4206
4203
|
|
|
4207
4204
|
### Search (instant, not async)
|
|
4208
4205
|
- \`sdk.findInventoryItem(pattern)\` — Find first matching inventory item. Returns item or null.
|
|
@@ -4211,15 +4208,16 @@ Wrap in try/catch if you want to handle failures gracefully.
|
|
|
4211
4208
|
- \`sdk.findNearbyNpc(pattern)\` — Find a nearby NPC. Returns NPC or null.
|
|
4212
4209
|
- \`sdk.findNearbyLoc(pattern)\` — Find a nearby game object. Returns loc or null.
|
|
4213
4210
|
|
|
4214
|
-
### Direct Commands (
|
|
4215
|
-
|
|
4216
|
-
- \`sdk.
|
|
4217
|
-
- \`sdk.
|
|
4218
|
-
- \`sdk.
|
|
4219
|
-
- \`sdk.
|
|
4220
|
-
- \`sdk.
|
|
4211
|
+
### Direct Commands (async, send action to server)
|
|
4212
|
+
All send* methods are async and return Promise<ActionResult>. Use await or fire-and-forget.
|
|
4213
|
+
- \`sdk.sendWalk(x, z)\` — Click a tile to walk there. Fast, no pathfinding. Use for quick movement.
|
|
4214
|
+
- \`sdk.sendPickup(x, z, itemId)\` — Pick up a ground item. Args are (x, z, itemId) — NOT (itemId, x, z).
|
|
4215
|
+
- \`sdk.sendInteractPlayer(playerIndex, option)\` — Interact with a player. Use player.index from getNearbyPlayers().
|
|
4216
|
+
- \`sdk.sendInteractNpc(npcIndex, option)\` — Interact with an NPC. Use npc.index from getNearbyNpcs(). NOT npcId.
|
|
4217
|
+
- \`sdk.sendInteractLoc(x, z, locId, option)\` — Interact with a game object. Args are (x, z, locId, option) — NOT (locId, x, z).
|
|
4218
|
+
- \`sdk.sendUseItem(slot, option)\` — Use an inventory item. option defaults to 1 (first option, e.g. eat/wear).
|
|
4221
4219
|
- \`sdk.sendSetCombatStyle(style)\` — Change combat style (0-3).
|
|
4222
|
-
- \`sdk.sendTogglePrayer(
|
|
4220
|
+
- \`sdk.sendTogglePrayer(prayer)\` — Toggle a prayer. Accepts prayer name string (e.g. 'protect_from_melee') or prayer ID number.
|
|
4223
4221
|
|
|
4224
4222
|
### Timing (async)
|
|
4225
4223
|
- \`await sdk.waitForTicks(n)\` — Wait n game ticks. Each tick ≈ 0.6 seconds.
|
|
@@ -4242,16 +4240,23 @@ sdk.getState() returns:
|
|
|
4242
4240
|
hp: number, // Current hitpoints
|
|
4243
4241
|
maxHp: number, // Max hitpoints
|
|
4244
4242
|
combatLevel: number,
|
|
4245
|
-
|
|
4243
|
+
animId: number, // Current animation ID (-1 = idle)
|
|
4244
|
+
combat: { // Combat sub-state
|
|
4245
|
+
inCombat: boolean,
|
|
4246
|
+
targetIndex: number,
|
|
4247
|
+
},
|
|
4246
4248
|
},
|
|
4249
|
+
inGame: boolean, // Whether connected to game
|
|
4247
4250
|
skills: [...], // Array of skill objects
|
|
4248
4251
|
inventory: [...], // Array of inventory slots
|
|
4249
4252
|
equipment: [...], // Array of equipment slots
|
|
4250
|
-
groundItems: [...], // Nearby ground items (each has .name, .x, .z, .id, .count)
|
|
4251
|
-
nearbyPlayers: [...], // Nearby players
|
|
4252
|
-
nearbyNpcs: [...], // Nearby NPCs
|
|
4253
|
+
groundItems: [...], // Nearby ground items (each has .name, .x, .z, .id, .count, .distance)
|
|
4254
|
+
nearbyPlayers: [...], // Nearby players (each has .index, .name, .x, .z, .distance, .combatLevel)
|
|
4255
|
+
nearbyNpcs: [...], // Nearby NPCs (each has .index, .name, .x, .z, .distance, .hp, .maxHp)
|
|
4256
|
+
nearbyLocs: [...], // Nearby game objects (each has .id, .name, .x, .z, .distance, .options)
|
|
4253
4257
|
dialog: { isOpen, ... }, // Dialog state
|
|
4254
4258
|
modalOpen: boolean, // Whether a modal is open
|
|
4259
|
+
gameMessages: [...], // Recent game messages
|
|
4255
4260
|
}
|
|
4256
4261
|
\`\`\`
|
|
4257
4262
|
|
|
@@ -4267,10 +4272,20 @@ IMPORTANT PROPERTY NAMES:
|
|
|
4267
4272
|
|
|
4268
4273
|
### Quick loot (walk + pick up):
|
|
4269
4274
|
\`\`\`
|
|
4270
|
-
|
|
4271
|
-
await
|
|
4272
|
-
|
|
4273
|
-
|
|
4275
|
+
// Option A: Use bot.pickupItem (walks to item automatically, throws on failure)
|
|
4276
|
+
try { await bot.pickupItem(/lobster/i); } catch(e) { console.log("Missed lobster"); }
|
|
4277
|
+
|
|
4278
|
+
// Option B: Manual walk + raw pickup (more control)
|
|
4279
|
+
const item = sdk.findGroundItem(/lobster/i);
|
|
4280
|
+
if (item) {
|
|
4281
|
+
sdk.sendWalk(item.x, item.z); // Walk to item
|
|
4282
|
+
await sdk.waitForTicks(5); // Wait to arrive
|
|
4283
|
+
sdk.sendPickup(item.x, item.z, item.id); // Pick up (args: x, z, itemId)
|
|
4284
|
+
await sdk.waitForTicks(2); // Wait for server
|
|
4285
|
+
}
|
|
4286
|
+
|
|
4287
|
+
// Equip from inventory
|
|
4288
|
+
await bot.equipItem(/scimitar/i);
|
|
4274
4289
|
\`\`\`
|
|
4275
4290
|
|
|
4276
4291
|
### Combat loop:
|