From 7c39c7ea3cd445192e00a4e57584fa16190fa0de Mon Sep 17 00:00:00 2001 From: patty21 Date: Sun, 18 May 2003 14:06:29 +0000 Subject: [PATCH] 2 new specials finished and some bugs fixed --- src/basic.h | 6 +- src/bomb.c | 2 +- src/bomberclone.h | 3 +- src/configuration.c | 5 +- src/field.c | 10 ++- src/packets.c | 6 +- src/player.c | 42 +++++++------ src/special.c | 148 ++++++++++++++++++++++++++++++++++++-------- 8 files changed, 169 insertions(+), 53 deletions(-) diff --git a/src/basic.h b/src/basic.h index c9f01e0..c40a352 100644 --- a/src/basic.h +++ b/src/basic.h @@ -9,9 +9,9 @@ #define GAME_SPECIAL_ITEMSHOE 10 #define GAME_SPECIAL_ITEMDEATH 25 #define GAME_SPECIAL_ITEMMIXED 10 -#define GAME_SPECIAL_ITEMSTRIGGER 10 -#define GAME_SPECIAL_ITEMSROW 0 -#define GAME_SPECIAL_ITEMSPUSH 0 +#define GAME_SPECIAL_ITEMSTRIGGER 2 +#define GAME_SPECIAL_ITEMSROW 2 +#define GAME_SPECIAL_ITEMSPUSH 2 #define GAME_SPECIAL_ITEMSKICK 0 #define EXPLOSION_SAVE_DISTANCE 64 diff --git a/src/bomb.c b/src/bomb.c index 6fdd175..6393e58 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -289,7 +289,7 @@ explosion_check_field (int x, int y, int p, int b) bman.field[x][y].frame = 1; } draw_stone (x, y); - gfx_AddUpdateRect (x * gfx.block.x + gfx.offset.x,y * gfx.block.y + gfx.offset.y, gfx.block.x, gfx.block.y); + field_update(x,y); } return bman.field[x][y].type; diff --git a/src/bomberclone.h b/src/bomberclone.h index 726e3d6..b06856f 100644 --- a/src/bomberclone.h +++ b/src/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.23 2003/05/15 00:27:00 patty21 Exp $ */ +/* $Id: bomberclone.h,v 1.24 2003/05/18 14:06:29 patty21 Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -175,6 +175,7 @@ extern void game_set_playerposition(); extern void draw_field (); extern void draw_stone (int x, int y); extern void field_clear(int x, int y); +extern void field_update(int x,int y); extern void field_new (char *filename); extern void field_set_playerposition (int usermap); extern void tileset_random (); diff --git a/src/configuration.c b/src/configuration.c index 5291678..2af37fa 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -135,6 +135,9 @@ ReadConfig () if (!strcmp (keyword, "resolutiony")) { gfx.res.y = atoi (value); } + if (!strcmp (keyword, "tileset")) { + strcpy (gfx.tileset, value); + } if (!strcmp (keyword, "fieldpath")) { if (strlen (value) > 510) { d_printf @@ -207,6 +210,7 @@ WriteConfig () fprintf (config, "resolutionx=%d\n", gfx.res.x); fprintf (config, "resolutiony=%d\n", gfx.res.y); fprintf (config, "fullscreen=%d\n", gfx.fullscreen); + fprintf (config, "tileset=%s\n", gfx.tileset); fprintf (config, "fieldpath=%s\n", bman.fieldpath); fprintf (config, "fieldsizex=%d\n", bman.fieldsize.x); fprintf (config, "fieldsizey=%d\n", bman.fieldsize.y); @@ -221,7 +225,6 @@ WriteConfig () fprintf (config, "askplayername=%d\n", bman.askplayername); fprintf (config, "playername=%s\n", bman.playername); fprintf (config, "bitsperpixel=%d\n", gfx.bpp); - fprintf (config, "fieldpath=%s\n", bman.fieldpath); fprintf (config, "randomtileset=%d\n", gfx.random_tileset); fprintf (config, "randommap=%d\n", bman.random_map); fclose (config); diff --git a/src/field.c b/src/field.c index 4583452..e7bb795 100644 --- a/src/field.c +++ b/src/field.c @@ -1,4 +1,4 @@ -/* $Id: field.c,v 1.20 2003/05/14 04:59:17 stpohle Exp $ */ +/* $Id: field.c,v 1.21 2003/05/18 14:06:29 patty21 Exp $ */ /* field.c - procedures which are needed to control the field */ #include @@ -274,6 +274,14 @@ field_clear(int x, int y) net_game_send_field (x, y); } +void +field_update(int x, int y) +{ +gfx_AddUpdateRect (x * gfx.block.x + gfx.offset.x, y * gfx.block.y + gfx.offset.y, + gfx.block.x, gfx.block.y); + +} + // put items into the field void field_fillitems (int fieldtype, int num) diff --git a/src/packets.c b/src/packets.c index 2bf57e5..1c52a11 100644 --- a/src/packets.c +++ b/src/packets.c @@ -591,7 +591,11 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) if ((bomb->pos.x != b_dat->x || bomb->pos.y != b_dat->y) && bomb->state == BS_exploding && b_dat->state != BS_exploding) d_printf ("do_bombdata WARNING : bomb explosion haven't finished\n"); - + if (bomb->state==BS_ticking && b_dat->state==BS_ticking) { // handle push & kick special + bman.bfield[bomb->pos.x][bomb->pos.y] = 0; //remove bomb at old location + draw_stone(bomb->pos.x,bomb->pos.y); + field_update(bomb->pos.x,bomb->pos.y); + } bomb->pos.x = b_dat->x; bomb->pos.y = b_dat->y; if (bomb->state != BS_ticking) diff --git a/src/player.c b/src/player.c index c187ccf..3de8c7d 100644 --- a/src/player.c +++ b/src/player.c @@ -143,7 +143,7 @@ player_check_powerup (_player * p) p->bombs_n++; bman.updatestatusbar = 1; } - field_clear(fx,fy); + field_clear (fx, fy); break; /* we found a fire powerup */ @@ -152,7 +152,7 @@ player_check_powerup (_player * p) p->range++; bman.updatestatusbar = 1; } - field_clear(fx,fy); + field_clear (fx, fy); break; /* we found a shoe powerup */ @@ -161,7 +161,7 @@ player_check_powerup (_player * p) p->speed *= SPEEDMUL; bman.updatestatusbar = 1; } - field_clear(fx,fy); + field_clear (fx, fy); break; /* we found a death ?powerup? */ @@ -170,18 +170,20 @@ player_check_powerup (_player * p) bman.updatestatusbar = 1; if (bman.gametype != GT_single) net_game_send_ill (bman.p_nr); - field_clear(fx,fy); + field_clear (fx, fy); break; - + /* we found a special */ - case FT_sp_trigger: + case FT_sp_trigger: case FT_sp_row: - case FT_sp_push: - case FT_sp_kick: - p->special=ft-FT_sp_trigger+1; - field_clear(fx,fy); - bman.updatestatusbar=1; - break; + case FT_sp_push: + case FT_sp_kick: + if (p->special == SP_nothing) { + p->special = ft - FT_sp_trigger + 1; + bman.updatestatusbar = 1; + } + field_clear (fx, fy); + break; } }; @@ -356,13 +358,14 @@ player_drop_bomb (int pl_nr) d_printf ("Player %d Dropped Bomb %d\n", bman.p_nr, i); bomb->r = player->range; - if (player->special== SP_trigger) - bomb->state = BS_trigger; - else bomb->state = BS_ticking; + if (player->special == SP_trigger) + bomb->state = BS_trigger; + else + bomb->state = BS_ticking; bomb->ex_nr = -1; bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200 - bman.bfield [bomb->pos.x][bomb->pos.y] = 1; + bman.bfield[bomb->pos.x][bomb->pos.y] = 1; if (bman.gametype != GT_single) { net_game_send_bomb (pl_nr, i); if (GT_MP_PTPS) @@ -385,7 +388,8 @@ get_player_on (short int x, short int y, int pl_nr[]) if (PS_IS_alife (bman.players[p].state)) { 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 && bman.players[p].pos.y + EXPLOSION_SAVE_DISTANCE < y + 256) { + && bman.players[p].pos.y - EXPLOSION_SAVE_DISTANCE > y - 256 + && bman.players[p].pos.y + EXPLOSION_SAVE_DISTANCE < y + 256) { pl_nr[i] = p; i++; } @@ -400,8 +404,8 @@ player_died (_player * player, signed char dead_by) // player die ! d_printf ("player_died (%10s)\n", player->name); - bman.updatestatusbar = 1; // force an update - + bman.updatestatusbar = 1; // force an update + if (PS_IS_alife (player->state) && dead_by >= 0 && dead_by < MAX_PLAYERS) if (bman.p_nr != dead_by) bman.players[dead_by].points++; diff --git a/src/special.c b/src/special.c index bf353f9..7bcc5cc 100644 --- a/src/special.c +++ b/src/special.c @@ -8,52 +8,148 @@ void special_trigger (int p_nr) { int i, - z=0, - ex_nr = bman.last_ex_nr; - + z = 0, + ex_nr = bman.last_ex_nr; + _player *p = &bman.players[p_nr]; - - // all ticking bombs will explode + + // all triggered bombs will explode for (i = 0; i < MAX_BOMBS; i++) if (p->bombs[i].state == BS_trigger) { - p->bombs[i].ex_nr = ex_nr + 5; // we take the next 5 number to be shure - bomb_explode (p_nr, i,0); // no other explosion interfear with it. - z++; - } - - if (p_nr == bman.p_nr && GT_MP_PTP && z) - net_game_send_special (p_nr, ex_nr); - - if (z) - bman.last_ex_nr = ex_nr + 6; + p->bombs[i].ex_nr = ex_nr + 5; // we take the next 5 number to be shure + bomb_explode (p_nr, i, 0); // no other explosion interfear with it. + z++; // count the bombs which will explode + } + + if (p_nr == bman.p_nr && GT_MP_PTP && z) + net_game_send_special (p_nr, ex_nr); + + if (z) + bman.last_ex_nr = ex_nr + 6; } + void special_row (int p_nr) { + _bomb *b = NULL; _player *p = &bman.players[p_nr]; + int x = p->pos.x >> 8, + y = p->pos.y >> 8, + dx = 0, + dy = 0, + t = 0, + i; + switch (p->d) { + case left: + dx = -1; + break; + case right: + dx = 1; + break; + case up: + dy = -1; + break; + case down: + dy = +1; + break; + } + x += dx; + y += dy; + while (bman.bfield[x][y]) { + x += dx; + y += dy; + /* add one time tick to each bomb found to ensure that the explosion is infacted by the previous bomb + otherwise powerups will disappear due to explosion of previous bomb */ + t++; + } + if (bman.field[x][y].type == FT_nothing) { + for (i = 0; ((i < p->bombs_n) && (p->bombs[i].state != BS_off)); i++); + if (i < p->bombs_n) { + b = &p->bombs[i]; + b->state = BS_ticking; + b->r = p->range; + b->ex_nr = -1; + b->pos.x = x; + b->pos.y = y; + b->to = BOMB_TIMEOUT * TIME_FACTOR + t; // 5 Secs * 200 + bman.bfield[x][y] = 1; + if (bman.gametype != GT_single) { + net_game_send_bomb (p_nr, i); + if (GT_MP_PTPS) + b->to = b->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR); + } + } + } +} +void +special_push (int p_nr) +{ + _bomb *b = NULL; + _player *p = &bman.players[p_nr]; + _point bombs[MAX_PLAYERS * MAX_BOMBS]; + int x = p->pos.x >> 8, + y = p->pos.y >> 8, + dx = 0, + dy = 0, + x1, + y1, + i; + switch (p->d) { + case left: + dx = -1; + break; + case right: + dx = 1; + break; + case up: + dy = -1; + break; + case down: + dy = +1; + break; + } + x += dx; + y += dy; + if (!bman.bfield[x][y]) + return; + x1 = x + dx; + y1 = y + dy; + if (bman.bfield[x1][y1] || bman.field[x1][y1].type != FT_nothing) + return; + get_bomb_on (x, y, bombs); + for (i = 0; bombs[i].x != -1; i++) { + b = &bman.players[bombs[i].x].bombs[bombs[i].y]; + if (b->state != BS_exploding) { + b->pos.x = x1; + b->pos.y = y1; + bman.bfield[x][y]=0; + bman.bfield[x1][y1]=1; + draw_stone(x,y); + field_update(x,y); + if (bman.gametype != GT_single) { + net_game_send_bomb (bombs[i].x, bombs[i].y);} + } + } - ; } + void -special_use (int p_nr) -{ - + special_use (int p_nr) { + switch (bman.players[p_nr].special) { case SP_trigger: special_trigger (p_nr); break; - case SP_row: - if (bman.players[p_nr].m) + case SP_row:if (bman.players[p_nr].m) special_row (p_nr); break; - case SP_push: + case SP_push:if (bman.players[p_nr].m) + special_push (p_nr); break; - case SP_kick: - break; - } -} + case SP_kick:break; +}}