Tank Help - Scripting


(BloodLusts) #1

OK below is the script i have now

I know enough script to setup the Splines

but my trouble is it keeps thinking its hitting an obsticle - so it stops

please someone - can u remove the obsticle checking codes from this script

All i need this tank to do - is run a line from point a to point b - stop and blow up a Gate

and it has to be escorted

so far i have it all ok - except for it stopping cuz it thinks there is an obsticle

so can someone please read this script and remove the obsticle check stuff - cuz im lost

once i have it removed i can finish setting the tank stuff up for my map

please help

SCRIPT CODE

game_manager
{
	spawn
	{
		wm_axis_respawntime		1
		wm_allied_respawntime	1
		wm_set_round_timelimit	20

		setchargetimefactor 0 soldier		0
		setchargetimefactor 0 medic			0
		setchargetimefactor 0 engineer		0
		setchargetimefactor 0 fieldops		0
		setchargetimefactor 0 covertops		0

		setchargetimefactor 1 soldier		0
		setchargetimefactor 1 medic			0
		setchargetimefactor 1 engineer		0
		setchargetimefactor 1 fieldops		0
		setchargetimefactor 1 covertops		0
	}
}


	







//======================================================================
// TANK
//======================================================================
//
// Slot	Used for
// ====	========
// 0	State:
//		- Bit 0: Broken						0 = No		1 = Yes
//		- Bit 1: Moving						0 = No		1 = Yes
//		- Bit 2: Escort present				0 = No		1 = Yes
//		- Bit 3: Obstacle in the way		0 = No		1 = Yes
//		- Bit 4: Model shown broken			0 = No		1 = Yes
// 1	Path state:
//		- Bit 0: Obstacle 000 present		0 = No		1 = Yes
// 2	Waypoint counter
// 3	Stop timer
// 4	***unused***
// 5	***unused***
// 6	***unused***
// 7	***unused***
// 8	***unused***
// 9	Script lockout counter
//
tank1
{
	//----------------------------------------------------------------------
	// The following are events that this entity is capable of triggering
	//----------------------------------------------------------------------
	spawn
	{
		// Set variables to defaults
		accum 0 set 0			// State
		accum 1 set 0			// Path state
		accum 1 bitset 0		// Set obstacle 0 as present
		accum 3 set 0			// Reset stop timer
		accum 9 set 0			// Reset script lockout counter

		// Wait for entities to spawn
		wait 100
		
		// Set initial position to the first waypoint
		followspline 0 waypoint_000 10000
		accum 2 set 1

		// Set default state (ie. tank ready)
		trigger self sound_idle
		trigger self anim_tracks_stop
		setstate tank1_smoke invisible
	}
	

	
	// Called when the entity is hurt
	pain
	{
	}
	
	
	
	// Called when the entity is destroyed
	death
	{
		// Update state bits
		accum 0 bitset 0						// Mark as broken, which mean it will stop at next waypoint
	}
	
	
	
	// Indirectly called when the entity is repaired
	rebirth
	{
		// Lock script
		trigger self script_lock
		
			// Change from broken to fixed model
			changemodel models/mapobjects/tanks_sd/churchhill.md3
	
			// Remove smoke
			setstate tank1_smoke invisible
	
			// Start
			trigger tank1_sound rebirth
			wait 500

			// Update state bits
			accum 0 bitreset 0					// Mark as not broken
		    accum 0 bitreset 4					// Mark as visually not broken
		
		// Unlock script
		trigger self script_unlock
	}
	
	
	
	// Called when a player is using the mounted MG
	mg42 mount
	{
	}
	
	
	
	// Called when a player is no longer using the mounted MG
	mg42 unmount
	{
	}
	

	
	
	
	//----------------------------------------------------------------------
	// Trigger functions
	//----------------------------------------------------------------------

	// This function is called when a player moves inside the escort zone
	trigger escort_trigger
	{
		// Check for obstacles
		trigger self check_obstacle_status

		// Update state bits and counters
		accum 0 bitset 2				// Mark as escort present
		accum 3 set 0					// Reset stop timer
		
		// Check if allowed to move
		accum 0 abort_if_bitset 0		// Abort if its broken
		accum 0 abort_if_bitset 1		// Abort if its already moving
		accum 0 abort_if_bitset 3		// Abort if an obstacle is in the way
		accum 9 abort_if_not_equal 0	// Abort if the script is currently locked
		
		// Lock script
		trigger self script_lock
		
			// Starting state
			trigger tank1_sound start
			startanimation 55 10 15 nolerp norandom
			wait 666

			// Driving state
			trigger self anim_tracks_forward
			startanimation 5 40 15 nolerp norandom

			// Wait a bit before starting to move
			wait 500
			
		// Unlock script
		trigger self script_unlock
		
		// Start movement loop
		trigger self move
	}

	
	
	// This function is called periodicly by a func_timer entity in the map.
	// Each time it checks a counter to see if the escort has been gone too
	// long. The counter is reset by the escort trigger function.
	trigger timer
	{
		// Increase counter, and if it hasn't reached 4 then abort
		accum 3 inc 1
		accum 3 abort_if_less_than 4
		
		// Update state bits
		accum 0 bitreset 2						// Mark as not escorted, which means it will stop at next waypoint

		// Need to periodicly check if the tank has been damaged
		trigger self check_death
	}
	
	


	
	//----------------------------------------------------------------------
	// Waypoint functions that checks if it can proceed to the next waypoint
	//----------------------------------------------------------------------

	// Check if its broken, and if so change to the broken state
	trigger check_death
	{
		// Check if its broken
		accum 0 abort_if_not_bitset 0		// Abort if not broken
		accum 0 abort_if_bitset 1			// Abort if its already moving
		accum 0 abort_if_bitset	4			// Abort if its already in its broken state
		accum 9 abort_if_not_equal 0		// Abort if the script is currently locked

		// Lock script
		trigger self script_lock

			// This target_kill entity will kill the func_constructible so that an engineer can repair it
			alertentity tank1_kill
		
			// Change from fixed to broken model
			changemodel models/mapobjects/tanks_sd/churchhill_broken.md3

			// Start smoking
			setstate tank1_smoke default

			// Death sound
			trigger self sound_death
			
			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom

			// Update state bits
		    accum 0 bitset 4				// Mark as visually broken state

		// Unlock script
		trigger self script_unlock
	}

	
	
	// Check if it isn't escorted, and if not then stop it
	trigger check_escort
	{
		// Check if its not escorted
		accum 0 abort_if_bitset 2			// Abort if escort is present

		// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom
			
		// Unlock script
		trigger self script_unlock
	}


	
	// Check if there is an obstacle preventing it from continuing to the next waypoint, and if so then stop it
	trigger check_obstacle
	{
		// Update obstacle bit (with the help of the waypoint counter and some of the obstacle functions)
		trigger self check_obstacle_status
		accum 0 abort_if_not_bitset 3		// Abort if no obstacles in the way
		
		// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom
			
		// Unlock script
		trigger self script_unlock
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Obstacle functions
	//----------------------------------------------------------------------

	// Dispatching obstacle checking function
	trigger check_obstacle_status
	{
		accum 0 bitreset 3				// Mark as no obstacles in the way
		accum 2 trigger_if_equal 3 tank1 obstacle_000_check
	}


	
	// First obstacle - Checks if the obstacle is blocking the way
	trigger obstacle_000_check
	{
		accum 1 abort_if_not_bitset 0	// Abort if the obstacle has been removed
		accum 0 bitset 3				// Mark as an obstacle in the way
	}
	
	// First obstacle - Called by the death routine in another entity, once the obstacle is destroyed
	trigger obstacle_000_removed
	{
		accum 1 bitreset 0				// Mark obstacle as removed
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Misc. functions
	//----------------------------------------------------------------------
	trigger script_lock {
		accum 9 inc 1
		}
	
	trigger script_unlock {
		accum 9 inc -1
		}


		
	
		
	//----------------------------------------------------------------------
	// Move functions
	//----------------------------------------------------------------------
	
	// Dispatching move function
	trigger move
	{
		// The obstacle bit is still valid because of the obstacle check done by the calling function
		accum 0 abort_if_bitset 3			// Abort if an obstacle is in the way

		// List of waypoints to go to
		accum 2 trigger_if_equal 1 tank1 move_to_001
		accum 2 trigger_if_equal 2 tank1 move_to_002
		accum 2 trigger_if_equal 3 tank1 move_to_003
		accum 2 trigger_if_equal 4 tank1 move_to_004
		accum 2 trigger_if_equal 5 tank1 move_to_005
		accum 2 trigger_if_equal 6 tank1 move_to_006
		accum 2 trigger_if_equal 7 tank1 move_to_007
	}


	
	// Called at the end of each move. If it passes some checks the movement is repeated
	trigger move_increment
	{
		accum 2 inc 1						// Increment waypoint counter

		// Check if its ok to proceed to the next waypoint
		trigger self check_death
		trigger self check_escort
		trigger self check_obstacle

		// This loop is used so that the tank can immediately advance after completing the move
		trigger self move
	}

	
	
	// Move to waypoint 001
	trigger move_to_001
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 waypoint_001 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 002
	trigger move_to_002
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 waypoint_002 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 003
	trigger move_to_003
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 waypoint_003 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving

		// If there is a need to do something after it passes an obstacle then this is the place to do it.
		// Ex. hiding func_constructible for the obstacle or voice overs

		trigger self move_increment
	}

	// Move to waypoint 004
	trigger move_to_004
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 waypoint_004 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 005
	trigger move_to_005
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 waypoint_005 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving

		// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom

		    // Wait a little until starting the fireing sequence
		    wait 900
			
			// Manually increment waypoint counter
			accum 2 inc 1
			
			// This turret function will unlock the script when its done
			trigger tank1_turret fire_at_target_1
	}

	// Move to waypoint 006
	trigger move_to_006
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 waypoint_006 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 007
	trigger move_to_007
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 waypoint_007 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		
		// If you want waypoints to loop, this is the place to reset the waypoint counter
		// Make sure that the last waypoint targets waypoint_001 to loop correctly
		accum 2 set 0				// Make the waypoints loop around

		trigger self move_increment
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Tank sounds
	//----------------------------------------------------------------------
	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
	}




	
	//----------------------------------------------------------------------
	// Tank animations
	//----------------------------------------------------------------------
	trigger anim_tracks_forward
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	
	trigger anim_tracks_turningleft
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_backward
		remapshaderflush
	}
	
	trigger anim_tracks_turningright
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_backward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	
	trigger anim_tracks_stop
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_r
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_r
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_l
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_l
		remapshaderflush
	}

	trigger anim_fire_start
	{
		startanimation 67 8 10 nolerp norandom
	}
	
	trigger anim_fire_stop
	{
		startanimation 0 1 15 nolerp norandom
	}
}





//======================================================================
// Tank turret
//======================================================================

