|
massive target finding
#419384
03/09/13 17:59
03/09/13 17:59
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Hallo everybody. I have two armies (10 vs 10) with are suppose to fight against another. My problem is, I don`t know how to create a local targets for each AI. The target they search now is global. So Team A looks for: ENTITY* enemy_target;While Team b looks for: ENTITY* ally_target;Team A searching code:
function AI_find_target()
{
result = c_scan(my.x, my.pan, vector(360,180,2000), SCAN_ENTS | SCAN_LIMIT | IGNORE_ME);
if(result > 0)
{
if(you.team != my.team)
{
while ((vec_dist (my.x, you.x)<2000) && (you.health>0))
{
enemy_target = you;
wait(1);
}
enemy_target = NULL;
}
}
}
Team B searching code:
function AIfriendly_find_target()
{
result = c_scan(my.x, my.pan, vector(360,180,2000), SCAN_ENTS | SCAN_LIMIT | IGNORE_ME);
if(result > 0)
{
if(you.team != my.team)
{
while ((vec_dist (my.x, you.x)<2000) && (you.health>0))
{
ally_target = you;
wait(1);
}
ally_target = NULL;
}
}
}
Obviously this can`t work as soon there are more AIs on each side... Any ideas how to make this better?
|
|
|
Re: massive target finding
[Re: Random]
#419400
03/09/13 19:55
03/09/13 19:55
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
yes what sivan said .
"as soon there are more AIs on each side..."
and also maby create an array for each team of entitys and perhaps store an id also for each entity in the array if you need it ..
Compulsive compiler
|
|
|
Re: massive target finding
[Re: Wjbender]
#419412
03/09/13 21:00
03/09/13 21:00
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Great it works! I would never thought that you could mix entity with defines ^^ Fore those who are interested:
function AIfriendly_find_target()
{
var closestTarget_dist;
for(you=ent_next(NULL); you!=NULL; you=ent_next(you))
{
if ((you != my) && (you.team != my.team) && (you.health>0))
{
if(my.the_target ==NULL)
{
my.the_target = you;
ENTITY* enemy_target = my.the_target;
closestTarget_dist = vec_dist(you.x, me.x);
}
else
{
if(vec_dist(you.x, me.x) < closestTarget_dist)
{
my.the_target = you;
ENTITY* enemy_target = my.the_target;
closestTarget_dist = vec_dist(you.x, me.x);
}
}
}
}
}
Thank you!
|
|
|
Re: massive target finding
[Re: Random]
#419418
03/09/13 21:45
03/09/13 21:45
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
nice now you only need to limit how many may choose the same target.. but perhaps you would like to have them bunch up on the same target ?
Compulsive compiler
|
|
|
Re: massive target finding
[Re: Abarudra]
#419466
03/10/13 16:15
03/10/13 16:15
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Wouldn`t that effect the FPS quite much?
|
|
|
|