2026-02-20 10:16:03 -08:00
2026-02-20 10:16:03 -08:00
2026-02-20 10:16:03 -08:00
2026-02-20 10:16:03 -08:00
2026-02-20 10:16:03 -08:00
2026-02-20 10:16:03 -08:00

King's Quest IV: The Perils of Rosella - Interaction Documentation

A comprehensive documentation of all game interactions extracted from the decompiled SCI (Sierra's Creative Interpreter) source code. This project documents the logic, conditions, state changes, and dependencies for recreating King's Quest IV as a modern point-and-click adventure.

Repository Structure

/
├── rooms/                          # Room-specific interaction documentation
│   ├── kq4-001.md                  # Beach (starting room)
│   ├── kq4-002.md                  # Beach continuation
│   ├── kq4-007.md                  # Fisherman's shack exterior
│   ├── kq4-042.md                  # Fisherman's cottage interior
│   └── ...                         # One file per room
├── KQ4_v1.006.004_int0.000.502_SRC_(6)/
│   └── src/                        # Decompiled SCI scripts
│       ├── Main.sc                 # Game engine & global handlers
│       ├── Game.sc                 # Core game classes
│       ├── Feature.sc              # Object interaction framework
│       ├── InvI.sc                 # Inventory system
│       ├── rm1.sc - rm99.sc        # Room scripts
│       └── *.sc                    # Various utility scripts
└── README.md                       # This file

Source Code Overview

File Types

  • .sc files: Sierra Script source code (main logic)
  • .sco files: Compiled script object files (not human-readable)
  • game.sh: Header file with game constants and defines

Key Source Files

File Purpose
Main.sc Global game state, inventory, death handlers, sound management
Game.sc Core Game class, save/load system, event handling
Feature.sc Base classes for interactive objects (Feature, View, Actor)
InvI.sc Inventory item definitions and display logic
Class_255_0.sc Low-level system procedures and kernel functions
rm##.sc Individual room scripts (rooms 1-99)
*Reg.sc Region scripts (shared logic for multiple rooms)

Room Script Anatomy

Each room script (rm##.sc) typically contains:

Room## of Rm                    # Room class definition
├── Properties
│   └── picture                 # Background image number
├── Methods
│   ├── init()                  # Room initialization
│   │   ├── north/south/east/west  # Exit directions
│   │   ├── horizon             # Walkable area boundary
│   │   ├── setRegions:         # Apply shared region logic
│   │   ├── Props/Actors/Views  # Interactive objects
│   │   └── gEgo positioning    # Player start position
│   ├── doit()                  # Per-frame logic (rarely used)
│   ├── handleEvent()           # Text parser input handling
│   └── dispose()               # Cleanup when leaving room
└── Instances
    ├── Scripts                 # Multi-step sequences
    ├── Props                   # Animated objects
    ├── Views                   # Static scenery
    └── Sounds                  # Audio effects

Game Systems

Parser Commands

The original game uses a text parser with verb-noun structure:

  • Said 'look/grass' - Player typed "look at grass"
  • Said 'use/key' - Player typed "use key"
  • Said 'take/diamond' - Player typed "take diamond"
  • Said '[<around][/room]' - "look around" or "look room"

State Management

Global variables track game state:

Variable Purpose
gEgo Player character object
gRoom Current room instance
gPrevRoomNum Previous room number
gInv Inventory collection
global100 Unknown flag (weather/time?)
global101 Room has been visited
global116 Story progression state
global105 Multi-path room state

Inventory System

Items referenced by index in gInv at: ##:

Index Item
1 Diamonds
17 Fishing pole
... (others documented per-room)

Message System

Text displayed via Print scriptNum messageNum:

  • Print 1 0 = Message 0 from script 1
  • Messages stored separately in RESOURCE files
  • To be extracted and added to room documentation

Looking Up Text in the Strings Directory

Message text is extracted and stored in the strings/ directory:

File Pattern Contents
strings/script_XXX_strings.txt Script-specific strings (room names, object names)
strings/text_XXX.txt In-game dialog and message text

To look up a message:

  1. Identify the script number from the Print command (e.g., Print 2 1 = script 2, message 1)
  2. Open strings/text_XXX.txt where XXX matches the script number
  3. Find the entry with the matching message number (e.g., [0001])

Example:

Print 2 1  →  Look in strings/text_002.txt, line [0001]
Result: "You see a river in the distance to the north."

Note: Message numbers in the code start from 0 and are displayed in brackets (e.g., [0001] = message 1).

Room Documentation Format

Each room file follows this structure:

# Room ##: [Room Name]

## Overview
- **Room Number**: ##
- **Picture**: ###
- **Region**: [Beach/Forest/Castle/etc.]
- **Exits**: North→#, South→#, East→#, West→#

## Objects

### [Object Name]
- **Type**: Prop/View/Actor
- **Position**: (x, y)
- **View**: ### (sprite/animation resource)
- **States**: [list of possible states]

#### Interactions

**Look**:
- Condition: [when visible]
- Text: "Message from game"
- Logic: [simplified state check]

**Use [Item]**:
- Condition: [inventory check]
- Effect: [what happens]
- State Change: [global or local variable changes]

## NPCs

### [Character Name]
- **Type**: Actor
- **Behavior**: [wandering, stationary, scripted]

#### Dialogue
- **Greeting**: [initial interaction]
- **Topics**: [what player can ask about]
- **Conditions**: [when available]

## Scripts

### [Script Name]
- **Trigger**: [what starts it]
- **Steps**: [sequence of actions]
- **State Changes**: [what it modifies]

## Walkthrough Integration

- **Critical Path**: [essential interactions]
- **Optional**: [side content]
- **Deaths**: [ways to die in this room]

Conversion Notes for Point-and-Click

When adapting to a KQ5-style interface (walk, look, hand, talk, inventory):

  1. Walk: Automated - player clicks destination, character walks there
  2. Look: Maps to Said 'look/object' commands
  3. Hand: Maps to Said 'use/object', Said 'take/object', Said 'open/object'
  4. Talk: Maps to Said 'talk/person' or Said 'ask/person/about'
  5. Inventory: Click item, then click target (replaces Said 'use/item/on/target')

Simplifications Made

  • Auto-walking: No manual positioning needed
  • Context-sensitive: Combine look/take/use based on object type
  • Smart defaults: Auto-select appropriate verb for known object types
  • Inventory drag: Drag item to target instead of typing commands

Message Extraction Status

Status Description
Pending Text resources not yet extracted from RESOURCE.### files
📝 Documented Text added to room files

Text messages referenced as Print scriptNum messageNum will be extracted from the game's RESOURCE files and added to each room's documentation.

Contributing

When adding room documentation:

  1. Read the corresponding rm##.sc file
  2. Document all handleEvent interactions
  3. Note all Props, Views, and Actors
  4. Track state dependencies (global variables)
  5. Include original text when available
  6. Describe simplified logic for point-and-click adaptation

Progress

Room Number Room Description Status
001 Beach DONE
002 Meadow (with Satyr/Pan) DONE
003 Fountain Pool DONE
004 Ogre's Cottage Exterior DONE
005 Forest Grove DONE
006 Cave Entrance DONE
007 Fisherman's Shack Exterior DONE
008 Back of Fisherman's Shack DONE
009 Shady Wooded Area DONE
010 Forest Path DONE
011 Enchanted Grove DONE
012 Haunted Forest DONE
013 Beach DONE
014 Green Meadow DONE
015 The Frog Pond DONE
016 Graveyard DONE
017 Spooky House Exterior DONE
018 Cemetery DONE
019 Coastal Cliffs DONE
020 Meadow DONE
021 Bridge Over Stream DONE
022 Gnome's Cottage DONE
023 Forest Path with Cottage DONE
024 Waterfall and Pool DONE
025 Beach at River Delta DONE
026 River Meadow DONE
027 Forest Path DONE
028 Mine Entrance DONE
029 Dense Forest DONE
030 Mountain Pass DONE
031 Open Ocean DONE
032 Ocean Near Island DONE
033 Enchanted Island Beach DONE
034 Island Beach DONE
035 Island Beach DONE
036 Island Garden Pond DONE
037 Fairy Island DONE
038 Island Garden DONE
039 Island Beach DONE
040 Island Beach (East) DONE
041 Island Shore DONE
042 Fisherman's Cottage Interior DONE
043 Desert Island DONE
044 Inside Whale DONE
045 Genesta's Bed Chamber DONE
046 Tower Stairway DONE
047 Genesta's Palace Entry Hall DONE
048 Ogre's Bedroom DONE
049 Ogre's Cottage DONE
050 Ogress's Kitchen DONE
051 Ogre's Closet DONE
052 N/A (doesn't exist)
053 Seven Dwarfs' Bedroom DONE
054 Seven Dwarfs' Cottage DONE
055 Seven Dwarfs Diamond Mine DONE
056 Seven Dwarfs' Diamond Mine (West) DONE
057 Witches' Cave DONE
058 Tower Organ Room DONE
059 Baby Nursery DONE
060 Bedroom DONE
061 Tower Stairs DONE
062 Bedroom DONE
063 Attic DONE
064 Old Dining Room DONE
065 Old Kitchen DONE
066 Secret Tower DONE
067 The Parlor DONE
068 The Foyer DONE
069 The Crypt DONE
070 Waterfall Cave DONE
071 Cave Entrance DONE
072 Dark Cave Passage DONE
073 Cave Exit DONE
074 Troll Cave DONE
075 Troll Cave Passage DONE
076 Dark Chasm DONE
077 Swamp DONE
078 Swamp Island DONE
079 Mountain Path to Dark Castle DONE
080 Lolotte's Castle Entrance DONE
081 Edgar's Tower Bedroom DONE
082 Lolotte's Tower Bedroom DONE
083 Castle Dungeon Cell DONE
084 Cottage Front DONE
085 Dark Tower Stairs DONE
086 Dim Hallway (West End) DONE
087 East End of Hallway DONE
088 Stone Tower Stairs DONE
089 Castle Kitchen DONE
090 West Tower Bottom DONE
091 Castle Dining Room DONE
092 Lolotte's Throne Room DONE
093 Bottom of East Tower DONE
094 Unicorn Stable DONE
095 Fisherman's Pier DONE
096 N/A (doesn't exist)
097 N/A (doesn't exist)
098 Transitional Room DONE
099 Transitional Room DONE

Credits

  • Original Game: Sierra On-Line (1988)
  • Decompilation: Unknown decompiler tools
  • Source Code: King's Quest IV v1.006.004
  • Documentation: Created for remake project

License

This documentation is for educational and preservation purposes. King's Quest IV is a trademark of Sierra On-Line/Activision.

Description
No description provided
Readme 10 MiB
Languages
Scala 90.1%
Python 4%
C 2.9%
Csound Score 2.1%
DIGITAL Command Language 0.4%
Other 0.5%