Awards GS

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

krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Awards GS

Post by krinn »

Here's a new gamescript : awards.
This GS doesn't handle goals and town growth. Offering a different style of gamescript.
It need an openttd that handle 1.4 GS API.

There's currently no dependencies for it. Language: english and french.

Here are the rules (but just hit the storybook button for more explain):
- You win awards, medals... by playing the game and get points for each one you own.

If enable, you can also win rewards :
- For each X points (per default 100) : a company steal money from others companies.
- For each X month, all companies get a percent of money base on their rank.

The amount of money, inverval... are options you can set.

Both rewards use a base money amount for money operation, that "BaseMoney" is x * LoanInterval (where x is configurable in the script option) : per default 1

* 1 reward is a periodic one (disable per default): companies cannot loose money with this one, it have two usage :
- Gives a bit of money to boost companies that lead the rank table
- Balance the other reward bad effect (as this one takes money)
It's pretty simple :
The company rank 1st gets 100% of BaseMoney
The company rank 2nd gets the percent of points from the 1st company of BaseMoney : so if 1st company have 130 points, 2nd company have 90 points and BaseMoney is 10000 : 1st company takes 10000, 2nd company takes 90 / 130 * 10000 = 6923.... And another one with 40 points : 40 / 130 * 10000 = 3000

* And the 2nd reward is gave to any companies that reach an amount of points (this one is per default enable, to spice things), per default the amount is set to 100 but it's also configurable :
When a company reach 100 points : BaseMoney is taken from all other companies and add to its account : So with 5 companies playing : 4 companies loose 10000, 1 company gets 40000.
This one can be a serious threat for new company sure, but it could be balance by enabling the other one or disabling it.
There also some rewards that can only be get when you plays poorly or do wrong things... This should help new companies a bit to not stay at 0 points.

Disable both rewards to play a "classic" openttd game while still getting awards/medals.
This gamescript is license under the GPLv2+ and source are there : http://dev.openttdcoop.org/projects/gs-awards
awards.png
awards.png (86.72 KiB) Viewed 3168 times
Last edited by krinn on 15 Dec 2013 19:42, edited 5 times in total.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Awards GS

Post by Zuu »

I think it is an interesting concept that I'm sure will add some spice to causal multiplayer games.

At start I though it was a bit hard to know what to do in order to obtain awards. But I saw that the AI got some rewards just by playing, so I just started to play too as usual and got some awards.

Regarding the medals, it is a bit hard when all you know is that they are hard to obtain. Eventually people who play competitive with this GS will look up in the source how to obtain the medals (I did that as I was wondering what kind of effort was required to get a medal, but will not post the solution here in case that give a spoiler to someone who like to try it out without this information)

Taking money from the companies with least points and give to the company with most points may for some seem to be a bit silly as that make it harder for new companies than it is already. However, as long as the money taken is not too significant it may bee seen as just some fun fact and I see that you can turn off this if you still want to play with the awards but with no money impact. (says the guy who wrote the API to give/take money ;-) )

krinn wrote:It's not yet finish, but if you want test, report bug, translate (and fixes spelling), i'll be happy.
You may get more testers, if you tell a bit about what is finished or not? Eg. is it worth the effort to try it out? After testing, I would say yes, but I had no clue when I read this statement.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Awards GS

Post by krinn »

I'll update the first post with a more details, here are the full rules for rewards:

Both rewards use a base money amount for money operation, that "BaseMoney" is x * LoanInterval (where x is configurable in the script option) : per default 1

* 1 reward is a periodic one (disable per default): companies cannot loose money with this one, it have two usage :
- Gives a bit of money to boost companies that lead the rank table
- Balance the other reward bad effect (as this one takes money)
It's pretty simple :
The company rank 1st gets 100% of BaseMoney
The company rank 2nd gets the percent of points from the 1st company of BaseMoney : so if 1st company have 130 points, 2nd company have 90 points and BaseMoney is 10000 : 1st company takes 10000, 2nd company takes 90 / 130 * 10000 = 6923.... And another one with 40 points : 40 / 130 * 10000 = 3000

* And the 2nd reward is gave to any companies that reach an amount of points (this one is per default enable, to spice things), per default the amount is set to 100 but it's also configurable :
When a company reach 100 points : BaseMoney is taken from all other companies and add to its account : So with 5 companies playing : 4 companies loose 10000, 1 company gets 40000.
This one can be a serious threat for new company sure, but it could be balance by enabling the other one or disabling it.
There also some rewards that can only be get when you plays poorly or do wrong things... This should help new companies a bit to not stay at 0 points.


Many rewards included clues on how to get them in their title, and nearly all gave the conditions to get them when someone reveal them.
SPOILER ALERT : As example The "We are the Borg" is grant to a company that buy all shares of another one...

