From 977bd8ca9dc7f9980f8101f5cfcff789838c3a12 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 6 Apr 2024 18:33:29 +0200 Subject: [PATCH] ls:: cursed walls --- barriers.cpp | 134 ++++++++++++++++++++++++++++++++++++--------------- config.cpp | 5 ++ landgen.cpp | 8 ++- landlock.cpp | 13 +++-- menus.cpp | 2 + 5 files changed, 118 insertions(+), 44 deletions(-) diff --git a/barriers.cpp b/barriers.cpp index 4a10dea4..e8082cf0 100644 --- a/barriers.cpp +++ b/barriers.cpp @@ -616,6 +616,12 @@ EX void extendBarrier(cell *c) { if(buildBarrier6(cw, 2)) return; } + if(land_structure == lsCursedWalls && c->barleft != laMirror && c->barright != laMirror && hrand(100) < 80) { + cellwalker cw(c, c->bardir); + cw = cw + wstep + 3 + wstep - 1; + if(buildBarrier6(cw, c->barright, c->barleft)) return; + } + if(barrier_cross(c->barleft, c->barright) || (firstmirror && hrand(100) < 60)) { cellwalker cw(c, c->bardir); @@ -681,6 +687,7 @@ EX void buildBarrier(cell *c, int d, eLand l IS(laNone)) { buildBarrierForce(c, d, l); } +/** mirror variant of 6-fold walls */ EX bool buildBarrier6(cellwalker cw, int type) { limitgen("build6 %p/%d (%d)\n", hr::voidp(cw.at), cw.spin, type); @@ -725,21 +732,28 @@ EX bool buildBarrier6(cellwalker cw, int type) { if(!(PURE?checkBarriersFront:checkBarriersBack)(b[0], 6, true)) return false; if(!(PURE?checkBarriersFront:checkBarriersBack)(b[3], 6, true)) return false; } - + + eLand m0 = laMirror; + eLand m1 = laMirrored; + eLand m2 = laMirrored2; + eLand mw1 = laMirrorWall; + eLand mw2 = laMirrorWall2; + eWall w = waMirrorWall; + for(int d=0; d<4; d++) { b[d].at->bardir = b[d].spin; if(PURE) { - b[0].at->barleft = laMirrored, b[0].at->barright = laMirrored2; - b[1].at->barleft = laMirror, b[1].at->barright = laMirrored; - b[2].at->barleft = laMirrored2, b[2].at->barright = laMirrored; - b[3].at->barleft = laMirrored, b[3].at->barright = laMirror; + b[0].at->barleft = m1, b[0].at->barright = m2; + b[1].at->barleft = m0, b[1].at->barright = m1; + b[2].at->barleft = m2, b[2].at->barright = m1; + b[3].at->barleft = m1, b[3].at->barright = m0; } else { - b[0].at->barleft = laMirror, b[0].at->barright = laMirrored; - b[1].at->barleft = laMirrored, b[1].at->barright = laMirror; - b[2].at->barleft = laMirrored, b[2].at->barright = laMirrored2; - b[3].at->barleft = laMirrored2, b[3].at->barright = laMirrored; + b[0].at->barleft = m0, b[0].at->barright = m1; + b[1].at->barleft = m1, b[1].at->barright = m0; + b[2].at->barleft = m1, b[2].at->barright = m2; + b[3].at->barleft = m2, b[3].at->barright = m1; } (PURE?extendBarrierFront:extendBarrierBack)(b[d].at); @@ -753,45 +767,87 @@ EX bool buildBarrier6(cellwalker cw, int type) { } if(BITRUNCATED) { - setland((cw+1).cpeek(), laMirrorWall); - setland((cw+2).cpeek(), laMirrored); - setland((cw+3).cpeek(), laMirrorWall2); - setland((cw+4).cpeek(), laMirrorWall2); - setland((cw+5).cpeek(), laMirrored); - setland((cw+0).cpeek(), laMirrorWall); - setland((b[0]+2).cpeek(), laMirrored); - setland((b[3]+6).cpeek(), laMirrored2); - setland((b[3]+5).cpeek(), laMirrored2); - setland((b[1]-1).cpeek(), laMirrored); - setland((b[2]-2).cpeek(), laMirrored); - setland((b[1]-2).cpeek(), laMirrored); - setland((b[0]-2).cpeek(), laMirror); - cw.at->land = laMirrorWall; - cw.at->wall = waMirrorWall; + setland((cw+1).cpeek(), mw1); + setland((cw+2).cpeek(), m1); + setland((cw+3).cpeek(), mw2); + setland((cw+4).cpeek(), mw2); + setland((cw+5).cpeek(), m1); + setland((cw+0).cpeek(), mw1); + setland((b[0]+2).cpeek(), m1); + setland((b[3]+6).cpeek(), m2); + setland((b[3]+5).cpeek(), m2); + setland((b[1]-1).cpeek(), m1); + setland((b[2]-2).cpeek(), m1); + setland((b[1]-2).cpeek(), m1); + setland((b[0]-2).cpeek(), m0); + cw.at->land = mw1; + cw.at->wall = w; cw.at->landparam = 1; } else { - setland(cw.at, laMirrorWall2); - setland((cw+0).cpeek(), laMirrorWall2); - setland((cw+1).cpeek(), laMirrored); - setland((cw+2).cpeek(), laMirrored); - setland((cw+3).cpeek(), laMirrorWall); - setland((cw+4).cpeek(), laMirrored); - setland((cw+5).cpeek(), laMirrorWall2); - setland((cw+6).cpeek(), laMirrored2); + setland(cw.at, mw2); + setland((cw+0).cpeek(), mw2); + setland((cw+1).cpeek(), m1); + setland((cw+2).cpeek(), m1); + setland((cw+3).cpeek(), mw1); + setland((cw+4).cpeek(), m1); + setland((cw+5).cpeek(), mw2); + setland((cw+6).cpeek(), m2); - setland((b[1]).cpeek(), laMirrorWall); - setland((b[1]+1).cpeek(), laMirror); - setland((b[1]+2).cpeek(), laMirrorWall); - setland((b[1]+6).cpeek(), laMirrored); + setland((b[1]).cpeek(), mw1); + setland((b[1]+1).cpeek(), m0); + setland((b[1]+2).cpeek(), mw1); + setland((b[1]+6).cpeek(), m1); - setland((b[0] + wstep - 2).cpeek(), laMirrored); - setland((b[3] + wstep - 2).cpeek(), laMirrored); + setland((b[0] + wstep - 2).cpeek(), m1); + setland((b[3] + wstep - 2).cpeek(), m1); } return true; } - + +EX int curse_percentage = 10; + +/** cursed variant of 6-fold walls */ +EX bool buildBarrier6(cellwalker cw, eLand m0, eLand m1) { + cellwalker b[6]; + if(buggyGeneration) return true; + + for(int i=0; i<6; i+=2) + b[i] = cw + i + wstep; + for(int i=1; i<6; i+=2) + b[i] = cw + i + wstep + 3 + wstep; + + for(int i=0; i<6; i++) if(i != 1) { + if(!(PURE?checkBarriersFront:checkBarriersBack)(b[i], 6, true)) return false; + } + + for(int d=0; d<6; d++) { + b[d].at->bardir = b[d].spin; + b[d].at->barleft = (d&1) ? m1 : m0; + b[d].at->barright = (d&1) ? m0 : m1; + (PURE?extendBarrierFront:extendBarrierBack)(b[d].at); + } + + cw.at->land = laBarrier; + cw.at->wall = waBarrier; + forCellCM(c, cw.at) { c->land = laBarrier; c->wall = waBarrier; } + for(int d=0; d<6; d+=2) { + setland((b[d]-2).cpeek(), m0); + setland((b[d]+2).cpeek(), m1); + setland((b[d+1]-2).cpeek(), m1); + setland((b[d+1]+2).cpeek(), m0); + } + if(hrand(100) < curse_percentage) { + setland(cw.at, laCursed); + cw.at->wall = waRubble; + cw.at->monst = moHexer; + cw.at->item = random_curse(); + } + + return true; + } + EX bool buildBarrier4(cell *c, int d, int mode, eLand ll, eLand lr) { limitgen("build4 %p\n", hr::voidp(c)); if(buggyGeneration) return true; diff --git a/config.cpp b/config.cpp index 9efd4312..0eb624e6 100644 --- a/config.cpp +++ b/config.cpp @@ -3339,6 +3339,11 @@ EX int config3 = addHook(hooks_configfile, 100, [] { "Then, we find a cell of the bitruncated cubic honeycomb at these cordinates, and this cell determines which land it is. The bigger the value, the larger the lands.", 'R') ->set_reaction([] { if(game_active) { stop_game(); start_game(); } }); + param_i(curse_percentage, "curse_percentage")->editable(0, 100, 1, + "curse percentage", + "The percentage of towers in Cursed Walls mode to be manned by Canyon Hags", 'R') + ->set_reaction([] { if(game_active) { stop_game(); start_game(); } }); + param_f(global_boundary_ratio, "global_boundary_ratio") ->editable(0, 5, 0.1, "Width of cell boundaries", "How wide should the cell boundaries be.", '0'); diff --git a/landgen.cpp b/landgen.cpp index 9cb62eaf..fd2c2dca 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -292,6 +292,10 @@ EX int rebalance_treasure(int x, int y, eLand l) { return res; } +EX eItem random_curse() { + return pick(itCurseWeakness, itCurseDraining, itCurseWater, itCurseFatigue, itCurseRepulsion, itCurseGluttony); + } + EX void giantLandSwitch(cell *c, int d, cell *from) { bool fargen = d == 9; switch(c->land) { @@ -2653,7 +2657,7 @@ EX void giantLandSwitch(cell *c, int d, cell *from) { } case laCursed: { - if(fargen) { + if(fargen && c->wall != waRubble) { c->wall = waStone; for(int i=0; i<3; i++) { auto ew = [i] (cell *c1) { @@ -2689,7 +2693,7 @@ EX void giantLandSwitch(cell *c, int d, cell *from) { c->wall = waStone; else { c->monst = moHexer; - c->item = pick(itCurseWeakness, itCurseDraining, itCurseWater, itCurseFatigue, itCurseRepulsion, itCurseGluttony); + c->item = random_curse(); } break; } diff --git a/landlock.cpp b/landlock.cpp index 828897cb..9750fb0a 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -81,7 +81,7 @@ EX eLand firstland = laIce; EX eLand specialland = laIce; #if HDR -enum eLandStructure { lsNiceWalls, lsChaos, lsPatchedChaos, lsTotalChaos, lsChaosRW, lsWallChaos, lsSingle, lsNoWalls, lsHorodisks, lsVoronoi, lsLandscape, lsCrossWalls, lsVineWalls, lsGUARD }; +enum eLandStructure { lsNiceWalls, lsChaos, lsPatchedChaos, lsTotalChaos, lsChaosRW, lsWallChaos, lsSingle, lsNoWalls, lsHorodisks, lsVoronoi, lsLandscape, lsCrossWalls, lsVineWalls, lsCursedWalls, lsGUARD }; #endif EX eLandStructure land_structure; @@ -90,9 +90,9 @@ EX namespace ls { EX bool single() { return land_structure == lsSingle; } -EX bool any_chaos() { return among(land_structure, lsChaos, lsPatchedChaos, lsWallChaos, lsTotalChaos, lsChaosRW, lsCrossWalls, lsVineWalls, lsLandscape); } +EX bool any_chaos() { return among(land_structure, lsChaos, lsPatchedChaos, lsWallChaos, lsTotalChaos, lsChaosRW, lsCrossWalls, lsVineWalls, lsCursedWalls, lsLandscape); } EX bool std_chaos() { return land_structure == lsChaos; } -EX bool wall_chaos() { return among(land_structure, lsWallChaos, lsCrossWalls, lsVineWalls); } +EX bool wall_chaos() { return among(land_structure, lsWallChaos, lsCrossWalls, lsVineWalls, lsCursedWalls); } EX bool patched_chaos() { return land_structure == lsPatchedChaos; } EX bool any_order() { return among(land_structure, lsNiceWalls, lsNoWalls, lsHorodisks, lsVoronoi); } @@ -113,6 +113,7 @@ EX int chaoticity() { if(land_structure == lsLandscape) return 35; if(land_structure == lsWallChaos) return 30; if(land_structure == lsCrossWalls) return 32; + if(land_structure == lsCursedWalls) return 34; if(land_structure == lsVoronoi) return 20; if(land_structure == lsSingle) return 0; return 10; @@ -123,6 +124,7 @@ EX int ls_mul() { if(land_structure == lsWallChaos) return 2; if(land_structure == lsCrossWalls) return 3; if(land_structure == lsVineWalls) return 3; + if(land_structure == lsCursedWalls) return 3; return 1; } @@ -131,6 +133,7 @@ EX int ls_mul_big() { if(land_structure == lsWallChaos) return 5; if(land_structure == lsCrossWalls) return 10; if(land_structure == lsVineWalls) return 10; + if(land_structure == lsCursedWalls) return 10; return 1; } @@ -165,6 +168,8 @@ EX string land_structure_name(bool which) { return XLAT("excessive crossing walls"); case lsVineWalls: return XLAT("regular walls"); + case lsCursedWalls: + return XLAT("cursed walls"); default: return "error structure"; } @@ -189,6 +194,8 @@ EX void fix_land_structure_choice() { land_structure = lsChaos; if(land_structure == lsVineWalls && (geometry != gNormal || !BITRUNCATED)) land_structure = lsNiceWalls; + if(land_structure == lsCursedWalls && (geometry != gNormal || !BITRUNCATED)) + land_structure = lsNiceWalls; if(ls::hv_structure() && (!hyperbolic || bt::in() || quotient)) land_structure = lsSingle; if(walls_not_implemented() && among(land_structure, lsChaos, lsNoWalls)) diff --git a/menus.cpp b/menus.cpp index 85c92be5..1fb67483 100644 --- a/menus.cpp +++ b/menus.cpp @@ -466,6 +466,8 @@ EX void show_chaos() { add_edit(randomwalk_size); else if(land_structure == lsLandscape) add_edit(landscape_div); + else if(land_structure == lsCursedWalls) + add_edit(curse_percentage); else dialog::addBreak(100); dialog::addBack();