Help! Scripting for a truck


(TFate) #1

Here begins perhaps the greatest mapping feat I have ever pulled onto myself – a truck. Unfortunately due to a drastic lack (or non-existence) of tutorials based around scripting for vehicles, I have to look at goldrush’s truck and script. Well, so far I have a script_mover (the truck and clippings, or in my case, a big rectangular block temporarily depicting the truck), the trigger_objective_info, the trigger_multiple, a couple of nice little target_script_triggers, and a func_timer (I will not be using gold crates yet, so I deemed the flagonly unnecessary, I hope I’m right).

So far I only have 3 splines, tspln_0, tspln_1, and tspln_2. My script looks like this.

game_manager
{
	spawn
	{
		
		wm_axis_respawntime	15
		wm_allied_respawntime	15
		wm_set_round_timelimit	30

		wm_set_defending_team	0

		wait 200

		enablespeaker desert_sound

		setautospawn "Axis Bank" 0
		setautospawn "Allied Bunker" 1
	}
}

truck_build
{
	spawn
	{
	}
}

truck_construct
{
	spawn
	{
		constructible_class 2
		constructible_health 1050
		constructible_constructxpbonus 10
		constructible_destructxpbonus 10
	}

	built final
	{
		alertentity truck
		
		wm_announce "The Allies have repaired the truck!"
	}
}

//Let's take a quick break to see what the accums are
//accum 0: Is the truck moving? 	0: no	1: yes
//accum 1: Current position
//accum 2: Dead?	0: no, we're moving, 1: yes, but we just stopped, 2: yes, but we know
//accum 3: blank
//
//Okay then!
//I guess we're ready.

truck
{
	spawn
	{
		faceangles 0 360 0 50

		accum 1 set 0
		accum 2 set 0
		accum 0 set 0
	}

	trigger run_continue
	{
		trigger truck deathcheck
	}

	trigger run_1
	{
		accum 0 set 1
		followspline 0 tspln_0 125 wait length 100
		accum 0 set 0

		accum 1 set 1

		trigger truck run_continue
	}

	trigger run_2
	{
		accum 0 set 1
		followspline 0 tspln_1 125 wait length 100
		accum 0 set 0

		accum 1 set 2

		trigger truck run_continue
	}

	trigger run_3
	{
		accum 0 set 1
		followspline 0 tspln_2 125 wait length 100
		accum 0 set 0

		accum 1 set 3
	}

	death
	{
		accum 2 set 1
	}

	trigger deathcheck
	{
		accum 2 abort_if_equal 0

		accum 2 set 2

		wm_announce "Axis have damaged the truck!"

		wm_teamvoiceannounce 0 "axis_hq_truck_damaged"

		wm_teamvoiceannounce 1 "allies_hq_truck_damaged_axis"

		kill truck_construct

		resetscript
	}

	trigger truck_enable
	{
		trigger truck move
	}

	trigger truck_disable
	{
		trigger truck deathcheck
	}

	rebirth
	{
		accum 2 set 0

		wm_teamvoiceannounce 0 "axis_hq_truck_repaired_allies"

		wm_teamvoiceannounce 1 "allies_hq_truck_repaired"

		trigger truck move
	}

	trigger move
	{
		trigger truck move_check

		wait 500

		trigger truck move
	}

	trigger move_check
	{
		accum 1 abort_if_equal 4 //hmm, looks like the move inspectors are slacking		

		accum 0 set 1

		trigger truck dispatch
	}

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

}

truck_disabler
{
	trigger run
	{
		trigger truck truck_disable
	}
}

truck_enabler
{
	trigger run
	{
		trigger truck truck_enable
	}
}

However when I fire up my map in ET I get the error, “G_Scripting: truck_disable must have a name and an identifier.” I did a search on this which led to one particular topic which suggested fixing a certain error in the script. I don’t have this error, AFAIK. I have no idea what’s going on… can someone tell me if they see something wrong with the script? PROBLEM SOLVED

Once I’m done all this I am definitely writing a tutorial for making vehicles!!

EDIT: I’ve updated the script.


(Mean Mr. Mustard) #2

It’s: ‘trigger truck truck_disable’


(TFate) #3

Fixed! So far my credits list has one person. Thanks. :slight_smile:

Next problem: trigger_objective_info has missing target: truck_construct.

What is a truck_construct? I did not find one in goldrush.


(Mean Mr. Mustard) #4

There is one in goldrush. It’s a function_constructible (first function_constructible in the goldrush entity list)-- it’s what makes the truck repairable/damageable.


(TFate) #5

Ok, I got the func_constructible down. I changed the big rectangular brush into a proper truck and added clipping, etc. Now my only problem is that when an Allied player goes near the truck, it does not move. I think it’s the splines or the spline scripting.

EDIT: The good news is that the truck is destructible and constructible


(Mean Mr. Mustard) #6

That is a good start…The reason your truck is not moving is because your script is not telling it to :wink:

When an allied player moves into the trigger, it calls truck_enabler run. This calls truck move. But your truck move just waits, then calls itself. So ‘nothing’ happens.

Here’s a code fragment from my script. (BTW, you can grab the .map file for v2_factory from pcgamemods.com if you want a 2nd truck map to dissect). You can see that my truck move first calls truck move_check – which performs a bunch of “are we stuck and shouldn’t move?” checks and finally it calls truck dispatch. This is the ‘important’ routine which controls which spline path (truck run_x) is called.

trigger move
	{
		trigger self move_check
		wait 500
		trigger self move
	}

	trigger move_check
	{
		trigger self stuck_check		// truck stuck?
		accum 0 abort_if_bitset 4
		trigger self stopcheck			// truck stopped?
		trigger self deathcheck			// truck dead?
		accum 0 abort_if_bitset 6
		
		accum 0 abort_if_bitset 0
		
		accum 2 set 0
		trigger self dispatch			// run to next spline point
	}

	trigger dispatch
	{
		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
		accum 1 trigger_if_equal 4	truck run_4
		accum 1 trigger_if_equal 5	truck run_5
		accum 1 trigger_if_equal 6	truck run_6
		accum 1 trigger_if_equal 7	truck run_7
		accum 1 trigger_if_equal 8	truck run_8
		accum 1 trigger_if_equal 9	truck run_9

(TFate) #7

Ah okay, I see. BTW, Ifurita already pointed me in the direction of the v2_factory .map file at PCGamemods, so I took a look at that.

Next problem, my func_constructible has just turned into an ordinary contructible brush. Also, my trigger brushes do not move with the truck.