train.m Object

Ask for help regarding any Re-Volt topic here.
User avatar
Kiwi
Posts: 378
Joined: Thu Dec 07, 2017 9:04 pm
Contact:

train.m Object

Unread post by Kiwi » Wed Jun 05, 2019 9:18 am

How does the train.m object works exactly?

If I place a customized train object (Replaced models: train.m, train2.m, train3.m; Replaced NCP: train.ncp; Replaced sounds: train.wav, whistle.wav) on my map on location (a1), it moves in one direction, until it reach point (z1). It respawns on point (y1) and move to point (z1) again. From this time, it always move from (y1) to (z1).

I wasn't able to find out, why the object stop moving at point (z1), and I also was not able to find out why it respawns at point (y1).

If I place a second train object at location (a2), it moves to (z2), it respawns at (y2), move to (z2) again, and so on.

The strange thing is: (a1) and (a2) are on different axis. (y1) and (y2) are on the same axis, as well (z1) and (z2).

If I place train objects at (a3), (a4), (a5), (a6), and so on, it always react the exactly same way as described above: Stop at z, respawn at y.

Maybe the y and z axis are hardcoded?

Here a picture for better understanding:

Image
User avatar
Gotolei
Posts: 30
Joined: Mon Dec 04, 2017 9:55 pm
Discord: Gotolei#0819
Location: The New Are

Re: train.m Object

Unread post by Gotolei » Thu Jun 06, 2019 5:32 am

Assuming it's the same as the leaked source that's been floating around, it looks to me like it's handled by this:

Code: Select all

// move train
	CopyVec(&obj->body.Centre.Pos, &obj->body.Centre.OldPos);
	obj->body.Centre.Pos.v[Z] -= TimeStep * 200.0f;
	if (obj->body.Centre.Pos.v[Z] < -11500)
		obj->body.Centre.Pos.v[Z] = -400;
...which leads me to think that it's only looking at the z axis. So in the diagram (y) would be z=-400, and (z) would be z=-11500.
If (a) is 'left of' -400 then it'll move 'to the right' towards it just fine, but when it respawns it just goes directly back to -400 rather than the location of the placed object.

Indeed just a bit of old hardcoding, unfortunately.
Image
User avatar
Kiwi
Posts: 378
Joined: Thu Dec 07, 2017 9:04 pm
Contact:

Re: train.m Object

Unread post by Kiwi » Thu Jun 06, 2019 6:31 am

Thanks for this source code snippet and the describtion. Yes, this make sense.

As a change of this behaviour (replacing "-400" with the initial position of the object) would have bad influence to train objects placed on old tracks, this couldn't be changed in future RVGL releases, I guess.
Post Reply