2011-08-24 14:14:44 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2003 Parallel Realities
|
2015-03-01 21:37:32 +01:00
|
|
|
Copyright (C) 2011, 2012 Guus Sliepen
|
|
|
|
Copyright (C) 2015 Julian Marchant
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
2015-02-26 17:20:36 +01:00
|
|
|
as published by the Free Software Foundation; either version 3
|
2011-08-24 14:14:44 +02:00
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-02-26 17:20:36 +01:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2015-02-26 17:20:36 +01:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-08-24 14:14:44 +02:00
|
|
|
*/
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
#include "Starfighter.h"
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Create a new collectable item based on supplied arguments.
|
|
|
|
*/
|
2015-04-24 22:27:07 +02:00
|
|
|
void collectable_add(float x, float y, int type, int value, int life)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-09 01:59:33 +01:00
|
|
|
int r;
|
|
|
|
|
2011-08-24 14:14:44 +02:00
|
|
|
if (type == P_ANYTHING)
|
|
|
|
{
|
|
|
|
type = P_CASH;
|
|
|
|
|
2015-03-09 01:59:33 +01:00
|
|
|
r = rand() % 9;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
switch (r)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
type = P_PLASMA_AMMO;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
type = P_SHIELD;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
type = P_ROCKET;
|
|
|
|
value /= 10;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type == P_WEAPONS)
|
|
|
|
{
|
|
|
|
type = P_PLASMA_RATE;
|
|
|
|
|
2015-05-21 01:41:43 +02:00
|
|
|
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))))
|
2015-03-09 01:59:33 +01:00
|
|
|
{
|
|
|
|
// Deny the Super Charge in Nightmare difficulty, and on bosses.
|
|
|
|
r = rand() % 59;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
r = rand() % 61;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (r <= 19)
|
|
|
|
type = P_PLASMA_DAMAGE;
|
|
|
|
else if (r <= 39)
|
|
|
|
type = P_PLASMA_SHOT;
|
|
|
|
else if (r <= 59)
|
|
|
|
type = P_PLASMA_RATE;
|
|
|
|
else
|
|
|
|
type = P_SUPER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == P_SUPER)
|
2015-03-17 21:54:00 +01:00
|
|
|
value = MAX(value, 1);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-02-28 15:45:26 +01:00
|
|
|
if (value == 0)
|
|
|
|
return; // don't bother!
|
|
|
|
|
2015-03-01 00:56:24 +01:00
|
|
|
// No point in giving the player plasma ammo if the weapons aren't
|
|
|
|
// upgraded! Give them money instead.
|
|
|
|
if (type == P_PLASMA_AMMO)
|
|
|
|
{
|
2015-05-21 01:41:43 +02:00
|
|
|
if ((weapon[W_PLAYER_WEAPON].reload[0] >= rate2reload[game.minPlasmaRate]) &&
|
|
|
|
(weapon[W_PLAYER_WEAPON].ammo[0] <= game.minPlasmaOutput) &&
|
|
|
|
(weapon[W_PLAYER_WEAPON].damage <= game.minPlasmaDamage))
|
2015-03-01 00:56:24 +01:00
|
|
|
{
|
|
|
|
type = P_CASH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-24 14:14:44 +02:00
|
|
|
// If the player has a charge cannon or a laser cannon, don't give them
|
|
|
|
// rockets. Causes problems otherwise :)
|
|
|
|
if (type == P_ROCKET)
|
|
|
|
{
|
|
|
|
if ((player.weaponType[1] == W_CHARGER) || (player.weaponType[1] == W_LASER))
|
|
|
|
{
|
|
|
|
type = P_CASH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-28 04:16:53 +01:00
|
|
|
// Shield bonus is useless in Nightmare difficulty; give cash instead.
|
|
|
|
if (type == P_SHIELD)
|
|
|
|
{
|
2015-05-21 01:41:43 +02:00
|
|
|
if (game.difficulty == DIFFICULTY_NIGHTMARE)
|
2015-02-28 04:16:53 +01:00
|
|
|
{
|
|
|
|
type = P_CASH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-21 01:41:43 +02:00
|
|
|
if (game.difficulty == DIFFICULTY_ORIGINAL)
|
2015-03-14 00:11:14 +01:00
|
|
|
{
|
2015-03-28 18:59:33 +01:00
|
|
|
// Cash is just rare in the original game. You can still grind,
|
|
|
|
// just not as much.
|
2015-05-21 01:41:43 +02:00
|
|
|
if ((game.area == MISN_INTERCEPTION) && (type == P_CASH))
|
2015-03-28 18:59:33 +01:00
|
|
|
{
|
|
|
|
if (rand() % 10 > 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No cash or ammo on interceptions. Completely stops grinding.
|
2015-05-21 01:41:43 +02:00
|
|
|
if ((game.area == MISN_INTERCEPTION) &&
|
2015-03-28 18:59:33 +01:00
|
|
|
((type == P_CASH) || (type == P_PLASMA_AMMO) || (type == P_ROCKET)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-03-14 00:11:14 +01:00
|
|
|
}
|
|
|
|
|
2011-08-24 14:14:44 +02:00
|
|
|
collectables *collectable = new collectables;
|
|
|
|
|
|
|
|
collectable->next = NULL;
|
2011-08-26 16:14:58 +02:00
|
|
|
collectable->active = true;
|
2011-08-24 14:14:44 +02:00
|
|
|
collectable->x = x;
|
|
|
|
collectable->y = y;
|
|
|
|
|
2015-03-29 16:19:53 +02:00
|
|
|
collectable->dx = RANDRANGE(-100, 100);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (collectable->dx != 0)
|
|
|
|
collectable->dx /= 100;
|
|
|
|
|
2015-03-29 16:19:53 +02:00
|
|
|
collectable->dy = RANDRANGE(-100, 100);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (collectable->dy != 0)
|
|
|
|
collectable->dy /= 100;
|
|
|
|
|
|
|
|
collectable->type = type;
|
|
|
|
collectable->value = value;
|
|
|
|
collectable->life = life;
|
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case P_CASH:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[24];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_ROCKET:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[49];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_PLASMA_AMMO:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[25];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_SHIELD:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[26];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_PLASMA_SHOT:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[27];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_PLASMA_RATE:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[28];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_PLASMA_DAMAGE:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[29];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_CARGO:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[32];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_SUPER:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[50];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_MINE:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[31];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_SLAVES:
|
|
|
|
case P_ESCAPEPOD:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[45];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case P_ORE:
|
2011-08-26 23:53:46 +02:00
|
|
|
collectable->image = shape[46 + rand() % 3];
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
engine.collectableTail->next = collectable;
|
|
|
|
engine.collectableTail = collectable;
|
|
|
|
}
|
|
|
|
|
2015-09-25 22:28:09 +02:00
|
|
|
bool collectable_collision(collectables *collectable, object *ship)
|
|
|
|
{
|
|
|
|
float x0 = collectable->x;
|
|
|
|
float y0 = collectable->y;
|
|
|
|
float w0 = collectable->image->w;
|
|
|
|
float h0 = collectable->image->h;
|
|
|
|
|
|
|
|
float x2 = ship->x;
|
|
|
|
float y2 = ship->y;
|
|
|
|
float w1 = ship->image[0]->w;
|
|
|
|
float h1 = ship->image[0]->h;
|
|
|
|
|
|
|
|
float x1 = x0 + w0;
|
|
|
|
float y1 = y0 + h0;
|
|
|
|
|
|
|
|
float x3 = x2 + w1;
|
|
|
|
float y3 = y2 + h1;
|
|
|
|
|
|
|
|
return !(x1<x2 || x3<x0 || y1<y2 || y3<y0);
|
|
|
|
}
|
|
|
|
|
2015-04-24 22:27:07 +02:00
|
|
|
void collectable_explode(collectables *collectable)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
Several adjustments for difficulty purposes.
Started out adjusting prices, then ended up doing other things
while testing. Committing this now before I start doing other
random stuff!
But all of the changes are related to balancing difficulty, mostly
with prices, except for a couple bugfixes in the shop. Most notably:
* Ammo now costs $10, not $50. You no longer have to worry about
saving ammo quite as much as a result.
* Plasma upgrades' cost is now calculated differently, and the result
is slightly lower prices than before.
* Easy mode now grants the player more max ammo than other difficulties.
* Increasing max plasma ammo now costs less at the start, and increases
in cost faster.
* You increase max plasma ammo by 25 at a time, not 10. (10 was just too
small of a number.)
* Destroying enemy ships no longer gives you money. I found that, even
in hard mode, I had *way* too much money coming in, and this cuts it
down substantially. It also makes the shield bonus at the end of missions
much more significant. To compensate for the loss of massive bonuses
bosses used to give, these bosses now drop a lot more stuff.
* Kline has decreased health in his first encounter, and increased health
in his last two encounters (the numbers have been reversed).
2015-03-07 18:19:35 +01:00
|
|
|
if ((collectable->x >= 0) && (collectable->x <= screen->w) &&
|
|
|
|
(collectable->y >= 0) && (collectable->y <= screen->h))
|
2015-03-08 15:38:58 +01:00
|
|
|
audio_playSound(SFX_EXPLOSION, collectable->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
for (int i = 0 ; i < 10 ; i++)
|
2015-05-01 00:51:26 +02:00
|
|
|
explosion_add(collectable->x + rand() % 25 - rand() % 25,
|
Several adjustments for difficulty purposes.
Started out adjusting prices, then ended up doing other things
while testing. Committing this now before I start doing other
random stuff!
But all of the changes are related to balancing difficulty, mostly
with prices, except for a couple bugfixes in the shop. Most notably:
* Ammo now costs $10, not $50. You no longer have to worry about
saving ammo quite as much as a result.
* Plasma upgrades' cost is now calculated differently, and the result
is slightly lower prices than before.
* Easy mode now grants the player more max ammo than other difficulties.
* Increasing max plasma ammo now costs less at the start, and increases
in cost faster.
* You increase max plasma ammo by 25 at a time, not 10. (10 was just too
small of a number.)
* Destroying enemy ships no longer gives you money. I found that, even
in hard mode, I had *way* too much money coming in, and this cuts it
down substantially. It also makes the shield bonus at the end of missions
much more significant. To compensate for the loss of massive bonuses
bosses used to give, these bosses now drop a lot more stuff.
* Kline has decreased health in his first encounter, and increased health
in his last two encounters (the numbers have been reversed).
2015-03-07 18:19:35 +01:00
|
|
|
collectable->y + rand() % 25 - rand() % 25, E_BIG_EXPLOSION);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-04-24 22:37:55 +02:00
|
|
|
player_checkShockDamage(collectable->x, collectable->y);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|