Page 1 of 2

Coding aRVs with different capacity for each part

Posted: 12 Jun 2008 10:10
by Wile E. Coyote
I wanted to code articulated RV with different capacities for each part. I used this code:

Code: Select all

   72 * 9	  02 01 10 01 01 00 00 00 00
   73 * 9	  02 01 11 01 01 01 00 01 00
   74 * 9	  02 01 12 01 01 02 00 02 00
   75 * 9	  02 01 13 01 01 03 00 03 00
   76 * 22	 02 01 20 82 46 08 03 03 10 00 00 00 11 00 01 01 12 00 02 02 13 00
   77 * 9	  02 01 21 01 01 04 00 04 00

   78 * 14	 02 01 25 81 10 00 FF 01 00 FF 0F 0F 20 00 //change capacity to 0
   79 * 14	 02 01 27 81 0C 00 FF 01 25 00 36 36 20 00 //apply that capacity via Callback 36

   80 * 14	 02 01 30 81 41 00 01 01 27 00 00 00 21 00 //when consist is formed, use c-ID with new capacity
   81 * 14	 02 01 31 81 10 00 FF 01 46 FF 01 01 FF FF
   82 * 18	 02 01 32 81 10 00 FF 02 24 FF 01 02 0E FF 03 03 30 00
   83 * 18	 02 01 33 81 0C 00 FF 02 31 00 16 16 32 00 33 33 30 00
   84 * 9 	 02 01 40 01 01 05 00 05 00
   85 * 10	 03 01 01 46 01 FF 40 00 33 00
Idea was to have first part of consist with capacity 0, and second with capacity 20 passengers (I set capacity of 20 passengers in Action0 prop. 0F). But vehicle shows capacity of 20 passengers only in purchase list, but in game has capacity 40 passengers. (With OTTD all works correct.) I even made other Callback 36, which sets capacity to 20 passengers, and applied it to second part before consist forming, but still same error appears. What I am doing wrong?

Re: Coding aRVs with different capacity for each part

Posted: 12 Jun 2008 10:20
by PikkaBird
It's showing the wrong capacity in the buy menu because you're not building the articulated vehicle there. With trains, you can use callback 15 to show the correct capacity for artics in the buy menu, I don't know if that works for RVs.

Callback 36 for capacity is not supported in TTDP yet, so that's why it won't work there. :)

Re: Coding aRVs with different capacity for each part

Posted: 12 Jun 2008 10:28
by Wile E. Coyote
Yes, I haven't noticed that CB 36 is supported for OTTD only. So that's another thing (other is CB 1D) that I am waiting for. :) (Suggestion for DaleStan: NFO Renum haven't said that CB 36 isn't supported, but for CB 1D it says.)
And actually it's showed wrong capacity in game, I intended to be 0+20, but in game shows 40 passengers.

Re: Coding aRVs with different capacity for each part

Posted: 12 Jun 2008 10:58
by PikkaBird
Wile E. Coyote wrote:Yes, I haven't noticed that CB 36 is supported for OTTD only. So that's another thing (other is CB 1D) that I am waiting for. :) (Suggestion for DaleStan: NFO Renum haven't said that CB 36 isn't supported, but for CB 1D it says.)
And actually it's showed wrong capacity in game, I intended to be 0+20, but in game shows 40 passengers.
Callback 36 is supported, though... just not setting that particular property.

Re: Coding aRVs with different capacity for each part

Posted: 12 Jun 2008 13:43
by Wile E. Coyote
But, as I saw in Wiki, it's only supported for trains? I saw that for RVs CB36 is only supported in OTTD (and only props 0F and 11).

Re: Coding aRVs with different capacity for each part

Posted: 12 Jun 2008 13:59
by Lakie
In the buy menu it appears that articulated road vehicles do not show the correct capacity, this is something I've also noticed.
They tend to show the capacity of the first unit of the articulated road vehicle's type capacity.

~ Lakie

Re: Coding aRVs with different capacity for each part

Posted: 12 Jun 2008 14:39
by Wile E. Coyote
In that case I have very strange behaviour with my code: first unit has capacity 0, second has 20, in buy menu it's shown 20, but in game capacity is 40 (Action 0 prop. 0F is set to 20).

But I suppose it's consequence of using non-available callback.

Re: Coding aRVs with different capacity for each part

Posted: 12 Jun 2008 15:06
by Lakie
Unless I'm missing something, callback 15 is used for refitting, and the buy menu uses the action0 property value, hence 20 would be the expected result...

~ Lakie

Re: Coding aRVs with different capacity for each part

Posted: 12 Jun 2008 15:27
by PikkaBird
Wile E. Coyote wrote:In that case I have very strange behaviour with my code: first unit has capacity 0
Only after it's run the callback, which it hasn't. :roll:

Re: Coding aRVs with different capacity for each part

Posted: 13 Jun 2008 07:40
by Wile E. Coyote
Lakie wrote:Unless I'm missing something, callback 15 is used for refitting, and the buy menu uses the action0 property value, hence 20 would be the expected result...
That confused me too. :?
PikkaBird wrote:
Wile E. Coyote wrote:In that case I have very strange behaviour with my code: first unit has capacity 0
Only after it's run the callback, which it hasn't. :roll:
Hm... I missed something... isn't callback ran in sprites 78 and 79? :?

BTW, in OTTD in buy list there is showed capacity 20, and in vehicle info window first unit has capacity 0, and second 20 (that is just what I intended).

Re: Coding aRVs with different capacity for each part

Posted: 13 Jun 2008 08:41
by peter1138
I'm not quite getting this. Are you using a callback which isn't supported in TTDPatch, and you're wondering why it does not work?

Re: Coding aRVs with different capacity for each part

Posted: 13 Jun 2008 10:49
by Wile E. Coyote
I wondered because I haven't knew that callback isn't supported (my mistake :oops: ). Now all is clear, I couldn't do this in Patch, only in OTTD. But now I wonder why it shows doubled capacity, due to thing Lakie said that because there is no callback support it should be used property from Action 0. Nevertheless, with OTTD which supports this callback all is working in way I wanted. :)

Just one question for OTTD: is it possible to make unit which has no capacity not to show "Empty" in vehicle info window, but to show nothing (like locomotive in train consist)?

Re: Coding aRVs with different capacity for each part

Posted: 13 Jun 2008 13:24
by Lakie
Because in TTDpatch it goes through the consist and adds all the cargo capacities together and shows the total cargo and capacity of the articulated road vehicle.
Not sure how OpenTTD shows this information though.
(Also remember an articulated road vehicle is not a train and making it look like one would be confusing to users as you cannot do the same things to them)...

~ Lakie

Re: Coding aRVs with different capacity for each part

Posted: 13 Jun 2008 13:36
by PikkaBird
Wile E. Coyote wrote:Hm... I missed something... isn't callback ran in sprites 78 and 79? :?
Not in the buy menu, no.

Your buy menu chain looks like this:

Code: Select all

84 * 9     02 01 40 01 01 05 00 05 00
85 * 10    03 01 01 46 01 FF 40 00 33 00
No callback there... :P

Re: Coding aRVs with different capacity for each part

Posted: 14 Jun 2008 13:14
by Wile E. Coyote
Lakie wrote:Because in TTDpatch it goes through the consist and adds all the cargo capacities together and shows the total cargo and capacity of the articulated road vehicle.
Is there any way to avoid that adding?
PikkaBird wrote:No callback there... :P
Whoops, you're right... My mistake. :oops:

EDIT: I did that, but capacity in buy menu is still not equal as capacity in game:

Code: Select all

   80 * 9	  02 01 40 01 01 00 00 00 00
   81 * 10	 02 01 41 81 41 00 01 01 40 00 00 00 28 00
   82 * 14	 02 01 42 81 10 00 FF 01 46 FF 01 01 FF FF
   83 * 14	 02 01 43 81 0C 00 FF 01 42 00 16 16 40 00
   84 * 10	 03 01 01 46 01 FF 43 00 33 00
What did I do wrong now?

Re: Coding aRVs with different capacity for each part

Posted: 14 Jun 2008 14:13
by Lakie
Not currently, and because its the way train articulated units work I am very reluctant to remove it.
As I've said they are not trains and they work quite differently from trains in both OpenTTD and TTDpatch.

Currently neither show articulated road vehicles like trains thus not having the totals would just be confusing (You must remember that the total can include up to 2/3 different cargo types).

[Edit] I don't think using a variable 41 in the buy menu would work as there is no consist at that point in time...
You should just return the final total capacity of the articulated road vehicle instead for the buy menu?

And as previously said for TTDpatch it requires a fix minor alterations to work better, such as trying to loop the consist in a theoretical sense.

~ Lakie

Re: Coding aRVs with different capacity for each part

Posted: 14 Jun 2008 17:06
by Wile E. Coyote
Lakie wrote:Not currently, and because its the way train articulated units work I am very reluctant to remove it.
As I've said they are not trains and they work quite differently from trains in both OpenTTD and TTDpatch.
Of course, you're absolutely right about that, I'm also against that removing (and probably others too).
Lakie wrote:I don't think using a variable 41 in the buy menu would work as there is no consist at that point in time...
It worked for articulated train wagons so I supposed it should work here too.
Lakie wrote:You should just return the final total capacity of the articulated road vehicle instead for the buy menu?
But how to do that when CB36 is not supported?

Re: Coding aRVs with different capacity for each part

Posted: 14 Jun 2008 19:05
by Lakie
As previously said, I recognise its a bug in TTDpatch, however I will not be adding cargo support through callback 36, I will merely fix TTDpatch's cargo consist calculations for the buy menu when I feel like doing any TTDpatch developing.

~ Lakie

Re: Coding aRVs with different capacity for each part

Posted: 15 Jun 2008 03:43
by PikkaBird
Wile E. Coyote wrote:
Lakie wrote:You should just return the final total capacity of the articulated road vehicle instead for the buy menu?
But how to do that when CB36 is not supported?
Edit: no you don't, silly me. :roll:

Re: Coding aRVs with different capacity for each part

Posted: 15 Jun 2008 05:24
by michael blunck
[total capacity]
PikkaBird wrote:For articulated trains, you use callback 15 in the buy menu to set the cargo amount.
IIRC, CB16.

regards
Michael