Eventhandling question regarding new engine

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
honnes
Engineer
Engineer
Posts: 30
Joined: 22 Sep 2009 16:07

Eventhandling question regarding new engine

Post by honnes »

Hello,

I have a question regarding new engines available. When there's a new vehicle available to the player, is it then available to the AI as well ?

If so, then something is going wrong with the events, because when it's 1964 ingame, a new bus will become available, and when it's available to me, the event is not being triggered at the AI. (A long time later it does)

I use the following to deal with the event:

Code: Select all

case AIEvent.AI_ET_ENGINE_AVAILABLE: // A new engine is available
	Debug("EVENTS: There's a new vehicle available!");
	// Here goes what to do next
	break;
I also put in the logwindow the eventnumber, and for subsidies, it's 2, and that event shows up the moment there is one available, but for the new vehicle, the eventID is 17, it also runs the code I posted, but the event is being triggered ages later.

I'm kind of confused by this matter, unless that it is true that the AI gets the event triggered months later (to give the normal player a benefit).

I also hope that there are other's interested in this, and hope they'll get to know it this way as well :)
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

Re: Eventhandling question regarding new engine

Post by Chruker »

Just to make sure. The player havent accepted the engine as a preview offer (the blue dialog box), correct?
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

Re: Eventhandling question regarding new engine

Post by Chruker »

honnes wrote:I'm kind of confused by this matter, unless that it is true that the AI gets the event triggered months later (to give the normal player a benefit).
AFAIK and have observed, the API doesnt do that.
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Re: Eventhandling question regarding new engine

Post by XeryusTC »

Chruker wrote:Just to make sure. The player havent accepted the engine as a preview offer (the blue dialog box), correct?
I think this is the case here, you the player got to test the prototype and the actual model is introduced a year later. That would be the only logical explanation to me.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
honnes
Engineer
Engineer
Posts: 30
Joined: 22 Sep 2009 16:07

Re: Eventhandling question regarding new engine

Post by honnes »

XeryusTC wrote:
Chruker wrote:Just to make sure. The player havent accepted the engine as a preview offer (the blue dialog box), correct?
I think this is the case here, you the player got to test the prototype and the actual model is introduced a year later. That would be the only logical explanation to me.
I just checked it and you are totally right. I thought that this blue box would mean that you want to use the vehicle now, and that the AI could use it too. Thanks for this info :)
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: Eventhandling question regarding new engine

Post by Brumi »

The blue window means that the company is offered an exclusive use of the vehicle for 1 year. The AI can also get this 'blue window', the name of that event is AI_ET_ENGINE_PREVIEW. Just make sure that you convert the AIEvent instance to an AIEventEnginePreview and call AcceptPreview() from there. Then only the AI will be able to use that vehicle for one year.
honnes
Engineer
Engineer
Posts: 30
Joined: 22 Sep 2009 16:07

Re: Eventhandling question regarding new engine

Post by honnes »

Brumi wrote:The blue window means that the company is offered an exclusive use of the vehicle for 1 year. The AI can also get this 'blue window', the name of that event is AI_ET_ENGINE_PREVIEW. Just make sure that you convert the AIEvent instance to an AIEventEnginePreview and call AcceptPreview() from there. Then only the AI will be able to use that vehicle for one year.
Thank you very much for your input Brumi, this is something I would not have thought of !
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest