2011-08-24 14:14:44 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2003 Parallel Realities
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
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
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
#include "Starfighter.h"
|
|
|
|
|
|
|
|
object cargo[MAX_CARGO];
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
void initCargo()
|
|
|
|
{
|
|
|
|
for (int i = 0 ; i < MAX_CARGO ; i++)
|
|
|
|
{
|
2011-08-26 16:14:58 +02:00
|
|
|
cargo[i].active = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
cargo[i].owner = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* I think you all know what this does by now! ;)
|
|
|
|
*/
|
2011-08-26 21:29:04 +02:00
|
|
|
static int getCargo()
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
for (int i = 0 ; i < MAX_CARGO ; i++)
|
|
|
|
{
|
2011-08-26 16:14:58 +02:00
|
|
|
if (!cargo[i].active)
|
2011-08-24 14:14:44 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
object *addCargo(object *owner, int cargoType)
|
|
|
|
{
|
|
|
|
int index = getCargo();
|
|
|
|
|
|
|
|
if (index == -1)
|
|
|
|
return NULL;
|
|
|
|
|
2011-08-26 16:14:58 +02:00
|
|
|
cargo[index].active = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
cargo[index].owner = owner;
|
|
|
|
cargo[index].x = owner->x;
|
|
|
|
cargo[index].y = owner->y;
|
|
|
|
cargo[index].dx = 0;
|
|
|
|
cargo[index].dy = 0;
|
|
|
|
cargo[index].collectType = cargoType;
|
2011-08-26 23:53:46 +02:00
|
|
|
cargo[index].image[0] = shape[32];
|
2011-08-24 14:14:44 +02:00
|
|
|
if (cargoType == P_PHOEBE)
|
2011-08-26 23:53:46 +02:00
|
|
|
cargo[index].image[0] = shipShape[20];
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
return &cargo[index];
|
|
|
|
}
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
static void becomeCollectable(int i)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if (cargo[i].collectType != P_PHOEBE)
|
|
|
|
{
|
|
|
|
addCollectable(cargo[i].x, cargo[i].y, cargo[i].collectType, 1, 600);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-26 16:14:58 +02:00
|
|
|
enemy[FR_PHOEBE].active = true;
|
2011-08-24 14:14:44 +02:00
|
|
|
enemy[FR_PHOEBE].x = cargo[i].x;
|
|
|
|
enemy[FR_PHOEBE].y = cargo[i].y;
|
|
|
|
setRadioMessage(FACE_PHOEBE, "Thanks!! Watch out, WEAPCO! Phoebe's loose and she's ANGRY!!!", 1);
|
|
|
|
}
|
|
|
|
|
2011-08-26 16:14:58 +02:00
|
|
|
cargo[i].active = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void doCargo()
|
|
|
|
{
|
|
|
|
float dx, dy, chainX, chainY;
|
|
|
|
|
|
|
|
for (int i = 0 ; i < MAX_CARGO ; i++)
|
|
|
|
{
|
|
|
|
if (cargo[i].active)
|
|
|
|
{
|
|
|
|
if (!cargo[i].owner->active)
|
|
|
|
{
|
|
|
|
becomeCollectable(i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(cargo[i].image[0], (int)cargo[i].x, (int)cargo[i].y);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
cargo[i].x += engine.ssx;
|
|
|
|
cargo[i].y += engine.ssy;
|
|
|
|
|
2011-08-26 23:27:16 +02:00
|
|
|
limitFloat(&cargo[i].x, cargo[i].owner->x - 50, cargo[i].owner->x + 50);
|
|
|
|
limitFloat(&cargo[i].y, cargo[i].owner->y - 50, cargo[i].owner->y + 50);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
dx = (cargo[i].x - cargo[i].owner->x) / 10;
|
|
|
|
dy = (cargo[i].y - cargo[i].owner->y) / 10;
|
|
|
|
chainX = cargo[i].x - cargo[i].dx;
|
|
|
|
chainY = cargo[i].y - cargo[i].dy;
|
|
|
|
|
|
|
|
// draw the chain link line
|
|
|
|
for (int j = 0 ; j < 10 ; j++)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(shape[30], (int)chainX, (int)chainY);
|
2011-08-24 14:14:44 +02:00
|
|
|
chainX -= dx;
|
|
|
|
chainY -= dy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|