External Publication
Visit Post

OpenTTD AIs and Game Scripts • Re: Detect if company is human or AI controlled?

Transport Tycoon Forums - Index page [Unofficial] March 21, 2026
Source

Yeah, there is no api to check if company is AI, the only api is AIInfo, but docs says it's not an api in a sense that it can be used from within AI, only game can use this info.

What you can do in regard to testing some company income is to handle all of the AIEventCompany*** events, like, AIEventCompanyNew or AIEventCompanyAskMerger, still doesn't tell if company is AI or human but you can store Company ID's and update them when they change such as AIEventCompanyBankrupt will release an ID and then AIEventCompanyNew will assign a new ID, ID's are not guaranteed to be sequential and they may be released so events help here.

Getting income of companies out there is easy if you have ID's, but no way to tell if it's human.

AICompany::ResolveCompanyID looks promising but there are constants for only first and last company, and you figured out first one is human, but that's useless in multi player. However you can use this function in combination with events e.g to test your stored company ID's if they're valid and to filter out yourself and 1st player.

Statistics: Posted by GoldMine — 21 Mar 2026 20:01


Discussion in the ATmosphere

Loading comments...