Open TomRotfl opened 6 months ago
It's because for some reason GetSpecialAbilityCount() doesn't count the removed ones (id = -1), so in your case it'll return an amount of 1 special abilities, which you would assume to be at index 0, but it is in fact at index = 1, since when you "remove" one it just sets the ID to -1 so its spot can be reused at a later time.
So, for your repro steps:
[880]
and GetSpecialAbilityCount() returns 1
and the special ability is at index 0[880, 881]
and GetSpecialAbilityCount() returns 2
and the special abilities are at index 0 and 1[-1, 881]
and GetSpecialAbilityCount() returns 1
, so you assume the valid spellid is at index 0, but it's actually at index 1.Interesting! Adjusting the title name to reflect the real bad guy here
When I add 2 or more abilities with different
id
values, if I don't remove them sequentially (last to first), but I remove the first I added as first, and then I try to remove the second, this last one will have an id value of -1 if checked, and can't be removed.To reproduce:
id 880
(totally random)id 881
id 880
id 881
, but you will find an ability withid -1
, that can't be removedNWNX_Creature_RemoveSpecialAbility
probably doesn't reorder the list of available abilities, so on the next loop it finds an empty value and stops there (just guessing from a conversation on discord).