From NetHackWiki
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)

Thanks for the help! Yesterday I did some experiments, and it seems objnam.c holds the function that makes the game display an enchantment. However, making the iron chain able to be +5 (or something like that) does nothing at first (the chain still does the same melee damage); I did find a way to change that but can't remember exactly which file governs it, maybe it was weapon.c or wield.c. And annoyingly, missile damage doesn't seem to go up; I allowed rocks, flint stones etc. to have a plus as well but when firing them with a sling they unfortunately don't do extra damage. The only advantage of having a stack of +10 rocks is they don't disappear nearly as often when fired, so the sling is still as useless as ever... --Bluescreenofdeath (talk) 06:55, 20 February 2014 (UTC)