[crossfire] Materials

Nicolas Weeger nicolas.weeger at laposte.net
Sat Jun 9 07:51:58 CDT 2007


Hello.

I'd dug some in the material code, and it is quite messy. But I'm not sure how 
to fix/change it.

Here is how it works.

Material is used for saving throws against attacktypes (against fire, 
ice, ...).
When NEW_MATERIAL_CODE is defined, material will also affect an item's 
resistances, damage, speed, wc, ac.

There are 2 related fields, "material" which is a bitmask and "materialname" 
which is a string.

lib/materials contains a list of materials, first "regular" materials (which 
all got neutral resistances / modifiers), then special ones (with special 
resistances / modifiers).
Each material type (metal, dragonscale, ...) corresponds to a type, check 
include/material.h (M_xxx) for their values.

If "materialname" is NULL, it is initialized with a material 
matching "material"'s bitmask.
When NEW_MATERIAL_CODE  is defined, this material "incarnation" is chosen 
randomly based on map's difficulty and item's magic (thus having a material 
of 2 can translate to iron, silver, gold, lead, steel, ...).
When NEW_MATERIAL_CODE is not set, the first matching material is used (thus 2 
will always do iron).

materialname is used when doing saving throws, pointing to the material's 
intrinsic resistances. It is also used when describing the item - thus gold 
coins have a "it is made of: gold" even when its material value is 2 (iron) 
in the archetype. Consequently also, gold coins will use the 'gold' values 
for saving throws.


There are some issues with the current implementation:
* when NEW_MATERIAL_CODE  is defined, objects have modified resistances / 
stats based on their material and also random materials, thus leading to 
massive non merging things
* materialname only reflects one material - if I set "material 3" in the 
archetypes, it will only be "paper", not "paper and iron". This also 
influences the saving throw, which will only be paper, not iron.
* if material name is set to a special value (paper and glass - anything not 
listed in lib/materials), the item is then indestructible.
* material is effectively useless when materialname is set, even to 
an "invalid" value


So the plan is obviously to fix multi material handling - and for instance use 
a random material for saving throws, the hit can be on a "random" part of the 
item.
Keeping specific saving throws seems logical, since gold doesn't behave like 
iron for instance (but they got the same "material" value, 2).


The 2 things I'm wondering whether to keep (and maybe enable?) or remove 
totally are:
* random material choice if not set.
* resistances / stats modifier


Activating this could lead to more random items, and interesting combinations. 
Current eg resistance modifiers in the lib/material aren't that important 
(around -5 to 5), but could add variety to items.
On the other hand, it would introduce quite many different items, non merging, 
things like that.


If I were to decide right now (but that may change), I'd probably keep/enable 
modifiers and random materials. But I would link that to "loot diminution", 
ie reduce the junk players find. Thus less items, but more varied. I would 
also add materials with higher modifiers and penalties (eg: +20 fire, -20 
cold - you get a bracers of that type, keep it?). And maybe even add other 
modifiers (reduce/increase hp regen, ...)
Of course, that would mean more time required to sort/test all the junk :)


Nicolas
-- 
http://nicolas.weeger.free.fr [Petit site d'images, de textes, de code, bref 
de l'aléatoire !]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.metalforge.org/pipermail/crossfire/attachments/20070609/07de6497/attachment.pgp 


More information about the crossfire mailing list