#define OBJLKR
#include "dink_sym.h"
#include "dink_glb.h"

void objlooker(n)
/*********************************************************/
/*                                                       */
/*    --- Object in Room Examination Subroutine ---      */
/*                                                       */
/*      Program by Gary A. Allen, Jr.  18 May 1990       */
/*        (c) Copywrite 1989 by Gary A. Allen, Jr.       */
/*                                                       */
/*********************************************************/
int n ;
{
#ifdef __TURBOC__
void objector(int) ;
#endif

register int i ;

if (((object[O_torch][J_loc] == B_have)&&object[O_torch][J_property])|| 
   (n < 186)||(n > 202)) { 
	if (room[n][M_obj_cnt] == 1) {
		for (i=0; i <= objcnt; i++) {
			if ((object[i][J_loc] == n) && 
				(object[i][J_type] != Z_unmovable)) {
				if (n == R_office_mang) {
printf ("On the floor you see ") ;
					objector(i) ;
					printf (".\n") ;
				}
				else {
 					printf ("You see ") ;
					objector(i) ;
					printf (".\n") ;
				}
			}
		}
	}
	if (room[n][M_obj_cnt] > 1) {
		if (n == R_office_mang) 
printf ("You see the following on the floor: \n");
		else printf ("You see the following: \n");
		for (i=0; i <= objcnt; i++) {
			if ((object[i][J_loc] == n) && 
				(object[i][J_type] != Z_unmovable)) {
				printf ("        ") ;
				objector(i) ;
				printf ("\n") ;
			}
		}
	}
}
} /* end of "objlooker" subroutine */
 
