Page 1 of 1

Action0, need help, coding price

Posted: 10 Jan 2005 19:34
by Bernhard
hello,
need help. Want to code the price of my train-engine.
I thougt this must work, anyway...

13 * 31 00 00 09 01 16 00 42 0E 09 3C 00 0B 90 00 14 28 15 00 16 14 19 08 12 FD 0D 01 0E 3C 4C 00 00

price is now $ 281.250.- but i need a price of $ 10.000.
How do i do that??

Posted: 10 Jan 2005 20:03
by krtaylor
You don't code the price in absolute dollars. I believe the price is expressed in British pounds, date 1921. Thereafter it is adjusted by the inflation set in the individual game settings.

Posted: 10 Jan 2005 20:51
by Oracle
No, price is actually set by "Cost factor", which is therefore a factor rather than an absolute value. I did do some research some time ago into prices and put the running costs on the Wiki but for some reason I never put build costs on there. This is what I found, with cost factor on the left and price on the right (all prices 1920, pre-inflation, US dollars, vary with difficulty level):

Code: Select all

Easy:
01 $  2342
10 $ 37500
20 $ 75000
80 $300000
A0 $375000
FF $597656

Medium:
01 $  3124
10 $ 50000
20 $100000
80 $400000
A0 $500000
FF $796874

Hard:
01 $  3514
10 $ 56250
20 $112500
80 $450000
A0 $562500
FF $896484
The cost factor is a linear scaling of the price so, to approximate, do price divided by $3124 and convert to hex to get a reasonable value of cost in Medium difficulty.

Posted: 10 Jan 2005 21:39
by Patchman
Note that the dbset xl modifies the base costs (using a new action 0 type), so if you load your train with the db set xl active, the prices will probably be much higher than you want/expect.

