//Script by Pyro and Elypter

// player
PLAYER_PED p1 = (120.5, 120.5, 3.0) 7 270
PLAYER_PED p2 = (118.5, 120.5, 3.0) 8 90
PLAYER_PED p3 = (119.5, 119.5, 3.0) 9 0
PLAYER_PED p4 = (119.5, 121.5, 3.0) 10 180
PLAYER_PED p5 = (118.7, 121.3, 255.0) 11 135
PLAYER_PED p6 = (120.3, 119.7, 255.0) 12 315

OBJ_DATA weapon = (119.5, 120.5) 0 MOVING_COLLECT_09
//OBJ_DATA shop = (121.5, 125.5) 0 BUSY_CAR_SHOP

OBJ_DATA TOWER1 = (129.5, 120.5, 3.1) 0 TOWER
OBJ_DATA TOWER2 = (122.5, 123.5, 3.0) 0 TOWER
OBJ_DATA TOWER3 = (125.5, 116.5, 6.0) 0 TOWER
OBJ_DATA TOWER4 = (128.5, 116.5, 6.0) 0 TOWER
OBJ_DATA TOWER5 = (122.5, 114.5, 3.3) 0 TOWER

// conveyor belts (set animation in map editor!)
CONVEYOR conv1 = (122.0, 115.5, 3.0) (10.0, 1.0) 1 0
CONVEYOR conv2 = (126.5, 119.0) (1.0, 8.0) 0 1
CONVEYOR conv3 = (116.5, 118.0, 2.5) (1.0, 2.0) 0 -1
CONVEYOR conv4 = (121.8, 122.5) (10.5, 1.0) -1 0
CONVEYOR conv5 = (116.5, 121.0, 2.0) (1.0, 4.0) 0 -1
CONVEYOR conv6 = (116.5, 116.3, 3.0) (1.0, 1.5) 0 -1
CONVEYOR conv7 = (116.5, 115.3) (1.0, 0.5) 1 0

// anything that enters this area is destroyed, cars, peds or even the player
DESTRUCTOR crusher_in = (125.5, 115.5, 3.0) (1.0, 1.0)
DESTRUCTOR crusher_out = (116.5, 122.5, 2.0) (1.0, 1.0)

// crushes the car into a small block
CRUSHER crusher1 = (119.5, 120.5)

// setup cranes. first (FIRST) crane picks up car and drops on crusher, second (SECOND) crane picks up crushed car and places it on conveyor
CRANE_DATA crane1 = (121.5, 118.5) 285 NO_HOMECRANE SECOND (121.5, 115.5) 270
CRANE_DATA crane2 = (116.5, 122.5) 115 NO_HOMECRANE SECOND (120.0, 122.5) 180

CRANE_DATA crane3 = (117.5, 117.5) 210 NO_HOMECRANE FIRST (119.5, 120.5) 180
CRANE_DATA crane4 = (120.5, 124.5) 155 NO_HOMECRANE FIRST (119.5, 120.5) 180
CRANE_DATA crane5 = (124.5, 121.5) 150 NO_HOMECRANE FIRST (122.0, 121.5) 180
CRANE_DATA crane6 = (122.5, 113.5) 15 NO_HOMECRANE FIRST (120.5, 116.5) 180

// reward for crushing car
GENERATOR generator_crusher_crane_powerup1 = (126.5, 117.5, 3.0) 0 TYRE 80 80 5
GENERATOR generator_crusher_crane_powerup2 = (116.5, 121.5) 0 TYRE 80 80 5
//GENERATOR generator1 = (126.5, 117.5, 3.0) 0 TYRE 400 400 -1

// declare what cars are accepted on crane and crusher (full list of car names and code on website)
DECLARE_POWERUP_CARLIST ( spider , graham , xk120 , bmw , stripetb , zcx5 , buick , merc , vtype , allard
, tranceam , jeffrey , sprite , t2000gt , tbird , wbtwin , stingray , rtype , stype )

