Since my map concept (or any other like convoy map) may never see a server let alone a map editor, here is some tutorial scripting for those interested. I have written it up with various forms for the compare trigger-blocks. Not shown are the typical other scripts for other movements, and the acum buffers used don’t match the typical values copied from the original maps (i.e. accum 3 is most often used as the position counter in many existing maps)
Mentioned but not shown is the trigger call to vehicle_ahead_clear from the movement of the vehicle ahead. Also the movement of the vehicle ahead needs to inc accum_2 to keep accum_2 in sync with truck_1’s position, so the same trigger-block can do that (or can be split into 2 trigger-blocks).
// SAMPLE W:ET MAP CODE
// To compare accum 1 to the moving limit in accum 2.
// Assumption is accum 2 normally only increases
// Use accum 3 bits for result flags
// bit 0 == 1 then repaired, ==0 then damaged
// bit 1 == 1 then stop , ==0 can go
// bit 2 == 1 then collision, ==0 normal
// bit 3 etc ... -> other movement flags like barriers
//
// Application: 2 vehicles following each other that cannot pass, nor switch position
// 2nd vehicle must remain behind.
// Collision detect optional i/e. proper working code -> accum 1 is never greater than accum 2
// (Collision detect might be needed when using high values of timescale in testing?)
// A Position offset between vehicles is assumed, enough so that they are not colliding
// any where on the map. Offset may be coded in their position counter -> spline number
// or offset may be in the value of accum 2 relative to the accum 1 position counter of
// the first vehicle.
truck_2
{
//etc...
trigger stuck_check_vehicle_blocks
{
//etc...
accum 1 trigger_if_equal 0 truck_2 compare_to_0 //truck_2 vs truck_1 position
accum 1 trigger_if_equal 1 truck_2 compare_to_1
accum 1 trigger_if_equal 2 truck_2 compare_to_2
accum 1 trigger_if_equal 3 truck_2 compare_to_3
accum 1 trigger_if_equal 4 truck_2 compare_to_4
accum 1 trigger_if_equal 5 truck_2 compare_to_5
accum 1 trigger_if_equal 6 truck_2 compare_to_6
accum 1 trigger_if_equal 7 truck_2 compare_to_7
accum 1 trigger_if_equal 8 truck_2 compare_to_8
accum 1 trigger_if_equal 9 truck_2 compare_to_9
accum 1 trigger_if_equal 10 truck_2 compare_to_10
//etc...
}
trigger vehicle_ahead_blocking //common routine for method 2, 2a
{
accum 3 bitset 1 //stop
}
trigger vehicle_ahead_clear //common routine called by truck_1's movement forward
{
accum 2 inc 1 // must be called for each spline move of truck_1
accum 3 bitreset 1 //can go
}
trigger vehicle_collided //common routine for method 2a
{
accum 3 bitset 1 //stop
accum 3 bitset 2 //collision
}
trigger compare_to_0 //method 1 (note it stops before starts)
{
accum 3 bitset 1 //assume stop
accum 2 abort_if_less_than 1 //i.e. 0 stop, >0 can go
accum 3 bitreset 1 //ok >0 so can move
}
trigger compare_to_1 //method 1 plus collision (note it stops before starts)
{
accum 3 bitset 1 //assume stop
accum 3 bitset 2 //assume collision
accum 2 abort_if_less_than 1 //i.e. < 1 =stop, and in collision
accum 3 bitreset 2 //ok 1+, assume stop but not collision
accum 2 abort_if_equal 1 //i.e. 1 =stop, >1 can go
accum 3 bitreset 1 //ok >0 so can move
}
trigger compare_to_2 //method 2 w/o collision
{
accum 2 trigger_if_equal 2 truck_2 vehicle_ahead_blocking
accum 2 abort_if_less_than 3 //line-is-optional if a resetscript makes the line above not return here, and assuming accum 2 can't be <2
accum 3 bitreset 1 //ok move
}
trigger compare_to_3 //method 2 plus collision
{
//...
accum 2 trigger_if_equal 3 truck_2 vehicle_ahead_blocking //i.e. 3 means stop
accum 2 abort_if_equal 3 //line-is-optional if a resetscript makes the line above not return here
accum 3 bitreset 1 //ok move //i.e. >3 can go
accum 2 abort_if_greater_than 2 //i.e. if 2, 1, 0, -1...
accum 3 bitset 2 //then collision
//(stop bit 1 not needed if movement check routine uses collision bit for stop)
}
trigger compare_to_4 //method 2 plus collision
{
//...
accum 2 trigger_if_equal 4 truck_2 vehicle_ahead_blocking
accum 2 abort_if_equal 4 //line-is-optional if a resetscript makes the line above not return here
accum 3 bitreset 1 //ok move
accum 2 abort_if_greater_than 3 //i.e. if 3, 2, 1, 0, -1...
accum 3 bitset 2 //collision i.e. less than 4
accum 3 bitset 1 //ok stop bit jic
}
trigger compare_to_5 //method 2a plus collision for multiple splines
{
//...
accum 2 trigger_if_equal 5 truck_2 vehicle_ahead_blocking
accum 2 abort_if_equal 5 //line-is-optional if a resetscript makes the line above not return here
accum 3 bitreset 1 //ok move
accum 2 abort_if_greater_than 4 //i.e. if 4, 3, 2, 1, 0, -1...
trigger truck_2 vehicle_collided
}
trigger compare_to_6 //method 2a plus collision for a single spline point
{
//...
accum 2 trigger_if_equal 6 truck_2 vehicle_ahead_blocking
accum 2 trigger_if_equal 5 truck_2 vehicle_collided
accum 2 abort_if_less_than 7 //line-is-optional if a resetscript makes the lines above not return here, but omitting this line assumes accum 2 cannot equal 4 or less
accum 3 bitreset 1 //ok move
}
//etc...
So the examples in compare_to_0, compare_to_2 (no collisions)
and in compare_to_6 (with single spline collision)
are shorter and easier to read than the others.
An alternate method to truck_2’s trigger stuck67_check_vehicle_blocks routine would be
to do the checks in the move_to_<N> trigger-blocks by trigger calls to the respective
compare_to_<N>
If you see something wrong in the tutorial please say so.