//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXX Example 2 - By Aqutiv XXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX		

/* This is an example script of a fully working level, except that you can not save... Also you'll notice
 that in order to pass a level, you'll need to pass all the kill frenzies... see if you can make it... :)
[for use with wateryisle.gmp] */

PLAYER_PED player1 = ( 116.0 , 141.5 , 2.0 ) 25 0 
//Change, if needed, to the co-ordinate you wish to start at





// ******************************************Gangs***********************************************************
SET_GANG_INFO ( krisgang , 9 , pistol , molotov , flame_thrower , 6 , 96.5 , 128.5 , 5.0 , 1 , krsnabus , -1 )

SET_GANG_INFO ( zaibgang , 8 , pistol , silenced_machine_gun , rocket_launcher , 3 , 115.5 , 135.5 , 3.0 , 1 , vtype , 2 )

SET_GANG_INFO ( russgang , 10 , pistol , shotgun , machine_gun , 7 , 124.5 , 113.5 , 4.0 , 1 , buick , 28 ) 
// **********************************************************************************************************


// ******************************************Objects***********************************************************

ARROW_DATA arrow_end

//Phones:
OBJ_DATA krisphone  =  ( 96.5  , 128.5 , 5.0 )  0  phone
OBJ_DATA russphone  =  ( 123.5 , 114.5 , 4.0 )  90  phone
OBJ_DATA zaibphone  =  ( 115.5  , 135.5 , 3.0 )  180  phone
// Note that the coordination for the phones is the same for the gang arrows coordinations.

//Car Shops:
OBJ_DATA bombshop  =  ( 129.5  , 117.5 , 2.0 )  0  car_shop bomb_shop
OBJ_DATA mineshop  =  ( 117.5 , 111.5 , 2.0 )  0  car_shop mines_shop
OBJ_DATA gunshop  =  ( 129.5  , 111.5 , 2.0 ) 0  car_shop machinegun_shop
OBJ_DATA sprayshop  =  ( 117.5  , 117.5 , 2.0 )  0 car_shop // Spray shop doesn't need shop type.

//Respawning Power-ups (generators)
GENERATOR zaib_machinegun  =  ( 117.5 , 132.5 ) 0 COLLECT_01 1600 2000 10
GENERATOR zaib_health  =  ( 116.5 , 137.5 ) 0 COLLECT_30 1600 2000 

GENERATOR kris_machinegun  =  ( 96.5 , 126.5 ) 0 COLLECT_01 1600 2000 10
GENERATOR kris_health  =  ( 96.5 , 130.5 ) 0 COLLECT_30 1600 2000 

GENERATOR russ_shotgun  =  ( 123.5 , 119.5 ) 0 COLLECT_06 1600 2000 10

//Regular powrups
OBJ_DATA flamethrower_1  =  ( 105.5  , 133.5 )  0 COLLECT_08
OBJ_DATA hidden_mutiplier  =  ( 95.5  , 128.5 , 3.0 )  0 COLLECT_28

//Kill Frenzy objects:
OBJ_DATA KFicon_1  =  ( 119.5  , 132.5 ) 0 kill_frenzy 
OBJ_DATA KFicon_2  =  ( 122.5  , 114.5 ) 0 kill_frenzy 
OBJ_DATA KFicon_3  =  ( 133.5  , 126.5 ) 0 kill_frenzy 
OBJ_DATA KFicon_4  =  ( 105.5  , 137.5 ) 0 kill_frenzy 
OBJ_DATA KFicon_5  =  ( 101.5  , 119.5 ) 0 kill_frenzy  
CAR_DATA KFcar_6 =   (  104.0 , 127.0 , 6.0  )  9 0 xk120

ONSCREEN_COUNTER kf_counter  
SAVED_COUNTER kf_counter_total
TIMER_DATA kf_timer

BONUS kill_frenzy_1
BONUS kill_frenzy_2
BONUS kill_frenzy_3
BONUS kill_frenzy_4
BONUS kill_frenzy_5
BONUS kill_frenzy_6
// **********************************************************************************************************

// ******************************************Declerations and counters***********************************************************

DECLARE_TOTAL_SECRETS ( 6 ) //There are 6 Kill Frenzies

SAVED_COUNTER true = 1
SAVED_COUNTER false = 0 // sometimes it's better to use true and false to better get the idea of what you're doing.

SAVED_COUNTER kf_passed = 0
SAVED_COUNTER kf_failed = 0
SAVED_COUNTER all_kf_passed = 0

