1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

Clearing in bounded geometries

This commit is contained in:
Zeno Rogue 2018-04-14 10:24:02 +02:00
parent d8e7c74f70
commit d9381c7284
8 changed files with 39 additions and 12 deletions

View File

@ -715,6 +715,8 @@ void setLandQuotient(cell *c) {
if(fv%4==0 || fv%4 == 2) setland(c, laWarpSea); if(fv%4==0 || fv%4 == 2) setland(c, laWarpSea);
if(specialland == laElementalWall) if(specialland == laElementalWall)
setland(c, eLand(laEFire + (fv%4))); setland(c, eLand(laEFire + (fv%4)));
if(specialland == laClearing)
c->land = laClearing;
if(specialland == laIvoryTower || specialland == laEndorian || specialland == laDungeon || specialland == laOcean) { if(specialland == laIvoryTower || specialland == laEndorian || specialland == laDungeon || specialland == laOcean) {
int d = celldist(c) - 1; int d = celldist(c) - 1;
if(d <= 0) if(d <= 0)
@ -727,6 +729,8 @@ void setLandQuotient(cell *c) {
void setLandSphere(cell *c) { void setLandSphere(cell *c) {
if(specialland == laWarpCoast) if(specialland == laWarpCoast)
setland(c, getHemisphere(c, 0) > 0 ? laWarpCoast : laWarpSea); setland(c, getHemisphere(c, 0) > 0 ? laWarpCoast : laWarpSea);
if(specialland == laClearing)
c->land = laClearing;
if(specialland == laElementalWall) { if(specialland == laElementalWall) {
int x = getHemisphere(c, 1); int x = getHemisphere(c, 1);
int y = getHemisphere(c, 2); int y = getHemisphere(c, 2);

View File

@ -741,6 +741,22 @@ namespace clearing {
std::map<heptagon*, clearingdata> bpdata; std::map<heptagon*, clearingdata> bpdata;
cell *current_root;
void new_root() {
if(!current_root || current_root->monst != moMutant) {
auto& ac = currentmap->allcells();
int iter = 0;
while(!current_root || pseudohept(current_root) || current_root->cpdist < 3) {
if(iter++ > 100) return;
current_root = ac[hrand(size(ac))];
}
current_root->monst = moMutant;
current_root->mondir = NODIR;
current_root->stuntime = (mutantphase + 1) & 15;
}
}
int plantdir(cell *c) { int plantdir(cell *c) {
if(!quotient) { if(!quotient) {
generateAlts(c->master); generateAlts(c->master);
@ -802,10 +818,9 @@ namespace clearing {
void generate(cell *c) { void generate(cell *c) {
if(buggyplant) return; if(buggyplant) return;
if(sphere) return; if(sphere) return;
if(gp::on) return; if(gp::on) return;
if(quotient) return;
if(euclid) { if(euclid) {
if(torus) return; if(torus) return;

View File

@ -4747,9 +4747,9 @@ void movehex_rest(bool mounted) {
void movemutant() { void movemutant() {
vector<cell*> young; vector<cell*> young;
for(int i=0; i<size(dcal); i++) for(cell *c: currentmap->allcells())
if(dcal[i]->monst == moMutant && dcal[i]->stuntime == mutantphase) if(c->monst == moMutant && c->stuntime == mutantphase)
young.push_back(dcal[i]); young.push_back(c);
for(int j=1; j<size(young); j++) for(int j=1; j<size(young); j++)
swap(young[j], young[hrand(j+1)]); swap(young[j], young[hrand(j+1)]);
@ -4772,7 +4772,7 @@ void movemutant() {
if(isPlayerOn(c2)) continue; if(isPlayerOn(c2)) continue;
if((c2->land == laOvergrown || !pseudohept(c2)) && passable(c2, c, 0)) { if((c2->land == laOvergrown || !pseudohept(c2)) && passable(c2, c, 0)) {
if(c2->land == laClearing && c2->mpdist > 7) continue; if(c2->land == laClearing && !bounded && c2->mpdist > 7) continue;
c2->monst = moMutant; c2->monst = moMutant;
c2->mondir = c->spn(j); c2->mondir = c->spn(j);
c2->stuntime = mutantphase; c2->stuntime = mutantphase;
@ -5845,7 +5845,7 @@ void movemonsters() {
DEBT("leader"); DEBT("leader");
if(havewhat & HF_LEADER) groupmove(moPirate, 0); if(havewhat & HF_LEADER) groupmove(moPirate, 0);
DEBT("mutant"); DEBT("mutant");
if(havewhat & HF_MUTANT) movemutant(); if((havewhat & HF_MUTANT) || (bounded && among(specialland, laOvergrown, laClearing))) movemutant();
DEBT("bugs"); DEBT("bugs");
if(havewhat & HF_BUG) hive::movebugs(); if(havewhat & HF_BUG) hive::movebugs();
DEBT("whirlpool"); DEBT("whirlpool");

View File

@ -3669,7 +3669,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
} }
if(viewdists) { if(viewdists) {
int cd = celldistance(c, cwt.c); int cd = (cwt.c == currentmap->gamestart() && numplayers() == 1) ? celldist(c) : celldistance(c, cwt.c);
string label = its(cd); string label = its(cd);
// string label = its(fieldpattern::getriverdistleft(c)) + its(fieldpattern::getriverdistright(c)); // string label = its(fieldpattern::getriverdistleft(c)) + its(fieldpattern::getriverdistright(c));
int dc = distcolors[cd&7]; int dc = distcolors[cd&7];

View File

@ -3257,3 +3257,4 @@ bool horo_ok();
ld master_to_c7_angle(); ld master_to_c7_angle();
extern int mutantphase;

View File

@ -1173,6 +1173,7 @@ land_validity_t& land_validity(eLand l) {
if(l == laClearing) if(l == laClearing)
if(!(stdeuc || a38 || (a45 && !nonbitrunc) || (a47 && !nonbitrunc)) || gp::on) if(!(stdeuc || a38 || (a45 && !nonbitrunc) || (a47 && !nonbitrunc)) || gp::on)
if(!bounded)
return not_implemented; return not_implemented;
// does not work in non-bitrunc a4 // does not work in non-bitrunc a4

View File

@ -304,10 +304,15 @@ void wandering() {
if(cwt.c->land == laCA) ghostcount = 0; if(cwt.c->land == laCA) ghostcount = 0;
bool genturn = hrand(100) < 30; bool genturn = hrand(100) < 30;
if(bounded && specialland == laClearing)
clearing::new_root();
if(cwt.c->land == laZebra && cwt.c->wall == waNone && wchance(items[itZebra], 20)) if(cwt.c->land == laZebra && cwt.c->wall == waNone && wchance(items[itZebra], 20))
wanderingZebra(cwt.c); wanderingZebra(cwt.c);
if(smallbounded) { bool smallbounded_generation = smallbounded || (bounded && specialland == laClearing);
if(smallbounded_generation) {
int maxdist = 0; int maxdist = 0;
for(int i=0; i<size(dcal); i++) if(dcal[i]->cpdist > maxdist) maxdist = dcal[i]->cpdist; for(int i=0; i<size(dcal); i++) if(dcal[i]->cpdist > maxdist) maxdist = dcal[i]->cpdist;
for(int i=0; i<size(dcal); i++) if(dcal[i]->cpdist >= maxdist-1) { first7 = i; break; } for(int i=0; i<size(dcal); i++) if(dcal[i]->cpdist >= maxdist-1) { first7 = i; break; }
@ -338,7 +343,7 @@ void wandering() {
if(isPlayerOn(c)) continue; if(isPlayerOn(c)) continue;
} }
if(smallbounded && !c->item && hrand(5) == 0 && c->land != laHalloween) { if(smallbounded_generation && !c->item && hrand(5) == 0 && c->land != laHalloween) {
if(passable(c, NULL, 0) || specialland == laKraken) { if(passable(c, NULL, 0) || specialland == laKraken) {
if(c->land != laGraveyard && !haveOrbPower() && specialland != laHell) for(int it=0; it<1000 && !c->item; it++) if(c->land != laGraveyard && !haveOrbPower() && specialland != laHell) for(int it=0; it<1000 && !c->item; it++)
placeLocalOrbs(c); placeLocalOrbs(c);

View File

@ -233,6 +233,7 @@ void initgame() {
} }
princess::squeaked = false; princess::squeaked = false;
clearing::current_root = NULL;
if(!safety) { if(!safety) {
usedSafety = false; usedSafety = false;