tank1_turret
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}


	
	//----------------------------------------------------------------------
	// Turret sequence
	//----------------------------------------------------------------------
	trigger fire_at_target_1
	{
		// Wait a little until starting sequence
		wait 1000

		// Turn turret towards target
		trigger tank1_sound turret_turn_start
		faceangles 0 60 0 4000						// Adjust angles to match the target
		trigger tank1_sound turret_turn_stop
		wait 500

		// Fire at target
		trigger tank1_sound turret_fire
		trigger tank1 anim_fire_start
		setstate tank1_flash default
		wait 50
		setstate tank1_flash invisible
		wait 200
		trigger tank1 anim_fire_stop

		// BUG: Apparently the entitys scriptblock is completely removed after its blown up the first time
		trigger target_000 blow_up
		wait 1000

		// Turn turret back to target
		trigger tank1_sound turret_turn_start
		faceangles 0 0 0 4000
		trigger tank1_sound turret_turn_stop
			
		// Wait a little until its ready to move again
		wait 500

		// Unlock script
		trigger tank1 script_unlock
	}


		
	//----------------------------------------------------------------------
	// Turret sounds
	//----------------------------------------------------------------------
	trigger sound_fire
	{
		stopsound
		playsound sound/vehicles/tank/tank_fire.wav volume 300
	}

	trigger sound_turn_start
	{
		stopsound
		playsound sound/vehicles/tank/turret_spin.wav looping volume 127
	}

	trigger sound_turn_stop
	{
		stopsound
		playsound sound/vehicles/tank/turret_end.wav volume 96
	}
}





//======================================================================
// The following are related entities which are attached because they need to follow the script_mover
//======================================================================

tank1_enabler_trigger
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}
}



tank1_flash
{
	spawn
	{
		// Wait for host entity to spawn
		wait 200
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1_turret tag_flash
		
		// Hides the flash
		setstate tank1_flash invisible
	}
}



tank1_smoke
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
		
		// Turn off smoking
		alertentity tank1_smoke
	}
}



tank1_toi
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}
}





//======================================================================
// The following are the remaining entities
//======================================================================

tank1_construct
{
	spawn
	{
		// Needed for the icon to reappear correctly on the command map
		constructible_class 2
	}
	
	// Called when the repairs are starting
	buildstart final
	{
	}

	// Called when the repairs have failed
	decayed final
	{
	}
	
	// Called when the repairs have failed
	failed
	{
	}
		
	// Called when the repairs are done
	built final
	{
		// Resurrect the entity. This fills up its health and trigger the ::rebirth function
		alertentity tank1
	}
}

tank1_disabler
{
	spawn
	{
	}

	trigger run
	{
		// Call the function which controls the escort timeout
		trigger tank1 timer
	}
}

tank1_enabler
{
	spawn
	{
	}

	trigger run
	{
		// Call the function which handles the escort
		trigger tank1 escort_trigger
	}
}

tank1_kill
{
	spawn
	{
	}
}

tank1_timer
{
	spawn
	{
	}
}






//======================================================================
// This block contains sound redirectors. Since commands are executed in order
// the only way to have multiple waits at the same time is to play them through another scriptblock
//======================================================================

tank1_sound
{
	spawn
	{
	}
	
	trigger start
	{
		trigger tank1 sound_start
		wait 3400
		trigger tank1 sound_move
	}
	
	trigger stop
	{
		trigger tank1 sound_stop
		wait 1400
		trigger tank1 sound_idle
	}
	
	trigger rebirth
	{
		trigger tank1 sound_rebirth
		wait 1400
		trigger tank1 sound_idle
	}

	trigger turret_fire
	{
		trigger tank1_turret sound_fire
	}

	trigger turret_turn_start
	{
		trigger tank1_turret sound_turn_start
	}

	trigger turret_turn_stop
	{
		trigger tank1_turret sound_turn_stop
	}
}











//======================================================================
// OBSTACLES
//======================================================================

obstacle_000
{
	spawn
	{
	}
	
	pain
	{
	}
	
	death
	{
		// Notify relevant parts of the script that the obstacle has been destroyed
		trigger tank1 obstacle_000_removed
	}
}











//======================================================================
// TARGETS
//======================================================================
//
// Slot	Used for
// ====	========
// 0	State:
//		- Bit 0: Broken						0 = No		1 = Yes
//
target_000
{
	spawn
	{
		// Reset state bits
		accum 0 bitset 0					// Mark as not blown up
	}
	
	pain
	{
	}
	
	// If you need to notify other parts of the script that the target has been removed, then do it here.
	death
	{
	}
	
	// Called when the entity should be destroyed
	trigger blow_up
	{
		// Check if we have already been blown up
		accum 0 abort_if_not_bitset 0		// Abort if already blown up
		
		// Update state bits
		accum 0 bitreset 0					// Mark as blown up

		// Blow up
		alertentity target_000
	}
}


(codejockey13) #2

tank1
{
//----------------------------------------------------------------------
// The following are events that this entity is capable of triggering
//----------------------------------------------------------------------
spawn
{
// Set variables to defaults
accum 0 set 0 // State
accum 1 set 0 // Path state


Looks like this should be “accum 1 bitreset 0” … you are setting the bit to 1 to say true that there is an obstacle preset.

  accum 1 bitset 0      // Set obstacle 0 as present 

  accum 3 set 0         // Reset stop timer 
  accum 9 set 0         // Reset script lockout counter 

  // Wait for entities to spawn 
  wait 100 
   
  // Set initial position to the first waypoint 
  followspline 0 waypoint_000 10000 
  accum 2 set 1 

  // Set default state (ie. tank ready) 
  trigger self sound_idle 
  trigger self anim_tracks_stop 
  setstate tank1_smoke invisible 

}


(codejockey13) #3

tank1
{
//----------------------------------------------------------------------
// The following are events that this entity is capable of triggering
//----------------------------------------------------------------------
spawn
{
// Set variables to defaults
accum 0 set 0 // State
accum 1 set 0 // Path state


Looks like this should be “accum 1 bitreset 0” … you are setting the bit to 1 to say true that there is an obstacle preset.

  accum 1 bitset 0      // Set obstacle 0 as present 

  accum 3 set 0         // Reset stop timer 
  accum 9 set 0         // Reset script lockout counter 

  // Wait for entities to spawn 
  wait 100 
   
  // Set initial position to the first waypoint 
  followspline 0 waypoint_000 10000 
  accum 2 set 1 

  // Set default state (ie. tank ready) 
  trigger self sound_idle 
  trigger self anim_tracks_stop 
  setstate tank1_smoke invisible 

}


(BloodLusts) #4

can u be a bit more specific – see the Tank moves for about 3 Splines - then it just Stops moving and plays the Idle tank sound – I think its because it thinks its hitting an obsticle in that spline – so i need someone to read over that script and remove the obsticle codes - and paste back a script without obsticle codes etc…

please help me - i am horrible with the Accum stuff


(BloodLusts) #5

UPDATE

– now my tank does this

Runs perfectly fine on everything EXCEPT for - when it hits Spline 03 – it triggers the Tank_kill - so the tank stops running - and changes its skins to the Broken ones
I need that fixed


game_manager
{
	spawn
	{
		wm_axis_respawntime		1
		wm_allied_respawntime	1
		wm_set_round_timelimit	20

		setchargetimefactor 0 soldier		0
		setchargetimefactor 0 medic			0
		setchargetimefactor 0 engineer		0
		setchargetimefactor 0 fieldops		0
		setchargetimefactor 0 covertops		0

		setchargetimefactor 1 soldier		0
		setchargetimefactor 1 medic			0
		setchargetimefactor 1 engineer		0
		setchargetimefactor 1 fieldops		0
		setchargetimefactor 1 covertops		0
	}
}


	







//======================================================================
// TANK
//======================================================================
//
// Slot	Used for
// ====	========
// 0	State:
//		- Bit 0: Broken						0 = No		1 = Yes
//		- Bit 1: Moving						0 = No		1 = Yes
//		- Bit 2: Escort present				0 = No		1 = Yes
//		- Bit 3: Obstacle in the way		0 = No		1 = Yes
//		- Bit 4: Model shown broken			0 = No		1 = Yes
// 1	Path state:
//		- Bit 0: Obstacle 000 present		0 = No		1 = Yes
// 2	Waypoint counter
// 3	Stop timer
// 4	***unused***
// 5	***unused***
// 6	***unused***
// 7	***unused***
// 8	***unused***
// 9	Script lockout counter
//
tank1
{
	//----------------------------------------------------------------------
	// The following are events that this entity is capable of triggering
	//----------------------------------------------------------------------
	spawn
	{
		// Set variables to defaults
		accum 0 set 0			// State
            accum 1 bitreset 0		
		accum 1 bitset 0		      // Set obstacle 0 as present
		accum 3 set 0			// Reset stop timer
		accum 9 set 0			// Reset script lockout counter

		// Wait for entities to spawn
		wait 100
		
		// Set initial position to the first waypoint
		followspline 0 spl_000 10000
		accum 2 set 1

		// Set default state (ie. tank ready)
		trigger self sound_idle
		trigger self anim_tracks_stop
		setstate tank1_smoke invisible
	}
	

	
	// Called when the entity is hurt
	pain
	{
	}
	
	
	
	// Called when the entity is destroyed
	death
	{
		// Update state bits
		accum 0 bitset 0						// Mark as broken, which mean it will stop at next waypoint
	}
	
	
	
	// Indirectly called when the entity is repaired
	rebirth
	{
		// Lock script
		trigger self script_lock
		
			// Change from broken to fixed model
			changemodel models/mapobjects/tanks_sd/churchhill.md3
	
			// Remove smoke
			setstate tank1_smoke invisible
	
			// Start
			trigger tank1_sound rebirth
			wait 500

			// Update state bits
			accum 0 bitreset 0					// Mark as not broken
		    accum 0 bitreset 4					// Mark as visually not broken
		
		// Unlock script
		trigger self script_unlock
	}
	
	
	
	// Called when a player is using the mounted MG
	mg42 mount
	{
	}
	
	
	
	// Called when a player is no longer using the mounted MG
	mg42 unmount
	{
	}
	

	
	
	
	//----------------------------------------------------------------------
	// Trigger functions
	//----------------------------------------------------------------------

	// This function is called when a player moves inside the escort zone
	trigger escort_trigger
	{
		// Check for obstacles
		trigger self check_obstacle_status

		// Update state bits and counters
		accum 0 bitset 2				// Mark as escort present
		accum 3 set 0					// Reset stop timer
		
		// Check if allowed to move
		accum 0 abort_if_bitset 0		// Abort if its broken
		accum 0 abort_if_bitset 1		// Abort if its already moving
		accum 0 abort_if_bitset 3		// Abort if an obstacle is in the way
		accum 9 abort_if_not_equal 0	// Abort if the script is currently locked
		
		// Lock script
		trigger self script_lock
		
			// Starting state
			trigger tank1_sound start
			startanimation 55 10 15 nolerp norandom
			wait 666

			// Driving state
			trigger self anim_tracks_forward
			startanimation 5 40 15 nolerp norandom

			// Wait a bit before starting to move
			wait 500
			
		// Unlock script
		trigger self script_unlock
		
		// Start movement loop
		trigger self move
	}

	
	
	// This function is called periodicly by a func_timer entity in the map.
	// Each time it checks a counter to see if the escort has been gone too
	// long. The counter is reset by the escort trigger function.
	trigger timer
	{
		// Increase counter, and if it hasn't reached 4 then abort
		accum 3 inc 1
		accum 3 abort_if_less_than 4
		
		// Update state bits
		accum 0 bitreset 2						// Mark as not escorted, which means it will stop at next waypoint

		// Need to periodicly check if the tank has been damaged
		trigger self check_death
	}
	
	


	
	//----------------------------------------------------------------------
	// Waypoint functions that checks if it can proceed to the next waypoint
	//----------------------------------------------------------------------

	// Check if its broken, and if so change to the broken state
	trigger check_death
	{
		// Check if its broken
		accum 0 abort_if_not_bitset 0		// Abort if not broken
		accum 0 abort_if_bitset 1			// Abort if its already moving
		accum 0 abort_if_bitset	4			// Abort if its already in its broken state
		accum 9 abort_if_not_equal 0		// Abort if the script is currently locked

		// Lock script
		trigger self script_lock

			// This target_kill entity will kill the func_constructible so that an engineer can repair it
			alertentity tank1_kill
		
			// Change from fixed to broken model
			changemodel models/mapobjects/tanks_sd/churchhill_broken.md3

			// Start smoking
			setstate tank1_smoke default

			// Death sound
			trigger self sound_death
			
			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom

			// Update state bits
		    accum 0 bitset 4				// Mark as visually broken state

		// Unlock script
		trigger self script_unlock
	}

	
	
	// Check if it isn't escorted, and if not then stop it
	trigger check_escort
	{
		// Check if its not escorted
		accum 0 abort_if_bitset 2			// Abort if escort is present

		// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom
			
		// Unlock script
		trigger self script_unlock
	}


	
	// Check if there is an obstacle preventing it from continuing to the next waypoint, and if so then stop it
	trigger check_obstacle
	{
		// Update obstacle bit (with the help of the waypoint counter and some of the obstacle functions)
		trigger self check_obstacle_status
		accum 0 abort_if_not_bitset 3		// Abort if no obstacles in the way
		
		// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom
			
		// Unlock script
		trigger self script_unlock
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Obstacle functions
	//----------------------------------------------------------------------

	// Dispatching obstacle checking function
	trigger check_obstacle_status
	{
		accum 0 bitreset 3				// Mark as no obstacles in the way
		accum 2 trigger_if_equal 3 tank1 obstacle_000_check
	}


	
	// First obstacle - Checks if the obstacle is blocking the way
	trigger obstacle_000_check
	{
		accum 1 abort_if_not_bitset 0	// Abort if the obstacle has been removed
		accum 0 bitset 0				// Mark as an obstacle in the way
	}
	
	// First obstacle - Called by the death routine in another entity, once the obstacle is destroyed
	trigger obstacle_000_removed
	{
		accum 1 bitreset 0				// Mark obstacle as removed
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Misc. functions
	//----------------------------------------------------------------------
	trigger script_lock {
		accum 9 inc 1
		}
	
	trigger script_unlock {
		accum 9 inc -1
		}


		
	
		
	//----------------------------------------------------------------------
	// Move functions
	//----------------------------------------------------------------------
	
	// Dispatching move function
	trigger move
	{
		// The obstacle bit is still valid because of the obstacle check done by the calling function
		accum 0 abort_if_bitset 3			// Abort if an obstacle is in the way

		// List of waypoints to go to
		accum 2 trigger_if_equal 1 tank1 move_to_001
		accum 2 trigger_if_equal 2 tank1 move_to_002
		accum 2 trigger_if_equal 3 tank1 move_to_003
		accum 2 trigger_if_equal 4 tank1 move_to_004
		accum 2 trigger_if_equal 5 tank1 move_to_005
		accum 2 trigger_if_equal 6 tank1 move_to_006
		accum 2 trigger_if_equal 7 tank1 move_to_007
	}


	
	// Called at the end of each move. If it passes some checks the movement is repeated
	trigger move_increment
	{
		accum 2 inc 1						// Increment waypoint counter

		// Check if its ok to proceed to the next waypoint
		trigger self check_death
		trigger self check_escort
		trigger self check_obstacle

		// This loop is used so that the tank can immediately advance after completing the move
		trigger self move
	}

	
	
	// Move to waypoint 001
	trigger move_to_001
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_00 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 002
	trigger move_to_002
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_0 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 003
	trigger move_to_003
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_01 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving

		// If there is a need to do something after it passes an obstacle then this is the place to do it.
		// Ex. hiding func_constructible for the obstacle or voice overs

		trigger self move_increment
	}

	// Move to waypoint 004
	trigger move_to_004
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_02 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 005
	trigger move_to_005
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_03 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment

	}

	// Move to waypoint 006
	trigger move_to_006
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_04 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 007
	trigger move_to_007
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_05 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
           

// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom

		    // Wait a little until starting the fireing sequence
		    wait 900
			
			// Manually increment waypoint counter
			accum 2 inc 1
			
			// This turret function will unlock the script when its done
			trigger tank1_turret fire_at_target_1
		
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Tank sounds
	//----------------------------------------------------------------------
	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
	}




	
	//----------------------------------------------------------------------
	// Tank animations
	//----------------------------------------------------------------------
	trigger anim_tracks_forward
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	
	trigger anim_tracks_turningleft
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_backward
		remapshaderflush
	}
	
	trigger anim_tracks_turningright
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_backward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	
	trigger anim_tracks_stop
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_r
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_r
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_l
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_l
		remapshaderflush
	}

	trigger anim_fire_start
	{
		startanimation 67 8 10 nolerp norandom
	}
	
	trigger anim_fire_stop
	{
		startanimation 0 1 15 nolerp norandom
	}
}





