CAR_DATA truckcab
car_data trailer
counter in_truck = 0
counter got_trailer = 0
counter delivered =0



FORWARD clean_up_red_phone1:


red_phone1:
SET failed_red_phone1 = 0
SET flag_on_mission = 1
SET flag_on_red_mission = 1

DISPLAY_MESSAGE ( 3848 ) 
DISPLAY_BRIEF ( 3880 )

truckcab = CREATE_CAR ( 8.5 , 194.0 , 2.0 )  5  45  TRUKCAB1 END
trailer = CREATE_CAR ( 5.0 , 196.5 , 2.0 )  5  90  TRUKCONT END


POINT_ARROW_AT ( blaow , truckcab )

WHILE_EXEC ( delivered =0 )



if ( got_trailer = 0 )

IF ( IS_CHARACTER_IN_CAR ( p1 , truckcab ) )
set in_truck = 1
DISPLAY_BRIEF ( 3895 )
POINT_ARROW_AT ( blaow , trailer  )
endif
endif

if  ( IS_TRAILER_ATTACHED ( truckcab , trailer ) )
set got_trailer = 1

endif



if ( in_truck = 1 )

IF             ( ( got_trailer = 0 )
		AND ( NOT ( IS_CHARACTER_IN_CAR ( p1 , truckcab ) ) ) )
			
			DISPLAY_BRIEF_NOW  ( 3896 )		
			POINT_ARROW_AT ( blaow , truckcab )
		ENDIF
  	
  		IF  ( ( got_trailer = 1 )
		AND ( NOT ( IS_CHARACTER_IN_CAR ( p1 , truckcab ) ) ) )
			DISPLAY_BRIEF_NOW  ( 3897 ) 
			POINT_ARROW_AT ( blaow , truckcab )
		ENDIF
	ENDIF


IF    ( got_trailer = 1 )

if ( NOT ( IS_TRAILER_ATTACHED ( truckcab , trailer  ) ) ) 
DISPLAY_BRIEF ( 3899 ) 	
			POINT_ARROW_AT ( blaow , trailer  )
endif
if ( ( IS_TRAILER_ATTACHED ( truckcab , trailer ) )
and  ( IS_CHARACTER_IN_CAR ( p1 , truckcab ) ) )
DISPLAY_BRIEF ( 3900 )
POINT_ARROW_AT ( blaow , 163.0 , 211.0 , 2.0  )



endif
endif




IF 	 ( ( IS_CAR_WRECKED ( trailer ) ) 
		AND ( failed_red_phone1 = 0 ) )
		CLEAR_ALL_BRIEFS ( )
		DISPLAY_BRIEF ( 3523 )   	
		SET failed_red_phone1 = 1
		DISPLAY_MESSAGE ( 3730 ) 
		RETURN
	ENDIF





IF 	 ( ( IS_CAR_WRECKED ( truckcab ) ) 
		AND ( failed_red_phone1 = 0 ) )
		CLEAR_ALL_BRIEFS ( )
		DISPLAY_BRIEF ( 3523 )   	
		SET failed_red_phone1 = 1
		DISPLAY_MESSAGE ( 3730 ) 
		RETURN
	ENDIF

  IF ( ( IS_CAR_IN_BLOCK ( trailer , 163.0 , 211.0 , 2.0 , 2.0 , 2.0 ) )
and  ( NOT ( IS_TRAILER_ATTACHED ( truckcab , trailer  ) ) ) )
		CLEAR_ALL_BRIEFS ( )
		DISPLAY_BRIEF ( 3536 ) 
		SET delivered = 1
		
   	ENDIF




ENDWHILE



IF ( ( passed_red_phone1 = 0 )
AND ( delivered = 1 ) )  
	DISPLAY_BRIEF ( 3537 ) 
	SET passed_red_phone1	= 1
	++ counter_all_missions_passed
	DISPLAY_MESSAGE ( 3100 ) 
        remove_arrow ( blaow )
	ADD_SCORE ( p1 , 40000 )
	ADD_MULTIPLIER ( p1 , 1 ) 
	CHANGE_GANG_CHAR_RESPECT_AND_UPDATE ( gng2 , p1 , 1 )
	CLEAR_WANTED_LEVEL ( p1 )
	SET_PHONE_DEAD ( red_phone1 ) 
	DISABLE_THREAD_TRIGGER ( thr_red_phone1 )
	RETURN
ENDIF



clean_up_red_phone1:


IF ( passed_red_phone1 = 1 )
		++ flag_red_missions_passed
		++ flag_all_missions_passed
                REMOVE_ARROW ( blaow )
		IF ( flag_red_missions_passed = 7 )
			DISPLAY_BRIEF ( 3673 ) 
			DISPLAY_MESSAGE ( 3672 ) 
		ENDIF
	ENDIF

	IF ( failed_red_phone1 = 1 )
		++ flag_red_missions_failed
		++ flag_all_missions_failed
                REMOVE_ARROW ( blaow )
		CHANGE_GANG_CHAR_RESPECT_AND_UPDATE ( gng2 , p1 , -1 ) 
		CLEAR_WANTED_LEVEL ( p1 )
//		CLEAR_ALL_BRIEFS ( )
	ENDIF

	IF ( CHECK_DEATHARREST_EXECUTED ( ) )
		++ flag_red_missions_failed
		++ flag_all_missions_failed
                REMOVE_ARROW ( blaow )
		CHANGE_GANG_CHAR_RESPECT_AND_UPDATE ( gng2 , p1 , -1 ) 
		CLEAR_WANTED_LEVEL ( p1 )
	ENDIF

	MISSION_HAS_FINISHED ( )

	SET flag_on_mission	= 0
	SET flag_on_red_mission = 0
	
	RETURN


MISSIONSTART

	GOSUB red_phone1:

	GOSUB clean_up_red_phone1:

MISSIONEND

