From e7abfe30a6d562d9c09d8defbb1711b2c6e52eca Mon Sep 17 00:00:00 2001 From: onpon4 Date: Thu, 7 Jan 2016 19:01:25 -0500 Subject: [PATCH] Fixed the bug that caused mobile rays to shoot bullets. This was a strange cause, and I wonder why it happened. Quite simply, there was an assumption in the code that any alien's primary weapon was a bullet, despite the fact that the secondary weapon code could handle any weapon, including bullets. I've fixed this by getting rid of the special primary weapon mechanism; the one for the secondary weapons is used on primary weapons as well. --- src/alien.cpp | 2 +- src/game.cpp | 51 ++++++++++++++++++++++++--------------------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/alien.cpp b/src/alien.cpp index e64959c..447c01e 100644 --- a/src/alien.cpp +++ b/src/alien.cpp @@ -522,7 +522,7 @@ void alien_defs_init() alien_defs[CD_MOBILE_RAY].weaponType[0] = W_ENERGYRAY; alien_defs[CD_MOBILE_RAY].weaponType[1] = W_ENERGYRAY; alien_defs[CD_MOBILE_RAY].chance[0] = 50; - alien_defs[CD_MOBILE_RAY].chance[1] = 50; + alien_defs[CD_MOBILE_RAY].chance[1] = 0; alien_defs[CD_MOBILE_RAY].collectChance = 75; alien_defs[CD_MOBILE_RAY].collectType = P_ANYTHING; alien_defs[CD_MOBILE_RAY].collectValue = 100; diff --git a/src/game.cpp b/src/game.cpp index 156cd58..228791c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1022,35 +1022,32 @@ static void game_doAliens() if (canFire) { - if ((aliens[i].reload[0] == 0) && - ((rand() % 1000 < aliens[i].chance[0]) || - (aliens[i].flags & FL_CONTINUOUS_FIRE))) + for (int j = 0 ; j < 2 ; j++) { - // FIXME: I'm pretty sure this is the line that's causing mobile energy ray cannons - // to fire off 5 plasma bullets. Need to find out exactly what - // this line is for and make the appropriate adjustments. - ship_fireBullet(&aliens[i], 0); - } - if ((aliens[i].reload[1] == 0) && - ((rand() % 1000 < aliens[i].chance[1]) || - (aliens[i].flags & FL_CONTINUOUS_FIRE))) - { - if ((aliens[i].weaponType[1] != W_ENERGYRAY) && - (aliens[i].weaponType[1] != W_LASER)) + if ((aliens[i].reload[j] == 0) && + ((rand() % 1000 < aliens[i].chance[j]) || + (aliens[i].flags & FL_CONTINUOUS_FIRE))) { - if (aliens[i].weaponType[1] == W_CHARGER) - aliens[i].ammo[1] = 50 + rand() % 150; - ship_fireBullet(&aliens[i], 1); - } - else if (aliens[i].weaponType[1] == W_LASER) - { - aliens[i].flags += FL_FIRELASER; - } - else if ((aliens[i].weaponType[1] == W_ENERGYRAY) && - (aliens[i].ammo[0] == 250)) - { - aliens[i].flags += FL_FIRERAY; - audio_playSound(SFX_ENERGYRAY, aliens[i].x); + if ((aliens[i].weaponType[j] != W_ENERGYRAY) && + (aliens[i].weaponType[j] != W_LASER)) + { + if (aliens[i].weaponType[j] == W_CHARGER) + aliens[i].ammo[j] = 50 + rand() % 150; + ship_fireBullet(&aliens[i], j); + } + else if (aliens[i].weaponType[j] == W_LASER) + { + aliens[i].flags += FL_FIRELASER; + } + // XXX: This ammo check only seems to work for ammo[0], + // not ammo[1], thus necessitating using ammo[0] instead of + // ammo[j]. Should be investigated in the future. + else if ((aliens[i].weaponType[j] == W_ENERGYRAY) && + (aliens[i].ammo[0] >= 250)) + { + aliens[i].flags += FL_FIRERAY; + audio_playSound(SFX_ENERGYRAY, aliens[i].x); + } } } }