Changed "DAMAGEOWNER" flag to work when damaged, rather than destroyed.

This change in behavior has some very significant effects:

1. Damaging a child alien isn't rendered meaningless if you are
   primarily attacking the owner. This could be especially annoying
   with the miner bosses, which have tiny parts that are completely
   impractical to aim at.
2. Again, for the miner boss: previously, you couldn't see how much
   total health the ship had; the health bar only uselessly showed
   whether or not you defeated half of the ship (which you could
   already tell by looking at it). Now, the health bar tells you
   how much more damage you have to do in total.
This commit is contained in:
onpon4 2015-03-14 21:06:37 -04:00
parent b44037f05a
commit f58e15615b
3 changed files with 107 additions and 98 deletions

View File

@ -1382,14 +1382,6 @@ void alien_destroy(object *alien, object *attacker)
{ {
audio_playSound(SFX_EXPLOSION, alien->x); audio_playSound(SFX_EXPLOSION, alien->x);
// Chain reaction destruction if needed
if (alien->flags & FL_DAMAGEOWNER)
{
alien->owner->shield -= alien->maxShield;
if (alien->owner->shield < 1)
alien_destroy(alien->owner, attacker);
}
if (alien->flags & FL_FRIEND) if (alien->flags & FL_FRIEND)
{ {
if (alien->classDef == CD_PHOEBE) if (alien->classDef == CD_PHOEBE)
@ -1471,3 +1463,88 @@ void alien_destroy(object *alien, object *attacker)
alien->shield = -150; alien->shield = -150;
} }
} }
void alien_hurt(object *alien, object *attacker, int damage, bool ion)
{
if (ion)
alien->systemPower -= damage;
else
alien->shield -= damage;
// Chain reaction damage if needed
if (alien->flags & FL_DAMAGEOWNER)
{
alien_hurt(alien->owner, attacker, damage, ion);
}
if (alien->classDef == CD_KLINE)
{
if (currentGame.area == 11)
{
if ((alien->shield <= alien->maxShield - 500) &&
!(alien->flags & FL_LEAVESECTOR))
{
alien->flags |= FL_LEAVESECTOR;
alien->flags &= ~FL_CIRCLES;
setRadioMessage(FACE_KLINE, "Seems I underestimated you, Bainfield. We'll meet again!", 1);
}
}
else if (currentGame.area == 25)
{
if ((alien->shield <= alien->maxShield - 750) &&
!(alien->flags & FL_LEAVESECTOR))
{
alien->flags |= FL_LEAVESECTOR;
alien->flags &= ~FL_CIRCLES;
setRadioMessage(FACE_SID, "Chris, Kethlan is getting away!", 1);
}
}
else if (currentGame.area == 26)
{
if (alien->shield + damage > 1500 &&
alien->shield <= 1500)
alien_setKlineAttackMethod(alien);
else if (alien->shield + damage > 1000 &&
alien->shield <= 1000)
alien_setKlineAttackMethod(alien);
else if (alien->shield + damage > 500 &&
alien->shield <= 500)
alien_setKlineAttackMethod(alien);
}
else
{
if ((alien->shield <= alien->maxShield - 100) &&
!(alien->flags & FL_LEAVESECTOR))
{
alien->flags |= FL_LEAVESECTOR;
alien->flags &= ~FL_CIRCLES;
}
}
}
if ((alien->flags & FL_RUNSAWAY) && ((rand() % 50) == 0))
{
alien->flags |= FL_LEAVESECTOR;
}
audio_playSound(SFX_HIT, alien->x);
if (alien->AIType == AI_EVASIVE)
alien->thinktime = 0;
if (alien->shield < 1)
alien_destroy(alien, attacker);
if (alien->systemPower < 1)
{
if (!(alien->flags & FL_DISABLED))
{
alien->flags += FL_DISABLED;
updateMissionRequirements(M_DISABLE_TARGET,
alien->classDef, 1);
}
alien->systemPower = 0;
if (alien->classDef == CD_KLINE)
alien->systemPower = alien->maxShield;
}
}

