AICompany.SetCompanyColor("pink")

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
Hephi
Engineer
Engineer
Posts: 72
Joined: 25 Oct 2009 09:56
Location: Belgium

AICompany.SetCompanyColor("pink")

Post by Hephi »

Hey guys,

I can't seem to find the NOAI command to set the company colour although it 'should' exist because it's a value you can change inside the game.
Any pointers? I've searched API and forum but couldn't find a topic about it. Thx
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AICompany.SetCompanyColor("pink")

Post by planetmaker »

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: AICompany.SetCompanyColor("pink")

Post by Zuu »

I remember that this has been suggested before and docummented in the API extension suggestions thread.

Mainly I think this has been left out because it does not really affect anything in the game. That said, I think if someone comes up with an implementation of the API that will increase the chance of it being added. I think It's just that the AI API developers haven't found this feature worth the effort.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AICompany.SetCompanyColor("pink")

Post by Yexo »

Zuu wrote:Mainly I think this has been left out because it does not really affect anything in the game. That said, I think if someone comes up with an implementation of the API that will increase the chance of it being added. I think It's just that the AI API developers haven't found this feature worth the effort.
Correct.
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: AICompany.SetCompanyColor("pink")

Post by Lord Aro »

This interests me
Which files in the source code would i have to edit to implement these functions? (In a patch)
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AICompany.SetCompanyColor("pink")

Post by Yexo »

At least ai_company.hpp and ai_company.cpp. If I could be bothered to check if you need to change any more files I'd have already implemented it.
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: AICompany.SetCompanyColor("pink")

Post by Lord Aro »

Yexo wrote:At least ai_company.hpp and ai_company.cpp. If I could be bothered to check if you need to change any more files I'd have already implemented it.
Hmm.

Me and no-experience with c++ means that i am unable to complete this patch on my own. :rolleyes:

My problems are understanding the p1 and p2 of the AIObject::DoCommand() function. i have looked at the main DoCommandP() and the documentation and other implementations of company colour change, but i can't seem to understand how to do it

For example, line 798 of company_gui.cpp has this:

Code: Select all

DoCommandP(0, scheme | (widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), index, CMD_SET_COMPANY_COLOUR);
From what i can tell, an extra parameter has been shoved in with p1 with the '|' operator, and the first half of p1 has something to do with bits

Help please?

Also, i notice that there are xxxxxxxxx.hpp.sq files. Do i need to edit them as well?
Attachments
ai_company_colour_r21329_unfinished.diff
(985 Bytes) Downloaded 41 times
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests