<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.splashdamage.com/index.php?action=history&amp;feed=atom&amp;title=Moving_Object_Scripting</id>
	<title>Moving Object Scripting - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.splashdamage.com/index.php?action=history&amp;feed=atom&amp;title=Moving_Object_Scripting"/>
	<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Moving_Object_Scripting&amp;action=history"/>
	<updated>2026-04-07T16:44:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=Moving_Object_Scripting&amp;diff=4142&amp;oldid=prev</id>
		<title>192.168.0.151 at 17:13, 11 August 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=Moving_Object_Scripting&amp;diff=4142&amp;oldid=prev"/>
		<updated>2008-08-11T17:13:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;===Moving Object Scripting===&lt;br /&gt;
&lt;br /&gt;
Making a moving object objective requires many interconnected entities and scripting, especially if it needs to be damageable. &lt;br /&gt;
&lt;br /&gt;
===Triggers===&lt;br /&gt;
To allow people to move the object, and see it displayed on the command map, requires a few triggers: a &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_multiple&amp;lt;/span&amp;gt; entity for movement and a &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_objective_info&amp;lt;/span&amp;gt; entity for the command map.&lt;br /&gt;
&lt;br /&gt;
The keys you will need to set on the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_multiple&amp;lt;/span&amp;gt; are:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | targetname:&lt;br /&gt;
| The name used in the script for referencing this entity.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | scriptname:&lt;br /&gt;
|&lt;br /&gt;
The routine name in the script file.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | target:&lt;br /&gt;
| This should be the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;targetname&amp;lt;/span&amp;gt; of the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;target_script_trigger&amp;lt;/span&amp;gt; entity used to control the movement, which will be described later.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
You may also want to set some of the spawnflags , to allow only one team, or one class, the ability to move the object.&lt;br /&gt;
&lt;br /&gt;
The keys you will need to set on the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_objective_info&amp;lt;/span&amp;gt; are:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | targetname:&lt;br /&gt;
| The name used in the script for referencing this entity.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | scriptname:&lt;br /&gt;
|&lt;br /&gt;
The routine name in the script file.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | shortname:&lt;br /&gt;
| The name that will be displayed on the command map.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | track:&lt;br /&gt;
| The name that will display when you are near it.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | target:&lt;br /&gt;
| This should be the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;targetname&amp;lt;/span&amp;gt; of the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;func_constructible&amp;lt;/span&amp;gt; which will be used to handle damaging/repairing the object, and allow it to show on the command map.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
You must set the tank spawnflag for this to show up correctly, and if the object is to be destroyed, the team that owns the object must be chosen from the objective spawnflags.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_multiple&amp;lt;/span&amp;gt; should be a fairly large area around the object, whilst the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt; trigger_objective_info&amp;lt;/span&amp;gt; should just fit around the edges, thus only allowing people to construct it when very close to it.&lt;br /&gt;
&lt;br /&gt;
===Building, Destroying and the Object Itself===&lt;br /&gt;
The object itself is made from a &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;script_mover&amp;lt;/span&amp;gt; entity. This is best made out of clip brushes, with a &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;model2&amp;lt;/span&amp;gt; key supplied to use an external md3 model.&lt;br /&gt;
&lt;br /&gt;
The keys you will likely want to use for this are:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | targetname:&lt;br /&gt;
| The name used in the script for referencing this entity.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | scriptname:&lt;br /&gt;
|&lt;br /&gt;
The routine name in the script file.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | health:&lt;br /&gt;
| The amount of damage the object can take.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | model2:&lt;br /&gt;
| The path to an md3 that will be used to display the object.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | description:&lt;br /&gt;
| The name that will show up when you hover your cursor over it.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | tagent:&lt;br /&gt;
| (as in tag-ent) If using a gun, the targetname of the entity to which it will be attached. (Note: this can be the same entity)&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | gun:&lt;br /&gt;
| The type of gun. Default is mg42, other value is; browning.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
There are various spawnflags which should be set, and some which must be set. You must have the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;resurrectable&amp;lt;/span&amp;gt; flag set and in most cases you will want solid to be set as well. If the object is to be damageable, the appropriate team button should be selected for who owns the object. The compass flag should be set if the object is to show on the compass. If the object is only to be destructible using explosive weapons, the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;explosivedamageonly&amp;lt;/span&amp;gt; flag must be set. Last of all, if you want to attach a gun to the object, the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;mounted_gun&amp;lt;/span&amp;gt; flag must be set.&lt;br /&gt;
&lt;br /&gt;
For damage and repair of the object to work, you must have a &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;func_constructible&amp;lt;/span&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
The keys you will need for this entity are:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | targetname:&lt;br /&gt;
| The name used in the script for referencing this entity.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | scriptname:&lt;br /&gt;
|&lt;br /&gt;
The routine name in the script file.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;start_built&amp;lt;/span&amp;gt; flag should be set if the object is to be 'alive' at the beginning of the map. The appropriate team should again be chosen for the team that is to own the object.&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous Entities==&lt;br /&gt;
&lt;br /&gt;
You will also need a handful of other point entities which I will now detail.&lt;br /&gt;
&lt;br /&gt;
2 &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;target_script_trigger&amp;lt;/span&amp;gt; entities&amp;lt;br /&amp;gt; 1 &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;func_timer&amp;lt;/span&amp;gt; entity&amp;lt;br /&amp;gt; 1 &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;target_kill&amp;lt;/span&amp;gt; entity&lt;br /&gt;
&lt;br /&gt;
The target_script_trigger entities require the following keys :&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | targetname:&lt;br /&gt;
| The name used in the script for referencing this entity.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | scriptname:&lt;br /&gt;
|&lt;br /&gt;
The routine name in the script file.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | target:&lt;br /&gt;
| The name of the trigger event to fire within the routine. (Note: generally this was called 'run')&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
One of these will be known as the disabler, the other is the enabler (This is the one pointed to by the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_multiple&amp;lt;/span&amp;gt; entity)&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;func_timer&amp;lt;/span&amp;gt; entity requires the following keys:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | target:&lt;br /&gt;
| This should point at the other target_script_trigger entity. (Disabler)&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | wait:&lt;br /&gt;
| &amp;quot;1&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It should also have the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;start_on&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;spawnflag&amp;lt;/span&amp;gt; set.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;target_kill&amp;lt;/span&amp;gt; entity requires the following keys:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | targetname:&lt;br /&gt;
| The name used in the script for referencing this entity.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | scriptname:&lt;br /&gt;
| The routine name in the script file.&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;code&amp;quot; valign=&amp;quot;top&amp;quot; | target:&lt;br /&gt;
| This should point at the func_constructible entity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Scripting===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:tankstuff.jpg]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The control of the object via scripting may look complex at first, but it is in fact quite simple. The examples below are taken from the 'Fueldump' script if you wish to take a look over the whole script.&lt;br /&gt;
&lt;br /&gt;
First off, you have the two script trigger routines, which tell the tank whether there is someone in the trigger or not.&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tank_disabler&lt;br /&gt;
{&lt;br /&gt;
    trigger run&lt;br /&gt;
    {&lt;br /&gt;
        trigger tank tank_disable&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
tank_enabler&lt;br /&gt;
{&lt;br /&gt;
    trigger run&lt;br /&gt;
    {&lt;br /&gt;
        trigger tank tank_enable&lt;br /&gt;
    }&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 'tank_enabler' routine will call the trigger run function while there are players standing within the trigger, and the 'tank_disabler' will call its trigger run function every time the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;func_timer&amp;lt;/span&amp;gt; activates, i.e. once per second. These two functions just keep the tank object informed about players being in the trigger or not, and it will make decisions based on this information.&lt;br /&gt;
&lt;br /&gt;
Now we'll take a look at what the tank does with this information.&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trigger tank_enable&lt;br /&gt;
{&lt;br /&gt;
    trigger self stuck_check&lt;br /&gt;
    accum 1 abort_if_bitset 3 // stuck check&lt;br /&gt;
&lt;br /&gt;
    accum 4 set 0 // reset stop counter&lt;br /&gt;
    accum 1 bitreset 8 // reset stop check&lt;br /&gt;
    accum 1 abort_if_bitset 2 // already following spline&lt;br /&gt;
    accum 5 abort_if_not_equal 0// are we not in a script lockout?&lt;br /&gt;
    accum 1 abort_if_bitset 7 // death check&lt;br /&gt;
&lt;br /&gt;
    // Any just started moving stuff goes here&lt;br /&gt;
&lt;br /&gt;
    trigger self script_lockout&lt;br /&gt;
    trigger tank_sound start&lt;br /&gt;
&lt;br /&gt;
    startanimation 55 10 15 nolerp norandom&lt;br /&gt;
    wait 666&lt;br /&gt;
    startanimation 5 40 15 nolerp norandom&lt;br /&gt;
    wait 500&lt;br /&gt;
    trigger self tracks_forward&lt;br /&gt;
    trigger self script_lockout_stop&lt;br /&gt;
    trigger self move&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
First off, it calls the trigger 'stuck_check' function (which will be explained later), which will set bit 3 of &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1&amp;lt;/span&amp;gt; if the object is stuck. If it is stuck, it aborts, as movement is not possible.&lt;br /&gt;
&lt;br /&gt;
Next, it resets the counter (&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 4&amp;lt;/span&amp;gt;) which would stop the vehicle from moving if there was no-one there, and resets the counter that says we shouldn't be moving any more (&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 8&amp;lt;/span&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
Next it aborts if we were already following a path, as you don't want the startup stuff to happen if already moving.&lt;br /&gt;
&lt;br /&gt;
Next, it will abort if a script_lockout (&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 5&amp;lt;/span&amp;gt;, more information later) is in place, or if the tank has been damaged (&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 7&amp;lt;/span&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
If it passes all of these checks, then the tank has just started moving, and so it calls all the sound startup and animation startup functions. As it has some waits to have the animation work properly, a &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;script_lockout&amp;lt;/span&amp;gt; is put in place so that nothing can interrupt this sequence. After the startup is complete, it then calls the 'trigger move' function, to commence movement along a path.&lt;br /&gt;
&lt;br /&gt;
The disabler routine below is fairly simple.&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trigger tank_disable&lt;br /&gt;
{&lt;br /&gt;
    accum 4 inc 1 // up the stop counter&lt;br /&gt;
    accum 4 abort_if_less_than 4&lt;br /&gt;
&lt;br /&gt;
    accum 1 bitset 8 // set stop check&lt;br /&gt;
&lt;br /&gt;
    trigger self deathcheck&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Every time this is called (once per second), &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 4&amp;lt;/span&amp;gt; is incremented. If the value of &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 4&amp;lt;/span&amp;gt; is below 4, then the function does nothing more. &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;Accum 4&amp;lt;/span&amp;gt; will be reset by the enabler function as long as the tank is not stuck, and someone is in the trigger. If the tank is stuck, or no-one is in the trigger, then the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum&amp;lt;/span&amp;gt; will be allowed to continue incrementing, up to the value of 4 and beyond. Once it reaches this stage, the rest of the function will be allowed to execute, and the stopped moving flag (&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 8&amp;lt;/span&amp;gt; ) will be set. This also then calls the 'trigger deathcheck' function, to be sure that something is checking whether the tank has been damaged enough to go into its broken state.&lt;br /&gt;
&lt;br /&gt;
Outlined below are some more of the tank's main functions.&lt;br /&gt;
&lt;br /&gt;
===Movement Loop===&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trigger move_check&lt;br /&gt;
{&lt;br /&gt;
    trigger self stuck_check&lt;br /&gt;
    accum 1 abort_if_bitset 3&lt;br /&gt;
&lt;br /&gt;
    trigger self dispatch&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger move&lt;br /&gt;
{&lt;br /&gt;
    trigger self move_check&lt;br /&gt;
    wait 500&lt;br /&gt;
    trigger self move&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger dispatch&lt;br /&gt;
{&lt;br /&gt;
    accum 3 trigger_if_equal 0 tank run_0&lt;br /&gt;
    ...&lt;br /&gt;
    accum 3 trigger_if_equal 133 tank run_133&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 'trigger move' function will be called from the 'tank_enabler' event upon startup, and never again, unless it shuts down, and then starts up again, or is continuing movement from a previous call. The 'trigger move' function calls the 'trigger move_check' function which will see if the tank is stuck, and if not, then call the 'trigger dispatch' function which will in turn select the appropriate 'run_XXX' function to move from its current position. If the 'trigger move_check' function fails because the tank is stuck, then execution will return to the 'trigger move' function. The function will wait 500ms and then call itself again.&lt;br /&gt;
&lt;br /&gt;
===Run Events===&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trigger run_0&lt;br /&gt;
{&lt;br /&gt;
    accum 1 bitset 2&lt;br /&gt;
    trigger tank_turret2 run_0&lt;br /&gt;
    followspline 0 spln0 80 wait length -64&lt;br /&gt;
    accum 1 bitreset 2&lt;br /&gt;
&lt;br /&gt;
    trigger self run_continue&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Above is one of the tank's 'trigger run' functions. This first sets the moving status to in (&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 2&amp;lt;/span&amp;gt; ), then issues the command for the turret to move (as it isn't attached using a tag in this case), and then issue its own move command. After this has completed, it sets the move status to off again, then calls the 'trigger run_continue' function.&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trigger run_incpos&lt;br /&gt;
{&lt;br /&gt;
    accum 3 inc 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger run_continue&lt;br /&gt;
{&lt;br /&gt;
    trigger self run_incpos&lt;br /&gt;
    trigger self deathcheck&lt;br /&gt;
    trigger self stopcheck&lt;br /&gt;
    trigger self move&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 'trigger run_continue' function increases the position counter for the tank, checks it hasn't been damaged, if it hasn't, then checks it hasn't stopped because no one is escorting it, and then if there are escorts, trigger the move function, to continue movement.&lt;br /&gt;
&lt;br /&gt;
===Stuck Checking===&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trigger stuck_check&lt;br /&gt;
{&lt;br /&gt;
    accum 1 bitreset 3&lt;br /&gt;
&lt;br /&gt;
    trigger self stuck_check_bridge_built&lt;br /&gt;
    trigger self stuck_check_bridge_dyna&lt;br /&gt;
    trigger self stuck_check_scriptlockout&lt;br /&gt;
    trigger self stuck_check_finished&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger stuck_check_finished&lt;br /&gt;
{&lt;br /&gt;
    accum 3 abort_if_less_than 134&lt;br /&gt;
    accum 1 bitset 3&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger stuck_check_scriptlockout&lt;br /&gt;
{&lt;br /&gt;
    accum 5 abort_if_equal 0&lt;br /&gt;
    accum 1 bitset 3&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
These functions, plus several more not outlined here, form a set of functions that check whether the tank can move or not.&lt;br /&gt;
&lt;br /&gt;
The 'trigger stuck_check' function first resets &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 3&amp;lt;/span&amp;gt; , which it uses as an indicator to say whether or not the tank is in fact stuck. Since we are resetting it every time, we are assuming that the tank is not stuck unless we are told otherwise, which is the easiest way to handle things. Next, it calls the functions for each individual reason for being stuck, such as the bridge not being built, or it having finished its entire run across the map.&lt;br /&gt;
&lt;br /&gt;
These extra functions simply check to make sure they are valid, usually by checking the position indicator, and any other data they may need to know about. If those checks don't fail, then they set &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 3&amp;lt;/span&amp;gt;, as an indicator that the tank is in fact stuck. Now, no matter what any of the other events do (assuming they don't reset &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 3&amp;lt;/span&amp;gt;, which they shouldn't ever do), the flag will remain set when the 'trigger stuck_check' function exits. Other functions can use this to check whether the tank is stuck by simply calling the 'trigger stuck_check' function, then checking the value of &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 3&amp;lt;/span&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
===Stop Checking===&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trigger stopcheck_setup&lt;br /&gt;
{&lt;br /&gt;
    accum 1 bitset 6&lt;br /&gt;
    accum 1 abort_if_bitset 8&lt;br /&gt;
    trigger self stuck_check&lt;br /&gt;
    accum 1 abort_if_bitset 3&lt;br /&gt;
    accum 1 bitreset 6&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger stopcheck&lt;br /&gt;
{&lt;br /&gt;
    trigger self stopcheck_setup&lt;br /&gt;
    accum 1 abort_if_not_bitset 6&lt;br /&gt;
    trigger self script_lockout&lt;br /&gt;
&lt;br /&gt;
    // Any just stopped moving stuff goes here&lt;br /&gt;
    trigger tank_sound stop&lt;br /&gt;
    trigger self tracks_stop&lt;br /&gt;
    startanimation 45 10 15 nolerp norandom&lt;br /&gt;
    wait 666&lt;br /&gt;
    startanimation 0 1 15 nolerp norandom&lt;br /&gt;
    wait 900&lt;br /&gt;
&lt;br /&gt;
    trigger self script_lockout_stop&lt;br /&gt;
    resetscript&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
These two functions, in combination, check whether the tank should stop its movement, as either it's stuck, or no-one is escorting it.&lt;br /&gt;
&lt;br /&gt;
The 'trigger stopcheck_stuck' function does the initial checks to see whether either of those conditions are met, and stores the result as &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 6&amp;lt;/span&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
The 'trigger stopcheck' function will then check that value, and act accordingly, either shutting the tank down, or aborting. As before, since the shutdown animation requires some waits, the shutdown enforces a script lockout during that period to prevent anything from interfering.&lt;br /&gt;
&lt;br /&gt;
===Script Lockouts===&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
trigger script_lockout&lt;br /&gt;
{&lt;br /&gt;
    accum 5 inc 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger script_lockout_stop&lt;br /&gt;
{&lt;br /&gt;
    accum 5 inc -1&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The script lockout system acts as a reference counter, that is, it keeps track of how many times it has been told to lock itself using &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 5&amp;lt;/span&amp;gt;. This allows various parts of the script to check whether it is locked, by checking that &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 5&amp;lt;/span&amp;gt; is not 0. As this isn't just a flag, it can be used by multiple parts of the script at once, from multiple procedures, as long as they make sure to unlock the tank when they are finished. This was used for the firing sequences and some other things.&lt;br /&gt;
&lt;br /&gt;
===Death and Resurrection===&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
death&lt;br /&gt;
{&lt;br /&gt;
    accum 1 bitset 7&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
trigger deathcheck&lt;br /&gt;
{&lt;br /&gt;
    accum 1 abort_if_not_bitset 7&lt;br /&gt;
    accum 1 abort_if_bitset 9&lt;br /&gt;
    accum 1 abort_if_bitset 2&lt;br /&gt;
    accum 5 abort_if_not_equal 0&lt;br /&gt;
&lt;br /&gt;
    accum 1 bitset 9&lt;br /&gt;
&lt;br /&gt;
    changemodel models/mapobjects/tanks_sd/churchhill_broken.md3&lt;br /&gt;
    setstate tank_smoke default&lt;br /&gt;
&lt;br /&gt;
    alertentity kill_tank&lt;br /&gt;
&lt;br /&gt;
    trigger self sound_death&lt;br /&gt;
    trigger self tracks_stop&lt;br /&gt;
    trigger self script_lockout&lt;br /&gt;
    trigger self tracks_stop&lt;br /&gt;
    startanimation 45 10 15 nolerp norandom&lt;br /&gt;
    wait 666&lt;br /&gt;
    startanimation 0 1 15 nolerp norandom&lt;br /&gt;
    trigger self script_lockout_stop&lt;br /&gt;
    resetscript&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 'trigger death' function simply sets &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;accum 1 bit 7&amp;lt;/span&amp;gt; to on, as a flag for the 'trigger deathcheck' function, so that it knows that the tank's health has reached 0.&lt;br /&gt;
&lt;br /&gt;
The 'trigger deathcheck' function does a few checks at the beginning before changing the model, and playing the shutdown sequence. These checks are: making sure the health has hit 0, the tank hasn't already been made to look broken, the tank isn't moving, and the tank isn't in a script lockout. As before, it initiates a script lockout during the shutdown process.&lt;br /&gt;
&lt;br /&gt;
This also fires the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;target_kill&amp;lt;/span&amp;gt; entity, which is used to damage the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;func_constructible&amp;lt;/span&amp;gt; entity, making the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_objective_info&amp;lt;/span&amp;gt; entity become active, and so, allowing people to rebuild the constructible, which in turn, will activate the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;script_mover&amp;lt;/span&amp;gt; entity which will call the 'rebirth' function below.&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rebirth&lt;br /&gt;
{&lt;br /&gt;
    accum 1 bitreset 9&lt;br /&gt;
    accum 1 bitreset 7&lt;br /&gt;
&lt;br /&gt;
    trigger self script_lockout&lt;br /&gt;
    changemodel models/mapobjects/tanks_sd/churchhill.md3&lt;br /&gt;
&lt;br /&gt;
    setstate tank_smoke invisible&lt;br /&gt;
&lt;br /&gt;
    trigger tank_sound rebirth&lt;br /&gt;
    wait 500&lt;br /&gt;
&lt;br /&gt;
    trigger self script_lockout_stop&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This function simply makes the tank look repaired, setting the appropriate flags, and starts the low engine hum up again.&lt;br /&gt;
&lt;br /&gt;
===The Other Entities===&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tank_trigger&lt;br /&gt;
{&lt;br /&gt;
    spawn&lt;br /&gt;
    {&lt;br /&gt;
        wait 100&lt;br /&gt;
        attachtotag tank tag_turret&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_multiple&amp;lt;/span&amp;gt; entity routine which is used to move the tank. When it spawns, it attaches its origin to a tag positioned at the turret origin on the tank. This allows the trigger to follow the tank around, without having to script its movement independently.&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tank_build&lt;br /&gt;
{&lt;br /&gt;
    spawn&lt;br /&gt;
    {&lt;br /&gt;
        wait 100&lt;br /&gt;
        attachtotag tank tag_turret&lt;br /&gt;
    }&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_objective_info&amp;lt;/span&amp;gt; entity routine, which is used for the repair of the tank. As with the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;trigger_multiple&amp;lt;/span&amp;gt; entity it attaches itself to the tank, for easy movement.&lt;br /&gt;
&lt;br /&gt;
{| id=&amp;quot;Table1&amp;quot; width=&amp;quot;90%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
| class=&amp;quot;codeblock&amp;quot; | &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tank_construct&lt;br /&gt;
{&lt;br /&gt;
    spawn&lt;br /&gt;
    {&lt;br /&gt;
        wait 400&lt;br /&gt;
        constructible_class 2&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    built final&lt;br /&gt;
    {&lt;br /&gt;
        alertentity tank&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    trigger final_pos&lt;br /&gt;
    {&lt;br /&gt;
        constructible_constructxpbonus 3&lt;br /&gt;
        constructible_destructxpbonus 3&lt;br /&gt;
    }&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is the &amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;func_constructible&amp;lt;/span&amp;gt; entity associated with the tank. First, it sets its construction class, which is required for the command map marker to show correctly. When the construction finishes, it activates the tank, which will call its 'rebirth' function, and fill its health up again.&lt;br /&gt;
&lt;br /&gt;
When the tank reaches its final position, the 'trigger final_pos' function is called, which changes the amount of XP you get for repairing the tank.&lt;br /&gt;
&lt;br /&gt;
[[Category:WET Documentation]]&lt;/div&gt;</summary>
		<author><name>192.168.0.151</name></author>
		
	</entry>
</feed>