FS#5390 - Patch -> GS + AI API Addition: OnHouseDestroyed

Attached to Project: OpenTTD
Opened by Frank (XFrankX) - Friday, 14 December 2012, 10:48 GMT
Last edited by andythenorth (andythenorth) - Thursday, 24 August 2017, 19:23 GMT
Type Patch
Category Script → Goal/Game script
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


This patch adds a functionality to the GameScript + AI engine called OnHouseDestroyed. It's triggered when some company destroys a house in a town.

A Forum thread has been created for this patch:

The patch returns the ID of the company which destroyed a house, the ID of the town where the house got destroyed and the population of the house that got destroyed. This Function can be usefull in gamescripts when you want for example an anti-cheat / anti-troll function!

The Patch attached is for the latest TRUNK (14-12-2012).

Best regards,

Server Admin BTPro
This task depends upon

Closed by  andythenorth (andythenorth)
Thursday, 24 August 2017, 19:23 GMT
Reason for closing:  Won't implement
Additional comments about closing:  Mass closure of patch tickets with no recent commentary. Goal is to reduce patch queue as an experiment to see if it aids faster reviewing and rejection/acceptance (it may not). If this offends you and the patch is maintained and compiles with current trunk, discuss with andythenorth in irc. (andythenorth has no ability to review patches but can re-open tickets). Thanks.
Comment by Frank (XFrankX) - Friday, 14 December 2012, 11:14 GMT
Oops, Attachment didn't come through...
Comment by Charles Pigott (LordAro) - Tuesday, 25 December 2012, 22:28 GMT
1 issue i noticed:

- "script/api/game/game_event.hpp.sq" there is a strange line with some extra whitespace, which is odd, as that file is generated by a script. You did use squirrel_export.[sh|awk], right?
Comment by Leif Linse (Zuu) - Monday, 21 January 2013, 19:56 GMT
If you look at the existing Event classes, none of them include "On" in their name. Instead events in NoAI and NoGo only uses "Event" as prefix. Thus I suggest that your event is renamed to ScriptEventHouseDestroyed (instead of ScriptEventOnHouseDestroyed).

Also, guided by the design goal that AIs should have about the same information available as players, I would suggest that this event is only available to game scripts. To accomplish this you can look at for example script_goal.hpp and see how it uses "@api game" to make it GameScript only. Re-run to re-generate the .sq files as LordAro suggested.