Note on GetUnitDef(enemyunit)...

Note on GetUnitDef(enemyunit)...

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Note on GetUnitDef(enemyunit)...

Post by krogothe »

I think that the enemy unitdef problem you are all experience is not a bug in the interface (zaphod and the SYs are too great to create ugly bugs IMO :wink: ), but just a setting:

Code: Select all

const UnitDef* CAICallback::GetUnitDef(int unitid)
{
	CUnit* unit=uh->units[unitid];
	if(unit && (unit->losStatus[gs->AllyTeam(team)] & LOS_INLOS)){
		return unit->unitDef;
	}
	return 0;
}
so it wont allow you to get a def an an enemy unit if they are in radar only, which makes sense since humans cant tell what the unit is just from the radar blip.

In fact, i bet a good part of the AI instability issues across the board are due to enemies being saved and their defs getting called after the enemy left LOS (or say killed the only unit that could see it). Or say trying to get a unitdef of a unit that is in radar but not LOS.

Might also be worth noting that the cheat interface giving all enemy units is pretty useless since the AI is not allowed to find the position or def of the units returned by it. It should simply give the AI LOS for the whole map.

Hope this helps
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

what did you exspect?

iirc its also mentioned somewhere in the ai documentation... i thought every ai dev would know that
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

I dont expect anything, just thought id share, since people are thinking the interface is more buggy than it is
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

I dont expect anything, just thought id share, since people are thinking the interface is more buggy than it is
It's mainly AF who thinks that, but he has no proof though. Also me and submarine never had unexpected results with the AI interface, (other than units getting stuck to buildings, but that a pathfinding problem I think)
Might also be worth noting that the cheat interface giving all enemy units is pretty useless since the AI is not allowed to find the position or def of the units returned by it. It should simply give the AI LOS for the whole map.
That is very true though, it really has to be fixed sometime.
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

zaph im looking more and more into the spring source each day so ill probably start helping out with a few things once im good enough in c++. Do i just send you source files with changes?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I know this because I rant ests with atatck code.

EnemyUnitEnteredLOS(){
check the position of the enemy unit
if returned position is 0,0,0 or 0,1,0 then give error "failed unit location"
else do attack code
}

The above will always return failed unit location. Sometimes it doesnt, sometimes ti does. I ran tests where if an enemy entered LOS (Not radar, LOS), then the AI would put down a marker. Of course I then tested this out and 9/10 trials in identical circumstances, it failed totally.

I ran similair test using markers and messages for many fo them. Of all the interface functions enemyenteredLOS is the most unreliable, mainly because if you call the engine for information on that unit you dont always get an answer.
Chocapic
Posts: 556
Joined: 16 Oct 2005, 03:35

Post by Chocapic »

well in EnemyEnterLOS(int enemy) i also get a fancy null pointer trying to reach out is unitdef, but now i should get the right one as it is in LOS right ?
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

zaph im looking more and more into the spring source each day so ill probably start helping out with a few things once im good enough in c++. Do i just send you source files with changes?
send me a SVN diff file, can be generated with something like
"svn diff directory/source files"
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

Chocapic wrote:well in EnemyEnterLOS(int enemy) i also get a fancy null pointer trying to reach out is unitdef, but now i should get the right one as it is in LOS right ?
probably, but maybe you have to delay your unitdef by a frame, give it a go
Chocapic
Posts: 556
Joined: 16 Oct 2005, 03:35

Post by Chocapic »

lol, before u said that i did that yesterday, i gave it a 30frame delay!
it works ok its just not the kind of code i was expecting
Post Reply

Return to “AI”