//======================================================================
// Tank turret
//======================================================================

tank1_turret
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}


	
	//----------------------------------------------------------------------
	// Turret sequence
	//----------------------------------------------------------------------
	trigger fire_at_target_1
	{
		// Wait a little until starting sequence
		wait 1000

		// Turn turret towards target
		trigger tank1_sound turret_turn_start
		faceangles 0 60 0 4000						// Adjust angles to match the target
		trigger tank1_sound turret_turn_stop
		wait 500

		// Fire at target
		trigger tank1_sound turret_fire
		trigger tank1 anim_fire_start
		setstate tank1_flash default
		wait 50
		setstate tank1_flash invisible
		wait 200
		trigger tank1 anim_fire_stop

		// BUG: Apparently the entitys scriptblock is completely removed after its blown up the first time
		trigger target_000 blow_up
		wait 1000

		// Turn turret back to target
		trigger tank1_sound turret_turn_start
		faceangles 0 0 0 4000
		trigger tank1_sound turret_turn_stop
			
		// Wait a little until its ready to move again
		wait 500

		// Unlock script
		//trigger tank1 script_unlock
	}


		
	//----------------------------------------------------------------------
	// Turret sounds
	//----------------------------------------------------------------------
	trigger sound_fire
	{
		stopsound
		playsound sound/vehicles/tank/tank_fire.wav volume 300
	}

	trigger sound_turn_start
	{
		stopsound
		playsound sound/vehicles/tank/turret_spin.wav looping volume 127
	}

	trigger sound_turn_stop
	{
		stopsound
		playsound sound/vehicles/tank/turret_end.wav volume 96
	}
}





//======================================================================
// The following are related entities which are attached because they need to follow the script_mover
//======================================================================

tank1_enabler_trigger
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}
}



tank1_flash
{
	spawn
	{
		// Wait for host entity to spawn
		wait 200
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1_turret tag_flash
		
		// Hides the flash
		setstate tank1_flash invisible
	}
}



tank1_smoke
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
		
		// Turn off smoking
		alertentity tank1_smoke
	}
}



tank1_toi
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}
}





//======================================================================
// The following are the remaining entities
//======================================================================

tank1_construct
{
	spawn
	{
		// Needed for the icon to reappear correctly on the command map
		constructible_class 2
	}
	
	// Called when the repairs are starting
	buildstart final
	{
	}

	// Called when the repairs have failed
	decayed final
	{
	}
	
	// Called when the repairs have failed
	failed
	{
	}
		
	// Called when the repairs are done
	built final
	{
		// Resurrect the entity. This fills up its health and trigger the ::rebirth function
		alertentity tank1
	}
}

tank1_disabler
{
	spawn
	{
	}

	trigger run
	{
		// Call the function which controls the escort timeout
		trigger tank1 timer
	}
}

tank1_enabler
{
	spawn
	{
	}

	trigger run
	{
		// Call the function which handles the escort
		trigger tank1 escort_trigger
	}
}

tank1_kill
{
	spawn
	{
	}
}

tank1_timer
{
	spawn
	{
	}
}






//======================================================================
// This block contains sound redirectors. Since commands are executed in order
// the only way to have multiple waits at the same time is to play them through another scriptblock
//======================================================================

tank1_sound
{
	spawn
	{
	}
	
	trigger start
	{
		trigger tank1 sound_start
		wait 3400
		trigger tank1 sound_move
	}
	
	trigger stop
	{
		trigger tank1 sound_stop
		wait 1400
		trigger tank1 sound_idle
	}
	
	trigger rebirth
	{
		trigger tank1 sound_rebirth
		wait 1400
		trigger tank1 sound_idle
	}

	trigger turret_fire
	{
		trigger tank1_turret sound_fire
	}

	trigger turret_turn_start
	{
		trigger tank1_turret sound_turn_start
	}

	trigger turret_turn_stop
	{
		trigger tank1_turret sound_turn_stop
	}
}











//======================================================================
// OBSTACLES
//======================================================================

obstacle_000
{
	spawn
	{
	}
	
	pain
	{
	}
	
	death
	{
		// Notify relevant parts of the script that the obstacle has been destroyed
		trigger tank1 obstacle_000_removed
	}
}











//======================================================================
// TARGETS
//======================================================================
//
// Slot	Used for
// ====	========
// 0	State:
//		- Bit 0: Broken						0 = No		1 = Yes
//
target_000
{
	spawn
	{
		// Reset state bits
		accum 0 bitset 0					// Mark as not blown up
	}
	
	pain
	{
	}
	
	// If you need to notify other parts of the script that the target has been removed, then do it here.
	death
	{
	}
	
	// Called when the entity should be destroyed
	trigger blow_up
	{
		// Check if we have already been blown up
		accum 0 abort_if_not_bitset 0		// Abort if already blown up
		
		// Update state bits
		accum 0 bitreset 0					// Mark as blown up

		// Blow up
		alertentity target_000
	}
}

so in a nutshell – tank starts when being escorted runs for 3 Splines then breaks down - just like if a axis had destroyed it – I can even rebuild it and it continues on like normal works great after i rebuild it

so someone please find out where in my code its telling it to break down lol

thanks


(CooperHawkes) #6

c’mon… it isn’t THAT hard! just read the comments in the script!
hint: scan for “Abort if an obstacle is in the way”


(codejockey13) #7

how about just remove the obsticle check.

comment out the code:

trigger self check_obstacle 

then it won’t set that bit


(BloodLusts) #8

ok well i got it so far

the tank works now - it can be escorted to the Gates - and it blasts the gates – However after the gates are Blown axis cannot destroy the tank - that needs to be fixed & when it blows the gates i cant get it to trigger any OBJ info lmao

