hello all, I am having a bit of trouble trying to squash a very elusive bug in my game.
I have been getting "Invalid Array Index" errors. Upon checking the breakpoint read out, here is generally what it's showing me:
health_array[you.pather_id]-=5;
What that is basically saying, is to reduce an entity's health at a certain index.
"my.Pather_ID" is a skill which is only assigned ONCE, right when an AI is created. It is never changed at any point after. The pather_id is only a 1-300 number which stores that particular AI's ID number.
However I setup some debug error readouts to see if the pather_id is ever below 0, which means it is a negative number, and an array cannot have a negative index, which brings the error.
When I did this, I let the game run, went downstairs to watch tv, then came back to see what errors came up. The "pather_id" skill was indeed at one point below zero,which brought the invalid array index.
I did the simple task of checking to see if 1 entity has a skill which uses the same skill number, like:
bullet_power,skill45;
...
Shield_power,skill45;
I had found no obvious duplicates. Something is obviously changing the pather_id number, but it is driving me mad trying to find it. My guess is that there is another skill using the same skill number as pather_id and changing it.
My final question is should every skill in my game be between 1-100, and no two skills should have the same skill number, even if they are for seperate entities? I had planned to make a wholly different 1-100 skill set for say the bullet entities, and a different 1-100 skill set for the AI themselves.