void kelly(n) 
/********************************************************************/
/*                                                                  */
/*                  --- Ned Kelly Subroutine --                     */
/*                                                                  */
/* Software by Gary A. Allen, Jr. 5 November 1989  Version: Mk 1.2  */
/*           (c) Copyright 1989 by Gary A. Allen, Jr.               */
/*                                                                  */
/********************************************************************/
int n ;
{
register int i, k ;
static int ned_look = 0, sw_fiddle = TRUE ;
int  sw_ned_look, sw_ned_set ;

/* check if Ned  Kelly is dead */
if (enemy[N_ned][E_location] == B_destroyed) return ;

/* this switch is for Ned looking for treasure once per cycle */
sw_ned_look = FALSE ;
sw_ned_set = FALSE ;

/* check if player is in Ned's trigger rooms */
switch (n) {
/* Cause Ned Kelly to steal */
case R_lift_inside:
	/* are there valuables in the safe and the safe open? */
	if ((score > 0)&&
		(room[R_office_mang][M_rm_status] >= S_dialed)) {
	/* is the office building open? */
		if ((ned_look > 4)||
			(room[R_office_entr][M_rm_status] == S_open)||
			(room[R_office_entr][M_rm_status] == S_kicked)||
		(room[R_office_entr][M_rm_status] == S_unlocked)) {

			if (ned_look > 4) {
			room[R_office_entr][M_rm_status] = S_kicked ;
			room[R_office_entr][2] = R_office_hall ;
			}
/* scan the object list for treasure in safe and transfer to hideout */
			for (i=0; i <= objcnt; i++) {
	if ((object[i][J_loc] == B_in_safe)&&(object[i][J_value] > 0)) {
					++room[R_hideout][M_obj_cnt] ;
					object[i][J_loc] = R_hideout; 
					sw_ned_set = TRUE ;
				}
			}	
		}
/* the safe is open with treasure but the door is locked */
		else {
			++ned_look ;
			sw_ned_look = TRUE ;
		}
	} /* end of the block concerning Ned and the safe */

	if (sw_valuable) {
		for (i=0; i <= objcnt; i++) {
/* scan for treasure laying around outside the building on surface */
			for (k = 22; k <= 36; k++) { 
				if ((object[i][J_loc] == k)&&
					(object[i][J_value] > 0)) {
					++room[R_hideout][M_obj_cnt] ;
					--room[k][M_obj_cnt] ;
					object[i][J_loc] = R_hideout; 
					sw_ned_set = TRUE ;
					sw_valuable = FALSE ;
					break ;
				}
			}	
			for (k = 144; k <= 145; k++) {
				if ((object[i][J_loc] == k)&&
					(object[i][J_value] > 0)) {
					++room[R_hideout][M_obj_cnt] ;
					--room[k][M_obj_cnt] ;
					object[i][J_loc] = R_hideout; 
					sw_valuable = FALSE ;
					sw_ned_set = TRUE ;
					break ;
				}
			}	
		/* scan the office building for treasure on the floor */
			for (k = 37; k <= 41; k++) { 
				if ((object[i][J_loc] == k)&&
					(object[i][J_value] > 0)) {
/* if the office bldg. door is open then Ned Kelly steals treasure */
		if ((room[R_office_entr][M_rm_status] == S_open)||
	  	  (room[R_office_entr][M_rm_status] == S_unlocked)||
		  (room[R_office_entr][M_rm_status] == S_kicked)) {
			++room[R_hideout][M_obj_cnt] ;
			--room[k][M_obj_cnt] ;
			object[i][J_loc] = R_hideout; 
			sw_valuable = FALSE ;
			sw_ned_set = TRUE ;
			break ;
		}
/* if Ned Kelly sees locked treasure four times, he kicks in the door */
		if (ned_look > 4) {
			room[R_office_entr][M_rm_status] = S_kicked ;
			room[R_office_entr][2] = R_office_hall ;
			++room[R_hideout][M_obj_cnt] ;
			--room[k][M_obj_cnt] ;
			object[i][J_loc] = R_hideout; 
			sw_valuable = FALSE ;
			sw_ned_set = TRUE ;
		}
		else {
			if (!sw_ned_look) ++ned_look ;
			sw_ned_look = TRUE ;
			break ; /* conclude the office bldg. loop */
		}
		break ;
				}
			}	
		}	
	} /* end of block concerning Ned and loose treasure */

	if (sw_ned_set) {
		enemy[N_ned][E_status] = F_stealing ; 
		enemy[N_ned][E_location] = R_hideout ;
		room[R_hideout][M_monster] = 1 ;
		sw_ned_set = FALSE ;
	}
	return ;

case R_office_entr:
/* Cause Ned Kelly to run away with treasure */
	if (enemy[N_ned][E_status] == F_stealing) {
		enemy[N_ned][E_status] = F_asleep ;
printf("There is an odd looking character with an iron bucket on his ");
printf("head and a swag\n");
printf("bag over his shoulder running away from the ");
printf("office building towards\nthe desert. \n\n") ;
		return ;
	}
	if ((ned_look == 3) && sw_fiddle && 
		(room[R_office_entr][M_rm_status] != S_open) &&
		(room[R_office_entr][M_rm_status] != S_kicked) &&
		(room[R_office_entr][M_rm_status] != S_unlocked)) {
		sw_fiddle = FALSE ;
printf("As you approach the office building's door, you see a\n");
printf("strange looking character with a bucket on his head and\n") ;
printf("wearing an iron breast plate.  He is on his knees before\n") ;
printf("the door trying to pick the lock with a bit of coat hanger\n") ;
printf("wire. Suddenly, he turns and sees you coming. With amazing\n"); 
printf("speed, he throws away his wire and runs off towards the\n") ;
printf("open desert.\n\n") ;
		return ;
	}
} /* end of the ned kelly room switch block */
} /* --- end of the "kelly" subroutine  --- */ 

