Trains


(Xterm1n8or) #1

Hello,

How do i go about linking carriages to a train?

I’ve got a script mover and a trigger and target script trigger, which makes the engine go round the track. (i’m going by moving platform tut at nibsworld).

How do i get carriages to follow the train, so that each carriage turns as it should?

In case it helps, here is my basic script:

game_manager
{
spawn
{
// Game rules
wm_axis_respawntime 1
wm_allied_respawntime 1
wm_set_round_timelimit 30

}

}

// Scriptname of target_script_trigger entity
train_controls
{
// Target name of target_script_trigger
trigger train_start
{
// Calls go trigger within track function block
trigger track go
}

// Target name of target_script_trigger 

// trigger train_stop
// {
// Calls stop trigger within track function block
// trigger track stop
// }
}

// Function block. Scriptname used on script_mover brush
track
{
// Called by train_controls trigger train_start.
trigger go
{
// move the script_mover defined by scriptname “track”
followspline globalaccum 0 spln_00 200 wait length -224
followspline globalaccum 0 spln_01 400 wait length -224
followspline globalaccum 0 spln_02 600 wait length -224
followspline globalaccum 0 spln_03 800 wait length -224
followspline globalaccum 0 spln_04 1000 wait length -224
followspline globalaccum 0 spln_05 1000 wait length -224
followspline globalaccum 0 spln_06 1000 wait length -224
followspline globalaccum 0 spln_07 1000 wait length -224
followspline globalaccum 0 spln_08 1000 wait length -224
followspline globalaccum 0 spln_09 1000 wait length -224
followspline globalaccum 0 spln_10 1000 wait length -224
followspline globalaccum 0 spln_11 800 wait length -224
followspline globalaccum 0 spln_12 600 wait length -224
followspline globalaccum 0 spln_13 400 wait length -224
followspline globalaccum 0 spln_14 200 wait length -224
}

//

// trigger stop
// {
//
// }

}

Many thanks in advance :slight_smile:


(-SSF-Sage) #2

Search for tags (a part of a md3) and attachtotag (a scripting command).


(murka) #3

A better idea is to use attachtotrain, which is used by the garage door in fueldump for example.


(Xterm1n8or) #4

Thanks for the reply.

I guess then i have to turn my brushes and patches (that make up my train engine), into a md3 model.
Also make seperate md3’s for all the different carriages?

Does it HAVE to be a md3 model? I tried making a model a while back and just couldn’t get on with it.
I can turn brushwork into an ase model, with a .map to .ase converter, only this time round the textures are 2 to 3x smaller than it should be.(Possibly because i’m using win 7 this time but havn’t looked into it yet.

There is a modelling tool somewhere that turns .map to .md3, so i’ll have a look at that incase the answer is that i do have to use a model to make this work properly.

Many thanks :slight_smile:


(Qualmi) #5

is your train only driving straight, or is it driving around corners and stuff ? i believe thats some hard scripting work to keep the carriages on track then.

for turning map into md3 you can use c’s modeltool. :stroggtapir:


(Xterm1n8or) #6

Unfortunately it goes round corners. I know i could select all the brushes from the train and turn it into my script_mover, but i really need it to go round bends.

I got my engine going round properly, just need to pull some carriages behind it.

Will look at c’s modeltool too.

Many Thanks :slight_smile:


(Nail) #7

you could check the railgun map, it uses carriages following a tug/train


(-SSF-Sage) #8

It has no worries what so ever with attachtotag. Everything would work just good. You can have the tag as a md3 but you don’t have to do it if you don’t want. An empty md3 with the tags only works just as good.


(Xterm1n8or) #9

Hi,

I’ve had some success. It turns out i can’t convert patches from .map to .md3, so i tried to make brushes (but they’re not as good).
I can however convert the train with patches to .ase, but i have too many vertices.
So, i was thinking of converting the patch bits (wheels, bumpers and railings) to .ase, then converting to md3.
And convert the brush bits straight to md3.
The tank has 3 models, so i think this should work, but havn’t got that far yet.

you could check the railgun map, it uses carriages following a tug/train

This is how i got started. But it’s too confusing for me. For example: I wanted a command map icon, but there are 2 toi’s; 1 with origin texture and another with trigger. They target fakeobj1. This is a func_constructible, but why? You can’t construct it nor damage it. It’s allied constructible, I thought it would have been invulnerable if anything. The scriptname is tank_construct, but i don’t see this anywhere in the script.
Maybe i should start a different thread with this example, but anyway, i found it too complicated.
Was able to get my splines working though.

It has no worries what so ever with attachtotag. Everything would work just good. You can have the tag as a md3 but you don’t have to do it if you don’t want. An empty md3 with the tags only works just as good.

If i understand you correctly, you say i don’t NEED to use models? I’ve tried searching and googling attachtotag/train but, other than the definitions i can’t find anything on HOW to do this. I don’t really know how to go about making an empty model with tags.

I may have used the wrong search terms, any chance you could point me in the right direction. If not, would it be too much trouble to ask someone for an example, maybe just 2 basic blocks joined together with the entity stuff i need?

Many thanks for your help :slight_smile:


(-SSF-Sage) #10

[QUOTE=Xterm1n8or;199332]
If i understand you correctly, you say i don’t NEED to use models? I’ve tried searching and googling attachtotag/train but, other than the definitions i can’t find anything on HOW to do this. I don’t really know how to go about making an empty model with tags.

I may have used the wrong search terms, any chance you could point me in the right direction. If not, would it be too much trouble to ask someone for an example, maybe just 2 basic blocks joined together with the entity stuff i need?

Many thanks for your help :)[/QUOTE]

