Fixed some problems with the charge cannon.

Specifically:
- When an enemy is hit, its damage is reduced, not its lifetime.
- When the shot's lifetime ends, it no longer explodes.
This commit is contained in:
onpon4 2015-03-17 13:03:20 -04:00
parent 717d56755c
commit 6610cddeac
3 changed files with 39 additions and 20 deletions

View File

@ -228,6 +228,7 @@ void doBullets()
object *alien, *theCargo;
bool okayToHit = false;
int old_shield;
float homingMissileSpeed = 0;
while (bullet->next != NULL)
@ -325,6 +326,8 @@ void doBullets()
{
if ((bullet->active) && (collision(bullet, alien)))
{
old_shield = alien->shield;
if (bullet->owner == &player)
{
currentGame.hits++;
@ -343,9 +346,17 @@ void doBullets()
if (bullet->id == WT_CHARGER)
{
bullet->shield -= alien->shield;
if (bullet->shield <= 0)
bullet->damage -= old_shield;
if (bullet->damage <= 0)
{
bullet->active = false;
bullet->shield = 0;
audio_playSound(SFX_EXPLOSION, bullet->x);
for (int i = 0 ; i < 10 ; i++)
addExplosion(bullet->x + rrand(-35, 35),
bullet->y + rrand(-35, 35),
E_BIG_EXPLOSION);
}
}
else
{
@ -365,9 +376,11 @@ void doBullets()
if ((bullet->flags & WF_WEAPCO) || (bullet->id == WT_ROCKET) ||
(bullet->id == WT_LASER) || (bullet->id == WT_CHARGER))
{
if ((bullet->active) && (player.shield > 0) &&
(collision(bullet, &player)) && (bullet->owner != &player))
if (bullet->active && (player.shield > 0) &&
(bullet->owner != &player) && collision(bullet, &player))
{
old_shield = player.shield;
if ((!engine.cheatShield) || (engine.missionCompleteTimer != 0))
{
if ((player.shield > engine.lowShield) &&
@ -383,17 +396,24 @@ void doBullets()
(bullet->owner->classDef == CD_URSULA))
getPlayerHitMessage(bullet->owner);
if (bullet->id != WT_CHARGER)
if (bullet->id == WT_CHARGER)
{
bullet->damage -= old_shield;
if (bullet->damage <= 0)
{
bullet->active = false;
bullet->shield = 0;
audio_playSound(SFX_EXPLOSION, bullet->x);
for (int i = 0 ; i < 10 ; i++)
addExplosion(bullet->x + rrand(-35, 35),
bullet->y + rrand(-35, 35), E_BIG_EXPLOSION);
}
}
else
{
bullet->active = false;
bullet->shield = 0;
}
else if (bullet->id == WT_CHARGER)
{
bullet->shield -= alien->shield;
if (bullet->shield < 0)
bullet->active = false;
}
audio_playSound(SFX_HIT, player.x);
@ -441,18 +461,16 @@ void doBullets()
if (bullet->shield < 1)
{
if ((bullet->flags & WF_TIMEDEXPLOSION) ||
(bullet->id == WT_CHARGER))
if (bullet->flags & WF_TIMEDEXPLOSION)
{
audio_playSound(SFX_EXPLOSION, bullet->x);
for (int i = 0 ; i < 10 ; i++)
addExplosion(bullet->x + rrand(-35, 35),
bullet->y + rrand(-35, 35), E_BIG_EXPLOSION);
if (bullet->flags & WF_TIMEDEXPLOSION)
if (checkPlayerShockDamage(bullet->x, bullet->y))
setInfoLine("Warning: Missile Shockwave Damage!!",
FONT_RED);
if (checkPlayerShockDamage(bullet->x, bullet->y))
setInfoLine("Warning: Missile Shockwave Damage!!",
FONT_RED);
}
bullet->active = false;
}

View File

@ -318,7 +318,8 @@ static void evaluateRequirement(int type, int id, int *completed, int *targetVal
{
char message[25];
if ((*targetValue <= 0) && (type != M_PROTECT_TARGET) && (type != M_PROTECT_PICKUP))
if ((*targetValue <= 0) && (type != M_PROTECT_TARGET) &&
(type != M_PROTECT_PICKUP))
{
*completed = 2;
checkTimer();

View File

@ -37,10 +37,10 @@ struct object {
int deathCounter; // how long to explode for
signed char speed;
unsigned char damage; // Contact damage for bullets
int damage; // Contact damage for bullets
unsigned char ammo[2]; // Ammo for 2nd weapon.
signed char face; // Either 0 or 1
int face; // Either 0 or 1
object *owner; // Who owns this object