|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: bomb.c,v 1.51 2003/11/09 04:09:49 stpohle Exp $ */
|
|
|
|
/* $Id: bomb.c,v 1.52 2004/01/07 23:04:31 patty21 Exp $ */
|
|
|
|
/* everything what have to do with the bombs */
|
|
|
|
/* everything what have to do with the bombs */
|
|
|
|
|
|
|
|
|
|
|
|
#include "bomberclone.h"
|
|
|
|
#include "bomberclone.h"
|
|
|
@ -11,14 +11,18 @@ draw_bomb (_bomb * bomb)
|
|
|
|
dest;
|
|
|
|
dest;
|
|
|
|
int x = floorf (bomb->pos.x),
|
|
|
|
int x = floorf (bomb->pos.x),
|
|
|
|
y = floorf (bomb->pos.y);
|
|
|
|
y = floorf (bomb->pos.y);
|
|
|
|
|
|
|
|
float w,
|
|
|
|
|
|
|
|
x1,
|
|
|
|
|
|
|
|
x2,
|
|
|
|
|
|
|
|
y1,
|
|
|
|
|
|
|
|
y2;
|
|
|
|
|
|
|
|
|
|
|
|
if (x < 0 || y < 0 || x >= map.size.x || y >= map.size.y) {
|
|
|
|
if (x < 0 || y < 0 || x >= map.size.x || y >= map.size.y) {
|
|
|
|
d_printf ("FATAL: Draw Bomb out of range [%f,%f]\n", x, y);
|
|
|
|
d_printf ("FATAL: Draw Bomb out of range [%f,%f]\n", x, y);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (bomb->state != BS_trigger
|
|
|
|
if (bomb->state != BS_trigger || ((bomb->state == BS_trigger) && (bomb->to < BOMB_TIMEOUT))) {
|
|
|
|
|| ((bomb->state == BS_trigger) && (bomb->to < BOMB_TIMEOUT))) {
|
|
|
|
|
|
|
|
/* check the framenumber */
|
|
|
|
/* check the framenumber */
|
|
|
|
bomb->frame += (timefactor / 3.0);
|
|
|
|
bomb->frame += (timefactor / 3.0);
|
|
|
|
if (bomb->frame < 0 || bomb->frame >= gfx.bomb.frames)
|
|
|
|
if (bomb->frame < 0 || bomb->frame >= gfx.bomb.frames)
|
|
|
@ -27,8 +31,48 @@ draw_bomb (_bomb * bomb)
|
|
|
|
|
|
|
|
|
|
|
|
dest.w = src.w = gfx.bomb.image->w;
|
|
|
|
dest.w = src.w = gfx.bomb.image->w;
|
|
|
|
dest.h = src.h = gfx.block.y;
|
|
|
|
dest.h = src.h = gfx.block.y;
|
|
|
|
|
|
|
|
if (bomb->mode == BM_kicked) {
|
|
|
|
|
|
|
|
w = sqrt (bomb->speed);
|
|
|
|
|
|
|
|
w *= absol (sin (w));
|
|
|
|
|
|
|
|
x1 = bomb->dest.x - bomb->pos.x;
|
|
|
|
|
|
|
|
y1 = bomb->dest.y - bomb->pos.y;
|
|
|
|
|
|
|
|
if (x1 > 0) {
|
|
|
|
|
|
|
|
x2 = bomb->pos.x + x1 * bomb->speed / 88 + y1 * w / 20;
|
|
|
|
|
|
|
|
y2 = bomb->pos.y + y1 * bomb->speed / 88 - x1 * w / 20;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
x2 = bomb->pos.x + x1 * bomb->speed / 88 - y1 * w / 20;
|
|
|
|
|
|
|
|
y2 = bomb->pos.y + y1 * bomb->speed / 88 + x1 * w / 20;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
x = floorf (x2);
|
|
|
|
|
|
|
|
y = floorf (y2);
|
|
|
|
|
|
|
|
bomb->speed -= timediff * 100;
|
|
|
|
|
|
|
|
if (bomb->speed < 0) {
|
|
|
|
dest.x = gfx.offset.x + bomb->pos.x * gfx.block.x;
|
|
|
|
dest.x = gfx.offset.x + bomb->pos.x * gfx.block.x;
|
|
|
|
dest.y = gfx.offset.y + bomb->pos.y * gfx.block.y;
|
|
|
|
dest.y = gfx.offset.y + bomb->pos.y * gfx.block.y;
|
|
|
|
|
|
|
|
bomb->mode = BM_normal;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
w = sqrt (bomb->speed);
|
|
|
|
|
|
|
|
w *= absol (sin (w));
|
|
|
|
|
|
|
|
if (x1 > 0) {
|
|
|
|
|
|
|
|
x2 = bomb->pos.x + x1 * bomb->speed / 88 + y1 * w / 20;
|
|
|
|
|
|
|
|
y2 = bomb->pos.y + y1 * bomb->speed / 88 - x1 * w / 20;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
x2 = bomb->pos.x + x1 * bomb->speed / 88 - y1 * w / 20;
|
|
|
|
|
|
|
|
y2 = bomb->pos.y + y1 * bomb->speed / 88 + x1 * w / 20;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dest.x = gfx.offset.x + x2 * gfx.block.x;
|
|
|
|
|
|
|
|
dest.y = gfx.offset.y + y2 * gfx.block.y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
dest.x = gfx.offset.x + bomb->pos.x * gfx.block.x;
|
|
|
|
|
|
|
|
dest.y = gfx.offset.y + bomb->pos.y * gfx.block.y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
src.x = 0;
|
|
|
|
src.x = 0;
|
|
|
|
src.y = src.h * (int) bomb->frame;
|
|
|
|
src.y = src.h * (int) bomb->frame;
|
|
|
|
stonelist_add (x, y);
|
|
|
|
stonelist_add (x, y);
|
|
|
@ -75,8 +119,10 @@ void
|
|
|
|
bomb_move (_bomb * bomb)
|
|
|
|
bomb_move (_bomb * bomb)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int keepdir = 0;
|
|
|
|
int keepdir = 0;
|
|
|
|
_pointf fpos, rpos;
|
|
|
|
_pointf fpos,
|
|
|
|
float dist = 0.0f, step = 0.0f;
|
|
|
|
rpos;
|
|
|
|
|
|
|
|
float dist = 0.0f,
|
|
|
|
|
|
|
|
step = 0.0f;
|
|
|
|
|
|
|
|
|
|
|
|
map.bfield[(int) bomb->pos.x][(int) bomb->pos.y] = 0; /* delete bfield */
|
|
|
|
map.bfield[(int) bomb->pos.x][(int) bomb->pos.y] = 0; /* delete bfield */
|
|
|
|
stonelist_add (bomb->pos.x, bomb->pos.y);
|
|
|
|
stonelist_add (bomb->pos.x, bomb->pos.y);
|
|
|
@ -124,14 +170,17 @@ bomb_move (_bomb * bomb)
|
|
|
|
bomb->mode = BM_normal;
|
|
|
|
bomb->mode = BM_normal;
|
|
|
|
else if (bomb->mode == BM_moving || bomb->mode == BM_liquid) {
|
|
|
|
else if (bomb->mode == BM_moving || bomb->mode == BM_liquid) {
|
|
|
|
/* it is a moving liquid bomb so check for another field */
|
|
|
|
/* it is a moving liquid bomb so check for another field */
|
|
|
|
_point b, d;
|
|
|
|
_point b,
|
|
|
|
|
|
|
|
d;
|
|
|
|
|
|
|
|
|
|
|
|
b.x = (int) bomb->pos.x;
|
|
|
|
b.x = (int) bomb->pos.x;
|
|
|
|
b.y = (int) bomb->pos.y;
|
|
|
|
b.y = (int) bomb->pos.y;
|
|
|
|
d.x = b.x + bomb->dest.x;
|
|
|
|
d.x = b.x + bomb->dest.x;
|
|
|
|
d.y = b.y + bomb->dest.y;
|
|
|
|
d.y = b.y + bomb->dest.y;
|
|
|
|
|
|
|
|
|
|
|
|
if (map.bfield[d.x][d.y] == 0 && (map.field[d.x][d.y].type == FT_nothing || map.field[d.x][d.y].type == FT_tunnel))
|
|
|
|
if (map.bfield[d.x][d.y] == 0
|
|
|
|
|
|
|
|
&& (map.field[d.x][d.y].type == FT_nothing
|
|
|
|
|
|
|
|
|| map.field[d.x][d.y].type == FT_tunnel))
|
|
|
|
/* this direction is still oky */
|
|
|
|
/* this direction is still oky */
|
|
|
|
keepdir = 1;
|
|
|
|
keepdir = 1;
|
|
|
|
else if (bomb->mode == BM_liquid) {
|
|
|
|
else if (bomb->mode == BM_liquid) {
|
|
|
@ -149,7 +198,8 @@ bomb_move (_bomb * bomb)
|
|
|
|
/* if a network game is running send bomb data with the
|
|
|
|
/* if a network game is running send bomb data with the
|
|
|
|
current information */
|
|
|
|
current information */
|
|
|
|
if (GT_MP) {
|
|
|
|
if (GT_MP) {
|
|
|
|
int b = -1, i = 0;
|
|
|
|
int b = -1,
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
if (&players[bman.p_nr].bombs[i] == bomb)
|
|
|
|
if (&players[bman.p_nr].bombs[i] == bomb)
|
|
|
@ -163,7 +213,8 @@ bomb_move (_bomb * bomb)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dist += step;
|
|
|
|
dist += step;
|
|
|
|
} while (dist < (timefactor * bomb->speed) && (bomb->mode == BM_liquid || bomb->mode == BM_moving) && keepdir);
|
|
|
|
} while (dist < (timefactor * bomb->speed)
|
|
|
|
|
|
|
|
&& (bomb->mode == BM_liquid || bomb->mode == BM_moving) && keepdir);
|
|
|
|
|
|
|
|
|
|
|
|
map.bfield[(int) bomb->pos.x][(int) bomb->pos.y] = 1; /* set new bfield */
|
|
|
|
map.bfield[(int) bomb->pos.x][(int) bomb->pos.y] = 1; /* set new bfield */
|
|
|
|
stonelist_add (bomb->pos.x, bomb->pos.y);
|
|
|
|
stonelist_add (bomb->pos.x, bomb->pos.y);
|
|
|
@ -248,7 +299,8 @@ get_bomb_on (float x, float y, _point bombs[])
|
|
|
|
for (b = 0; b < MAX_BOMBS; b++) {
|
|
|
|
for (b = 0; b < MAX_BOMBS; b++) {
|
|
|
|
bomb = &players[p].bombs[b];
|
|
|
|
bomb = &players[p].bombs[b];
|
|
|
|
if (bomb->state == BS_ticking || bomb->state == BS_trigger) {
|
|
|
|
if (bomb->state == BS_ticking || bomb->state == BS_trigger) {
|
|
|
|
if (bomb->pos.x-1.0f < x && bomb->pos.x+1.0f > x && bomb->pos.y-1.0f < y && bomb->pos.y+1.0f > y) {
|
|
|
|
if (bomb->pos.x - 1.0f < x && bomb->pos.x + 1.0f > x && bomb->pos.y - 1.0f < y
|
|
|
|
|
|
|
|
&& bomb->pos.y + 1.0f > y) {
|
|
|
|
bombs[i].x = p;
|
|
|
|
bombs[i].x = p;
|
|
|
|
bombs[i].y = b;
|
|
|
|
bombs[i].y = b;
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
@ -287,9 +339,12 @@ draw_fire (int x, int y, int d, int frame)
|
|
|
|
void
|
|
|
|
void
|
|
|
|
restore_explosion (_bomb * bomb)
|
|
|
|
restore_explosion (_bomb * bomb)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i, j,
|
|
|
|
int i,
|
|
|
|
d, dx = 0,
|
|
|
|
j,
|
|
|
|
dy = 0, _x,
|
|
|
|
d,
|
|
|
|
|
|
|
|
dx = 0,
|
|
|
|
|
|
|
|
dy = 0,
|
|
|
|
|
|
|
|
_x,
|
|
|
|
_y;
|
|
|
|
_y;
|
|
|
|
|
|
|
|
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
@ -331,8 +386,7 @@ restore_explosion (_bomb * bomb)
|
|
|
|
|
|
|
|
|
|
|
|
// delete the stone completly if there was any in the way
|
|
|
|
// delete the stone completly if there was any in the way
|
|
|
|
if (bomb->firer[d] <= bomb->r && map.field[_x][_y].type != FT_block
|
|
|
|
if (bomb->firer[d] <= bomb->r && map.field[_x][_y].type != FT_block
|
|
|
|
&& map.field[_x][_y].type != FT_tunnel
|
|
|
|
&& map.field[_x][_y].type != FT_tunnel && bomb->ex_nr != map.field[_x][_y].ex_nr) {
|
|
|
|
&& bomb->ex_nr != map.field[_x][_y].ex_nr) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.field[_x][_y].ex_nr = bomb->ex_nr;
|
|
|
|
map.field[_x][_y].ex_nr = bomb->ex_nr;
|
|
|
|
map.field[_x][_y].frame = 0.0f;
|
|
|
|
map.field[_x][_y].frame = 0.0f;
|
|
|
@ -393,7 +447,8 @@ explosion_check_field (int x, int y, int p, int b)
|
|
|
|
for (i = 0; pl[i] != -1; i++) {
|
|
|
|
for (i = 0; pl[i] != -1; i++) {
|
|
|
|
tmpplayer = &players[pl[i]];
|
|
|
|
tmpplayer = &players[pl[i]];
|
|
|
|
if (((tmpplayer->state & PSF_alife) != 0)
|
|
|
|
if (((tmpplayer->state & PSF_alife) != 0)
|
|
|
|
&& (GT_SP || (GT_MP && (&players[bman.p_nr] == tmpplayer)) || (GT_MP_PTPM && PS_IS_aiplayer(tmpplayer->state))))
|
|
|
|
&& (GT_SP || (GT_MP && (&players[bman.p_nr] == tmpplayer))
|
|
|
|
|
|
|
|
|| (GT_MP_PTPM && PS_IS_aiplayer (tmpplayer->state))))
|
|
|
|
player_died (tmpplayer, p);
|
|
|
|
player_died (tmpplayer, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -494,7 +549,8 @@ do_explosion (int p, int b)
|
|
|
|
&& bomb->firerst[d] == -1) {
|
|
|
|
&& bomb->firerst[d] == -1) {
|
|
|
|
bomb->firer[d]++;
|
|
|
|
bomb->firer[d]++;
|
|
|
|
map.field[(int) bomb->pos.x + dx][(int) bomb->pos.y + dy].ex[d].count++;
|
|
|
|
map.field[(int) bomb->pos.x + dx][(int) bomb->pos.y + dy].ex[d].count++;
|
|
|
|
map.field[(int)bomb->pos.x + dx][(int)bomb->pos.y + dy].ex[d].frame = bomb->firer[d];
|
|
|
|
map.field[(int) bomb->pos.x + dx][(int) bomb->pos.y + dy].ex[d].frame =
|
|
|
|
|
|
|
|
bomb->firer[d];
|
|
|
|
/* if we have a slow pc we can enable this and disable the drawing animation */
|
|
|
|
/* if we have a slow pc we can enable this and disable the drawing animation */
|
|
|
|
// draw_fire (bomb->pos.x + dx, bomb->pos.y + dy, d, gfx.fire.frames>>1);
|
|
|
|
// draw_fire (bomb->pos.x + dx, bomb->pos.y + dy, d, gfx.fire.frames>>1);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -511,13 +567,17 @@ do_explosion (int p, int b)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void bomb_action (_bomb *bomb) {
|
|
|
|
inline void
|
|
|
|
|
|
|
|
bomb_action (_bomb * bomb)
|
|
|
|
|
|
|
|
{
|
|
|
|
switch (bomb->mode) {
|
|
|
|
switch (bomb->mode) {
|
|
|
|
case (BM_moving):
|
|
|
|
case (BM_moving):
|
|
|
|
case (BM_liquid):
|
|
|
|
case (BM_liquid):
|
|
|
|
case (BM_pushed):
|
|
|
|
case (BM_pushed):
|
|
|
|
bomb_move (bomb);
|
|
|
|
bomb_move (bomb);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (BM_kicked):
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
bomb->mode = BM_normal;
|
|
|
|
bomb->mode = BM_normal;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|