problem with a tutorial


(Wezelkrozum) #1

I had need a tank so i copy a tank from a tutorial. The tank of the tutorial have 7 splnpoints. So i have taken 3 splnpoint with it and now i have 10 splnpoints but if i run my map the tank stops at the 6e splnpoint. must i changes someting in the script?

This is my script:


game_manager
{
	spawn
	{
		wm_set_round_timelimit	30
		wm_axis_respawntime	10
		wm_allied_respawntime	10

		wait 500
	}
}

tank
{
// accum 0, track state
// accum 1
//  - bit 0: barrier1 state		( 0 = not built,	1 = built		)
//  - bit 1: barrier2 state		( 0 = not built,	1 = built		)
//  - bit 2: spline status 		( 0 = not moving, 	1 = moving 		)
//  - bit 3: stuck check flag 	( 0 = not stuck, 	1 = stuck 		)
//  - bit 4: flag for message	( 0 = dont display, 1= display		)
//  - bit 5: blank
//  - bit 6: temp register 		(XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
//  - bit 7: death status 		( 0 = alive, 		1 = dead		)
//  - bit 8: player check 		( 0 = players, 		1 = no players	)
//  - bit 9: visible state		( 0 = alive, 		1 = dead		)
// accum 2, blank
// accum 3, current movement loop position
// accum 4, stop counter
// accum 5, lockout ref counter
// accum 6, blank
// accum 7, blank
	spawn
	{
		wait 400
		followspline 0 spln0 50000 length 32 wait
		followspline 1 spln0 50000 length 32 wait

		trigger tank sound_idle
		trigger tank tracks_stop
	}

	death
	{
		accum 1 bitset 7
	}

	rebirth
	{
		accum 1 bitreset 9 // we're visibly alive
		accum 1 bitreset 7 // we're alive again

		trigger self script_lockout

		changemodel models/mapobjects/tanks_sd/jagdpanther_africa_tracks.md3

		setstate tank_smoke invisible

		wm_teamvoiceannounce 0 "axis_hq_tank_repaired_allies"
		wm_teamvoiceannounce 1 "allies_hq_tank_repaired"

		trigger tank_sound rebirth
		wait 500

		trigger self script_lockout_stop
	}

	trigger barrier_built
	{
		accum 1 bitset 1
	}

	trigger barrier_destroyed
	{
		accum 1 bitreset 1
	}

	trigger deathcheck
	{
		accum 1 abort_if_not_bitset 7	// abort if tank not damaged
		accum 1 abort_if_bitset 9	// abort if tank already visibly dead
		accum 1 abort_if_bitset 2	// abort if we are following a spline
		accum 5 abort_if_not_equal 0	// abort if we are in a script lockout

		accum 1 bitset 9				// we're now visibly dead

		trigger self deathcheck_message
		accum 1 bitset 4

		changemodel models/mapobjects/tanks_sd/jagdpanther_africa_tracks2.md3

		setstate tank_smoke default

		kill tank_construct

		trigger self sound_death
		trigger self tracks_stop

		trigger self script_lockout

		trigger self tracks_stop
		startanimation 45 10 15 nolerp norandom
		wait 666
		startanimation 0 1 15 nolerp norandom

		trigger self script_lockout_stop

		resetscript
	}

	trigger deathcheck_message
	{
		accum 1 abort_if_not_bitset 4

		wm_announce "The tank has been damaged!"

		wm_teamvoiceannounce 0 "axis_hq_tank_damaged"
		wm_teamvoiceannounce 1 "allies_hq_tank_damaged_axis"
	}

	// ========================
	// movement

	trigger dispatch
	{
		accum 3 trigger_if_equal 0 tank run_0
		accum 3 trigger_if_equal 1 tank run_1
		accum 3 trigger_if_equal 2 tank run_2
		accum 3 trigger_if_equal 3 tank run_3
		accum 3 trigger_if_equal 4 tank run_4
		accum 3 trigger_if_equal 5 tank run_5
		accum 3 trigger_if_equal 6 tank run_6
		accum 3 trigger_if_equal 7 tank run_7
		accum 3 trigger_if_equal 8 tank run_8
		accum 3 trigger_if_equal 9 tank run_9
		accum 3 trigger_if_equal 10 tank run_10
	}

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

	trigger move_check
	{
		trigger self stuck_check
		accum 1 abort_if_bitset 3

		trigger self dispatch
	}

	trigger run_continue
	{
		accum 3 inc 1

		trigger self deathcheck
		trigger self stopcheck
		trigger self move
	}

	trigger run_0
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln0 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_1
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln1 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_2
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln2 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_3
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln3 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_4
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln4 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_5
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln5 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_6
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln6 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_7
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln7 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_8
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln8 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_9
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln9 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_10
	{
		trigger self tracks_forward
		accum 1 bitset 2
		followspline 0 spln10 80 wait
		accum 1 bitreset 2

		trigger self run_continue
	}

//	trigger run_7
//	{
//		trigger self tracks_forward
//		accum 1 bitset 2
//		followspline 0 spln7 80 wait
//		accum 1 bitreset 2
//
//		trigger self script_lockout
//
//		accum 3 inc 1
//
//		trigger tank_sound stop
//		trigger self tracks_stop		
//		startanimation 5 10 15 nolerp norandom	// stopping
//		wait 666
//		startanimation 0 1 15 nolerp norandom	// stopped
//
//		wait 900
//
//		trigger tank_turret turn
//	}

	// =========================
	// script lockouts

	trigger script_lockout
	{
		accum 5 inc 1
	}

	trigger script_lockout_stop
	{
		accum 5 inc -1
	}

	trigger sound_idle
	{
		stopsound
		playsound sound/vehicles/tank/tank_idle.wav looping volume 512
	}

	trigger sound_start
	{
		stopsound
		playsound sound/vehicles/tank/tank_revup.wav volume 196
	}

	trigger sound_move
	{
		stopsound
		playsound sound/vehicles/tank/tank_move.wav looping volume 512
	}

	trigger sound_stop
	{
		stopsound
		playsound sound/vehicles/tank/tank_revdown.wav volume 196
	}

	trigger sound_death
	{
		stopsound
		playsound sound/vehicles/tank/tank_stop.wav volume 256
	}

	trigger sound_rebirth
	{
		stopsound
		playsound sound/vehicles/tank/tank_start.wav volume 196
	}

	// ================================
	// stop check
	trigger stopcheck
	{
		trigger self stopcheck_setup
		accum 1 abort_if_not_bitset 6

		trigger self script_lockout

		trigger tank_sound 	stop
		trigger self 		tracks_stop
		startanimation 45 	10 	15 nolerp norandom
		wait 666
		startanimation 0 	1 	15 nolerp norandom
		wait 900

		trigger self script_lockout_stop
		resetscript
	}

	trigger stopcheck_setup
	{
		accum 1 bitset 6				// stop if we're stuck/no-one's pushing :)

		accum 1 abort_if_bitset 8		// no one in the trigger, abort

		trigger self stuck_check		// call the stop check function
		accum 1 abort_if_bitset 3		// we're stuck so break out

		accum 1 bitreset 6			// we're free to move
	}

	// ======================================
	// stuck checking

	trigger stuck_check
	{
		accum 1 bitreset 3

		trigger self stuck_check_barrier
		trigger self stuck_check_scriptlockout
		trigger self stuck_check_finished
	}

	trigger stuck_check_finished
	{
	//	The check should be the final spln nbr + 1
		accum 3 abort_if_less_than 8
		accum 1 bitset 3
	}

	trigger stuck_check_scriptlockout
	{
		accum 5 abort_if_equal 0
		accum 1 bitset 3
	}

	trigger stuck_check_barrier
	{
		accum 3 abort_if_not_equal 3
		globalaccum 0 abort_if_not_bitset 0	// abort if barrier not built
		accum 1 bitset 3
	}

	trigger tank_disable
	{
		accum 4 inc 1				// up the stop counter
		accum 4 abort_if_less_than 4

		accum 1 bitset 8				// set stop check

		trigger self deathcheck
	}

	trigger tank_enable
	{
		trigger self stuck_check
		accum 1 abort_if_bitset 3 	// stuck check

		accum 4 set 0			// reset stop counter
		accum 1 bitreset 8		// reset stop check

		accum 1 abort_if_bitset 2 	// already following spline
		accum 5 abort_if_not_equal 0	// are we not in a script lockout?

		accum 1 abort_if_bitset 7 	// death check

		trigger self script_lockout

		trigger tank_sound start

		startanimation 55 10 15 nolerp norandom
		wait 666
		startanimation 5 40 15 nolerp norandom
		wait 500
		trigger self tracks_forward

		trigger self script_lockout_stop

		trigger self move
	}

	trigger tracks_forward
	{
		accum 0 abort_if_equal 1
		accum 0 set 1

		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_alt_forward

		remapshaderflush
	}

	trigger tracks_stop
	{
		accum 0 abort_if_equal 0
		accum 0 set 0

		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_left
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_right
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_left
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_right
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_left
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_right

		remapshaderflush
	}

	trigger tracks_turn_left
	{
		accum 0 abort_if_equal 2
		accum 0 set 2

		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_alt_forward

		remapshaderflush
	}

	trigger tracks_turn_right
	{
		accum 0 abort_if_equal 3
		accum 0 set 3

		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_alt_backward

		remapshaderflush
	}

	trigger startfire
	{
		startanimation 67 8 10 nolerp norandom noloop
	}

	trigger stopfire
	{
		startanimation 0 1 15 nolerp norandom
	}
}

