Don't allow weapon to be fired if owner's facing is FACING_DIE.

This commit is contained in:
Steve 2018-02-25 17:30:05 +00:00
parent 501db4420b
commit 4ff02a82e5
1 changed files with 115 additions and 88 deletions

View File

@ -69,6 +69,8 @@ void firePistol(void)
{
Bullet *bullet;
if (world.bob->facing != FACING_DIE)
{
bullet = createBaseBullet((Unit*)world.bob);
bullet->weaponType = WPN_PISTOL;
bullet->facing = world.bob->facing;
@ -77,7 +79,8 @@ void firePistol(void)
world.bob->reload = 20;
playSound(SND_PISTOL, CH_BOB);
playSound(SND_PISTOL, world.bob->uniqueId % MAX_SND_CHANNELS);
}
}
void fireAimedShot(Unit *owner)
@ -86,6 +89,8 @@ void fireAimedShot(Unit *owner)
float dx, dy;
Bullet *bullet;
if (owner->facing != FACING_DIE)
{
x = (int) (world.bob->x + rrnd(-8, 24));
y = (int) (world.bob->y + rrnd(-8, 24));
@ -100,26 +105,32 @@ void fireAimedShot(Unit *owner)
owner->reload = 15;
playSound(SND_PISTOL, CH_WEAPON);
playSound(SND_PISTOL, owner->uniqueId % MAX_SND_CHANNELS);
}
}
void fireMachineGun(Unit *owner)
{
Bullet *bullet;
if (owner->facing != FACING_DIE)
{
bullet = createBaseBullet(owner);
bullet->weaponType = WPN_MACHINE_GUN;
bullet->sprite[0] = bulletSprite[0];
bullet->sprite[1] = bulletSprite[1];
owner->reload = 8;
playSound(SND_MACHINE_GUN, CH_WEAPON);
playSound(SND_MACHINE_GUN, owner->uniqueId % MAX_SND_CHANNELS);
}
}
void firePlasma(Unit *owner)
{
Bullet *bullet;
if (owner->facing != FACING_DIE)
{
bullet = createBaseBullet(owner);
bullet->weaponType = WPN_PLASMA;
bullet->sprite[0] = plasmaSprite[0];
@ -128,7 +139,8 @@ void firePlasma(Unit *owner)
owner->reload = owner->type == ET_BOB ? 4 : 8;
playSound(SND_PLASMA, owner->type == ET_BOB ? CH_BOB : CH_WEAPON);
playSound(SND_PLASMA, owner->uniqueId % MAX_SND_CHANNELS);
}
}
void fireSpread(Unit *owner, int numberOfShots)
@ -137,6 +149,8 @@ void fireSpread(Unit *owner, int numberOfShots)
int i;
float dy;
if (owner->facing != FACING_DIE)
{
dy = -(numberOfShots / 2) * 3;
for (i = 0 ; i < numberOfShots ; i++)
@ -152,13 +166,16 @@ void fireSpread(Unit *owner, int numberOfShots)
owner->reload = 16;
}
playSound(SND_SPREAD, owner->type == ET_BOB ? CH_BOB : CH_WEAPON);
playSound(SND_SPREAD, owner->uniqueId % MAX_SND_CHANNELS);
}
}
void fireLaser(Unit *owner)
{
Bullet *laser;
if (owner->facing != FACING_DIE)
{
laser = createBaseBullet(owner);
laser->x = owner->x + owner->w / 2;
laser->y = owner->y + owner->h / 2;
@ -171,13 +188,16 @@ void fireLaser(Unit *owner)
owner->reload = owner->type == ET_BOB ? FPS / 2 : FPS;
playSound(SND_LASER, owner->type == ET_BOB ? CH_BOB : CH_WEAPON);
playSound(SND_LASER, owner->uniqueId % MAX_SND_CHANNELS);
}
}
void fireGrenade(Unit *owner)
{
Bullet *grenade;
if (owner->facing != FACING_DIE)
{
grenade = createBaseBullet(owner);
grenade->x = owner->x + owner->w / 2;
grenade->y = owner->y;
@ -191,7 +211,8 @@ void fireGrenade(Unit *owner)
owner->reload = FPS / 2;
playSound(SND_THROW, owner->type == ET_BOB ? CH_BOB : CH_WEAPON);
playSound(SND_THROW, owner->uniqueId % MAX_SND_CHANNELS);
}
}
void fireShotgun(Unit *owner)
@ -200,6 +221,8 @@ void fireShotgun(Unit *owner)
float dx, dy;
Bullet *bullet;
if (owner->facing != FACING_DIE)
{
for (i = 0 ; i < 8 ; i++)
{
getSlope(world.bob->x + rrnd(0, 40), world.bob->y + rrnd(0, 40), owner->x, owner->y, &dx, &dy);
@ -216,13 +239,16 @@ void fireShotgun(Unit *owner)
owner->reload = 15;
}
playSound(SND_SHOTGUN, CH_WEAPON);
playSound(SND_SHOTGUN, owner->uniqueId % MAX_SND_CHANNELS);
}
}
void fireMissile(Unit *owner)
{
Bullet *missile;
if (owner->facing != FACING_DIE)
{
missile = createBaseBullet(owner);
missile->x = owner->x + owner->w / 2;
missile->y = owner->y + 10;
@ -236,7 +262,8 @@ void fireMissile(Unit *owner)
owner->reload = FPS / 2;
playSound(SND_MISSILE, CH_WEAPON);
playSound(SND_MISSILE, owner->uniqueId % MAX_SND_CHANNELS);
}
}
int getRandomPlayerWeapon(int excludeGrenades)