home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
games
/
volume15
/
dinkum2
/
part02
/
pusher.c
< prev
Wrap
C/C++ Source or Header
|
1993-01-27
|
19KB
|
601 lines
#define PUSHER
#include "dink_sym.h"
#include "dink_glb.h"
void pusher(n_arg)
/********************************************************************/
/* */
/* --- The Pusher Subroutine --- */
/* */
/* Software by Gary A. Allen, Jr. 14 June 1989, Version: Mk 1.2 */
/* (c) Copyright 1988 by Gary A. Allen, Jr. */
/* */
/********************************************************************/
int *n_arg ;
{
register int i ;
int n ;
char file_name[80] ;
#if (PROTOTYPE)
void which_button(void) ;
void lift_moves(void) ;
void nothing_happens(void) ;
void cubic(void) ;
void no_gray(void) ;
void no_switch(void) ;
void no_cube(void) ;
#endif
/* pass the room pointer */
n = *n_arg ;
/* reject an isolated "push" command */
if (tag[V_VERB_ONLY]) {
printf ("What exactly do you want me to push? \n");
return;
}
/* Deal with the recorder */
if ((tag[V_red_button] || tag[V_white_button] || tag[V_green_button])) {
if (sw_script) {
if (object[O_recorder][J_loc] == B_have) {
if (tag[V_red_button]) {
if (sw_recording || sw_playing) {
if (sw_recording) {
sw_recording = FALSE;
printf("--- The data recorder has stopped recording. ---\n") ;
}
else sw_playing = FALSE;
fclose(fp) ;
}
else printf("Nothing happened!\n") ;
return ;
}
if (tag[V_white_button]) {
printf("Type in the file name for reading from: ") ;
scanf("%s",file_name) ;
if ((fp = fopen(file_name,"r")) == 0) {
printf("I could not open the file: %s \n",file_name);
printf("This file probably doesn't exit.\n") ;
printf("Try pressing the white button again and using a different name.\n") ;
}
else sw_playing = TRUE ;
return ;
}
if (tag[V_green_button]) {
printf("Type in the file name for writing to: ") ;
scanf("%s",file_name) ;
if ((fp = fopen(file_name,"w")) == 0) {
printf ("I could not open the file: %s \n",file_name);
printf("Try pressing the green button again and using a different name.\n") ;
}
else {
sw_recording = TRUE ;
printf("--- Recording ---\n") ;
}
return ;
}
}
else printf("You don't have the recorder in your possession!\n") ;
}
else printf("I have never seen a button of that color.\n") ;
return ;
}
switch (n) {
/* Lift entrance at the ground level */
case R_lift_entr:
if (tag[V_gray_button]) {
no_gray() ;
return ;
}
if (!tag[V_button]) {
if (!tag[V_blue_button]) {
printf ("I don't see why I should push that! \n");
}
else nothing_happens() ;
return ;
}
if (room[R_lift_entr][M_rm_status] == S_flashing ) {
printf ("You push the call button and there is a loud \"whirr\" from ");
printf ("an electric motor. \nThe massive steel doors slide open ");
printf ("revealing a huge lift that could hold \ntwenty men at once. ");
printf ("The way is now open for you to enter. \n");
room[R_lift_entr][M_rm_status] = S_open ;
room[R_lift_entr][2] = R_lift_inside ;
break ;
}
else {
if (room[R_lift_entr][M_rm_status] == S_open) {
printf ("You push the call button and there is a loud \"whirr\" from ");
printf ("an electric motor. \nThe massive steel doors slide shut, ");
printf ("closing off access to the lift.\n");
room[R_lift_entr][M_rm_status] = S_flashing ;
room[R_lift_entr][2] = R_wall ;
break ;
}
else {
printf("You pushed the lift call button, but nothing happened.\n");
printf("I think the electrical power has been turned off at the\n") ;
printf("circuit breaker.\n") ;
break ;
}
}
/* Lift Compartment */
case R_lift_inside:
if (tag[V_gray_button]) {
no_gray() ;
return ;
}
/* scan push sentence */
/* zero level */
if (tag[V_0]) {
if (room[R_lift_inside][M_rm_status]== S_L0) {
printf ("You pushed the flashing button, but nothing happened.\n");
break ;
}
printf ("The steel doors slam shut and you feel heavy as the lift ");
printf ("accelerates \nupwards. Finally the lift jerks to a halt ");
printf ("and the doors whirr open. \nSunlight is streaming in. ");
printf ("Once again you are breathing the fresh air.\n");
room[R_lift_inside][M_rm_status] = S_L0;
room[R_lift_inside][3] = R_lift_entr;
room[R_lift_inside][7] = R_lift_entr;
return ;
}
/* forty-ninth level */
if (tag[V_49]) {
if (room[R_lift_inside][M_rm_status]== S_L49) {
printf ("You pushed the forty-nine button, but nothing happened.\n");
return ;
}
room[R_lift_inside][M_rm_status] = S_L49 ;
room[R_lift_inside][3] = R_L49_entr;
room[R_lift_inside][7] = R_L49_entr;
lift_moves() ;
return ;
}
/* sixty-seventh level */
if (tag[V_67]) {
if (room[R_lift_inside][M_rm_status]== S_L67) {
printf ("You pushed the sixty-seven button, but nothing happened.\n");
return ;
}
room[R_lift_inside][M_rm_status] = S_L67;
room[R_lift_inside][3] = R_L67_entr;
room[R_lift_inside][7] = R_L67_entr;
lift_moves() ;
return ;
}
/* eighty-second level */
if (tag[V_82]) {
if (room[R_lift_inside][M_rm_status]== S_L82) {
printf ("You pushed the eighty-two button, but nothing happened.\n");
return ;
}
room[R_lift_inside][M_rm_status] = S_L82;
room[R_lift_inside][3] = R_L82_entr;
room[R_lift_inside][7] = R_L82_entr;
printf ("The steel doors slam shut and you feel a sense of ");
printf ("weightlessness as \nthe lift plummets down the mine shaft. ");
printf ("Finally the lift comes to a halt \n");
printf ("and the doors whirr open. \n");
return ;
}
if (tag[V_blue_button]) {
nothing_happens() ;
return ;
}
printf ("This lift can go only to levels 0, 49, 67, or 82 \n");
return ;
/* inside the closet at the Iranian Parliament */
case R_closet:
if (tag[V_gray_button]) {
no_gray() ;
return ;
}
if (tag[V_blue_button] || tag[V_button]) {
/* Is the command for the black cube */
if (object[O_cube][J_loc] != B_have) {
no_switch() ;
}
printf("There is a bright flash of light! Then suddenly you are\n");
printf("back in the hexagon chamber of the ancient spaceship.\n\n");
*n_arg = R_transport ;
}
else no_switch() ;
return ;
/* the transporter control panel room */
case R_panel:
if (tag[V_button]) {
which_button() ;
return;
}
if (tag[V_blue_button]) {
if (object[O_cube][J_loc]==B_have) cubic() ;
else no_cube() ;
return ;
}
if (tag[V_gray_button]) {
if (sw_transport != TRUE) {
printf("Lots of the \"Sanskrit\" text is flashing by on the display\n");
printf("panel's CRTs. There is a whirring noise coming out of the\n");
printf("equipment around you which is increasing in both loudness\n");
printf("and pitch. You've turned something on, that's for sure!\n") ;
sw_transport = TRUE ;
}
else nothing_happens() ;
return ;
}
default:
/* Semtex explosive detector */
if (tag[V_detector] || tag[V_yellow_button] ||
((object[O_cube][J_loc] != B_have) &&
(object[O_detector][J_loc] == B_have))) {
if (object[O_detector][J_loc] == B_have) {
/* press Semtex detector button */
printf("You press the button on the Semtex explosive detector and\n");
for (i = 0; i <= 9; i++) {
if ((n == i+207)||(n == i+228)) {
if (room[227-i][M_rm_type] == T_lethal) {
printf("hear a \"beep, beep, beep\".\n") ;
return ;
}
}
}
printf("the yellow light flashed.\n") ;
}
else {
printf("You don't have the detector in your possession.\n") ;
}
return ;
}
/* Transporter return device */
if (object[O_cube][J_loc] == B_have) {
if ((object[O_detector][J_loc] == B_have) &&
(!tag[V_blue_button])) {
which_button() ;
return;
}
cubic() ;
return ;
}
if (tag[V_blue_button]) {
no_cube() ;
return ;
}
if (tag[V_gray_button]) {
no_gray() ;
return ;
}
printf ("You can push as much as you like, but nothing will happen.\n");
} /* end of the switch block */
return;
} /* --- end of the "pusher" subroutine --- */
void which_button()
/********************************************************************/
/* */
/* Software by Gary A. Allen, Jr. 8 December 1992 Version: Mk 1.0 */
/* (c) Copyright 1992 by Gary A. Allen, Jr. */
/* */
/********************************************************************/
{
printf("Which button do you want me to push? \n") ;
return;
} /* --- end of the "which_button" subroutine --- */
void lift_moves()
/********************************************************************/
/* */
/* Software by Gary A. Allen, Jr. 8 December 1992 Version: Mk 1.0 */
/* (c) Copyright 1992 by Gary A. Allen, Jr. */
/* */
/********************************************************************/
{
printf ("The steel doors slam shut and you feel the vibration of ");
printf ("the lift \nmoving in its shaft. Finally the lift jerks ");
printf ("to a halt and the doors whirr open. \n");
return;
} /* --- end of the "lift_moves" subroutine --- */
void nothing_happens()
/********************************************************************/
/* */
/* Software by Gary A. Allen, Jr. 8 December 1992 Version: Mk 1.0 */
/* (c) Copyright 1992 by Gary A. Allen, Jr. */
/* */
/********************************************************************/
{
printf("Nothing happens!\n");
return;
} /* --- end of the "nothing_happens" subroutine --- */
void cubic()
/********************************************************************/
/* */
/* Press cube button in wrong place. */
/* */
/* Software by Gary A. Allen, Jr. 8 December 1992 Version: Mk 1.0 */
/* (c) Copyright 1992 by Gary A. Allen, Jr. */
/* */
/********************************************************************/
{
printf("You press the button on the cube but nothing happens.\n");
return;
} /* --- end of the "cubic" subroutine --- */
void no_gray()
/********************************************************************/
/* */
/* Software by Gary A. Allen, Jr. 8 December 1992 Version: Mk 1.0 */
/* (c) Copyright 1992 by Gary A. Allen, Jr. */
/* */
/********************************************************************/
{
printf("I see no gray button to push!\n");
return;
} /* --- end of the "no_gray" subroutine --- */
void no_switch()
/********************************************************************/
/* */
/* Software by Gary A. Allen, Jr. 8 December 1992 Version: Mk 1.0 */
/* (c) Copyright 1992 by Gary A. Allen, Jr. */
/* */
/********************************************************************/
{
printf("There is nothing here with a push button switch.\n");
return;
} /* --- end of the "no_switch" subroutine --- */
void no_cube()
/********************************************************************/
/* */
/* Software by Gary A. Allen, Jr. 8 December 1992 Version: Mk 1.0 */
/* (c) Copyright 1992 by Gary A. Allen, Jr. */
/* */
/********************************************************************/
{
printf("You don't have the black cube with the blue button in your") ;
printf(" possession!\n") ;
return;
} /* --- end of the "no_cube" subroutine --- */
void switcher(n)
/********************************************************************/
/* */
/* --- The Switcher Subroutine --- */
/* */
/* */
/* Software by Gary A. Allen, Jr. 29 October 1989 Version: Mk 1.4 */
/* (c) Copyright 1988 by Gary A. Allen, Jr. */
/* */
/********************************************************************/
int n ;
{
int flag_switch, flag_rifle_md ;
#if (PROTOTYPE)
void dialer(int) ;
#endif
/* deal with single verb commands */
if (tag[V_VERB_ONLY]) {
if (tag[V_turn]) printf("Turn what?\n") ;
if (tag[V_set]) printf("Set what?\n") ;
if (tag[V_select]) printf("Select what?\n") ;
if (tag[V_switch]) printf("Switch what?\n") ;
return ;
}
/* Deal with changing the safety on the rifle */
if (tag[V_safety]) {
if (object[O_rifle][J_loc] == B_have) {
if (tag[V_off]) {
rifle_flag = F_single ;
printf("The M16 rifle is set to single shot mode ") ;
printf("with the safey off.\n") ;
return ;
}
if (tag[V_on]) {
rifle_flag = F_safety ;
printf("The M16 rifle's safety has been turned on.\n") ;
return ;
}
printf("How do you want the safety set?\n") ;
}
else printf("You're not holding the rifle!\n") ;
return ;
}
/* deal with special case "turn (safe) dial 0 49 67 82" */
if (tag[V_turn] && tag[V_dial] && (!tag[V_rifle])) {
dialer(n) ;
return ;
}
/* deal with special case "turn safe ..." */
if (tag[V_turn] && (!tag[V_dial]) && tag[V_safe]) {
if (n != R_office_mang) {
printf("There is no safe here to turn!\n") ;
return ;
}
printf("Since the safe is set in a concrete wall, turning it would\n");
printf("be rather difficult! Perhaps I should turn the safe's\n") ;
printf("dial instead?\n") ;
return ;
}
/* initialize the local switches */
flag_switch = F_no_argument ;
if (tag[V_on]) flag_switch = TRUE ;
if (tag[V_off]) flag_switch = FALSE ;
if (verb == V_light) flag_switch = TRUE ;
flag_rifle_md = F_no_argument ;
if (tag[V_safe]) flag_rifle_md = F_safety ;
if (tag[V_triple]) flag_rifle_md = F_triple ;
if (tag[V_single]) flag_rifle_md = F_single ;
if (tag[V_auto]) flag_rifle_md = F_auto ;
if ((flag_switch == F_no_argument)&&(flag_rifle_md == F_no_argument)) {
printf("You will have to be a little more specific than that. \n") ;
return ;
}
/* see if it is a simple "on/off" power equipment switch command */
if ((!tag[V_torch])&&(!tag[V_rifle])&&
(flag_rifle_md == F_no_argument)) {
if (n == R_store_room) {
/* The circuit breaker is switched off */
if (flag_switch == FALSE) {
if (room[R_store_room][M_rm_status] == S_off) {
printf ("The circuit breaker is already turned off! \n");
}
else {
printf ("As you pull the switch lever, there is a bright blue \n");
printf ("arc and then all of the lights go out. \n");
room[R_store_room][M_rm_status] = S_off ;
room[R_lift_entr][M_rm_status] = S_closed ;
}
return;
}
/* The circuit breaker is switched on */
if (flag_switch == TRUE) {
if (room[R_store_room][M_rm_status] == S_on) {
printf ("The circuit breaker is already turned on! \n");
}
else {
printf ("As you pull the switch lever, there is a loud \"CLUNK\" \n");
printf ("and you see a POWER ON light glowing. \n");
room[R_store_room][M_rm_status] = S_on ;
room[R_lift_entr][M_rm_status] = S_flashing ;
}
return;
}
}
/* Deal with a garbage command */
printf("I don't understand what you want me to switch. \n") ;
return ;
} /* end of the simple "on/off" switch group */
/* the switch command is to select an M16 rifle firing mode */
if (tag[V_rifle]) {
if (object[O_rifle][J_loc] == B_have) {
/* turn the rifle on naively */
if ((flag_switch==TRUE)||
((flag_rifle_md==F_safety)&&(flag_switch==FALSE))) {
if (rifle_flag != F_safety) {
printf("The rifle's safety is already off! \n") ;
return;
}
rifle_flag = F_single ;
printf("The M16 rifle has been set to single shot mode. \n") ;
return ;
}
/* turn on the safety */
if ((flag_switch==FALSE)||
((flag_rifle_md==F_safety)&&((flag_switch==TRUE)||
(flag_switch==F_no_argument)))) {
if (rifle_flag == F_safety) {
printf("The rifle's safety is already on! \n") ;
return;
}
rifle_flag = F_safety ;
printf("The M16 rifle's safety has now been turned on. \n") ;
return ;
}
/* select single shot mode */
if (flag_rifle_md == F_single) {
if (rifle_flag == F_single) {
printf("The rifle has already been set to single shot mode.\n");
return;
}
rifle_flag = F_single ;
printf("The M16 rifle has been set to single shot mode. \n") ;
return ;
}
/* select triple fire mode */
if (flag_rifle_md == F_triple) {
if (rifle_flag == F_triple) {
printf("The rifle has already been set to triple fire mode.\n");
return;
}
rifle_flag = F_triple ;
printf("The M16 rifle has been set to triple fire mode. \n") ;
return ;
}
/* select to fully automatice mode */
if (flag_rifle_md == F_auto) {
if (rifle_flag == F_auto) {
printf("The rifle has already been set to fully automatic.\n");
return;
}
rifle_flag = F_auto ;
printf("The M16 rifle has been set to fully automatic. \n") ;
return ;
}
}
/* This is the rifle nonpossession error handler */
else {
printf("You don't have a rifle in your possession! \n") ;
return ;
}
} /* end of the rifle mode switching block */
/* the switch command is to turn the torch off or on. */
if (tag[V_torch]) {
if (object[O_torch][J_loc] == B_have) {
/* "switch torch on" command */
if (flag_switch==TRUE) {
if (object[O_torch][J_property]) {
printf("The torch is already turned on.\n") ;
return ;
}
printf("An intense beam of light is projected from the torch.\n") ;
object[O_torch][J_property] = TRUE ;
return ;
}
/* "switch torch off" command */
if (flag_switch==FALSE) {
if (!object[O_torch][J_property]) {
printf("The torch isn't switched on.\n") ;
return ;
}
printf("The torch switches off with a \"click\".\n") ;
object[O_torch][J_property] = FALSE ;
return ;
}
}
printf("You don't have a torch in your possession to switch! \n") ;
return ;
}
} /* --- end of the "switcher" subroutine --- */
void new_score()
/* This subroutine calculates the score based on treasure in the safe */
{
int i ;
score = 0 ;
for (i = 0; i <= objcnt; i++) if (object[i][J_loc] == B_in_safe) {
score += object[i][J_value] ;
} ;
} /* --- end of the "new_score" subroutine --- */