tank_build
{
	spawn
	{
		wait 500
		attachtotag tank_shell tag_turret
	}
}

tank_construct
{
	spawn
	{
		wait 1000

		kill tank

		constructible_class 2
		constructible_health 1200
		constructible_constructxpbonus 10
		constructible_destructxpbonus 10
	}

	built final
	{
		alertentity tank
		wm_announce "The tank has been repaired!"
	}
}

tank_disabler
{
	trigger run
	{
		trigger tank tank_disable
	}
}

tank_enabler
{
	trigger run
	{
		trigger tank tank_enable
	}
}

tank_fire_sound
{
	trigger run
	{
		setposition tank
		alertentity tank_fire_sound
	}
}

tank_flash
{
	spawn
	{
		wait 300
 		attachtotag tank_turret tag_flash
		setstate tank_flash invisible
	}

	trigger run
	{
		setstate tank_gunsmoke default
		setstate tank_flash default
		wait 100
		setstate tank_flash invisible
		setstate tank_gunsmoke invisible
	}
}

tank_gunsmoke
{
	spawn
	{
		wait 300
 		attachtotag tank_turret tag_flash
		setstate tank_gunsmoke invisible
	}
}

tank_shell
{
	spawn
	{
		wait 400
		attachtotag tank tag_tank
	}
}