game_manager
{
	spawn
	{
		wm_axis_respawntime		1
		wm_allied_respawntime	1
		wm_set_round_timelimit	20

		setchargetimefactor 0 soldier		0
		setchargetimefactor 0 medic			0
		setchargetimefactor 0 engineer		0
		setchargetimefactor 0 fieldops		0
		setchargetimefactor 0 covertops		0

		setchargetimefactor 1 soldier		0
		setchargetimefactor 1 medic			0
		setchargetimefactor 1 engineer		0
		setchargetimefactor 1 fieldops		0
		setchargetimefactor 1 covertops		0


	}
}


//======================================================================
// TANK
//======================================================================
//
// Slot	Used for
// ====	========
// 0	State:
//		- Bit 0: Broken						0 = No		1 = Yes
//		- Bit 1: Moving						0 = No		1 = Yes
//		- Bit 2: Escort present				0 = No		1 = Yes
//		- Bit 3: Obstacle in the way		0 = No		1 = Yes
//		- Bit 4: Model shown broken			0 = No		1 = Yes
// 1	Path state:
//		- Bit 0: Obstacle 000 present		0 = No		1 = Yes
// 2	Waypoint counter
// 3	Stop timer
// 4	***unused***
// 5	***unused***
// 6	***unused***
// 7	***unused***
// 8	***unused***
// 9	Script lockout counter
//
tank1
{
	//----------------------------------------------------------------------
	// The following are events that this entity is capable of triggering
	//----------------------------------------------------------------------
	spawn
	{
		// Set variables to defaults
		accum 0 set 0			// State
            accum 1 bitreset 0		
		accum 1 bitset 0		      // Set obstacle 0 as present
		accum 3 set 0			// Reset stop timer
		accum 9 set 0			// Reset script lockout counter

		// Wait for entities to spawn
		wait 100
		
		// Set initial position to the first waypoint
		followspline 0 spl_000 10000
		accum 2 set 1

		// Set default state (ie. tank ready)
		trigger self sound_idle
		trigger self anim_tracks_stop
		setstate tank1_smoke invisible
	}
	

	
	// Called when the entity is hurt
	pain
	{
	}
	
	
	
	// Called when the entity is destroyed
	death
	{
		// Update state bits
		accum 0 bitset 0
		wm_announce	"Axis have Destroyed The Tank!"						// Mark as broken, which mean it will stop at next waypoint
		wm_addteamvoiceannounce 1 "allies_hq_tank_damaged_axis"
		wm_teamvoiceannounce 1 "allies_hq_tank_damaged_axis"
	}
	
	
	
	// Indirectly called when the entity is repaired
	rebirth
	{
		// Lock script
		trigger self script_lock
		
			// Change from broken to fixed model
			changemodel models/mapobjects/tanks_sd/churchhill.md3
	
			// Remove smoke
			setstate tank1_smoke invisible
	
			// Start
			trigger tank1_sound rebirth
			wait 500

			// Update state bits
		       wm_announce	"Allies have repaired The Tank!"			
			accum 0 bitreset 0					// Mark as not broken
		    accum 0 bitreset 4					// Mark as visually not broken
		
		// Unlock script
		trigger self script_unlock
	}
	
	
	
	// Called when a player is using the mounted MG
	mg42 mount
	{
	}
	
	
	
	// Called when a player is no longer using the mounted MG
	mg42 unmount
	{
	}
	

	
	
	
	//----------------------------------------------------------------------
	// Trigger functions
	//----------------------------------------------------------------------

	// This function is called when a player moves inside the escort zone
	trigger escort_trigger
	{
		// Check for obstacles
		trigger self check_obstacle_status

		// Update state bits and counters
		accum 0 bitset 2				// Mark as escort present
		accum 3 set 0					// Reset stop timer
		
		// Check if allowed to move
		accum 0 abort_if_bitset 0		// Abort if its broken
		accum 0 abort_if_bitset 1		// Abort if its already moving
		accum 0 abort_if_bitset 3		// Abort if an obstacle is in the way
		accum 9 abort_if_not_equal 0	      // Abort if the script is currently locked
		
		// Lock script
		trigger self script_lock
		
			// Starting state
			trigger tank1_sound start
			startanimation 55 10 15 nolerp norandom
			wait 666

			// Driving state
			trigger self anim_tracks_forward
			startanimation 5 40 15 nolerp norandom

			// Wait a bit before starting to move
			wait 500
			
		// Unlock script
		trigger self script_unlock
		
		// Start movement loop
		trigger self move
	}

	
	
	// This function is called periodicly by a func_timer entity in the map.
	// Each time it checks a counter to see if the escort has been gone too
	// long. The counter is reset by the escort trigger function.
	trigger timer
	{
		// Increase counter, and if it hasn't reached 4 then abort
		accum 3 inc 1
		accum 3 abort_if_less_than 4
		
		// Update state bits
		accum 0 bitreset 2						// Mark as not escorted, which means it will stop at next waypoint

		// Need to periodicly check if the tank has been damaged
		trigger self check_death
	}
	
	


	
	//----------------------------------------------------------------------
	// Waypoint functions that checks if it can proceed to the next waypoint
	//----------------------------------------------------------------------

	// Check if its broken, and if so change to the broken state
	trigger check_death
	{
		// Check if its broken
		accum 0 abort_if_not_bitset 0		// Abort if not broken
		accum 0 abort_if_bitset 1			// Abort if its already moving
		accum 0 abort_if_bitset	4			// Abort if its already in its broken state
		accum 9 abort_if_not_equal 0		// Abort if the script is currently locked

		// Lock script
		trigger self script_lock

			// This target_kill entity will kill the func_constructible so that an engineer can repair it
			alertentity tank1_kill
		
			// Change from fixed to broken model
			changemodel models/mapobjects/tanks_sd/churchhill_broken.md3

			// Start smoking
			setstate tank1_smoke default

			// Death sound
			trigger self sound_death
			
			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom

			// Update state bits
		    accum 0 bitset 4				// Mark as visually broken state

		// Unlock script
		trigger self script_unlock
	}

	
	
	// Check if it isn't escorted, and if not then stop it
	trigger check_escort
	{
		// Check if its not escorted
		accum 0 abort_if_bitset 2			// Abort if escort is present

		// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom
			
		// Unlock script
		trigger self script_unlock
	}


	
	// Check if there is an obstacle preventing it from continuing to the next waypoint, and if so then stop it
	trigger check_obstacle
	{
		// Update obstacle bit (with the help of the waypoint counter and some of the obstacle functions)
		trigger self check_obstacle_status
		accum 0 abort_if_not_bitset 3		// Abort if no obstacles in the way
		
		// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom
			
		// Unlock script
		trigger self script_unlock
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Obstacle functions
	//----------------------------------------------------------------------

	// Dispatching obstacle checking function
	trigger check_obstacle_status
	{
		accum 0 bitreset 3				// Mark as no obstacles in the way
		accum 2 trigger_if_equal 3 tank1 obstacle_000_check
	}


	
	// First obstacle - Checks if the obstacle is blocking the way
	trigger obstacle_000_check
	{
		accum 1 abort_if_not_bitset 0	// Abort if the obstacle has been removed
		accum 3 bitset 0				// Mark as an obstacle in the way
	}
	
	// First obstacle - Called by the death routine in another entity, once the obstacle is destroyed
	trigger obstacle_000_removed
	{
		accum 1 bitreset 0				// Mark obstacle as removed
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Misc. functions
	//----------------------------------------------------------------------
	trigger script_lock {
		accum 9 inc 1
		}
	
	trigger script_unlock {
		accum 9 inc -1
		}


		
	
		
	//----------------------------------------------------------------------
	// Move functions
	//----------------------------------------------------------------------
	
	// Dispatching move function
	trigger move
	{
		// The obstacle bit is still valid because of the obstacle check done by the calling function
		accum 0 abort_if_bitset 3			// Abort if an obstacle is in the way

		// List of waypoints to go to
		accum 2 trigger_if_equal 1 tank1 move_to_001
		accum 2 trigger_if_equal 2 tank1 move_to_002
		accum 2 trigger_if_equal 3 tank1 move_to_003
		accum 2 trigger_if_equal 4 tank1 move_to_004
		accum 2 trigger_if_equal 5 tank1 move_to_005
		accum 2 trigger_if_equal 6 tank1 move_to_006
		accum 2 trigger_if_equal 7 tank1 move_to_007
		accum 2 trigger_if_equal 8 tank1 move_to_008
		accum 2 trigger_if_equal 9 tank1 move_to_009

	}


	
	// Called at the end of each move. If it passes some checks the movement is repeated
	trigger move_increment
	{
		accum 2 inc 1						// Increment waypoint counter

		// Check if its ok to proceed to the next waypoint
		trigger self check_death
		trigger self check_escort
		trigger self check_obstacle

		// This loop is used so that the tank can immediately advance after completing the move
		trigger self move
	}

	
	
	// Move to waypoint 001
	trigger move_to_001
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_00 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 002
	trigger move_to_002
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_0 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 003
	trigger move_to_003
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_01 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving

		// If there is a need to do something after it passes an obstacle then this is the place to do it.
		// Ex. hiding func_constructible for the obstacle or voice overs

		trigger self move_increment
	}

	// Move to waypoint 004
	trigger move_to_004
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_02 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 005
	trigger move_to_005
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_03 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment

	}


	// Move to waypoint 006
	trigger move_to_006
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_04 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}


	// Move to waypoint 007
	trigger move_to_007
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_05 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 008
	trigger move_to_008
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_06 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}


// Move to waypoint 009
	trigger move_to_009
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_07 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
           
// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom

		    // Wait a little until starting the fireing sequence
		    wait 900
			
			// Manually increment waypoint counter
			//accum 2 inc 1
			
			// This turret function will unlock the script when its done
			trigger tank1_turret fire_at_target_1

	}

	
	
	
	
	//----------------------------------------------------------------------
	// Tank sounds
	//----------------------------------------------------------------------
	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
	}




	
	//----------------------------------------------------------------------
	// Tank animations
	//----------------------------------------------------------------------
	trigger anim_tracks_forward
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	
	trigger anim_tracks_turningleft
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_backward
		remapshaderflush
	}
	
	trigger anim_tracks_turningright
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_backward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	
	trigger anim_tracks_stop
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_r
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_r
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_l
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_l
		remapshaderflush
	}

	trigger anim_fire_start
	{
		startanimation 67 8 10 nolerp norandom
	}
	
	trigger anim_fire_stop
	{
		startanimation 0 1 15 nolerp norandom
	}
}





//======================================================================
// Tank turret
//======================================================================

