From 5c9b69dd0c6466ef719ba74f0b7db838c3b6b70d Mon Sep 17 00:00:00 2001 From: Layla Marchant Date: Tue, 26 May 2020 15:51:04 -0400 Subject: [PATCH] Added a super-easy difficulty. --- src/alien.c | 106 +++++++++++++++++++++++++++++++++++---------- src/bullet.c | 4 +- src/collectable.c | 70 +++++++++++++++++------------- src/defs.h | 3 +- src/game.c | 10 ++++- src/intermission.c | 5 ++- src/ship.c | 12 +---- 7 files changed, 139 insertions(+), 71 deletions(-) diff --git a/src/alien.c b/src/alien.c index 3f2e2de..5cc0dbc 100644 --- a/src/alien.c +++ b/src/alien.c @@ -1286,9 +1286,9 @@ int alien_add() int randEnemy = alienArray[rand() % numberOfAliens]; - if ((game.area != MISN_DORIM) && - (game.area != MISN_SIVEDI) && - (game.area != MISN_MARS)) + if ((game.area != MISN_DORIM) + && (game.area != MISN_SIVEDI) + && (game.area != MISN_MARS)) { if ((game.system == SYSTEM_EYANANTH) && (game.area == MISN_INTERCEPTION)) { @@ -1312,15 +1312,33 @@ int alien_add() aliens[index].deathCounter = 0 - (aliens[index].maxShield * 3); aliens[index].hit = 0; + if (game.difficulty == DIFFICULTY_SUPEREASY) + { + if ((aliens[index].classDef == CD_SID) + || (aliens[index].classDef == CD_PHOEBE) + || (aliens[index].classDef == CD_URSULA) + || (aliens[index].classDef == CD_GOODTRANSPORT) + || (aliens[index].classDef == CD_REBELCARRIER) + || ((game.area == MISN_URUSOR) + && (aliens[index].classDef == CD_CARGOSHIP))) + { + aliens[index].shield *= 2; + aliens[index].maxShield *= 2; + } + else if ((aliens[index].classDef != CD_ASTEROID) + && (aliens[index].classDef != CD_ASTEROID2)) + { + aliens[index].shield /= 2; + aliens[index].maxShield /= 2; + } + } + LIMIT(aliens[index].deathCounter, -250, 0); // Attempts to place an alien. If it fails, the alien is deactivated. - for (int i = 0 ; i < 100 ; i++) + if (!alien_place(&aliens[index])) { - if (alien_place(&aliens[index])) - break; aliens[index].active = 0; - return 0; } @@ -1590,16 +1608,25 @@ This AI is exclusively for Kline. */ void alien_setKlineAI(Object *alien) { + int threshold; + // Weapon type change if (CHANCE(1. / 3.)) { - if ((game.area != MISN_VENUS) || (game.difficulty != DIFFICULTY_ORIGINAL)) + if ((game.area != MISN_VENUS) + || (game.difficulty != DIFFICULTY_ORIGINAL)) { alien->flags &= ~FL_AIMS; if (CHANCE(0.5)) { - if ((game.area != MISN_VENUS) || (alien->shield > 1500)) + if (game.difficulty == DIFFICULTY_SUPEREASY) + threshold = 750; + else + threshold = 1500; + + if ((game.area != MISN_VENUS) + || (alien->shield > threshold)) alien->weaponType[0] = W_TRIPLE_SHOT; else alien->weaponType[0] = W_SPREADSHOT; @@ -2123,6 +2150,7 @@ void alien_hurt(Object *alien, Object *attacker, int damage, int ion) { int ai_type; double run_chance; + int stage1_shield, stage2_shield, stage3_shield; ai_type = ((game.difficulty == DIFFICULTY_ORIGINAL) ? alien->AITypeOriginal : alien->AIType); @@ -2133,8 +2161,8 @@ void alien_hurt(Object *alien, Object *attacker, int damage, int ion) alien->shield -= damage; // Chain reaction damage if needed - if ((game.difficulty != DIFFICULTY_ORIGINAL) && - (alien->owner != alien) && (alien->flags & FL_DAMAGEOWNER)) + if ((game.difficulty != DIFFICULTY_ORIGINAL) + && (alien->owner != alien) && (alien->flags & FL_DAMAGEOWNER)) { alien_hurt(alien->owner, attacker, damage, ion); } @@ -2143,8 +2171,15 @@ void alien_hurt(Object *alien, Object *attacker, int damage, int ion) { if (game.area == MISN_ELAMALE) { - if ((alien->shield <= alien->maxShield - ((game.difficulty != DIFFICULTY_ORIGINAL) ? 500 : 750)) && - !(alien->flags & FL_LEAVESECTOR)) + if (game.difficulty == DIFFICULTY_ORIGINAL) + stage1_shield = 750; + else if (game.difficulty == DIFFICULTY_SUPEREASY) + stage1_shield = 250; + else + stage1_shield = 500; + + if ((alien->shield <= alien->maxShield - stage1_shield) + && !(alien->flags & FL_LEAVESECTOR)) { alien->flags |= FL_LEAVESECTOR; alien->flags &= ~FL_CIRCLES; @@ -2155,8 +2190,15 @@ void alien_hurt(Object *alien, Object *attacker, int damage, int ion) } else if (game.area == MISN_EARTH) { - if ((alien->shield <= alien->maxShield - ((game.difficulty != DIFFICULTY_ORIGINAL) ? 750 : 500)) && - !(alien->flags & FL_LEAVESECTOR)) + if (game.difficulty == DIFFICULTY_ORIGINAL) + stage1_shield = 500; + else if (game.difficulty == DIFFICULTY_SUPEREASY) + stage1_shield = 375; + else + stage1_shield = 750; + + if ((alien->shield <= alien->maxShield - stage1_shield) + && !(alien->flags & FL_LEAVESECTOR)) { alien->flags |= FL_LEAVESECTOR; alien->flags &= ~FL_CIRCLES; @@ -2167,20 +2209,38 @@ void alien_hurt(Object *alien, Object *attacker, int damage, int ion) } else if (game.area == MISN_VENUS) { - if (alien->shield + damage > 1500 && - alien->shield <= 1500) + if (game.difficulty == DIFFICULTY_SUPEREASY) + { + stage1_shield = 750; + stage2_shield = 500; + stage3_shield = 250; + } + else + { + stage1_shield = 1500; + stage2_shield = 1000; + stage3_shield = 500; + } + + if (alien->shield + damage > stage1_shield + && alien->shield <= stage1_shield) alien_setKlineAttackMethod(alien); - else if (alien->shield + damage > 1000 && - alien->shield <= 1000) + else if (alien->shield + damage > stage2_shield + && alien->shield <= stage2_shield) alien_setKlineAttackMethod(alien); - else if (alien->shield + damage > 500 && - alien->shield <= 500) + else if (alien->shield + damage > stage3_shield + && alien->shield <= stage3_shield) alien_setKlineAttackMethod(alien); } else { - if ((alien->shield <= alien->maxShield - 100) && - !(alien->flags & FL_LEAVESECTOR)) + if (game.difficulty == DIFFICULTY_SUPEREASY) + stage1_shield = 50; + else + stage1_shield = 100; + + if ((alien->shield <= alien->maxShield - stage1_shield) + && !(alien->flags & FL_LEAVESECTOR)) { alien->flags |= FL_LEAVESECTOR; alien->flags &= ~FL_CIRCLES; diff --git a/src/bullet.c b/src/bullet.c index 3a46fcf..ab41920 100644 --- a/src/bullet.c +++ b/src/bullet.c @@ -60,8 +60,8 @@ void bullet_add(Object *theWeapon, Object *attacker, int y, int dy) if (attacker->face == 0) { bullet->dx = theWeapon->speed; - if ((game.area == MISN_ELLESH) || - (game.area == MISN_MARS)) + if ((game.area == MISN_ELLESH) + || (game.area == MISN_MARS)) bullet->dx += fabsf(engine.ssx + engine.smx); } else diff --git a/src/collectable.c b/src/collectable.c index aee07d5..dc4b10e 100644 --- a/src/collectable.c +++ b/src/collectable.c @@ -40,17 +40,18 @@ void collectable_add(float x, float y, int type, int value, int life) Collectable *collectable; int plasma_useless, shield_useless, rockets_useless; - plasma_useless = (((weapons[W_PLAYER_WEAPON].reload[0] >= rate2reload[game.minPlasmaRate]) && - (weapons[W_PLAYER_WEAPON].ammo[0] <= game.minPlasmaOutput) && - (weapons[W_PLAYER_WEAPON].damage <= game.minPlasmaDamage)) || - (player.ammo[0] >= game.maxPlasmaAmmo)); + plasma_useless = (((weapons[W_PLAYER_WEAPON].reload[0] >= rate2reload[game.minPlasmaRate]) + && (weapons[W_PLAYER_WEAPON].ammo[0] <= game.minPlasmaOutput) + && (weapons[W_PLAYER_WEAPON].damage <= game.minPlasmaDamage)) + || (player.ammo[0] >= game.maxPlasmaAmmo)); shield_useless = ((game.difficulty == DIFFICULTY_NIGHTMARE) || (player.shield >= player.maxShield)); - rockets_useless = ((player.weaponType[1] == W_CHARGER) || - (player.weaponType[1] == W_LASER) || (game.maxRocketAmmo <= 0) || - (player.ammo[1] >= game.maxRocketAmmo)); + rockets_useless = ((player.weaponType[1] == W_CHARGER) + || (player.weaponType[1] == W_LASER) + || (game.maxRocketAmmo <= 0) + || (player.ammo[1] >= game.maxRocketAmmo)); if (type == P_ANYTHING) { @@ -61,21 +62,22 @@ void collectable_add(float x, float y, int type, int value, int life) switch (r) { case 0: - if ((game.difficulty == DIFFICULTY_ORIGINAL) || - (game.difficulty == DIFFICULTY_NIGHTMARE)) + if ((game.difficulty == DIFFICULTY_ORIGINAL) + || (game.difficulty == DIFFICULTY_NIGHTMARE)) { type = P_PLASMA_AMMO; } else { - if ((!shield_useless) && - (CHANCE(2 * (player.maxShield - player.shield) / player.maxShield))) + if ((!shield_useless) + && (CHANCE(2 * (player.maxShield - player.shield) / player.maxShield))) { type = P_SHIELD; } - else if ((!rockets_useless) && (game.maxRocketAmmo > 0) && - (CHANCE((game.maxRocketAmmo - player.ammo[1]) / game.maxRocketAmmo))) + else if ((!rockets_useless) + && (game.maxRocketAmmo > 0) + && (CHANCE((game.maxRocketAmmo - player.ammo[1]) / game.maxRocketAmmo))) { type = P_ROCKET; } @@ -91,20 +93,21 @@ void collectable_add(float x, float y, int type, int value, int life) break; case 2: - if ((game.difficulty == DIFFICULTY_ORIGINAL) || - (game.difficulty == DIFFICULTY_NIGHTMARE)) + if ((game.difficulty == DIFFICULTY_ORIGINAL) + || (game.difficulty == DIFFICULTY_NIGHTMARE)) { type = P_ROCKET; } else { - if ((!shield_useless) && - (CHANCE(2 * (player.maxShield - player.shield) / player.maxShield))) + if ((!shield_useless) + && (CHANCE(2 * (player.maxShield - player.shield) / player.maxShield))) { type = P_SHIELD; } - else if ((!plasma_useless) && (game.maxPlasmaAmmo > 0) && - (CHANCE((game.maxPlasmaAmmo - player.ammo[0]) / game.maxPlasmaAmmo))) + else if ((!plasma_useless) + && (game.maxPlasmaAmmo > 0) + && (CHANCE((game.maxPlasmaAmmo - player.ammo[0]) / game.maxPlasmaAmmo))) { type = P_PLASMA_AMMO; } @@ -120,13 +123,14 @@ void collectable_add(float x, float y, int type, int value, int life) { type = P_PLASMA_RATE; - if ((game.difficulty == DIFFICULTY_NIGHTMARE) || - ((game.difficulty != DIFFICULTY_EASY) && - (game.difficulty != DIFFICULTY_ORIGINAL) && - ((game.area == MISN_MOEBO) || - (game.area == MISN_ELAMALE) || - (game.area == MISN_ELLESH) || - (game.area == MISN_EARTH)))) + if ((game.difficulty == DIFFICULTY_NIGHTMARE) + || ((game.difficulty != DIFFICULTY_SUPEREASY) + && (game.difficulty != DIFFICULTY_EASY) + && (game.difficulty != DIFFICULTY_ORIGINAL) + && ((game.area == MISN_MOEBO) + || (game.area == MISN_ELAMALE) + || (game.area == MISN_ELLESH) + || (game.area == MISN_EARTH)))) { // Deny the Super Charge in Nightmare difficulty, and on bosses. r = rand() % 59; @@ -149,6 +153,9 @@ void collectable_add(float x, float y, int type, int value, int life) if (value == 0) return; // don't bother! + + if (game.difficulty == DIFFICULTY_SUPEREASY) + value *= 2; // No point in giving the player plasma ammo if the weapons aren't // upgraded! Give them money instead. (Except in Classic difficulty.) @@ -164,9 +171,9 @@ void collectable_add(float x, float y, int type, int value, int life) // rockets. Causes problems otherwise :) if (type == P_ROCKET) { - if ((player.weaponType[1] == W_CHARGER) || - (player.weaponType[1] == W_LASER) || - (value < 10)) + if ((player.weaponType[1] == W_CHARGER) + || (player.weaponType[1] == W_LASER) + || (value < 10)) { type = P_CASH; } @@ -199,8 +206,9 @@ void collectable_add(float x, float y, int type, int value, int life) else { // No cash or ammo on interceptions. Completely stops grinding. - if ((game.area == MISN_INTERCEPTION) && - ((type == P_CASH) || (type == P_PLASMA_AMMO) || (type == P_ROCKET))) + if ((game.area == MISN_INTERCEPTION) + && ((type == P_CASH) || (type == P_PLASMA_AMMO) + || (type == P_ROCKET))) { return; } diff --git a/src/defs.h b/src/defs.h index 74ca83c..685c3ab 100644 --- a/src/defs.h +++ b/src/defs.h @@ -794,7 +794,8 @@ enum { // Difficulties enum { - DIFFICULTY_EASY = 0, + DIFFICULTY_SUPEREASY = 0, + DIFFICULTY_EASY, DIFFICULTY_NORMAL, DIFFICULTY_HARD, DIFFICULTY_NIGHTMARE, diff --git a/src/game.c b/src/game.c index 134fda1..17a75d3 100644 --- a/src/game.c +++ b/src/game.c @@ -130,6 +130,7 @@ void game_init() switch (game.difficulty) { + case DIFFICULTY_SUPEREASY: case DIFFICULTY_EASY: player.maxShield = 100; @@ -872,8 +873,9 @@ static void game_doBullets() } } - if ((game.difficulty != DIFFICULTY_EASY) && - ((bullet->owner == &player) || (bullet->id == WT_ROCKET))) + if ((game.difficulty != DIFFICULTY_SUPEREASY) + && (game.difficulty != DIFFICULTY_EASY) + && ((bullet->owner == &player) || (bullet->id == WT_ROCKET))) { for (int j = 0 ; j < 20 ; j++) { @@ -2386,6 +2388,10 @@ void game_getDifficultyText(char *dest, int difficulty) { switch (difficulty) { + case DIFFICULTY_SUPEREASY: + /// DIFFICULTY_SUPEREASY + strcpy(dest, _("Super-Easy")); + break; case DIFFICULTY_EASY: /// DIFFICULTY_EASY strcpy(dest, _("Easy")); diff --git a/src/intermission.c b/src/intermission.c index 1341785..26b670d 100644 --- a/src/intermission.c +++ b/src/intermission.c @@ -1461,8 +1461,9 @@ int intermission() intermission_createCommsSurface(commsSurface); // Remove the Supercharge, if it is there - if ((game.difficulty != DIFFICULTY_EASY) && - (game.difficulty != DIFFICULTY_ORIGINAL)) + if ((game.difficulty != DIFFICULTY_SUPEREASY) + && (game.difficulty != DIFFICULTY_EASY) + && (game.difficulty != DIFFICULTY_ORIGINAL)) { weapons[W_PLAYER_WEAPON].reload[0] = MAX( weapons[W_PLAYER_WEAPON].reload[0], diff --git a/src/ship.c b/src/ship.c index 56650eb..f5c0226 100644 --- a/src/ship.c +++ b/src/ship.c @@ -105,16 +105,8 @@ void ship_fireBullet(Object *ship, int weaponIndex) if (theWeapon->ammo[0] == 5) { - if (game.difficulty == DIFFICULTY_ORIGINAL) - { - bullet_add(theWeapon, ship, y * 2, -1); - bullet_add(theWeapon, ship, y * 4, 1); - } - else - { - bullet_add(theWeapon, ship, y * 1, -2); - bullet_add(theWeapon, ship, y * 5, 2); - } + bullet_add(theWeapon, ship, y * 1, -2); + bullet_add(theWeapon, ship, y * 5, 2); } } else