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

View File

@ -741,6 +741,22 @@ namespace clearing {
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) {
if(!quotient) {
generateAlts(c->master);
@ -801,11 +817,10 @@ namespace clearing {
vector<cell*> rpath;
void generate(cell *c) {
if(buggyplant) return;
if(sphere) return;
if(buggyplant) return;
if(sphere) return;
if(gp::on) return;
if(quotient) return;
if(euclid) {
if(torus) return;

View File

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

View File

@ -3669,7 +3669,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
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(fieldpattern::getriverdistleft(c)) + its(fieldpattern::getriverdistright(c));
int dc = distcolors[cd&7];

View File

@ -3257,3 +3257,4 @@ bool horo_ok();
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(!(stdeuc || a38 || (a45 && !nonbitrunc) || (a47 && !nonbitrunc)) || gp::on)
if(!bounded)
return not_implemented;
// does not work in non-bitrunc a4

View File

@ -303,11 +303,16 @@ void wandering() {
int ghostcount = getGhostcount();
if(cwt.c->land == laCA) ghostcount = 0;
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))
wanderingZebra(cwt.c);
if(smallbounded) {
bool smallbounded_generation = smallbounded || (bounded && specialland == laClearing);
if(smallbounded_generation) {
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-1) { first7 = i; break; }
@ -338,7 +343,7 @@ void wandering() {
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(c->land != laGraveyard && !haveOrbPower() && specialland != laHell) for(int it=0; it<1000 && !c->item; it++)
placeLocalOrbs(c);

View File

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