Today, I learnt this is not true.
NPCs aren't indexing the talent IDs of talents added in the addons I've created, although the player character always starts with these values. They do index the talents in "talents_def" and similar tables - it's just the direct index to a talent ID that's lacking.
Because I've always accessed talent IDs this way, I've noticed that features which have worked for the player are breaking now I'm seeing NPCs try to use them.
I've looked through a number of different addons and have come to the conclusion that I'm not doing anything drastically wrong.
Passing the talent IDs directly wouldn't do me any harm, as there's no way any given function could tell the difference, but doing so would break stylistically with the code I've seen in ToME and I have the feeling things aren't supposed to be this way.
To give a direct example, I can open the Lua console and enter:
Code: Select all
=game.player.T_FLAME
1 :=: T_FLAME --beholder player character doesn't know flame, but has indexed the talent ID as it has all other talents
=game.player.T_FLAME_LASER
1 :=: T_FLAME_LASER --fine
=uids[1247].name --let's look at some random NPC
1 :=: brown bear
=uids[1247].T_FLAME
1 :=: T_FLAME --bears don't cast flame, but init with the talent ID "T_FLAME" indexed anyway
=uids[1247].T_FLAME_LASER --no output for my beholder addon talent id
Possessed by a fell mood, and eager to the be the first to uncover the causes of a mysterious bug, I spent most of the morning talking to my rubber duck as I waded through the Actor class's init process. While I had fun learning lots about the class system, I didn't come close to finding out why this is happening. So if it needs fixing, I'm certainly in no position to fix it.
On the other hand, maybe things are designed to work this way, and someone could explain why?