// declare bonus for crane/crusher. needs the name of the SECOND crane, the generator and its X, Y and Z co-ords (no need for float values, and same position as the generator)
DECLARE_CRANE_POWERUP (crane1, generator_crusher_crane_powerup1, 124, 115, 3)
DECLARE_CRANE_POWERUP (crane2, generator_crusher_crane_powerup2, 117, 122, 2)


COUNTER neverends = 1
//COUNTER tmr=782000
//COUNTER tmr2=0

//debug
//ONSCREEN_COUNTER dummy_osc
//ONSCREEN_COUNTER dummy_osc2

LEVELSTART

// switch generators to ON
//SWITCH_GENERATOR ( generator_crusher_crane_powerup1 , ON )
//SWITCH_GENERATOR ( generator_crusher_crane_powerup2 , ON )
//SWITCH_GENERATOR ( generator1 , ON )

//ADD_ONSCREEN_COUNTER  (   dummy_osc  , tmr )
//ADD_ONSCREEN_COUNTER  (   dummy_osc2  , tmr2 )

WHILE_EXEC ( neverends = 1 )
	DO_NOWT
	//SET tmr = (tmr+100)
	//SET tmr2 = (tmr2+1)
	
	IF (CHECK_CHARACTER_HEALTH(p1, 0))
		IF ( LOCATE_CHARACTER_ANY_MEANS ( p1, 123.5, 119.0, 1.0, 15.0, 14.0 ))
			//CONVEYOR belt_north4 = (123.5, 119.0) (15.0, 14.0) 0 -1
			WARP_FROM_CAR_TO_POINT (p1, 119.5, 120.5, 3.0, 0)
		ENDIF
	ENDIF
	
	IF (CHECK_CHARACTER_HEALTH(p2, 0))
		IF ( LOCATE_CHARACTER_ANY_MEANS ( p2, 123.5, 119.0, 1.0, 15.0, 14.0 ))
			//CONVEYOR belt_north4 = (123.5, 119.0) (15.0, 14.0) 0 -1
			WARP_FROM_CAR_TO_POINT (p2, 119.5, 120.5, 3.0, 0)
		ENDIF
	ENDIF
	
	IF (CHECK_CHARACTER_HEALTH(p3, 0))
		IF ( LOCATE_CHARACTER_ANY_MEANS ( p3, 123.5, 119.0, 1.0, 15.0, 14.0 ))
			//CONVEYOR belt_north4 = (123.5, 119.0) (15.0, 14.0) 0 -1
			WARP_FROM_CAR_TO_POINT (p3, 119.5, 120.5, 3.0, 0)
		ENDIF
	ENDIF
	
	IF (CHECK_CHARACTER_HEALTH(p4, 0))
		IF ( LOCATE_CHARACTER_ANY_MEANS ( p4, 123.5, 119.0, 1.0, 15.0, 14.0 ))
			//CONVEYOR belt_north4 = (123.5, 119.0) (15.0, 14.0) 0 -1
			WARP_FROM_CAR_TO_POINT (p4, 119.5, 120.5, 3.0, 0)
		ENDIF
	ENDIF
	
	IF (CHECK_CHARACTER_HEALTH(p5, 0))
		IF ( LOCATE_CHARACTER_ANY_MEANS ( p5, 123.5, 119.0, 1.0, 15.0, 14.0 ))
			//CONVEYOR belt_north4 = (123.5, 119.0) (15.0, 14.0) 0 -1
			WARP_FROM_CAR_TO_POINT (p5, 119.5, 120.5, 3.0, 0)
		ENDIF
	ENDIF
	
	IF (CHECK_CHARACTER_HEALTH(p6, 0))
		IF ( LOCATE_CHARACTER_ANY_MEANS ( p6, 123.5, 119.0, 1.0, 15.0, 14.0 ))
			//CONVEYOR belt_north4 = (123.5, 119.0) (15.0, 14.0) 0 -1
			WARP_FROM_CAR_TO_POINT (p6, 119.5, 120.5, 3.0, 0)
		ENDIF
	ENDIF
ENDWHILE

LEVELEND
