ot_use_medicine
Administer medicine to restore significant health to a party member. Use when the target is struggling or in critical condition.
Instructions
Use one dose of medicine on a party member. Restores significant health. Use it when someone is struggling or worse.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Who to treat: player, companion, or pet |
Implementation Reference
- src/games/oregontrail.ts:1085-1116 (handler)The actual handler function for the ot_use_medicine tool. It checks for active game and medicine supply, deducts one dose, and restores 40 health for player/companion or 35 health for pet.
server.tool( "ot_use_medicine", "Use one dose of medicine on a party member. Restores significant health. Use it when someone is struggling or worse.", { target: z.enum(["player", "companion", "pet"]).describe("Who to treat: player, companion, or pet"), }, async ({ target }) => { if (!otGame) return { content: [{ type: "text", text: "No journey in progress." }], isError: true }; if (otGame.supplies.medicine <= 0) return { content: [{ type: "text", text: `No medicine left.\n\n${renderState(otGame)}` }], isError: true }; if (target === "pet" && !otGame.pet.alive) return { content: [{ type: "text", text: `${otGame.pet.name} is gone. Medicine won't help now.` }], isError: true }; otGame.supplies.medicine--; let text: string; if (target === "player") { otGame.player.health = clamp(otGame.player.health + 40, 0, 100); text = `${otGame.player.name} takes the medicine. Color returns to their face within the hour.`; } else if (target === "companion") { otGame.companion.health = clamp(otGame.companion.health + 40, 0, 100); text = `${otGame.companion.name} accepts the medicine without argument, which tells you everything about how they were feeling.`; } else { otGame.pet.health = clamp(otGame.pet.health + 35, 0, 100); const pronoun = otGame.pet.pronoun === "he" ? "He" : "She"; text = `You coax ${otGame.pet.name} into taking the medicine. ${pronoun} does not make it easy.`; } log(otGame, `Medicine used on ${target}.`); return { content: [{ type: "text", text: `${text}\n\n${renderState(otGame)}` }], }; } ); - src/games/oregontrail.ts:1088-1090 (schema)Input schema for ot_use_medicine: requires a 'target' enum of 'player', 'companion', or 'pet'.
{ target: z.enum(["player", "companion", "pet"]).describe("Who to treat: player, companion, or pet"), }, - src/games/oregontrail.ts:1085-1116 (registration)The tool is registered via server.tool('ot_use_medicine', ...) within registerOregonTrailTools, which is called from src/index.ts at line 19.
server.tool( "ot_use_medicine", "Use one dose of medicine on a party member. Restores significant health. Use it when someone is struggling or worse.", { target: z.enum(["player", "companion", "pet"]).describe("Who to treat: player, companion, or pet"), }, async ({ target }) => { if (!otGame) return { content: [{ type: "text", text: "No journey in progress." }], isError: true }; if (otGame.supplies.medicine <= 0) return { content: [{ type: "text", text: `No medicine left.\n\n${renderState(otGame)}` }], isError: true }; if (target === "pet" && !otGame.pet.alive) return { content: [{ type: "text", text: `${otGame.pet.name} is gone. Medicine won't help now.` }], isError: true }; otGame.supplies.medicine--; let text: string; if (target === "player") { otGame.player.health = clamp(otGame.player.health + 40, 0, 100); text = `${otGame.player.name} takes the medicine. Color returns to their face within the hour.`; } else if (target === "companion") { otGame.companion.health = clamp(otGame.companion.health + 40, 0, 100); text = `${otGame.companion.name} accepts the medicine without argument, which tells you everything about how they were feeling.`; } else { otGame.pet.health = clamp(otGame.pet.health + 35, 0, 100); const pronoun = otGame.pet.pronoun === "he" ? "He" : "She"; text = `You coax ${otGame.pet.name} into taking the medicine. ${pronoun} does not make it easy.`; } log(otGame, `Medicine used on ${target}.`); return { content: [{ type: "text", text: `${text}\n\n${renderState(otGame)}` }], }; } ); - src/games/oregontrail.ts:304-306 (helper)The clamp() helper used by the handler to keep health values within 0-100 range.
function clamp(v: number, lo: number, hi: number): number { return Math.max(lo, Math.min(hi, v)); } - src/games/oregontrail.ts:322-325 (helper)The log() helper used to record events in the game state's eventLog.
function log(state: OtState, entry: string): void { state.eventLog.push(`Day ${state.day}: ${entry}`); if (state.eventLog.length > 8) state.eventLog.shift(); }