View File

@ -37,5 +37,6 @@ int alien_checkTarget(object *alien);
int alien_enemiesInFront(object *alien); int alien_enemiesInFront(object *alien);
void alien_move(object *alien); void alien_move(object *alien);
void alien_destroy(object *alien, object *attacker); void alien_destroy(object *alien, object *attacker);
void alien_hurt(object *alien, object *attacker, int damage, bool ion);
#endif #endif

View File

@ -236,7 +236,9 @@ void fireRay(object *attacker)
{ {
if (player.shield > 0) if (player.shield > 0)
{ {
if (collision(player.x, player.y, player.image[0]->w, player.image[0]->h, ray.x, ray.y, ray.w, ray.h) && (!engine.cheatShield)) if (collision(player.x, player.y, player.image[0]->w,
player.image[0]->h, ray.x, ray.y, ray.w, ray.h) &&
(!engine.cheatShield))
{ {
if (player.shield > engine.lowShield) if (player.shield > engine.lowShield)
{ {
@ -265,17 +267,13 @@ void fireRay(object *attacker)
if (anEnemy->flags & FL_IMMORTAL) if (anEnemy->flags & FL_IMMORTAL)
continue; continue;
if ((anEnemy->shield > 0) && (attacker != anEnemy) && (attacker->classDef != anEnemy->classDef)) if ((anEnemy->shield > 0) && (attacker != anEnemy) &&
(attacker->classDef != anEnemy->classDef))
{ {
if (collision(anEnemy->x, anEnemy->y, anEnemy->image[0]->w, anEnemy->image[0]->h, ray.x, ray.y, ray.w, ray.h)) if (collision(anEnemy->x, anEnemy->y, anEnemy->image[0]->w,
anEnemy->image[0]->h, ray.x, ray.y, ray.w, ray.h))
{ {
anEnemy->shield--; alien_hurt(anEnemy, attacker->owner, 1, false);
addExplosion(anEnemy->x, anEnemy->y, E_SMALL_EXPLOSION);
audio_playSound(SFX_HIT, anEnemy->x);
if (anEnemy->shield < 1)
{
alien_destroy(anEnemy, attacker->owner);
}
} }
} }
@ -336,7 +334,8 @@ void doBullets()
if ((bullet->flags & WF_AIMED)) if ((bullet->flags & WF_AIMED))
{ {
blit(bullet->image[0], (int)(bullet->x - bullet->dx), (int)(bullet->y - bullet->dy)); blit(bullet->image[0], (int)(bullet->x - bullet->dx),
(int)(bullet->y - bullet->dy));
} }
if (bullet->id == WT_CHARGER) if (bullet->id == WT_CHARGER)
@ -412,64 +411,12 @@ void doBullets()
if (!(alien->flags & FL_IMMORTAL)) if (!(alien->flags & FL_IMMORTAL))
{ {
if (!(bullet->flags & WF_DISABLE)) alien_hurt(alien, bullet->owner, bullet->damage,
alien->shield -= bullet->damage; (bullet->flags & WF_DISABLE));
else
alien->systemPower -= bullet->damage;
alien->hit = 5; alien->hit = 5;
} }
if (alien->classDef == CD_KLINE)
{
if (currentGame.area == 11)
{
if ((alien->shield <= alien->maxShield - 500) &&
!(alien->flags & FL_LEAVESECTOR))
{
alien->flags |= FL_LEAVESECTOR;
alien->flags &= ~FL_CIRCLES;
setRadioMessage(FACE_KLINE, "Seems I underestimated you, Bainfield. We'll meet again!", 1);
}
}
else if (currentGame.area == 25)
{
if ((alien->shield <= alien->maxShield - 750) &&
!(alien->flags & FL_LEAVESECTOR))
{
alien->flags |= FL_LEAVESECTOR;
alien->flags &= ~FL_CIRCLES;
setRadioMessage(FACE_SID, "Chris, Kethlan is getting away!", 1);
}
}
else if (currentGame.area == 26)
{
if (alien->shield + bullet->damage > 1500 &&
alien->shield <= 1500)
alien_setKlineAttackMethod(alien);
else if (alien->shield + bullet->damage > 1000 &&
alien->shield <= 1000)
alien_setKlineAttackMethod(alien);
else if (alien->shield + bullet->damage > 500 &&
alien->shield <= 500)
alien_setKlineAttackMethod(alien);
}
else
{
if ((alien->shield <= alien->maxShield - 100) &&
!(alien->flags & FL_LEAVESECTOR))
{
alien->flags |= FL_LEAVESECTOR;
alien->flags &= ~FL_CIRCLES;
}
}
}
if ((alien->flags & FL_RUNSAWAY) && ((rand() % 50) == 0))
{
alien->flags |= FL_LEAVESECTOR;
}
if (bullet->id == WT_CHARGER) if (bullet->id == WT_CHARGER)
{ {
bullet->shield -= alien->shield; bullet->shield -= alien->shield;
@ -482,27 +429,6 @@ void doBullets()
bullet->shield = 0; bullet->shield = 0;
} }
audio_playSound(SFX_HIT, alien->x);
if (alien->AIType == AI_EVASIVE)
alien->thinktime = 0;
if (alien->shield < 1)
alien_destroy(alien, bullet->owner);
if (alien->systemPower < 1)
{
if (!(alien->flags & FL_DISABLED))
{
alien->flags += FL_DISABLED;
updateMissionRequirements(M_DISABLE_TARGET,
alien->classDef, 1);
}
alien->systemPower = 0;
if (alien->classDef == CD_KLINE)
alien->systemPower = alien->maxShield;
}
if (bullet->id == WT_ROCKET) if (bullet->id == WT_ROCKET)
addExplosion(bullet->x, bullet->y, E_BIG_EXPLOSION); addExplosion(bullet->x, bullet->y, E_BIG_EXPLOSION);
else else
@ -573,8 +499,11 @@ void doBullets()
theCargo->active = false; theCargo->active = false;
audio_playSound(SFX_EXPLOSION, theCargo->x); audio_playSound(SFX_EXPLOSION, theCargo->x);
for (int i = 0 ; i < 10 ; i++) for (int i = 0 ; i < 10 ; i++)
addExplosion(theCargo->x + rrand(-15, 15), theCargo->y + rrand(-15, 15), E_BIG_EXPLOSION); addExplosion(theCargo->x + rrand(-15, 15),
updateMissionRequirements(M_PROTECT_PICKUP, P_CARGO, 1); theCargo->y + rrand(-15, 15),
E_BIG_EXPLOSION);
updateMissionRequirements(M_PROTECT_PICKUP,
P_CARGO, 1);
} }
} }
} }
@ -588,7 +517,8 @@ void doBullets()
if (bullet->shield < 1) if (bullet->shield < 1)
{ {
if ((bullet->flags & WF_TIMEDEXPLOSION) || (bullet->id == WT_CHARGER)) if ((bullet->flags & WF_TIMEDEXPLOSION) ||
(bullet->id == WT_CHARGER))
{ {
audio_playSound(SFX_EXPLOSION, bullet->x); audio_playSound(SFX_EXPLOSION, bullet->x);
for (int i = 0 ; i < 10 ; i++) for (int i = 0 ; i < 10 ; i++)
@ -597,7 +527,8 @@ void doBullets()
if (bullet->flags & WF_TIMEDEXPLOSION) if (bullet->flags & WF_TIMEDEXPLOSION)
if (checkPlayerShockDamage(bullet->x, bullet->y)) if (checkPlayerShockDamage(bullet->x, bullet->y))
setInfoLine("Warning: Missile Shockwave Damage!!", FONT_RED); setInfoLine("Warning: Missile Shockwave Damage!!",
FONT_RED);
} }
bullet->active = false; bullet->active = false;
} }