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
|
|
|
|
|
|
|
void addBullet(object *theWeapon, object *attacker, int y, int dy)
|
|
|
|
{
|
|
|
|
object *bullet;
|
|
|
|
signed char imageIndex;
|
|
|
|
int tempX, tempY, steps;
|
|
|
|
|
|
|
|
bullet = new object;
|
|
|
|
|
|
|
|
if (attacker == &player)
|
|
|
|
currentGame.shots++;
|
|
|
|
|
|
|
|
bullet->next = NULL;
|
2011-08-26 16:14:58 +02:00
|
|
|
bullet->active = true;
|
2011-08-24 14:14:44 +02:00
|
|
|
bullet->x = attacker->x - ((attacker->image[0]->w / 2) * attacker->face);
|
|
|
|
bullet->y = attacker->y + y;
|
|
|
|
bullet->flags = theWeapon->flags;
|
|
|
|
bullet->shield = 300; // bullets live for (approximately) 5 seconds
|
|
|
|
|
|
|
|
// Timed explosions live between 1 and 3 seconds
|
|
|
|
if (bullet->flags & WF_TIMEDEXPLOSION)
|
|
|
|
bullet->shield = 60 + ((rand() % 3) * 60);
|
|
|
|
|
|
|
|
if (attacker->face == 0)
|
|
|
|
{
|
|
|
|
bullet->dx = theWeapon->speed;
|
|
|
|
if ((currentGame.area == 18) || (currentGame.area == 24))
|
2015-02-27 05:23:08 +01:00
|
|
|
bullet->dx += fabsf(engine.ssx + engine.smx);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bullet->dx = (0 - theWeapon->speed);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bullet->flags & WF_VARIABLE_SPEED)
|
|
|
|
{
|
2011-08-26 23:27:16 +02:00
|
|
|
bullet->dx = rrand(100, 200);
|
2011-08-24 14:14:44 +02:00
|
|
|
bullet->dx /= 10;
|
|
|
|
if (attacker->face == 1)
|
|
|
|
bullet->dx = 0 - bullet->dx;
|
|
|
|
}
|
|
|
|
|
|
|
|
bullet->dy = dy;
|
|
|
|
|
|
|
|
if (bullet->flags & WF_SCATTER)
|
|
|
|
{
|
2011-08-26 23:27:16 +02:00
|
|
|
bullet->dy = rrand(-200, 200);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (bullet->dy != 0)
|
|
|
|
bullet->dy /= 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attacker->flags & FL_WEAPCO)
|
2011-09-04 14:23:31 +02:00
|
|
|
bullet->flags |= WF_WEAPCO;
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-09-04 14:23:31 +02:00
|
|
|
bullet->flags |= WF_FRIEND;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
bullet->owner = attacker->owner;
|
|
|
|
|
|
|
|
bullet->id = theWeapon->id;
|
|
|
|
|
|
|
|
bullet->damage = theWeapon->damage;
|
|
|
|
|
|
|
|
if (bullet->id == WT_CHARGER)
|
|
|
|
{
|
2015-03-01 02:20:36 +01:00
|
|
|
bullet->damage = attacker->ammo[1] / 2;
|
|
|
|
if (bullet->damage < 15)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
bullet->damage = 1;
|
|
|
|
bullet->id = WT_PLASMA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bullet->target = NULL;
|
|
|
|
|
|
|
|
if (attacker->flags & FL_FRIEND)
|
|
|
|
imageIndex = 0;
|
|
|
|
else
|
|
|
|
imageIndex = 1;
|
|
|
|
|
|
|
|
// Use the enemy's images if applicable
|
|
|
|
if (bullet->id != WT_ROCKET)
|
|
|
|
bullet->image[0] = theWeapon->image[imageIndex];
|
|
|
|
else
|
|
|
|
bullet->image[0] = theWeapon->image[attacker->face];
|
|
|
|
|
|
|
|
if (bullet->flags & WF_AIMED)
|
|
|
|
{
|
2011-08-24 22:43:54 +02:00
|
|
|
tempX = (int)fabsf(attacker->target->x - attacker->x);
|
|
|
|
tempY = (int)fabsf(attacker->target->y - attacker->y);
|
2011-08-24 14:14:44 +02:00
|
|
|
steps = max(tempX, tempY);
|
|
|
|
|
2011-08-24 14:23:29 +02:00
|
|
|
if (steps < 12)
|
2011-08-24 14:14:44 +02:00
|
|
|
steps = 12;
|
|
|
|
|
|
|
|
if (!(bullet->flags & WF_TIMEDEXPLOSION))
|
|
|
|
steps /= 8;
|
|
|
|
else
|
|
|
|
steps /= 6 + (rand() % 6);
|
|
|
|
|
|
|
|
tempX = (int)(attacker->target->x - attacker->x);
|
|
|
|
tempY = (int)(attacker->target->y - attacker->y);
|
|
|
|
|
|
|
|
bullet->dx = tempX / steps;
|
|
|
|
bullet->dy = tempY / steps;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attacker->classDef == CD_ASTEROID)
|
|
|
|
{
|
2011-08-26 23:27:16 +02:00
|
|
|
bullet->dx = rrand(-20, 20);
|
|
|
|
bullet->dy = rrand(-20, 20);
|
2011-08-26 23:53:46 +02:00
|
|
|
bullet->image[0] = shape[4];
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
engine.bulletTail->next = bullet;
|
|
|
|
engine.bulletTail = bullet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Fill in later...
|
|
|
|
*/
|
|
|
|
void fireBullet(object *attacker, int weaponType)
|
|
|
|
{
|
|
|
|
if (attacker->reload[weaponType] > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int y = (attacker->image[0]->h) / 5;
|
|
|
|
|
|
|
|
// Remove some ammo from the player
|
|
|
|
if ((attacker == &player) && (weaponType == 1) && (!engine.cheatAmmo))
|
|
|
|
player.ammo[1]--;
|
|
|
|
|
|
|
|
object *theWeapon = &weapon[attacker->weaponType[weaponType]];
|
|
|
|
|
|
|
|
switch(theWeapon->id)
|
|
|
|
{
|
|
|
|
case WT_PLASMA:
|
|
|
|
case WT_SPREAD:
|
|
|
|
case WT_DIRECTIONAL:
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_PLASMA, attacker->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
case WT_ROCKET:
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_MISSILE, attacker->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
case WT_LASER:
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_LASER, attacker->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
case WT_CHARGER:
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_PLASMA3, attacker->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-04 18:24:54 +02:00
|
|
|
if (theWeapon->flags & WF_SPREAD && theWeapon->ammo[0] >= 3)
|
|
|
|
{
|
|
|
|
addBullet(theWeapon, attacker, y * 1, -2);
|
|
|
|
|
|
|
|
if(theWeapon->ammo[0] != 4)
|
|
|
|
addBullet(theWeapon, attacker, y * 3, 0);
|
|
|
|
|
|
|
|
if(theWeapon->ammo[0] != 3)
|
|
|
|
{
|
|
|
|
addBullet(theWeapon, attacker, y * 2, -1);
|
|
|
|
addBullet(theWeapon, attacker, y * 4, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
addBullet(theWeapon, attacker, y * 5, 2);
|
|
|
|
}
|
|
|
|
else
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-09-05 21:55:23 +02:00
|
|
|
if(theWeapon->ammo[0] & 1)
|
|
|
|
addBullet(theWeapon, attacker, y * 3, 0);
|
|
|
|
|
|
|
|
if(theWeapon->ammo[0] >= 2)
|
|
|
|
{
|
|
|
|
addBullet(theWeapon, attacker, y * 2, 0);
|
|
|
|
addBullet(theWeapon, attacker, y * 4, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(theWeapon->ammo[0] >= 4)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-09-05 21:55:23 +02:00
|
|
|
addBullet(theWeapon, attacker, y * 1, 0);
|
|
|
|
addBullet(theWeapon, attacker, y * 5, 0);
|
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
|
|
|
// Reset the weapon reload time. Double it if it is not friendly or
|
|
|
|
// a boss or Kline
|
2011-08-24 14:14:44 +02:00
|
|
|
attacker->reload[weaponType] = theWeapon->reload[0];
|
2015-03-07 15:42:24 +01:00
|
|
|
if ((attacker->flags & FL_WEAPCO) && (attacker != &aliens[WC_BOSS]) && (attacker != &aliens[WC_KLINE]) && (theWeapon->id != W_LASER))
|
2011-08-24 14:14:44 +02:00
|
|
|
attacker->reload[weaponType] *= 2;
|
|
|
|
|
|
|
|
if ((engine.cheatAmmo) || (theWeapon->id == WT_LASER))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((attacker == &player) && (weaponType == 0))
|
|
|
|
{
|
|
|
|
if (player.ammo[0] > 0)
|
|
|
|
{
|
|
|
|
player.ammo[0]--;
|
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 (player.ammo[0] <= 0)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-02-28 14:15:53 +01:00
|
|
|
weapon[W_PLAYER_WEAPON].ammo[0] = currentGame.minPlasmaOutput;
|
|
|
|
weapon[W_PLAYER_WEAPON].damage = currentGame.minPlasmaDamage;
|
|
|
|
weapon[W_PLAYER_WEAPON].reload[0] = rate2reload[currentGame.minPlasmaRate];
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Used for homing missiles. When a missile is active and it is told to home in
|
|
|
|
on an enemy, it will attempt to randomly grab one every frame if it does not
|
|
|
|
already have a target. If the target it is currently chasing is killed, it will
|
|
|
|
begin to look for a new one (done in doBullets()). The homing missile will make
|
|
|
|
one attempt per call (one call per frame) to find a suitable target. If the target
|
|
|
|
it picks is dead or outside the screen range, then it returns NULL. A suitable
|
|
|
|
target will be returned as the object address.
|
|
|
|
*/
|
2011-08-26 21:29:04 +02:00
|
|
|
static object *getRandomEnemy(object *bullet)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (bullet->owner->flags & FL_WEAPCO)
|
|
|
|
{
|
|
|
|
i = (rand() % 10);
|
|
|
|
|
|
|
|
if (i < 1)
|
|
|
|
return &player;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = rand() % MAX_ALIENS;
|
|
|
|
|
2015-03-07 15:42:24 +01:00
|
|
|
if ((aliens[i].shield < 1) || (!aliens[i].active))
|
2011-08-24 14:14:44 +02:00
|
|
|
return NULL;
|
2015-03-07 18:34:07 +01:00
|
|
|
|
|
|
|
if (aliens[i].flags & FL_IMMORTAL)
|
|
|
|
return NULL;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-07 15:42:24 +01:00
|
|
|
if ((bullet->owner->flags & FL_WEAPCO) && (aliens[i].flags & FL_WEAPCO))
|
2011-08-24 14:14:44 +02:00
|
|
|
return NULL;
|
|
|
|
|
2015-03-07 15:42:24 +01:00
|
|
|
if ((bullet->owner->flags & FL_FRIEND) && (aliens[i].flags & FL_FRIEND))
|
2011-08-24 14:14:44 +02:00
|
|
|
return NULL;
|
|
|
|
|
2015-03-07 15:42:24 +01:00
|
|
|
if (abs((int)bullet->x - (int)aliens[i].target->x) > 800)
|
2011-08-24 14:14:44 +02:00
|
|
|
return NULL;
|
|
|
|
|
2015-03-07 15:42:24 +01:00
|
|
|
if (abs((int)bullet->y - (int)aliens[i].target->y) > 200)
|
2011-08-24 14:14:44 +02:00
|
|
|
return NULL;
|
|
|
|
|
2015-03-07 15:42:24 +01:00
|
|
|
return &aliens[i];
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Fill in later...
|
|
|
|
*/
|
2015-03-06 15:37:21 +01:00
|
|
|
static void alien_destroy(object *alien, object *attacker)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
playSound(SFX_EXPLOSION, alien->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
// Chain reaction destruction if needed
|
2015-03-06 15:37:21 +01:00
|
|
|
if (alien->flags & FL_DAMAGEOWNER)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->owner->shield -= alien->maxShield;
|
|
|
|
if (alien->owner->shield < 1)
|
|
|
|
alien_destroy(alien->owner, attacker);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if (alien->flags & FL_FRIEND)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
if (alien->classDef == CD_PHOEBE)
|
2011-08-24 14:14:44 +02:00
|
|
|
currentGame.wingMate1Ejects++;
|
2015-03-06 15:37:21 +01:00
|
|
|
else if (alien->classDef == CD_URSULA)
|
2011-08-24 14:14:44 +02:00
|
|
|
currentGame.wingMate2Ejects++;
|
|
|
|
|
|
|
|
// Phoebe cannot eject on the rescue mission
|
|
|
|
if (currentGame.area != 7)
|
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
if ((alien->classDef == CD_PHOEBE) || (alien->classDef == CD_URSULA))
|
2011-08-24 14:14:44 +02:00
|
|
|
setInfoLine(">> Ally has ejected! <<\n", FONT_RED);
|
|
|
|
else
|
2011-08-27 21:21:43 +02:00
|
|
|
setInfoLine(">> Friendly craft has been destroyed!! <<\n", FONT_RED);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if (attacker != NULL)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
if (attacker == &player)
|
|
|
|
{
|
|
|
|
currentGame.totalKills++;
|
|
|
|
}
|
|
|
|
else if (attacker->classDef == CD_PHOEBE)
|
|
|
|
{
|
|
|
|
currentGame.wingMate1Kills++;
|
|
|
|
}
|
|
|
|
else if (attacker->classDef == CD_URSULA)
|
|
|
|
{
|
|
|
|
currentGame.wingMate2Kills++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
currentGame.totalOtherKills++;
|
|
|
|
}
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if ((attacker->classDef == CD_PHOEBE) || (attacker->classDef == CD_URSULA))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
if ((rand() % 8) == 0)
|
|
|
|
{
|
|
|
|
getKillMessage(attacker);
|
|
|
|
}
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
updateMissionRequirements(M_DESTROY_TARGET_TYPE, alien->classDef, 1);
|
|
|
|
updateMissionRequirements(M_PROTECT_TARGET, alien->classDef, 1);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if (rand() % 100 <= alien->collectChance)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
unsigned char value;
|
|
|
|
|
|
|
|
if ((rand() % 10) == 0)
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->collectValue *= 2;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
while (alien->collectValue > 0)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
value = (10 + (rand() % alien->collectValue));
|
|
|
|
if (value > alien->collectValue)
|
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
|
|
|
value = alien->collectValue;
|
2015-03-06 15:37:21 +01:00
|
|
|
addCollectable(alien->x, alien->y, alien->collectType, value, 600);
|
|
|
|
alien->collectValue -= value;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make it explode immediately
|
2015-03-06 15:37:21 +01:00
|
|
|
if (alien->classDef == CD_ASTEROID)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->shield = -999;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if ((alien->classDef == CD_KRASS) && (attacker == &player))
|
2011-08-24 14:14:44 +02:00
|
|
|
setRadioMessage(FACE_CHRIS, "My NAME is CHRIS!!!!!!!!", 1);
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if (alien->classDef == CD_KLINE)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
setRadioMessage(FACE_KLINE, "It was an honor... to have fought you...", 1);
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->dx = alien->dy = 0;
|
2015-03-07 21:34:47 +01:00
|
|
|
alien->maxShield = 2250;
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->shield = -200;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-24 22:22:26 +02:00
|
|
|
char checkPlayerShockDamage(float x, float y)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
// Don't let the player be hurt by an explosion after they have completed
|
|
|
|
// all the mission objectives. That would be *really* annoying!
|
|
|
|
if ((engine.cheatShield) || (engine.missionCompleteTimer != 0))
|
|
|
|
return 0;
|
|
|
|
|
2011-08-24 22:43:54 +02:00
|
|
|
float distX = fabsf(x - player.x);
|
|
|
|
float distY = fabsf(y - player.y);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if ((distX <= 50) && (distY <= 50))
|
|
|
|
{
|
|
|
|
if (distX >= 1)
|
|
|
|
distX /= 5;
|
|
|
|
|
|
|
|
if (distY >= 1)
|
|
|
|
distY /= 5;
|
|
|
|
|
|
|
|
player.shield -= (int)(10 - distX);
|
|
|
|
player.shield -= (int)(10 - distY);
|
2011-08-26 23:27:16 +02:00
|
|
|
limitInt(&player.shield, 0, player.maxShield);
|
2011-08-24 14:14:44 +02:00
|
|
|
player.hit = 10;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Fill in later...
|
|
|
|
*/
|
|
|
|
void fireRay(object *attacker)
|
|
|
|
{
|
|
|
|
SDL_Rect ray;
|
|
|
|
|
|
|
|
if (attacker->face == 0)
|
|
|
|
{
|
|
|
|
ray.x = (int)(attacker->x + attacker->image[0]->w);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ray.x = (int)(attacker->x - 800);
|
|
|
|
}
|
|
|
|
ray.y = (int)(attacker->y + attacker->engineY - 1);
|
|
|
|
ray.h = 3;
|
|
|
|
ray.w = 800;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
int red = SDL_MapRGB(screen->format, rand() % 256, 0x00, 0x00);
|
|
|
|
SDL_FillRect(screen, &ray, red);
|
|
|
|
addBuffer(ray.x, ray.y, ray.w, ray.h);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (attacker != &player)
|
|
|
|
{
|
|
|
|
if (player.shield > 0)
|
|
|
|
{
|
2011-08-26 23:27:16 +02:00
|
|
|
if (collision(player.x, player.y, player.image[0]->w, player.image[0]->h, ray.x, ray.y, ray.w, ray.h) && (!engine.cheatShield))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if (player.shield > engine.lowShield)
|
|
|
|
{
|
|
|
|
if (player.shield - 1 <= engine.lowShield)
|
|
|
|
{
|
|
|
|
setInfoLine("!!! WARNING: SHIELD LOW !!!", FONT_RED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
player.shield--;
|
|
|
|
|
|
|
|
addExplosion(player.x, player.y, E_SMALL_EXPLOSION);
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_HIT, player.x);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (player.shield < 1)
|
|
|
|
{
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_DEATH, player.x);
|
|
|
|
playSound(SFX_EXPLOSION, player.x);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-07 15:42:24 +01:00
|
|
|
object *anEnemy = aliens;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
for (int i = 0 ; i < MAX_ALIENS ; i++)
|
|
|
|
{
|
|
|
|
if (anEnemy->flags & FL_IMMORTAL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((anEnemy->shield > 0) && (attacker != anEnemy) && (attacker->classDef != anEnemy->classDef))
|
|
|
|
{
|
2011-08-26 23:27:16 +02:00
|
|
|
if (collision(anEnemy->x, anEnemy->y, anEnemy->image[0]->w, anEnemy->image[0]->h, ray.x, ray.y, ray.w, ray.h))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
anEnemy->shield--;
|
|
|
|
addExplosion(anEnemy->x, anEnemy->y, E_SMALL_EXPLOSION);
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_HIT, anEnemy->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (anEnemy->shield < 1)
|
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
alien_destroy(anEnemy, attacker->owner);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-24 14:44:40 +02:00
|
|
|
anEnemy++;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
attacker->ammo[0]--;
|
|
|
|
if (attacker->ammo[0] < 1)
|
2011-09-04 14:23:31 +02:00
|
|
|
attacker->flags &= ~FL_FIRERAY;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This handles active bullets in a linked list. The current bullet and
|
|
|
|
previous bullet pointers are first assigned to the main header bullet
|
|
|
|
and each successive bullet is pulled out. Bullets are moved in their
|
|
|
|
delta coordinates, with rockets having fire trails added to them. Seperate
|
|
|
|
collision checks are done for a bullet that belongs to the enemy and one
|
|
|
|
that belongs to a player. However rockets can hit anyone. Upon an enemy
|
|
|
|
being killed, mission requirements are checked and collectables are randomly
|
|
|
|
spawned.
|
|
|
|
*/
|
|
|
|
void doBullets()
|
|
|
|
{
|
|
|
|
object *bullet = engine.bulletHead;
|
|
|
|
object *prevBullet = engine.bulletHead;
|
|
|
|
engine.bulletTail = engine.bulletHead;
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
object *alien, *theCargo;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 16:55:46 +02:00
|
|
|
bool okayToHit = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
float homingMissileSpeed = 0;
|
|
|
|
|
|
|
|
while (bullet->next != NULL)
|
|
|
|
{
|
|
|
|
bullet = bullet->next;
|
|
|
|
|
2011-08-26 16:14:58 +02:00
|
|
|
if (bullet->active)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if (bullet->flags & WF_HOMING)
|
|
|
|
{
|
|
|
|
if (bullet->target == NULL)
|
|
|
|
bullet->target = getRandomEnemy(bullet);
|
|
|
|
|
|
|
|
if (bullet->owner->flags & FL_FRIEND)
|
|
|
|
homingMissileSpeed = 0.25;
|
|
|
|
else
|
|
|
|
homingMissileSpeed = 0.05;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bullet->id == WT_ROCKET)
|
|
|
|
{
|
|
|
|
addExplosion(bullet->x, bullet->y, E_SMALL_EXPLOSION);
|
|
|
|
}
|
|
|
|
else if (bullet->id == WT_MICROROCKET)
|
|
|
|
{
|
|
|
|
addExplosion(bullet->x, bullet->y, E_TINY_EXPLOSION);
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:55:23 +02:00
|
|
|
if ((bullet->flags & WF_AIMED))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(bullet->image[0], (int)(bullet->x - bullet->dx), (int)(bullet->y - bullet->dy));
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bullet->id == WT_CHARGER)
|
|
|
|
{
|
2015-03-01 02:20:36 +01:00
|
|
|
for (int i = 0 ; i < bullet->damage * 2 ; i++)
|
|
|
|
blit(bullet->image[0], (int)(bullet->x - rrand(-(bullet->damage * 2 / 3), 0)), (int)(bullet->y + rrand(-3, 3)));
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(bullet->image[0], (int)bullet->x, (int)bullet->y);
|
2011-08-24 14:14:44 +02:00
|
|
|
bullet->x += bullet->dx;
|
|
|
|
bullet->y += bullet->dy;
|
|
|
|
|
|
|
|
if (bullet->target != NULL)
|
|
|
|
{
|
|
|
|
if (bullet->x < bullet->target->x)
|
2011-08-26 23:27:16 +02:00
|
|
|
limitFloat(&(bullet->dx += homingMissileSpeed), -15, 15);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (bullet->x > bullet->target->x)
|
2011-08-26 23:27:16 +02:00
|
|
|
limitFloat(&(bullet->dx -= homingMissileSpeed), -15, 15);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
//Rocket is (more or less) inline with target. Fly straight
|
|
|
|
if ((bullet->x > bullet->target->x - 1) && (bullet->x < bullet->target->x + 5))
|
|
|
|
bullet->dx = 0;
|
|
|
|
|
|
|
|
if (bullet->y < bullet->target->y)
|
2011-08-26 23:27:16 +02:00
|
|
|
limitFloat(&(bullet->dy += homingMissileSpeed), -15, 15);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (bullet->y > bullet->target->y)
|
2011-08-26 23:27:16 +02:00
|
|
|
limitFloat(&(bullet->dy -= homingMissileSpeed), -15, 15);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
//Rocket is (more or less) inline with target. Fly straight
|
|
|
|
if ((bullet->y > bullet->target->y - 1) && (bullet->y < bullet->target->y + 5))
|
|
|
|
bullet->dy = 0;
|
|
|
|
|
|
|
|
if ((bullet->target->shield < 1) || (bullet->target->flags & FL_ISCLOAKED))
|
|
|
|
bullet->target = NULL;
|
|
|
|
}
|
|
|
|
|
2015-02-27 05:23:08 +01:00
|
|
|
bullet->x += engine.ssx + engine.smx;
|
|
|
|
bullet->y += engine.ssy + engine.smy;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
for (int i = 0 ; i < MAX_ALIENS ; i++)
|
|
|
|
{
|
2015-03-07 15:42:24 +01:00
|
|
|
alien = &aliens[i];
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if ((alien->shield < 1) || (!alien->active))
|
2011-08-24 14:14:44 +02:00
|
|
|
continue;
|
|
|
|
|
2011-08-26 16:55:46 +02:00
|
|
|
okayToHit = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if ((bullet->flags & WF_FRIEND) && (alien->flags & FL_WEAPCO))
|
2011-08-26 16:55:46 +02:00
|
|
|
okayToHit = true;
|
2015-03-06 15:37:21 +01:00
|
|
|
if ((bullet->flags & WF_WEAPCO) && (alien->flags & FL_FRIEND))
|
2011-08-26 16:55:46 +02:00
|
|
|
okayToHit = true;
|
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 ((bullet->id == WT_ROCKET) || (bullet->id == WT_LASER) ||
|
|
|
|
(bullet->id == WT_CHARGER))
|
2011-08-26 16:55:46 +02:00
|
|
|
okayToHit = true;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if (bullet->owner == alien->owner)
|
2011-08-26 16:55:46 +02:00
|
|
|
okayToHit = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (okayToHit)
|
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
if ((bullet->active) && (collision(bullet, alien)))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if (bullet->owner == &player)
|
|
|
|
{
|
|
|
|
currentGame.hits++;
|
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 ((alien->classDef == CD_PHOEBE) ||
|
|
|
|
(alien->classDef == CD_URSULA))
|
2015-03-06 15:37:21 +01:00
|
|
|
getMissFireMessage(alien);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if (!(alien->flags & FL_IMMORTAL))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if (!(bullet->flags & WF_DISABLE))
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->shield -= bullet->damage;
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->systemPower -= bullet->damage;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->hit = 5;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if (alien->flags & FL_CANNOTDIE)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
limitInt(&alien->shield, 1, alien->maxShield);
|
|
|
|
if (alien->shield == 1)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if (currentGame.area != 26)
|
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
if (!(alien->flags & FL_LEAVESECTOR))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->flags |= FL_LEAVESECTOR;
|
|
|
|
alien->flags &= ~FL_CIRCLES;
|
2011-08-24 14:14:44 +02:00
|
|
|
if (currentGame.area == 11)
|
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
|
|
|
setRadioMessage(FACE_KLINE, "Seems I underestimated you, Bainfield. We'll meet again!", 1);
|
2011-08-24 14:14:44 +02:00
|
|
|
else if (currentGame.area == 25)
|
|
|
|
setRadioMessage(FACE_SID, "Chris, Kethlan is getting away!", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
alien_setKlineAttackMethod(alien);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if ((alien->flags & FL_RUNSAWAY) && ((rand() % 50) == 0))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->flags |= FL_LEAVESECTOR;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bullet->id != WT_CHARGER)
|
|
|
|
{
|
2011-08-26 16:14:58 +02:00
|
|
|
bullet->active = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
bullet->shield = 0;
|
|
|
|
}
|
|
|
|
else if (bullet->id == WT_CHARGER)
|
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
bullet->shield -= alien->shield;
|
2011-08-24 14:14:44 +02:00
|
|
|
if (bullet->shield < 0)
|
2011-08-26 16:14:58 +02:00
|
|
|
bullet->active = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
playSound(SFX_HIT, alien->x);
|
|
|
|
if (alien->AIType == AI_EVASIVE)
|
|
|
|
alien->thinktime = 0;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if (alien->shield < 1)
|
|
|
|
alien_destroy(alien, bullet->owner);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
if (alien->systemPower < 1)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
if (!(alien->flags & FL_DISABLED))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->flags += FL_DISABLED;
|
|
|
|
updateMissionRequirements(M_DISABLE_TARGET, alien->classDef, 1);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2015-03-06 15:37:21 +01:00
|
|
|
alien->systemPower = 0;
|
|
|
|
if (alien->classDef == CD_KLINE)
|
|
|
|
alien->systemPower = alien->maxShield;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bullet->id == WT_ROCKET)
|
|
|
|
addExplosion(bullet->x, bullet->y, E_BIG_EXPLOSION);
|
|
|
|
else
|
|
|
|
addExplosion(bullet->x, bullet->y, E_SMALL_EXPLOSION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for bullets hitting player
|
|
|
|
if ((bullet->flags & WF_WEAPCO) || (bullet->id == WT_ROCKET) || (bullet->id == WT_LASER) || (bullet->id == WT_CHARGER))
|
|
|
|
{
|
2011-08-26 23:27:16 +02:00
|
|
|
if ((bullet->active) && (player.shield > 0) && (collision(bullet, &player)) && (bullet->owner != &player))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if ((!engine.cheatShield) || (engine.missionCompleteTimer != 0))
|
|
|
|
{
|
|
|
|
if (player.shield > engine.lowShield)
|
|
|
|
{
|
|
|
|
if (player.shield - bullet->damage <= engine.lowShield)
|
|
|
|
{
|
|
|
|
setInfoLine("!!! WARNING: SHIELD LOW !!!", FONT_RED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
player.shield -= bullet->damage;
|
2011-08-26 23:27:16 +02:00
|
|
|
limitInt(&player.shield, 0, player.maxShield);
|
2011-08-24 14:14:44 +02:00
|
|
|
player.hit = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((bullet->owner->classDef == CD_PHOEBE) || (bullet->owner->classDef == CD_URSULA))
|
|
|
|
getPlayerHitMessage(bullet->owner);
|
|
|
|
|
|
|
|
if (bullet->id != WT_CHARGER)
|
|
|
|
{
|
2011-08-26 16:14:58 +02:00
|
|
|
bullet->active = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
bullet->shield = 0;
|
|
|
|
}
|
|
|
|
else if (bullet->id == WT_CHARGER)
|
|
|
|
{
|
2015-03-06 15:37:21 +01:00
|
|
|
bullet->shield -= alien->shield;
|
2011-08-24 14:14:44 +02:00
|
|
|
if (bullet->shield < 0)
|
2011-08-26 16:14:58 +02:00
|
|
|
bullet->active = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_HIT, player.x);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (bullet->id == WT_ROCKET)
|
|
|
|
addExplosion(bullet->x, bullet->y, E_BIG_EXPLOSION);
|
|
|
|
else
|
|
|
|
addExplosion(bullet->x, bullet->y, E_SMALL_EXPLOSION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-28 00:45:21 +01:00
|
|
|
if ((currentGame.difficulty > DIFFICULTY_EASY) &&
|
|
|
|
((bullet->owner == &player) || (bullet->id == WT_ROCKET)))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
for (int j = 0 ; j < 20 ; j++)
|
|
|
|
{
|
|
|
|
theCargo = &cargo[j];
|
|
|
|
if (theCargo->active)
|
|
|
|
{
|
2011-08-26 23:27:16 +02:00
|
|
|
if (collision(bullet, theCargo))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 16:14:58 +02:00
|
|
|
bullet->active = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
addExplosion(bullet->x, bullet->y, E_SMALL_EXPLOSION);
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_HIT, theCargo->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (theCargo->collectType != P_PHOEBE)
|
|
|
|
{
|
2011-08-26 16:14:58 +02:00
|
|
|
theCargo->active = false;
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_EXPLOSION, theCargo->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
for (int i = 0 ; i < 10 ; i++)
|
2011-08-26 23:27:16 +02:00
|
|
|
addExplosion(theCargo->x + rrand(-15, 15), theCargo->y + rrand(-15, 15), E_BIG_EXPLOSION);
|
2011-08-24 14:14:44 +02:00
|
|
|
updateMissionRequirements(M_PROTECT_PICKUP, P_CARGO, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check to see if a bullet (on any side) hits a mine
|
|
|
|
checkMineBulletCollisions(bullet);
|
|
|
|
|
|
|
|
bullet->shield--;
|
|
|
|
|
|
|
|
if (bullet->shield < 1)
|
|
|
|
{
|
|
|
|
if ((bullet->flags & WF_TIMEDEXPLOSION) || (bullet->id == WT_CHARGER))
|
|
|
|
{
|
2012-03-02 23:00:35 +01:00
|
|
|
playSound(SFX_EXPLOSION, bullet->x);
|
2011-08-24 14:14:44 +02:00
|
|
|
for (int i = 0 ; i < 10 ; i++)
|
2011-08-26 23:27:16 +02:00
|
|
|
addExplosion(bullet->x + rrand(-35, 35), bullet->y + rrand(-35, 35), E_BIG_EXPLOSION);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (bullet->flags & WF_TIMEDEXPLOSION)
|
2011-08-24 22:22:26 +02:00
|
|
|
if (checkPlayerShockDamage(bullet->x, bullet->y))
|
2011-08-24 14:14:44 +02:00
|
|
|
setInfoLine("Warning: Missile Shockwave Damage!!", FONT_RED);
|
|
|
|
}
|
2011-08-26 16:14:58 +02:00
|
|
|
bullet->active = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-26 16:14:58 +02:00
|
|
|
if (bullet->active)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
prevBullet = bullet;
|
|
|
|
engine.bulletTail = bullet;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prevBullet->next = bullet->next;
|
|
|
|
delete bullet;
|
|
|
|
bullet = prevBullet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|