With this you can create a dummy md3. Make that dummy model move and use attachtotag to attach your actual train, carriages, wheels etc. to it and they will do what ever the dummy model does.

You can use the dummy md3 in a script_mover with model2 key, but do note that you can only use invisible brushes in that script_mover (eg. clips). This is the most painless method if you don’t know how to handle the models.

The dummy/empty model is a md3 that contains only 1 or more tags but nothing else.

An entity will be attached to a tag from origin. So the origin and the tag will be togethor. And the rest of the entity will move with the origin.


(Xterm1n8or) #11

Thanks for the quick reply :slight_smile:

I actually bookmarked that link when i found it after your previous post, but didn’t have a clue what to do.
I’ve just spent a good couple of hours trying to figure it out. Now i have a major headache. Seriously lol.
Anyway, am off tomorrow so will continue then.

Just 1 quick question: Would it make my life alot easier if i continue in my efforts to convert this thing into a md3?
I figure that i will at least be able to see exactly where these tags are.
At the moment it’s way off in the ocean somewhere! Obviosly did that wrong. lol.

I’m using q3 model tool, which i think was et model tool and C’s model tool prior to that.

Anyway, i need to take a paracetamol and go to bed.

Thanks for the help :slight_smile:


(-SSF-Sage) #12

If you have no experience with modelling, then not in any case. You will have to retexture it if you turn it into md3, and trust me it won’t be a small job, especially if you don’t have experience.

Just do it like this: place your train so that the origin is exactly at 0 0 0 in radiant. Then figure out the exact spot(s) where you need the tag(s), pick up the coordinates and put it into that generator (into the tag definitions). Also do note a tag name has to start with tag_

edit. I did not remember C’s tool will handle the texturing automaticly. It is up to you which way you’ll do. If you do convert it into a md3 you will end up with 1 entity less and it will be easier to debug.

If you decide to go this way, you can use q3map2 to convert the patches AND brushes into ase and convert it into a md3 in C’s handly little proggie. And add tags into it.


(Xterm1n8or) #13

Hello again

Spent weekend playing with C’s model tool, and now have md3’s for my train. I have got it going but am still having trouble with the carriage. Here’s what i’ve got:

train_shell.md3
It has 4 tags, tag_wheelf and tag_wheelr (front and rear wheels)
tag_linkf and tag_linkr (front and rear carriage links)

train_wheels2.md3
1 tag at origin, tag_train_wheel2

car1.md3
2 tags, tag_linkf and tag_linkr (front and rear carriage links)

You can use the dummy md3 in a script_mover with model2 key, but do note that you can only use invisible brushes in that script_mover (eg. clips).

I put my models where they should go and made clip weapon metal brushes around them.
I added an origin to center of train, level with the track.

Deleted the train_shell model.
Selected the clips of the train and origin, made them into script_mover.
model2 - models/mapobjects/trains/train_shell.md3
scriptname and targetname - train
spawnflags - solid, compass

train_wheels2.md3 have scriptname/targetname - train_wheelf and the other, train_wheelr

Put an origin center of car1, level with track
Deleted the car1 model
Selected the clips of car1 and origin, made into script_mover.
model2 - models/mapobjects/trains/train_car1.md3
scriptname/targetname - car1
spawnflags - solid, compass

I can’t find a way to attach the trains’ tag_linkr (rear carriage link) to the car1’s tag_linkf (front carriage link)

