diff --git a/src/bomberclone.h b/src/bomberclone.h index 0a3b1c6..491fc43 100644 --- a/src/bomberclone.h +++ b/src/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.31 2003/05/30 19:57:20 patty21 Exp $ */ +/* $Id: bomberclone.h,v 1.32 2003/06/01 20:34:47 stpohle Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -161,6 +161,8 @@ struct __bomberclone { unsigned char firewall; unsigned char notifygamemaster; unsigned char askplayername; // ask player for name at startup + + unsigned char ai_players; // number of ai players signed char debug; // 0 = off 1 = on } typedef _bomberclone; @@ -256,6 +258,7 @@ extern void single_game_new (); extern void single_create_ai (int players); extern void single_loop(); extern void single_playergame (); +extern void single_menu (); extern int ai_choosedir (int dir, int nearbomb, int oldpos); extern int ai_invertdir (int dir); extern int ai_checkpos (_player * pl, _point * pos); diff --git a/src/configuration.c b/src/configuration.c index e5bab16..14d2d33 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -53,6 +53,7 @@ game_init (int argc, char **argv) bman.fieldpath[0] = 0; bman.random_map = 2; bman.firewall = 0; + bman.ai_players = 1; snd.inited = 0; init_map_tileset(); @@ -168,6 +169,9 @@ ReadConfig () if (!strcmp (keyword, "firewall")) { bman.firewall = atoi (value); } + if (!strcmp (keyword, "ai_players")) { + bman.ai_players = atoi (value); + } if (!strcmp (keyword, "fieldsizex")) { bman.fieldsize.x = atoi (value); } @@ -234,6 +238,7 @@ WriteConfig () fprintf (config, "tileset=%s\n", gfx.tileset); fprintf (config, "fieldpath=%s\n", bman.fieldpath); fprintf (config, "firewall=%d\n", bman.firewall); + fprintf (config, "ai_players=%d\n", bman.ai_players); fprintf (config, "fieldsizex=%d\n", bman.fieldsize.x); fprintf (config, "fieldsizey=%d\n", bman.fieldsize.y); fprintf (config, "notify=%d\n", bman.notifygamemaster); diff --git a/src/game.c b/src/game.c index 1d7657c..1574329 100644 --- a/src/game.c +++ b/src/game.c @@ -218,7 +218,7 @@ game_loop () /* check if there is only one player left and the game is in multiplayer mode and if there the last dieing animation is done */ - if (bman.players_nr < 2) + if ((bman.players_nr < 2 && (GT_MP_PTP || (bman.gametype == GT_single && bman.ai_players > 0))) || (bman.gametype == GT_single && bman.ai_players == 0 && bman.players_nr < 1)) gameovertimeout--; if (gameovertimeout <= 0) { diff --git a/src/main.c b/src/main.c index f0a62d6..f8ae9f1 100644 --- a/src/main.c +++ b/src/main.c @@ -40,7 +40,7 @@ main (int argc, char **argv) switch (menuselect) { case (0) : // Singleplayer - single_playergame (); + single_menu (); break; case (1) : // Multiplayer netmenu(); diff --git a/src/single.c b/src/single.c index f3bf092..b44f2c5 100644 --- a/src/single.c +++ b/src/single.c @@ -1,4 +1,4 @@ -/* $Id: single.c,v 1.29 2003/06/01 20:18:27 stpohle Exp $ */ +/* $Id: single.c,v 1.30 2003/06/01 20:34:47 stpohle Exp $ */ /* single player */ #include "basic.h" @@ -626,7 +626,7 @@ single_playergame () for (p = 0; p < MAX_PLAYERS; p++) bman.players[p].state = 0; - single_create_ai (1); + single_create_ai (bman.ai_players); single_game_new (); gfx_game_init (); game_loop (); @@ -693,3 +693,41 @@ single_loop () move_player (p); } }; + + +/* singleplayer menü with some options you can make */ +void single_menu () { + int menuselect = 0; + _menu menu[] = { + {1, "Start Game"}, + {2, "Number Of Players"}, + {3, "Map Option"}, + {4, "Return To Main Menu"}, + {-1, ""} + }; + + while (menuselect != -1 && bman.state != GS_quit) { + sprintf (menu[1].text, "%d AI Player", bman.ai_players); + menuselect = menu_loop ("Single Player", menu, menuselect); + switch (menuselect) { + case (0): // Start Game + single_playergame (); + break; + case (1): // Change number of Player + bman.ai_players++; + if (bman.ai_players >= MAX_PLAYERS) { + if (debug) + bman.ai_players = 0; // null players with debugging on + else + bman.ai_players = 1; + } + break; + case (2): // Map Options + mapmenu(); + break; + case (3): + menuselect = -1; + break; + } + } +}; \ No newline at end of file