Page 1 of 1

Slope Definition

Posted: 25 Apr 2009 04:31
by fanioz
Hello all,
In the documentation there are slope definitions. And I only can understand AITile.SLOPE_FLAT = a flat tile. The other definition for me is slightly hard to understand. (probably language term) :?: . I'm confused with AITile::IsSteepSlope(), AITile::IsHalftileSlope()
Okay, I just want to know:
1. what kind of tile is in this picture. Let say, giving them AITile.GetSlope() what value are returned ? :roll:
slope.png
slope.png (40.84 KiB) Viewed 2203 times
2. what is the difference between AITile.SLOPE_FLAT & AITile.SLOPE_ELEVATED, docs said "All corner are raised, similar to SLOPE_FLAT"

Thanks for any help.

Re: Slope Definition

Posted: 25 Apr 2009 06:00
by Rubidium
http://vcs.openttd.org/svn/browser/trunk/docs/tileh.png should help quite a bit. Furthermore an elevated tile can (or could?) exist on some tiles with foundation but it is primarily used as a bitmask.

Re: Slope Definition

Posted: 25 Apr 2009 09:47
by fanioz
Rubidium wrote:http://vcs.openttd.org/svn/browser/trunk/docs/tileh.png should help quite a bit
root/trunk/docs/tileh.png
Revision 1, 36.7 kB (checked in by truelight, 5 years ago)
Import of revision 975 of old (crashed) SVN
Thanks Rubidium :D , I've missed something 'old-stable' here. That picture is very 'self-explanation'
Rubidium wrote:Furthermore an elevated tile can (or could?) exist on some tiles with foundation but it is primarily used as a bitmask.
That make me think, tile "this 4" on my previous post is elevated Tile.

Re: Slope Definition

Posted: 25 Apr 2009 13:55
by frosch
Actually SLOPE_ELEVATED is only used as bitmask. A tile or a foundation has never SLOPE_ELEVATED, instead it has SLOPE_FLAT and an increased height in that case. (Note to self: I should fix those comments)

Furthermore, it seems to me that the API only provides slopes through AITile::GetSlope().
This is the slope of the bare tile without the foundation. That also means that that function will never return a halftile slope.

Maybe AITile::GetFoundationSlope() should be added :) Though maybe it is not of any use.

Oh, hmm, AITile::GetHeight() also needs work :/

Re: Slope Definition

Posted: 26 Apr 2009 06:01
by fanioz
frosch wrote:Actually SLOPE_ELEVATED is only used as bitmask. A tile or a foundation has never SLOPE_ELEVATED, instead it has SLOPE_FLAT and an increased height in that case. (Note to self: I should fix those comments)
Okay,got it :idea: . That's mean SLOPE_ELEVATED is only use to ease check, whether a tile has one (or more) kind of slope. IMHO, the documentation should not said "all corner are raised, similar to SLOPE_FLAT ", because a corner tile would never raised at all

frosch wrote: Furthermore, it seems to me that the API only provides slopes through AITile::GetSlope().
This is the slope of the bare tile without the foundation. That also means that that function will never return a halftile slope.
Maybe AITile::GetFoundationSlope() should be added :) Though maybe it is not of any use.
Mmmm.... I think so, doesn't need to care with foundation. As long as the tile is flat and buildable, we can build something over it :P .
frosch wrote: Oh, hmm, AITile::GetHeight() also needs work :/
Maybe adding this into API would be more useful. :)
Quoted from docs :

GetTileMaxZ(TileIndex t) -> Get top height of the tile.
GetTileZ(TileIndex tile) - > Get bottom height of the tile.

But it could be implemented too with squirrel (doesn't need change API)

Re: Slope Definition

Posted: 04 Jan 2012 22:18
by MinchinWeb
Bump... old topic, but I have some more questions about slopes.

Is there an easy way to test if the slope is one of the 'simple' slopes (3, 6, 9, 12 on the image above)? I'm trying to figure out which tiles I can build a dock on.

Re: Slope Definition

Posted: 05 Jan 2012 00:54
by Zuu
You could take a look on these SuperLib functions. They don't do exactly what you want but they can give some inspiration for a new function eg. CanHaveDock(tile_id).

Code: Select all

static function IsDownSlope(tile_id, direction);
static function IsUpSlope(tile_id, direction);
You could of course try IsUpSlope with all four main directions, but I think it would be possible to come up with a function that is quicker than that for the kind of test that you want.

Re: Slope Definition

Posted: 05 Jan 2012 11:18
by Brumi
And what about trying to build a dock in AITestMode?

Re: Slope Definition

Posted: 05 Jan 2012 11:50
by Zuu
Brumi wrote:And what about trying to build a dock in AITestMode?
Not sure if that is a good idea as it might cause a DoCommand and thus terminate the current tick. But I have to say I'm not sure how the AITestMode affects DoCommands. As it is not executed, it doesn't need to be transfered over the network, thus I don't see why it would need to end the current tick.