|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: bomb.c,v 1.58 2004/08/08 23:18:46 stpohle Exp $ */
|
|
|
|
|
/* $Id: bomb.c,v 1.59 2004/08/30 20:01:32 stpohle Exp $ */
|
|
|
|
|
/* everything what have to do with the bombs */
|
|
|
|
|
|
|
|
|
|
#include "bomberclone.h"
|
|
|
|
@ -103,14 +103,7 @@ draw_bomb (_bomb * bomb)
|
|
|
|
|
void
|
|
|
|
|
bomb_explode (_bomb *bomb, int net)
|
|
|
|
|
{
|
|
|
|
|
int d,
|
|
|
|
|
ftype,
|
|
|
|
|
dx,
|
|
|
|
|
dy;
|
|
|
|
|
_point dir_ch [] ={ { -1, 0 },
|
|
|
|
|
{ 1, 0 },
|
|
|
|
|
{ 0, -1 },
|
|
|
|
|
{ 0, 1 } };
|
|
|
|
|
int d;
|
|
|
|
|
|
|
|
|
|
d_printf ("Bomb Explode p:%d, b:%d [%f,%f]\n", bomb->id.p, bomb->id.b, bomb->pos.x, bomb->pos.y);
|
|
|
|
|
|
|
|
|
@ -120,23 +113,18 @@ bomb_explode (_bomb *bomb, int net)
|
|
|
|
|
players[bomb->id.p].bomb_lastex = bomb->id.b;
|
|
|
|
|
bomb->to = EXPLOSIONTIMEOUT; /* set the timeout for the fireexplosion */
|
|
|
|
|
bomb->state = BS_exploding;
|
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
|
dx = bomb->pos.x;
|
|
|
|
|
dy = bomb->pos.y;
|
|
|
|
|
bomb->firer[d] = 0;
|
|
|
|
|
ftype = map.field[dx][dy].type;
|
|
|
|
|
|
|
|
|
|
while ((ftype == FT_nothing || ftype == FT_tunnel) && bomb->firer[d] < bomb->r) {
|
|
|
|
|
bomb->firer[d]++;
|
|
|
|
|
dx += dir_ch[d].x;
|
|
|
|
|
dy += dir_ch[d].y;
|
|
|
|
|
ftype = explosion_check_field (dx, dy, bomb);
|
|
|
|
|
if (ftype == FT_nothing || ftype == FT_tunnel) {
|
|
|
|
|
map.field[dx][dy].ex[d].count++;
|
|
|
|
|
map.field[dx][dy].ex[d].frame = bomb->firer[d];
|
|
|
|
|
stonelist_add (dx, dy);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
explosion_check_field ((int)bomb->pos.x, (int)bomb->pos.y, bomb);
|
|
|
|
|
|
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
|
bomb->firer[d] = 0.0f;
|
|
|
|
|
bomb->firemaxr[d] = 0;
|
|
|
|
|
map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex[d].count++;
|
|
|
|
|
map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex[d].frame = 0.0f;
|
|
|
|
|
map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex_nr = bomb->ex_nr;
|
|
|
|
|
map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex[d].bomb_p = bomb->id.p;
|
|
|
|
|
map.field[(int)bomb->pos.x][(int)bomb->pos.y].ex[d].bomb_b = bomb->id.b;
|
|
|
|
|
stonelist_add ((int)bomb->pos.x, (int)bomb->pos.y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GT_MP_PTPM && net) /* from now on only the server let the bomb explode */
|
|
|
|
@ -360,6 +348,8 @@ void explosion_restore (_bomb *bomb) {
|
|
|
|
|
{ 0, -1 },
|
|
|
|
|
{ 0, 1 } };
|
|
|
|
|
|
|
|
|
|
// printf ("342: bomb (%d,%d)\n", (int) bomb->pos.x, (int) bomb->pos.y);
|
|
|
|
|
|
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
|
_x = bomb->pos.x;
|
|
|
|
|
_y = bomb->pos.y;
|
|
|
|
@ -368,6 +358,7 @@ void explosion_restore (_bomb *bomb) {
|
|
|
|
|
map.field[_x][_y].ex[d].count--;
|
|
|
|
|
if (map.field[_x][_y].ex[d].count == 0)
|
|
|
|
|
map.field[_x][_y].ex[d].frame = 0; // reset the framenumber
|
|
|
|
|
if (d==3) stonelist_add (_x, _y);
|
|
|
|
|
|
|
|
|
|
/* with every field where was an fire on it decrease the ex[].count value
|
|
|
|
|
* and force an drawing of this field */
|
|
|
|
@ -379,7 +370,7 @@ void explosion_restore (_bomb *bomb) {
|
|
|
|
|
map.field[_x][_y].ex[d].count--;
|
|
|
|
|
if (map.field[_x][_y].ex[d].count == 0)
|
|
|
|
|
map.field[_x][_y].ex[d].frame = 0; // reset the framenumber
|
|
|
|
|
|
|
|
|
|
// printf ("361: d = %d, (%d,%d)\n", d, _x, _y);
|
|
|
|
|
stonelist_add (_x, _y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -398,6 +389,7 @@ void explosion_restore (_bomb *bomb) {
|
|
|
|
|
map.field[_x][_y].type = FT_nothing;
|
|
|
|
|
d_printf ("field_explode (%d,%d) ex_nr = %d\n", _x, _y, map.field[_x][_y].ex_nr);
|
|
|
|
|
|
|
|
|
|
// printf ("380: d = %d, (%d,%d)\n", d, _x, _y);
|
|
|
|
|
stonelist_add (_x, _y);
|
|
|
|
|
|
|
|
|
|
if (GT_MP_PTPM) /* send only if we are the master */
|
|
|
|
@ -469,12 +461,60 @@ explosion_draw (_bomb * bomb)
|
|
|
|
|
* calculate the explosion itself,
|
|
|
|
|
* check the direction of the explosion and and and
|
|
|
|
|
*
|
|
|
|
|
* as long as the explosion grows, make sure the explosion will reach it's 'maximum'
|
|
|
|
|
* (MAX_RANGE) end at 1.5 seconds. Make sure all explosion will have the same speed.
|
|
|
|
|
* range += (MAX_RANGE/1.0) * timediff;
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void explosion_do (_bomb *bomb) {
|
|
|
|
|
/* with a slow pc disable this --- maybe option over a config menu */
|
|
|
|
|
if (bomb->state == BS_exploding)
|
|
|
|
|
_point dir_ch [] ={ { -1, 0 },
|
|
|
|
|
{ 1, 0 },
|
|
|
|
|
{ 0, -1 },
|
|
|
|
|
{ 0, 1 } };
|
|
|
|
|
int d, dx, dy, ftype;
|
|
|
|
|
float range_grow = (timediff * (float) MAX_RANGE)/EXPLOSION_GROW_SPEED;
|
|
|
|
|
float range;
|
|
|
|
|
|
|
|
|
|
if (bomb->state == BS_exploding) {
|
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
|
if (bomb->firemaxr[d] == 0 && bomb->firer[d] < bomb->r) {
|
|
|
|
|
|
|
|
|
|
range = bomb->firer[d];
|
|
|
|
|
bomb->firer[d] += range_grow;
|
|
|
|
|
if (bomb->firer[d] > bomb->r) bomb->firer[d] = bomb->r;
|
|
|
|
|
|
|
|
|
|
dx = bomb->pos.x + (dir_ch[d].x * rintf (range));
|
|
|
|
|
dy = bomb->pos.y + (dir_ch[d].y * rintf (range));
|
|
|
|
|
|
|
|
|
|
/* check all fields between [dx,dy] and [odx,ody] */
|
|
|
|
|
while (bomb->firemaxr[d] == 0 && (rintf (range) < rintf (bomb->firer[d]))) {
|
|
|
|
|
|
|
|
|
|
if (rintf (range) < rintf(bomb->firer[d])) {
|
|
|
|
|
range += 1.0f;
|
|
|
|
|
dx += dir_ch[d].x;
|
|
|
|
|
dy += dir_ch[d].y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ftype = explosion_check_field (dx, dy, bomb);
|
|
|
|
|
if (ftype == FT_nothing || ftype == FT_tunnel) {
|
|
|
|
|
// printf ("484: count++ d=%d (%d,%d) c_old: %d\n", d, dx, dy, map.field[dx][dy].ex[d].count);
|
|
|
|
|
map.field[dx][dy].ex[d].count++;
|
|
|
|
|
map.field[dx][dy].ex[d].frame = 0.0f;
|
|
|
|
|
map.field[dx][dy].ex_nr = bomb->ex_nr;
|
|
|
|
|
map.field[dx][dy].ex[d].bomb_p = bomb->id.p;
|
|
|
|
|
map.field[dx][dy].ex[d].bomb_b = bomb->id.b;
|
|
|
|
|
stonelist_add (dx, dy);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bomb->firemaxr[d] = 1;
|
|
|
|
|
bomb->firer[d] = rintf (bomb->firer[d]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
explosion_draw (bomb);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|