GetElevation(..)returns zero if underwater

GetElevation(..)returns zero if underwater

Discuss your problems with the latest release of the engine here. Problems with games, maps or other utilities belong in their respective forums.

Moderator: Moderators

Post Reply
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

GetElevation(..)returns zero if underwater

Post by submarine »

I spent hours on debugging AAI water map behaviour just to find out that GetElevation() dioes not return negative values (if terrain is below water level) anymore

why has this been changed? is it just a bug or has this been done on purpose?

Code: Select all

float CGround::GetHeight(float x, float y)
{
	float r = GetHeight2(x, y);
	if(r<0)
		r=0;
	return r;
}
if its not done on purpose can i commit a fix?

e.g. GetElevation(..) could call GetHeight2(..) instead of GetHeight..
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

tobi? trepan? jc?


or should i just commit a fix? do any other ai-devs disagree with this?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

I actually changed the lua script call-out to use GetHeight2() a while ago.
Be wary of current AIs thatmight rely on that clamping... it would be safest
to add a new call, but not as clean.

P.S. If you wanted to be super keen, you could change all instances of
GetHeight() to GetHeightClamped(), and GetHeight2() to GetHeight() ;)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I'm at a loss to think why AI devs would want the ability to detect negative height values removed or why they'd want a second function that had this when they could just as easily implement it AI side rather than have a core AI functions behaviour suddenly change without notice.
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

the problem is that i need those negative values, otherwise aai doesnt work on water maps (as it is the case right now)

i could
(a) fix it in the GetElevation() call (if the other AI devs agree with that, AF seems to share my opinion
(b) add a new function (not very nice though)
(c) modify AAI
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

At the moment the current check for underwater ground is

if(height < 0)

However this is a problem as this means AAI isnt the only AI broken. There are numerous small behaviours in NTai that are broken by this, such as the ones preventing land units attacking sea targets.

QAI has an entire system for detecting water and landmasses which is made useless by this, as the entire map is detected as a single landmass.
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

well i just didnt want to change something in the ai interface without asking other ai devs before

it seems that we are all suffering from the problem, i would suggest to call the GetElevation2(..) (and bypass the < 0 check) from the intefrace function

do you agree?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

if it gives us the old behaviour then that sounds good
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

3496 / submarine 0 minutes AICallback::GetElevation(..) returns negative values again
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

there is already a new call for that stuff that can give you water depth.
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

in the ai interface?

i just restored the old behaviour (which most ais are based on)
Post Reply

Return to “Help & Bugs”