Here is my script:

game_manager
{
spawn
{
// Game rules
wm_axis_respawntime 1
wm_allied_respawntime 1
wm_set_round_timelimit 30
}
}

train //scriptname of script_mover
{
spawn
{
wait 300
followspline 0 spln_00 000 wait length 224 //spawn the train to here
playsound sound/vehicles/tug/tug_idle.wav looping volume 512
}

trigger train_path
{
	stopsound
	playsound sound/vehicles/tug/tug_move.wav looping volume 512

	followspline 0 spln_00 200 wait length 224
	followspline 0 spln_01 200 wait length 224
	followspline 0 spln_02 200 wait length 224
	followspline 0 spln_03 200 wait length 224
	followspline 0 spln_04 200 wait length 224
	followspline 0 spln_05 200 wait length 224
	followspline 0 spln_06 200 wait length 224
	followspline 0 spln_07 200 wait length 224
	followspline 0 spln_08 200 wait length 224
	followspline 0 spln_09 200 wait length 224
	followspline 0 spln_10 200 wait length 224
	followspline 0 spln_11 200 wait length 224	
	followspline 0 spln_12 200 wait length 224
	followspline 0 spln_13 200 wait length 224
	followspline 0 spln_14 200 wait length 224

	stopsound
	playsound sound/vehicles/tug/tug_idle.wav looping volume 512
}

}

train_wheelf
{
spawn
{
wait 300
attachtotag train tag_wheelf
//this attaches train_wheelf to the scriptmover train
}
}

train_wheelr
{
spawn
{
wait 300
attachtotag train tag_wheelr
//this attaches train_wheelr to the scriptmover train
}
}

car1
{
spawn
{
wait 300
attachtotag train tag_linkr car1 tag_linkf
}
}

// Scriptname of target_script_trigger entity
train_controls
{
// Target name of target_script_trigger
trigger train_start
{
// Calls train_path trigger within train function block
trigger train train_path
}
}

Sorry for long post, tried to give as much info as i could.

Hope you can help.
Many Thanks :slight_smile:

Edit: The train and it’s wheels go round ok, just can’t get a carriage to follow.


(-SSF-Sage) #14

First of all. Only the MAIN model will have tags. Those other stuff are going to be attached to a tag by it’s origin. It’s not a tag-to-tag connection, it’s origin-to-tag. Secondable you cannot “chain” tagging. It’s always once you attach an entity to one tag, it’s going to be there (also regardless of where it is placed in your map file). You will have one entity for each carriage. So this does not work:

attachtotag train tag_linkr car1 tag_linkf

(-SSF-Sage) #15

First of all. Only the MAIN model will have tags. Those other stuff are going to be attached to a tag by it’s origin. It’s not a tag-to-tag connection, it’s origin-to-tag. Secondable you cannot “chain” tagging. It’s always once you attach an entity to one tag, it’s going to be there (also regardless of where it is placed in your map file). You will have one entity for each carriage. So this does not work:

attachtotag train tag_linkr car1 tag_linkf

(Xterm1n8or) #16

Hi and thanks Sage,

Those other stuff are going to be attached to a tag by it’s origin. It’s not a tag-to-tag connection, it’s origin-to-tag.

I think i understand. So, the origin of car1 should be where linkf is (the point at which it attaches to the train)?
I take it were talking about the brush origin (script mover) and not the models’ origin?

Only the MAIN model will have tags.

Does this mean that car1 should not have any tags? If so, how then can i attach car2 to car1 (when i get that far)?

Many thanks :slight_smile:


(Xterm1n8or) #17

hello,

I tried moving the origin brush (script mover) of car1 to to where linkf is, but this didn’t work.
So, i loaded up the md3 in C’s tool and did this:

You can however use any existing tag as a new origin for Your model. You do it this way:

  • Load an MD3
  • Choose the tag You want to use as the new origin (in the lower right of the window; Select it from the ‘Pivot Point’ dropdown listbox)
  • From the main-menu choose: Edit / Tags / Use Pivot-Tag As Origin
  • Save the model.

Car1 now attaches to the train at the right place. When i trigger the train to go, it follows it :slight_smile:

Only thing is, it stays rigid. It doesn’t articulate (bend) at the point where car1 joins to the train.

I’m at a loss as to what to try next. I havn’t changed my script (although i know the car1 bit is wrong), could this be it?

Many thanks


(-SSF-Sage) #18