Medals & rewards even depends on the current game configuration : the current map type and the newGRFs in use. So some cannot be earn on a "stock openttd". And yes you cannot earn all rewards available in one game.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Awards GS

Post by Zuu »

enhlish.txt wrote:<space>:<space>
In lots of places you have a space before the colon in a sentence. This is not common in English to do so. Is there any reason why you have this extra space?
english.txt wrote:STR_INFO_39 : The first owning the three awards.
Should "the" really be there. Is this award really an award for having 3 specific awards or is it awarded to someone having 3 random awards? In the later case, there should not be any "the" there. In the former case the sentence is incomplete as it doesn't specify which 3 specific awards that it indicate that you need to achieve.


Edit: Making an initial translation by editing english.txt may be useful, but for easier maintaining of translations, especially those languages that you do not know yourself it would be good if you could use Eints (translator.openttdcoop.org). To do so it is a good idea to first move those setting strings to some .nut definition file rather than having them in the translation system. If you use eints and change a string in english.txt, then that string will be marked as needing verification/update for all translations. After someone looking through the string he/she can save the string again and it will be marked as up to date.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Awards GS

Post by krinn »

Zuu wrote:
enhlish.txt wrote:<space>:<space>
In lots of places you have a space before the colon in a sentence. This is not common in English to do so. Is there any reason why you have this extra space?
No, that's a mistake or bad habit, french use <word space : space word> version, something i should fix.
english.txt wrote:STR_INFO_39 : The first owning the three awards.
Should "the" really be there. Is this award really an award for having 3 specific awards or is it awarded to someone having 3 random awards?
Really for having 3 specific awards
In the former case the sentence is incomplete as it doesn't specify which 3 specific awards that it indicate that you need to achieve.
It will shown the needed 3 awards only when that award is earn by someone, this is normal as this award is rank medal.
But really you don't get a clue of what the three could be by its title, that's a real classic movie...
Edit: Making an initial translation by editing english.txt may be useful, but for easier maintaining of translations, especially those languages that you do not know yourself it would be good if you could use Eints (translator.openttdcoop.org). To do so it is a good idea to first move those setting strings to some .nut definition file rather than having them in the translation system. If you use eints and change a string in english.txt, then that string will be marked as needing verification/update for all translations. After someone looking through the string he/she can save the string again and it will be marked as up to date.
I have no idea how this works, even i have use it to update some files for you :)
But in my case, i'm not sure it would be really of help, i don't plant to change awards, i might add new ones, but won't change older ones, so language files should remain the same except for the additionnal awards. I mean a fix in english.txt (like the : case) shouldn't propagate need for fixes in other languages.
lugo
Engineer
Engineer
Posts: 100
Joined: 12 Oct 2010 13:55

Re: Awards GS

Post by lugo »

Hi Krinn,

i recently had a multiplayer game using r26156 und your awards gs. Problem is, it didn't seem to start.
There are no ranks or medals assigned to any company after now 40 game years. There's also only one company (owner of that company being the server) in the rank list (with 0 points).

P.S. i really like the idea of your script and in single player (with AIs) it's working well
P.P.S. PM me, if you need any newgrfs to load attached save game
Attachments
Malaysian Airlines, 27. Dez 1944.sav
(485.83 KiB) Downloaded 378 times
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Awards GS

Post by krinn »

lugo:
I will look for that, but i'm afraid i would need to setup a server for that, and might need some answers from the bad guys at #openttd as there's no difference from the API pov with a server or a standalone game.
I suppose (and hope to reproduce the bug without it) i won't need that savegame, FFS ! How many newGRF are there ! openttd content download help me for like 20 of them, but i'm still missing like 8-12 grfs!
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Awards GS

Post by Zuu »

In dedicated multiplayer there is no company zero created at first tick after worldgen, instead companies are created when people join. There is an API to check if the game is running on a multiplayer server. I'm unsure if you can tell a dedicated server from a GUI-server but in general if you write code that work on dedicated servers it will work on both GUI-servers and single player.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Awards GS

Post by krinn »

Zuu wrote:In dedicated multiplayer there is no company zero created at first tick after worldgen
That's good hint , i will look at that, it might be possible i assume one exists.
lugo
Engineer
Engineer
Posts: 100
Joined: 12 Oct 2010 13:55

Re: Awards GS

Post by lugo »

I don't know if that's relevant, but iirc i created the map in single player, saved and copied it over to the server (which is not dedicated) and loaded it there as a multiplayer game.

P.S. PM with GRFs should be in your inbox, krinn
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Awards GS

Post by Zuu »

lugo: It is relevant how you saved that game. Was it saved on the server or from a client? When you join a multiplayer game as client and save it, the save game will NOT contain Game Script data even including information about what script is running is only present on the server. Thus if you ever made a save from a client and then uploaded here or transfered to your server to resume the game, information about what GS to use will be lost.

