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 documentation (one directory per room)
│ ├── kq4-001-beach/ # Beach (starting room)
│ │ ├── 001-beach.md # Room documentation
│ │ ├── pic_001_visual.png # Background visual
│ │ ├── pic_001_control.png # Control (walkable areas)
│ │ └── pic_001_priority.png # Priority (z-ordering)
│ ├── kq4-002-meadow/ # Meadow (with Satyr/Pan)
│ ├── kq4-010-forest-path/ # Forest Path
│ └── ... # One directory per room
├── docs/scripts/ # Non-room script documentation
│ └── non-room-scripts.md # Core, region, and interaction scripts
├── 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
.scfiles: Sierra Script source code (main logic).scofiles: 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:
- Identify the script number from the
Printcommand (e.g.,Print 2 1= script 2, message 1) - Open
strings/text_XXX.txtwhere XXX matches the script number - 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):
- Walk: Automated - player clicks destination, character walks there
- Look: Maps to
Said 'look/object'commands - Hand: Maps to
Said 'use/object',Said 'take/object',Said 'open/object' - Talk: Maps to
Said 'talk/person'orSaid 'ask/person/about' - 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.
Generating Room Visuals
Each room directory contains rendered PNG images of the game's PIC resources:
Using sci_pic_render
./sci_pic_render <room_number> "<path_to_game>" <output_directory>
Example:
./sci_pic_render 1 "King's Quest IV - The Perils of Rosella (1988)/KQ4" rooms/kq4-001-beach
This generates three PNG files in the room directory:
pic_###_visual.png- The background visualpic_###_control.png- Control (walkable areas)pic_###_priority.png- Priority (z-ordering)
Directory Structure
rooms/
├── kq4-001-beach/
│ ├── 001-beach.md # Room documentation
│ ├── pic_001_visual.png # Background
│ ├── pic_001_control.png # Walkable areas
│ └── pic_001_priority.png # Z-ordering
└── kq4-010-forest-path/
└── ...
Contributing
When adding room documentation:
- Read the corresponding
rm##.scfile - Document all
handleEventinteractions - Note all Props, Views, and Actors
- Track state dependencies (global variables)
- Include original text when available
- 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 |
Non-Room Scripts
In addition to room-specific documentation, this project also documents the game's non-room scripts including core system scripts, region scripts, and interaction scripts.
| Category | Description | Documentation |
|---|---|---|
| Core System | Main.sc, Game.sc, Feature.sc, InvI.sc, Sound.sc, etc. | Non-Room Scripts |
| Region Scripts | BeachReg.sc, Forest Region.sc, GhostWander.sc, etc. | Non-Room Scripts |
| Interaction Scripts | PlayFlute.sc, ShootBow.sc, ReadBook.sc, etc. | Non-Room Scripts |
| Special/Cutscene | Intro.sc, CopyProtect.sc, EndMusic.sc | Non-Room Scripts |
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.





























































































