From 6610cddeac892b7616fc049f8ad6ee8c7880328e Mon Sep 17 00:00:00 2001 From: onpon4 Date: Tue, 17 Mar 2015 13:03:20 -0400 Subject: [PATCH] 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. --- src/bullet.cpp | 52 ++++++++++++++++++++++++++++++++---------------- src/missions.cpp | 3 ++- src/structs.h | 4 ++-- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/bullet.cpp b/src/bullet.cpp index e1a2350..0126226 100644 --- a/src/bullet.cpp +++ b/src/bullet.cpp @@ -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; } diff --git a/src/missions.cpp b/src/missions.cpp index d36f4a1..a881389 100644 --- a/src/missions.cpp +++ b/src/missions.cpp @@ -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(); diff --git a/src/structs.h b/src/structs.h index 33d6ab2..82e0114 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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