1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-10-31 19:36:16 +00:00

westwall:: Yendor Quest in the West Wall

This commit is contained in:
Zeno Rogue 2018-12-22 22:39:16 +01:00
parent 6d392ce07e
commit 9d82cea995
4 changed files with 105 additions and 11 deletions

View File

@ -153,7 +153,7 @@ namespace whirlwind {
using namespace yendor; using namespace yendor;
for(int i=0; i<isize(yi); i++) { for(int i=0; i<isize(yi); i++) {
moveAt(yi[i].path[0], cl); moveAt(yi[i].path[0], cl);
moveAt(yi[i].path[YDIST-1], cl); moveAt(yi[i].key(), cl);
} }
} }

View File

@ -135,12 +135,17 @@ namespace westwall {
int gdist(int d, int e) { return dirdiff(d-e, where->type); } int gdist(int d, int e) { return dirdiff(d-e, where->type); }
int coastvalEdge1(cell *c) {
if(c->land == laWestWall && !c->landparam) buildEquidistant(c);
return coastvalEdge(c);
}
void build(vector<cell*>& whirlline, int d) { void build(vector<cell*>& whirlline, int d) {
again: again:
cell *at = whirlline[isize(whirlline)-1]; cell *at = whirlline[isize(whirlline)-1];
cell *prev = whirlline[isize(whirlline)-2]; cell *prev = whirlline[isize(whirlline)-2];
for(int i=0; i<at->type; i++) for(int i=0; i<at->type; 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)); whirlline.push_back(at->move(i));
goto again; goto again;
} }
@ -152,7 +157,7 @@ namespace westwall {
vector<cell*> whirlline; vector<cell*> whirlline;
int d = coastvalEdge(c); int d = coastvalEdge(c);
whirlline.push_back(c); whirlline.push_back(c);
whirlline.push_back(ts::left_of(c, coastvalEdge)); whirlline.push_back(ts::left_of(c, coastvalEdge1));
build(whirlline, d); build(whirlline, d);
reverse(whirlline.begin(), whirlline.end()); reverse(whirlline.begin(), whirlline.end());
build(whirlline, d); build(whirlline, d);
@ -178,7 +183,12 @@ namespace westwall {
using namespace yendor; using namespace yendor;
for(int i=0; i<isize(yi); i++) { for(int i=0; i<isize(yi); i++) {
moveAt(yi[i].path[0], cl); moveAt(yi[i].path[0], cl);
moveAt(yi[i].path[YDIST-1], cl); // println(hlog, "coastval of actual key is ", coastvalEdge1(yi[i].actual_key()), " and item is ", dnameof(yi[i].actual_key()->item), "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);
}
} }
} }
} }

View File

