single player needed to be fixed for the tunnel thing.. network is still not tested... but i am working on it

origin
stpohle 22 years ago
parent 494a2137bb
commit 0a2af7c18c

@ -1,4 +1,4 @@
/* $Id: map.c,v 1.7 2003/08/10 15:10:19 stpohle Exp $ */
/* $Id: map.c,v 1.8 2003/08/10 19:31:14 stpohle Exp $ */
/* map handling, like generate and load maps. */
#include "bomberclone.h"
@ -55,8 +55,6 @@ map_new (char *filename)
if (fmap == NULL)
map_genrandom ();
map.type = 1;
if (map.type == -1)
map.type = s_random (MAPT_max);
@ -255,20 +253,29 @@ map_set_playerposition (int usermap)
PLX = 2 * (s_random ((map.size.x - 1) / 2)) + 1;
PLY = 2 * (s_random ((map.size.y - 1) / 2)) + 1;
if (map.field[PLX][PLY].type != FT_tunnel)
map.field[PLX][PLY].type = FT_nothing;
dx = s_random (4); // bit 1 = up/down bit 2 = left/right
/* up and down */
if (((dx & 1) == 0 && PLX > 1) || PLX >= map.size.x - 2)
if (((dx & 1) == 0 && PLX > 1) || PLX >= map.size.x - 2) {
if (map.field[PLX - 1][PLY].type != FT_tunnel)
map.field[PLX - 1][PLY].type = FT_nothing;
else
}
else {
if (map.field[PLX + 1][PLY].type != FT_tunnel)
map.field[PLX + 1][PLY].type = FT_nothing;
}
/* left and right */
if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2)
if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2) {
if (map.field[PLX][PLY - 1].type != FT_tunnel)
map.field[PLX][PLY - 1].type = FT_nothing;
else
}
else {
if (map.field[PLX][PLY + 1].type != FT_tunnel)
map.field[PLX][PLY + 1].type = FT_nothing;
}
}
mx = my = 100;
for (j = 0; j <= i; j++) { /* search smalest distance */
dy = PLY - bman.players[j].pos.y;

@ -319,13 +319,27 @@ stepmove_player (int pl_nr)
_pos.x = p->pos.x & 255;
_pos.y = p->pos.y & 255;
if (_pos.x == 0 && _pos.y == 0 && map.field[fpos.x][fpos.y].type == FT_tunnel && p->tunnelto == -1) {
if (_pos.x == 0 && _pos.y == 0 && map.field[fpos.x][fpos.y].type == FT_tunnel
&& p->tunnelto == -1) {
d_printf ("Tunnel [%d] Player %s is going to (%d,%d)\n",
map.field[fpos.x][fpos.y].special, p->name,
map.tunnel[map.field[fpos.x][fpos.y].special].x,
map.tunnel[map.field[fpos.x][fpos.y].special].y);
d.x = d.y = 0;
if (map.
bfield[map.tunnel[map.field[fpos.x][fpos.y].special].x][map.
tunnel[map.
field[fpos.x][fpos.
y].
special].y])
d_printf (" *** End of tunnel is with an bomb.\n");
else {
p->pos.x = map.tunnel[map.field[fpos.x][fpos.y].special].x << 8;
p->pos.y = map.tunnel[map.field[fpos.x][fpos.y].special].y << 8;
p->tunnelto = GAME_TUNNEL_TO;
}
}
}
if (d.x == 0 && d.y == 0)
return 0;
@ -383,7 +397,7 @@ move_player (int pl_nr)
/* network packet send control - send data if it's time to send or if we need to */
if (bman.gametype != GT_single)
net_game_send_playermove (pl_nr, (p->old_m == 0));
if (p->tunnelto==0)
if (p->tunnelto == 0)
p->tunnelto = -1;
}
@ -393,8 +407,6 @@ move_player (int pl_nr)
p->old_m = p->m; // save the old state
p->m = 0;
}
/* check the players position */
if ((p->pos.x & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == left || p->d == right))
if (!check_field ((p->pos.x >> 8) + 1, (p->pos.y >> 8)))
@ -408,6 +420,8 @@ move_player (int pl_nr)
&& (p->d == up || p->d == down)))
if (!check_field (p->pos.x >> 8, p->pos.y >> 8))
player_died (p, -1);
}
};
@ -485,7 +499,7 @@ get_player_on (short int x, short int y, int pl_nr[])
p;
for (i = 0, p = 0; p < MAX_PLAYERS; p++)
if (PS_IS_alife (bman.players[p].state)) {
if (PS_IS_alife (bman.players[p].state) && bman.players[p].tunnelto <= 0) {
if (bman.players[p].pos.x - EXPLOSION_SAVE_DISTANCE > x - 256
&& bman.players[p].pos.x + EXPLOSION_SAVE_DISTANCE < x + 256
&& bman.players[p].pos.y - EXPLOSION_SAVE_DISTANCE > y - 256

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.42 2003/07/27 20:16:58 stpohle Exp $ */
/* $Id: single.c,v 1.43 2003/08/10 19:31:15 stpohle Exp $ */
/* single player */
#include "basic.h"
@ -20,6 +20,7 @@ single_game_new ()
if (PS_IS_used (bman.players[p].state)) {
bman.players_nr_s++;
bman.players_nr++;
bman.players[p].tunnelto = 0;
bman.players[p].state = PSF_used + PSF_alife + PSF_playing;
}
else
@ -62,7 +63,7 @@ ai_checkfield (int x, int y)
{
return ((map.field[x][y].type == FT_nothing || map.field[x][y].type == FT_fire
|| map.field[x][y].type == FT_shoe || map.field[x][y].type == FT_bomb
|| map.field[x][y].type == FT_mixed)
|| map.field[x][y].type == FT_mixed || map.field[x][y].type == FT_tunnel)
&& map.bfield[x][y] == 0);
}
@ -287,12 +288,12 @@ ai_bombpoints (_point pos, int range)
p = pos;
for (r = 0; (r < range && map.field[p.x][p.y].type == FT_nothing); r++) {
for (r = 0; (r < range && (map.field[p.x][p.y].type == FT_nothing || map.field[p.x][p.y].type == FT_tunnel)); r++) {
p.x += m.x;
p.y += m.y;
}
if (map.field[p.x][p.y].type != FT_nothing
if (map.field[p.x][p.y].type != FT_nothing && map.field[p.x][p.y].type != FT_tunnel
&& (map.field[p.x][p.y].type != FT_block || map.field[p.x][p.y].type == FT_shoe
|| map.field[p.x][p.y].type == FT_bomb || map.field[p.x][p.y].type == FT_fire))
points++;
@ -691,6 +692,9 @@ single_loop ()
pl->m = 1;
}
}
if (pl->m == 0 && map.field[pl->pos.x >> 8][pl->pos.y >> 8].type == FT_tunnel)
pl->m = 1;
}
player_ilness_loop (p);
move_player (p);

Loading…
Cancel
Save