SAVED_COUNTER gameloop = 1

DECLARE_SECRETS_PASSED_FLAG ( kf_passed )

DECLARE_SECRETS_FAILED_FLAG ( kf_failed )


//Declare subs for triggers:
FORWARD answear_zaibphone:
FORWARD answear_krisphone:
FORWARD answear_russphone:

FORWARD do_kill_frenzy_1:
FORWARD do_kill_frenzy_2:
FORWARD do_kill_frenzy_3:
FORWARD do_kill_frenzy_4:
FORWARD do_kill_frenzy_5:
FORWARD do_kill_frenzy_6:
// **********************************************************************************************************

// ******************************************Thread Triggers***********************************************************

// Phones: (checks the player answearing one of the phone, then goes to the proper sub.) 
THREAD_TRIGGER thread_zaibphone = THREAD_WAIT_FOR_ANSWER_PHONE ( player1 , zaibphone , answear_zaibphone: )
THREAD_TRIGGER thread_krisphone = THREAD_WAIT_FOR_ANSWER_PHONE ( player1 , krisphone , answear_krisphone: )
THREAD_TRIGGER thread_russphone = THREAD_WAIT_FOR_ANSWER_PHONE ( player1 , russphone , answear_russphone: )

// player answeared zaibatsu phone:
answear_zaibphone:

DISPLAY_BRIEF ( 3724 )  //"We're the zaibatus, blah blah"
		
DISPLAY_BRIEF ( 3725 )  //"we hate the krishnas, go and kill them."

RETURN

// player answeared krishna phone:
answear_krisphone:

DISPLAY_BRIEF ( 3728 )  //"We're the krishna, blah blah"
		
DISPLAY_BRIEF ( 3729 )  //"we hate the russians, go and kill them."

RETURN

// player answeared russian phone:

answear_russphone:

DISPLAY_BRIEF ( 3726 )  //"We're the russian, blah blah"
		
DISPLAY_BRIEF ( 3727 )  //"we hate the zaibatsu, go and kill them."

RETURN

// Kill Frenzies: (checks the player either taking one of the icons or enetering a kill frenzy car) 

THREAD_TRIGGER thread_kill_frenzy_1 = THREAD_WAIT_FOR_CHAR_IN_AREA ( player1 , 119.5 , 132.5 , 3.0 , 0.2 , 0.2 , do_kill_frenzy_1: )
THREAD_TRIGGER thread_kill_frenzy_2 = THREAD_WAIT_FOR_CHAR_IN_AREA ( player1 , 122.5 , 114.5 , 2.0 , 0.2 , 0.2 , do_kill_frenzy_2: )
THREAD_TRIGGER thread_kill_frenzy_3 = THREAD_WAIT_FOR_CHAR_IN_AREA ( player1 , 133.5 , 126.5 , 3.0 , 0.2 , 0.2 , do_kill_frenzy_3: )
THREAD_TRIGGER thread_kill_frenzy_4 = THREAD_WAIT_FOR_CHAR_IN_AREA ( player1 , 105.5 , 137.5 , 3.0 , 0.2 , 0.2 , do_kill_frenzy_4: )
THREAD_TRIGGER thread_kill_frenzy_5 = THREAD_WAIT_FOR_CHAR_IN_AREA ( player1 , 101.5 , 119.5 , 3.0 , 0.2 , 0.2 , do_kill_frenzy_5: )
THREAD_TRIGGER thread_kill_frenzy_6 = THREAD_WAIT_FOR_CHAR_IN_CAR ( player1 , KFcar_6 , do_kill_frenzy_6: )

do_kill_frenzy_1:

	START_BASIC_KF_TEMPLATE ( thread_kill_frenzy_1 , 4329 , KFicon_1 , player1 , shotgun )
	kill_frenzy_1 = START_BONUS_CHECK ( no_zone , 2700 , 20 , 0 , char , not_exclusive , by_shotgun , none , any_law_enforcement )
	DO_BASIC_KF_TEMPLATE ( kill_frenzy_1 , kf_timer , 90 , kf_counter , kf_counter_total , 20 , 4329 , player1 , mult , 1 )
		// Note that the award for the kill frenzy is multiplier, not lives as usuall.

RETURN