void sounder(n) 
/********************************************************************/
/*                                                                  */
/*                  --- Gong Sounding Subroutine --                 */
/*                                                                  */
/* Software by Gary A. Allen, Jr. 21 June 1989     Version: Mk 1.0  */
/*           (c) Copyright 1989 by Gary A. Allen, Jr.               */
/*                                                                  */
/********************************************************************/
int n ;
{
#ifdef __TURBOC__
void exit(int), hold_it(void) ;
char getche(void) ;
#endif

char letter ;

/* see if player is in the gong room */
if (n != R_gong) {
	if (tag[V_gong]) printf("I don't see a gong here.\n") ;
	else printf("I don't see how you can do that.\n") ;
	return ;
}

/* The player is in the gong room. Does he have the clapper? */
if (tag[V_clapper]) {
	if (object[O_clapper][J_loc] == B_have) {
		if (!tag[V_gong]) {
printf("With what are you going to do that with the clapper?\n") ;
			return ;
		}
printf
("\n  GGGGGGGG       OOOOOOOO     NN       NN     GGGGGGGG     !!!\n") ;
printf
("GG        GG   OO        OO   NNN      NN   GG        GG   !!!\n") ;
printf
("GG             OO        OO   NN N     NN   GG             !!!\n") ;
printf
("GG             OO        OO   NN  N    NN   GG             !!!\n") ;
printf
("GG   GGGGGGG   OO        OO   NN   N   NN   GG    GGGGGG   !!!\n") ;
printf
("GG        GG   OO        OO   NN    N  NN   GG        GG   !!!\n") ;
printf
("GG        GG   OO        OO   NN     N NN   GG        GG\n") ;
printf
("GG        GG   OO        OO   NN      NNN   GG        GG   000\n") ;
printf
("  GGGGGGGG       OOOOOOOO     NN       NN     GGGGGGGG     000\n\n") ;

/* see if the "end game" can begine */
		if ((score < max_score)||(gleep_score == 0)) {
printf("You hear an ethereal voice which says:\n\n") ;
			if (score < max_score) {
printf("Sorry Mate!  You haven't put all of the treasure in the\n") ;
printf("safe yet.  Find the rest, and then the secret of the gong\n") ;
printf("will be revealed.\n") ;
				return ;
			}
			if (gleep_score == 0) {
printf("Good on you Mate!  You've found all of the treasure.\n") ;
printf("However you haven't put a single gleep in the gleep tank!\n");
printf("You're not a Fair Dinkum Adventurer until you've put at\n") ;
printf("least one gleep in the tank.\n") ;
				return ;
			}
		}
		/* Begin the End Game */
printf("There is a loud \"Fromp!\" as a portcullis crashes down and\n");
printf("seals the northern (and only) exit.  The lights go dim and\n");
printf("a hazy fog appears in the room.  Slowly this fog coalesces\n") ;
if (sw_warned) {
printf("into the now familiar form of Banjo Patterson.  For some\n") ;
printf("odd reason Banjo is holding in his right hand a sword of\n") ;
printf("fire such as one reads about in Genesis. The deathly quiet\n");
printf("is broken when Banjo begins to speak:\n") ;
}
else {
printf("into a ghostly human form.  This ethereal being is wearing\n") ;
printf("a grey flannel suit, a bowler hat, and has a gold pocket\n") ;
printf("watch chain looped across the front of his waist coat.  He\n");
printf("is holding in his right hand a sword of fire such as one\n") ;
printf("reads about in Genesis.  You can hear \"Waltzing Matilda\"\n");
printf("being played softly in the background.  You know what?\n");
printf("I think this ethereal being is none other than the ghost\n") ;
printf("of Banjo Patterson!  With this realization Banjo begins to\n") ;
printf("speak:\n") ;
}
		hold_it() ;
printf("\"Good on you, Fair Dinkum Adventurer!  You have braved\n") ; 
printf("the perils of hoop snakes, drop bears, and mutant wombats.\n") ;
printf("You have solved many riddles, collected much treasure and\n") ;
printf("encountered true evil and dealt with it appropriately.\n");
printf("However it has occured to us that you might not be one of\n") ;
printf("the chosen few who can be admitted into the Land of the\n") ;
printf("Blessed.  The possibility remains that you could be a\n") ;
printf("whinging Pom or a bleeding Yank.  Therefore you will be\n") ;
printf("tested with three questions.  If you answer correctly, you\n") ;
printf("will be admitted into paradise. However should you answer\n");
printf("falsely, you will be sent to another place, an abode of\n");
printf("darkness and dread.  So answer wisely, for you will not be\n") ;
printf("given a second chance!\"\n\n") ;

printf("What is the capital of Australia?\n\n") ;
printf("     A) Sydney\n") ;
printf("     B) Canberra\n") ;
printf("     C) Melbourne\n\n") ;
printf("Answer A, B, or C:  ") ;
quest1:
#ifndef __TURBOC__
		letter = getchar() ;
		if ((letter == '\n')||(letter == ' ')) goto quest1 ;
		if (('b' == letter)||('B' == letter)) 
			printf("\nCorrect!\n\n") ;
#endif

#ifdef __TURBOC__
		letter = getche() ;
		if ((letter == '\n')||(letter == ' ')) goto quest1 ;
		if (('b' == letter)||('B' == letter)) 
			printf("\n\nCorrect!\n\n") ;
#endif
		else goto la ;

printf("In the Australian emblem there appears two animals on\n") ;
printf("either side of a shield.  One of the two animals is a\n") ;
printf("kangaroo.  What species is the other animal?\n\n") ;
printf("     A) Koala Bear\n") ;
printf("     B) Platypus\n") ;
printf("     C) Emu\n\n") ;
printf("Answer A, B, or C:  ") ;
quest2:
#ifndef __TURBOC__
		letter = getchar() ;
		if ((letter == '\n')||(letter == ' ')) goto quest2 ;
		if (('c' == letter)||('C' == letter)) 
			printf("\nCorrect!\n\n") ;
#endif

#ifdef __TURBOC__
		letter = getche() ;
		if ((letter == '\n')||(letter == ' ')) goto quest2 ;
		if (('c' == letter)||('C' == letter)) 
			printf("\n\nCorrect!\n\n") ;
#endif
		else goto la ;

printf("Which place is a state in Australia?\n\n") ;
printf("     A) Arcadia\n") ;
printf("     B) Patagonia\n") ;
printf("     C) Tasmania\n\n") ;
printf("Answer A, B, or C:  ") ;
quest3:
#ifndef __TURBOC__
		letter = getchar() ;
		if ((letter == '\n')||(letter == ' ')) goto quest3 ;
		if (('c' == letter)||('C' == letter)) 
			printf("\nCorrect!\n\n") ;
#endif

#ifdef __TURBOC__
		letter = getche() ;
		if ((letter == '\n')||(letter == ' ')) goto quest3 ;
		if (('c' == letter)||('C' == letter)) 
			printf("\n\nCorrect!\n\n") ;
#endif
		else goto la ;

/* Player has won the game */
printf("You see Banjo Patterson with a beatific smile.  He waves\n") ;
printf("his firey sword with a florish and the scene around you\n") ;
printf("disolves into a million tiny motes of light.  You now\n") ;
printf("find yourself wearing swimming togs.  You are being carried\n");
printf("by a guard of honor made up of four sumptuous shielas\n") ;
printf("dressed in string bikinis and four handsome lifeguards.\n") ;
printf("They carry you to a perfect beach on South Stradbroke\n") ;
printf("Island.  Off in the distance on the Queensland mainland\n") ;
printf("you see the Gold Coast which vaguely resembles the Emerald\n") ;
printf("City of the classic movie.  Your guard of honor sets you\n") ;
printf("down and hands you a can of Power's Bitter.  Three\n") ;
printf("beautiful white pelicans float over head in a clear blue\n") ;
printf("sky completing a scene of exquisite beauty.\n\n") ;
printf("You're in paradise Mate and you've also won the game!\n\n") ;

/* deal with final gleep announcement */
if (gleep_score == 1) {
printf("---- A hint for those who want to go on playing Dinkum ----\n");
printf("In this game you only put the minimum single gleep in the\n");
printf("gleep tank.  In future games try seeding fertile tunnels\n");
printf("with gleeps and reproducing them.  Build up as many gleeps\n");
printf("as you can and then hit the gong before Dinkum times out.\n");
}
else {
printf("You won this game with %d gleeps in the gleep tank.\n\n",
	gleep_score) ;
}
		if (sw_wizard) return ;
		else exit(0) ;

/* Player enters false answer and goes to Los Angeles */
la:
printf("\n        -!-!-!-!-!-     Wrong!    -!-!-!-!-!-\n\n") ;
printf("Banjo Patterson brings down the sword of fire onto your\n");
printf("head. The scene around you disappears in a flash and you\n");
printf("find yourself transported to.....\n\n") ;
printf("             Pico Blvd., West Los Angeles\n\n") ;
printf("L.A. is having a stage three smog alert.  The air is so\n");
printf("foul you can taste it.  A Los Angeles municipal bus roars\n");
printf("by covering you in soot.  Across the street you see a\n");
printf("modern day Neanderthal selling vials of Crack to children.\n"); 
printf("The person next to you has taken a definite physical\n");
printf("interest in you.  She/he is wearing a short skirt and has a\n");
printf("beehive hairdo.  He/she also has a five o'clock shadow, and\n");
printf("bicepts so thick that he could collapse your skull with a\n");
printf("single thump.\n\n") ; 
printf("We now leave this unhappy scene.  Since you were sent to\n") ;
printf("Los Angeles your score has been zeroed.\n\n") ; 
printf("So ends yet another unsuccessful session at Dinkum!\n") ;

		if (sw_wizard) return ;
		else exit(0) ;
	}
	else {
		printf("I don't have a clapper to hit it with! \n") ;
		return ;
	}
}
else {
	printf("Thud! \n") ;
	printf("Nothing happened.\n") ;
printf("I think you'd have more success if you used a gong clapper.\n");
	return ;
}
} /* --- end of the "sounder" subroutine  --- */ 
