P2C

From Valve Developer Community
Jump to navigation Jump to search

P2C files are used to store the definition of a Portal 2 community puzzle. The format used is similar to that of VMF files, with some small differences.

Concepts

The P2C file format is a simplified representation of a level. It uses a voxel system for blocks and item positioning.

Coordinate System

Locations in P2C files are stored in X Y Z format, where X is right, Y is forward, and Z is up. All coordinates are integers, and represent voxel positions.

Voxels

A level's structure is made up of voxels. Each voxel represents a 1 x 1 x 1 area in the level (where 1 is about equal to one portalable panel). Each voxel may be either solid (a wall) or empty (open space). Additionally, each voxel has 3 sides that can be defined as portalable (white surface) or non-portalable (gray surface). These are the -X, -Y and -Z sides of the voxel. They will be used as the portalable definitions for neighboring voxels (if the specified voxel is not solid and the neighbor is solid).

There is a voxel definition in the P2C file for each point in the map (+1 in each dimension to account for portalable definitions on interior sides), except in the case that the voxel is not solid, and all of its side-sharing neighbors are not solid as well (the three neighboring voxels are each at 1 unit less on one axis - (X - 1, Y, Z), (X, Y - 1, Z), and (X, Y, Z - 1)).

Structure

A P2C file is laid out as follows:

"portal2_puzzle"
{
	// Puzzle Metadata
	"Voxels"
	{
		// Voxel Definitions
	}
	"Items"
	{
		// Item Definitions
	}
	"Connections"
	{
		// Connection Definitions
	}
}

Note that each string in the file is surrounded in quotes (e.g. "Voxels").

Puzzle Metadata

The puzzle metadata block contains information about the puzzle. It looks like this:

	"AppID"		"644"
	"Version"		"12"
	"FileID"		"0x0000000000000000"
	"Timestamp_Created"		"0x000000004FAAF4AD"
	"Timestamp_Modified"		"0x000000004FAAFB4B"
	"CompileTime"		"15.000000"
	"Title"		"My level"
	"Description"		"A deceptively hard test chamber."
	"PreviewDirty"		"1"
	"ChamberSize"		"2 2 4"

The values are as follows:

Key Description
AppID Represents Portal 2 - always "644".
Version The version - currently always "12".
FileID Currently always "0x0000000000000000".
Timestamp_Created The time the puzzle was created.
Timestamp_Modified The time the puzzle was last modified.
Title The name of the puzzle.
Description The description of the puzzle. Can include line breaks.
PreviewDirty Whether or not the preview image is dirty - currently always "1".
ChamberSize The size of the test chamber, in voxels, width x depth x height (X Y Z).

Voxel

Each voxel in the Voxels collection looks like:

		"Voxel"
		{
			"Position"		"0 0 0"
			"Solid"		"1"
			"Portal0"		"1"
			"Portal1"		"1"
			"Portal2"		"1"
		}
Key Description
Position The position of the voxel, in the format "X Y Z".
Solid Whether or not the voxel is solid ("1") or empty space ("0")
Portal0 Whether or not the -X side of the voxel is portalable ("1") or not("0").
Portal1 Whether or not the -Y side of the voxel is portalable ("1") or not("0").
Portal2 Whether or not the -Z side of the voxel is portalable ("1") or not("0").

Item

Each item contains basic information about index, type, location and orientation, with further information depending on the item type (described below). An item looks like:

		"Item"
		{
			"Index"		"0"
			"Type"		"ITEM_ENTRY_DOOR"
			"Deletable"		"0"
			"VoxelPos"		"1 0 0"
			"LocalPos"		"0 0 0"
			"Angles"		"-90 -90 0"
			"Facing"		"0 0 0"
		}
Key Description
Index The index of the item in the puzzle.
Type The type of item.
Deletable Whether the item can be deleted ("1") or not ("2"). Doors and the observation room must not be deletable.
VoxelPos The world position of the item (the voxel the item resides in).
LocalPos
Angles The orientation of the item.[Clarify]
Facing The orientation of freely oriented objects (currently only the turret).

Connections

Connections trigger an action on an item from another item. They have a sender and receiver (both item indices), as well as a type. They look like:

		"Connection"
		{
			"Sender"		"3"
			"Receiver"		"1"
			"Type"		"CONNECTION_STANDARD"
		}
Key Description
Sender The index of the item that sends the signal.
Receiver The index of the item that receives the signal.
Type The type of connection

Connection types

Type Description
CONNECTION_STANDARD

Items

Under construction.png
This page is actively undergoing a major edit.
As a courtesy, please do not edit this while this message is displayed.
If this page has not been edited for at least several hours to a few days, please remove this template. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page.

The person who added this notice will be listed in its edit history should you wish to contact them.