[CF-Devel] Patch: map building, hopefully the stable one :)

crossfire-devel at archives.real-time.com crossfire-devel at archives.real-time.com
Fri Nov 28 17:03:03 CST 2003


Hello.

I finally finished basic map building stuff in a 'decent' way, so here it is :)

Attached archive includes:
* build.patch: patch for the code
* build_map.c: new file, to be put into server/ subdirectory (or elsewhere, as 
long as you build it :)
* mapbuilding: subdir that goes somewhere in your arch/ folder
* apartments: modified version of Scorn's apartment
* buildshop: hacked alchemy shop from Scorn for building material. Made to be 
linked from the shop just west of potions/alchemy shop

I leave to you the procedure to patch & rebuild archs & thus.
Note: my patch will not change autoconf/makefiles/... to build build_map.c, you 
may need to add it.
Also, I didn't find how the 'artifacts' file is generated, so i just patched it 
directly (from /lib).

To test the patch, you need to have a unique map with the correct flags: set 
'is_buildable' (new flag) to all walls/floors the player will be able to build 
on. For those squares, set the type for walls to 'WALL' (type 77), floors to 
'FLOOR' (71). Put the flag, without the 'is_buildable', on walls around the 
buildable zone (needed for correct wall connection, but not critical per se).
Best way to quick preview is to use my modified apartment :) (south walls after 
extender are buildable, gold & diamonds included for faster testing)

How building works ingame:
You need a 'generic builder' (archetype 'building_builder'), and 'material of 
<stuff you wanna build>' (archetype 'building_material' + artifact. Don't know 
how to create an artifact, btw). Either get'em from the shop (if you installed 
it), or switch to dm mode & create some.
The builder acts like a range attack.
You then need to 'mark the material you want to use. Right now, there are 
artifacts for: wood floor, basic wall, horizontal & vertical gate, pedestal, 
lever/button.
Then it's a matter of firing in the desired direction :)
Obviously one material is used per firing.

Note: I patched the 'examine' command to add a message when something is 
buildable, to make it easy to see squares where it's allowed.

Building is currently allowed: in unique maps only, not on the map's edges (as 
defined by the map's size, not the squares where the player can go), not under 
yourself, only on squares where all items have the 'is_buildable' flag set.
Only exception is that you can build on marking runes, as they are used for some 
things.


Floor building: you can build a floor on a wall, or existing floor.
On a wall will remove existing wall, create walls and floor around affected 
square if required, and make sure walls are correctly connected. If walls are 
inserted, they will take the archetype of the removed wall, and also have a 
floor underneath (with your new archetype).
Building on a square without a wall will simply replace the floor. You can 
replace even if there are items, as long as they are buildable.

Wall building: you can build a wall on an existing wall, or a floor without any 
item. In both cases the affected square will end with a wall of the archetype 
defined in your marked material.

Items requiring a connection (buttons, pedestals, gates, more later on maybe): 
before building, write a 'marking rune' on the target square. Put any name you 
want, then build the gate / lever / pedestal. All items built on a rune with the 
same name will be connected, thus act together.
Pedestals are inserted below ground.

All other items (none at present... feel free to tweak 'slaying' field of your 
material): just build :)

To remove items: you need a 'generic destroyer' (archetype 
'building_destroyer'), to be found in the shop. It will remove the first item 
starting from below, thus first pedestals (underground), then buttons, and so 
on. It will not remove walls.


How it is implemented in the code:
Three archetypes are defined:
* building_builder
* building_destroyer
* building_material: 'abstract' archetype, must be associated with an artifact

Builder & destroyer use the new type '160', with subtypes to distinguish (resp. 
1 & 2).
Material uses new type '161', with subtypes for: floor, wall, all other items.
'slaying' field is the built archetype. If ( Str == 1 ), item will be inserted 
below floor.

Items of type 160 act as range attack, so the code has been tweaked for that.
Also, 'treasure.c' has been changed to force the artifact generation for 
'building_material' archetype (ie item type 161).

When applying a 'builder'/'destroyer', sanity checks are done: unique map, not 
on map edge, not under yourself, the affected square is buildable (AND has valid 
object on it, just in case).
If it's a 'destroyer', special function is called to remove the first object it 
finds.
For builders, there are 3 functions: for walls, for floors, for all items.
This last function creates built item, and uses its type field for special cases 
like gate, button (requiring a 'connection' to work properly).

For connection values, the 'message' on the marking rune is checked. If it's 
been previously seen, returns the value associated. Else find a free connection 
value (1000 random retries, then failure), and store it as a 'force' in the 
player's inventory. The force's 'slaying' will contain the map path (to avoid 
conflicts between maps), 'msg' the name and 'path_attuned' the connection value.

There are some helper functions, I think comments are good enough to understand 
what they do.

Pics I made. Hammer & stove (hum, not sure that's the correct name, oh well) I 
digital camera'd & tweaked, other pics are built item's pic + stove's pic :)
Also, prices and weights may need some adjustements.

Random notes:
* all inserted items get the 'is_buildable' flag
* when inserting a floor, it gets the 'is_unique' flag
* when removing a wall, walls around WITHOUT the 'is_buildable' flag may be 
affected, for correct visual connection. Flags are preserved, so hopefully isn't 
an issue. This is also why the 'WALL' type must be set around intended build area
* 'generic' items get also the 'no_pick' flag
* I think errors are checked, but some log messages may be missing (invalid 
archetype in 'slaying' field, stuff like that)
* I may have requested a connection value for too many items (DOOR? CF_HANDLE?), 
it may need to be corrected

Warning: the Scorn modified apartment is intended for demonstration purposes 
only. As it is currently, if a player builds east then north, towards the 
'blocking view' items, s/he'll be able to build floors right next to this 
blocking view, thus stand on a square with a blocking view on the adjacent 
square. Probably not harmful, but not something we'd want. Also player could 
access the key for Pupland by building.

There may be flaws/bugs in the code. I tested and it seems ok, but nobody's 
perfect, and it's well known that the one developing usually tests in a certain 
way so it works, but the first one to test without knowing how it's supposed to 
work will find The Big And Fatal Flaw (c) so obvious that the developer will 
smack his head wondering how he could have missed it :)

Future improvements will, in a perfect world, include:
* more artifacts, more things to build (potentially anything, adding special 
cases here and there when needed)
* doors & keys, detectors with some special things (for access control, for 
instance)
* teleporters, either to existing places OR to new maps
* maybe magic mouths/ears
* and why not monsters & such :)
* also in stock player-owned shops, where others players could buy/sell
* ability to change walls on map edge

I do plan, at some point, to let people build maps others could go into. So the 
check for map's uniqueness could go at some point, or be conditioned by a flag / 
value in a certain field (to prevent building some things in non-unique maps, or 
in unique maps).

(those are ideas that may or may not be implemented in the near or far future :))

Have fun testing, and thank you for reading everything ^_-

Nicolas 'Ryo'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build.tar.gz
Type: application/x-gzip-compressed
Size: 18698 bytes
Desc: not available
Url : 
     
     http://shadowknight.real-time.com/pipermail/crossfire/attachments/20031129/8a77b5c3/build.tar.bin
     
     
-------------- next part --------------
_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    


More information about the crossfire mailing list