tank1_turret
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}


	
	//----------------------------------------------------------------------
	// Turret sequence
	//----------------------------------------------------------------------
	trigger fire_at_target_1
	{
		// Wait a little until starting sequence
		wait 1000

		// Turn turret towards target
		trigger tank1_sound turret_turn_start
		faceangles 0 -50 0 4000						// Adjust angles to match the target
		trigger tank1_sound turret_turn_stop
		wait 500

		// Fire at target
		trigger tank1_sound turret_fire
		trigger tank1 anim_fire_start
		setstate tank1_flash default
		wait 50
		setstate tank1_flash invisible
		wait 200
		trigger tank1 anim_fire_stop

		// BUG: Apparently the entitys scriptblock is completely removed after its blown up the first time
		trigger target_000 blow_up
		wait 1000

		// Turn turret back to target
		trigger tank1_sound turret_turn_start
		faceangles 0 0 0 4000
		trigger tank1_sound turret_turn_stop
			
		// Wait a little until its ready to move again
		wait 500

		// Unlock script
		trigger tank1 script_unlock
	}


		
	//----------------------------------------------------------------------
	// Turret sounds
	//----------------------------------------------------------------------
	trigger sound_fire
	{
		stopsound
		playsound sound/vehicles/tank/tank_fire.wav volume 300
	}

	trigger sound_turn_start
	{
		stopsound
		playsound sound/vehicles/tank/turret_spin.wav looping volume 127
	}

	trigger sound_turn_stop
	{
		stopsound
		playsound sound/vehicles/tank/turret_end.wav volume 96
	}
}





//======================================================================
// The following are related entities which are attached because they need to follow the script_mover
//======================================================================

tank1_enabler_trigger
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}
}



tank1_flash
{
	spawn
	{
		// Wait for host entity to spawn
		wait 200
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1_turret tag_flash
		
		// Hides the flash
		setstate tank1_flash invisible
	}
}



tank1_smoke
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
		
		// Turn off smoking
		alertentity tank1_smoke
	}
}



tank1_toi
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}
}





//======================================================================
// The following are the remaining entities
//======================================================================

tank1_construct
{
	spawn
	{
		// Needed for the icon to reappear correctly on the command map
		constructible_class 2
	}
	
	// Called when the repairs are starting
	buildstart final
	{
	}

	// Called when the repairs have failed
	decayed final
	{
	}
	
	// Called when the repairs have failed
	failed
	{
	}
		
	// Called when the repairs are done
	built final
	{
		// Resurrect the entity. This fills up its health and trigger the ::rebirth function
		alertentity tank1
	}
}

tank1_disabler
{
	spawn
	{
	}

	trigger run
	{
		// Call the function which controls the escort timeout
		trigger tank1 timer
	}
}

tank1_enabler
{
	spawn
	{
	}

	trigger run
	{
		// Call the function which handles the escort
		trigger tank1 escort_trigger
	}
}

tank1_kill
{
	spawn
	{
	}
}

tank1_timer
{
	spawn
	{
	}
}






//======================================================================
// This block contains sound redirectors. Since commands are executed in order
// the only way to have multiple waits at the same time is to play them through another scriptblock
//======================================================================

tank1_sound
{
	spawn
	{
	}
	
	trigger start
	{
		trigger tank1 sound_start
		wait 3400
		trigger tank1 sound_move
	}
	
	trigger stop
	{
		trigger tank1 sound_stop
		wait 1400
		trigger tank1 sound_idle
	}
	
	trigger rebirth
	{
		trigger tank1 sound_rebirth
		wait 1400
		trigger tank1 sound_idle
	}

	trigger turret_fire
	{
		trigger tank1_turret sound_fire
	}

	trigger turret_turn_start
	{
		trigger tank1_turret sound_turn_start
	}

	trigger turret_turn_stop
	{
		trigger tank1_turret sound_turn_stop
	}
}











//======================================================================
// OBSTACLES
//======================================================================

obstacle_000
{
	spawn
	{
	}
	
	pain
	{
	}
	
	death
	{
		// Notify relevant parts of the script that the obstacle has been destroyed
		trigger tank1 obstacle_000_removed
	}
}











//======================================================================
// TARGETS
//======================================================================
//
// Slot	Used for
// ====	========
// 0	State:
//		- Bit 0: Broken						0 = No		1 = Yes
//
target_000
{
	spawn
	{
		// Reset state bits
		accum 0 bitset 0					// Mark as not blown up
	}
	
	pain
	{
	}
	
	// If you need to notify other parts of the script that the target has been removed, then do it here.
	death
	{
		wm_announce	"Allies have Blasted The Axis Storage Gates!"
	}
	
	// Called when the entity should be destroyed
	trigger blow_up
	{
		// Check if we have already been blown up
		accum 0 abort_if_not_bitset 0		// Abort if already blown up
		
		// Update state bits
		accum 0 bitreset 0					// Mark as blown up

		// Blow up
		alertentity target_000
	}
}

construction_script
{
   spawn
   {
      wait 200
      constructible_class 1
	constructible_health 1
      setstate construction_materials invisible
   }

   buildstart final
   {
   }

   built final
   {
      setstate construction_materials invisible

      // Some kind of UI pop-up to alert players
      wm_announce   "The Firing Range has been Rebuilt"
   }

   decayed final
   {
      trigger self startup
   }

   death
   {
      // Some kind of UI pop-up to alert players
      wm_announce   "The Firing Range needs to be Rebuilt"
      setstate construction_materials default
   }

   trigger startup
   {

      setstate construction_materials invisible

   }
} 

thats the code with part of the gate obj stuff in it - can someone just post me the code to add that one Obj - im lost on ET scripts i used to script for RTCW and do some maps for it easy - ET just changed a ton of stuff


(S14Y3R) #9

first of all, KNOW this: Accum’s are local to a routine. so you don’t need to set it differently for every friggin thing. accum 1 of script_routine_one({}) has nothing to do with accum 1 of script_routine_two({}) so you can set them up logically(cleanly) without having to worry about them interfering with anything else.

eg. accums within the whole tank script are “only” for the tank unless specified otherwise by globalaccum.

spawn 
   { 
      // Set variables to defaults 
      accum 0 set 0         // State 
            accum 1 bitreset 0       
      accum 1 bitset 0            // Set obstacle 0 as present 
      accum 3 set 0         // Reset stop timer 
      accum 9 set 0         // Reset script lockout counter 

      // Wait for entities to spawn 
      wait 100 
       
      // Set initial position to the first waypoint 
      followspline 0 spl_000 10000 
      accum 2 set 1 

      // Set default state (ie. tank ready) 
      trigger self sound_idle 
      trigger self anim_tracks_stop 
      setstate tank1_smoke invisible 
   }

so you can organize this better without having to worry about accum 2 in door_5, know what I mean?

remove this:

// Called when the entity is hurt 
   pain 
   { 
   }

-when damaged the"script_mover" calls
death
{
trigger dying stuff
}
there is no “pain” to it, exept for the damage bar, so make sure you set health/$$ and description/“target_name” entity keys for health bar going down.

remove this:


 // Called when a player is using the mounted MG 
   mg42 mount 
   { 
   } 
       
   // Called when a player is no longer using the mounted MG 
   mg42 unmount 
   { 
   }

the script_mover’s model has a “tag” that the gun is attached to, set in script_movers entity checkbox mounted gun, it isn’t called from the script. It’s in the tank script_movers entity tags…

In this:


        // This function is called when a player moves inside the escort zone 
   trigger escort_trigger 
   { 
      // Check for obstacles 
      trigger self check_obstacle_status 

      // Update state bits and counters 
      accum 0 bitset 2            // Mark as escort present 
      accum 3 set 0               // Reset stop timer 
       
      // Check if allowed to move 
      accum 0 abort_if_bitset 0      // Abort if its broken 
      accum 0 abort_if_bitset 1      // Abort if its already moving 
      accum 0 abort_if_bitset 3      // Abort if an obstacle is in the way 
      accum 9 abort_if_not_equal 0         // Abort if the script is currently locked 
       
      // Lock script 
      trigger self script_lock 
       
         // Starting state 
         trigger tank1_sound start 
         startanimation 55 10 15 nolerp norandom 
         wait 666 

         // Driving state 
         trigger self anim_tracks_forward 
         startanimation 5 40 15 nolerp norandom 

         // Wait a bit before starting to move 
         wait 500 
          
      // Unlock script 
      trigger self script_unlock 
       
      // Start movement loop 
      trigger self move 
   }

remove :accum 0 abort_if_bitset 3 , as something is setting bitset 3 of accum 0 of tank1 script(constuctable?) locking it.

You copy/pasted this from someone else, eh?

 // This function is called periodicly by a func_timer entity in the map. 
   // Each time it checks a counter to see if the escort has been gone too 
   // long. The counter is reset by the escort trigger function. 

:eek: :bump:
Its better to learn what’s going on than trying to decifer anothers misinterpretation.
The func_timer that targets your disable_target_script_trigger goes off every half a second, sometimes a whole second, depending, so it is more relevant than most think.

Anyway: :moo:

Anything to do with stopping is in your stuck_check.(read your level designers manual). What the func_timer does is try to keep a closed circuit(always trying to stop the vehicle/tank/crane/whatever) , a player in the trigger keeps it(circuit) open to move it, unless a switch(constructable) says different. So anything that can/or will interfere with this relationship will stop the cycle. so if the vihicle “thinks” there’s a barrier, it will break the cycle therefore stopping the vehicle. So go over your stuck_check more thouroughly and remove what isn’t needed.

so in other words take out:

accum 0 abort_if_bitset 3

(BloodLusts) #10

yes its a copied script from someone elses tutorial – it had MANY MANY Errors that i fixed myself - however this last one i cant get working

  • The tank functions 100% Correctly - runs to Point B being escorted - blows the gate etc…

However like i said after u blow the gate – if a allies walks up to the tank it tries to move again - but has no spline to goto - cuz well its on the last one –

so it plays that darned animation of moving and sound of moving etc… – and i can blow it up via Axis if i do it like that – but i need it to Sit Idle after blowing the gate - and have the ability to be blasted and repaired etc…

ok i tried ur suggestion - it didnt work
what happened when i tried ur sugestion was – when i stepped near the tank after it blew the gates - it just warped backwards to the spline behind it - and ran to the gates and played the animation of blowing the gates all over again

  • so still im LOST – All i need is a constructible / destructible / repairable tank that allies escort to a Gate – it Blows the Gate and Stops moving all togather – so axis can use the Gun on it or Blow it up and allies Vice Versa – so far it works except for the sitting idle part and being able to blow up

i am totally lost


(BloodLusts) #11

yes its a copied script from someone elses tutorial – it had MANY MANY Errors that i fixed myself - however this last one i cant get working

  • The tank functions 100% Correctly - runs to Point B being escorted - blows the gate etc…

However like i said after u blow the gate – if a allies walks up to the tank it tries to move again - but has no spline to goto - cuz well its on the last one –

so it plays that darned animation of moving and sound of moving etc… – and i can blow it up via Axis if i do it like that – but i need it to Sit Idle after blowing the gate - and have the ability to be blasted and repaired etc…

ok i tried ur suggestion - it didnt work
what happened when i tried ur sugestion was – when i stepped near the tank after it blew the gates - it just warped backwards to the spline behind it - and ran to the gates and played the animation of blowing the gates all over again

  • so still im LOST – All i need is a constructible / destructible / repairable tank that allies escort to a Gate – it Blows the Gate and Stops moving all togather – so axis can use the Gun on it or Blow it up and allies Vice Versa – so far it works except for the sitting idle part and being able to blow up

i am totally lost


(BloodLusts) #12

Hrm it Double Posted – NEWS UPDATE here

I have the tank now where it blasts the Gate and Sits Idle even if ur in the Escort Zone – When a axis blows the tank up it says they destroyed the tank - BUT the tank doesnt go and show the Destroyed Model – so its really screwy

