home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume18 / xmpb / part07 / ud_win.c < prev    next >
C/C++ Source or Header  |  1993-07-12  |  2KB  |  133 lines

  1. /* ud_win.c - *** Handle button presses etc. */
  2.  
  3. static char sccs_id[] = "@(#)ud_win.c 1.17 92/11/24 XMPB";
  4.  
  5. #include "player.h"
  6.  
  7. extern int weap_energy[NO_WEAPONS];        /* what energy does the weapon use */
  8. extern int load_rate[NO_WEAPONS];        /* how fast does it load */
  9. extern winptr first_win;
  10.  
  11. /*
  12. *    Do all of the firing, changing weapons, and thrusting controlled 
  13. *    by the mouse for all of the players
  14. */
  15. update_win_input()
  16. {
  17.     winptr t;
  18.  
  19.     t = first_win;
  20.     while(t)
  21.     {
  22.         /*
  23.         *    Can't do anything if you're dead!
  24.         */
  25.         if(t->exploding)
  26.             goto kludge2;
  27.  
  28.         /*
  29.         *    They want to thrust
  30.         */
  31.         if(t->b3)
  32.         {
  33.             t->t2 = 1;
  34.         }
  35.         else
  36.         {
  37.             t->t2 = 0;
  38.         }
  39.  
  40.         /* 
  41.         *    continue loading all weapons  
  42.         */
  43.         {
  44.             int i;
  45.         
  46.             for(i=0;i<NO_WEAPONS;i++)
  47.             {
  48.                 if(t->load_status[i] > 0) 
  49.                     t->load_status[i]--;
  50.             }
  51.         }
  52.  
  53.         if(t->b1 && t->b2 && t->curr_weap != -1)
  54.         {
  55.             int i = t->curr_weap;
  56.             t->curr_weap++;
  57.             t->curr_weap %= NO_WEAPONS;
  58.  
  59.             /*
  60.             *    During a "nailstorm", go to the next ready weapon
  61.             */
  62.             while((!t->does_have_weap[t->curr_weap] || t->load_status[t->curr_weap] != 0 || t->weap_on_status[t->curr_weap] == 0) && i != t->curr_weap)
  63.             {
  64.                 t->curr_weap++;
  65.                 t->curr_weap %= NO_WEAPONS;
  66.             }
  67.             t->changed_last_frame = 1;
  68.         }
  69.         else    
  70.         /*
  71.         *    Change weapons only if we didn't change last frame
  72.         */    
  73.         if(t->b2 && !(t->changed_last_frame) && t->curr_weap != -1)
  74.         {
  75.             int cw,noweap=0;
  76.             /* 
  77.             *    Go to the next weapon
  78.             */
  79.             cw = t->curr_weap%NO_WEAPONS;
  80.             
  81.             t->curr_weap++;
  82.             t->curr_weap %= NO_WEAPONS;
  83.     
  84.             /*
  85.             *    Make sure the ship has the weapon
  86.             */
  87.             while(!t->does_have_weap[t->curr_weap])
  88.             {
  89.                 t->curr_weap++;
  90.                 t->curr_weap %= NO_WEAPONS;
  91.                 if(t->curr_weap == cw)
  92.                 {
  93.                     if(!t->does_have_weap[t->curr_weap]) noweap = 1;
  94.                     break;
  95.                 }
  96.             }
  97.             if(noweap)
  98.                 t->curr_weap = -1;
  99.  
  100.             /*
  101.             *    Don't allow a weapon change next frame
  102.             */
  103.             t->changed_last_frame = 1;
  104.         }
  105.         else 
  106.         {
  107.             /*
  108.             *    Ok they can change next frame
  109.             */
  110.             t->changed_last_frame = 0;
  111.         }
  112.  
  113.         
  114.         /*
  115.         *    Fire weapons if we have enough energy and the weapon is loaded
  116.         *    and on
  117.         */    
  118.         if(t->b1 && (t->load_status[t->curr_weap] == 0) && 
  119.             (t->energy_curr > weap_energy[t->curr_weap]) && 
  120.             (t->weap_on_status[t->curr_weap]) && t->curr_weap != -1)
  121.         {
  122.             fire_weapon(t);
  123.         }
  124.         
  125.         /*
  126.         *    Do the pics for thrust
  127.         */
  128.         update_thrust(t);
  129. kludge2:
  130.         t = t->next;
  131.     }
  132. }
  133.