tank_smoke
{
	spawn
	{
		wait 300
		attachtotag tank_shell tag_smoke
		setstate tank_smoke invisible
	}
}

tank_sound
{
	trigger start
	{
		trigger tank sound_start
		wait 3400
		trigger tank sound_move
	}

	trigger stop
	{
		trigger tank sound_stop
		wait 1400
		trigger tank sound_idle
	}

	trigger rebirth
	{
		trigger tank sound_rebirth
		wait 1400
		trigger tank sound_idle
	}
}

tank_trigger
{
	spawn
	{
		wait 500
		attachtotag tank_shell tag_turret
	}
}

tank_turret
{
	spawn
	{
		wait 500
		attachtotag tank_shell tag_turret
	}

	trigger turn
	{
		wait 1000

		playsound sound/vehicles/tank/turret_spin.wav looping
		faceangles 0 340 0 3000
		stopsound
		playsound sound/vehicles/tank/turret_end.wav

		wait 500

		trigger tank startfire
		playsound sound/vehicles/tank/tank_fire.wav
		trigger tank_flash run
		wait 600
		trigger tank stopfire

		playsound sound/vehicles/tank/turret_spin.wav looping
		faceangles 0 0 0 3000
		stopsound
		playsound sound/vehicles/tank/turret_end.wav
		trigger tank sound_death

		trigger tank script_lockout_stop
	}
}



(-SSF-Sage) #2

I think here is the problem:

trigger stuck_check_finished
{
// The check should be the final spln nbr + 1
accum 3 abort_if_less_than 8 //should be 11
accum 1 bitset 3
}

Shouldn’t that be this instead:


   trigger stuck_check_finished 
   { 
   //   The check should be the final spln nbr + 1 
      accum 3 abort_if_less_than 11 // here
      accum 1 bitset 3 
   } 

Right? Correct me if im not.

And I think you should have

tank
{
spawn
{
accum 3 set 0 //to reset the script at the beginning, put it right after wait 400 ^^
}
}

I may be wrong, i’m not too good script monkey.


(Wezelkrozum) #3

thanx, it works now XD

but i don’t understand what you said about that accum 3 set 0


(aburn) #4

he ment that you should reset it at the beginning… and set it to the desired value after 400 so there wont be any bugs in the movement of whatever moves there… ( IDK what the script, actually moves… just skimmed it)

accum 3 checks if your mover is 0 - not stuck, 1 - stuck on something (eg. barrier)


(-SSF-Sage) #5

Accum 3 set 0 is to make this moving start really from the start. So always when you restart the map it starts from the right spot. (Really affects on the tanks moving, not actual spawnpoint I think, will probably cause bugs so you should set it imo).

Since


trigger run_continue 
   { 
      accum 3 inc 1 //add accum 3 1 more, so in this start stage accum 3 is set to 1 (0+1=1) if you set it to 0 in start, so the first spline will be executed.

      trigger self deathcheck 
      trigger self stopcheck 
      trigger self move 
   } 

So everytime this runs (the tanks moves a spline), it adds one to this value. It has to be start as zero, because if it started for example as 3 then it would start executing the


accum 3 trigger_if_equal 3 tank run_3 //-line,

In other words it would start by going to the third spline. And when you set the accum 3 to a value of 0 in the spawn, it makes it always start where you want it to start from. Although there is the spawnpoint set to


      followspline 0 spln0 50000 length 32 wait 
      followspline 1 spln0 50000 length 32 wait 

it may cause bugs and such. And certainly will affect on moving since the accum 3 starts in wrong values. I hope you got it.

And I wanted you to position this accum 3 set 0 to here:


tank
{
spawn 
   { 
      wait 400 
      accum 3 set 0 //after wait so it is sure to not cause any bugs. I'm not sure if it would have if it wasn't.
      followspline 0 spln0 50000 length 32 wait 
      followspline 1 spln0 50000 length 32 wait 

      trigger tank sound_idle 
      trigger tank tracks_stop 
   }
}

I hope you got it m8. And I hope I didn’t tell you too much bad info or had a typ0s etc.

Edit. and aburn the stuck status is accum 1 bit 3, not accum 3. I think you just made a mistake.


(aburn) #6

was skimming… prolly missread :stuck_out_tongue:
soz, my bad