Oops! I’m really sorry but I made you do a lot of stuff that you would not had to do (well atleast you learned a new thing). But I seemed to overread your problem. I was imaging you wanted something like the gold on the truck. :o:o:o I was totally overreading what you wanted to have. So to make it up for you I’m going to explain what you need to do.

Ok. you have a train. It is md3 and has tags, so you can attach the wheels onto it. It is a script_mover with model2 key. This works like you did above.

Then you have a car1. It is md3 and has tags, so you can attach the wheels onto it. It is a script_mover with model2 key. The origin is aligned with the trains origin. And in script you have

attatchtotrain train x

x is the distance between the origins of car1 and train.

Then you have a car2. It is md3 and has tags, so you can attach the wheels onto it. It is a script_mover with model2 key. The origin is aligned with the trains origin. And in script you have

attatchtotrain car1 x

x is the distance between the origins of car1 and car2.

I’m sorry again. :o So for attatchtotrain, it is origin-distance-origin connection. But those wheels are attached to the trains and cars with attachtotag. That is if you want them rotating ofc. They can be rotated with shader too (truck and tank).

Edit. And and I think you have to replace followspline with followpath.


(Xterm1n8or) #19

Thankyou Sage,

It’s not a problem my friend, like you say, i’ve learned something new :slight_smile:

Just to clarify; my train (engine) only needs tags for the wheels and i can forget about the link tags?
The origin (script mover) is at the same place as the models’ origin (center of train, level with the track)

Car1, same as train.

In my script for car1, i use ‘attachtotrain train x’, x=distance between the trains’ origin and car1s’ origin.
In my script for car2, i use ‘attachtotrain car1 x’, x=distance between car1s’ origin and car2s’ origin.
and so on…

And and I think you have to replace followspline with followpath.

According to the LDR, it would appear so.

Assuming that i have understood correctly, i’ll give it a go and see what happens.

Many many thanks :slight_smile:


(Xterm1n8or) #20

Hi,

attatchtotrain train x

Thought you made a spelling mistake lol. Turns out the game has! ‘attachtotrain’ kept giving me a script error.

Changed my followspline to followpath. But now, the map loading bar gets to the end and then hangs. Only way to get out of it is: Ctrl+Alt+Del and end ET.exe process.

The origin for the train (and that of the model) is 0 on the x axis, the origin of car1 (and that of the model) is at -448 on the x axis.

Here again is my script:

train //scriptname of script_mover
{
spawn
{
wait 300
playsound sound/vehicles/tug/tug_idle.wav looping volume 512
followpath 0 spln_00 000 wait length 224 //spawn the train to here
}

trigger train_path
{
	stopsound
	playsound sound/vehicles/tug/tug_move.wav looping volume 512

	followpath 0 spln_00 200 wait length 224
	followpath 0 spln_01 200 wait length 224
	followpath 0 spln_02 200 wait length 224
	followpath 0 spln_03 200 wait length 224
	followpath 0 spln_04 200 wait length 224
	followpath 0 spln_05 200 wait length 224
	followpath 0 spln_06 200 wait length 224
	followpath 0 spln_07 200 wait length 224
	followpath 0 spln_08 200 wait length 224
	followpath 0 spln_09 200 wait length 224
	followpath 0 spln_10 200 wait length 224
	followpath 0 spln_11 200 wait length 224	
	followpath 0 spln_12 200 wait length 224
	followpath 0 spln_13 200 wait length 224
	followpath 0 spln_14 200 wait length 224

	stopsound
	playsound sound/vehicles/tug/tug_idle.wav looping volume 512
}

}

train_wheelf
{
spawn
{
wait 300
attachtotag train tag_wheelf
//this attaches train_wheelf to the scriptmover train
}
}

train_wheelr
{
spawn
{
wait 300
attachtotag train tag_wheelr
//this attaches train_wheelr to the scriptmover train
}
}

car1
{
spawn
{
wait 300
// attatchtotrain train 448
//this attaches the origin of car1 to the origin of train at a distance of 448
}
}

// Scriptname of target_script_trigger entity
train_controls
{
// Target name of target_script_trigger
trigger train_start
{
// Calls train_path trigger within train function block
trigger train train_path
}
}

I commented out the attatchtotrain command in order to see whether it was this that was causing my map not to load, and it seems that it is was.

I have no idea what length 224 is, there’s no mention in LDR, but it’s in railgun. Without it, my train goes round bends jerkily, whereas its smooth with it. Don’t know if this has anything to do with it, thought i’d mention it anyway.

I tried both -448 and 448, but neither worked.

Hope you can help, thankyou.