If you made a single player save game and then loaded that in the server, that should in general work, unless there is a limitation in the specific GS that you use.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Awards GS

Post by krinn »

Ok after enabling newgrf devtools to bypass the missing newgrf (thanks planetmaker). I finally could load the game, and Zuu is right, there's no gamescript in that savegame.
lugo
Engineer
Engineer
Posts: 100
Joined: 12 Oct 2010 13:55

Re: Awards GS

Post by lugo »

If you made a single player save game and then loaded that in the server, that should in general work, unless there is a limitation in the specific GS that you use.
That's what i initially did, but the save i uploaded here is from a client.
Note: the server didn't have the GS downloaded.
So the question is: should the server download the GS if it's loading a save game with that GS?
I attached the save game the server was started with.
Attachments
Unbenannt, 1. Jan 1914.sav
(374.6 KiB) Downloaded 330 times
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Awards GS

Post by Zuu »

lugo wrote:So the question is: should the server download the GS if it's loading a save game with that GS?
Yes, in my view (and I know other devs agree on this too) it _should_ inform you about missing GS and offer you to download that just as with NewGRFs. However, currently it will silently just not load any missing Game Script.

There are some technical difficulties in making it work well. That includes the problem that OpenTTD currently saves the script name and not its uniqueid (short name) in the save game file.

I've started a patch queue to work on this, but so far I've not got very far. If anyone else want to work on this, it is welcome.


Edit: To download a GS on a dedicated server, there is a console command called "content" which allow you to access the content download system. If you use 1.4-beta/rc or trunk, it will be enhanced to allow you to filter the search results.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
lugo
Engineer
Engineer
Posts: 100
Joined: 12 Oct 2010 13:55

Re: Awards GS

Post by lugo »

Thanks for clarifying Zuu,

so to get back on topic.
Is there a chance you can add your project here: https://translator.openttdcoop.org/?

And by the way i had some pretty good laughs while translating :)
Sadly, while testing it, there were immediatly gone, because debug-window says there might be an error in a lang file.
I'm a little clueless as to what the problem might be. I checked if all {, and ( are closed, they are.

edit: typos
Attachments
german.txt
(11.85 KiB) Downloaded 306 times
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Awards GS

Post by krinn »

Thank you for the language file lugo.

At first, the filetype should be in linux format if i'm right. Ending with \n only. Windows format add an extra \r
Easy to fix it. (make sure your editor is setup for linux file)

Code: Select all

english.txt: UTF-8 Unicode text, with very long lines
french.txt:  UTF-8 Unicode text, with very long lines
german.new:  UTF-8 Unicode text, with very long lines
german.txt:  UTF-8 Unicode text, with very long lines, with CRLF line terminators
Still there's another error, with invalid UTF char in the file.

Code: Select all

dbg: [script] german:33: FATAL: Unwanted UTF-8 character U+0009 in sequence ' FAHRZEUGPRÄMIE	'
Removing the tab after the word. Fix.

And removing the part from the german.txt state as #No translation need -> upto # Translation need. (see french.txt for example or the new german.txt i will attach here).
If that part is missing in german.txt, openttd will default display the one from english.txt
So you modify STR_LGS_AUTHOR from english.txt, and remove it from german.txt. If it was there, openttd would only display it in german, if the part miss in any language, it will use the one from english.txt. So in all language that part display the same text.
This way, even english users will see who has made the german version instead of only german users. This also avoid duplicate what would be common in all languages files.

Here are the updated files, if you want see in real the result :)
Attachments
english.txt
(10.8 KiB) Downloaded 231 times
german.txt
(11.06 KiB) Downloaded 369 times
Last edited by krinn on 25 Mar 2014 14:55, edited 1 time in total.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Awards GS

Post by planetmaker »

Just a hint: The DevZone's translation service can also handle game scripts. It would take care of these errors mostly automagically.
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Awards GS

Post by krinn »

Zuu speak about that too, i use it myself to update Zuu script language file, but i wasn't sure anyone have interest in that (with my script i mean).
I will look into adding that.

edit: Add it thru eints, there : https://translator.openttdcoop.org/project/gs-awards
lugo
Engineer
Engineer
Posts: 100
Joined: 12 Oct 2010 13:55

Re: Awards GS

Post by lugo »

Thank you. Much more convinient!
One thing i forgot to mention, when i posted the first translation.
I haven't found the strings for the AI/GS-settings window, i.e. "Display news when a medal or award is won" , in english.txt
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Awards GS

Post by Zuu »

lugo wrote:I haven't found the strings for the AI/GS-settings window, i.e. "Display news when a medal or award is won" , in english.txt
Those strings are not translatable. It would be good if it was, but it is currently not implemented.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest