//Punch Battle
//MAP BY JEDRAS
//Thanks to all tersters: Kamil, Kratek, Xan, szkarlatyn, BONEMAN, elypter, Magnus, JackS, Wojti, FirstBlood, Aim, Andrej, Baron, YoGhurt
//based on elypter's script
//2015

PLAYER_PED p1 = (158.5, 137.5, 5.0) 16 180
PLAYER_PED p2 = (156.5, 137.5, 5.0) 17 180
PLAYER_PED p3 = (160.5, 137.5, 5.0) 51 180
PLAYER_PED p4 = (154.5, 137.5, 5.0) 45 180
PLAYER_PED p5 = (159.5, 127.5, 5.0) 34 0
PLAYER_PED p6 = (156.5, 127.5, 5.0) 50 0

GENERATOR e_fingers_1 = (160.5, 137.5, 5.0) 0 COLLECT_37 1 1 1
GENERATOR e_fingers_2 = (154.5, 137.5, 5.0) 0 COLLECT_37 1 1 1
GENERATOR e_fingers_3 = (157.5, 132.5, 2.0) 0 COLLECT_37 3000 3000 1
GENERATOR ebaton_1 = (154.5, 135.5, 4.0) 0 COLLECT_07 200 200 88
GENERATOR ebaton_2 = (160.5, 135.5, 4.0) 0 COLLECT_07 200 200 88
GENERATOR ebaton_3 = (157.5, 132.5, 5.0) 0 COLLECT_07 200 200 88
GENERATOR gran = (157.5, 128.5, 6.0) 0 COLLECT_05 1500 1500 1
GENERATOR health = (160.5, 127.5, 6.0) 0 COLLECT_30 1000 1000 1
GENERATOR pist = (154.5, 129.5, 6.0) 0 COLLECT_00 1000 1000 8
GENERATOR inv = (157.5, 133.5, 2.0) 0 COLLECT_39 7500 7500 1

COUNTER mainloop = 1
COUNTER p1_expunch = 0
COUNTER p1_trg_punched = 0
COUNTER p1_killpunch = 0
CHAR_DATA p1_punched

COUNTER p2_expunch = 0
COUNTER p2_trg_punched = 0
COUNTER p2_killpunch = 0
CHAR_DATA p2_punched

COUNTER p3_expunch = 0
COUNTER p3_trg_punched = 0
COUNTER p3_killpunch = 0
CHAR_DATA p3_punched

COUNTER p4_expunch = 0
COUNTER p4_trg_punched = 0
COUNTER p4_killpunch = 0
CHAR_DATA p4_punched

COUNTER p5_expunch = 0
COUNTER p5_trg_punched = 0
COUNTER p5_killpunch = 0
CHAR_DATA p5_punched

COUNTER p6_expunch = 0
COUNTER p6_trg_punched = 0
COUNTER p6_killpunch = 0
CHAR_DATA p6_punched

COUNTER tmr_expunch = 1
COUNTER col_expunch = 1
COUNTER res_expunch = 1500
OBJ_DATA obj_expunch

SOUND club01 = (157.5,133.5,5.0) STRIP_CLUB PLAY_FOREVER
SET_GANG_INFO (islagang, 06, DUAL_PISTOL,DUAL_PISTOL,DUAL_PISTOL,
               0, 0.0,0.0,0.0, 0, GRAHAM, 30)

PARKED_CAR_DATA plane01 = (148.5,145.5,5.0) -1 300 TOWTRUCK
PARKED_CAR_DATA plane02 = (150.5,145.5,5.0) -1 300 TOWTRUCK
PARKED_CAR_DATA plane03 = (152.5,145.5,5.0) -1 300 TOWTRUCK
PARKED_CAR_DATA plane04 = (154.5,145.5,5.0) -1 300 TOWTRUCK
PARKED_CAR_DATA plane05 = (156.5,145.5,5.0) -1 300 TOWTRUCK
PARKED_CAR_DATA plane06 = (158.5,145.5,5.0) -1 300 TOWTRUCK
PARKED_CAR_DATA plane07 = (160.5,145.5,5.0) -1 300 TOWTRUCK
PARKED_CAR_DATA plane08 = (162.5,145.5,5.0) -1 300 TOWTRUCK
PARKED_CAR_DATA plane09 = (164.5,145.5,5.0) -1 300 TOWTRUCK
PARKED_CAR_DATA plane10 = (166.5,145.5,5.0) -1 300 TOWTRUCK

