From: jim <ji...@ma...> - 2002-09-19 13:24:31
|
Greetings all, and hi to the uwadv guys; this information isn't in your version of the specs document, so I'm ccing you in. A recent TTLG thread got me thinking about these, so I had a bit of a look to see if I could find out how enchantments are coded in Underworld. It's a bit confusing. A general note on the "link" field first. This is either a link (object index) or a quantity or special property. This is generally determined by the link flag in the flags field (bit 6 or bit 15 of the first object description word); if this is a 1, the link field is quantity/special (not a link). The exception is triggers, which have a flags value of 0x7e or occasionally 0x7c, yet their link field is a link to a trap. A quantity (link flag set) value of less than 512 is a quantity, otherwise is a special property. Objects with special properties or which link to other objects don't stack, of course. For an enchantment this is the spell type. The best guess I've got for an "enchanted" flag is bit 3 of the flags field (bit 12 of the first object description word); this works for scrolls, which have 0x4c flags if they are magical in which case the link field is the spell type, or 0x40 if they are not in which case the link field is the text. Fountains (some of them are healing fountains) seem to work this way too. Spells and potions have 0x4c flags as well; the 4 bit might be because they are consumed when used. Enchanted weapons and armour have 0x48 flags, and again the link is the spell type. However, this throws up some false positives. Triggers have an odd flags value, as I said above. Writing objects (the ones on the wall, not scrolls) may also have this flag set, although they aren't magical and their link field is the text. So I'm not sure about this "enchanted flag" as it were, but there must be one, surely? Or perhaps it only has this meaning if applied to an object which might or might not be enchanted? Wands act differently; they link to a spell object which holds the enchantment. Presumably this is because they also have a number of charges; I'm guessing that this is the "quality" field of the spell object. I don't see any reason why this shouldn't work for any kind of objects - there's certainly at least one sceptre of Deadly Seeker in Underworld II, and am I dreaming or do I remember a gem of some sort which boosted your mana? Both of which had limited charges. Let's go through the object classes. 000-01f Weapons : Enchantable, uses enchantment flag and link field 020-03f Armour : Enchantable, uses enchantment flag and link field 040-07f Critters : Not enchantable[1] 080-08f Containers: Not enchantable, link to inventory 090-097 Lights : Probably enchantable, but not much point 098-09f Wands : Enchanted, link to spell object 0a0-0af Loot : Enchantable, by linking to spell object or otherwise? 0b0-0bf Food/drink: Enchantable, uses enchantment flag and link field[2] 0c0-0df Junk : Probably enchantable, but not much point 0e0-0ff Quest/rune: Dunno. 100-10f Keys : Stackable, no point enchanting these[3] 110-12f Misc items: Enchantable, uses enchantment flag and link field[4] 130-13f Scrolls : Enchantable, uses enchantment flag and link field 140-14f Doors : Not enchantable, may link to a lock object 150-16f 3D/decal : Not enchantable[5] 170-17f Switches : Not enchantable, link to a use trigger 180-19f Traps : Not enchantable 1a0-1bf Triggers : Not enchantable, odd flags value 1c0-??? Anim objs : Not enchantable Actually, now I've tabulated them all it looks pretty easy; objects with an object_id less than 0x140 (start of doors) are enchantable, and honour the enchantment flag. All objects but triggers honour the link flag. I'd be inclined to think that any object may be enchanted by linking to a spell object. In such a case it is the SPELL OBJECT which has its enchantment flag set, NOT the object which is actually enchanted. Now, how does the value in the link field determine what spell an object holds? Well, it seems to be complicated. (No surprise there, then). Spell names are stored in string chunk 5 (counting from zero). Most enchantments seem to correspond to the second half of these, i.e. adjusted enchantment no. = adjusted special property + 256 (= link value - 256). This works for scrolls and potions. Fountains don't seem to add the 256; a typical enchanted fountain has a link value of 582, corresponding to a special value of 70, and index 70 is "Heal" in the spells list. Pretty good. Most weapon enchantments are in the range 128-255, corresponding to spells 384-511. So far so good. Most armour enchantments are similar, but they must add an extra 16 (there are 16 damage/accuracy spells followed by 16 protection/toughness spells). However (there's always that however, isn't there) when I tried out my object describer it asserted that there was a breastplate of Local Teleport somewhere on level 8. Not very likely. Subtract 256 from the spell index and you get Resist Blows, which is much more likely. Seems then that armour and weapon enchantments are coded differently: 0-127 are generic enchantments and are unmodified, 128-255 are specific weapon/armour enchantments corresponding to 256+stored value, or 16 more than that for armours. Buggrit. Now it's talking about locks of magic. Evidently locks can't be enchanted, and don't honour the enchantment flag, and presumably the same for keys. That complicates the enchantability test somewhat. Never mind, it looks to be correct in the main. Cheers, jim --Footnotes [1] Though I'd be interested to make a critter link to a spell object and see if Underworld comes up with "a friendly mountainman of Magic Arrow" or something ;) Link field is used for NPC name, no? [2] These include potions which are (almost) always enchanted, but there do exist such things as bottles of ale of Heal. Most foods are stackable however, and they can't be both. (Bit of trivia: the "red is rotten" potion in F^HIronwit's complex isn't enchanted in the usual way; it links to a damage trap). [3] These also include the lock object, which uses the link field to determine which key fits it. Oh - and doesn't honour the enchantment flag. Sod. [4] These include fountains, which may hold a Heal enchantment. I don't see why other objects in this class shouldn't be enchantable, though I can't recall any examples off hand. [5] These seem to use the enchantment flag for something else. -- http://madeira.physiol.ucl.ac.uk/people/jim/ - Bill Stickers is innocent! |