What's the best/fastest way for object detection?

Posted By: Impaler

What's the best/fastest way for object detection? - 05/26/07 11:54

Hi,
In my WWII game, I have about 10 or more AI players on each team, some my allies, some my enemies. I need each actor to be able to detect it's enemies and attack them. I have been using a "radar-style" c_trace, one that constantly spins around so every 5 seconds it turns 360 degrees and scans it's surroundings for enemies. Now, this works fine, but I need the whole process to be faster, but I can't make the rotating c_trace any faster or it skip over enemies. Should I use c_scan instead of a rotating c_trace, and if I do, how can I make c_scan return YOU as the closest detected object with the enemy property, not just the closest object(which might be another ally)? Also, c_scan will go through walls, and the actor will be wasting his time trying to shoot at an enemy which he can't hit.
Posted By: sheefo

Re: What's the best/fastest way for object detection? - 05/26/07 12:36

In my RTS I loop through each player, and their array of units (in Lite-C) and check if it is within sightrange. It gets more complicated, I check if it is on a different team with no diplomatic relations. Then I store the entity pointer if it's health is lower than the previous one, which in the end has the enemy unit in sightrange with the lowest heath for the unit to attack (if in aggresive mode, otherwise the function is aborted).

Try something like that in C-Sctipt. It is fast because no c_trace or c_scan is needed, all done with maths in one frame.
Posted By: Impaler

Re: What's the best/fastest way for object detection? - 05/27/07 05:46

I thought that's just what c_scan does, except within a certain range? Anyway, how can you access a list of objects or actors in the game, to check which ones are enemies?
Posted By: Germanunkol

Re: What's the best/fastest way for object detecti - 05/27/07 05:51

check out ent_next(entity); in the manual.
good luck with this!
Posted By: Impaler

Re: What's the best/fastest way for object detecti - 05/27/07 06:41

Thanks, Micha!
Posted By: testDummy

Re: What's the best/fastest way for object detecti - 05/27/07 15:56

Quote:

I thought that's just what c_scan does, except within a certain range? Anyway, how can you access a list of objects or actors in the game, to check which ones are enemies?



Quoted Impaler.
I might use eLL (entity linked lists and arrays plugin) found here for such things. I wrote it for similar purposes but I assume very few actually use it.
At one time, I clocked it, and it appeared to be faster than scan_entity. Essentially it works similarly to ent_next, and maybe scan_entity, except user-defined entity link lists can be defined. In principle, fewer items might be iterated over. A version for 6.5 is currently under revision.
© 2024 lite-C Forums