Hi Ambit,

as you alreaqdy pointed out, variables are global i.e If you change them in any action the change would effect all other entities using the same variable. The entity SKILLS are local i.e they exist per entity. 3DGS uses cooperative multitasking so if your function or action reaches a WAIT instruction, control is given back to the engines "dispatcher" and another action is given control. i.e you can only be sure that a variable has not been changed it's value before a wait instruction. As you have already noticed, the way you do use those variables, messes up the whole thing. Now if you are in need of more "local" variables (more then the 48 entity skills give you) you could cheat using an array. In the upcoming features file JCL has added a description how to use arrays as local varables. The idea comes from my array tutorial. Look at the description below which is taken from the upcoming features readme file :

quote:

Local variables and additional entity skills
You can use multidimensional arrays to add local variables to
functions - variables that are only used within a certain function
and nowhere else. Local variables can be used for unlimited entity
skills. Suppose the 48 entity skills are not enough for a certain
type of entity - you need 100 skills. Just defining an array[52]
to get a total of 100 skills won't work when you have more than
one entity of that type.

If WDL functions would support local variables, you could just define
a local array[52] within the entity action. Well, you can do this
already, through defining a 'pool' of local variables in an array
outside the function:

var ent100_skill[5200]; // enough for 100 entities, 52 skills each
var ent100_offs = 0; // index offset into the array

define _local my.skill48; // use my.skill48 to store the index offset

action ent100 // directly attached to the entity
{
_local = ent100_offs; // store the current array offset
ent100_offs += 52; // and reserve 52 array elements for this action
if (ent100_offs >= 5200) // check whether we have enough skills left
{ beep; beep; return; } // indicate an error (too much entities)
...

while (1) // entity main loop
{
...
temp = ent100_skill[_local+0]; // access first additional skill
...
temp = ent100_skill[_local+51]; // access last additional skill
...
wait(1);
}
}

Do not forget to set ent100_offs back to 0 when loading a new level!
The idea to use arrays for additional entity skills is taken from
Ronny Funk's Array Tutorial.


hope that helped ....

greetings Ronny