From 2b1aebb9b47604b48f476149f292be3c99bfa654 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 27 May 2019 07:17:39 +0200 Subject: [PATCH] chaosmode variants (CLI only for now) --- bigstuff.cpp | 11 +++++++++++ complex.cpp | 1 + debug.cpp | 18 ++++++++++++++++++ game.cpp | 1 + hyper.h | 4 +++- landgen.cpp | 34 +++++++++++++++++++++++++++++++++- landlock.cpp | 2 +- system.cpp | 5 +++-- yendor.cpp | 4 ++-- 9 files changed, 73 insertions(+), 7 deletions(-) diff --git a/bigstuff.cpp b/bigstuff.cpp index 93ff7e24..fa01b882 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -1207,6 +1207,7 @@ bool good_for_wall(cell *c) { void buildBigStuff(cell *c, cell *from) { if(sphere || quotient) return; + if(chaosmode > 1) return; bool deepOcean = deep_ocean_at(c, from); // if(weirdhyperbolic && c->land == laOcean) deepOcean = c->landparam >= 30; @@ -1606,4 +1607,14 @@ void generate_mines() { for(int i=0; iwall = waMineMine; } +vector currentlands; + +void pregen() { + currentlands.clear(); + if(chaosmode > 1) + for(eLand l: land_over) + if(landUnlocked(l) && isLandIngame(l)) + currentlands.push_back(l); + } + } diff --git a/complex.cpp b/complex.cpp index 5cb409a2..52bbde4b 100644 --- a/complex.cpp +++ b/complex.cpp @@ -3039,6 +3039,7 @@ namespace prairie { } void move() { + if(chaosmode) return; manual_celllister cl; for(int i=0; i currentlands; } diff --git a/landgen.cpp b/landgen.cpp index c24d6ae0..58ac1430 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -27,6 +27,7 @@ void doOvergenerate() { bool notDippingFor(eItem i) { if(peace::on) return false; + if(chaosmode > 1) return true; int v = items[i] - currentLocalTreasure; if(v <= 10) return true; if(v >= 20) return false; @@ -35,6 +36,7 @@ bool notDippingFor(eItem i) { bool notDippingForExtra(eItem i, eItem x) { if(peace::on) return false; + if(chaosmode > 1) return true; int v = items[i] - min(items[x], currentLocalTreasure); if(v <= 10) return true; if(v >= 20) return false; @@ -2442,6 +2444,16 @@ void repairLandgen(cell *c) { } } +void setland_randomwalk(cell *c) { + if(c->land) return; + if(hrand(10) == 0) setland(c, currentlands[hrand(isize(currentlands))]); + else { + cell *c2 = c->cmove(hrand(c->type)); + setland_randomwalk(c2); + c->land = c2->land; + } + } + void setdist(cell *c, int d, cell *from) { if(c->mpdist <= d) return; @@ -2483,7 +2495,7 @@ void setdist(cell *c, int d, cell *from) { if(cseek->master->emeraldval) setland(c, eLand(cseek->master->emeraldval)); } - if(!c->land && from && (WDIM == 3 || !among(from->land, laBarrier, laElementalWall, laHauntedWall, laOceanWall)) && !quotient) { + if(!c->land && from && (WDIM == 3 || !among(from->land, laBarrier, laElementalWall, laHauntedWall, laOceanWall)) && !quotient && !(chaosmode > 1)) { if(!hasbardir(c)) setland(c, from->land); } if(c->land == laTemple && !tactic::on && !chaosmode) setland(c, laRlyeh); @@ -2492,6 +2504,25 @@ void setdist(cell *c, int d, cell *from) { if(c->land == laWhirlpool && !tactic::on && !yendor::on) setland(c, laOcean); if(c->land == laCamelot && !tactic::on) setland(c, laCrossroads); if(c->land == laBrownian && !tactic::on && !chaosmode) setland(c, laOcean); + + if(chaosmode && !c->land && isize(currentlands)) { + if(chaosmode == 3) setland(c, currentlands[hrand(isize(currentlands))]); + if(chaosmode == 2) { + if(stdeuc) { + cell *c2 = c; + while(true) { + forCellCM(c3, c2) if(cdist50(c3) < cdist50(c2)) { c2 = c3; goto again; } + break; + again: ; + } + if(!c2->land) setland(c2, currentlands[hrand(isize(currentlands))]); + c->land = c2->land; + } + else chaosmode = 4; + } + if(chaosmode == 4) + setland_randomwalk(c); + } #if CAP_DAILY if(!daily::on) { @@ -2499,6 +2530,7 @@ void setdist(cell *c, int d, cell *from) { if(true) { #endif if(0); + else if(chaosmode > 1) ; #if CAP_CRYSTAL else if(geometry == gCrystal) crystal::set_land(c); #endif diff --git a/landlock.cpp b/landlock.cpp index 1f445a69..2032ed11 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -71,7 +71,7 @@ eLand oppositeElement(eLand l, eLand l2) { eLand firstland = laIce, specialland = laIce; -bool chaosmode = false; +int chaosmode = 0; bool landUnlockedRPM(eLand n) { if(isRandland(n) == 2) return true; diff --git a/system.cpp b/system.cpp index aa22a7dc..ce2a86ed 100644 --- a/system.cpp +++ b/system.cpp @@ -146,6 +146,7 @@ void initgame() { createMov(cwt.at, 0); + pregen(); setdist(cwt.at, BARLEV, NULL); if(!use_special_land && !safety) { @@ -622,7 +623,7 @@ void applyBoxes() { applyBoxM(moFalsePrincess); applyBoxM(moRoseLady); applyBoxM(moRoseBeauty); - applyBoxBool(chaosmode, "Chaos mode"); + applyBoxNum(chaosmode, "Chaos mode"); applyBoxNum(multi::players, "shmup players"); if(multi::players < 1 || multi::players > MAXPLAYER) multi::players = 1; @@ -778,7 +779,7 @@ void loadBoxHigh() { dynamicval sp1(multi::players, savebox[197]); dynamicval sp2(geometry, (eGeometry) savebox[116]); dynamicval sp3(shmup::on, savebox[119]); - dynamicval sp4(chaosmode, savebox[196]); + dynamicval sp4(chaosmode, savebox[196]); dynamicval sp5(variation, (eVariation) savebox[186]); dynamicval sp7(gp::param.first, savebox[342]); dynamicval sp8(gp::param.second, savebox[343]); diff --git a/yendor.cpp b/yendor.cpp index 55c9aeac..85bf7020 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -455,7 +455,7 @@ namespace yendor { if(phase == 1) { won = false; if(!easy) items[itOrbYendor] = bestscore[modecode()][challenge]; - chaosmode = (clev().flags & YF_CHAOS); + chaosmode = (clev().flags & YF_CHAOS) ? 1 : 0; specialland = clev().l; if(clev().flags & YF_START_AL) { specialland = laAlchemist; @@ -704,7 +704,7 @@ namespace yendor { if(yendor::on) { yendor::won = true; if(!cheater) { - dynamicval c(chaosmode, false); + dynamicval c(chaosmode, 0); yendor::bestscore[modecode()][yendor::challenge] = max(yendor::bestscore[modecode()][yendor::challenge], items[itOrbYendor]); yendor::uploadScore();