| 1 |
TECHNICAL INFORMATION ABOUT MAPS: |
| 2 |
|
| 3 |
This documented is intended to convey technical information on how |
| 4 |
crossfire deals with the map objects and objects placed on the maps. For |
| 5 |
the most part, I only intend document how the new code works, and not |
| 6 |
go too much into history on the older methods. A lot of the map |
| 7 |
code was re-written in early July 2001, which changed how many things are |
| 8 |
dealt with. |
| 9 |
|
| 10 |
Mark Wedel |
| 11 |
July 7, 2001 |
| 12 |
------------------------------------------------------------------------------ |
| 13 |
Contents: |
| 14 |
|
| 15 |
1. THE MAP HEADER |
| 16 |
2. THE MAP OBJECTS |
| 17 |
3. Map Tiling |
| 18 |
4. STACKING OF OBJECTS ON THE MAP |
| 19 |
|
| 20 |
------------------------------------------------------------------------------ |
| 21 |
1. THE MAP HEADER: |
| 22 |
|
| 23 |
The map header is the section at the start of the map file that |
| 24 |
describes the maps characteristics. The values are described below. |
| 25 |
|
| 26 |
The map variables now make some sense, and are only stored in the |
| 27 |
map structure itself. I still include the old value (the 'was') so |
| 28 |
if you are looking at old maps, you know what they mean. Generally |
| 29 |
speaking, the values in the map files themselves match the same element |
| 30 |
name in the map structure. |
| 31 |
|
| 32 |
'width','height', was 'x','y': Size of the map. |
| 33 |
|
| 34 |
'enter_x', 'enter_y', was ('hp','sp') = (x,y) of the destination on the |
| 35 |
new map. These are only used if the exit does not have a specific |
| 36 |
location set. |
| 37 |
|
| 38 |
'reset_timeout', was 'weight': stores the number of seconds that need |
| 39 |
to elapse before this map will be reset. Ie, if 1800, it means this |
| 40 |
map expires after 30 minutes. This value is not modified once loaded - |
| 41 |
instead reset_time is used to track this. The value 0 means to use |
| 42 |
a default timeout (MAP_DEFAULTRESET). |
| 43 |
|
| 44 |
'swap_time', was 'value': This controls how many ticks must elapse |
| 45 |
after the map has not been used before it gets swapped out. |
| 46 |
Swapping out is different than reset, as a swapped out map will |
| 47 |
get loaded back into memory if someone re-visits it before it is due to |
| 48 |
reset. |
| 49 |
|
| 50 |
'difficulty', was 'level' stores the map difficulty. If not set to |
| 51 |
anything, the server code will try to come up with some difficulty value. |
| 52 |
|
| 53 |
'fixed_resettime', was 'stand_still': If nonzero, the map reset time will not |
| 54 |
be updated when someone enters/exits the map. Thus, once the map has |
| 55 |
been loaded, it will reset in 'reset time' no matter what access |
| 56 |
happen. This is useful for shops and towns, which are constantly |
| 57 |
accessed, but should be reset periodically. |
| 58 |
|
| 59 |
'darkness', was 'invisible'. Light/darkness of map (overall). If 0, |
| 60 |
all of map is fully bright. |
| 61 |
|
| 62 |
'unique' - if set, this entire map is unique. Exactly unique to what |
| 63 |
will depend on how it was created (it could be a per player |
| 64 |
unique map, or maybe a common map that is just permanent for |
| 65 |
all the players. |
| 66 |
|
| 67 |
'nosmooth' - if set, no faces in this map will be smoothed. |
| 68 |
|
| 69 |
'outdoor' - if set, this is a hint that this is an outdoor map. |
| 70 |
If this is not set, weather and dawn/dusk will not occur on this |
| 71 |
map. It is highly advised that this be set appropriately. |
| 72 |
|
| 73 |
tile_path_<x> - Used with map tiling. <x> is a number, 1 is north, |
| 74 |
2 is east, 3 south, 4 west. This determines what map is tiled |
| 75 |
in that direction. See the section below for more information about |
| 76 |
map tiling. |
| 77 |
|
| 78 |
'shopitems', 'shopgreed', 'shoprace', 'shopmin', 'shopmax' - the type of thing |
| 79 |
the shop trades in, see doc/Developers/shops for more details |
| 80 |
|
| 81 |
------------------------------------------------------------------------------ |
| 82 |
2. THE MAP OBJECTS: |
| 83 |
|
| 84 |
The objects within the map are saved in standard 'object save' form |
| 85 |
(same as is used for the players objects). Other files document the |
| 86 |
actual meaning, but the general form is: |
| 87 |
|
| 88 |
arch <some name> |
| 89 |
x <some value> |
| 90 |
y <some value> |
| 91 |
<other object specific values> |
| 92 |
end |
| 93 |
|
| 94 |
Note that x and y are in fact optional. If not present, the values |
| 95 |
default to zero. |
| 96 |
|
| 97 |
Multipart objects: |
| 98 |
|
| 99 |
Multipart objects pose a tricky problem, in that they have to |
| 100 |
appear together in the map file - this makes proper handling of |
| 101 |
layers hard to deal with. |
| 102 |
|
| 103 |
In old map code, all the single spaces objects were saved, and |
| 104 |
then all the multi part objects were saved. This effectively |
| 105 |
means that the multi part objects always ended up on top. The multipart |
| 106 |
objects were saved with all their parts. For example: |
| 107 |
|
| 108 |
slaying shops/magicshop |
| 109 |
hp 14 |
| 110 |
sp 14 |
| 111 |
x 1 |
| 112 |
y 13 |
| 113 |
end |
| 114 |
More |
| 115 |
arch store_magic_2 |
| 116 |
name Magic Shop |
| 117 |
slaying shops/magicshop |
| 118 |
hp 14 |
| 119 |
sp 14 |
| 120 |
x 2 |
| 121 |
y 13 |
| 122 |
end |
| 123 |
<snip - there are really two more parts> |
| 124 |
|
| 125 |
This method does not work very well with the map tiling however (how do you |
| 126 |
reasonably deal with a monster that may be straddling the two maps?) Current |
| 127 |
code now only saves the head of the object. When the map is loaded, the |
| 128 |
objects on the map are examined to see what objects need to have more objects |
| 129 |
added on. Additional parts linked in are put just above floor level when |
| 130 |
linked in, so things like shops won't hide items that someone drops on them. |
| 131 |
For monsters, this linking shouldn't be a problem - once they start moving, |
| 132 |
they will get relinked as normal (on top). |
| 133 |
|
| 134 |
The effect of saving only the head does have the effect of not being |
| 135 |
able to customize the non head parts of the object. This generally should not |
| 136 |
be a problem (in the case of shops/building, the exit code now knows to look |
| 137 |
only at the head for valid information). The case where this may not work as |
| 138 |
well as expected is for buildings where setting the move_block to non |
| 139 |
archetype defaults will get lost. |
| 140 |
|
| 141 |
------------------------------------------------------------------------------ |
| 142 |
3. Map Tiling: |
| 143 |
|
| 144 |
Map tiling is a feature that lets multiple maps be connected, effectively |
| 145 |
forming a much larger single map. This is most useful for the outdoor |
| 146 |
world maps, where it is not practical to have on massive map, but |
| 147 |
the old style tiling method (copying areas of the adjoining map to the next |
| 148 |
one) are not very efficient. |
| 149 |
|
| 150 |
The transfer of objects from one map to another tiled map are automatic. |
| 151 |
Presuming the proper macros are used (out_of_map, get_map_..), minimal extra |
| 152 |
work is necessary for everything to work right |
| 153 |
|
| 154 |
Notes: |
| 155 |
Tiled maps must be the same width/height along the side they are tiled with. |
| 156 |
If map1 has a height of 15, and you want to tile along one of the sides, the |
| 157 |
map(s) it gets tiled with along that side should also be 15. Given |
| 158 |
the following diagram (not to scale): |
| 159 |
|
| 160 |
|
| 161 |
+---x1----+----x2---+ |
| 162 |
| | | |
| 163 |
| map1 | map2 y2 |
| 164 |
y1 | | |
| 165 |
| | | |
| 166 |
+---------+---------+ |
| 167 |
|
| 168 |
x1 is the width of map1, y1 is its height. |
| 169 |
x2 is the width of map2, y2 is its height. |
| 170 |
map1 will tile map2 as indicated in the above diagram. |
| 171 |
|
| 172 |
Given that, the following must be true: |
| 173 |
y1 must equal y2 |
| 174 |
x1 must be greater than 12 |
| 175 |
x2 must be greater than 12 |
| 176 |
x1 and x2 do not need to be equal |
| 177 |
|
| 178 |
The value is derived as being half the maximum viewable area. The reason |
| 179 |
for this is that the line of sight code (and likely some other code) will only |
| 180 |
look one map away from a source coordinate. While the values can be less |
| 181 |
than 12, they should be at least 12 if the map tiles with another one in |
| 182 |
that direction. If the map is an 'end' map (ie, no further tiling in a |
| 183 |
specific direction), then having a value less than 12 should work just fine. |
| 184 |
|
| 185 |
Note that tiles maps do not have to be symmetric - several maps |
| 186 |
could tile to a common map. That common map can only tile back to one of |
| 187 |
those. And example of where this might be used is for a courtyard of |
| 188 |
a multi floor house - that courtyard should be visible (and be the same) |
| 189 |
from all the levels, but you can only go from the courtyard to first floor |
| 190 |
rooms off the courtyard. This may not be ideal (ie, if flying, you should |
| 191 |
be able to go to any floor), but this tiling for elevation is just an |
| 192 |
example that can be used. |
| 193 |
|
| 194 |
------------------------------------------------------------------------------ |
| 195 |
4. STACKING OF OBJECTS ON THE MAP |
| 196 |
|
| 197 |
The stacking of objects on a map is somewhat confusing. This is because there |
| 198 |
are really two stacks a designer may care about - the actual stacking of |
| 199 |
objects on the map (as op->above points to) and the stacking of objects as they |
| 200 |
appear to the client. |
| 201 |
|
| 202 |
It is usually the appearance in the client the designers care most about. |
| 203 |
However, actual stacking in the code can be important - some objects only look |
| 204 |
for objects above them - if you put a teleporter above a sword, that is |
| 205 |
different than if you put the teleporter below the sword. |
| 206 |
|
| 207 |
When loading a map from disk, the server will keep the same stacking order as |
| 208 |
set in the map. Note however that multipart (big) objects are handled |
| 209 |
specially - because only the head of the object is saved, the stacking for the |
| 210 |
non head objects is always right above the floor. So if you put a troll down, |
| 211 |
with its head above a sword, when the rest of it is linked in, those other |
| 212 |
parts will be below any items on the ground. |
| 213 |
|
| 214 |
Additional objects put on the space during play will generally be in stack |
| 215 |
order - newest object is on top. The one real exception is that flying |
| 216 |
objects (spells typically) will always be put on the top of the space, and |
| 217 |
then followed by non flying objects. So if a sword is dropped on a space with |
| 218 |
a bunch of active spell objects, within the server stacking, the sword will be |
| 219 |
below the spell objects, but above other objects on the space. |
| 220 |
|
| 221 |
This ordering of objects in the server has little relation to how things |
| 222 |
appear in the client. With the client (and map2 protocol command), there are |
| 223 |
10 visible layers, displayed in following order (from bottom up): |
| 224 |
|
| 225 |
Floor (by definition, nothing beneath a floor is visible) |
| 226 |
no_pick (2) - things like signs, savebeds, runes |
| 227 |
item (3) - swords, armor, scrolls, arrows, etc |
| 228 |
living (2) - monsters |
| 229 |
fly (2) - spells, arrows, some monsters |
| 230 |
|
| 231 |
The number in parentheses are the number of layers for those type of objects. |
| 232 |
So while there are 10 visible layers, in most cases, at least a few will not |
| 233 |
be used. If there are 50 items (swords, bows) on a space, the client will |
| 234 |
still only be sent information on 3 of them. It will not use the other |
| 235 |
layers, as only items will be sent in the items layer. |
| 236 |
|
| 237 |
In most all cases, the server automatically figures out what layer an object |
| 238 |
belongs to based on various flags (FLAG_IS_FLOOR, FLAG_NO_PICK, etc). |
| 239 |
|
| 240 |
An object/map maker can override these values with the 'map_layer' object |
| 241 |
parameter. For example, if a map maker wanted to make what appears to be a |
| 242 |
flying statue, they would just put in 'map_layer fly' in the object |
| 243 |
definition. The names listed above are the correct names used for the loading |
| 244 |
of objects. |
| 245 |
|
| 246 |
There can be other cases where map maker want to change layering. A current |
| 247 |
case is levitation boots - because they seem to fly, they would normally |
| 248 |
always be drawn on top of other objects. The archetype sets the map_layer |
| 249 |
flag to item, so that they will be drawn with the rest of the pickable |
| 250 |
objects. |
| 251 |
|
| 252 |
In cases of there being more objects of a type than can be displayed on a |
| 253 |
space, the first fallback is to look at the visibility of the defined face. |
| 254 |
Visibility is a face, not object, attribute, but is used when certain objects |
| 255 |
should take viewing precedence over others. An example of its use is |
| 256 |
buildings and exits - you pretty much always want those visible, even if there |
| 257 |
are other non pickable objects on the space (or a player casts some runes). |
| 258 |
|
| 259 |
If the visibility for the face is the same, the last fallback is server (map) |
| 260 |
stacking. In this case, the object on the top of the stack will take |
| 261 |
precedence of objects further down. Note however that visibility is always |
| 262 |
used to put important objects higher on the space as far as the clients sees |
| 263 |
them. For example, suppose we have the following space with objects with the |
| 264 |
hypothetical visibilities: |
| 265 |
|
| 266 |
mace (50) |
| 267 |
sword (50) |
| 268 |
bow (100) |
| 269 |
shield (50) |
| 270 |
floor (50) (this is included just to make stacking order clear). |
| 271 |
|
| 272 |
One might look at that and think that since shield is at the bottom and |
| 273 |
doesn't have high visibility, order would be mace, sword, bow, floor (shield |
| 274 |
getting dropped). |
| 275 |
|
| 276 |
But that is not the case - the high visibility of the bow causes it to be |
| 277 |
virtually placed above the other objects in the map view, so actual view would |
| 278 |
be bow, mace, sword, floor |
| 279 |
|
| 280 |
Because visibility is not an object attribute, there is generally little that |
| 281 |
can be done to control this, other than to set up the appropriate stacking. |
| 282 |
|