home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume18
/
xmpb
/
part07
/
ud_win.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-12
|
2KB
|
133 lines
/* ud_win.c - *** Handle button presses etc. */
static char sccs_id[] = "@(#)ud_win.c 1.17 92/11/24 XMPB";
#include "player.h"
extern int weap_energy[NO_WEAPONS]; /* what energy does the weapon use */
extern int load_rate[NO_WEAPONS]; /* how fast does it load */
extern winptr first_win;
/*
* Do all of the firing, changing weapons, and thrusting controlled
* by the mouse for all of the players
*/
update_win_input()
{
winptr t;
t = first_win;
while(t)
{
/*
* Can't do anything if you're dead!
*/
if(t->exploding)
goto kludge2;
/*
* They want to thrust
*/
if(t->b3)
{
t->t2 = 1;
}
else
{
t->t2 = 0;
}
/*
* continue loading all weapons
*/
{
int i;
for(i=0;i<NO_WEAPONS;i++)
{
if(t->load_status[i] > 0)
t->load_status[i]--;
}
}
if(t->b1 && t->b2 && t->curr_weap != -1)
{
int i = t->curr_weap;
t->curr_weap++;
t->curr_weap %= NO_WEAPONS;
/*
* During a "nailstorm", go to the next ready weapon
*/
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)
{
t->curr_weap++;
t->curr_weap %= NO_WEAPONS;
}
t->changed_last_frame = 1;
}
else
/*
* Change weapons only if we didn't change last frame
*/
if(t->b2 && !(t->changed_last_frame) && t->curr_weap != -1)
{
int cw,noweap=0;
/*
* Go to the next weapon
*/
cw = t->curr_weap%NO_WEAPONS;
t->curr_weap++;
t->curr_weap %= NO_WEAPONS;
/*
* Make sure the ship has the weapon
*/
while(!t->does_have_weap[t->curr_weap])
{
t->curr_weap++;
t->curr_weap %= NO_WEAPONS;
if(t->curr_weap == cw)
{
if(!t->does_have_weap[t->curr_weap]) noweap = 1;
break;
}
}
if(noweap)
t->curr_weap = -1;
/*
* Don't allow a weapon change next frame
*/
t->changed_last_frame = 1;
}
else
{
/*
* Ok they can change next frame
*/
t->changed_last_frame = 0;
}
/*
* Fire weapons if we have enough energy and the weapon is loaded
* and on
*/
if(t->b1 && (t->load_status[t->curr_weap] == 0) &&
(t->energy_curr > weap_energy[t->curr_weap]) &&
(t->weap_on_status[t->curr_weap]) && t->curr_weap != -1)
{
fire_weapon(t);
}
/*
* Do the pics for thrust
*/
update_thrust(t);
kludge2:
t = t->next;
}
}