|
3 registered members (AndrewAMD, juanex, Grant),
1,018
guests, and 8
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Entity skills
#214547
07/05/08 10:23
07/05/08 10:23
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
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.
|
|
|
Re: Entity skills
[Re: jumpman]
#214650
07/06/08 05:04
07/06/08 05:04
|
Joined: Dec 2005
Posts: 116
tD_Datura_v
Member
|
Member
Joined: Dec 2005
Posts: 116
|
Jumpman, I would also like some replies for that skill usage query.
If appropriate, I just loosely work off the following: Some elements are relatively common among classes of object, and once defined, such skills can be reused across similar classes. Other elements are fairly unique to certain classes of object, and those skills are not shared to the same extent. Common, re-used skills can be assigned to a certain range of skill numbers as a standard. Unique skills can be assigned to a different range.
It seems you are an experienced user, so I will assume that you have squashed that bug successfully some time ago.
|
|
|
Re: Entity skills
[Re: tD_Datura_v]
#214770
07/07/08 09:00
07/07/08 09:00
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
hello datura. You are absolutly correct.
I have isolated, and found a way to recreate my bug, although it is different than the minus 5 health in my first post, but same in dealing with skills. Here is the scenario:
In my game, whenever an AI gets scanned by another entity, the scanned AI is able to "read" that entity's information. So for example, an AI is standing still guarding an area, and an incoming rocket explodes next to him. The Rocket entity is using a skill called "Shell_ID", which was defined as:
define Shell_ID,skill99; // A skill defined only for the Rocket class define Shell_Power,skill100; // a skill to determine how strong the shell is
The AI's themselves use their own ID storage in their own skill:
define Unit_ID,skill100; //
IF the AI begins asking what the Unit_ID of the rocket is, the AI will get the rocket's shell power, instead of a unit ID. Because Unit_ID and Shell_Power are both defined as skill 100, the 100th skill will be queried if either shell_power or unit_id is asked for.
Although that is not the best example, what this means is that you can have as many different 1-100 skill defines as you want. For entities that do not transmit their skills, nor ask for other entities skills, you can make as many skills as you want. For example, for a cloud entity, that floats by itself without any direct influence of other entity's skills, you can have this:
define Cloud_type,skill1; // give the cloud class their own skills define Cloud_size,skill2;
define Soldier_Health,skill1; // You can give the soldier class the same skills define Soldier_Armor,skill2;
Because the soldier entity never has to ask the cloud entity about it skills, you can define the skill names using the same skill numbers.
HOWEVER, for entities that will need to query another entity's skill, the skills will need to have their own skill number.
|
|
|
Re: Entity skills
[Re: TigerTao]
#215399
07/10/08 23:10
07/10/08 23:10
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
Exactly Tigertao!
One thing Ive noticed, is that when you do assign two different names to the same skill number, the program will still "generally" refer to the right one.
By mistake, I had assigned two different names to the same skill number for an entity. One skill name was "Health", and the other was "Path_Slot". Health could have been any number, positive or negative. Path_slot however was a number that referenced an array index. Array indexes cannot be negative nor exceed the array length.
Also, another thing to look out for is checking to see if an entity's skill is ZERO. The bullets in my game had a skill called "bullet_id". The rockets had their own "shell_id". There was a chance that an AI would get hit by the shell and ask for it's bullet_id. Since the shell's bullet ID was zero, since it wasnt assigned, the AI began shooting at target ID zero.......which was the player......across the map minding his own business.
|
|
|
Re: Entity skills
[Re: jumpman]
#218279
07/27/08 16:06
07/27/08 16:06
|
Joined: Apr 2006
Posts: 159 Latvija
Arrovs
Member
|
Member
Joined: Apr 2006
Posts: 159
Latvija
|
Cool! You give me nice ideas! For uing more local vars which can work like skills(because i can send them to other entity and dont change it to whole entities). And from experience im got situations when used coords like: define kords,skillx;//x for any number vec_set(kods,blabla);//or changed places
gets in result that when skill x+1 and +2 changes accordingly from y and z axes results.
And if define lifes,skill(x+1);// that will mean when if is created object and putted on that koords skill lifes starts strangely jumping(from experience).
But anyway thanks for this discussion this will be soooo handy for my rpg game continuing.
Arrovs once will publish game
|
|
|
|