mirror of
https://github.com/Blzut3/Wolf3D-Mac.git
synced 2024-11-28 15:50:19 +00:00
1 line
12 KiB
C
1 line
12 KiB
C
|
#include "wolfdef.h"
#define SHOTRATE 6
/**********************************
Change my weapon to the biggest one I got
**********************************/
static void OutOfAmmo(void)
{
if (gamestate.missile && gamestate.missiles) {
gamestate.pendingweapon = WP_MISSILE;
return; /* Launcher & missiles */
}
if (gamestate.flamethrower && gamestate.gas) {
gamestate.pendingweapon = WP_FLAMETHROWER;
return; /* Flames and gas */
}
if (gamestate.ammo) {
if (gamestate.chaingun) {
gamestate.pendingweapon = WP_CHAINGUN;
return;
}
if (gamestate.machinegun) {
gamestate.pendingweapon = WP_MACHINEGUN;
return;
}
gamestate.pendingweapon = WP_PISTOL;
return;
}
gamestate.pendingweapon = WP_KNIFE;
}
/**********************************
Draw the ammo for the new weapon
**********************************/
void ChangeWeapon (void)
{
switch(gamestate.weapon) { /* Which weapon */
case WP_PISTOL:
case WP_MACHINEGUN:
case WP_CHAINGUN:
IO_DrawAmmo(gamestate.ammo); /* Draw bullets */
break;
case WP_FLAMETHROWER:
IO_DrawAmmo(gamestate.gas); /* Draw gasoline */
break;
case WP_MISSILE:
IO_DrawAmmo(gamestate.missiles); /* Draw missiles */
}
}
/**********************************
Fire my weapon, change to knife if no more ammo
**********************************/
void Cmd_Fire(void)
{
switch(gamestate.weapon) {
case WP_CHAINGUN:
case WP_MACHINEGUN:
case WP_PISTOL:
if (!gamestate.ammo) { /* Do I have ammo? */
OutOfAmmo(); /* Change the weapon */
}
break;
case WP_FLAMETHROWER:
if (!gamestate.gas) {
OutOfAmmo(); /* Change the weapon */
}
break;
case WP_MISSILE:
if (!gamestate.missiles) {
OutOfAmmo(); /* Change the weapon */
}
}
gamestate.attackframe = 1; /* Begin the attack */
gamestate.attackcount = SHOTRATE; /* Time before next action */
}
/**********************************
Try to use a switch, door or pushwall...
**********************************/
void Cmd_Use(void)
{
Word dir; /* Direction facing */
Word tile; /* Tile tested */
Word x,y; /* x,y of the tile to test */
/* Find which cardinal direction the player is facing */
x = actors[0].x >> FRACBITS; /* Get the x,y in tiles */
y = actors[0].y >> FRACBITS;
dir = ((gamestate.viewangle+ANGLES/8)&(ANGLES-1)) >> 7; /* Force into a cardinal direction */
switch (dir) {
case 0:
x++;
dir = CD_EAST; /* East */
break;
case 1:
y--;
dir = CD_NORTH; /* North */
break;
case 2:
x--;
dir = CD_WEST; /* West */
break;
case 3:
y++;
dir = CD_SOUTH; /* South */
}
tile = tilemap[y][x]; /* Get the tile data */
if (tile & TI_DOOR) { /* Is this a door? */
OperateDoor(tile&TI_NUMMASK); /* Door # to operate */
return;
}
if (!PushWallRec.pwallcount && (tile&TI_PUSHWALL)) { /* Push wall? */
PushWall(x,y,dir); /* Note: Only 1 pushwall at a time! */
return;
}
if (tile & TI_SWITCH) { /* Elevator switch? */
PlaySound(SND_THROWSWITCH|0x8000);
playstate = EX_COMPLETED;
return;
}
if (tile & TI_SECRET) { /* Secret level? */
PlaySound(SND_THROWSWITCH|0x8000);
playstate = EX_SECRET;
return;
}
if (tile & TI_BLOCKSIGHT) {
PlaySound(SND_HITWALL|0x8000); /* Oof! */
}
}
/**********************************
Change my weapon
**********************************/
void Cmd_ChangeWeapon(void)
{
for (;;) {
++gamestate.pendingweapon; /* Next weapon */
switch(gamestate.pendingweapon) {
case WP_PISTOL:
if (gamestate.ammo) { /* Do I have ammo ? */
return; /* Use it! */
}
break;
case WP_MACHINEGUN:
if (gamestate.machinegun && gamestate.ammo) {
return; /* Machine gun & ammo! */
}
break;
case WP_CHAINGUN:
if (gamestate.cha
|