From 9d82cea995cdae18378b51d8c29f874c2ca6b343 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 22 Dec 2018 22:39:16 +0100 Subject: [PATCH] westwall:: Yendor Quest in the West Wall --- complex.cpp | 2 +- complex2.cpp | 16 +++++++-- game.cpp | 4 ++- yendor.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 105 insertions(+), 11 deletions(-) diff --git a/complex.cpp b/complex.cpp index 05bbaafe..1ebbc184 100644 --- a/complex.cpp +++ b/complex.cpp @@ -153,7 +153,7 @@ namespace whirlwind { using namespace yendor; for(int i=0; itype); } + int coastvalEdge1(cell *c) { + if(c->land == laWestWall && !c->landparam) buildEquidistant(c); + return coastvalEdge(c); + } + void build(vector& whirlline, int d) { again: cell *at = whirlline[isize(whirlline)-1]; cell *prev = whirlline[isize(whirlline)-2]; for(int i=0; itype; i++) - if(at->move(i) && coastvalEdge(at->move(i)) == d && at->move(i) != prev) { + if(at->move(i) && coastvalEdge1(at->move(i)) == d && at->move(i) != prev) { whirlline.push_back(at->move(i)); goto again; } @@ -152,7 +157,7 @@ namespace westwall { vector whirlline; int d = coastvalEdge(c); whirlline.push_back(c); - whirlline.push_back(ts::left_of(c, coastvalEdge)); + whirlline.push_back(ts::left_of(c, coastvalEdge1)); build(whirlline, d); reverse(whirlline.begin(), whirlline.end()); build(whirlline, d); @@ -178,7 +183,12 @@ namespace westwall { using namespace yendor; for(int i=0; iitem), "and mpdist is ", yi[i].actual_key()->mpdist); + moveAt(yi[i].actual_key(), cl); + if(yi[i].actualKey) { + yi[i].age++; + setdist(yi[i].actual_key(), 8, NULL); + } } } } diff --git a/game.cpp b/game.cpp index bc87127b..39a479b4 100644 --- a/game.cpp +++ b/game.cpp @@ -6893,7 +6893,7 @@ bool collectItem(cell *c2, bool telekinesis) { } else if(c2->item == itKey) { playSound(c2, "pickup-key"); - for(int i=0; iitem == itKey) { for(int i=0; iitem == itBabyTortoise) { diff --git a/yendor.cpp b/yendor.cpp index a60636fa..c2feacfd 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -47,7 +47,7 @@ namespace yendor { int challenge; // id of the challenge int lastchallenge; - #define YENDORLEVELS 32 + #define YENDORLEVELS 33 map> bestscore; @@ -87,7 +87,8 @@ namespace yendor { {laTortoise, YF_RECALL}, {laCocytus, YF_NEAR_FJORD}, {laRuins, YF_DEAD}, - {laCaves, YF_DEAD5} + {laCaves, YF_DEAD5}, + {laWestWall, YF_START_CR}, }; int tscorelast; @@ -122,10 +123,14 @@ namespace yendor { struct yendorinfo { cell *path[YDIST]; + cell *actualKey; bool found; bool foundOrb; int howfar; + bignum age; + yendorinfo() { actualKey = NULL; } cell* key() { return path[YDIST-1]; } + cell *actual_key() { return actualKey ? actualKey : key(); } cell* orb() { return path[0]; } }; @@ -169,12 +174,16 @@ namespace yendor { int turns = 0; + bignum full_id_0; + + int odir = 0; + if(true) { int t = -1; bignum full_id; bool onlychild = true; - cellwalker ycw(yendor, hrand(yendor->type)); + cellwalker ycw(yendor, odir = hrand(yendor->type)); ycw--; if(S3 == 3) ycw--; setdist(nyi.path[0], 7, NULL); @@ -227,7 +236,7 @@ namespace yendor { if(i == 0) { t = type_in(expansion, yendor, [yendor] (cell *c) { return celldistance(yendor, c); }); bignum b = expansion.get_descendants(YDIST-1, t); - full_id = hrand(b); + full_id_0 = full_id = hrand(b); } #if DEBUG_YENDORGEN @@ -282,11 +291,19 @@ namespace yendor { nyi.found = false; nyi.foundOrb = false; + for(int i=1; iland)) { + // println(hlog, i, ": ", coastvalEdge(nyi.path[i])); + buildEquidistant(nyi.path[i]); + } + } + setdist(nyi.path[YDIST-1], 7, nyi.path[YDIST-2]); cell *key = nyi.path[YDIST-1]; generating = false; - + for(int b=10; b>=5; b--) setdist(key, b, nyi.path[YDIST-2]); for(int i=-1; itype; i++) { @@ -314,7 +331,7 @@ namespace yendor { for(int i=0; itype; i++) c2->move(i)->wall = waSea; } - if(isGravityLand(c2->land) && key->land == c2->land && + if(isGravityLand(c2->land) && key->land == c2->land && c2->land != laWestWall && c2->landparam < key->landparam && c2->wall != waTrunk) c2->wall = waPlatform; if(c2->land == laReptile && i >= 0) @@ -323,10 +340,75 @@ namespace yendor { c2->wall = waNone; } key->item = itKey; + + bool split_found = false; + + if(key->land == laWestWall && trees_known()) { + + int t = type_in(expansion, yendor, [yendor] (cell *c) { return celldistance(yendor, c); }); + int maxage = 10; + for(int i=0; iitem = itRuby; + split_found = true; + setdist(ycw.at, 6, NULL); + auto tt = type_in(expansion, ycw.at, coastvalEdge); + // println(hlog, "at split, ydist-type: ", t, " coast-type: ", tt); + if(t != tt) { + // try again! + key->item = itNone; + return check(yendor); + } + } + t = tch; + break; + } + + full_id.addmul(sub_id, -1); + if(!split_found) full_id_0.addmul(sub_id, -1); + onlychild = true; + } + + if(inmirror(ycw)) ycw = mirror::reflect(ycw); + ycw += wstep; + setdist(ycw.at, 8, ycw.peek()); + buildEquidistant(ycw.at); + // println(hlog, "actual key #", i, ": ", ycw.at->landparam); + } + + nyi.actualKey = ycw.at; + ycw.at->item = itKey; + key->item = itGold; + } yi.push_back(nyi); } addMessage(XLAT("You need to find the right Key to unlock this Orb of Yendor!")); + if(yi[byi].actualKey) + addMessage(XLAT("You feel that these directions are %1 turns old.", yi[byi].age.get_str(100))); if(yii != byi) { yii = byi; achievement_gain("YENDOR1");