PLAYER_PED grnplayer = ( 111.0 , 113.5 ,255.0 ) 24 180

SET_GANG_INFO ( redngang , 24 , NO_WEAPON , NO_WEAPON , NO_WEAPON , 1 , 1.0 , 1.0 , 2.0 , 0 , PICKUP , 8 )
MAP_ZONE zombie = ( 0 , 0, 0, 0 , 1000 , 0 , 0 , 0, 1000 , 0 , 0 )

//army gang missing

PARKED_CAR_DATA  grntank  =   ( 113.0 , 113.5, 2.0 ) 0 180 tank
PARKED_CAR_DATA trailer = (120.0,131.0,2.0) 19 90 TRUKTRNS

CHAR_DATA bot1
CHAR_DATA bot2
CHAR_DATA bot3
CHAR_DATA bot4
CHAR_DATA bot5

DECLARE_FINISH_SCORE ( 9999999 )
DECLARE_DOOR_INFO ( 128 , 135 , 2 ) 
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXGENERATORsXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
GENERATOR rocket1 = ( 116.5 , 125.5 , 5.0 ) 0 COLLECT_02 240 240 10
GENERATOR molotov1 = ( 115.5 , 125.5 , 5.0 ) 0 COLLECT_04 240 240 10

ARROW_DATA arrow1

COUNTER loop = 1
COUNTER powergen_died = 0
COUNTER powergen_created = 0
COUNTER blocks_removed = 0
COUNTER target_score_reached = 0

OBJ_DATA powergen1

LEVELSTART

CHANGE_GANG_CHAR_RESPECT  ( zombie  ,  grnplayer , -5 ) 

SOUND clock1 = ( 111.0 , 125.5 , 5.0 ) CLOCK_TOWER PLAY_FOREVER
SOUND clock2 = ( 110.0 , 125.0 , 5.0 ) CLOCK_TOWER PLAY_FOREVER
SOUND crick1 = ( 109.5 , 129.5 , 3.0 ) CRICKETS PLAY_FOREVER
DOOR_DATA door_end = DOUBLE ( 135 , 102 , 2 ) ( 135.0 , 102.0 , 2.0 , 2.0 , 2.0 ) LEFT 0 ANY_PLAYER CLOSE_NEVER 255 NOT_FLIPPED NOT_REVERSED 
MAKE_DOOR_MANUAL (door_end)

CHANGE_GANG_CHAR_RESPECT  ( redngang  ,  grnplayer , -5 )

DISPLAY_BRIEF ( 1019 )

GIVE_WEAPON ( grnplayer , machine_gun, 60 )
SWITCH_GENERATOR ( rocket1 , ON )
SWITCH_GENERATOR ( molotov1 , ON )

WHILE ( loop = 1 )
                        
SET_CHAR_GRAPHIC_TYPE ( grnplayer, DUMMY_GRAPHIC , 24)

GIVE_WEAPON ( grntank, CAR_MACHINE_GUN, 99)
GIVE_WEAPON ( grntank, CAR_MINE, 99)
GIVE_WEAPON ( grnplayer , pistol, 99 )

IF ( ( CHECK_SCORE_GREATER ( grnplayer , 4999 ) ) AND (target_score_reached = 0 ))
	SET target_score_reached = 1

        DISPLAY_BRIEF ( 1020 )
        POINT_ARROW_AT ( arrow1 , 116.5 , 125.5 , 5.0 )

	REMOVE_BLOCK ( 122, 131, 4, DONT_DROP )
	REMOVE_BLOCK ( 123, 131, 4, DONT_DROP )
	SET blocks_removed = 1

	bot1 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 GUARD_AGAINST_PLAYER END
	bot2 = CREATE_CHAR ( 133.5 , 102.5 , 2.0 ) 24 270 GUARD_AGAINST_PLAYER END
	bot3 = CREATE_CHAR ( 132.5 , 102.6 , 2.0 ) 24 270 GUARD_AGAINST_PLAYER END
	bot4 = CREATE_CHAR ( 131.5 , 102.7 , 2.0 ) 24 270 GUARD_AGAINST_PLAYER END
	bot5 = CREATE_CHAR ( 130.5 , 102.8 , 2.0 ) 24 270 GUARD_AGAINST_PLAYER END
                                                                        
	IF ( CHECK_CHARACTER_HEALTH ( bot1 , 0 ) )
		GIVE_WEAPON ( bot1 , machine_gun )
		SET_CHAR_THREAT_SEARCH ( bot1 , AREA )
		SET_CHAR_THREAT_REACTION ( bot1 , REACT_AS_NORMAL )
		SET_CHAR_BRAVERY_LEVEL ( bot1 , LOONY )
		SET_CHAR_SHOOTING_SKILL ( bot1 , CRACK_SHOT )
		SET_CHAR_OBJECTIVE (bot1 , GUARD_AREA)
		ADD_GROUP_TO_CHARACTER ( bot1 , 0 )
	ENDIF

	IF ( CHECK_CHARACTER_HEALTH ( bot2 , 0 ) )
		GIVE_WEAPON ( bot2 , silenced_machine_gun )
		SET_CHAR_THREAT_SEARCH ( bot2 , AREA )
		SET_CHAR_THREAT_REACTION ( bot2 , REACT_AS_NORMAL )
		SET_CHAR_BRAVERY_LEVEL ( bot2 , LOONY )
		SET_CHAR_SHOOTING_SKILL ( bot2 , CRACK_SHOT )
		SET_CHAR_OBJECTIVE (bot2 , GUARD_AREA)
		ADD_EXISTING_CHAR_TO_GROUP ( bot1 , bot2 )
	ENDIF

	IF ( CHECK_CHARACTER_HEALTH ( bot3 , 0 ) )
		GIVE_WEAPON ( bot3 , electro_baton )
		SET_CHAR_THREAT_SEARCH ( bot3 , AREA )
		SET_CHAR_THREAT_REACTION ( bot3 , REACT_AS_NORMAL )
		SET_CHAR_BRAVERY_LEVEL ( bot3 , LOONY )
		SET_CHAR_SHOOTING_SKILL ( bot3 , CRACK_SHOT )
		SET_CHAR_OBJECTIVE (bot3 , GUARD_AREA)
		ADD_EXISTING_CHAR_TO_GROUP ( bot1 , bot3 )
	ENDIF

	IF ( CHECK_CHARACTER_HEALTH ( bot4 , 0 ) )
		GIVE_WEAPON ( bot4 , dual_pistol )
		SET_CHAR_THREAT_SEARCH ( bot4 , AREA )
		SET_CHAR_THREAT_REACTION ( bot4 , REACT_AS_NORMAL )
		SET_CHAR_BRAVERY_LEVEL ( bot4 , LOONY )
		SET_CHAR_SHOOTING_SKILL ( bot4 , CRACK_SHOT )
		SET_CHAR_OBJECTIVE (bot4 , GUARD_AREA)
		ADD_EXISTING_CHAR_TO_GROUP ( bot1 , bot4 )
	ENDIF

	IF ( CHECK_CHARACTER_HEALTH ( bot5 , 0 ) )
		GIVE_WEAPON ( bot5 , shotgun)
		SET_CHAR_MAX_RUNSPEED ( bot5 , 0.2 )
		SET_CHAR_THREAT_REACTION ( bot5 , REACT_AS_NORMAL )
		SET_CHAR_BRAVERY_LEVEL ( bot5 , LOONY )
		SET_CHAR_SHOOTING_SKILL ( bot5 , CRACK_SHOT )
		SET_CHAR_OBJECTIVE (bot5 , GUARD_AREA)
		ADD_EXISTING_CHAR_TO_GROUP ( bot1 , bot5 )
	ENDIF
