diff --git a/bigstuff.cpp b/bigstuff.cpp index ed947676..415cbeec 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -1516,4 +1516,15 @@ void moreBigStuff(cell *c) { } } +void generate_mines() { + vector candidates; + for(cell *c: currentmap->allcells()) + if(c->wall == waMineUnknown) + candidates.push_back(c); + bounded_mine_max = isize(candidates); + hrandom_shuffle(&candidates[0], bounded_mine_max); + bounded_mine_quantity = int(bounded_mine_max * bounded_mine_percentage + 0.5); + for(int i=0; iwall = waMineMine; + } + } diff --git a/config.cpp b/config.cpp index 0cedf55c..f4a14bff 100644 --- a/config.cpp +++ b/config.cpp @@ -4,6 +4,9 @@ namespace hr { +ld bounded_mine_percentage = 0.1; +int bounded_mine_quantity, bounded_mine_max; + const char *conffile = "hyperrogue.ini"; array sightranges; @@ -409,6 +412,8 @@ void initConfig() { addsaver(racing::standard_centering, "race_standard_centering"); #endif + addsaver(bounded_mine_percentage, "bounded_mine_percentage"); + #if CAP_SHMUP shmup::initConfig(); #endif diff --git a/game.cpp b/game.cpp index b22c9bfd..6c30e4d9 100644 --- a/game.cpp +++ b/game.cpp @@ -3515,6 +3515,7 @@ void gainShard(cell *c2, const char *msg) { void uncoverMinesFull(cell *c2) { int mineradius = + bounded ? 3 : (items[itBombEgg] < 1 && !tactic::on) ? 0 : items[itBombEgg] < 20 ? 1 : items[itBombEgg] < 30 ? 2 : diff --git a/geom-exp.cpp b/geom-exp.cpp index df5d86a7..f3313404 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -676,6 +676,24 @@ void showEuclideanMenu() { dialog::addSelItem(XLAT("land"), XLAT1(linf[specialland].name), 'l'); dialog::add_action_push(ge_land_selection); + + if(specialland == laMinefield && bounded) { + dialog::addSelItem(XLAT("number of mines"), its(bounded_mine_quantity), 'm'); + dialog::add_action([] { + dialog::editNumber(bounded_mine_quantity, 0, bounded_mine_max, (bounded_mine_max+5)/10, 1, + XLAT("number of mines"), ""); + dialog::reaction = [] { + if(bounded_mine_quantity < 0) bounded_mine_quantity = 0; + if(bounded_mine_quantity > bounded_mine_max) bounded_mine_quantity = bounded_mine_max; + }; + dialog::reaction_final = [] { + bounded_mine_percentage = bounded_mine_quantity * 1. / bounded_mine_max; + stop_game(); + start_game(); + }; + }); + } + dialog::addBoolItem(XLAT("pattern"), specialland == laCanvas, 'p'); if(specialland == laCanvas) dialog::lastItem().value = patterns::whichCanvas; dialog::add_action_push(patterns::showPrePattern); diff --git a/hyper.h b/hyper.h index 0f301718..ef87acef 100644 --- a/hyper.h +++ b/hyper.h @@ -1663,6 +1663,10 @@ extern bool timerstopped; bool againstRose(cell *cfrom, cell *cto); bool withRose(cell *cfrom, cell *cto); +extern ld bounded_mine_percentage; +extern int bounded_mine_quantity, bounded_mine_max; +void generate_mines(); + // loops #define fakecellloop(ct) for(cell *ct = (cell*)1; ct; ct=NULL) diff --git a/landgen.cpp b/landgen.cpp index 05db6518..7d62fa51 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -1954,7 +1954,8 @@ void giantLandSwitch(cell *c, int d, cell *from) { break; case laMinefield: - if(d == 7) { + if(d == 7 && bounded) c->wall = waMineUnknown; + else if(d == 7) { c->wall = waMineUnknown; // 250: rare mines // 1250: at 25 @@ -1985,7 +1986,7 @@ void giantLandSwitch(cell *c, int d, cell *from) { c->monst = moBomberbird; else placeLocalSpecial(c, 500); } - if(d == 3 && safety && (c->wall == waMineMine || c->wall == waMineUnknown)) + if(d == 3 && safety && (c->wall == waMineMine || c->wall == waMineUnknown) && !bounded) c->wall = waMineOpen; break; diff --git a/monstergen.cpp b/monstergen.cpp index 77485a9c..665dc203 100644 --- a/monstergen.cpp +++ b/monstergen.cpp @@ -304,6 +304,13 @@ eItem wanderingTreasure(cell *c) { } void wandering() { + if(bounded && specialland == laMinefield) { + kills[moBomberbird] = 0; + kills[moTameBomberbird] = 0; + for(cell *c: currentmap->allcells()) if(c->wall == waMineUnknown) kills[moBomberbird]++; + for(cell *c: currentmap->allcells()) if(among(c->wall, waMineMine, waMineUnknown) && mineMarked(c)) kills[moTameBomberbird]++; + return; + } if(!canmove) return; if(!gen_wandering) return; if(racing::on) return; diff --git a/system.cpp b/system.cpp index aa32da59..729fb676 100644 --- a/system.cpp +++ b/system.cpp @@ -270,6 +270,9 @@ void initgame() { makeEmpty(cwt.at); } + if(specialland == laMinefield && bounded) + generate_mines(); + princess::squeaked = false; clearing::current_root = NULL;