Hi there,
I have been trying to extend the 'awards gs' with some extra goals. One of those is an award for funding/prospecting an industry. It does not seem possible with the current GS api to determine who funded an industry though.
I would therefor like to request for an extension of GSEventIndustryOpen class with something like GetIndustryFunded (or if that is not the proper class may add a new class like GSEventIndustryFunded.)
If there is another way to solve it I am open for suggestions.
Extension of GSEventIndustry
Moderator: OpenTTD Developers
Re: Extension of GSEventIndustry
I don't think anyone would change any part of openttd just to agree any script. If the functionality can add value to the API, you can make a patch and add it to flyspray.
Addding who build the town/industry is a bit weak as it won't provide any benefits to anyone except your case, seems kinda a lost cause to me.
That's my pov, but openttd devs may answer that part better.
You might get better result asking a change to per example GetBankBalance or GetQuaterlyExpenses to take ExpensesType into account, so you would be able to query the balance of a company base on its ExpensesType ; this should be more useful for many (and also to you see below why).
If you really want track who build a town or industry, you can try guess it :
- track all companies value (or company money, hence if API can filter out GetQuaterlyExpenses with ExpensesType.EXPENSES_OTHER it will fine tune it better)
- wait for event town/industry built
on event town/industry
- lookup what industrytype was built GSIndustry.GetIndustryType
- lookup how much it cost to built that industrytype : GSIndustry.GetConstructionCost
- now lookup what company value has been taken down by the industry cost : when a company built an industry/town, its own value is taken down a lot because of the huge amount of money taken to build it. Better add a margin there in case the company value variation.
To sumup :
If all companies values are 10000
if building an industry need 5000 money to be build, lookup what company value has lost 4500-5500 (using a 10% margin) and it should answer who has invest its money on it.
It's not perfect, if a company built two industries in a row or two companies built two industries before the event is trigger, you will get a hard time finding who has made that. But it should generally works. You might specially watch it as award itself influence the company value by giving or taking money to/from others, right now it is doing it with EXPENSES_OTHER but it could be change to help.
Addding who build the town/industry is a bit weak as it won't provide any benefits to anyone except your case, seems kinda a lost cause to me.
That's my pov, but openttd devs may answer that part better.
You might get better result asking a change to per example GetBankBalance or GetQuaterlyExpenses to take ExpensesType into account, so you would be able to query the balance of a company base on its ExpensesType ; this should be more useful for many (and also to you see below why).
If you really want track who build a town or industry, you can try guess it :
- track all companies value (or company money, hence if API can filter out GetQuaterlyExpenses with ExpensesType.EXPENSES_OTHER it will fine tune it better)
- wait for event town/industry built
on event town/industry
- lookup what industrytype was built GSIndustry.GetIndustryType
- lookup how much it cost to built that industrytype : GSIndustry.GetConstructionCost
- now lookup what company value has been taken down by the industry cost : when a company built an industry/town, its own value is taken down a lot because of the huge amount of money taken to build it. Better add a margin there in case the company value variation.
To sumup :
If all companies values are 10000
if building an industry need 5000 money to be build, lookup what company value has lost 4500-5500 (using a 10% margin) and it should answer who has invest its money on it.
It's not perfect, if a company built two industries in a row or two companies built two industries before the event is trigger, you will get a hard time finding who has made that. But it should generally works. You might specially watch it as award itself influence the company value by giving or taking money to/from others, right now it is doing it with EXPENSES_OTHER but it could be change to help.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Extension of GSEventIndustry
The game already tracks in the industry struct who owns (always 'none', though) and who funded an industry. But afaik it's not exposed anywhere for any use.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Extension of GSEventIndustry
Thanks for your answers.
I doubt that this script would be the only one that could potentially benefit from this function though. It could be used for a gs that claims funded industries as private by placing a sign or something similar. I know that private industries have been discussed before and some don't like the idea, but IMO it could be nice for multiplayer games (especially city builder games). The argument that this goes against the idea of competition in the game is not really valid here imho because on most bigger Ottd server comunities (Btpro, N-ice and Novapolis that I am aware of) competition on secondary industries is not allowed anyway. In these cases private (funded) industries would be an improvement because then at least a player has to first fund an industry before being able to claim it.
@krinn: thanks for the suggested workaround. Unless something better pops into my mind or the requested function gets implemented I guess this will be the way I'll implement it.
I have thought about similar ways of doing it but the problem is that it is, as you pointed out yourself, not 'fail-safe'.
The thing here is: my goal is to create a gs that implements 'quest-like' goals into the game. In stead of a global goal for the whole game (reach x-cv or x-income or grow a city to a certain population, it should have smaller goals that get increasingly difficult and implement that on a multiplayer server. I would not like to use a system that is highly likely to fail at some point in this situation.
About the patching part: If I get more time in the future I will probably learn more about c++ and the general coding style of the game. For the moment, it is out of my range though. Squirrel is easier to understand for me and I have also learned a bit about the NML code for newgrfs so that are areas where I can actually make some progress. Also I am quite sure that for people that do have the right knowledge and experience this will not be a lot of work to add. (it's not like I am asking for a completely new game functionality and as planetmaker has pointed out the required info is already present in the industry struct.)
I doubt that this script would be the only one that could potentially benefit from this function though. It could be used for a gs that claims funded industries as private by placing a sign or something similar. I know that private industries have been discussed before and some don't like the idea, but IMO it could be nice for multiplayer games (especially city builder games). The argument that this goes against the idea of competition in the game is not really valid here imho because on most bigger Ottd server comunities (Btpro, N-ice and Novapolis that I am aware of) competition on secondary industries is not allowed anyway. In these cases private (funded) industries would be an improvement because then at least a player has to first fund an industry before being able to claim it.
@krinn: thanks for the suggested workaround. Unless something better pops into my mind or the requested function gets implemented I guess this will be the way I'll implement it.
I have thought about similar ways of doing it but the problem is that it is, as you pointed out yourself, not 'fail-safe'.
The thing here is: my goal is to create a gs that implements 'quest-like' goals into the game. In stead of a global goal for the whole game (reach x-cv or x-income or grow a city to a certain population, it should have smaller goals that get increasingly difficult and implement that on a multiplayer server. I would not like to use a system that is highly likely to fail at some point in this situation.
About the patching part: If I get more time in the future I will probably learn more about c++ and the general coding style of the game. For the moment, it is out of my range though. Squirrel is easier to understand for me and I have also learned a bit about the NML code for newgrfs so that are areas where I can actually make some progress. Also I am quite sure that for people that do have the right knowledge and experience this will not be a lot of work to add. (it's not like I am asking for a completely new game functionality and as planetmaker has pointed out the required info is already present in the industry struct.)
Who is online
Users browsing this forum: No registered users and 5 guests