Here is my code now -

game_manager
{
	spawn
	{
		wm_axis_respawntime		1
		wm_allied_respawntime	1
		wm_set_round_timelimit	20

		setchargetimefactor 0 soldier		0
		setchargetimefactor 0 medic			0
		setchargetimefactor 0 engineer		0
		setchargetimefactor 0 fieldops		0
		setchargetimefactor 0 covertops		0

		setchargetimefactor 1 soldier		0
		setchargetimefactor 1 medic			0
		setchargetimefactor 1 engineer		0
		setchargetimefactor 1 fieldops		0
		setchargetimefactor 1 covertops		0


	}
}


//======================================================================
// TANK
//======================================================================
//
// Slot	Used for
// ====	========
// 0	State:
//		- Bit 0: Broken						0 = No		1 = Yes
//		- Bit 1: Moving						0 = No		1 = Yes
//		- Bit 2: Escort present				0 = No		1 = Yes
//		- Bit 3: Obstacle in the way		0 = No		1 = Yes
//		- Bit 4: Model shown broken			0 = No		1 = Yes
// 1	Path state:
//		- Bit 0: Obstacle 000 present		0 = No		1 = Yes
// 2	Waypoint counter
// 3	Stop timer
// 4	***unused***
// 5	***unused***
// 6	***unused***
// 7	***unused***
// 8	***unused***
// 9	Script lockout counter
//
tank1
{
	//----------------------------------------------------------------------
	// The following are events that this entity is capable of triggering
	//----------------------------------------------------------------------
	spawn
	{
		// Set variables to defaults
		accum 0 set 0			// State
            accum 1 bitreset 0		
		accum 1 bitset 0		      // Set obstacle 0 as present
		accum 3 set 0			// Reset stop timer
		accum 9 set 0			// Reset script lockout counter

		// Wait for entities to spawn
		wait 100
		
		// Set initial position to the first waypoint
		followspline 0 spl_000 10000
		accum 2 set 1

		// Set default state (ie. tank ready)
		trigger self sound_idle
		trigger self anim_tracks_stop
		setstate tank1_smoke invisible
	}
	

	
	// Called when the entity is hurt
	pain
	{
	}
	
	
	
	// Called when the entity is destroyed
	death
	{
		// Update state bits
		accum 0 bitset 0
		wm_announce	"Axis have Destroyed The Tank!"						// Mark as broken, which mean it will stop at next waypoint
		wm_addteamvoiceannounce 1 "allies_hq_tank_damaged_axis"

		wm_teamvoiceannounce 0 "axis_hq_tank_damaged"

		wm_teamvoiceannounce 1 "allies_hq_tank_damaged_axis"

		wm_removeteamvoiceannounce 0 "axis_hq_tank_stop"
	}
	
	
	
	// Indirectly called when the entity is repaired
	rebirth
	{
		// Lock script
		trigger self script_lock
		
			// Change from broken to fixed model
			changemodel models/mapobjects/tanks_sd/churchhill.md3
	
			// Remove smoke
			setstate tank1_smoke invisible
			wm_addteamvoiceannounce 0 "axis_hq_tank_stop"

			wm_teamvoiceannounce 0 "axis_hq_tank_repaired_allies"

			wm_teamvoiceannounce 1 "allies_hq_tank_repaired"

			wm_removeteamvoiceannounce 1 "allies_hq_tank_damaged_axis"
	
			// Start
			trigger tank1_sound rebirth
			wait 500

			// Update state bits
		       wm_announce	"Allies have repaired The Tank!"			
			accum 0 bitreset 0					// Mark as not broken
		    accum 0 bitreset 4					// Mark as visually not broken
		// Unlock script
		trigger self script_unlock
	}
	
	
	
	// Called when a player is using the mounted MG
	mg42 mount
	{
	}
	
	
	
	// Called when a player is no longer using the mounted MG
	mg42 unmount
	{
	}
	

	
	
	
	//----------------------------------------------------------------------
	// Trigger functions
	//----------------------------------------------------------------------

	// This function is called when a player moves inside the escort zone
	trigger escort_trigger
	{
		// Check for obstacles
		trigger self check_obstacle_status

		// Update state bits and counters
		accum 0 bitset 2				// Mark as escort present
		accum 3 set 0					// Reset stop timer
		
		// Check if allowed to move
		accum 0 abort_if_bitset 0		// Abort if its broken
		accum 0 abort_if_bitset 1		// Abort if its already moving
		accum 0 abort_if_bitset 3		// Abort if an obstacle is in the way
		accum 9 abort_if_not_equal 0	      // Abort if the script is currently locked
		
		// Lock script
		trigger self script_lock
		
			// Starting state
			trigger tank1_sound start
			startanimation 55 10 15 nolerp norandom
			wait 666

			// Driving state
			trigger self anim_tracks_forward
			startanimation 5 40 15 nolerp norandom

			// Wait a bit before starting to move
			wait 500
			
		// Unlock script
		trigger self script_unlock
		
		// Start movement loop
		trigger self move
	}

	
	
	// This function is called periodicly by a func_timer entity in the map.
	// Each time it checks a counter to see if the escort has been gone too
	// long. The counter is reset by the escort trigger function.
	trigger timer
	{
		// Increase counter, and if it hasn't reached 4 then abort
		accum 3 inc 1
		accum 3 abort_if_less_than 4
		
		// Update state bits
		accum 0 bitreset 2						// Mark as not escorted, which means it will stop at next waypoint

		// Need to periodicly check if the tank has been damaged
		trigger self check_death
	}
	
	


	
	//----------------------------------------------------------------------
	// Waypoint functions that checks if it can proceed to the next waypoint
	//----------------------------------------------------------------------

	// Check if its broken, and if so change to the broken state
	trigger check_death
	{
		// Check if its broken
		accum 0 abort_if_not_bitset 0		// Abort if not broken
		accum 0 abort_if_bitset 1			// Abort if its already moving
		accum 0 abort_if_bitset	4			// Abort if its already in its broken state
		accum 9 abort_if_not_equal 0		// Abort if the script is currently locked

		// Lock script
		trigger self script_lock

			// This target_kill entity will kill the func_constructible so that an engineer can repair it
			alertentity tank1_kill
		
			// Change from fixed to broken model
			changemodel models/mapobjects/tanks_sd/churchhill_broken.md3

			// Start smoking
			setstate tank1_smoke default

			// Death sound
			trigger self sound_death
			
			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom

			// Update state bits
		    accum 0 bitset 4				// Mark as visually broken state

		// Unlock script
		trigger self script_unlock
	}

	
	
	// Check if it isn't escorted, and if not then stop it
	trigger check_escort
	{
		// Check if its not escorted
		accum 0 abort_if_bitset 2			// Abort if escort is present

		// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom
			
		// Unlock script
		trigger self script_unlock
	}


	
	// Check if there is an obstacle preventing it from continuing to the next waypoint, and if so then stop it
	trigger check_obstacle
	{
		// Update obstacle bit (with the help of the waypoint counter and some of the obstacle functions)
		trigger self check_obstacle_status
		accum 0 abort_if_not_bitset 3		// Abort if no obstacles in the way
		
		// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom
			
		// Unlock script
		trigger self script_unlock
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Obstacle functions
	//----------------------------------------------------------------------

	// Dispatching obstacle checking function
	trigger check_obstacle_status
	{
		accum 0 bitreset 3				// Mark as no obstacles in the way
		accum 2 trigger_if_equal 3 tank1 obstacle_000_check
	}


	
	// First obstacle - Checks if the obstacle is blocking the way
	trigger obstacle_000_check
	{
		accum 1 abort_if_not_bitset 0	// Abort if the obstacle has been removed
		accum 3 bitset 0				// Mark as an obstacle in the way
	}
	
	// First obstacle - Called by the death routine in another entity, once the obstacle is destroyed
	trigger obstacle_000_removed
	{
		accum 1 bitreset 0				// Mark obstacle as removed
	}

	
	
	
	
	//----------------------------------------------------------------------
	// Misc. functions
	//----------------------------------------------------------------------
	trigger script_lock {
		accum 9 inc 1
		}
	
	trigger script_unlock {
		accum 9 inc -1
		}


		
	
		
	//----------------------------------------------------------------------
	// Move functions
	//----------------------------------------------------------------------
	
	// Dispatching move function
	trigger move
	{
		// The obstacle bit is still valid because of the obstacle check done by the calling function
		accum 0 abort_if_bitset 3			// Abort if an obstacle is in the way

		// List of waypoints to go to
		accum 2 trigger_if_equal 1 tank1 move_to_001
		accum 2 trigger_if_equal 2 tank1 move_to_002
		accum 2 trigger_if_equal 3 tank1 move_to_003
		accum 2 trigger_if_equal 4 tank1 move_to_004
		accum 2 trigger_if_equal 5 tank1 move_to_005
		accum 2 trigger_if_equal 6 tank1 move_to_006
		accum 2 trigger_if_equal 7 tank1 move_to_007
		accum 2 trigger_if_equal 8 tank1 move_to_008
		accum 2 trigger_if_equal 9 tank1 move_to_009

	}


	
	// Called at the end of each move. If it passes some checks the movement is repeated
	trigger move_increment
	{
		accum 2 inc 1						// Increment waypoint counter

		// Check if its ok to proceed to the next waypoint
		trigger self check_death
		trigger self check_escort
		trigger self check_obstacle

		// This loop is used so that the tank can immediately advance after completing the move
		trigger self move
	}

	
	
	// Move to waypoint 001
	trigger move_to_001
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_00 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 002
	trigger move_to_002
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_0 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 003
	trigger move_to_003
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_01 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving

		// If there is a need to do something after it passes an obstacle then this is the place to do it.
		// Ex. hiding func_constructible for the obstacle or voice overs

		trigger self move_increment
	}

	// Move to waypoint 004
	trigger move_to_004
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_02 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 005
	trigger move_to_005
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_03 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment

	}


	// Move to waypoint 006
	trigger move_to_006
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_04 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}


	// Move to waypoint 007
	trigger move_to_007
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_05 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}

	// Move to waypoint 008
	trigger move_to_008
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_06 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
		trigger self move_increment
	}


// Move to waypoint 009
	trigger move_to_009
	{
		accum 0 bitset 1			// Mark as moving
		followspline 0 spl_07 80 wait length -64
		accum 0 bitreset 1			// Mark as not moving
           
// Lock script
		trigger self script_lock

			// Stop sound
			trigger tank1_sound stop

			// Stopping state
			trigger self anim_tracks_stop
		    startanimation 45 10 15 nolerp norandom
		    wait 666

			// Stationary state
		    startanimation 0 1 15 nolerp norandom

		    // Wait a little until starting the fireing sequence
		    wait 900
			
			// Manually increment waypoint counter
		      accum 2 inc 1
			
			// This turret function will unlock the script when its done
			trigger tank1_turret fire_at_target_1
			trigger fullstop

	}

	
	
	//----------------------------------------------------------------------
	// Tank sounds
	//----------------------------------------------------------------------
	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
	}




	
	//----------------------------------------------------------------------
	// Tank animations
	//----------------------------------------------------------------------
	trigger anim_tracks_forward
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	
	trigger anim_tracks_turningleft
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_backward
		remapshaderflush
	}
	
	trigger anim_tracks_turningright
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_backward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	
	trigger anim_tracks_stop
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_r
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_r
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_l
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_l
		remapshaderflush
	}

	trigger anim_fire_start
	{
		startanimation 67 8 10 nolerp norandom
	}
	
	trigger anim_fire_stop
	{
		startanimation 0 1 15 nolerp norandom
	}
}