(For testing, it's always best to deactivate all other graphics anyway to eliminate this kind of interference.)

Posted: 11 Jan 2005 07:00
by Bernhard
@ Oracle... thanx. i had read your explanations in the wiki, they are good. But i didn' understood why it doesn't work as i thought. Perhaps is the dbset the reason, as Patchman said.

@ Patchman... thanx too. Do you have a idea how i could change that back? I need a price of max. 20.000 DEM in 1930 for my VT133 ( http://ttdgraphics.cjb.net/graphid.php?id=98 ). It was a very cheap railbus.

@ krtaylor, thanks to you too. What currency is the base is not so importent. If i have the way to code, i can figure out. (is that right for try until it is right?)

Posted: 11 Jan 2005 15:47
by Patchman
Bernhard wrote:@ Patchman... thanx too. Do you have a idea how i could change that back? I need a price of max. 20.000 DEM in 1930 for my VT133 ( http://ttdgraphics.cjb.net/graphid.php?id=98 ). It was a very cheap railbus.
Well, empty out your newgrfw.cfg file and only leave your test grf in there. Then try again.

Posted: 11 Jan 2005 16:17
by Bernhard
Oracle wrote:The cost factor is a linear scaling of the price so, to approximate, do price divided by $3124 and convert to hex to get a reasonable value of cost in Medium difficulty.
sorry, had not seen your last sentence. Will try that this evening!

Re: Action0, need help, coding price

Posted: 12 Jan 2005 06:56
by Bernhard
if i had understood the wiki right, this is the part where the costs are defined: 0D 01 0E 3C 4C 00 00

but it doesn't work.

With DB-Set active the price is 580.000DEM, without the price is 250.000DEM.

and it is regardless of which values i add. 0D FF 0E 3C 4C 00 00 will have the same resulat as 0D 00 0E 3C 4C 00 00

is it possible that the price comes from the train-id?

i've coded the train to replace id 16................

ok i will try............

Re: Action0, need help, coding price

Posted: 12 Jan 2005 21:39
by cornelius
Bernhard wrote:if i had understood the wiki right, this is the part where the costs are defined: 0D 01 0E 3C 4C 00 00

but it doesn't work.

With DB-Set active the price is 580.000DEM, without the price is 250.000DEM.

and it is regardless of which values i add. 0D FF 0E 3C 4C 00 00 will have the same resulat as 0D 00 0E 3C 4C 00 00

is it possible that the price comes from the train-id?

i've coded the train to replace id 16................

ok i will try............
Properties 0d and 0e are for running cost (how much the thing costs to maintain). To set the purchase price you need to use property 17 - this is the 'cost factor' that Oracle mentioned.

Posted: 13 Jan 2005 06:53
by Bernhard
ok, my fault, will try ...........

thx cornelius !

Posted: 27 Jan 2005 03:35
by Siema
I don't want to make new topic to don't make mess and write my problem here. I'm begginer in coding and need some help. I spent half night studing wiki graphics specs and other sets but i don't know where is the problem:

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 4)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
    0 * 4  0E 00 00 00
    1 * 24 08 06 4D 53 01 01 50 4B 50 20 73 65 74 00 28 63 29 20 53 69 65 6D 61 00
    2 * 4  01 00 01 08
    3 C:\Documents and Settings\Maciej\Pulpit\pkp set\gotowe grafiki PCX\sp32w.pcx 16 16 16 21 7 -3 -14
    4 C:\Documents and Settings\Maciej\Pulpit\pkp set\gotowe grafiki PCX\sp32w.pcx 26 16 16 15 20 -9 -7
    5 C:\Documents and Settings\Maciej\Pulpit\pkp set\gotowe grafiki PCX\sp32w.pcx 49 16 16 11 29 -13 -6
    6 C:\Documents and Settings\Maciej\Pulpit\pkp set\gotowe grafiki PCX\sp32w.pcx 81 16 16 15 20 -9 -7
    7 C:\Documents and Settings\Maciej\Pulpit\pkp set\gotowe grafiki PCX\sp32w.pcx 104 16 01 21 07 -3 -6
    8 C:\Documents and Settings\Maciej\Pulpit\pkp set\gotowe grafiki PCX\sp32w.pcx 114 16 09 15 20 -10 -8
    9 C:\Documents and Settings\Maciej\Pulpit\pkp set\gotowe grafiki PCX\sp32w.pcx 137 16 01 11 29 -15 -6
   10 C:\Documents and Settings\Maciej\Pulpit\pkp set\gotowe grafiki PCX\sp32w.pcx 169 16 09 15 20 -10 -8
   11 * 9  02 00 00 01 01 00 00 00 00
   12 * 7  03 00 01 02 00 00 00
   13 * 10 04 00 1F 01 02 53 50 33 32 00
   14 * 28 00 00 0A 01 02 00 56 47 02 00 03 25 04 50 06 07 09 64 00 0B FA 04 19 08 22 20 12 FD
Everything is ok. exept that that I see only 4 from 8 sprites of my loco in game.

Posted: 27 Jan 2005 03:45
by DaleStan
The NFO looks fine. Can you post the GRF?

Posted: 27 Jan 2005 09:32
by Siema
Here is my grf. And also newgrf.cfg. when i test this loco i have all grfs turned off, exept all that apears with blue flag in gamea, and of course this loco.

Posted: 27 Jan 2005 15:22
by DaleStan
OK, I found it, and it is in the NFO. A compression (the third number after the file name) of 16 is apparently not valid. (The wiki is <sarcasm>oh, so helpful</sarcasm> here.) I always use 01.

Posted: 27 Jan 2005 16:03
by Mek
DaleStan wrote:OK, I found it, and it is in the NFO. A compression (the third number after the file name) of 16 is apparently not valid. (The wiki is <sarcasm>oh, so helpful</sarcasm> here.) I always use 01.
I don't know much about that number either, but i tried reading the grfcodec source to see what it might do; first of all it is actualy a bitmask. but afaict only two bits are relevant, bit 1 (0x02) and bit 3 (0x08), but looking at the ttd grf files bit 0 also is always set. So the only relevant values for this field are 01, 03, 09 (and 0B?). (And yes, this field must be written in hex...)
According to the grfcodec source, bit 1 has something to do with compression, and bit 3 something with transparency...

Posted: 27 Jan 2005 19:51
by Siema
thanks a lot for this. it was 16 because I have used nfoeditor to calibrate vehicle position and it changed the values.

BTW as a begginer I want to know some things too:

1.When I want to code next vehicle in the same nfo file I just must repeat this construction (exept entry 0) with adequate values?

2.Does first entry (entry 0) have any other meaning or it just counts number of entrys?

Thanx in advance.

Posted: 27 Jan 2005 20:50
by DaleStan
1) Repeat sprites 2-14 as necessary. Do not duplicate the action 8.
2) Sprite 0 has no meaning beyond being a count of the sprites in the file.

It is possible to interlace the data to some extent, so you have only a few action 0s, two action 1s (one for 4-sprite vehicles and one for 8-sprite vehicles), and one action 4, but this makes modifications and debugging incredibly hard.

Posted: 27 Jan 2005 21:51
by Siema
thanx again. it was very instructive lesson .... for beginner :)