Games::EternalLands::Loader - Access Eternal Lands content files
use Games::EternalLands::Loader; my $loader = Games::EternalLands::Loader->new; $loader->content_path('/usr/share/games/eternal-lands'); use Data::Dumper; my $map = $loader->load('maps/startmap.elm'); print Dumper($map); my $entity = $loader->load('3dobjects/bag1.e3d'); print Dumper($entity); ...
This module reads binary content files for the online game Eternal Lands and unpacks them into perl data structures.
Creates a new Games::EternalLands::Loader object.
Sets the directory where the content files are located. The argument may be a string to set a single path, or an array reference to set multiple paths to be used in turn. If no argument is given the current value (an array reference) is returned.
Finds, opens, reads and constructs the game asset identified by the given name.
In case there is some error opening the file or parsing its contents, undef is returned. A description of the error can be retrieved using the "errstr" method.
See "DATA STRUCTURES" for what exactly is returned in each case.
Returns a string describing the last error that occurred.
The returned value from "load" is a hash reference with the following data in each case.
The maps used by Eternal Lands are tile-based with each 6x6 square of tiles grouped into one terrain square. Each tile has side length 0.5 units in world coordinates. Thus each terrain square has an area in world coordinates of 3 * 3 = 9 square units. A tile represents the smallest unit of space that a dynamic entity (e.g. a player or a creature) can occupy.
6x6
0.5
3 * 3 = 9
Maps returned by "load" have at least the following fields:
The argument passed to load that resulted in this map.
A boolean flag indicating whether this is map represents a location inside a building, cave, etc., or outside.
A 3 element array containing floating-point RGB values.
Number of terrain squares in the first linear dimension of the map (corresponding to the world x-axis).
Number of terrain squares in the second linear dimension of the map (corresponding to the world y-axis).
Total number of terrain squares on the map.
A one-dimensional array containing the terrain number for each terrain coordinate. It contains exactly terrain_count elements. Given a terrain coordinate pair ($tx, $ty), the terrain at that location is
terrain_count
($tx, $ty)
$num = $map->{terrain_map}->[$map->{terrain_length} * $ty + $tx];
The terrain number maps to a texture asset name as
$tex = "3dobjects/tile$num." . $extension;
where $extension is an image file extension (usually "dds").
$extension
NOTE: Terrain number 0 and all numbers between 230 and 255 (not inclusive) are treated as "water" and are drawn at z = -0.25 in world coordinates (rather than at z = 0 like all other terrain squares).
z = -0.25
z = 0
Terrain 255 is the "empty terrain" (a.k.a. "null") and is not drawn at all.
If the map is an indoor map then terrain number 0 is replaced by 231 every time it occurs.
Some maps will refer to missing terrain textures; these are simply ignored rather than being a fatal error. Depending on your application you may wish to notify the user with a warning.
Number of tiles in the first linear dimension of the map (corresponding to the world x-axis).
Number of tiles in the second linear dimension of the map (corresponding to the world y-axis).
Total number of tiles on the map.
An array of length tile_count containing an integer height value for each tile. Given tile coordinates ($x, $y), the corresponding height is found using
tile_count
($x, $y)
$h = $map->{tile_map}->[$map->{tile_length} * $y + $x];
A value of zero indicates that the tile is impassable. Otherwise the value maps to a coordinate along the world z-axis as
$z = $h * 0.2 - 2.2;
NOTE: When drawing the map the tile's height value affects only where dynamic entities such as players, bags, etc. are drawn; terrain squares are always drawn at z = 0 in world space (except for water terrains, which are drawn at z = -0.25).
An array of hashes each containing at least the fields:
An array of hashes representing particle systems each containing at least the fields:
Static 3D objects on the map are represented using triangular face-vertex meshes. Each mesh is further subdivided into a small number of submeshes each with its own texture (or two textures in some cases).
An array of hashes each containing:
NOTE: Some fields may not appear, but for any given mesh all vertices will have the same fields present.
An array containing indices into the vertices array for each triangular face. So the first three elements correspond to the three vertices making up the first triangle, the second three the second triangle, and so on.
vertices
An array of hashes each containing at least:
indices
These are static rectangular map objects generally used for ground details. For consistency with "Mesh Entities" their geometric data is also given in a triangular face-vertex format, albeit without submeshes.
Cole Minor, <coleminor at hush.ai>
<coleminor at hush.ai>
Copyright (C) 2012 Cole Minor. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Games::EternalLands::Loader, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::EternalLands::Loader
CPAN shell
perl -MCPAN -e shell install Games::EternalLands::Loader
For more information on module installation, please visit the detailed CPAN module installation guide.