//======================================================================
// Tank turret
//======================================================================

tank1_turret
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}


	
	//----------------------------------------------------------------------
	// Turret sequence
	//----------------------------------------------------------------------
	trigger fire_at_target_1
	{
		// Wait a little until starting sequence
		wait 1000

		// Turn turret towards target
		trigger tank1_sound turret_turn_start
		faceangles 0 -60 0 4000						// Adjust angles to match the target
		trigger tank1_sound turret_turn_stop
		wait 500

		// Fire at target
		trigger tank1_sound turret_fire
		trigger tank1 anim_fire_start
		setstate tank1_flash default
		wait 50
		setstate tank1_flash invisible
		wait 200
		trigger tank1 anim_fire_stop

		// BUG: Apparently the entitys scriptblock is completely removed after its blown up the first time
		trigger target_000 blow_up
		wait 1000

		// Turn turret back to target
		trigger tank1_sound turret_turn_start
		faceangles 0 0 0 4000
		trigger tank1_sound turret_turn_stop
			
		// Wait a little until its ready to move again
		wait 500

		// Unlock script
		//trigger tank1 script_unlock
	}


		
	//----------------------------------------------------------------------
	// Turret sounds
	//----------------------------------------------------------------------
	trigger sound_fire
	{
		stopsound
		playsound sound/vehicles/tank/tank_fire.wav volume 300
	}

	trigger sound_turn_start
	{
		stopsound
		playsound sound/vehicles/tank/turret_spin.wav looping volume 127
	}

	trigger sound_turn_stop
	{
		stopsound
		playsound sound/vehicles/tank/turret_end.wav volume 96
	}
}





//======================================================================
// The following are related entities which are attached because they need to follow the script_mover
//======================================================================

tank1_enabler_trigger
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}
}



tank1_flash
{
	spawn
	{
		// Wait for host entity to spawn
		wait 200
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1_turret tag_flash
		
		// Hides the flash
		setstate tank1_flash invisible
	}
}



tank1_smoke
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
		
		// Turn off smoking
		alertentity tank1_smoke
	}
}



tank1_toi
{
	spawn
	{
		// Wait for host entity to spawn
		wait 100
		
		// Attaches itself to a tag on the script_mover
		attachtotag tank1 tag_turret
	}
}





//======================================================================
// The following are the remaining entities
//======================================================================

tank1_construct
{
	spawn
	{
		// Needed for the icon to reappear correctly on the command map
		constructible_class 2
	}
	
	// Called when the repairs are starting
	buildstart final
	{
	}

	// Called when the repairs have failed
	decayed final
	{
	}
	
	// Called when the repairs have failed
	failed
	{
	}
		
	// Called when the repairs are done
	built final
	{
		// Resurrect the entity. This fills up its health and trigger the ::rebirth function
		alertentity tank1
	}
}

tank1_disabler
{
	spawn
	{
	}

	trigger run
	{
		// Call the function which controls the escort timeout
		trigger tank1 timer
	}
}

tank1_enabler
{
	spawn
	{
	}

	trigger run
	{
		// Call the function which handles the escort
		trigger tank1 escort_trigger
	}
}

tank1_kill
{
	spawn
	{
	}
}

tank1_timer
{
	spawn
	{
	}
}






//======================================================================
// This block contains sound redirectors. Since commands are executed in order
// the only way to have multiple waits at the same time is to play them through another scriptblock
//======================================================================

tank1_sound
{
	spawn
	{
	}
	
	trigger start
	{
		trigger tank1 sound_start
		wait 3400
		trigger tank1 sound_move
	}
	
	trigger stop
	{
		trigger tank1 sound_stop
		wait 1400
		trigger tank1 sound_idle
	}
	
	trigger rebirth
	{
		trigger tank1 sound_rebirth
		wait 1400
		trigger tank1 sound_idle
	}

	trigger turret_fire
	{
		trigger tank1_turret sound_fire
	}

	trigger turret_turn_start
	{
		trigger tank1_turret sound_turn_start
	}

	trigger turret_turn_stop
	{
		trigger tank1_turret sound_turn_stop
	}
}











//======================================================================
// OBSTACLES
//======================================================================

obstacle_000
{
	spawn
	{
	}
	
	pain
	{
	}
	
	death
	{
		// Notify relevant parts of the script that the obstacle has been destroyed
		trigger tank1 obstacle_000_removed
	}
}











//======================================================================
// TARGETS
//======================================================================
//
// Slot	Used for
// ====	========
// 0	State:
//		- Bit 0: Broken						0 = No		1 = Yes
//
target_000
{
	spawn
	{
		// Reset state bits
		accum 0 bitset 0					// Mark as not blown up
	}
	
	pain
	{
	}
	
	// If you need to notify other parts of the script that the target has been removed, then do it here.
	death
	{
		wm_announce	"Allies have Blasted The Axis Storage Gates!"
	}
	
	// Called when the entity should be destroyed
	trigger blow_up
	{
		// Check if we have already been blown up
		accum 0 abort_if_not_bitset 0		// Abort if already blown up
		
		// Update state bits
		accum 0 bitreset 0					// Mark as blown up

		// Blow up
		alertentity target_000
	}
}

(codejockey13) #13

If you would like a working tank with a working script that runs to the end of the spline path and shoots its turret go here

http://webpages.charter.net/ettutorial

and grab my Churchill.zip. I feel it’s easier to read than the script you are working with.

I also hooked a ladder clip on it so there is no problem climbing onto the tank.


(BloodLusts) #14

Thaks for that link - im playing with that script now – lol - ill for sure post if i need help


(BloodLusts) #15

Everything works perfect except for – after the tank blows the Gates – if Axis try to destroy it - it says tank has been destroyed etc… but it doesnt change the display to show a damanged tank –


game_manager
{
	spawn
	{
		// Game rules
		wm_axis_respawntime	10
		wm_allied_respawntime	10
		//wm_number_of_objectives 1
		wm_set_round_timelimit	35

		//wm_objective_status 1 0 0 // <objective team status>
		//wm_set_main_objective		1	0
		//wm_set_main_objective		1	1

		wm_setwinner 0
	
		//accum 1 set 0		
	}
}

//********************************************************
// TANK ROUTINES                                         *
//********************************************************

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
	}
}


//********************************************************
// digibob: converting truck script from goldrush over...
// ============================================================================
// 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
// ===========================================================================================
// spline points are spln2 -> spln78
// ===========================================================================================
// track events:
//  - tracks_forward
//  - tracks_stop
//  - tracks_turn_left
//  - tracks_turn_right

tank
{
	spawn
	{
		changemodel models/mapobjects/tanks_sd/churchhill.md3

		wait 400

		followspline 0 spln1 50000 length 32 wait

		trigger tank sound_idle
	}

	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
	}

// ===========================================================================================
	trigger tracks_forward
	{
		accum 1 abort_if_bitset 5
		accum 1 bitset 5

		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}

	trigger tracks_turningleft
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_backward
		remapshaderflush
	}

	trigger tracks_turningright
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_backward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}

	trigger tracks_stop
	{
		accum 1 abort_if_not_bitset 5
		accum 1 bitreset 5

		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_r
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_r
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_l
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_l
		remapshaderflush
	}
// ===========================================================================================

	trigger run_continue
	{
		accum 3 inc 1
		trigger self deathcheck
		trigger self stopcheck
		trigger self move
	}

	trigger move_check
	{
		trigger self stuck_check
		accum 1 abort_if_bitset 3

		trigger tank tracks_forward

		trigger self dispatch
	}

	trigger move
	{
		trigger self move_check

		wait 500

		trigger self move
	}

	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
		accum 3 trigger_if_equal 11 tank run_11
		accum 3 trigger_if_equal 12 tank run_12
		accum 3 trigger_if_equal 13 tank run_13
		accum 3 trigger_if_equal 14 tank run_14
		accum 3 trigger_if_equal 15 tank run_15
		accum 3 trigger_if_equal 16 tank run_16
		accum 3 trigger_if_equal 17 tank run_17
		accum 3 trigger_if_equal 18 tank run_18
		accum 3 trigger_if_equal 19 tank run_19
		accum 3 trigger_if_equal 20 tank run_20
		accum 3 trigger_if_equal 21 tank run_21
		accum 3 trigger_if_equal 22 tank run_22
		accum 3 trigger_if_equal 23 tank run_23
		accum 3 trigger_if_equal 24 tank run_end
		accum 3 trigger_if_equal 25 tank run_end
//		accum 3 trigger_if_equal 26 tank run_26
//		accum 3 trigger_if_equal 27 tank run_27
//		accum 3 trigger_if_equal 28 tank run_28
//		accum 3 trigger_if_equal 29 tank run_29
//		accum 3 trigger_if_equal 30 tank run_30
//		accum 3 trigger_if_equal 31 tank run_31
//		accum 3 trigger_if_equal 32 tank run_32
//		accum 3 trigger_if_equal 33 tank run_33
//		accum 3 trigger_if_equal 34 tank run_34
//		accum 3 trigger_if_equal 35 tank run_35
//		accum 3 trigger_if_equal 36 tank run_36
//		accum 3 trigger_if_equal 37 tank run_37
//		accum 3 trigger_if_equal 38 tank run_38
//		accum 3 trigger_if_equal 39 tank run_39
//		accum 3 trigger_if_equal 40 tank run_40
//		accum 3 trigger_if_equal 41 tank run_41
//		accum 3 trigger_if_equal 42 tank run_42
//		accum 3 trigger_if_equal 43 tank run_43
//		accum 3 trigger_if_equal 44 tank run_44
//		accum 3 trigger_if_equal 45 tank run_45
//		accum 3 trigger_if_equal 46 tank run_46
//		accum 3 trigger_if_equal 47 tank run_47
//		accum 3 trigger_if_equal 48 tank run_48
//		accum 3 trigger_if_equal 49 tank run_49
//		accum 3 trigger_if_equal 50 tank run_50
//		accum 3 trigger_if_equal 51 tank run_51
//		accum 3 trigger_if_equal 52 tank run_52
//		accum 3 trigger_if_equal 53 tank run_53
//		accum 3 trigger_if_equal 54 tank run_54
//		accum 3 trigger_if_equal 55 tank run_55
//		accum 3 trigger_if_equal 56 tank run_56
//		accum 3 trigger_if_equal 57 tank run_57
//		accum 3 trigger_if_equal 58 tank run_58
//		accum 3 trigger_if_equal 59 tank run_59
//		accum 3 trigger_if_equal 60 tank run_60
//		accum 3 trigger_if_equal 61 tank run_61
//		accum 3 trigger_if_equal 62 tank run_62
//		accum 3 trigger_if_equal 63 tank run_63
//		accum 3 trigger_if_equal 64 tank run_64
//		accum 3 trigger_if_equal 65 tank run_65
//		accum 3 trigger_if_equal 66 tank run_66
//		accum 3 trigger_if_equal 67 tank run_67
//		accum 3 trigger_if_equal 68 tank run_68
//		accum 3 trigger_if_equal 69 tank run_69
//		accum 3 trigger_if_equal 70 tank run_70
//		accum 3 trigger_if_equal 71 tank run_71
//		accum 3 trigger_if_equal 72 tank run_72
//		accum 3 trigger_if_equal 73 tank run_73
//		accum 3 trigger_if_equal 74 tank run_74
//		accum 3 trigger_if_equal 75 tank run_75
//		accum 3 trigger_if_equal 76 tank run_end

		trigger self run_continue

	}
