refactored buildCamelot as a separate function

This commit is contained in:
Zeno Rogue 2018-12-01 23:49:14 +01:00
parent 036abd2091
commit 000f271552
3 changed files with 76 additions and 74 deletions

View File

@ -36,6 +36,7 @@ int roundTableRadius(cell *c) {
}
int celldistAltRelative(cell *c) {
if(geometry == gCrystal) return crystal::dist_relative(c);
if(sphere || quotient) {
return celldist(c) - 3;
}
@ -1166,6 +1167,74 @@ void buildCamelotWall(cell *c) {
}
}
void buildCamelot(cell *c) {
int d = celldistAltRelative(c);
if(tactic::on || (d <= 14 && roundTableRadius(c) > 20)) {
if(!eubinary) generateAlts(c->master);
preventbarriers(c);
if(d == 10) {
if(weirdhyperbolic ? hrand(100) < 50 : pseudohept(c)) buildCamelotWall(c);
else {
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move(i));
int q = 0;
if(weirdhyperbolic) {
for(int t=0; t<c->type; t++) createMov(c, t);
q = hrand(100);
if(q < 10) q = 0;
else if(q < 50) q = 1;
}
else {
for(int t=0; t<c->type; t++) {
createMov(c, t);
if(celldistAltRelative(c->move(t)) == 10 && !pseudohept(c->move(t))) q++;
}
}
if(q == 1) buildCamelotWall(c);
// towers of Camelot
if(q == 0 && BITRUNCATED) {
c->monst = moKnight;
c->wall = waTower;
forCellEx(c2, c) {
int cr = celldistAltRelative(c2);
if(cr == 9) ;
else {
buildCamelotWall(c2);
if(!ctof(c2))
c2->wall = waTower, c2->wparam = 1;
}
}
for(int i=0; i<c->type; i++) if(celldistAltRelative(c->move(i)) < d)
c->mondir = i;
}
}
}
if(d == 0) c->wall = waRoundTable;
if(celldistAlt(c) == 0 && !tactic::on) c->item = itHolyGrail;
if(d < 0 && hrand(7000) <= 10 + items[itHolyGrail] * 5) {
eMonster m[3] = { moHedge, moLancer, moFlailer };
c->monst = m[hrand(3)];
}
if(d == 1) {
// roughly as many knights as table cells
if(hrand(1000000) < 1000000 / expansion.get_growth())
c->monst = moKnight;
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move(i));
for(int i=0; i<c->type; i++)
if(c->move(i) && celldistAltRelative(c->move(i)) < d)
c->mondir = (i+3) % 6;
}
if(tactic::on && d >= 2 && d <= 8 && hrand(1000) < 10)
c->item = itOrbSafety;
if(d == 5 && tactic::on)
c->item = itGreenStone;
if(d <= 10) c->land = laCamelot;
if(d > 10 && !eubinary && !tactic::on) {
setland(c, eLand(c->master->alt->alt->fiftyval));
if(c->land == laNone) printf("Camelot\n"); // NONEDEBUG
}
}
}
void moreBigStuff(cell *c) {
if(quotient) return;
@ -1175,7 +1244,7 @@ void moreBigStuff(cell *c) {
if(d <= PRADIUS1) generateAlts(c->master);
}
if(c->land == laCanvas && !eubinary && c->master->alt)
if(c->land == laCanvas && !eubinary && c->master->alt && !quotient)
generateAlts(c->master);
if(c->land == laStorms)
@ -1197,73 +1266,8 @@ void moreBigStuff(cell *c) {
}
if((bearsCamelot(c->land) && !euclid && !quotient) || c->land == laCamelot)
if(eubinary || binarytiling || c->master->alt) if(!(binarytiling && specialland != laCamelot)) {
int d = celldistAltRelative(c);
if(tactic::on || (d <= 14 && roundTableRadius(c) > 20)) {
if(!eubinary) generateAlts(c->master);
preventbarriers(c);
if(d == 10) {
if(weirdhyperbolic ? hrand(100) < 50 : pseudohept(c)) buildCamelotWall(c);
else {
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move(i));
int q = 0;
if(weirdhyperbolic) {
for(int t=0; t<c->type; t++) createMov(c, t);
q = hrand(100);
if(q < 10) q = 0;
else if(q < 50) q = 1;
}
else {
for(int t=0; t<c->type; t++) {
createMov(c, t);
if(celldistAltRelative(c->move(t)) == 10 && !pseudohept(c->move(t))) q++;
}
}
if(q == 1) buildCamelotWall(c);
// towers of Camelot
if(q == 0 && BITRUNCATED) {
c->monst = moKnight;
c->wall = waTower;
forCellEx(c2, c) {
int cr = celldistAltRelative(c2);
if(cr == 9) ;
else {
buildCamelotWall(c2);
if(!ctof(c2))
c2->wall = waTower, c2->wparam = 1;
}
}
for(int i=0; i<c->type; i++) if(celldistAltRelative(c->move(i)) < d)
c->mondir = i;
}
}
}
if(d == 0) c->wall = waRoundTable;
if(celldistAlt(c) == 0 && !tactic::on) c->item = itHolyGrail;
if(d < 0 && hrand(7000) <= 10 + items[itHolyGrail] * 5) {
eMonster m[3] = { moHedge, moLancer, moFlailer };
c->monst = m[hrand(3)];
}
if(d == 1) {
// roughly as many knights as table cells
if(hrand(1000000) < 1000000 / expansion.get_growth())
c->monst = moKnight;
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move(i));
for(int i=0; i<c->type; i++)
if(c->move(i) && celldistAltRelative(c->move(i)) < d)
c->mondir = (i+3) % 6;
}
if(tactic::on && d >= 2 && d <= 8 && hrand(1000) < 10)
c->item = itOrbSafety;
if(d == 5 && tactic::on)
c->item = itGreenStone;
if(d <= 10) c->land = laCamelot;
if(d > 10 && !eubinary && !tactic::on) {
setland(c, eLand(c->master->alt->alt->fiftyval));
if(c->land == laNone) printf("Camelot\n"); // NONEDEBUG
}
}
}
if(eubinary || binarytiling || c->master->alt) if(!(binarytiling && specialland != laCamelot))
buildCamelot(c);
if(chaosmode && c->land == laTemple) {
for(int i=0; i<c->type; i++)

View File

@ -1334,13 +1334,11 @@ int compdist(int dx[]) {
int celldist(cell *c) {
if(fulltorus)
return torusmap()->dists[decodeId(c->master)];
if(geometry == gCrystal)
return crystal::distance(c, currentmap->gamestart());
if(euwrap)
return torusconfig::cyldist(decodeId(c->master), 0);
if(masterless)
return eudist(decodeId(c->master));
if(sphere || binarytiling) return celldistance(c, currentmap->gamestart());
if(sphere || binarytiling || geometry == gCrystal) return celldistance(c, currentmap->gamestart());
if(IRREGULAR) return irr::celldist(c, false);
if(archimedean || ctof(c)) return c->master->distance;
if(GOLDBERG) return gp::compute_dist(c, celldist);
@ -1363,6 +1361,8 @@ int celldistAlt(cell *c) {
return euclidAlt(x, y);
}
if(binarytiling) return c->master->distance + (specialland == laCamelot && !tactic::on? 30 : 0);
if(geometry == gCrystal)
return crystal::dist_alt(c);
if(sphere || quotient) {
return celldist(c) - 3;
}
@ -1738,9 +1738,6 @@ int celldistance(cell *c1, cell *c2) {
if(geometry == gFieldQuotient && !GOLDBERG)
return currfp.getdist(fieldpattern::fieldval(c1), fieldpattern::fieldval(c2));
if(geometry == gCrystal)
return crystal::distance(c1, c2);
if(bounded) {
if(saved_distances.count(make_pair(c1,c2)))

View File

@ -2756,6 +2756,7 @@ bool checkInTree(cell *c, int maxv);
cell *findcompass(cell *c);
int edgeDepth(cell *c);
int compassDist(cell *c);
void buildCamelot(cell *c);
#define HAUNTED_RADIUS getDistLimit()
#define UNKNOWN 65535