<pre>

# Map & Tile Database Reference
# Last Modified:
#  2004 Michael Wigley


TILE IMAGES:

Primary Database for storing tile images.

    CREATE TABLE $prefix_tile_images (
      TileImageId       mediumint        unsigned NOT NULL auto_increment,
      TileImageSet      varchar(32)      NOT NULL default '',
      TileImagePath     varchar(128)     NOT NULL default '',
      PRIMARY KEY      (TileImageId),
      UNIQUE KEY        TileImagePath   (TileImagePath),
      KEY               TileImageSet    (TileImageSet)
    ) TYPE=MyISAM;

TileImageId:
Primary index

TileImageSet:
Text name for a group of images

TileImagePath:
Physical path to the tiles image relative to PHPRPG_DIR.'/share/images/tiles/'


###############################################################################

TILE TERRAIN:

Primary Database for storing tile terrain (types).

    CREATE TABLE $prefix_tile_terrain (
      TerrainId         smallint     unsigned NOT NULL auto_increment,
      TerrainName       varchar(32)  NOT NULL default '',
      TerrainState      tinyint      unsigned NOT NULL default '0',
      TerrainPortType   tinyint      unsigned NOT NULL default '0',
      TerrainBG         varchar(128) NOT NULL default '',
      PRIMARY KEY      (TerrainId)
    ) TYPE=MyISAM;

TerrainId:
Primary index

TerrainName:
Text name for this terrain

TerrainState:
Numerical reference to physical state of the tile; solid = zero, liquid = one,
vacuum = two

TerrainPortType:
Numerical value representing the access level for crafts on tiles; sea port = one,
air port = two, and space port = four.  The sum of the numbers represents multiple
port types (e.g. A tile that was bot an air and see port would represent that with
a value of three)

TerraineBG:
Physical path to the terrain background image relative to
PHPRPG_DIR.'/share/images/backgrounds/'


###############################################################################

TILE MOVEMENT COST:

Used to store the stamina cost on a tile by tile bases.

    CREATE TABLE $prefix_tile_cost (
      TileCostId    mediumint   unsigned NOT NULL default '0',
      TileCostDN    smallint    unsigned NOT NULL default '0',
      TileCostNE    smallint    unsigned NOT NULL default '0',
      TileCostDE    smallint    unsigned NOT NULL default '0',
      TileCostSE    smallint    unsigned NOT NULL default '0',
      TileCostDS    smallint    unsigned NOT NULL default '0',
      TileCostSW    smallint    unsigned NOT NULL default '0',
      TileCostDW    smallint    unsigned NOT NULL default '0',
      TileCostNW    smallint    unsigned NOT NULL default '0',
      TileCostDU    smallint    unsigned NOT NULL default '0',
      TileCostDD    smallint    unsigned NOT NULL default '0',
      PRIMARY KEY  (TileCostId)
    ) TYPE=MyISAM;

TileCostId:
Primary Key

TileCostDN:
Numerical value representing the Due North stamina cost

TileCostNE:
Numerical value representing the North East stamina cost

TileCostDE:
Numerical value representing the Due East stamina cost

TileCostSE:
Numerical value representing the South East stamina cost

TileCostDS:
Numerical value representing the Due South stamina cost

TileCostSW:
Numerical value representing the South West stamina cost

TileCostDW:
Numerical value representing the Due West stamina cost

TileCostNW:
Numerical value representing the North West stamina cost

TileCostDU:
Numerical value representing the Due Up stamina cost

TileCostDD:
Numerical value representing the Due Down stamina cost


###############################################################################

TILE ATTRIBUTES

Attributes are a way to assign arbitrary values to game components dynamically that
can later be referenced by TileAttribKey

    CREATE TABLE $rpefix_tile_attrib (
      TileAttribId      bigint            unsigned NOT NULL auto_increment,
      TileAttribTarget  mediumint         unsigned NOT NULL default '0',
      TileAttribDeath   int               unsigned NOT NULL default '0',
      TileAttribKey     varchar(32)       NOT NULL default '',
      TileAttribValue   text,
      PRIMARY KEY      (TileAttribId),
      KEY               TileAttribTarget (TileAttribTarget),
      KEY               TileAttribKey    (TileAttribKey)
    ) TYPE=MyISAM;