@ -6893,7 +6893,7 @@ bool collectItem(cell *c2, bool telekinesis) {
} }
else if(c2->item == itKey) { else if(c2->item == itKey) {
playSound(c2, "pickup-key"); playSound(c2, "pickup-key");
for(int i=0; i<isize(yendor::yi); i++) if(yendor::yi[i].path[YDIST-1] == c2) for(int i=0; i<isize(yendor::yi); i++) if(yendor::yi[i].actual_key() == c2)
yendor::yi[i].found = true; yendor::yi[i].found = true;
items[itKey]++; items[itKey]++;
} }
@ -8156,6 +8156,8 @@ void moveItem1(cell *from, cell *to, bool activateYendor) {
if(from->item == itKey) { if(from->item == itKey) {
for(int i=0; i<isize(yendor::yi); i++) if(yendor::yi[i].path[YDIST-1] == from) for(int i=0; i<isize(yendor::yi); i++) if(yendor::yi[i].path[YDIST-1] == from)
yendor::yi[i].path[YDIST-1] = to; yendor::yi[i].path[YDIST-1] = to;
for(int i=0; i<isize(yendor::yi); i++) if(yendor::yi[i].actualKey == from)
yendor::yi[i].actualKey = to;
} }
if(from->item == itBabyTortoise) { if(from->item == itBabyTortoise) {

View File

@ -47,7 +47,7 @@ namespace yendor {
int challenge; // id of the challenge int challenge; // id of the challenge
int lastchallenge; int lastchallenge;
#define YENDORLEVELS 32 #define YENDORLEVELS 33
map<modecode_t, array<int, YENDORLEVELS>> bestscore; map<modecode_t, array<int, YENDORLEVELS>> bestscore;
@ -87,7 +87,8 @@ namespace yendor {
{laTortoise, YF_RECALL}, {laTortoise, YF_RECALL},
{laCocytus, YF_NEAR_FJORD}, {laCocytus, YF_NEAR_FJORD},
{laRuins, YF_DEAD}, {laRuins, YF_DEAD},
{laCaves, YF_DEAD5} {laCaves, YF_DEAD5},
{laWestWall, YF_START_CR},
}; };
int tscorelast; int tscorelast;
@ -122,10 +123,14 @@ namespace yendor {
struct yendorinfo { struct yendorinfo {
cell *path[YDIST]; cell *path[YDIST];
cell *actualKey;
bool found; bool found;
bool foundOrb; bool foundOrb;
int howfar; int howfar;
bignum age;
yendorinfo() { actualKey = NULL; }
cell* key() { return path[YDIST-1]; } cell* key() { return path[YDIST-1]; }
cell *actual_key() { return actualKey ? actualKey : key(); }
cell* orb() { return path[0]; } cell* orb() { return path[0]; }
}; };
@ -169,12 +174,16 @@ namespace yendor {
int turns = 0; int turns = 0;
bignum full_id_0;
int odir = 0;
if(true) { if(true) {
int t = -1; int t = -1;
bignum full_id; bignum full_id;
bool onlychild = true; bool onlychild = true;
cellwalker ycw(yendor, hrand(yendor->type)); cellwalker ycw(yendor, odir = hrand(yendor->type));
ycw--; if(S3 == 3) ycw--; ycw--; if(S3 == 3) ycw--;
setdist(nyi.path[0], 7, NULL); setdist(nyi.path[0], 7, NULL);
@ -227,7 +236,7 @@ namespace yendor {
if(i == 0) { if(i == 0) {
t = type_in(expansion, yendor, [yendor] (cell *c) { return celldistance(yendor, c); }); t = type_in(expansion, yendor, [yendor] (cell *c) { return celldistance(yendor, c); });
bignum b = expansion.get_descendants(YDIST-1, t); bignum b = expansion.get_descendants(YDIST-1, t);
full_id = hrand(b); full_id_0 = full_id = hrand(b);
} }
#if DEBUG_YENDORGEN #if DEBUG_YENDORGEN
@ -282,6 +291,14 @@ namespace yendor {
nyi.found = false; nyi.found = false;
nyi.foundOrb = false; nyi.foundOrb = false;
for(int i=1; i<YDIST; i++) {
setdist(nyi.path[i], 7, nyi.path[i-1]);
if(isEquidLand(nyi.path[i]->land)) {
// println(hlog, i, ": ", coastvalEdge(nyi.path[i]));
buildEquidistant(nyi.path[i]);
}
}
setdist(nyi.path[YDIST-1], 7, nyi.path[YDIST-2]); setdist(nyi.path[YDIST-1], 7, nyi.path[YDIST-2]);
cell *key = nyi.path[YDIST-1]; cell *key = nyi.path[YDIST-1];
@ -314,7 +331,7 @@ namespace yendor {
for(int i=0; i<c2->type; i++) for(int i=0; i<c2->type; i++)
c2->move(i)->wall = waSea; 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->landparam < key->landparam && c2->wall != waTrunk)
c2->wall = waPlatform; c2->wall = waPlatform;
if(c2->land == laReptile && i >= 0) if(c2->land == laReptile && i >= 0)
@ -324,9 +341,74 @@ namespace yendor {
} }
key->item = itKey; 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; i<min(items[itOrbYendor], 8); i++)
maxage *= 10;
nyi.age = maxage - hrand(maxage/2);
bignum full_id = full_id_0 - nyi.age;
bool onlychild = true;
cellwalker ycw(yendor, odir);
ycw--; if(S3 == 3) ycw--;
for(int i=0; i<YDIST-1; i++) {
if(i == 1) onlychild = true;
if(!onlychild) ycw++;
if(VALENCE == 3) ycw++;
onlychild = false;
for(int tch: expansion.children[t]) {
ycw++;
if(i == 1)
tch = type_in(expansion, ycw.cpeek(), [yendor] (cell *c) { return celldistance(yendor, c); });
auto& sub_id = expansion.get_descendants(YDIST-i-2, tch);
if(full_id < sub_id) {
if(!split_found && !(full_id_0 < sub_id)) {
ycw.at->item = 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); yi.push_back(nyi);
} }
addMessage(XLAT("You need to find the right Key to unlock this Orb of Yendor!")); 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) { if(yii != byi) {
yii = byi; yii = byi;
achievement_gain("YENDOR1"); achievement_gain("YENDOR1");