Continuing c_scan

Posted By: Stansmedia

Continuing c_scan - 05/28/14 07:43

Im trying to perform a scan of entities with scan limit and a test if the entities FLAG1 is set. Problem is the scan is executed randomly and if the object being scanned for is within a certain distance (and they are all in pretty short distance most of the time) - I need to ignore that entity and scan for one further. I tried running another scan after the distance returned less then the certain value with ignore you in the second scan but it's just coming up with empty pointer errors.

So basically, I need to run a c_scan that only returns entities that are further then a specified distance. I could have each of the entities being scanned for run their own vec_dist and toggle their enable_scan based on their own distance checked... But that's a lot of functions to be running so that's kind of a poor way out. Any ideas?
Posted By: CanadianDavid

Re: Continuing c_scan - 05/28/14 08:07

In the entity performing the scanning, perhaps you can simply do one check for distance (using vec_dist) based on the modified 'you' pointer given that c_scan result is greater than zero:

Code:
result = c_scan(...);
if(result>0 && you != NULL){
  var distance = vec_dist(my.x, you.x);
  if(distance > 100) { ... } // do something if further than a distance of 100
}

Posted By: Stansmedia

Re: Continuing c_scan - 05/29/14 01:46

I think performing the scan ahead of the play with vec_rotate will be the best way. I went to bed last night and it popped into my head. Which is the worst time because I had to get up early and I really wanted to stay up and keep coding haha.

Something like this:

vec_set(temp.x,vector(64,0,0));
vec_rotate(temp.x,vector(camera.pan,0,0));
vec_add(temp.x,camera.x);
c_scan(temp.x,...);
Posted By: CanadianDavid

Re: Continuing c_scan - 05/29/14 02:31

If you're absolutely sure you won't need a c_scan surrounding the player then that sounds like it could work too!
Posted By: Stansmedia

Re: Continuing c_scan - 05/29/14 03:13

I'll give a random y position to scan with, should turn out alright. laugh
© 2024 lite-C Forums