//********************************************************
// this sets the tracks in motion and follows one spline *
// to the next.                                          *
//********************************************************
	trigger run_0
	{
		
		accum 1 bitset 2
		followspline 0 spln2 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}
//********************************************************
// at this spline you can see where it calls the         *
// game manager to state the allies stole the tank       *
//********************************************************
	trigger run_1
	{
		

		accum 1 bitset 2
		followspline 0 spln3 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_2
	{
		

		accum 1 bitset 2
		followspline 0 spln4 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_3
	{
		

		accum 1 bitset 2
		followspline 0 spln5 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_4
	{
		

		accum 1 bitset 2
		followspline 0 spln6 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_5
	{
		

		accum 1 bitset 2
		followspline 0 spln7 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_6
	{
		

		accum 1 bitset 2
		followspline 0 spln8 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_7
	{
		

		accum 1 bitset 2
		followspline 0 spln9 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_8
	{
		

		accum 1 bitset 2
		followspline 0 spln10 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_9
	{
		

		accum 1 bitset 2
		followspline 0 spln11 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_10
	{
		

		accum 1 bitset 2
		followspline 0 spln12 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_11
	{
		

		accum 1 bitset 2
		followspline 0 spln13 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_12
	{
		

		accum 1 bitset 2
		followspline 0 spln14 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_13
	{
		trigger self tracks_turn_right

		accum 1 bitset 2
		followspline 0 spln15 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_14
	{
		

		accum 1 bitset 2
		followspline 0 spln16 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_15
	{
		

		accum 1 bitset 2
		followspline 0 spln17 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_16
	{
		

		accum 1 bitset 2
		followspline 0 spln18 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_17
	{
		

		accum 1 bitset 2
		followspline 0 spln19 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_18
	{
		

		accum 1 bitset 2
		followspline 0 spln20 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_19
	{
		

		accum 1 bitset 2
		followspline 0 spln21 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_20
	{
		

		accum 1 bitset 2
		followspline 0 spln22 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_21
	{
		

		accum 1 bitset 2
		followspline 0 spln23 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_22
	{
		

		accum 1 bitset 2
		followspline 0 spln24 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_23
	{
		

		accum 1 bitset 2
		followspline 0 spln25 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_24
	{
		

		accum 1 bitset 2
		followspline 0 spln26 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_25
	{
		

		accum 1 bitset 2
		followspline 0 spln27 50 wait length 32
		accum 1 bitreset 2

		trigger self run_continue
	}

	trigger run_end
	{
		
		trigger self script_lockout

		trigger tank_sound 	stop
		trigger tank tracks_stop

		wm_objective_status 2 0 2
		wm_objective_status 2 1 1

		startanimation 45 10 15 nolerp norandom
		wait 666
		startanimation 0 1 15 nolerp norandom

		wait 900

		trigger tank_turret turn

		accum 3 inc 100

		trigger self script_lockout_stop

	}

	trigger stuck_check
	{
		accum 1 bitreset 3

		trigger self stuck_check_barrier1_built
		trigger self stuck_check_barrier2_built
		trigger self stuck_check_scriptlockout
		trigger self stuck_check_finished
	}

	trigger stuck_check_finished
	{
//**************************************************************
//* stopping at spline 5 rather than 77 to make the tank stuck *
//* at the end of the splines.  ie stop the tank at the end    *
//* of its run.                                                *
//**************************************************************
//		accum 3 abort_if_less_than 77

		accum 3 abort_if_less_than 25

		accum 1 bitset 3
	}

	trigger stuck_check_scriptlockout
	{
		accum 5 abort_if_equal 0

		accum 1 bitset 3
	}

	trigger stuck_check_barrier1_built
	{
		accum 3 abort_if_not_equal 23

		accum 1 abort_if_not_bitset 0

		accum 1 bitset 3
	}

	trigger stuck_check_barrier1_built_msg
	{
		accum 1 abort_if_not_bitset 0

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "goldrush_allies_tankbar_destroy"
		// *---------------------------------------------------------------------------------*
	}

	trigger stuck_check_barrier2_built
	{
		accum 3 abort_if_not_equal 67

		accum 1 abort_if_not_bitset 1

		accum 1 bitset 3
	}

	trigger stuck_check_barrier2_built_msg
	{
		accum 1 abort_if_not_bitset 1

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "goldrush_allies_tankbar_destroy"
		// *---------------------------------------------------------------------------------*
	}

	trigger stopcheck_setup
	{
		accum 1 bitset 6				// stop if we're stuck

		accum 1 abort_if_bitset 8		// no one in the trigger around tank to make it move, 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
	}

	trigger stopcheck
	{
		trigger self stopcheck_setup
		accum 1 abort_if_not_bitset 6

		trigger self script_lockout

		// Any just stopped moving stuff goes here
		trigger tank_sound 	stop

		trigger tank 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 script_lockout
	{
		accum 5 inc 1
	}

	trigger script_lockout_stop
	{
		accum 5 inc -1
	}

	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

		// Any just started moving stuff goes here

		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 script_lockout_stop

		trigger self move
	}

	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
	}

	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/churchhill.md3

		setstate tank_smoke invisible

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_tank_stop"

		wm_teamvoiceannounce 0 "axis_hq_tank_repaired_allies"

		wm_teamvoiceannounce 1 "allies_hq_tank_repaired"

		wm_removeteamvoiceannounce 1 "allies_hq_tank_damaged_axis"
		// *---------------------------------------------------------------------------------*

		trigger tank_sound rebirth
		wait 500

		trigger self script_lockout_stop
	}

	death
	{
		accum 1 bitset 7
	      wm_announce "The Tank has been damaged!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 1 "allies_hq_tank_damaged_axis"

		wm_teamvoiceannounce 0 "axis_hq_tank_damaged"

		wm_teamvoiceannounce 1 "allies_hq_tank_damaged_axis"

		wm_removeteamvoiceannounce 0 "axis_hq_tank_stop"
		// *---------------------------------------------------------------------------------*
	}

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

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

		trigger self deathcheck_message
		accum 1 bitset 4

		setstate tank_smoke default

		changemodel models/mapobjects/tanks_sd/churchhill_broken.md3

		kill tank_construct

		trigger self sound_death

		trigger self script_lockout

		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
      // }

	trigger startfire
	{
		startanimation 67 8 10 nolerp norandom noloop
	}

	trigger stopfire
	{
		startanimation 0 1 15 nolerp norandom
	}

	trigger enable_stage2
	{
		accum 1 bitreset 0
	}

	trigger disable_stage2
	{
		accum 1 bitset 0
	}

	trigger enable_stage4
	{
		accum 1 bitreset 1
	}

	trigger disable_stage4
	{
		accum 1 bitset 1
	}
}

tank_trigger
{
	spawn
	{
		wait 500

		attachtotag tank tag_turret
		trigger tank_trigger bot_goal_loop
	}

	trigger bot_goal_loop
	{
		wait 4000	// check every 4 seconds
		trigger tank bot_active_check
		trigger tank_trigger bot_goal_loop
	}
}

tank_build
{
	spawn
	{
		wait 500

		attachtotag tank 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_turret
{
	spawn
	{
		wait 500
		attachtotag tank tag_turret
	}

	trigger turn
	{
		wait 1000
		playsound sound/vehicles/tank/turret_spin.wav looping
		faceangles 0 -80 0 3000
		stopsound
		playsound sound/vehicles/tank/turret_end.wav

		wait 500

		trigger tank startfire
		playsound sound/vehicles/tank/tank_fire.wav

//		trigger boomtrigger boom_all		// triggers the hurts around bank explosions (each has its own wait for timing)

		trigger tank_flash run

		wait 200
		trigger tank stopfire
		trigger self blow_doors
	}

	trigger blow_doors
	{
		setstate tank_flash invisible

		wait 200

		alertentity target_000
		alertentity door_effect
		//setstate doorframe invisible
		//setstate doorframe_damaged default

		wm_announce "Allies have Destroyed The Storage Gates!"
		//accum 1 set 1
		//wm_objective_status 1 0 2
		//wm_objective_status 1 1 1

		//wm_set_main_objective		1	0
		//wm_set_main_objective		1	1

		wait 100

		//trigger bank_door2_damaged bankbackboom

		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
	}
}


tank_flash
{
	spawn
	{
		setstate tank_flash invisible
	}

	trigger run
	{
		setstate tank_flash default

 		attachtotag tank_turret tag_flash
		faceangles 0 90 0 50

		wait 50
		
		setstate tank_flash invisible

//		trigger tank_turret blow_doors
	}
}

tank_disabler
{
	spawn
	{
		wait 200
	}

	trigger run
	{
		trigger tank tank_disable
	}
}

tank_enabler
{
	spawn
	{
		wait 200
	}

	trigger run
	{
		trigger tank tank_enable
	}
}

tank_smoke
{
	spawn
	{
		wait 300

		attachtotag tank tag_smoke
		setstate tank_smoke invisible
	}
}

tank_ladder
{
	spawn
	{
		wait 300

		attachtotag tank tag_turret
	}
}

I think it has something to do with the Accum settings for it - and suuch but i have no clue


(codejockey13) #16

yah after i posted for you to go get it i doubled checked it and found that bug too. here’s the fix for it:

first add a run_continue

// accum 3 trigger_if_equal 71 tank run_71
// accum 3 trigger_if_equal 72 tank run_72
// accum 3 trigger_if_equal 73 tank run_73
// accum 3 trigger_if_equal 74 tank run_74
// accum 3 trigger_if_equal 75 tank run_75
// accum 3 trigger_if_equal 76 tank run_end

	trigger self run_continue    &lt;--- this line here

and in this routine:

trigger run_end
{
	
	trigger self script_lockout

	trigger tank_sound 	stop
	trigger tank tracks_stop

	wm_objective_status 2 0 2
	wm_objective_status 2 1 1

	startanimation 45 10 15 nolerp norandom
	wait 666
	startanimation 0 1 15 nolerp norandom

	wait 900

	trigger tank_turret turn

	accum 3 inc 100

	trigger self script_lockout_stop    &lt;--- add this line here

}

After those two fixes you should be good to go. sorry for the mishap.


(BloodLusts) #17

umm those lines are already in there dude

Those exact lines are there double check the code i posted

they are already there

anymore advice?


(codejockey13) #18

accum 3 trigger_if_equal 23 tank run_23
accum 3 trigger_if_equal 24 tank run_end
accum 3 trigger_if_equal 25 tank run_end

maybe comment out the if equal 25 but not real sure at the moment

:frowning: