2020-12-28 09:51:40 +01:00
|
|
|
#include "driver2.h"
|
|
|
|
#include "bomberman.h"
|
|
|
|
#include "convert.h"
|
|
|
|
#include "overmap.h"
|
|
|
|
#include "players.h"
|
|
|
|
#include "cars.h"
|
|
|
|
#include "glaunch.h"
|
|
|
|
#include "job_fx.h"
|
|
|
|
#include "dr2roads.h"
|
|
|
|
#include "pad.h"
|
|
|
|
#include "camera.h"
|
|
|
|
#include "draw.h"
|
|
|
|
#include "debris.h"
|
|
|
|
#include "mission.h"
|
|
|
|
#include "denting.h"
|
|
|
|
#include "cosmetic.h"
|
|
|
|
#include "bcollide.h"
|
|
|
|
#include "pedest.h"
|
2020-06-05 17:32:32 +02:00
|
|
|
|
2020-12-28 09:51:40 +01:00
|
|
|
#include "ASM/rndrasm.h"
|
2020-06-05 17:51:00 +02:00
|
|
|
|
2020-04-21 17:28:52 +02:00
|
|
|
MODEL* gBombModel;
|
2020-10-07 16:54:48 +02:00
|
|
|
|
|
|
|
static BOMB ThrownBombs[MAX_THROWN_BOMBS];
|
|
|
|
|
2020-06-05 17:32:32 +02:00
|
|
|
static int ThrownBombDelay = 0;
|
|
|
|
static int CurrentBomb = 0;
|
|
|
|
static int gWantFlash = 0;
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA *gBombTargetVehicle = NULL;
|
2020-06-05 17:32:32 +02:00
|
|
|
static int flashval;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void InitThrownBombs(void)
|
|
|
|
{
|
2020-06-05 17:32:32 +02:00
|
|
|
int i;
|
|
|
|
|
2020-10-07 16:54:48 +02:00
|
|
|
for (i = 0; i < MAX_THROWN_BOMBS; i++)
|
2020-06-05 17:32:32 +02:00
|
|
|
ThrownBombs[i].flags = 0;
|
|
|
|
|
|
|
|
ThrownBombDelay = Random2(0) % 45 + 8;
|
2020-04-04 06:49:28 +02:00
|
|
|
CurrentBomb = 0;
|
|
|
|
gWantFlash = 0;
|
2020-06-05 17:32:32 +02:00
|
|
|
gBombTargetVehicle = NULL;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DrawThrownBombs(void)
|
|
|
|
{
|
2020-06-05 17:51:00 +02:00
|
|
|
BOMB *bomb;
|
|
|
|
int i;
|
|
|
|
MATRIX object_matrix;
|
|
|
|
VECTOR pos;
|
|
|
|
|
|
|
|
if (gBombModel == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bomb = ThrownBombs;
|
|
|
|
i = 0;
|
2020-10-07 16:54:48 +02:00
|
|
|
while (i < MAX_THROWN_BOMBS)
|
2020-06-05 17:51:00 +02:00
|
|
|
{
|
|
|
|
if ((bomb->flags & 1) != 0)
|
|
|
|
{
|
2021-05-15 21:58:23 +02:00
|
|
|
InitMatrix(object_matrix);
|
2020-06-05 17:51:00 +02:00
|
|
|
|
|
|
|
RotMatrixY(bomb->rot_speed * bomb->active * 3 & 0xfff, &object_matrix);
|
|
|
|
RotMatrixZ(bomb->rot_speed * bomb->active & 0xfff, &object_matrix);
|
|
|
|
|
|
|
|
pos.vx = bomb->position.vx - camera_position.vx;
|
|
|
|
pos.vy = bomb->position.vy - camera_position.vy;
|
|
|
|
pos.vz = bomb->position.vz - camera_position.vz;
|
|
|
|
|
|
|
|
Apply_Inv_CameraMatrix(&pos);
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&object_matrix);
|
|
|
|
gte_SetTransVector(&pos);
|
|
|
|
|
|
|
|
pos.vx = bomb->position.vx;
|
|
|
|
pos.vy = bomb->position.vy;
|
|
|
|
pos.vz = bomb->position.vz;
|
|
|
|
|
|
|
|
SetFrustrumMatrix();
|
|
|
|
|
|
|
|
if (FrustrumCheck(&pos, gBombModel->bounding_sphere) != -1)
|
|
|
|
{
|
|
|
|
PlotMDL_less_than_128(gBombModel);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-05 17:51:00 +02:00
|
|
|
|
|
|
|
i++;
|
|
|
|
bomb++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gWantFlash != 0)
|
|
|
|
{
|
|
|
|
add_haze(flashval, flashval, 7);
|
|
|
|
|
|
|
|
flashval -= 10;
|
|
|
|
|
|
|
|
if (flashval < 1)
|
|
|
|
gWantFlash = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void BombThePlayerToHellAndBack(int car)
|
|
|
|
{
|
2021-06-20 17:13:54 +02:00
|
|
|
CAR_DATA* cp;
|
2020-06-05 18:31:38 +02:00
|
|
|
BOMB *bomb;
|
|
|
|
|
|
|
|
if (car == -1)
|
|
|
|
return;
|
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
cp = &car_data[car];
|
|
|
|
|
|
|
|
cp->ap.damage[0] = 0xfff;
|
|
|
|
cp->ap.damage[1] = 0xfff;
|
|
|
|
cp->ap.damage[2] = 0xfff;
|
|
|
|
cp->ap.damage[3] = 0xfff;
|
|
|
|
cp->ap.damage[4] = 0xfff;
|
|
|
|
cp->ap.damage[5] = 0xfff;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
cp->ap.needsDenting = 1;
|
|
|
|
cp->totalDamage = MaxPlayerDamage[0];
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
DentCar(&car_data[car]);
|
|
|
|
|
|
|
|
if (maxCivCars == 0)
|
|
|
|
{
|
|
|
|
trap(7);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
gBombTargetVehicle = &car_data[(car + 1) % maxCivCars];
|
|
|
|
|
|
|
|
bomb = &ThrownBombs[CurrentBomb++];
|
2020-10-07 16:54:48 +02:00
|
|
|
CurrentBomb = CurrentBomb % MAX_THROWN_BOMBS;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
bomb->flags = 1;
|
|
|
|
bomb->active = 1;
|
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
bomb->position.vx = cp->hd.where.t[0];
|
|
|
|
bomb->position.vy = cp->hd.where.t[1];
|
|
|
|
bomb->position.vz = cp->hd.where.t[2];
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
bomb->velocity.vx = 0;
|
|
|
|
bomb->velocity.vy = 0;
|
|
|
|
bomb->velocity.vz = 0;
|
|
|
|
|
|
|
|
bomb = &ThrownBombs[CurrentBomb++];
|
2020-10-07 16:54:48 +02:00
|
|
|
CurrentBomb = CurrentBomb % MAX_THROWN_BOMBS;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
bomb->flags = 1;
|
|
|
|
bomb->active = 1;
|
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
bomb->position.vx = cp->hd.where.t[0] + 170;
|
|
|
|
bomb->position.vy = cp->hd.where.t[1];
|
|
|
|
bomb->position.vz = cp->hd.where.t[2] + 73;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
bomb->velocity.vx = 0;
|
|
|
|
bomb->velocity.vy = 0;
|
|
|
|
bomb->velocity.vz = 0;
|
|
|
|
|
|
|
|
bomb = &ThrownBombs[CurrentBomb++];
|
2020-10-07 16:54:48 +02:00
|
|
|
CurrentBomb = CurrentBomb % MAX_THROWN_BOMBS;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
bomb->flags = 1;
|
|
|
|
bomb->active = 1;
|
2021-06-20 17:13:54 +02:00
|
|
|
bomb->position.vx = cp->hd.where.t[0] - 109;
|
|
|
|
bomb->position.vy = cp->hd.where.t[1];
|
|
|
|
bomb->position.vz = cp->hd.where.t[2] - 147;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
bomb->velocity.vx = 0;
|
|
|
|
bomb->velocity.vy = 0;
|
|
|
|
bomb->velocity.vz = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
int BombCollisionCheck(CAR_DATA *cp, VECTOR *pPos)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-06-05 18:31:38 +02:00
|
|
|
CDATA2D cd[2] = {0};
|
|
|
|
|
|
|
|
cd[1].theta = cp->hd.direction;
|
|
|
|
cd[1].length[0] = car_cosmetics[cp->ap.model].colBox.vz;
|
|
|
|
cd[1].length[1] = car_cosmetics[cp->ap.model].colBox.vx;
|
|
|
|
cd[1].x.vx = cp->hd.where.t[0];
|
|
|
|
cd[1].x.vz = cp->hd.where.t[2];
|
|
|
|
|
|
|
|
cd[0].x.vx = pPos->vx;
|
|
|
|
cd[0].x.vz = pPos->vz;
|
|
|
|
cd[0].length[0] = 40;
|
|
|
|
cd[0].length[1] = 40;
|
|
|
|
cd[0].theta = 0;
|
|
|
|
cd[0].avel = 0;
|
|
|
|
cd[0].vel.vx = 0;
|
|
|
|
cd[0].vel.vy = 0;
|
|
|
|
cd[0].vel.vz = 0;
|
|
|
|
|
2020-12-08 19:41:43 +01:00
|
|
|
return bcollided2d(cd);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-06-05 18:31:38 +02:00
|
|
|
const int minBoxSize = 90;
|
|
|
|
const int littleBoxRange = 400;
|
|
|
|
const int halfStrike = 0x32000;
|
|
|
|
const int fullStrike = 0x32000;
|
|
|
|
|
2020-09-04 17:43:13 +02:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
void ExplosionCollisionCheck(CAR_DATA *cp, EXOBJECT *pE)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-06-05 18:31:38 +02:00
|
|
|
static int setUsed = 0;
|
|
|
|
|
2020-09-04 17:43:13 +02:00
|
|
|
int temp;
|
|
|
|
int strikeVel;
|
2020-09-04 17:43:00 +02:00
|
|
|
bool isCar;
|
2020-06-05 18:31:38 +02:00
|
|
|
VECTOR *pos;
|
2020-09-04 17:43:00 +02:00
|
|
|
int displacement;
|
|
|
|
int denom;
|
|
|
|
int debrisColour;
|
2020-06-05 18:31:38 +02:00
|
|
|
CDATA2D cd[2];
|
|
|
|
int carLength[2];
|
|
|
|
CRET2D collisionResult;
|
|
|
|
VECTOR velocity;
|
2020-12-08 17:45:14 +01:00
|
|
|
LONGVECTOR4 pointVel;
|
|
|
|
LONGVECTOR4 reaction;
|
|
|
|
LONGVECTOR4 lever;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-11-29 15:04:36 +01:00
|
|
|
isCar = (cp != &car_data[TANNER_COLLIDER_CARID]);
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
if (player[0].playerType == 2 || isCar)
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
2020-09-04 17:43:00 +02:00
|
|
|
cd[1].x.vx = cp->hd.where.t[0];
|
|
|
|
cd[1].length[0] = car_cosmetics[cp->ap.model].colBox.vz;
|
|
|
|
cd[1].length[1] = car_cosmetics[cp->ap.model].colBox.vx;
|
|
|
|
cd[1].theta = cp->hd.direction;
|
|
|
|
cd[1].x.vz = cp->hd.where.t[2];
|
|
|
|
|
|
|
|
if (pE->type <= LITTLE_BANG)
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
2021-05-15 15:46:21 +02:00
|
|
|
cd[0].length[1] = minBoxSize + ((pE->time / pE->speed) * littleBoxRange) / (4096 / pE->speed);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-09-04 17:43:00 +02:00
|
|
|
else if (pE->type == HEY_MOMMA) // biggest bang that might kill Tanner
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
|
|
|
pos = (VECTOR*)cp->hd.where.t;
|
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
if (!isCar)
|
|
|
|
pos = (VECTOR*)player->pos;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
if (cd[0].length[1] < 0)
|
2020-09-04 17:43:00 +02:00
|
|
|
cd[0].length[1] = pos->vx - pE->pos.vx;
|
|
|
|
else
|
|
|
|
cd[0].length[1] = pE->pos.vx - pos->vx;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:13 +02:00
|
|
|
temp = pE->pos.vz - pos->vz;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:13 +02:00
|
|
|
if (temp < 0)
|
|
|
|
temp = pos->vz - pE->pos.vz;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:13 +02:00
|
|
|
if (cd[0].length[1] < temp)
|
|
|
|
cd[0].length[1] = temp;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
|
|
|
if (cd[0].length[1] < 3000)
|
|
|
|
{
|
2020-09-04 17:43:00 +02:00
|
|
|
if (isCar)
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
2020-09-04 17:43:00 +02:00
|
|
|
if (CAR_INDEX(cp) == player[0].playerCarId)
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
|
|
|
cp->totalDamage = MaxPlayerDamage[0];
|
|
|
|
player[0].dying = 1;
|
|
|
|
lockAllTheDoors = 1;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-04 17:43:00 +02:00
|
|
|
else
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
|
|
|
bKillTanner = 1;
|
|
|
|
player[0].dying = 1;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-04 17:43:00 +02:00
|
|
|
else
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
|
|
|
cd[0].length[1] = 10;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-05 18:31:38 +02:00
|
|
|
else
|
|
|
|
{
|
2020-09-04 17:43:00 +02:00
|
|
|
cd[0].length[1] = 0;
|
2020-06-05 18:31:38 +02:00
|
|
|
}
|
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
cd[0].x.vx = (pE->pos).vx;
|
|
|
|
cd[0].x.vz = (pE->pos).vz;
|
|
|
|
cd[0].theta = 0;
|
|
|
|
cd[0].avel = 0;
|
|
|
|
cd[0].vel.vx = 0;
|
|
|
|
cd[0].vel.vy = 0;
|
|
|
|
cd[0].vel.vz = 0;
|
|
|
|
cd[0].length[0] = cd[0].length[1];
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-12-08 19:41:43 +01:00
|
|
|
if (bcollided2d(cd))
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
2020-09-04 17:43:00 +02:00
|
|
|
bFindCollisionPoint(cd, &collisionResult);
|
|
|
|
|
2020-09-11 11:30:58 +02:00
|
|
|
cp->hd.where.t[2] += FIXEDH(collisionResult.penetration * collisionResult.surfNormal.vz);
|
|
|
|
cp->hd.where.t[0] += FIXEDH(collisionResult.penetration * collisionResult.surfNormal.vx);
|
2020-09-04 17:43:00 +02:00
|
|
|
|
|
|
|
lever[0] = collisionResult.hit.vx - cp->hd.where.t[0];
|
|
|
|
lever[1] = 60;
|
|
|
|
lever[2] = collisionResult.hit.vz - cp->hd.where.t[2];
|
|
|
|
|
|
|
|
collisionResult.surfNormal.vy = 0;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
if (pE->type == LITTLE_BANG)
|
|
|
|
strikeVel = halfStrike - ((pE->time / pE->speed) * halfStrike) / (0x1000 / pE->speed);
|
|
|
|
else if (pE->type == BIG_BANG)
|
|
|
|
strikeVel = fullStrike;
|
|
|
|
else if (pE->type == HEY_MOMMA)
|
|
|
|
strikeVel = fullStrike << 1;
|
|
|
|
else
|
|
|
|
strikeVel = 0;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
setUsed = 1;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
if (strikeVel > 0)
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
2020-09-04 17:43:00 +02:00
|
|
|
collisionResult.hit.vy = -(cp->hd.where.t[1] + 60);
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
velocity.vx = cp->st.n.linearVelocity[0] >> 0xc;
|
|
|
|
velocity.vy = -17;
|
|
|
|
velocity.vz = cp->st.n.linearVelocity[2] >> 0xc;
|
|
|
|
|
|
|
|
if (strikeVel > 0x3600)
|
2020-06-05 18:31:38 +02:00
|
|
|
{
|
2020-09-04 17:43:00 +02:00
|
|
|
collisionResult.hit.vy += 30;
|
|
|
|
velocity.vy = -37;
|
|
|
|
Setup_Sparks(&collisionResult.hit, &velocity, 4, 0);
|
|
|
|
collisionResult.hit.vy -= 30;
|
|
|
|
velocity.vy += 20;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
if (strikeVel > 0x1b000)
|
|
|
|
{
|
|
|
|
debrisColour = GetDebrisColour(cp);
|
|
|
|
Setup_Debris(&collisionResult.hit, &velocity, 6, debrisColour << 0x10);
|
|
|
|
|
2020-09-27 11:03:11 +02:00
|
|
|
if (cp->controlType == CONTROL_TYPE_PLAYER)
|
2020-09-04 17:43:00 +02:00
|
|
|
SetPadVibration(*cp->ai.padid, 1);
|
|
|
|
}
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-11-29 15:04:36 +01:00
|
|
|
if(isCar)
|
|
|
|
DamageCar(cp, cd, &collisionResult, strikeVel);
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-11 11:30:58 +02:00
|
|
|
displacement = FIXEDH(lever[0] * collisionResult.surfNormal.vx + lever[1] * collisionResult.surfNormal.vy + lever[2] * collisionResult.surfNormal.vz);
|
2020-11-29 15:20:00 +01:00
|
|
|
displacement = FIXEDH(((lever[0] * lever[0] + lever[2] * lever[2]) - displacement * displacement) * car_cosmetics[cp->ap.model].twistRateY) + 4096;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
if (strikeVel < 0x7f001)
|
|
|
|
denom = (strikeVel * 4096) / displacement;
|
|
|
|
else
|
|
|
|
denom = (strikeVel / displacement) * 4096;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
denom >>= 6;
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
pointVel[0] = denom * (collisionResult.surfNormal.vx >> 6);
|
|
|
|
pointVel[1] = denom * (collisionResult.surfNormal.vy >> 6);
|
|
|
|
pointVel[2] = denom * (collisionResult.surfNormal.vz >> 6);
|
2020-06-05 18:31:38 +02:00
|
|
|
|
2020-10-07 16:54:48 +02:00
|
|
|
cp->st.n.linearVelocity[0] += pointVel[0];
|
|
|
|
cp->st.n.linearVelocity[1] += pointVel[1];
|
|
|
|
cp->st.n.linearVelocity[2] += pointVel[2];
|
2020-09-04 17:43:00 +02:00
|
|
|
|
2020-10-07 16:54:48 +02:00
|
|
|
cp->hd.aacc[0] += FIXEDH(lever[1] * pointVel[2]) - FIXEDH(lever[2] * pointVel[1]);
|
|
|
|
cp->hd.aacc[1] += FIXEDH(lever[2] * pointVel[0]) - FIXEDH(lever[0] * pointVel[2]);
|
|
|
|
cp->hd.aacc[2] += FIXEDH(lever[0] * pointVel[1]) - FIXEDH(lever[1] * pointVel[0]);
|
2020-09-04 17:43:00 +02:00
|
|
|
}
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-09-04 17:43:00 +02:00
|
|
|
|
|
|
|
if (isCar)
|
|
|
|
return;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-09-04 17:43:00 +02:00
|
|
|
|
|
|
|
if (setUsed != 0)
|
|
|
|
{
|
2020-04-04 06:49:28 +02:00
|
|
|
pE->type = BANG_USED;
|
2020-06-05 18:31:38 +02:00
|
|
|
setUsed = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-04 17:43:00 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void AddFlash(VECTOR *pos)
|
|
|
|
{
|
2020-06-05 17:32:32 +02:00
|
|
|
int dist;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-06-05 17:32:32 +02:00
|
|
|
dist = Long2DDistance(pos, NoPlayerControl ? &player[0].cameraPos : (VECTOR*)player[0].pos);
|
|
|
|
|
|
|
|
if (dist < 2500)
|
|
|
|
{
|
2020-04-04 06:49:28 +02:00
|
|
|
gWantFlash = 1;
|
2020-06-05 17:32:32 +02:00
|
|
|
flashval = 150 - dist / 20;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
// [D] [T]
|
|
|
|
void HandleThrownBombs(void)
|
|
|
|
{
|
|
|
|
CAR_DATA* cp;
|
|
|
|
BOMB* bomb;
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
|
|
|
|
int dx, dz;
|
|
|
|
VECTOR velocity;
|
|
|
|
|
|
|
|
// throw bombs if we have vehicle
|
|
|
|
if (gBombTargetVehicle)
|
|
|
|
{
|
|
|
|
ThrownBombDelay--;
|
|
|
|
|
|
|
|
if (ThrownBombDelay == -1)
|
|
|
|
{
|
|
|
|
ThrownBombDelay = Random2(0) % 45 + 8;
|
|
|
|
|
|
|
|
bomb = &ThrownBombs[CurrentBomb++];
|
|
|
|
CurrentBomb = CurrentBomb % MAX_THROWN_BOMBS;
|
|
|
|
|
|
|
|
bomb->flags = 1;
|
|
|
|
bomb->active = 1;
|
|
|
|
|
|
|
|
bomb->position.vx = gBombTargetVehicle->hd.where.t[0];
|
|
|
|
bomb->position.vy = gBombTargetVehicle->hd.where.t[1] - 200;
|
|
|
|
bomb->position.vz = gBombTargetVehicle->hd.where.t[2];
|
|
|
|
|
|
|
|
velocity.vx = FIXEDH(gBombTargetVehicle->st.n.linearVelocity[0]);
|
|
|
|
velocity.vz = FIXEDH(gBombTargetVehicle->st.n.linearVelocity[2]);
|
|
|
|
|
|
|
|
bomb->velocity.vx = velocity.vx >> 10;
|
|
|
|
bomb->velocity.vz = velocity.vz >> 10;
|
|
|
|
bomb->velocity.vy = -(Long2DDistance(&bomb->position, (VECTOR*)player[0].pos) >> 7);
|
|
|
|
|
|
|
|
if ((rand() & 1) == 0)
|
|
|
|
bomb->rot_speed = -bomb->velocity.vy;
|
|
|
|
else
|
|
|
|
bomb->rot_speed = bomb->velocity.vy;
|
|
|
|
|
|
|
|
if (bomb->velocity.vy < -100)
|
|
|
|
bomb->velocity.vy = -100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bomb = ThrownBombs;
|
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
for (i = 0; i < MAX_THROWN_BOMBS; i++)
|
2020-12-08 20:20:53 +01:00
|
|
|
{
|
|
|
|
if (bomb->flags & 1)
|
|
|
|
{
|
|
|
|
bomb->position.vx += bomb->velocity.vx;
|
|
|
|
bomb->position.vy += bomb->velocity.vy;
|
|
|
|
bomb->position.vz += bomb->velocity.vz;
|
|
|
|
|
|
|
|
bomb->velocity.vy += 10;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
bomb->active++;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
y = -MapHeight(&bomb->position);
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
if (y < bomb->position.vy)
|
|
|
|
{
|
|
|
|
if ((bomb->flags & 2) == 0)
|
|
|
|
{
|
|
|
|
bomb->flags |= 2;
|
|
|
|
bomb->position.vy = y;
|
|
|
|
bomb->velocity.vy = -bomb->velocity.vy / 2; // bounce
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bomb->flags = 0;
|
|
|
|
bomb->position.vy = y;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
AddExplosion(bomb->position, LITTLE_BANG);
|
|
|
|
AddFlash(&bomb->position);
|
|
|
|
|
|
|
|
dx = (bomb->position.vx - player[0].pos[0]);
|
|
|
|
dz = (bomb->position.vz - player[0].pos[2]);
|
|
|
|
|
|
|
|
if (FIXEDH(dx * dx + dz * dz) < 1024)
|
|
|
|
SetPadVibration(player[0].padid, 3); // [A] bug fix
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cp = car_data;
|
|
|
|
|
|
|
|
while (cp < &car_data[MAX_CARS])
|
|
|
|
{
|
|
|
|
if (cp != gBombTargetVehicle && cp->controlType != CONTROL_TYPE_NONE && BombCollisionCheck(cp, &bomb->position) != 0)
|
|
|
|
{
|
|
|
|
bomb->flags = 0;
|
|
|
|
|
|
|
|
AddExplosion(bomb->position, BIG_BANG);
|
|
|
|
AddFlash(&bomb->position);
|
|
|
|
}
|
|
|
|
cp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bomb++;
|
|
|
|
}
|
|
|
|
}
|