If we have 3 entities (test_subjects) that move around to check distances with 10 markers I have to use different pointer for each test_subject entity to be able to identify the correct marker.
Instead of using 3 test_subjects which use a unique pointer is there a way to use just one test_subject with a unique ID (any skill) which checks a marker that is the same as it's skill1 value.
function check_distance1 { if (vec_dist (temp_ptr.x, my.x) < 500){temp_ptr.light=on;temp_ptr_lightrange=0;} }
Is there a way to store the pointer to the entity for each test subject? Otherwise the pointer keeps changing everytime the temp_ptr value is changed and I have to use a different pointer for each entity (test_subject).
I guess that your main question is this: "is there a way to use just one test_subject with a unique ID (any skill) which checks a marker that is the same as it's skill1 value"?
The following is one of my ways doing such stuff. It is not tested (I always forget how to define a skill), but I hope you understand the system.
var number_of_marker = 0; var number_of_test_subject = 0;
#define id skill1 #define marker 1 #define test_subject 2
#define group skill2
#define marker_handle skill3
function check_distance() { if (vec_dist (you.x, my.x) < 500) {you.light=on;you.lightrange=0;} }
action marker_act() { my.id = marker; my.group = number_of_marker; number_of_marker += 1;//count up a global variable to give each marker a unique number }
action test_subject_act() { my.id = test_subject; my.group = number_of_test_subject; number_of_test_subject += 1; wait(1);//wait the first frame cycle, because every entity should have its number you = ent_next(NULL);//check each entity to find the 'personal' marker while(you) { if((you.id == marker)&&(you.group == my.group)) {my.marker_handle == handle(you);} you = ent_next(you); } while(1) { you = ptr_for handle(my.marker_handle); check_distance(); wait(1); } }
Thanks for the code. It's made things alot clearer.
On a final note, is there an alternative to using you for the pointer since I keep getting an error (unidentified pointer) when tracing between the you and my positions.
you = ptr_for handle(my.marker_handle);
result=trace(my.pos,you.pos); if(result>1){//rest of code}
But when using temp_ptr it works fine.
entity* temp_ptr;
temp_ptr = ptr_for handle(my.marker_handle);
result=trace(my.pos,temp_ptr.pos); if(result>1){//rest of code}