home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / sources.arc / DANG_SRC.LZH / MISC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-12  |  10.3 KB  |  412 lines

  1. #include <globals2.h>
  2. #include <osbind.h>
  3. #include <stdio.h>
  4. extern int  buffer[];        /* holds the char info for disk loading and saving */
  5. #define max_items 50          /* max weapons */
  6.  
  7.  
  8.  
  9. /** misc routines needed 
  10.  
  11.   switch_weapon()
  12.   scroller()
  13.   list_user_items()
  14.   special_display()
  15.  
  16.  
  17. **/
  18.  
  19. /**************************************************/
  20. switch_weapon()
  21. {
  22.   char s;
  23.   int var_,hold_num;
  24.  
  25.  
  26.   view_backpack();
  27.   v_justified(handle,6,83,"# to equip [X] to exit",184,0,1);
  28.   do
  29.   {
  30.     s = Bconin(2);
  31.   if( s == 'x' || s== 'X' ) return(1);
  32.  }while( (s-'0' < 0 || s-'0' >6) || (user.backpack[s - '0'] == -1));        /* if you dont own it, can sell it! */
  33.   
  34.   var_ = user.backpack[s-'0'];
  35.  
  36.   hold_num = calc_num();   /* calc. current weapons hit damage and id */ 
  37.                                    /* clear it */
  38.     v_gtext(handle,78,174,"             ");
  39.   strcpy(user.weapon,unique_item[var_].name);  /* copy new weapon */
  40.  
  41.   user.weapon_num = unique_item[var_].points;  /* set weapon hit damage */
  42.   user.backpack[s-'0'] = hold_num; /* place old weapon here */
  43.    
  44. }
  45.  
  46. calc_num()
  47. {
  48.  int p = -1, found = 0;
  49.  
  50.   while( p < max_items && !found)  
  51.    {
  52.     p++;
  53.     if( (strcmp(unique_item[p].name,user.weapon)) == 0) /* if found*/
  54.          found = 1;
  55.    
  56.    }
  57.  
  58.    if( found) return(unique_item[p].points);
  59.    else return(-1);  /* else return 'Empty' */
  60.  
  61. }
  62.  
  63. /********************************/
  64. /** list_user_items()
  65.    
  66.     Lists the items the user has.
  67.  
  68. **/
  69.  
  70. list_user_items()
  71. {
  72.  char com;
  73.  int picked;
  74.  int offset=6; /* so we can process potions, 1st one is 6..*/
  75.  
  76. clear_it();
  77.  
  78. sprintf(string,"0) Food   :%d",user.user_items[0]);
  79. v_gtext(handle,6,11,string);
  80.  
  81. sprintf(string,"1) Water  :%d",user.user_items[1]);
  82. v_gtext(handle,6,19,string);
  83.  
  84. sprintf(string,"2) Keys   :%d",user.user_items[2]);
  85. v_gtext(handle,6,27,string);
  86.  
  87. sprintf(string,"3) Torches:%d",user.user_items[3]);
  88. v_gtext(handle,6,35,string);
  89.  
  90. sprintf(string,"4) Gems   :%d",user.user_items[4]);
  91. v_gtext(handle,6,43,string);
  92.  
  93. sprintf(string,"5) Jewels :%d",user.user_items[5]);
  94. v_gtext(handle,6,51,string);
  95. v_gtext(handle,6,67,"# to use or C to ");
  96. v_gtext(handle,6,75,"Continue...      ");
  97. com = Bconin(2);
  98. picked = com-'0';
  99.  
  100. if( com == 'C' || com == 'c' )
  101. {
  102. v_gtext(handle,6,11,"       POTIONS   ");
  103. v_gtext(handle,6,19,"                 ");
  104. sprintf(string,"0) Healing          :%d",user.user_items[6]);
  105. v_gtext(handle,6,27,string);
  106.  
  107. sprintf(string,"1) Cure Poison      :%d",user.user_items[7]);
  108. v_gtext(handle,6,35,string);
  109.  
  110. sprintf(string,"2) Treasure Finding :%d",user.user_items[8]);
  111. v_gtext(handle,6,43,string);
  112.  
  113. sprintf(string,"3) Fleetness        :%d",user.user_items[9]);
  114. v_gtext(handle,6,51,string);
  115.  
  116. sprintf(string,"4) Protection       :%d",user.user_items[10]);
  117. v_gtext(handle,6,59,string);
  118.  
  119. sprintf(string,"5) Strength         :%d",user.user_items[11]);
  120. v_gtext(handle,6,67,string);
  121.  
  122. sprintf(string,"6) Charm            :%d",user.user_items[12]);
  123. v_gtext(handle,6,75,string);
  124.  
  125. v_gtext(handle,6,83,"# to use or (E)xit");
  126. com = Bconin(2);
  127. picked = com-'0' + offset;  /* will give a # from 6 to 12..(or above) */
  128. }
  129.  
  130. clear_it();
  131. if( com != 'E' && com != 'e' )
  132. {
  133.  if(user.user_items[picked] > 0 )
  134.     {
  135.     clear_it();
  136.     if(picked !=4 && picked !=5 && picked != 13 && picked !=14) /* dont use these items up!!! they are not perishable!! */
  137.     user.user_items[picked]--;   /* use it up! */
  138.     /* 4 = gem, 5 = jewel, 13 = timepiece,14=key to gate */
  139.     switch(picked)
  140.      {
  141.       case  0:  if(user.user_items[0]>0) user.hunger_thurst_status[0]--;/*food */
  142.                 if(user.hunger_thurst_status[0] < 0) user.hunger_thurst_status[0]=0; 
  143.                 v_gtext(handle,204,126,"         ");
  144.                 break;   /* food */
  145.       case  1:  if(user.user_items[1]>0) user.hunger_thurst_status[1]--;
  146.                 if(user.hunger_thurst_status[1] < 0) user.hunger_thurst_status[1]=0; 
  147.                 v_gtext(handle,204,134,"       ");
  148.                 break; /* h20 */
  149.       case  2:unlock_door();  break;
  150.       case  3:light_torch();  break;
  151.       case  4:       /* gem */
  152.       case  5:v_gtext(handle,6,11,"You can use that!"); break; /* jewel */
  153.       case  6:    /* potions */
  154.       case  7:
  155.       case  8:
  156.       case  9:
  157.       case  10:
  158.       case  11:
  159.       case  12: open_potion(picked); 
  160.                 v_gtext(handle,6,11,"You quaff the potion");break;
  161.       case  13: break;  /* timepiece.. */
  162.       case  14: break;  /* key to wizards gate.. */
  163.      }
  164.     } /* end of use item */
  165.    else v_gtext(handle,6,11,"You dont have any...");
  166.  }  
  167.  
  168. }
  169. /****************************************************/
  170. /** routines that are called from use user_item
  171.     unlock_door, light_torch,use food,h20,
  172.     open_potion(picked) & check_time
  173. **/
  174. unlock_door()
  175. {}
  176. light_torch()
  177. {}
  178. open_potion( potion )
  179. int potion;
  180. {
  181.  int amount;
  182.  
  183.   
  184.  /* the potions sent range from 6 to 12. 
  185.     potion 6 is heal..etc */
  186.   if(potion == 6) /* if heal.. */
  187.    {
  188.     amount = user.con;
  189.     if (user.hp + amount > user.max_hp) user.hp = user.max_hp;
  190.     else user.hp+=amount;
  191.    }
  192.   if( potion == 7 )
  193.    {   /* not inplememted yet!! cure!! */
  194.    }
  195.   else   /* we get here. we're at potions 8-12 !! */
  196.    {
  197.      potion -=8;  /* get it into range 0 to 4 */
  198.      user.current_spells_active[potion] = 1; /* set it active!! */
  199.    }   
  200.  
  201. }
  202.  
  203.  
  204. /***/
  205. check_for_sound_change()
  206. {
  207.  /* re-play sound if there was sound playing before encounter */
  208.           if(CURRENT_SOUND == 1) Dosound( wind_sound );
  209.  
  210.           if(CURRENT_SOUND == 4) Dosound( rain_sound );
  211.  
  212. }
  213.  
  214. /******/
  215. special_display()
  216. {
  217.  int vert = 27;
  218.  char com;
  219.  
  220.  clear_it();
  221.  
  222.   v_gtext(handle,6,11,"   ~Special Stats~ ");
  223.   sprintf(string,"Gold:%ld",user.gold);
  224.   v_gtext(handle,6,27,string);
  225.   sprintf(string,"Exp:%ld",user.exp);
  226.   v_gtext(handle,6,35,string);
  227.   v_gtext(handle,6,83,"Press any key");
  228.   com = Bconin(2);
  229.   clear_it();
  230.   v_gtext(handle,6,11," ~Active Spells/Magic~");
  231.   if(user.user_items[17]) {v_gtext(handle,6,vert,"CURSED!!"); vert+=8;}
  232.   if(user.current_spells_active[0]){v_gtext(handle,6,vert,"TREASURE FINDING"); vert+=8;}
  233.   if(user.current_spells_active[1]){v_gtext(handle,6,vert,"FLEETNESS"); vert+=8;}
  234.   if(user.current_spells_active[2]){v_gtext(handle,6,vert,"PROTECTION"); vert+=8;}
  235.   if(user.current_spells_active[3]){v_gtext(handle,6,vert,"STRENGTH"); vert+=8;}
  236.   if(user.current_spells_active[4]){v_gtext(handle,6,vert,"CHARM"); vert+=8;}
  237.   v_gtext(handle,6,83,"Press anykey");
  238.   com = Bconin(2);
  239.   clear_it();
  240.   vert = 27;
  241.   v_gtext(handle,6,11,"   ~Special Items~ ");
  242.   if(user.user_items[13]){v_gtext(handle,6,vert,"Timepiece"); vert +=8;}
  243.   if(user.user_items[14]){v_gtext(handle,6,vert,"Mithril Key"); vert +=8;}
  244.   vert+=8;
  245.   v_gtext(handle,6,vert,"Occupation");
  246.   vert+=8;
  247.   if(user.user_items[17]) v_gtext(handle,6,vert,"Guild Member");
  248.   else v_gtext(handle,6,vert,"Adventurer");
  249.  
  250.  v_gtext(handle,6,83,"Press any key");
  251.  com = Bconin(2);
  252. }
  253.  
  254.  
  255. /*****************************/
  256. game_options(temp,scr1,scr2,scr3,scr4,scr5,scr6)
  257. char *temp,*scr1,*scr2,*scr3,*scr4,*scr5,*scr6;
  258. {
  259.  long cli;
  260.  char ddd,disk;
  261.  int mask = 1,catch;
  262.  
  263.  clear_it();
  264.  
  265. do
  266. {
  267.  v_gtext(handle,6,11,"     Game Options  ");
  268.  v_gtext(handle,6,27,"  1. Save Game ");
  269.  v_gtext(handle,6,35,"  2. Quit Game ");
  270.  v_gtext(handle,6,43,"  3. Sound on/off ");
  271.  v_gtext(handle,6,51,"  4. Credits");
  272.  v_gtext(handle,6,59,"  5. Exit");
  273.  
  274.  cli = Bconin(2);
  275.  if(cli == 0x20031)  {
  276. do
  277. {
  278. if( (catch=Fopen("char.dat",0)) < 0 )
  279.   {
  280.       v_gtext(handle,6,11,"Please insert Disk 1");
  281.       v_gtext(handle,6,19,"into the current drive");
  282.       v_gtext(handle,6,27,"and press any key.");
  283.       disk = Bconin(2);
  284.        clear_it();
  285.   }
  286.     Fclose(catch);
  287. } while(catch < 0 );
  288.  
  289.  
  290.       save_character();
  291.       
  292.       disk = Bconin(2);
  293. do
  294. {
  295. if( (catch=Fopen("appla",0)) < 0 )
  296.   {
  297.       v_gtext(handle,6,27,"Please insert Disk 2");
  298.       v_gtext(handle,6,35,"into the current drive");
  299.       v_gtext(handle,6,43,"and press any key.");
  300.       disk = Bconin(2);
  301.        clear_it();
  302.   }
  303.     Fclose(catch);
  304. } while(catch < 0 );
  305.  
  306.   }
  307.                                       /* save */ 
  308.    
  309.   if(cli == 0x30032) quit_game(temp,scr1,scr2,scr3,scr4,scr5,scr6);     /* quit */
  310.    
  311.   if(cli == 0x40033)    /* sound on-off */
  312.    {
  313.     if(sound == 1) v_gtext(handle,6,75,"Sound is now OFF");
  314.     else v_gtext(handle,6,75,"Sound is now ON");
  315.     sound ^= mask;   /* xor with mask */ 
  316.   }
  317.   if(cli == 0x50034)
  318.    {
  319.     clear_it();
  320.     v_gtext(handle,6,11,"Concept and Programming");
  321.     v_gtext(handle,6,19," by Jeffrey  M. Bilger ");
  322.     v_gtext(handle,6,27,"  jmb8302@cs.tamu.edu ");
  323.     v_gtext(handle,6,43," Texas A&M University. ");
  324.     v_gtext(handle,6,51,"   12 December 1993    ");
  325.     v_gtext(handle,6,67,"     Hit any key      ");
  326.     ddd = Bconin(2);  
  327.    }
  328. clear_it();
  329. }while(cli != 0x60035);  /* do until exit chosen */
  330.  
  331.  
  332.  
  333.  
  334.  
  335. }
  336.  
  337. /**
  338.           **/
  339. save_character()
  340. {
  341. FILE *ofp;
  342. char out,ddd;
  343. int x;
  344.  
  345. clear_it();
  346. v_gtext(handle,6,11,"  Save a Character");
  347.  
  348.     v_gtext(handle,6,27,"Are you sure? [y/n]");
  349.   
  350.    do
  351.     {
  352.     ddd = Bconin(2);  
  353.     }while( (ddd !='Y' && ddd !='y') && (ddd !='N' && ddd !='n') );
  354.  
  355.   if( ddd == 'Y' || ddd == 'y')
  356.   {
  357.      savechar(buffer);
  358.      v_gtext(handle,6,67,"Character saved");
  359.    }
  360. }
  361. /******************************/
  362.  
  363.  
  364. quit_game(temp,scr1,scr2,scr3,scr4,scr5,scr6)
  365. char *temp,*scr1,*scr2,*scr3,*scr4,*scr5,*scr6;
  366. {
  367. char ddd;
  368. int on();
  369. int qr;
  370.  
  371. clear_it();
  372.           v_gtext(handle,6,19,"Quit......");
  373.     v_gtext(handle,6,27,"Did you SAVE yet?");
  374.     v_gtext(handle,6,35,"Really want to quit? ");
  375.     v_gtext(handle,6,43,"       [y/n]");
  376.   
  377.    do
  378.     {
  379.     ddd = Bconin(2);  
  380.     }while( (ddd !='Y' && ddd !='y') && (ddd !='N' && ddd !='n') );
  381.  
  382.    if( ddd == 'Y' || ddd == 'y' ) 
  383.      {
  384.      free(temp); free(scr1); free(scr2); free(scr3); free(scr4);
  385.      free(scr5); free(scr6);
  386.     cool_effect();
  387.     }
  388. }
  389.  
  390. cool_effect()
  391. {
  392.      do
  393.      {
  394.      v_gtext(handle,6,75,"    ~ Press Reset ~   ");  
  395.      pauser();
  396.      v_gtext(handle,6,75,"                      ");
  397.      pauser();
  398.      }while(1);
  399.      
  400. }
  401.  
  402.  
  403. /****************/
  404. on()
  405. {
  406.  char *conterm;
  407.  
  408. conterm = (char *) 0x484L;
  409. *conterm |=0x01; /*turn keyclick on */
  410.  
  411. }
  412.