Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TedMar, dr_panther), 1,049 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
massive target finding #419384
03/09/13 17:59
03/09/13 17:59
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline 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:
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:
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] #419392
03/09/13 19:33
03/09/13 19:33
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
simply, each unit entity could store target entity's handle in a skill.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: massive target finding [Re: Random] #419400
03/09/13 19:55
03/09/13 19:55
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

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 Offline OP
User
Random  Offline 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:

Code:
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
W
Wjbender Offline
User
Wjbender  Offline
User
W

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: Wjbender] #419428
03/09/13 22:32
03/09/13 22:32
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
yes, and maybe some weighting of target dangerousness could be also fine, e.g. if there is a position important to defend.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: massive target finding [Re: sivan] #419460
03/10/13 15:05
03/10/13 15:05
Joined: Mar 2012
Posts: 44
A
Abarudra Offline
Newbie
Abarudra  Offline
Newbie
A

Joined: Mar 2012
Posts: 44
Maybe you can try something like this, i use it (currently in a very basic version) in my TD Game. I cant provide code at the moment sorry.

I have one scanning - entity that "knows" a list of ally forces nearby. I let it scan for enemys and i use event_detect to store their pointers in an array.
Currently i only look for the closest enemy and assign it as target to the allied forces. For the "communication" i use structs with entitypointerarrays.
This way i have more ways to assign targets to units.

Kind regards

Re: massive target finding [Re: Abarudra] #419466
03/10/13 16:15
03/10/13 16:15
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
Wouldn`t that effect the FPS quite much?



Re: massive target finding [Re: Random] #419470
03/10/13 16:36
03/10/13 16:36
Joined: Mar 2012
Posts: 44
A
Abarudra Offline
Newbie
Abarudra  Offline
Newbie
A

Joined: Mar 2012
Posts: 44
Im sorry i dont know.
In my example i have currently only about 10 units on each side (1 scanner + several turrets vs a bunch of fighters. I don't have FPS Problems so far (i limit it to 60 and it never drops below).
When i have my system up and running again i will test it with more units.
My idea was to have one a bit more complex function and several "small" ones instead of a bunch of medium sized ones.
But my project is still in a prealpha version, so i dont have much experience in performance issues.

Re: massive target finding [Re: Abarudra] #419509
03/11/13 07:57
03/11/13 07:57
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
if you have fps problems. let only a few units to use c_scan within one frame. e.g. one unit from each group. thus it must be fine, and within one second all the units has updated information.


Free world editor for 3D Gamestudio: MapBuilder Editor

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1