LEVELSTART
SET_AMBIENT_LEVEL (0.45, 0)
SWITCH_GENERATOR (e_fingers_1, OFF)
SWITCH_GENERATOR (e_fingers_2, OFF)
SWITCH_GENERATOR (e_fingers_3, OFF)
SWITCH_GENERATOR (ebaton_1, ON)
SWITCH_GENERATOR (ebaton_2, ON)
SWITCH_GENERATOR (ebaton_3, OFF)
SWITCH_GENERATOR (gran, ON)
SWITCH_GENERATOR (health, OFF)
SWITCH_GENERATOR (pist, OFF)
SWITCH_GENERATOR (inv, ON)

WHILE_EXEC(mainloop=1)
SET_CHAR_GRAPHIC_TYPE (p1, DUMMY_GRAPHIC, 16)
SET_CHAR_GRAPHIC_TYPE (p2, DUMMY_GRAPHIC, 17)
SET_CHAR_GRAPHIC_TYPE (p3, DUMMY_GRAPHIC, 51)
SET_CHAR_GRAPHIC_TYPE (p4, DUMMY_GRAPHIC, 45)
SET_CHAR_GRAPHIC_TYPE (p5, DUMMY_GRAPHIC, 34)
SET_CHAR_GRAPHIC_TYPE (p6, DUMMY_GRAPHIC, 50)

//PLAYER 1
IF (CHECK_CHARACTER_HEALTH(p1, 0)) 
	IF ( HAS_CHARACTER_DIED (p1))
		SET p1_expunch = 0
		SET p1_killpunch = 0
		REMOVE_WEAPONS (p1)
	ENDIF
	IF ((LOCATE_CHARACTER_ANY_MEANS (p1, 157.5, 127.5, 5.0 , 0.8 , 0.8)) AND (col_expunch = 0))
		SET tmr_expunch = 0
		SET p1_trg_punched = 0
		SET p1_expunch = 1
	ENDIF
	IF ((( HAS_CHAR_PUNCHED_SOMEONE (p1)) AND (p1_trg_punched = 0)) AND (p1_expunch = 1))
		STORE_LAST_CHAR_PUNCHED (p1, p1_punched)
		SET p1_killpunch = 0
		SET p1_trg_punched = 1	
	ENDIF
	IF ((p1_trg_punched = 1) AND (p1_expunch = 1))
		IF (NOT (DELAY (20)))
			EXPLODE_SMALL (p1_punched)
			SET p1_trg_punched = 0
			SET p1_expunch = 0
			SET p1_killpunch = 1
			ADD_SCORE(p1, 4000)
		ENDIF
	ENDIF
	IF ((( HAS_CHAR_PUNCHED_SOMEONE (p1)) AND (p1_expunch = 0)) AND (p1_killpunch = 0))
		STORE_LAST_CHAR_PUNCHED (p1, p1_punched )
		SET p1_killpunch = 1
		SET p2_killpunch = 0
		SET p3_killpunch = 0
		SET p4_killpunch = 0
		SET p5_killpunch = 0
		SET p6_killpunch = 0
	ENDIF
	IF ( p1_killpunch = 1 )
 		IF (NOT (DELAY (5)))
			KILL_CHAR (p1_punched)
			SET p1_killpunch = 0
   		ENDIF
	ENDIF
ENDIF

//PLAYER 2
IF (CHECK_CHARACTER_HEALTH(p2, 0))
	IF ( HAS_CHARACTER_DIED ( p2))
		SET p2_expunch = 0
		SET p2_killpunch = 0
		REMOVE_WEAPONS (p2)
	ENDIF
	IF ((LOCATE_CHARACTER_ANY_MEANS (p2, 157.5, 127.5, 5.0 , 0.8 , 0.8 )) AND (col_expunch = 0))
		SET tmr_expunch = 0
		SET p2_trg_punched = 0
		SET p2_expunch = 1
	ENDIF
	IF ((( HAS_CHAR_PUNCHED_SOMEONE (p2)) AND (p2_trg_punched = 0)) AND (p2_expunch = 1 ))
		STORE_LAST_CHAR_PUNCHED (p2 , p2_punched)
		SET p2_killpunch = 0
		SET p2_trg_punched = 1
	ENDIF
	IF ((p2_trg_punched = 1) AND (p2_expunch = 1))
		IF (NOT (DELAY ( 20)))
			EXPLODE_SMALL (p2_punched)
			SET p2_trg_punched = 0
			SET p2_expunch = 0
			SET p2_killpunch = 1
			ADD_SCORE(p2, 4000)
		ENDIF
	ENDIF
	IF (((HAS_CHAR_PUNCHED_SOMEONE (p2)) AND (p2_expunch = 0)) AND (p2_killpunch = 0))
		STORE_LAST_CHAR_PUNCHED (p2 , p2_punched)
		SET p2_killpunch = 1
		SET p1_killpunch = 0
		SET p3_killpunch = 0
		SET p4_killpunch = 0
		SET p5_killpunch = 0
		SET p6_killpunch = 0
	ENDIF
	IF ( p2_killpunch = 1 )
 		IF (NOT (DELAY (5)))
			KILL_CHAR (p2_punched)
			SET p2_killpunch = 0
   		ENDIF
	ENDIF
ENDIF

//PLAYER 3
IF (CHECK_CHARACTER_HEALTH(p3, 0))
	IF ( HAS_CHARACTER_DIED (p3))
		SET p3_expunch = 0
		SET p3_killpunch = 0
		REMOVE_WEAPONS (p3)
	ENDIF
	IF ((LOCATE_CHARACTER_ANY_MEANS (p3, 157.5, 127.5, 5.0 , 0.8 , 0.8)) AND (col_expunch = 0))
		SET tmr_expunch = 0
		SET p3_trg_punched = 0
		SET p3_expunch = 1
	ENDIF
	IF ((( HAS_CHAR_PUNCHED_SOMEONE (p3)) AND ( p3_trg_punched = 0)) AND (p3_expunch = 1))
		STORE_LAST_CHAR_PUNCHED (p3, p3_punched)
		SET p3_killpunch = 0
		SET p3_trg_punched = 1
	ENDIF
	IF (( p3_trg_punched = 1 ) AND ( p3_expunch = 1))
		IF (NOT (DELAY (20)))
			EXPLODE_SMALL (p3_punched)
			SET p3_trg_punched = 0
   			SET p3_expunch = 0
			SET p3_killpunch = 1
			ADD_SCORE(p3, 4000)
		ENDIF
	ENDIF
 	IF (((HAS_CHAR_PUNCHED_SOMEONE (p3)) AND (p3_expunch = 0)) AND (p3_killpunch = 0))
		STORE_LAST_CHAR_PUNCHED (p3, p3_punched )
		SET p3_killpunch = 1
		SET p1_killpunch = 0
		SET p2_killpunch = 0
		SET p4_killpunch = 0
		SET p5_killpunch = 0
		SET p6_killpunch = 0
	ENDIF
	IF ( p3_killpunch = 1)
		IF (NOT (DELAY (5)))
			KILL_CHAR (p3_punched)
			SET p3_killpunch = 0
		ENDIF
	ENDIF
ENDIF

//PLAYER 4
IF (CHECK_CHARACTER_HEALTH(p4, 0))
	IF ( HAS_CHARACTER_DIED (p4))
		SET p4_expunch = 0
		SET p4_killpunch = 0
		REMOVE_WEAPONS (p4)
	ENDIF
	IF ((LOCATE_CHARACTER_ANY_MEANS (p4 , 157.5, 127.5, 5.0 , 0.8 , 0.8)) AND (col_expunch = 0))
		SET tmr_expunch = 0
		SET p4_trg_punched = 0
		SET p4_expunch = 1
	ENDIF
	IF (((HAS_CHAR_PUNCHED_SOMEONE (p4)) AND (p4_trg_punched = 0)) AND (p4_expunch = 1))
		STORE_LAST_CHAR_PUNCHED (p4, p4_punched )
		SET p4_trg_punched = 1
 		SET p4_killpunch = 0
	ENDIF
	IF ((p4_trg_punched = 1 ) AND ( p4_expunch = 1))
		IF (NOT (DELAY (20)))
			EXPLODE_SMALL (p4_punched)
			SET p4_trg_punched = 0
   			SET p4_expunch = 0
			SET p4_killpunch = 1
  			ADD_SCORE(p4, 4000)
		ENDIF
	ENDIF
 	IF (((HAS_CHAR_PUNCHED_SOMEONE ( p4)) AND (p4_expunch = 0)) AND (p4_killpunch = 0))
		STORE_LAST_CHAR_PUNCHED (p4, p4_punched)
		SET p4_killpunch = 1
		SET p1_killpunch = 0
		SET p2_killpunch = 0
		SET p3_killpunch = 0
		SET p5_killpunch = 0
		SET p6_killpunch = 0
	ENDIF
	IF (p4_killpunch = 1)
		IF (NOT (DELAY (5)))
			KILL_CHAR (p4_punched)
			SET p4_killpunch = 0
		ENDIF
	ENDIF
ENDIF

