|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: bomb.c,v 1.60 2004/10/18 18:27:19 stpohle Exp $ */
|
|
|
|
/* $Id: bomb.c,v 1.61 2004/12/01 02:41:54 stpohle Exp $ */
|
|
|
|
/* everything what have to do with the bombs */
|
|
|
|
/* everything what have to do with the bombs */
|
|
|
|
|
|
|
|
|
|
|
|
#include "bomberclone.h"
|
|
|
|
#include "bomberclone.h"
|
|
|
@ -242,12 +242,11 @@ bomb_move (_bomb * bomb)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
void
|
|
|
|
bomb_loop ()
|
|
|
|
bomb_loop ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int p,
|
|
|
|
int p,
|
|
|
|
i,
|
|
|
|
i;
|
|
|
|
b = 0;
|
|
|
|
|
|
|
|
_player *player;
|
|
|
|
_player *player;
|
|
|
|
_bomb *bomb;
|
|
|
|
_bomb *bomb;
|
|
|
|
|
|
|
|
|
|
|
@ -282,26 +281,24 @@ bomb_loop ()
|
|
|
|
if (bomb->mode != BM_normal)
|
|
|
|
if (bomb->mode != BM_normal)
|
|
|
|
bomb_action (bomb);
|
|
|
|
bomb_action (bomb);
|
|
|
|
|
|
|
|
|
|
|
|
b++; // Count ticking Bombs for Return value
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case BS_exploding:
|
|
|
|
case BS_exploding:
|
|
|
|
if (bomb->to > 0.0f) {
|
|
|
|
if (bomb->to > 0.0f) {
|
|
|
|
explosion_do (bomb);
|
|
|
|
explosion_do (bomb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bomb->to <= 0.0f) { // explosion done
|
|
|
|
else if (bomb->to <= 0.0f) { // explosion done
|
|
|
|
explosion_restore (bomb);
|
|
|
|
explosion_restore (bomb);
|
|
|
|
bomb->to = 0.0f;
|
|
|
|
bomb->to = 0.0f;
|
|
|
|
bomb->state = BS_off;
|
|
|
|
bomb->state = BS_off;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bomb->to -= timediff;
|
|
|
|
bomb->to -= timediff;
|
|
|
|
b++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -343,30 +340,31 @@ void explosion_restore (_bomb *bomb) {
|
|
|
|
d,
|
|
|
|
d,
|
|
|
|
_x,
|
|
|
|
_x,
|
|
|
|
_y;
|
|
|
|
_y;
|
|
|
|
// printf ("342: bomb (%d,%d)\n", (int) bomb->pos.x, (int) bomb->pos.y);
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("explosion_restore: %f,%f\n", bomb->pos.x, bomb->pos.y);
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
_x = bomb->pos.x;
|
|
|
|
_x = bomb->pos.x;
|
|
|
|
_y = bomb->pos.y;
|
|
|
|
_y = bomb->pos.y;
|
|
|
|
|
|
|
|
|
|
|
|
if (map.field[_x][_y].ex[d].count > 0)
|
|
|
|
if (map.field[_x][_y].ex[d].count > 0)
|
|
|
|
map.field[_x][_y].ex[d].count--;
|
|
|
|
map.field[_x][_y].ex[d].count--;
|
|
|
|
if (map.field[_x][_y].ex[d].count == 0)
|
|
|
|
map.field[_x][_y].ex[d].frame = 0.0f; // reset the framenumber
|
|
|
|
map.field[_x][_y].ex[d].frame = 0; // reset the framenumber
|
|
|
|
if (d==3) {
|
|
|
|
if (d==3) stonelist_add (_x, _y);
|
|
|
|
stonelist_add (_x, _y);
|
|
|
|
|
|
|
|
// printf ("restore: %d,%d\n", _x, _y);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* with every field where was an fire on it decrease the ex[].count value
|
|
|
|
/* with every field where was an fire on it decrease the ex[].count value
|
|
|
|
* and force an drawing of this field */
|
|
|
|
* and force an drawing of this field */
|
|
|
|
for (i = 0; i < bomb->firer[d]; i++) { // lower the number of explosions
|
|
|
|
for (i = 0; i < rintf(bomb->firer[d]); i++) { // lower the number of explosions
|
|
|
|
_x = _x + dir_change[d].x;
|
|
|
|
_x = _x + dir_change[d].x;
|
|
|
|
_y = _y + dir_change[d].y;
|
|
|
|
_y = _y + dir_change[d].y;
|
|
|
|
|
|
|
|
|
|
|
|
if (map.field[_x][_y].ex[d].count > 0)
|
|
|
|
if (map.field[_x][_y].ex[d].count > 0)
|
|
|
|
map.field[_x][_y].ex[d].count--;
|
|
|
|
map.field[_x][_y].ex[d].count--;
|
|
|
|
if (map.field[_x][_y].ex[d].count == 0)
|
|
|
|
map.field[_x][_y].ex[d].frame = 0.0f; // reset the framenumber
|
|
|
|
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);
|
|
|
|
stonelist_add (_x, _y);
|
|
|
|
|
|
|
|
// printf ("restore: %d,%d c=%d\n", _x, _y, map.field[_x][_y].ex[d].count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* delete the stone completly if there was any in the way
|
|
|
|
/* delete the stone completly if there was any in the way
|
|
|
@ -382,7 +380,7 @@ void explosion_restore (_bomb *bomb) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
map.field[_x][_y].type = FT_nothing;
|
|
|
|
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);
|
|
|
|
// 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);
|
|
|
|
// printf ("380: d = %d, (%d,%d)\n", d, _x, _y);
|
|
|
|
stonelist_add (_x, _y);
|
|
|
|
stonelist_add (_x, _y);
|
|
|
@ -444,32 +442,33 @@ explosion_draw (_bomb * bomb)
|
|
|
|
void explosion_do (_bomb *bomb) {
|
|
|
|
void explosion_do (_bomb *bomb) {
|
|
|
|
int d, dx, dy, ftype;
|
|
|
|
int d, dx, dy, ftype;
|
|
|
|
float range_grow = (timediff * (float) MAX_RANGE)/EXPLOSION_GROW_SPEED;
|
|
|
|
float range_grow = (timediff * (float) MAX_RANGE)/EXPLOSION_GROW_SPEED;
|
|
|
|
float range;
|
|
|
|
float new_range;
|
|
|
|
|
|
|
|
float step;
|
|
|
|
|
|
|
|
|
|
|
|
if (bomb->state == BS_exploding) {
|
|
|
|
if (bomb->state == BS_exploding) {
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
if (bomb->firemaxr[d] == 0 && bomb->firer[d] < bomb->r) {
|
|
|
|
if (bomb->firemaxr[d] == 0 && bomb->firer[d] < bomb->r) {
|
|
|
|
|
|
|
|
|
|
|
|
range = bomb->firer[d];
|
|
|
|
new_range = bomb->firer[d] + range_grow;
|
|
|
|
bomb->firer[d] += range_grow;
|
|
|
|
if (new_range > bomb->r) new_range = bomb->r;
|
|
|
|
if (bomb->firer[d] > bomb->r) bomb->firer[d] = bomb->r;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dx = bomb->pos.x + (dir_change[d].x * rintf (range));
|
|
|
|
|
|
|
|
dy = bomb->pos.y + (dir_change[d].y * rintf (range));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* check all fields between [dx,dy] and [odx,ody] */
|
|
|
|
/* check all fields between [dx,dy] and [odx,ody] */
|
|
|
|
while (bomb->firemaxr[d] == 0 && (rintf (range) < rintf (bomb->firer[d]))) {
|
|
|
|
while (bomb->firemaxr[d] == 0 && (bomb->firer[d] < new_range)) {
|
|
|
|
|
|
|
|
step = new_range - bomb->firer[d];
|
|
|
|
if (rintf (range) < rintf(bomb->firer[d])) {
|
|
|
|
|
|
|
|
range += 1.0f;
|
|
|
|
if (step > 1.0f) {
|
|
|
|
dx += dir_change[d].x;
|
|
|
|
step = 1.0f;
|
|
|
|
dy += dir_change[d].y;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bomb->firer[d] += step;
|
|
|
|
|
|
|
|
// printf ("d:%d, Cur_Range:%f New_Range:%f\n", d, bomb->firer[d], new_range);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dx = rintf(bomb->pos.x + dir_change[d].x * bomb->firer[d]);
|
|
|
|
|
|
|
|
dy = rintf(bomb->pos.y + dir_change[d].y * bomb->firer[d]);
|
|
|
|
|
|
|
|
|
|
|
|
ftype = explosion_check_field (dx, dy, bomb);
|
|
|
|
ftype = explosion_check_field (dx, dy, bomb);
|
|
|
|
if (ftype == FT_nothing || ftype == FT_tunnel) {
|
|
|
|
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);
|
|
|
|
if (map.field[dx][dy].ex[d].count == 0 || map.field[dx][dy].ex_nr != bomb->ex_nr)
|
|
|
|
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[d].frame = 0.0f;
|
|
|
|
map.field[dx][dy].ex_nr = bomb->ex_nr;
|
|
|
|
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_p = bomb->id.p;
|
|
|
|