API request - expose industry founder to gamescript.

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
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

API request - expose industry founder to gamescript.

Post by PikkaBird »

It would be useful, for a competitive game script, to know which company founded an industry. This information is already known to OpenTTD - it's industry var A7.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: API request - expose industry founder to gamescript.

Post by frosch »

Technically it's not known to OpenTTD. The founder information is incorrect when companies close and restart. But NewGRF never bothered about that.

Edit: Nevermind, it is actually updated on bankrupt or takeover.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: API request - expose industry founder to gamescript.

Post by PikkaBird »

frosch wrote:Edit: Nevermind, it is actually updated on bankrupt or takeover.
That's handy. :)

In any case, I was planning to check the founder only at the moment the industry was created, and handle companies closing down explicitly elsewhere.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: API request - expose industry founder to gamescript.

Post by Alberth »

Afaik there is no way to query the founder of an industry for a user, so when buying a company, I may become founder of an industry, but I have no way to find out if so, or which one(s).
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: API request - expose industry founder to gamescript.

Post by PikkaBird »

Alberth wrote:I have no way to find out if so, or which one(s).
Unless the GS tells you, of course. :)
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: API request - expose industry founder to gamescript.

Post by Alberth »

/me grabs the magic bulldozer to delete all those weird industries inherited from a former competitor :D
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: API request - expose industry founder to gamescript.

Post by PikkaBird »

Still, it's not really an issue for what I want to do with it. :)

To give a very simplified idea of what I had in mind: a GS where the winner is the first company to found 100 new industries. On GSEventIndustryOpen, the script would check which company built the industry and credit it to them. If a company closes down, its list will be cleared; the existing industries will not be recredited.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: API request - expose industry founder to gamescript.

Post by planetmaker »

PikkaBird wrote:Still, it's not really an issue for what I want to do with it. :)

To give a very simplified idea of what I had in mind: a GS where the winner is the first company to found 100 new industries. On GSEventIndustryOpen, the script would check which company built the industry and credit it to them. If a company closes down, its list will be cleared; the existing industries will not be recredited.
I think Alberth's concern is more that we then have (potentially) a mechanism which the player cannot understand or follow. However I do believe that this is a thing which for *game scripts* is not strictly necessary. If they wish to be opaque, so it be. As such *I* don't see a problem in exposing that variable to GS (contrary to exposing it to AI).
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: API request - expose industry founder to gamescript.

Post by keoz »

planetmaker wrote:I think Alberth's concern is more that we then have (potentially) a mechanism which the player cannot understand or follow. However I do believe that this is a thing which for *game scripts* is not strictly necessary. If they wish to be opaque, so it be. As such *I* don't see a problem in exposing that variable to GS (contrary to exposing it to AI).
There would be a way to make that more transparent.

If the GS keeps a list of the industries founded by a company, it can then publish and update the list in the storybook.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: API request - expose industry founder to gamescript.

Post by krinn »

PikkaBird wrote: To give a very simplified idea of what I had in mind: a GS where the winner is the first company to found 100 new industries. On GSEventIndustryOpen, the script would check which company built the industry and credit it to them. If a company closes down, its list will be cleared; the existing industries will not be recredited.
In case it might be of help for you :

- You can "guess" who made the industry, to a certain limit. On industry open you can browse all companies money spent (its not a cheap expense and it might also goes into some specific category, see the API expenses/money for details) and check this against the prize of the industrytype that was create.
There's limit, if two industrytype appears at the same time, or when two companies found two industries within the same month, you won't be able to tell what industry was found by whom, but you can still credits both companies have founded an industry. If your aim is only # of founded industries by companies.

- You can also make your GS drives player : player must add a sign at position where to build the indutry, GS read the special sign, remove it and create the industry for the player. So the GS take the hand of player and do build it (using the player money). In this form your GS can gives credit to any company that found industry using the sign trick ; validating owner itself.
GS have access to all signs, as such, any companies can speak with GS thru signs. (that's script communication protocol base to speak with all companies).
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: API request - expose industry founder to gamescript.

Post by krinn »

planetmaker wrote: I think Alberth's concern is more that we then have (potentially) a mechanism which the player cannot understand or follow. However I do believe that this is a thing which for *game scripts* is not strictly necessary. If they wish to be opaque, so it be. As such *I* don't see a problem in exposing that variable to GS (contrary to exposing it to AI).
I do know your concern about AI must be do what human can do only ; and cheat issues. But i hardly follow you why any AI should remain blind to that info in this case.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: API request - expose industry founder to gamescript.

Post by Alberth »

krinn wrote:
planetmaker wrote: I think Alberth's concern is more that we then have (potentially) a mechanism which the player cannot understand or follow. However I do believe that this is a thing which for *game scripts* is not strictly necessary. If they wish to be opaque, so it be. As such *I* don't see a problem in exposing that variable to GS (contrary to exposing it to AI).
I do know your concern about AI must be do what human can do only ; and cheat issues. But i hardly follow you why any AI should remain blind to that info in this case.
What I pointed out was that a normal player doesn't have this information either at this moment. As such normal players and AIs are the same.

If the GS gets this information, it should provide a way for the AI to get the same information that a player gets from the GS.


To be honest, I very much doubt that all GS authors will bother to make a story book page for users about their industries (both bought and inherited), especially if only a few industries are involved for the GS. I have even more doubts that they will also provide that information to the AI, and that an AI will understand such information.
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: API request - expose industry founder to gamescript.

Post by PikkaBird »

krinn wrote:its not a cheap expense
That's a rather NewGRF-specific assumption. ;)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 40 guests