ENDIF
                        
IF ( (target_score_reached = 1) AND ( LOCATE_CHARACTER_ON_FOOT ( grnplayer , 116.5 , 125.5 , 5.0 , 1.0 , 1.0 ) ) )
	DISPLAY_BRIEF_NOW ( 1021 )
	POINT_ARROW_AT ( arrow1 , bot1 )
	SET target_score_reached = 2 
ENDIF
                        
IF ( ( target_score_reached = 1 ) AND ( powergen_created = 0 ) ) // DAFE added another check to make this run once and init'd powergen_created = 0 instead of 1 at the top
	IF ( HAS_CHARACTER_DIED (bot1) )
		IF ( HAS_CHARACTER_DIED (bot2) )
                        IF ( HAS_CHARACTER_DIED (bot3) )
                        	IF ( HAS_CHARACTER_DIED (bot4) )
                        		IF ( HAS_CHARACTER_DIED (bot5) )
                           			powergen1 = CREATE_OBJ ( 135.5 , 102.0 , 2.0 ) 0 POWERGEN END
                                    		SET powergen_created = 1
                                    		SET powergen_died = 0
                                    		DISPLAY_BRIEF_NOW ( 1022 )
                                    		POINT_ARROW_AT ( arrow1 , 135.5 , 102.0 , 2.0 )
                        		ENDIF
                        	ENDIF
                        ENDIF
         	ENDIF
     	ENDIF
ENDIF

IF (IS_CAR_WRECKED(grntank))
	IF ( NOT ( IS_POINT_ONSCREEN ( 113.5,113.5,2.0 ) ) )
		DELETE_ITEM (grntank)
		grntank = CREATE_CAR (113.5,113.5,2.0) -1 180 TANK END
		GIVE_WEAPON (grntank, CAR_MACHINE_GUN, 99)
		GIVE_WEAPON (grntank, CAR_MINE, 99)
	ENDIF
ENDIF
                        
IF ( powergen_created = 1 )  // DAFE swapped this IF and next one around to make more sense and to control to run once
	IF ( ( CHECK_OBJ_MODEL ( powergen1 , POWERGEN_DEAD ) ) AND ( powergen_died = 0 ) )
		SET powergen_died = 1
		OPEN_DOOR ( door_end )
		DELETE_ITEM ( powergen1 )
		DISPLAY_BRIEF_NOW ( 1023 )
		SET powergen_created = 0
		SET powergen_died = 0
	ENDIF
ENDIF

IF ( LOCATE_CHARACTER_ANY_MEANS ( grnplayer , 135.5 , 102.0 , 2.0 , 1.0 , 4.0 ) )  //DAFE moved this condition out of a nested IF as it can be something that is checked every game cycle since the player is blocked from getting to this location until the end of game condition is met.  Gustavob, verify X,Y,Z,size of box coordinates are perfect!  Or else none of the below will happen as you'd expect!
	DISPLAY_MESSAGE (1124)
	ADD_SCORE ( grnplayer , 9999999 )
	FINISH_LEVEL (NO_BONUS)
ENDIF

ENDWHILE

LEVELEND
