You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
add a spell ability with id 880 (totally random)
add another spell ability with id 881
loop through the spell abilities and remove the one matching with id 880
loop again, and you won't find the id 881, but you will find an ability with id -1, that can't be removed
NWNX_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).
The text was updated successfully, but these errors were encountered:
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:
The array looks like this: [880] and GetSpecialAbilityCount() returns 1 and the special ability is at index 0
The array looks like this: [880, 881] and GetSpecialAbilityCount() returns 2 and the special abilities are at index 0 and 1
The array looks like this: [-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
TomRotfl
changed the title
NWNX_Creature_RemoveSpecialAbility doesn't re-order the list of available abilities on the creature
NWNX_Creature_GetSpecialAbilityCount doesn't count removed abilities (with id = -1)
May 15, 2024
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).The text was updated successfully, but these errors were encountered: