// player
PLAYER_PED p1 = ( 244.5 , 66.5 , 2.0 ) 10 180

// arrows
ARROW_DATA arrow01
ARROW_DATA end_arrow

// parked cars
PARKED_CAR_DATA car01 = ( 244.5 , 63.5 , 2.0 ) 2 180 STYPECAB
	// part 1
CAR_DATA p1_truck

// objects
OBJ_DATA intro_armour
OBJ_DATA phone = ( 127.5 , 91.3 , 2.0 ) 90 PHONE

	// part 7
OBJ_DATA p7_bollard01
OBJ_DATA p7_bollard02
OBJ_DATA p7_bollard03

// generators
GENERATOR health = ( 120.5 , 89.5 , 2.0 ) 0 COLLECT_30 1500 1500 10
GENERATOR armour = ( 120.5 , 90.5 , 2.0 ) 0 COLLECT_31 1500 1500 20
GENERATOR smg = ( 120.5 , 91.5 , 2.0 ) 0 COLLECT_01 1500 1500 3

// characters that will be created later
CHAR_DATA victim // used for storing last punch from player for later on
CHAR_DATA merc_guard01 = ( 125.5 , 90.7 , 5.0 ) 10 315 POLICE
CHAR_DATA merc_guard02 = ( 126.5 , 90.7 , 5.0 ) 10 0 POLICE
CHAR_DATA merc_guard03 = ( 127.5 , 90.7 , 5.0 ) 10 45 POLICE

	// part 1
CHAR_DATA p1_truck_driver

	// part 7
CHAR_DATA traitor01
CHAR_DATA traitor02
CHAR_DATA traitor03
CHAR_DATA traitor04
CHAR_DATA traitor05
CHAR_DATA traitor06
CHAR_DATA traitor07
CHAR_DATA traitor08
CHAR_DATA traitor09
CHAR_DATA traitor10
CHAR_DATA traitor11
CHAR_DATA traitor12
CHAR_DATA traitor_merc

// characters that spawn at the start
CHAR_DATA merc01 = ( 246.5 , 67.5 , 2.0 ) 10 180 POLICE
CHAR_DATA merc02 = ( 247.5 , 67.5 , 2.0 ) 10 180 POLICE
CHAR_DATA merc03 = ( 246.5 , 68.5 , 2.0 ) 10 180 POLICE
CHAR_DATA merc04 = ( 247.5 , 68.5 , 2.0 ) 10 180 POLICE

// trains
SET_STATION_INFO ( trak00 , 2 , 0 , 0 )
SET_STATION_INFO ( trak01 , NO_TRAIN )
SET_STATION_INFO ( trak02 , NO_TRAIN )
SET_STATION_INFO ( trak03 , 2 , 0 , 0 )
SET_STATION_INFO ( trak04 , NO_TRAIN )

// counters
COUNTER true = 1
	// check to how many player controlled mercs are still alive
COUNTER bodyguards = 4
COUNTER merc01_dead = 0
COUNTER merc02_dead = 0
COUNTER merc03_dead = 0
COUNTER merc04_dead = 0
COUNTER all_mercs_dead = 0
	// part 1
COUNTER intro = 0
COUNTER in_van = 0
COUNTER p1_intruck = 0
COUNTER p1_atlocation = 0
	// part 7
COUNTER final_part = 0
COUNTER final_part_setup = 0
COUNTER traitor_killed = 0

// declarations
DECLARE_FINISH_SCORE ( 3000000 )

LEVELSTART

SWITCH_GENERATOR ( health , ON )
SWITCH_GENERATOR ( armour , ON )
SWITCH_GENERATOR ( smg , ON )

SET_CHAR_THREAT_SEARCH ( merc_guard01 , AREA )
SET_CHAR_THREAT_SEARCH ( merc_guard02 , AREA )
SET_CHAR_THREAT_SEARCH ( merc_guard03 , AREA )
SET_CHAR_THREAT_REACTION ( merc_guard01 , REACT_AS_NORMAL )
SET_CHAR_THREAT_REACTION ( merc_guard02 , REACT_AS_NORMAL )
SET_CHAR_THREAT_REACTION ( merc_guard03 , REACT_AS_NORMAL )
SET_CHAR_OBJECTIVE ( merc_guard01 , GUARD_SPOT )
SET_CHAR_OBJECTIVE ( merc_guard02 , GUARD_SPOT )
SET_CHAR_OBJECTIVE ( merc_guard03 , GUARD_SPOT )


WHILE_EXEC ( true = 1 )

// never get a wanted level
IF ( CHECK_HEADS_GREATER ( p1 , 0 ) )
CLEAR_WANTED_LEVEL ( p1 )
ENDIF

// extremely hard punches from the player. i.e. kills them outright
IF ( HAS_CHAR_PUNCHED_SOMEONE ( p1 ) )
STORE_LAST_CHAR_PUNCHED ( p1 , victim ) // checks if player has punched and stores it in 'victim'
KILL_CHAR ( victim )
ENDIF

// check if merc01 is dead...
IF ( ( HAS_CHARACTER_DIED ( merc01 ) )
AND ( merc01_dead = 0 ) )
-- bodyguards
SET merc01_dead = 1
ENDIF

// check if merc02 is dead...
IF ( ( HAS_CHARACTER_DIED ( merc02 ) )
AND ( merc02_dead = 0 ) )
-- bodyguards
SET merc02_dead = 1
ENDIF

// check if merc03 is dead...
IF ( ( HAS_CHARACTER_DIED ( merc03 ) )
AND ( merc03_dead = 0 ) )
-- bodyguards
SET merc03_dead = 1
ENDIF

// check if merc04 is dead...
IF ( ( HAS_CHARACTER_DIED ( merc04 ) )
AND ( merc04_dead = 0 ) )
-- bodyguards
SET merc04_dead = 1
ENDIF

// check if bodyguards are dead
IF ( ( bodyguards = 0 )
AND ( all_mercs_dead = 0 ) )
DISPLAY_BRIEF ( 1001 ) // "All your men are dead! You're on your own from here!
SET all_mercs_dead = 1
ENDIF

/////////////////
// START GAME! //
/////////////////

///////////
// INTRO //
///////////

/*
info: this is where the player is told what to do. player is told to go to van to load up on weapons. other mercs follow the player. to stop cheating, all weapons are removed at the start of the game
*/

IF ( intro = 0 )
REMOVE_WEAPONS ( p1 ) // stops cheating
ADD_GROUP_TO_CHARACTER ( p1 , 0 )
ADD_EXISTING_CHAR_TO_GROUP ( p1 , merc01 )
ADD_EXISTING_CHAR_TO_GROUP ( p1 , merc02 )
ADD_EXISTING_CHAR_TO_GROUP ( p1 , merc03 )
ADD_EXISTING_CHAR_TO_GROUP ( p1 , merc04 )
SET_CHAR_OBJECTIVE ( merc01 , GUARD_AREA )
SET_CHAR_OBJECTIVE ( merc02 , GUARD_AREA )
SET_CHAR_OBJECTIVE ( merc03 , GUARD_AREA )
SET_CHAR_OBJECTIVE ( merc04 , GUARD_AREA )
SET_CHAR_THREAT_SEARCH ( merc01 , AREA )
SET_CHAR_THREAT_SEARCH ( merc02 , AREA )
SET_CHAR_THREAT_SEARCH ( merc03 , AREA )
SET_CHAR_THREAT_SEARCH ( merc04 , AREA )
SET_CHAR_THREAT_REACTION ( merc01 , REACT_AS_NORMAL )
SET_CHAR_THREAT_REACTION ( merc02 , REACT_AS_NORMAL )
SET_CHAR_THREAT_REACTION ( merc03 , REACT_AS_NORMAL )
SET_CHAR_THREAT_REACTION ( merc04 , REACT_AS_NORMAL )
SET_CAR_BULLETPROOF ( car01 , ON )
POINT_ARROW_AT ( arrow01 , car01 )
SET intro = 1
ENDIF

/*
info: when player is in the van, give weapons to him and the mercs. armour is also spawned under van for instant pickup
*/
IF ( ( ( IS_CHARACTER_IN_CAR ( p1 , car01 ) )
AND ( intro = 1 ) )
AND ( in_van = 0 ) )
REMOVE_ARROW ( arrow01 )
intro_armour = CREATE_OBJ ( 244.5 , 63.5 , 2.0 ) 0 COLLECT_31 END
GIVE_WEAPON ( p1 , machine_gun , 20 )
GIVE_WEAPON ( p1 , pistol , 50 )
GIVE_WEAPON ( p1 , grenade , 6 )
GIVE_WEAPON ( merc01 , machine_gun )
GIVE_WEAPON ( merc02 , machine_gun )
GIVE_WEAPON ( merc03 , machine_gun )
GIVE_WEAPON ( merc04 , machine_gun )
p1_truck = CREATE_CAR ( 213.5 , 75.5 , 2.0 ) 2 90 BOXTRUCK END
p1_truck_driver = CREATE_CHAR ( 29.5 , 233.5 , 2.0 ) 10 180 POLICE END
POINT_ARROW_AT ( arrow01 , p1_truck )
SET in_van = 1
ENDIF

IF ( IS_CHARACTER_IN_CAR ( p1 , p1_truck ) )
SET p1_intruck = 1
ENDIF

IF ( ( p1_intruck = 1 )
AND ( p1_atlocation = 0 ) )
REMOVE_ARROW ( arrow01 )
POINT_ARROW_AT ( arrow01 , 9.5 , 232.5 , 2.0 )
SET p1_atlocation = 1
ENDIF


////////////////
// FINAL PART //
////////////////

/*
info: this is the final stage. the player must kill the traitor mercenary and his band of traitors. the main goal is to kill the merc, and the others don't have to be killed to win, but is adviseable to make life easier :-)
*/

IF ( ( final_part = 1 )
AND ( final_part_setup = 0 ) )
p7_bollard01 = CREATE_OBJ ( 59.7 , 250.5 , 2.0 ) 90 BOLLARD END
p7_bollard02 = CREATE_OBJ ( 59.7 , 251.5 , 2.0 ) 90 BOLLARD END
p7_bollard03 = CREATE_OBJ ( 59.7 , 252.5 , 2.0 ) 90 BOLLARD END
traitor_merc = CREATE_CHAR ( 49.5 , 244.5 , 2.0 ) 7 0 CRIMINAL_TYPE2 END
POINT_ARROW_AT ( arrow01 , traitor_merc )
SET final_part_setup = 1
ENDIF

IF ( ( HAS_CHARACTER_DIED ( traitor_merc ) )
AND ( traitor_killed = 0 ) )
ADD_SCORE ( p1 , 2500000 )
REMOVE_ARROW ( arrow01 )
SET traitor_killed = 1
ENDIF

ENDWHILE

LEVELEND