From d08da08f85b359e937f454c779d8ca919b95a12e Mon Sep 17 00:00:00 2001 From: onpon4 Date: Mon, 9 Mar 2015 09:36:24 -0400 Subject: [PATCH] Moved alien_destroy to aliens module. --- src/aliens.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ src/aliens.h | 1 + src/bullets.cpp | 97 ------------------------------------------------- 3 files changed, 98 insertions(+), 97 deletions(-) diff --git a/src/aliens.cpp b/src/aliens.cpp index 28c0ad5..caa2dd5 100644 --- a/src/aliens.cpp +++ b/src/aliens.cpp @@ -1377,3 +1377,100 @@ void alien_move(object *alien) } } } + +/* +Fill in later... +*/ +void alien_destroy(object *alien, object *attacker) +{ + 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->classDef == CD_PHOEBE) + currentGame.wingMate1Ejects++; + else if (alien->classDef == CD_URSULA) + currentGame.wingMate2Ejects++; + + // Phoebe cannot eject on the rescue mission + if (currentGame.area != 7) + { + if ((alien->classDef == CD_PHOEBE) || (alien->classDef == CD_URSULA)) + setInfoLine(">> Ally has ejected! <<\n", FONT_RED); + else + setInfoLine(">> Friendly craft has been destroyed!! <<\n", FONT_RED); + } + } + + if (attacker != NULL) + { + if (attacker == &player) + { + currentGame.totalKills++; + } + else if (attacker->classDef == CD_PHOEBE) + { + currentGame.wingMate1Kills++; + } + else if (attacker->classDef == CD_URSULA) + { + currentGame.wingMate2Kills++; + } + else + { + currentGame.totalOtherKills++; + } + + if ((attacker->classDef == CD_PHOEBE) || (attacker->classDef == CD_URSULA)) + { + if ((rand() % 8) == 0) + { + getKillMessage(attacker); + } + } + } + + updateMissionRequirements(M_DESTROY_TARGET_TYPE, alien->classDef, 1); + updateMissionRequirements(M_PROTECT_TARGET, alien->classDef, 1); + + if (rand() % 100 <= alien->collectChance) + { + unsigned char value; + + if ((rand() % 10) == 0) + alien->collectValue *= 2; + + while (alien->collectValue > 0) + { + value = (10 + (rand() % alien->collectValue)); + if (value > alien->collectValue) + value = alien->collectValue; + addCollectable(alien->x, alien->y, alien->collectType, value, 600); + alien->collectValue -= value; + } + } + + // Make it explode immediately + if (alien->classDef == CD_ASTEROID) + { + alien->shield = -999; + } + + if ((alien->classDef == CD_KRASS) && (attacker == &player)) + setRadioMessage(FACE_CHRIS, "My NAME is CHRIS!!!!!!!!", 1); + + if (alien->classDef == CD_KLINE) + { + setRadioMessage(FACE_KLINE, "It was an honor... to have fought you...", 1); + alien->dx = alien->dy = 0; + alien->shield = -150; + } +} diff --git a/src/aliens.h b/src/aliens.h index 08f58f5..021e50c 100644 --- a/src/aliens.h +++ b/src/aliens.h @@ -36,5 +36,6 @@ void alien_searchForTarget(object *alien); int alien_checkTarget(object *alien); int alien_enemiesInFront(object *alien); void alien_move(object *alien); +void alien_destroy(object *alien, object *attacker); #endif diff --git a/src/bullets.cpp b/src/bullets.cpp index 6400082..59c0cf6 100644 --- a/src/bullets.cpp +++ b/src/bullets.cpp @@ -271,103 +271,6 @@ static object *getRandomEnemy(object *bullet) return &aliens[i]; } -/* -Fill in later... -*/ -static void alien_destroy(object *alien, object *attacker) -{ - 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->classDef == CD_PHOEBE) - currentGame.wingMate1Ejects++; - else if (alien->classDef == CD_URSULA) - currentGame.wingMate2Ejects++; - - // Phoebe cannot eject on the rescue mission - if (currentGame.area != 7) - { - if ((alien->classDef == CD_PHOEBE) || (alien->classDef == CD_URSULA)) - setInfoLine(">> Ally has ejected! <<\n", FONT_RED); - else - setInfoLine(">> Friendly craft has been destroyed!! <<\n", FONT_RED); - } - } - - if (attacker != NULL) - { - if (attacker == &player) - { - currentGame.totalKills++; - } - else if (attacker->classDef == CD_PHOEBE) - { - currentGame.wingMate1Kills++; - } - else if (attacker->classDef == CD_URSULA) - { - currentGame.wingMate2Kills++; - } - else - { - currentGame.totalOtherKills++; - } - - if ((attacker->classDef == CD_PHOEBE) || (attacker->classDef == CD_URSULA)) - { - if ((rand() % 8) == 0) - { - getKillMessage(attacker); - } - } - } - - updateMissionRequirements(M_DESTROY_TARGET_TYPE, alien->classDef, 1); - updateMissionRequirements(M_PROTECT_TARGET, alien->classDef, 1); - - if (rand() % 100 <= alien->collectChance) - { - unsigned char value; - - if ((rand() % 10) == 0) - alien->collectValue *= 2; - - while (alien->collectValue > 0) - { - value = (10 + (rand() % alien->collectValue)); - if (value > alien->collectValue) - value = alien->collectValue; - addCollectable(alien->x, alien->y, alien->collectType, value, 600); - alien->collectValue -= value; - } - } - - // Make it explode immediately - if (alien->classDef == CD_ASTEROID) - { - alien->shield = -999; - } - - if ((alien->classDef == CD_KRASS) && (attacker == &player)) - setRadioMessage(FACE_CHRIS, "My NAME is CHRIS!!!!!!!!", 1); - - if (alien->classDef == CD_KLINE) - { - setRadioMessage(FACE_KLINE, "It was an honor... to have fought you...", 1); - alien->dx = alien->dy = 0; - alien->shield = -150; - } -} - char checkPlayerShockDamage(float x, float y) { // Don't let the player be hurt by an explosion after they have completed