Talk:Enchantment

From NetHackWiki
Revision as of 17:39, 19 February 2014 by Chris (talk | contribs) (Specify that chwepon is the function in wield.c)
Jump to navigation Jump to search

Where is the function that determines if an item can have an enchantment? For some reason I can't find it in the source. It seems certain rings have an oc_charged property (increase attribute, adornment etc.) while others do not, and probably weapons and armor have it, maybe wands too, but I'd like to allow tools, iron balls and iron chains to have an enchantment value without changing their base object type; where could that function be hidden? There's got to be some kind of function that checks whether an object is of a type that can have an enchantment, so I'd just need to add ball_class and others to that type... --Bluescreenofdeath (talk) 11:35, 19 February 2014 (UTC)



The variable that holds enchantment level is spe.

There is no dedicated function that checks for whether an item can have an enchantment, the check is included in several places in the code (For enchanting weapons, it checks if the object is a weapon or a tool that can be used as a weapon). Just looking quickly, this is checked in read.c in the SCR_ENCHANT_WEAPON section (where erode-proofing is handled) and in chwepon in wield.c (where the actual enchanting of weapons is handled). You may also have to amend the code that displays object names (spe is ignored for object classes that can't be enchanted) and the code that handles attacks (again, spe is ignored for invalid types).

---Chris (talk)