Jump to content

Enchantment.playerKnows()


Recommended Posts

Why does this not work?  It always returns false, even for objects that are destructible in the arcane enchanter.

Keyword property	MagicDisallowEnchanting		Auto

bool function IsCollectableWisdom( ObjectReference r)
	Form f = r.getBaseObject()
	int t = f.getType()
	if r.isDeleted() || r.isDisabled()
		return False
	elseif t == 26 && !f.hasKeyword( MagicDisallowEnchanting)
		Enchantment e = (f as Armor).getEnchantment()
		if !e
			return False
		elseif e.getBaseEnchantment()
			e = e.getBaseEnchantment()
		endif
		return !e.playerKnows()
	else
		return False
	endif
endfunction

Other branches (not shown) of the elseif cascade, testing for potions, soulgems and unread books do work as intended.  It's just the unknown enchantments for armor and weapons that don't.

Link to comment
Share on other sites

Ah! Found it. Finally.

The function works.  There was a logic error elsewhere that prevented the function being called on the target objects (type 26 objects where in fact not being fed to the function in the circumstances that I was testing).

It escaped me because there are other paths through which the same processing can occur, making it look like the function was being called.  And other paths through which type 26 objects where fed in, but other conditions applied as well in those cases making them poor test targets.

Thanks Ishara.  Your being puzzled is what pushed me to reconsider ALL my potential failure points 🙂

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...