Convoy of Script movers?


(TomTom7777) #1

Hypothetical: Can multiple independent script_movers use the same splines but be otherwise independent (triggers etc). Is the only thing needed a movement trigger code block to keep them a few splines apart thus allowing a convoy of damageable trucks or tanks w/o mg to be moved down a narrow road close together or spread out apart?

Has anyone got an existing map example? I.e. a map where a win happens when not 1 but 2,3 or more vehicles have to make it to the finish.

Update: this seem the only really similar old topic
http://forums.warchest.com/showthread.php/2611-Scripting-help-accum?p=36643&viewfull=1#post36643


(twt_thunder) #2

Hypothetical:I guess yes… never tried


(Teuthis) #3

This is possible but scriptwise difficult. Imagine you want the back parts to only move if the front mover is not blocking the way. So if no one is escorting in the front, then escorting the back part too much would result in a crash. So with wise use of the accum variables this is possible. The is a function to let a script mover follow another script mover in a certain distance, func_train uses this I think. Maybe that’s the preferable option then.

Great idea btw :wink:


(WuTangH) #4

Idk how much complicated you want it, but a “simple” convoy - with destructable tank in front and trucks behind it is in UJE Convoy map. :wink:
You repair tank and when you move it, trucks follow.
http://www.dark-alchemy.com/wiki/index.php/UJE_Convoy


(TomTom7777) #5

Thanks WuTangH I’ll take a look sometime, but movement in tandem is not complicated.

I am thinking about collision detection and avoidance scripting. In the link I gave it looks like they would likely use separate globalaccums to track the vehicles which limits how many script_movers can be used.

To keep it ‘relatively’ simple each script_mover would be ore-coded for a specific offset, i.e.

front script_mover #1

trigger dispatch
	{
		accum 3 trigger_if_equal 0 s_mover_truck run_6
		accum 3 trigger_if_equal 1 s_mover_truck run_7
		accum 3 trigger_if_equal 2 s_mover_truck run_8
		accum 3 trigger_if_equal 3 s_mover_truck run_9
		accum 3 trigger_if_equal 4 s_mover_truck run_10
		accum 3 trigger_if_equal 5 s_mover_truck run_11
...

middle script_mover #2

trigger dispatch
	{
		accum 3 trigger_if_equal 0 s_mover_truck run_3
		accum 3 trigger_if_equal 1 s_mover_truck run_4
		accum 3 trigger_if_equal 2 s_mover_truck run_5
		accum 3 trigger_if_equal 3 s_mover_truck run_6
		accum 3 trigger_if_equal 4 s_mover_truck run_7
		accum 3 trigger_if_equal 5 s_mover_truck run_8
...

rear script_mover #3

trigger dispatch
	{
		accum 3 trigger_if_equal 0 s_mover_truck run_0
		accum 3 trigger_if_equal 1 s_mover_truck run_1
		accum 3 trigger_if_equal 2 s_mover_truck run_2
		accum 3 trigger_if_equal 3 s_mover_truck run_3
		accum 3 trigger_if_equal 4 s_mover_truck run_4
		accum 3 trigger_if_equal 5 s_mover_truck run_5
...

that way position accums would have the same value when script movers were close together, collisions might be supportable as negative diffs.

Comparisons between accums would be interesting coding. I am also thinking about whether to try using a single globalaccum as generic parameter passer (conceptually say a non-zero value means it is busy, which may be OK for events like movement triggers that fire multiple times a second).

Caveats would be size of scripts and some bots (FritzBot-ET Bobot?) would not becapable of full support.

My inspiration initially was thinking of the 1940 advance by Rommel through Northern France, but now I am imaging a map concept of a narrow mountain road in the Alps (tank and 2 trucks).


(-SSF-Sage) #6

It is possible indeed by multiple ways. But if the convoy is moving togethor, why can you not just have one with a regular tank script and other just follow it? It might not really be needed to make it so complex. For example do like

	trigger run_5
	{
		trigger self tracks_turn_left
		accum 1 bitset 2

		trigger vehicle2 run_1
		trigger vehicle3 run_2		
		trigger vehicle4 run_3		

		followspline 0 tank_spln_5 140 wait length 128
		accum 1 bitreset 2

		trigger self run_continue
	}

Then these slave vehicles would only need tiny script.


(TomTom7777) #7

Thanks, but actually a bit simpler than I thought.

For each of A’s moves,A calls B’s trigger_event block used to inc local accum limit.
If B destroyed at pos X, then A’s movement also calls C’s trigger Block to inc local accum limit.

For B moves, B calls C’s trigger_event block used to inc local accum limit.

If B destroyed at pos X, B’s movement trigger is set invisible, B is replaced by static truck on its side, then C’s movement diverts at X to X’+1 for bypass

If C destroyed at pos X no special code. C’s movement trigger is set invisible, C is replaced by same static model of a truck on its side.

So problem is just down to comparing accums, and having a local accum available for limit.

Each truck also needs a ‘carrying gold’ bit flag to determine what gets thrown off the truck if destroyed at pos X.

Now to compare 2 accums.
movement block calls directly or via a stop check trigger_event-block an
accum 3 trigger_if_equal <N> call to a trigger_event-block say Compare_<N> that sets the movement allowed bit if limit accum greater_than, the stop bit if equal, collision bit if less than.

If approaching max trigger blocks in a truck script_block, compare can be in a separate script_block that calls back a truck script_block’s trigger_event-block to set the movement bits.


(TomTom7777) #8

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.