Page 1 of 1
GetElevation(..)returns zero if underwater
Posted: 11 Mar 2007, 15:26
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..
Posted: 19 Mar 2007, 00:15
by submarine
tobi? trepan? jc?
or should i just commit a fix? do any other ai-devs disagree with this?
Posted: 19 Mar 2007, 00:19
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()

Posted: 19 Mar 2007, 10:36
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.
Posted: 19 Mar 2007, 11:12
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
Posted: 19 Mar 2007, 11:20
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.
Posted: 19 Mar 2007, 18:14
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?
Posted: 19 Mar 2007, 18:36
by AF
if it gives us the old behaviour then that sounds good
Posted: 25 Mar 2007, 21:28
by submarine
3496 / submarine 0 minutes AICallback::GetElevation(..) returns negative values again
Posted: 25 Mar 2007, 21:49
by smoth
there is already a new call for that stuff that can give you water depth.
Posted: 26 Mar 2007, 00:09
by submarine
in the ai interface?
i just restored the old behaviour (which most ais are based on)