A couple of truck questions


(Daemonicus) #1

Hey,

A little over a week ago i got into mapping again. I tried earlier over a year ago but gave up on it.
So now i am making a map with a truck in it. I tried to create the script from near scratch because i think copy pasting isnt as contributive to my knowledge. So worked on it with the script from this tutorial http://www.pythononline.co.uk/et/tutorial38.htm on the side and i got pretty far, the truck is driving, making sound and the wheels are rotating.
The only problem is that the trigger that triggers the truck is following my truck and just stays at the same position.
furthermore i cant yet figure out how to implement a bridge which has to be constructed before the truck can cross it.

here’s the script, it’s probably not the most efficient but yea…


truck
{
//accum 0:
//  - bit 0: is truck moving
//  - bit 1: is truck active
//  - bit 2: is player present
//accum 1: track position

	spawn
	{
		wait 400
		followspline 0 spl_00 50000 length 32 wait
		followspline 1 spl_00 50000 length 32 wait
		accum 1 set 0
	}

	trigger dispatch
	{
		accum 1 trigger_if_equal 0 truck run_0
		accum 1 trigger_if_equal 1 truck run_1
		accum 1 trigger_if_equal 2 truck run_2
		accum 1 trigger_if_equal 3 truck run_3
	}

	trigger run_0
	{
		accum 0 bitset 0
		followspline 0 spl_00 100 wait length 304
		accum 0 bitreset 0
		trigger self run_continue
	}

	trigger run_1
	{
		accum 0 bitset 0
		followspline 0 spl_01 100 wait length 304
		accum 0 bitreset 0
		trigger self run_continue
	}

	trigger run_2
	{
		accum 0 bitset 0
		followspline 0 spl_02 100 wait length 304
		accum 0 bitreset 0
		trigger self run_continue
	}

	trigger run_3
	{
		accum 0 bitset 0
		followspline 0 spl_03 100 wait length 304
		accum 0 bitreset 0
		trigger self run_continue
	}

	trigger run_continue
	{
		accum 1 inc 1
		trigger self truck_checks
		accum 0 abort_if_bitset 2
		trigger self truck_stop
	}

	trigger truck_enable
	{
		accum 0 bitset 2
		trigger self truck_checks
	}
	
	trigger truck_disable
	{
		accum 0 bitreset 2	
	}

	trigger truck_checks
	{
		accum 1 trigger_if_equal 4 truck truck_stop
		accum 1 abort_if_equal 4
		accum 0 abort_if_not_bitset 2
		accum 0 abort_if_bitset 0
		trigger self truck_start
		trigger self dispatch
	}

	trigger truck_start
	{
		accum 0 abort_if_bitset 1
		accum 0 bitset 1
		trigger truck_sound start
		trigger truck_whl_b wheels_forward
		trigger truck_whl_f wheels_forward
	}

	trigger truck_stop
	{
		accum 0 bitreset 1
		trigger truck_sound stop
		trigger truck_whl_b wheels_stop
		trigger truck_whl_f wheels_stop
	}

	trigger sound_idle
	{
		stopsound
		playsound sound/vehicles/truck/truck_idle.wav looping volume 512
	}

	trigger sound_start
	{
		stopsound
		playsound sound/vehicles/truck/truck_revup.wav volume 256
	}

	trigger sound_move
	{
		stopsound
		playsound sound/vehicles/truck/truck_move.wav looping volume 512
	}

	trigger sound_stop
	{
		stopsound
		playsound sound/vehicles/truck/truck_revdown.wav volume 256
	}
}

truck_trigger
{
	spawn
	{
		wait 300
	}
}

truck_enabler
{
	spawn
	{
		wait 300
	}
	
	trigger run
	{
		trigger truck truck_enable
	}
}

truck_disabler
{
	spawn
	{
		wait 300
	}

	trigger run
	{
		trigger truck truck_disable
	}
}

truck_sound
{
	spawn
	{
		wait 300
		trigger truck sound_idle
	}

	trigger start
	{
		trigger truck sound_start
		wait 500
		trigger truck sound_move
	}

	trigger stop
	{
		trigger truck sound_stop
		wait 500
		trigger truck sound_idle
	}
}

truck_whl_b
{
	spawn
	{
		wait 400
		attachtotag truck tag_wback
	}

	trigger wheels_forward
	{
		setrotation 150 0 0
	}

	trigger wheels_stop
	{
		setrotation 0 0 0
	}
}

truck_whl_f
{
	spawn
	{
		wait 400
		attachtotag truck tag_wfront
	}

	trigger wheels_forward
	{
		setrotation 150 0 0
	}

	trigger wheels_stop
	{
		setrotation 0 0 0
	}
}

Thanks in advance,
Daemonicus


(-SSF-Sage) #2

I assume you are using the sd blitz model or have the following tag in your model. You need to attach the trigger to the truck:

truck_trigger
{
	spawn
	{
		wait 500

		attachtotag truck tag_wback  //here
	}
}

Also for the barrier: I didn’t care to read your script with a lot of thinking. You are missing various triggers, such as move and many checks. For particulary bridge and those: have a look at trigger stuck_check and where it is triggered from. (From goldrush.script)


(Daemonicus) #3

I cant just use tag_wback for the trigger can I?
and for the bridge i’d thought i just set a globalaccum to 1 when its constucted and to 0 when damaged and somewhere in de truck part scripts he checks for that, i just dont know where and how exactly.
Oh btw, i have the goldrush.map but i can’t seem to find goldrush.script


(TomTom7777) #4

“i have the goldrush.map but i can’t seem to find goldrush.script”
try looking in etmain/pak0.pk3, pak1.pk3 or pak2.pk3 under /maps (pak2.pk3 maps/goldrush.script being the newer one)


(shagileo) #5

Well I once opened a threat about certain common Tank stuff : http://www.splashdamage.com/forums/showthread.php?t=16553

To make things easy, open your search (ctrl + F) and copy paste the following : I wanted to create 2 tank barriers

So you’ll move directly to the point/issue. I don’t know if it can help you out, but you never know


(Daemonicus) #6

Ok thx mate i think i got the bridge figured out now but i still don’t know how to attach that trigger to my truck. Anybody knows how to do that?

EDIT: I think I kinda understand the attachtotag thing now, I thought it worked completely different, but when i attach my trigger entity to the tag_wback i cant find it anywhere when i run my map and but when i attach a gamemodel to it it does show up only with its origin at the tag and not where i might want it. Ideas anyone?


(-SSF-Sage) #7

The trigger with that command should be attached to a tag called tag_wback, which should be found from entity with a scriptname/targetname truck.

tag_wback is the same tag you attach back wheels too. If you have a custom truck, you better add some tags. I checked you have back wheels attached to the very same tag. In case your wheels are attached properly (which I understood is happening), the trigger should be attached properly too. When the truck is moving, the trigger is supposed to move along with the truck.

Oh yeah and check that your trigger has an origin brush too. :slight_smile:

attachtotag truck tag_wback  //attach to tag "tag_wback" that is found from "truck" entity

(Daemonicus) #8

Ok, i’ve now did the attachtotag for the trigger_multiple and an additional toi, both with an origin brush.
When i run my map now it says you’re near the truck both at the place where the truck is driving ingame and where i put the toi in radiant. And the trigger_multiple trigger_multiple is still nowhere to be found =/