TileAttribId:
Primary Key

TileAttribTarget:
Links to $prefix_tiles.TileId

TileAttribDeath:
Numeric time stamp representing the UNIX time that the attribute should expire.

TileAttribKey:
Text reference to attribute stored on this tile.

TileAttribValue:
URLEncoded Serialized PHP value for attribute.


###############################################################################

TILE EVENTS:

This table holds the default references to $prefix_scripts.ScriptId that will hold
the script data to exec() when the named event is reached.

    CREATE TABLE $prefix_tile_events (
      TileEventId        mediumint   unsigned NOT NULL auto_increment,
      TileEventEnter     int         unsigned NOT NULL default '0',
      TileEventLeave     int         unsigned NOT NULL default '0',
      TileEventDestroy   int         unsigned NOT NULL default '0',
      PRIMARY KEY      (TileEventId)
    ) TYPE=MyISAM;

TileEventId:
Primary index

TileEventEnter:
Links to $prefix_scripts.ScriptId when a PC enters a tile

TileEventLeave:
Links to $prefix_scripts.ScriptId when a PC leaves a tile

TileEventDestroy:
Links to $prefix_scripts.ScriptId when a PC destroys an alt tile


###############################################################################

TILES:

Used to store the individual tiles that are available to the map editor. Main
information node for tiles that exist in game.

    CREATE TABLE $prefix_tiles (
      TileId            mediumint    unsigned NOT NULL auto_increment,
      TileTerrain       smallint     unsigned NOT NULL default '0',
      TileOverride      tinyint(1)   unsigned NOT NULL default '0',
      TileImage         mediumint    unsigned NOT NULL default '0',
      TileCost          mediumint    unsigned NOT NULL default '0',
      TileEvent         mediumint    unsigned NOT NULL default '0',
      TileName          varchar(32)  NOT NULL default '',
      PRIMARY KEY      (TileId),
      KEY               TileTerrain (TileTerrain)
    ) TYPE=MyISAM;

TileId:
Primary Index

TileTerrain:
Links to $prefix_tile_terrain.TerrainId

TileOverride:
Boolean value representing whether or not a tile could be temporarily overridden by
another tile in order to facilitate structures and other functionality where the
base tile needs to be remembered but another tile take its place; allow = true (one)
. deny = false (zero)

TileImage:
Links to $prefix_tile_images.TileImageId

TileCost:
Links to $prefix_tile_cost.TileCostId

TileEvent:
Links to $prefix_tile_event.TileEventId

TileName:
Text name for this tile


###############################################################################

MAP TABLE:

Used to group all the available maps into one table for easy referencing.  Primary
information node regarding maps existing in game.

    CREATE TABLE $prefix_maps (
      MapId         smallint     unsigned NOT NULL auto_increment,
      MapDefTile    mediumint    unsigned NOT NULL default '0',
      MapSizeX      int          NOT NULL default '0',
      MapSizeY      int          NOT NULL default '0',
      MapSizeZ      int          NOT NULL default '0',
      MapWrapX      int          NOT NULL default '0',
      MapWrapY      int          NOT NULL default '0',
      MapWrapZ      int          NOT NULL default '0',
      MapName       varchar(32)  NOT NULL default '',
      PRIMARY KEY  (MapId),
      UNIQUE KEY    MapName     (MapName)
    ) TYPE=MyISAM;


MapId:
Primary index

MapDefTile:
The default $prefix_tiles.TileId to use when filling in an empty map

MapSizeX:
Numeric value representing the size (tile number) for the width of the map

MapSizeY:
Numeric value representing the size (tile number) for the height of the map

MapSizeZ:
Numeric value representing the size (tile number) for the depth of the map

MapWrapX:
Boolean value representing whether to transport the user x|-x when a map
boarder is reached; transport = true (one), no transport = false (zero)

MapWrapY:
Boolean value representing whether to transport the user y|-y when a map
boarder is reached; transport = true (one), no transport = false (zero)

MapWrapZ:
Boolean value representing whether to transport the user z|-z when a map
boarder is reached; transport = true (one), no transport = false (zero)

MapName:
Text label for this map


###############################################################################

INDIVIDUAL MAP:

Each map that exists in game will have one of these tables to outline it's
properties as they exist (real time) in the game world.

    CREATE TABLE $prefix_map_$MapId (
      LocId             bigint          unsigned NOT NULL auto_increment,
      LocXPos           int             NOT NULL default '0',
      LocYPos           int             NOT NULL default '0',
      LocZPos           int             NOT NULL default '0',
      LocRegion         mediumint       unsigned NOT NULL default '0',
      LocRuler          mediumint       unsigned NOT NULL default '0',
      LocEvents         mediumint       unsigned NOT NULL default '0',
      LocPriTile        mediumint       unsigned NOT NULL default '0',
      LocAltTile        mediumint       unsigned NOT NULL default '0',
      LocAltAR          mediumint       unsigned NOT NULL default '0',
      LocAltHP          mediumint       unsigned NOT NULL default '0',
      LocLinkMapId      int             NOT NULL default '0',
      LocLinkMapLoc     int             NOT NULL default '0',
      LocLinkCost       int             NOT NULL default '0',
      LocTag            varchar(32)     NOT NULL default '',
      LocImage          varchar(64)     NOT NULL default '',
      PRIMARY KEY      (LocLocation),
      UNIQUE KEY        LocCords       (LocXPos,LocYPos),
      KEY               LocRegion      (LocRegion),
      KEY               LocRuler       (LocRuler),
      KEY               LocPriTile     (LocPriTile),
      KEY               LocAltTile     (LocAltTile),
      KEY		LocLink        (LocLinkMapId,LocLinkMapLoc,LinkCost)
    ) TYPE=MyISAM;

LocLocation:
Primary index

LocXPos:
Numeric value representing the horizontal position on the map's surface

LocYPos:
Numeric value representing the vertical position on the map's surface

LocRegion:
Numeric reference to (yet to be developed) regional table for use with political
mapping and other regional based functions

LocRuler:
Numerical reference to (yet to be developed) guild id for use with internal
functionality where knowing who owns a particular tile is essential

LocEvents:
Numerical Reference to $prefix_map_$LocId_event.LocEventId that store the default
events associated to this map location

LocPriTile:
Primary tile for the given map location.  This tile should be placed by the map
editor and should generally never change though any other method than the map
editor.

LocAltTile:
Alternate tile entry for use when (see $prefix_tiles.TileOverride) temporarily
overriding a tile.

LocAltAR:
Numeric value representing the current armor rating of LocAltTile located at this
map location

LocAltHP:
Numeric value representing the current hit point of LocAltTile located at this map
location

LocLinkMapId:
Links to $prefix_map.MapId

LocLinkMapLoc:
Links to $prefix_map_$MapId.LocId of LocLinkMapId

LocTag:
Text reference of the tile, can be used by the GUI for mouse overs or other
informational displays.

LocImage:
Relative path (from PHPRPG_DIR) to GD processed image.  Image will compose of the
primary tile as the base with the alternate tile merged on top of it.  If the
alternate tile is transparent, the base (primary) tile should still be exposed.
Images saved in PHPRPG_DIR.'/tmp/tiles/'


###############################################################################

MAP LOCATION ATTRIBUTES:

Variables that can be assigned to tiles in the game to handle special cases and
other instances where flagging a map location would be useful.

If an action is needed at a certain map location, in addition to the default event,
setting an attribute with the same event type as the event being called (e.g. if an
extra onEnter event is needed then setting the key to that type and giving it an
$prefix_action.ActionId to preform will add that action to the onEnter event) will
alert the event processor and include that event into the event list.

    CREATE TABLE $prefix_map_$MapId_attribs (
      MapAttribId       bigint            unsigned NOT NULL auto_increment,
      MapAttribTarget   bigint            unsigned NOT NULL default '0',
      MapAttribKey      varchar(32)       NOT NULL default '',
      MapAttribValue    text              default NULL,
      PRIMARY KEY      (MapAttribId),
      KEY               MapAttribTarget  (MapAttribTarget),
      KEY               MapAttribKey     (MapAttribKey)
    ) TYPE=MyISAM;

MapAttribId:
Primary index

MapAttribTarget:
Numeric reference to $prefix_map_$MapId.MapLocation for which map location this
attribute modifies.

MapAttribKey:
Text reference for this attribute

MapAttribValue:
Text field for storing the attribute value data


###############################################################################

</pre>