do_kill_frenzy_2:

	START_BASIC_KF_TEMPLATE ( thread_kill_frenzy_2 , 4324 , KFicon_2 , player1 , electro_gun )
	kill_frenzy_2 = START_BONUS_CHECK ( no_zone , 1800 , 40 , 0 , char , not_exclusive , by_electro_weapon , none , no_occupation ) 
	DO_BASIC_KF_TEMPLATE ( kill_frenzy_2 , kf_timer , 60 , kf_counter , kf_counter_total , 40 , 4324 , player1 , mult , 1 ) 


RETURN

do_kill_frenzy_3:

	START_BASIC_KF_TEMPLATE ( thread_kill_frenzy_3 , 4322 , KFicon_3 , player1 , flame_thrower )
	kill_frenzy_3 = START_BONUS_CHECK ( no_zone , 1800 , 40 , 0 , char , not_exclusive , by_flamethrower , none , no_occupation ) 
	DO_BASIC_KF_TEMPLATE ( kill_frenzy_3 , kf_timer , 60 , kf_counter , kf_counter_total , 40 , 4322 , player1 , mult , 1  ) 


RETURN

do_kill_frenzy_4:

	START_BASIC_KF_TEMPLATE ( thread_kill_frenzy_4 , 4321 , KFicon_4 , player1 , rocket_launcher )
	kill_frenzy_4 = START_BONUS_CHECK ( no_zone , 1800 , 15 , 0 , car , not_exclusive , by_rocket_launcher , none , none ) 
	DO_BASIC_KF_TEMPLATE ( kill_frenzy_4 , kf_timer , 60 , kf_counter , kf_counter_total , 15 , 4321 , player1 , mult , 1 ) 


RETURN

do_kill_frenzy_5:

	START_BASIC_KF_TEMPLATE ( thread_kill_frenzy_5 , 4315 , KFicon_5 , player1 , machine_gun )
	kill_frenzy_5 = START_BONUS_CHECK ( no_zone , 1800 , 40 , 0 , char , not_exclusive , by_gun , none , no_occupation ) 
	DO_BASIC_KF_TEMPLATE ( kill_frenzy_5 , kf_timer , 60 , kf_counter , kf_counter_total , 40 , 4315 , player1 , mult , 1 ) 



RETURN
  
 
do_kill_frenzy_6:

	START_BASIC_KF_TEMPLATE ( thread_kill_frenzy_6 , 4314 , KFcar_6 , player1 , car_mine )
	kill_frenzy_6 = START_BONUS_CHECK ( no_zone , 3600 , 20 , 0 , car , not_exclusive , by_car_mine , xk120 , copcar ) 
	DO_BASIC_KF_TEMPLATE ( kill_frenzy_6 , kf_timer , 120 , kf_counter , kf_counter_total , 20 , 4314 , player1 , mult , 1 ) 

RETURN

// **********************************************************************************************************


// ******************************************Start Execution Procedure***********************************************************
LEVELSTART

GIVE_WEAPON ( player1 , machine_gun ) // This gives the player a machine gun at start

//Switching generators on:
SWITCH_GENERATOR ( zaib_machinegun , ON )
SWITCH_GENERATOR ( zaib_health , ON )
SWITCH_GENERATOR ( kris_machinegun , ON )
SWITCH_GENERATOR ( kris_health , ON )
SWITCH_GENERATOR ( russ_shotgun , ON )

// who hates who?
SET_GANG_KILL_REACTION ( krisgang , zaibgang , 1 ) // zaibatsu hates krishna
SET_GANG_KILL_REACTION ( zaibgang , russgang , 1 ) // russians hates zaibatsu			
SET_GANG_KILL_REACTION ( russgang , krisgang , 1 ) // krishna hates russians

WHILE ( gameloop = 1 )

	//Check to see if the player has passed ALL 6 Kill Frenzies.
	IF ( ( kf_passed =  6 )
	AND ( all_kf_passed = false ) )
		LEVEL_END_POINT_ARROW_AT ( arrow_end , 95.5  , 128.5 , 3.0 ) // This points the level end big arrow at the exit point.
		SET all_kf_passed = true
	ENDIF
     
	//check to see if the player has came to the quit point after the objective ( passing all 6 KFs ) has been achieved.
	IF ( ( all_kf_passed = true )
	AND ( LOCATE_CHARACTER_ANY_MEANS ( player1 , 95.5  , 128.5 , 3.0 , 1.0 , 2.0 ) ) )
		FINISH_LEVEL ( bonus_1 )
	ENDIF
       
ENDWHILE


LEVELEND


//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX		

