Slope Definition

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Slope Definition

Post 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 2202 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.
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Slope Definition

Post 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.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Slope Definition

Post 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.
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Slope Definition

Post 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 :/
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Slope Definition

Post 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)
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: Slope Definition

Post 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.
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Slope Definition

Post 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.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: Slope Definition

Post by Brumi »

And what about trying to build a dock in AITestMode?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Slope Definition

Post 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.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests