# Room 22: Gnome's Cottage

This is a charming woodland scene featuring a cozy cottage built into a massive ancient tree. The room serves as a key location with the gnome's cottage - players can interact with the door, window, water wheel, and flowers. The cottage door is lockable and leads to room 54 (inside the cottage). The room features multiple animated elements (birds/bats in the sky) and is adjacent to the stream (room 21), the forest path (room 23), and higher ground (room 16).

## Look Description

"You have come upon a cute little house, built right into a huge tree! An old water wheel, attached to the house, goes unused beside the little river that flows gently before the house."

## Interactions

| Status | Behavior Type | Command | Response |
|--------|--------------|---------|----------|
| TODO | Look | `look/cottage` / `look/house` | "The roots of this great tree envelop a little, snug house. Smoke lazily curls from its chimney, and an old rustic water wheel rests beside the river." |
| TODO | Look | `look/window` (when near window) | "You peek through the window, but can make out no details." (Print 22 1) |
| TODO | Look | `look/window` (when not near window) | "You can't do that." (Print 800 1) |
| TODO | Look | `look/blossom` / `look/flower` | "There are flowers here and there." (Print 22 2) |
| TODO | Get | `get/blossom` / `get/flower` | "It would waste your precious time to stop and pick flowers." (Print 22 3) |
| TODO | Look | `look/door` | "It's a small wooden door." (Print 22 4) |
| TODO | Action | `break/window` | "That's vandalism!" (Print 22 5) |
| TODO | Action | `break/door` | "You could never do that." (Print 22 6) |
| TODO | Action | `open/window` | "The windows do not open." (Print 22 7) |
| TODO | Action | `open/door` (when near door) | Multiple responses based on door state - see table below |
| TODO | Action | `open/door` (when not near door) | "You can't do that." (Print 800 1) |
| TODO | Action | `unlatch/door` (when near door, door locked) | "The door is already unlocked." (Print 22 10) |
| TODO | Action | `unlatch/door` (when near door, door unlocked) | "You can't. You don't have the key." (Print 22 11) |
| TODO | Action | `bang/door` / `knock/door` (when door unlocked) | "Go away!" (Print 22 12) |
| TODO | Action | `bang/door` / `knock/door` (when has key) | "You knock loudly on the small door and hear a shuffling from inside. A sleepy voice calls out, 'We're all asleep here! Come back tomorrow!'" (Print 22 13) |
| TODO | Action | `bang/door` / `knock/door` (when no key) | "You knock loudly on the small door. No answer." (Print 22 14) |
| TODO | Look | `look/wheel` / `look/water wheel` | "The water wheel appears run-down, and is currently not in use." (Print 22 15) |
| TODO | Look | `look/room` / `look[<around>]` / `look` | "You have come upon a cute little house, built right into a huge tree! An old water wheel, attached to the house, goes unused beside the little river that flows gently before the house." |

### Door State Responses

When using `open/door` near the door:

| Door State | Response |
|------------|----------|
| `local0 = 1` (door unlocked) | "That would not be a good idea right now." (Print 22 8) |
| `global100 = 0` (no key) | Door opens with animation, leads to room 54 |
| `global100 = 1` (has key) | "You can't. It's locked and you don't have the key." (Print 22 9) |

## Scripts

| Status | Behavior Type | Name | Trigger | Behavior |
|--------|--------------|------|---------|----------|
| TODO | Interaction | doorActions | Entry from room 53 or 54 when global102 = 2 | Door is opened from the other side - plays door animation from closed (cel 0) to open, displays message "...and STAY OUT!" |
| TODO | Background | door | Init (always running) | Door prop (view 612) at position 179,111 - cel 0 closed, cel 1+ open animation |
| TODO | Background | newProp | Init (always running) | Animated element (view 627, loop 0) at position 158,25 - cel 3, likely sky element (bird/bat) |
| TODO | Background | newProp_2 | Init (always running) | Animated element (view 656, loop 0) at position 23,110 |
| TODO | Background | newProp_3 | Init (always running) | Animated element (view 656, loop 1) at position 309,156 |
| TODO | Background | newProp_4 | Init (always running) | Animated element (view 656, loop 2) at position 226,168 |
| TODO | Background | newProp_5 | Init (always running) | Animated element (view 656, loop 3) at position 41,125 |

## Technical Notes

- **Room Number**: 22
- **Picture**: 22
- **Regions**: 501 (WaterReg), 512 (RiverReg), 508 (Forest Region)
- **Exits**: North→16, South→28, East→23, West→21
- **Horizon**: 75

### Region Interactions

The room applies three region scripts:

1. **WaterReg (501)**: Handles terrain-based ego view changes when walking on different surfaces
2. **RiverReg (512)**: River-related interactions (look in/at brook, fish, bathe, drink, wade)
3. **Forest Region (508)**: Forest interactions (look at boulder, grass, bush, flora, blossoms, forest, crow)

### State Variables

| Variable | Values | Description |
|----------|--------|-------------|
| `global101` | 0 | Reset to 0 on room entry |
| `global100` | boolean | Door key flag - if set, player has the key (door can be opened) |
| `global102` | 2 | Set to 2 when entering from rooms 53 or 54 |
| `local0` | 0, 1 | Door state - 1 = door has been opened/unlatched from inside |

### Additional Technical Details

- Room uses setRegions: 501 512 508
- Door position zone: 170-202 x, 112-120 y (used for door interactions)
- Window position zones: 140-170 x, 112-124 y OR 170-202 x, 112-120 y
- Priority zone: 167-201 x, 140-149 y - player gets elevated priority (setPri: 11) when in this area (in front of door)
- Player enters in normal form (view 2)
- When global100 is set, overlay 122 is displayed on top of the base picture
- When global100 is set, door starts in open state (loop: 1) instead of closed (loop: 0)
- Entry from room 53 or 54 with global102 = 2 triggers doorActions script (door opened from inside)
- Entry from room 16 (north) positions ego at horizon + yStep + 1
- Entry from room 21 (west) has special y-position handling based on horizon
- Entry from room 23 (east) positions ego at far right edge (x: 317)
- Entry from room 28 (south) positions ego at bottom (x: 171, y: 188)
- Sound 300 plays when door is opened
- Door animation cycles from cel 0 (closed) to end cel (open), then triggers room change to 54