//PLAYER 5
IF (CHECK_CHARACTER_HEALTH(p5, 0))
	IF ( HAS_CHARACTER_DIED (p5))
		SET p5_expunch = 0
		SET p5_killpunch = 0
		REMOVE_WEAPONS (p5)
	ENDIF
	IF ((LOCATE_CHARACTER_ANY_MEANS (p5, 157.5, 127.5, 5.0 , 0.8 , 0.8)) AND (col_expunch = 0))
		SET tmr_expunch = 0
		SET p5_trg_punched = 0
		SET p5_expunch = 1
	ENDIF
	IF (((HAS_CHAR_PUNCHED_SOMEONE (p5)) AND (p5_trg_punched = 0)) AND (p5_expunch = 1))
		STORE_LAST_CHAR_PUNCHED (p5, p5_punched)
		SET p5_trg_punched = 1
  		SET p5_killpunch = 0
	ENDIF
	IF ((p5_trg_punched = 1) AND (p5_expunch = 1))
		IF ( NOT ( DELAY ( 20 ) ) )
			EXPLODE_SMALL (p5_punched)
			SET p5_trg_punched = 0
   			SET p5_expunch = 0
			SET p5_killpunch = 1
   			ADD_SCORE(p5, 4000)
		ENDIF
	ENDIF
 	IF (((HAS_CHAR_PUNCHED_SOMEONE (p5)) AND (p5_expunch = 0)) AND (p5_killpunch = 0))
		STORE_LAST_CHAR_PUNCHED (p5, p5_punched)
		SET p5_killpunch = 1
		SET p1_killpunch = 0
		SET p2_killpunch = 0
		SET p3_killpunch = 0
		SET p4_killpunch = 0
		SET p6_killpunch = 0
	ENDIF
	IF (p5_killpunch = 1)
		IF (NOT (DELAY (5)))
			KILL_CHAR (p5_punched)
			SET p5_killpunch = 0
		ENDIF
	ENDIF
ENDIF

//PLAYER 6
IF (CHECK_CHARACTER_HEALTH(p6, 0))
	IF (HAS_CHARACTER_DIED (p6))
		SET p6_expunch = 0
		SET p6_killpunch = 0
		REMOVE_WEAPONS ( p6 )
	ENDIF
	IF ((LOCATE_CHARACTER_ANY_MEANS (p6, 157.5, 127.5, 5.0 , 0.8 , 0.8)) AND (col_expunch = 0))
		SET tmr_expunch = 0
		SET p6_trg_punched = 0
		SET p6_expunch = 1
	ENDIF
	IF (((HAS_CHAR_PUNCHED_SOMEONE (p6)) AND (p6_trg_punched = 0)) AND (p6_expunch = 1))
		STORE_LAST_CHAR_PUNCHED (p6, p6_punched)
		SET p6_trg_punched = 1
  		SET p6_killpunch = 0
	ENDIF
	IF ((p6_trg_punched = 1) AND (p6_expunch = 1))
		IF (NOT (DELAY (20)))
			EXPLODE_SMALL (p6_punched)
			SET p6_trg_punched = 0
   			SET p6_expunch = 0
			SET p6_killpunch = 1	
   			ADD_SCORE(p6, 4000)
		ENDIF
	ENDIF
 	IF (((HAS_CHAR_PUNCHED_SOMEONE (p6)) AND (p6_expunch = 0)) AND (p6_killpunch = 0))
		STORE_LAST_CHAR_PUNCHED (p6, p6_punched)
		SET p6_killpunch = 1
		SET p1_killpunch = 0
		SET p2_killpunch = 0
		SET p3_killpunch = 0
		SET p4_killpunch = 0
		SET p5_killpunch = 0
	ENDIF
	IF (p6_killpunch = 1)
		IF (NOT (DELAY (5)))
			KILL_CHAR (p6_punched)
			SET p6_killpunch = 0
		ENDIF
	ENDIF
ENDIF

IF (tmr_expunch=0)
	SET tmr_expunch = (res_expunch + 0)
	SET col_expunch = 1
	DELETE_ITEM ( obj_expunch )
	obj_expunch = CREATE_OBJ ( 157.5, 127.5 , 5.0 ) 0 RUBBISH END
	DELETE_ITEM ( obj_expunch )
ENDIF
IF (tmr_expunch>1)
	SET tmr_expunch = ( tmr_expunch - 1 )
ENDIF
IF (tmr_expunch=1)
	SET col_expunch = 0
	SET tmr_expunch = -1
	obj_expunch = CREATE_OBJ ( 157.5, 127.5 , 5.0 ) 0 BRIEFCASE END
ENDIF
ENDWHILE
LEVELEND
