2019-08-10 11:43:24 +00:00
|
|
|
// Hyperbolic Rogue -- Big Stuff
|
2018-02-08 23:40:26 +00:00
|
|
|
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2019-08-10 11:43:24 +00:00
|
|
|
/** \file bigstuff.cpp
|
|
|
|
* \brief Large map structures, such as (horo)cycles and equidistants.
|
|
|
|
*
|
|
|
|
* This file implements:
|
|
|
|
* * routines related to (horo)cycles
|
|
|
|
* * routines related to equidistants
|
|
|
|
* * 'setland' routines for other geometries
|
|
|
|
* * the buildBigStuff function which calls equidistant/(horo)cycle/barrier generators.
|
|
|
|
* This routines are general, i.e., not necessarily Steam-specific.
|
|
|
|
*/
|
|
|
|
|
2019-09-05 07:15:40 +00:00
|
|
|
#include "hyper.h"
|
2018-06-10 23:58:31 +00:00
|
|
|
namespace hr {
|
|
|
|
|
2019-09-05 07:15:40 +00:00
|
|
|
// horocycles
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int newRoundTableRadius() {
|
2017-10-08 10:10:40 +00:00
|
|
|
return 28 + 2 * items[itHolyGrail];
|
|
|
|
}
|
|
|
|
|
2020-10-15 14:33:52 +00:00
|
|
|
#if CAP_COMPLEX2
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int getAnthraxData(cell *c, bool b) {
|
2017-10-08 10:10:40 +00:00
|
|
|
int d = celldistAlt(c);
|
2019-12-08 18:17:28 +00:00
|
|
|
int rad = 28 + 3 * camelot::anthraxBonus;
|
2017-10-08 10:10:40 +00:00
|
|
|
while(d < -rad) {
|
|
|
|
d += rad + 12;
|
|
|
|
rad += 3;
|
|
|
|
}
|
|
|
|
while(d >= 12) {
|
|
|
|
if(rad > 5) rad -= 3;
|
|
|
|
else if(rad) rad--;
|
|
|
|
d -= rad + 12;
|
|
|
|
}
|
|
|
|
if(b) return rad;
|
|
|
|
return d;
|
|
|
|
}
|
2020-10-15 14:33:52 +00:00
|
|
|
#endif
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int roundTableRadius(cell *c) {
|
2018-08-09 17:28:53 +00:00
|
|
|
if(eubinary) return 28;
|
2020-10-15 14:33:52 +00:00
|
|
|
#if CAP_COMPLEX2
|
2017-10-08 10:10:40 +00:00
|
|
|
if(tactic::on) return getAnthraxData(c, true);
|
2020-10-15 14:33:52 +00:00
|
|
|
#endif
|
2019-04-20 22:56:43 +00:00
|
|
|
if(!c->master->alt) return 28;
|
2017-10-08 10:10:40 +00:00
|
|
|
return c->master->alt->alt->emeraldval & GRAIL_RADIUS_MASK;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int celldistAltRelative(cell *c) {
|
2019-02-17 17:28:20 +00:00
|
|
|
#if CAP_CRYSTAL
|
2019-08-22 10:14:39 +00:00
|
|
|
if(cryst) return crystal::dist_relative(c);
|
2019-02-17 17:28:20 +00:00
|
|
|
#endif
|
2019-05-06 23:08:49 +00:00
|
|
|
#if MAXMDIM >= 4
|
2019-12-14 10:26:03 +00:00
|
|
|
if(euc::in(3)) return euc::dist_relative(c);
|
2019-05-06 23:08:49 +00:00
|
|
|
#endif
|
2019-11-27 00:01:20 +00:00
|
|
|
if(euclid && quotient) return celldistAlt(c) - roundTableRadius(c);
|
2017-10-30 21:47:07 +00:00
|
|
|
if(sphere || quotient) {
|
|
|
|
return celldist(c) - 3;
|
|
|
|
}
|
2020-10-15 14:33:52 +00:00
|
|
|
#if CAP_COMPLEX2
|
2017-10-08 10:10:40 +00:00
|
|
|
if(tactic::on) return getAnthraxData(c, false);
|
2020-10-15 14:33:52 +00:00
|
|
|
#endif
|
2017-10-08 10:10:40 +00:00
|
|
|
return celldistAlt(c) - roundTableRadius(c);
|
|
|
|
}
|
|
|
|
|
2019-12-08 09:59:09 +00:00
|
|
|
EX gp::loc camelot_coords() { return gp::loc(a4 ? 21 : 20, 10); }
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int euclidAlt(short x, short y) {
|
2018-09-28 10:27:44 +00:00
|
|
|
if(among(specialland, laTemple, laClearing, laCanvas)) {
|
2019-12-14 10:26:03 +00:00
|
|
|
if(euc::in(2,6))
|
2017-12-29 13:20:38 +00:00
|
|
|
return max(int(x), x+y);
|
2018-08-28 15:17:34 +00:00
|
|
|
else if(PURE)
|
2017-12-29 13:20:38 +00:00
|
|
|
return x + abs(y);
|
|
|
|
else
|
|
|
|
return max(x, y);
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
else if(specialland == laCaribbean || specialland == laWhirlpool || specialland == laMountain) {
|
2019-12-14 10:26:03 +00:00
|
|
|
if(euc::in(2,6))
|
2017-12-29 13:20:38 +00:00
|
|
|
return
|
|
|
|
min(
|
|
|
|
min(max(int(-x), -x-y) + 3,
|
|
|
|
max(int(x+y), int(y)) + 3),
|
|
|
|
max(int(x), int(-y)) + 3
|
|
|
|
);
|
2018-08-28 15:17:34 +00:00
|
|
|
else if(PURE)
|
2017-12-29 13:20:38 +00:00
|
|
|
return 3 - min(abs(x-y), abs(x+y));
|
|
|
|
else
|
|
|
|
return 3 - min(abs(x), abs(y));
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
else if(specialland == laPrincessQuest)
|
2019-12-08 09:59:09 +00:00
|
|
|
return euc::dist(gp::loc(x,y), princess::coords());
|
|
|
|
else return euc::dist(gp::loc(x,y), camelot_coords());
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int cylinder_alt(cell *c) {
|
2018-12-04 18:13:26 +00:00
|
|
|
if(specialland == laPrincessQuest)
|
2019-12-08 09:59:09 +00:00
|
|
|
return celldistance(c, euc::at(princess::coords()));
|
2018-12-04 18:13:26 +00:00
|
|
|
if(specialland == laCamelot)
|
2019-12-08 09:59:09 +00:00
|
|
|
return celldistance(c, euc::at(camelot_coords()));
|
2018-12-04 18:13:26 +00:00
|
|
|
|
|
|
|
int maxmul = 0;
|
|
|
|
for(int d = 0; d < SG6; d++)
|
2019-12-08 09:59:09 +00:00
|
|
|
maxmul = max(maxmul, euc::dcross(euc::sdxy(), gp::eudir(d)));
|
|
|
|
return 5-abs(gdiv(euc::dcross(euc::sdxy(), euc2_coordinates(c)), maxmul));
|
2018-12-04 18:13:26 +00:00
|
|
|
}
|
|
|
|
|
2017-10-08 10:10:40 +00:00
|
|
|
const int NOCOMPASS = 1000000;
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int compassDist(cell *c) {
|
2017-12-29 13:20:38 +00:00
|
|
|
if(sphere || quotient) return 0;
|
2018-08-09 17:28:53 +00:00
|
|
|
if(eubinary || c->master->alt) return celldistAlt(c);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(isHaunted(c->land) || c->land == laGraveyard) return getHauntedDepth(c);
|
|
|
|
return NOCOMPASS;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX cell *findcompass(cell *c) {
|
2017-10-08 10:10:40 +00:00
|
|
|
int d = compassDist(c);
|
|
|
|
if(d == NOCOMPASS) return NULL;
|
|
|
|
|
|
|
|
while(inscreenrange(c)) {
|
2018-08-09 17:28:53 +00:00
|
|
|
if(!eubinary && !sphere && !quotient)
|
2019-03-08 21:38:44 +00:00
|
|
|
currentmap->generateAlts(c->master);
|
2017-10-08 10:10:40 +00:00
|
|
|
forCellEx(c2, c) if(compassDist(c2) < d) {
|
|
|
|
c = c2;
|
|
|
|
d = compassDist(c2);
|
|
|
|
goto nextk;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
nextk: ;
|
|
|
|
}
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool grailWasFound(cell *c) {
|
2018-08-09 17:28:53 +00:00
|
|
|
if(eubinary || quotient || sphere) return items[itHolyGrail];
|
2017-10-08 10:10:40 +00:00
|
|
|
return c->master->alt->alt->emeraldval & GRAIL_FOUND;
|
|
|
|
}
|
|
|
|
|
2020-01-28 09:20:39 +00:00
|
|
|
EX int default_levs() {
|
|
|
|
if(IRREGULAR)
|
|
|
|
return 1;
|
|
|
|
if(S3 >= OINF)
|
|
|
|
return 1;
|
2020-01-29 17:18:51 +00:00
|
|
|
#if MAXMDIM >= 4
|
2020-01-28 18:45:24 +00:00
|
|
|
if(reg3::in_rule()) return 0;
|
2020-01-29 17:18:51 +00:00
|
|
|
#endif
|
2020-01-28 09:20:39 +00:00
|
|
|
return S3-3;
|
|
|
|
}
|
|
|
|
|
2019-03-08 21:38:44 +00:00
|
|
|
void hrmap::generateAlts(heptagon *h, int levs, bool link_cdata) {
|
2019-11-28 22:09:04 +00:00
|
|
|
if(hybri) { PIU ( generateAlts(h, levs, link_cdata) ); }
|
2017-10-08 10:10:40 +00:00
|
|
|
if(!h->alt) return;
|
2018-07-20 00:58:47 +00:00
|
|
|
preventbarriers(h->c7);
|
2019-02-28 21:23:47 +00:00
|
|
|
if(h->c7) forCellEx(c2, h->c7) preventbarriers(c2);
|
2018-08-28 15:17:34 +00:00
|
|
|
if(GOLDBERG)
|
2018-04-06 20:22:33 +00:00
|
|
|
for(int i=0; i<S7; i++) preventbarriers(createStep(h, i)->c7);
|
2020-01-18 23:13:54 +00:00
|
|
|
for(int i=0; i<h->type; i++)
|
2017-10-08 10:10:40 +00:00
|
|
|
createStep(h->alt, i)->alt = h->alt->alt;
|
|
|
|
int relspin = -4; // for horocycles it must go the other way
|
2020-01-29 17:18:51 +00:00
|
|
|
if(quotient) relspin = 0;
|
|
|
|
#if MAXMDIM >= 4
|
|
|
|
else if(reg3::in_rule()) relspin = 0;
|
|
|
|
#endif
|
2017-10-08 10:10:40 +00:00
|
|
|
else {
|
2020-01-18 23:13:54 +00:00
|
|
|
for(int j=0; j<h->type; j++) for(int i=0; i<h->type; i++) {
|
2017-10-08 10:10:40 +00:00
|
|
|
createStep(h, i);
|
2018-08-17 22:46:45 +00:00
|
|
|
if(h->move(i)->alt == h->alt->move(j)) {
|
2017-10-28 23:57:34 +00:00
|
|
|
relspin = (i-j+S7) % S7;
|
2017-10-08 10:10:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-06-25 21:14:46 +00:00
|
|
|
if(relspin == -4 && geometry != gFieldQuotient) {
|
2017-10-08 10:10:40 +00:00
|
|
|
if(h->alt != h->alt->alt) {
|
2020-02-23 02:48:46 +00:00
|
|
|
printf("relspin {%p:%p}\n", hr::voidp(h->alt), hr::voidp(h->alt->alt));
|
|
|
|
{for(int i=0; i<S7; i++) printf("%p ", hr::voidp(h->alt->move(i)));} printf(" ALT\n");
|
|
|
|
{for(int i=0; i<S7; i++) printf("%p ", hr::voidp(h->move(i)));} printf(" REAL\n");
|
|
|
|
{for(int i=0; i<S7; i++) printf("%p ", hr::voidp(h->move(i)->alt));} printf(" REAL ALT\n");
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
relspin = 3;
|
|
|
|
} }
|
|
|
|
// h[relspin] matches alt[0]
|
|
|
|
//printf("{%d~%d}\n", h->distance, h->alt->distance);
|
2020-01-18 23:13:54 +00:00
|
|
|
if(h->type != h->alt->type) return;
|
|
|
|
for(int i=0; i<h->type; i++) {
|
|
|
|
int ir = gmod(i-relspin, h->type);
|
2018-08-17 22:46:45 +00:00
|
|
|
heptagon *hm = h->alt->move(ir);
|
2017-10-08 10:10:40 +00:00
|
|
|
heptagon *ho = createStep(h, i);
|
|
|
|
// printf("[%p:%d ~ %p:%d] %p ~ %p\n",
|
2020-02-23 02:48:46 +00:00
|
|
|
// hr::voidp(h), i, hr::voidp(h->alt), ir,
|
|
|
|
// hr::voidp(ho), hr::voidp(hm));
|
2017-10-08 10:10:40 +00:00
|
|
|
if(ho->alt && ho->alt != hm) {
|
|
|
|
if(ho->alt->alt == hm->alt && !quotient) {
|
|
|
|
printf("ERROR: alt cross! [%d -> %d]\n", ho->alt->distance, hm->distance);
|
|
|
|
// exit(1);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ho->alt = hm;
|
2018-02-08 21:27:48 +00:00
|
|
|
if(link_cdata) hm->cdata = (cdata*) ho;
|
2019-03-08 21:38:44 +00:00
|
|
|
if(levs) currentmap->generateAlts(ho, levs-1, link_cdata);
|
2019-10-10 11:09:31 +00:00
|
|
|
if(S3 >= OINF) preventbarriers(ho->c7);
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-29 17:18:51 +00:00
|
|
|
#if MAXMDIM >= 4
|
2020-01-28 18:45:46 +00:00
|
|
|
EX int hrandom_adjacent(int d) {
|
|
|
|
vector<int> choices = {d};
|
2020-04-05 08:53:34 +00:00
|
|
|
for(int a=0; a<S7; a++) if(cgi.dirs_adjacent[d][a]) choices.push_back(a);
|
2020-01-28 18:45:46 +00:00
|
|
|
return hrand_elt(choices, d);
|
|
|
|
}
|
2020-01-29 17:18:51 +00:00
|
|
|
#endif
|
2020-01-28 18:45:46 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special IS(0)) {
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2019-08-24 12:07:46 +00:00
|
|
|
if(hybri) {
|
2019-11-28 22:09:38 +00:00
|
|
|
if(hybrid::under_class() == gcSphere) return NULL;
|
2019-08-24 12:07:46 +00:00
|
|
|
c = hybrid::get_where(c).first;
|
2019-11-28 22:09:04 +00:00
|
|
|
return PIU ( createAlternateMap(c, rad, firststate, special) );
|
2019-08-18 13:32:46 +00:00
|
|
|
}
|
|
|
|
|
2017-10-08 10:10:40 +00:00
|
|
|
// check for direction
|
|
|
|
int gdir = -1;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
2020-01-29 17:18:51 +00:00
|
|
|
#if MAXMDIM >= 4
|
2020-01-28 09:35:41 +00:00
|
|
|
if(!reg3::in_rule()) {
|
2020-01-29 17:18:51 +00:00
|
|
|
#else
|
|
|
|
if(true) {
|
|
|
|
#endif
|
2020-01-28 09:22:15 +00:00
|
|
|
if(c->move(i) && c->move(i)->mpdist < c->mpdist) gdir = i;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* mpdist may be incorrect */
|
|
|
|
if(c->move(i) && c->move(i)->master->distance < c->master->distance) gdir = i;
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
if(gdir < 0) return NULL;
|
|
|
|
|
2017-10-28 23:57:34 +00:00
|
|
|
// non-crossing in weird hyperbolic
|
|
|
|
if(weirdhyperbolic) {
|
|
|
|
if(c->bardir == NOBARRIERS) return NULL;
|
2020-01-28 09:22:15 +00:00
|
|
|
forCellCM(c1, c) if(c1->bardir == NOBARRIERS) return NULL;
|
2018-08-28 15:17:34 +00:00
|
|
|
if(IRREGULAR)
|
2018-07-20 00:58:47 +00:00
|
|
|
for(int i=0; i<S7; i++)
|
|
|
|
if(createStep(c->master, i)->c7->bardir != NODIR)
|
|
|
|
return NULL;
|
2017-10-28 23:57:34 +00:00
|
|
|
}
|
|
|
|
|
2017-10-08 10:10:40 +00:00
|
|
|
// check for non-crossing
|
|
|
|
int bd = 2;
|
|
|
|
cellwalker bb(c, bd);
|
2017-10-28 23:57:34 +00:00
|
|
|
if(!weirdhyperbolic && !(checkBarriersFront(bb) && checkBarriersBack(bb))) {
|
2017-10-08 10:10:40 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2020-01-28 09:28:11 +00:00
|
|
|
|
2020-01-28 18:45:46 +00:00
|
|
|
// if we always go to the opposite tile on a {even,x} tiling,
|
|
|
|
// it will be too easy
|
2020-01-28 09:28:11 +00:00
|
|
|
int flip = 0;
|
|
|
|
if(WDIM == 2 && S7 % 2 == 0) flip = hrand(2) ? 1 : -1;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
|
|
|
// okay, let's go then!
|
|
|
|
cellwalker bf(c, gdir);
|
2018-06-27 22:35:45 +00:00
|
|
|
std::vector<cell *> cx(rad+1);
|
2017-10-08 10:10:40 +00:00
|
|
|
for(int i=0; i<rad; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cx[i] = bf.at;
|
2018-03-24 11:59:01 +00:00
|
|
|
bf += revstep;
|
2020-01-28 09:28:11 +00:00
|
|
|
if(flip && hrand(2) == 0) { bf += flip; flip *= -1; }
|
2020-01-28 18:45:46 +00:00
|
|
|
|
2020-01-29 18:04:54 +00:00
|
|
|
#if MAXMDIM >= 4
|
2020-01-28 18:45:46 +00:00
|
|
|
// in 3D honeycombs we vary the direction, but never for three successive i's
|
|
|
|
if(WDIM == 3 && firststate == hsOrigin && (i%3))
|
|
|
|
bf.spin = hrandom_adjacent(bf.spin);
|
2020-01-29 18:04:54 +00:00
|
|
|
#endif
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
2018-08-17 22:46:45 +00:00
|
|
|
cx[rad] = bf.at;
|
|
|
|
heptagon *h = bf.at->master;
|
2018-04-13 12:00:30 +00:00
|
|
|
|
|
|
|
if(h->alt) {
|
|
|
|
printf("Error: creatingAlternateMap while one already exists\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
|
|
|
|
if(special == waPalace) {
|
|
|
|
|
|
|
|
// type 7 is ensured
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c = bf.at;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
|
|
|
if(cdist50(c) != 0) return NULL;
|
2018-09-05 13:37:07 +00:00
|
|
|
if(!polarb50(c)) return NULL;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
2020-01-18 23:13:54 +00:00
|
|
|
heptagon *alt = tailored_alloc<heptagon> (h->type);
|
2017-10-29 13:21:42 +00:00
|
|
|
allmaps.push_back(newAltMap(alt));
|
2020-02-23 02:48:46 +00:00
|
|
|
//printf("new alt {%p}\n", hr::voidp(alt));
|
2017-10-08 10:10:40 +00:00
|
|
|
alt->s = firststate;
|
|
|
|
alt->emeraldval = 0;
|
|
|
|
alt->zebraval = 0;
|
|
|
|
alt->distance = 0;
|
2019-11-14 18:50:12 +00:00
|
|
|
alt->fieldval = 0;
|
|
|
|
if(hybri) alt->fieldval = hybrid::get_where(centerover).second;
|
2017-10-08 10:10:40 +00:00
|
|
|
alt->c7 = NULL;
|
|
|
|
alt->alt = alt;
|
2020-01-29 17:18:51 +00:00
|
|
|
#if MAXMDIM >= 4
|
2020-01-28 09:35:41 +00:00
|
|
|
if(reg3::in_rule()) {
|
2020-01-28 11:43:53 +00:00
|
|
|
reg3::link_structures(h, alt, firststate);
|
2020-01-28 09:35:41 +00:00
|
|
|
if(alt->fiftyval == -1) return nullptr; /* unlinked */
|
|
|
|
}
|
2020-01-29 17:18:51 +00:00
|
|
|
#endif
|
2017-10-08 10:10:40 +00:00
|
|
|
h->alt = alt;
|
2018-01-25 18:49:19 +00:00
|
|
|
alt->cdata = (cdata*) h;
|
2019-03-09 00:00:46 +00:00
|
|
|
currentmap->link_alt(bf);
|
2020-01-28 11:43:53 +00:00
|
|
|
|
2017-10-08 10:10:40 +00:00
|
|
|
for(int d=rad; d>=0; d--) {
|
2019-03-08 21:38:44 +00:00
|
|
|
currentmap->generateAlts(cx[d]->master);
|
2017-10-08 10:10:40 +00:00
|
|
|
preventbarriers(cx[d]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(special == waPalace) {
|
|
|
|
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c = bf.at;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
|
|
|
princess::generating = true;
|
|
|
|
c->land = laPalace;
|
|
|
|
for(int j=BARLEV; j>=0; j--)
|
|
|
|
setdist(c, j, NULL);
|
|
|
|
princess::generating = false;
|
|
|
|
|
|
|
|
princess::newInfo(c);
|
|
|
|
princess::forceMouse = false;
|
|
|
|
|
2018-08-17 22:46:45 +00:00
|
|
|
if(princess::gotoPrincess && cheater) princess::gotoPrincess=false, cwt.at = c;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return alt;
|
2020-02-23 02:48:46 +00:00
|
|
|
//for(int d=rad; d>=0; d--) printf("%3d. %p {%d}\n", d, hr::voidp(cx[d]->master), cx[d]->master->alt->distance);
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void beCIsland(cell *c) {
|
2017-10-08 10:10:40 +00:00
|
|
|
int i = hrand(3);
|
|
|
|
if(i == 0) c->wall = waCIsland;
|
|
|
|
if(i == 1) c->wall = waCIsland2;
|
|
|
|
if(i == 2) c->wall = waCTree;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void generateTreasureIsland(cell *c) {
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary) currentmap->generateAlts(c->master);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(isOnCIsland(c)) return;
|
|
|
|
|
|
|
|
bool src = hrand(100) < 10;
|
|
|
|
if(src) {
|
|
|
|
beCIsland(c);
|
|
|
|
if(c->wall == waCTree) return;
|
|
|
|
}
|
2020-01-18 15:03:32 +00:00
|
|
|
vector<cell*> ctab;
|
|
|
|
int qlo, qhi;
|
2017-10-08 10:10:40 +00:00
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = createMov(c, i);
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary) currentmap->generateAlts(c2->master);
|
2018-08-09 17:28:53 +00:00
|
|
|
if((eubinary || (c->master->alt && c2->master->alt)) && celldistAlt(c2) < celldistAlt(c)) {
|
2020-01-18 15:03:32 +00:00
|
|
|
ctab.push_back(c2);
|
2017-10-08 10:10:40 +00:00
|
|
|
qlo = i; qhi = i;
|
2020-01-18 15:03:32 +00:00
|
|
|
while(true && isize(ctab) < c->type) {
|
2017-10-08 10:10:40 +00:00
|
|
|
qlo--;
|
2019-08-09 12:29:08 +00:00
|
|
|
c2 = c->cmodmove(qlo);
|
2018-08-09 17:28:53 +00:00
|
|
|
if(!eubinary && !c2->master->alt) break;
|
2017-10-08 10:10:40 +00:00
|
|
|
if(celldistAlt(c2) >= celldistAlt(c)) break;
|
2020-01-18 15:03:32 +00:00
|
|
|
ctab.push_back(c2);
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
2020-01-18 15:03:32 +00:00
|
|
|
while(true && isize(ctab) < c->type) {
|
2017-10-08 10:10:40 +00:00
|
|
|
qhi++;
|
2019-08-09 12:29:08 +00:00
|
|
|
c2 = c->cmodmove(qhi);
|
2018-08-09 17:28:53 +00:00
|
|
|
if(!eubinary && !c2->master->alt) break;
|
2017-10-08 10:10:40 +00:00
|
|
|
if(celldistAlt(c2) >= celldistAlt(c)) break;
|
2020-01-18 15:03:32 +00:00
|
|
|
ctab.push_back(c2);
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-01-18 15:03:32 +00:00
|
|
|
if(ctab.empty()) {
|
2017-10-08 10:10:40 +00:00
|
|
|
printf("NO QC\n"); c->wall = waSea;
|
2018-08-17 22:46:45 +00:00
|
|
|
for(int i=0; i<c->type; i++) printf("%d ", celldistAlt(c->move(i)));
|
2017-10-08 10:10:40 +00:00
|
|
|
printf("vs %d\n", celldistAlt(c));
|
|
|
|
return;
|
|
|
|
}
|
2019-08-09 12:29:08 +00:00
|
|
|
cell* c2 = c->cmodmove((qlo+qhi)/2);
|
2017-10-08 10:10:40 +00:00
|
|
|
generateTreasureIsland(c2);
|
|
|
|
if(!src) {
|
|
|
|
c->wall = c2->wall;
|
|
|
|
if(c->wall != waCTree && hrand(100) < 15)
|
|
|
|
c->wall = (c->wall == waCIsland ? waCIsland2 : waCIsland);
|
|
|
|
}
|
2019-03-04 16:56:32 +00:00
|
|
|
if(src && c2->wall == waCTree && (eubinary||c->master->alt) && celldistAlt(c) <= -10 && geometry != gRhombic3) {
|
2017-10-08 10:10:40 +00:00
|
|
|
bool end = true;
|
2020-01-18 15:03:32 +00:00
|
|
|
for(cell *cc: ctab) {
|
|
|
|
generateTreasureIsland(cc);
|
|
|
|
if(cc->wall != waCTree)
|
2017-10-08 10:10:40 +00:00
|
|
|
end = false;
|
|
|
|
}
|
2020-02-23 02:48:46 +00:00
|
|
|
// printf("%p: end=%d, qc=%d, dist=%d\n", hr::voidp(c), end, qc, celldistAlt(c));
|
2017-10-08 10:10:40 +00:00
|
|
|
if(end) c->item = itPirate;
|
|
|
|
else c->item = itCompass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// equidistants
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool generatingEquidistant = false;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX cell *buildAnotherEquidistant(cell *c, int radius) {
|
2017-10-08 10:10:40 +00:00
|
|
|
int gdir = -1;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
if(c->move(i) && c->move(i)->mpdist < c->mpdist) gdir = i;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
if(gdir == -1) return NULL;
|
|
|
|
|
|
|
|
cellwalker cw(c, (gdir+3) % c->type);
|
|
|
|
vector<cell*> coastpath;
|
2018-04-11 21:37:28 +00:00
|
|
|
|
2018-08-17 22:46:45 +00:00
|
|
|
while(isize(coastpath) < radius || (cw.at->type != 7 && !weirdhyperbolic)) {
|
2017-10-08 10:10:40 +00:00
|
|
|
// this leads to bugs for some reason!
|
2018-08-17 22:46:45 +00:00
|
|
|
if(cw.at->land == laCrossroads2) {
|
2017-10-08 10:10:40 +00:00
|
|
|
#ifdef AUTOPLAY
|
|
|
|
if(doAutoplay) printf("avoiding the Crossroads II\n"); // todo
|
|
|
|
#endif
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-08-17 22:46:45 +00:00
|
|
|
if(cw.at->bardir != NODIR) return NULL;
|
|
|
|
if(cw.at->landparam && cw.at->landparam < radius) return NULL;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2018-08-17 22:46:45 +00:00
|
|
|
/* forCellEx(c2, cw.at) if(c2->bardir != NODIR) {
|
2017-10-08 10:10:40 +00:00
|
|
|
generatingEquidistant = false;
|
|
|
|
return;
|
|
|
|
} */
|
2018-08-17 22:46:45 +00:00
|
|
|
coastpath.push_back(cw.at);
|
|
|
|
if(cw.at->land == laNone && cw.at->mpdist <= 7) {
|
|
|
|
raiseBuggyGeneration(cw.at, "landNone 1");
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(coastpath); i++) coastpath[i]->item = itPirate;
|
2017-10-08 10:10:40 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2018-03-24 11:59:01 +00:00
|
|
|
cw = cw + wstep + 3;
|
2018-08-17 22:46:45 +00:00
|
|
|
if(ctof(cw.at) && hrand(2) == 0) cw++;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
2018-08-17 22:46:45 +00:00
|
|
|
coastpath.push_back(cw.at);
|
2017-10-08 10:10:40 +00:00
|
|
|
// printf("setdists\n");
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=1; i<isize(coastpath) - 1; i++) {
|
2017-10-08 10:10:40 +00:00
|
|
|
if(coastpath[i-1]->land == laNone) {
|
2018-08-17 22:46:45 +00:00
|
|
|
raiseBuggyGeneration(cwt.at, "landNone 3");
|
2017-10-08 10:10:40 +00:00
|
|
|
int mpd[10];
|
|
|
|
for(int i=0; i<10; i++) mpd[i] = coastpath[i]->mpdist;
|
|
|
|
{for(int i=0; i<10; i++) printf("%d ", mpd[i]);} printf("\n");
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(coastpath); i++) coastpath[i]->item = itPirate;
|
2017-10-08 10:10:40 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
setdist(coastpath[i], BARLEV, coastpath[i-1]);
|
|
|
|
setdist(coastpath[i], BARLEV-1, coastpath[i-1]);
|
2018-06-22 12:47:24 +00:00
|
|
|
if(i < isize(coastpath) - 5) {
|
2017-10-08 10:10:40 +00:00
|
|
|
coastpath[i]->bardir = NOBARRIERS;
|
|
|
|
// forCellEx(c2, coastpath[i]) c2->bardir = NOBARRIERS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//printf("building barrier\n");
|
|
|
|
cell *c2 = coastpath[coastpath.size() - 1];
|
|
|
|
int bd = 2 + (hrand(2)) * 3;
|
|
|
|
|
|
|
|
bool nowall = false;
|
|
|
|
|
|
|
|
if(c2->land == laNone) {
|
|
|
|
raiseBuggyGeneration(c2, "landNone 2");
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(coastpath); i++) coastpath[i]->item = itPirate;
|
2017-10-08 10:10:40 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// prevent gravity anomalies
|
|
|
|
if(c2->land != c->land) return NULL;
|
|
|
|
|
2018-04-23 10:00:51 +00:00
|
|
|
bool oc = c->land == laOcean;
|
|
|
|
|
2017-10-29 13:21:42 +00:00
|
|
|
// else if(ctof(c) && hrand(10000) < 20 && !isCrossroads(c->land) && gold() >= 200)
|
2018-04-23 10:00:51 +00:00
|
|
|
if(oc && weirdhyperbolic && specialland == laCrossroads4 && buildBarrierNowall(c2, getNewLand(laOcean))) {
|
2018-04-11 21:37:28 +00:00
|
|
|
nowall = true;
|
|
|
|
}
|
2018-04-23 10:00:51 +00:00
|
|
|
else if(oc && pseudohept(c2) && gold() >= R200 && hrand(10) < 2 && buildBarrierNowall(c2, laCrossroads4)) {
|
2017-10-08 10:10:40 +00:00
|
|
|
nowall = true;
|
|
|
|
// raiseBuggyGeneration(c2, "check");
|
|
|
|
// return;
|
|
|
|
}
|
2018-04-11 21:37:28 +00:00
|
|
|
else if(!weirdhyperbolic) buildBarrier(c2, bd);
|
2017-10-08 10:10:40 +00:00
|
|
|
//printf("building barrier II\n");
|
|
|
|
if(hasbardir(c2)) extendBarrier(c2);
|
|
|
|
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=isize(coastpath)-(nowall?1:2); i>=0; i--) {
|
2017-10-08 10:10:40 +00:00
|
|
|
for(int j=BARLEV; j>=6; j--)
|
|
|
|
setdist(coastpath[i], j, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return c2;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void buildAnotherEquidistant(cell *c) {
|
2017-10-08 10:10:40 +00:00
|
|
|
//printf("building another coast\n");
|
|
|
|
|
|
|
|
if(yendor::on) return;
|
|
|
|
|
|
|
|
generatingEquidistant = true;
|
|
|
|
|
|
|
|
int radius = c->land == laOcean ? 30 : HAUNTED_RADIUS + 5;
|
|
|
|
|
|
|
|
buildAnotherEquidistant(c, radius);
|
|
|
|
|
|
|
|
generatingEquidistant = false;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int coastval(cell *c, eLand base) {
|
2017-10-08 10:10:40 +00:00
|
|
|
if(!c) return UNKNOWN;
|
|
|
|
if(c->land == laNone) return UNKNOWN;
|
|
|
|
if(base == laGraveyard) {
|
|
|
|
if(c->land == laHaunted || c->land == laHauntedWall)
|
|
|
|
return 0;
|
|
|
|
if(c->land != laGraveyard && c->land != laHauntedBorder) return 30;
|
|
|
|
}
|
|
|
|
else if(base == laMirrored) {
|
|
|
|
if(!inmirror(c)) return 0;
|
|
|
|
if(!c->landparam) return UNKNOWN;
|
|
|
|
return c->landparam & 255;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(c->land == laOceanWall || c->land == laCaribbean || c->land == laWhirlpool ||
|
2018-10-25 00:43:14 +00:00
|
|
|
c->land == laLivefjord || c->land == laWarpSea || c->land == laKraken || c->land == laDocks || c->land == laBrownian)
|
2017-10-08 10:10:40 +00:00
|
|
|
return 30;
|
|
|
|
if(c->land != laOcean && !isGravityLand(c->land) && c->land != laHaunted) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!c->landparam) return UNKNOWN;
|
|
|
|
return c->landparam;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool checkInTree(cell *c, int maxv) {
|
2017-10-08 10:10:40 +00:00
|
|
|
if(c->landparam <= 3) return false;
|
2019-12-14 11:05:01 +00:00
|
|
|
if(!maxv && WDIM == 3 && bt::in()) {
|
2019-03-23 21:25:35 +00:00
|
|
|
forCellEx(c2, c) if(c2->landflags) return true;
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
if(!maxv) return false;
|
|
|
|
if(c->landflags) return true;
|
2019-03-23 21:25:35 +00:00
|
|
|
forCellEx(c2, c)
|
|
|
|
if(c2->landparam < c->landparam && checkInTree(c2, maxv-1))
|
2017-10-08 10:10:40 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-30 14:08:05 +00:00
|
|
|
int loopval = 0;
|
|
|
|
|
|
|
|
struct loopchecker {
|
|
|
|
loopchecker() { loopval++; }
|
|
|
|
~loopchecker() { loopval--; }
|
|
|
|
};
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void buildEquidistant(cell *c) {
|
2018-08-30 14:08:05 +00:00
|
|
|
loopchecker lc;
|
|
|
|
// sometimes crashes in Archimedean
|
|
|
|
if(loopval > 100) { c->landparam = 0; return; }
|
2017-10-08 10:10:40 +00:00
|
|
|
if(!c) return;
|
|
|
|
if(c->landparam) return;
|
2018-04-03 22:08:17 +00:00
|
|
|
/* if(weirdhyperbolic) {
|
2017-10-30 09:29:15 +00:00
|
|
|
c->landparam = 50;
|
|
|
|
return;
|
2018-04-03 22:08:17 +00:00
|
|
|
} */
|
2018-04-11 15:44:46 +00:00
|
|
|
if(sphere || euclid) return;
|
2017-10-08 10:10:40 +00:00
|
|
|
eLand b = c->land;
|
|
|
|
if(chaosmode && !inmirror(b)) return;
|
|
|
|
if(!b) {
|
2020-02-23 02:48:46 +00:00
|
|
|
printf("land missing at %p\n", hr::voidp(c));
|
2017-10-08 10:10:40 +00:00
|
|
|
describeCell(c);
|
2018-08-17 22:46:45 +00:00
|
|
|
for(int i=0; i<c->type; i++) if(c->move(i))
|
|
|
|
describeCell(c->move(i));
|
2017-10-08 10:10:40 +00:00
|
|
|
// buggycells.push_back(c);
|
|
|
|
}
|
|
|
|
if(b == laHauntedBorder) b = laGraveyard;
|
|
|
|
if(inmirror(b)) b = laMirrored;
|
|
|
|
int mcv = UNKNOWN;
|
|
|
|
|
|
|
|
// find the lowest coastval
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
int cv = coastval(createMov(c,i), b);
|
|
|
|
if(cv < mcv) mcv = cv;
|
|
|
|
}
|
2019-10-10 11:09:31 +00:00
|
|
|
|
|
|
|
if(S3 == OINF) {
|
|
|
|
c->landparam = mcv + 1;
|
|
|
|
return;
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
|
|
|
|
int mcv2 = 0;
|
|
|
|
|
|
|
|
if(mcv == 0) {
|
|
|
|
// if(generatingEquidistant) printf("mcv=0\n");
|
|
|
|
c->landparam = 1;
|
|
|
|
}
|
2019-05-08 16:33:08 +00:00
|
|
|
else if(WDIM == 3) {
|
2019-03-23 15:27:27 +00:00
|
|
|
forCellCM(c2, c) if(coastval(c2, b) == mcv)
|
|
|
|
forCellEx(c3, c2) if(coastval(c3, b) < mcv)
|
|
|
|
forCellCM(c4, c3) {
|
|
|
|
if(c4->land == laNone && c2->mpdist <= BARLEV) setdist(c4, BARLEV, c2);
|
|
|
|
buildEquidistant(c4);
|
|
|
|
}
|
|
|
|
forCellCM(c2, c) {
|
|
|
|
int cv = coastval(c2, b);
|
|
|
|
if(cv < mcv) mcv = cv;
|
|
|
|
}
|
|
|
|
c->landparam = mcv + 1;
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
else {
|
|
|
|
// if it appears twice, increase it
|
|
|
|
int qcv = 0;
|
|
|
|
int sid = 0;
|
|
|
|
for(int i=0; i<c->type; i++)
|
2018-08-17 22:46:45 +00:00
|
|
|
if(coastval(c->move(i), b) == mcv)
|
2017-10-08 10:10:40 +00:00
|
|
|
qcv++, sid = i;
|
|
|
|
|
|
|
|
// if(generatingEquidistant) printf("qcv=%d mcv=%d\n", qcv, mcv);
|
|
|
|
if(qcv >= 2) c->landparam = mcv+1; // (mcv == UNKNOWN ? UNKNOWN : mcv+1);
|
|
|
|
else {
|
|
|
|
// if(qcv != 1) { printf("qcv = %d\n", qcv); exit(1); }
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = c->move(sid);
|
|
|
|
int bsid = c->c.spin(sid);
|
2020-01-18 15:03:32 +00:00
|
|
|
for(int j=0; j<c2->type; j++) {
|
|
|
|
int q = gmod(bsid+j, c2->type);
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c3 = c2->move(q);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(coastval(c3, b) < mcv) {
|
2019-08-09 12:29:08 +00:00
|
|
|
cell *c4 = c2->cmodmove(bsid+1);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(c4->land == laNone && c2->mpdist <= BARLEV) setdist(c4, BARLEV, c2);
|
|
|
|
buildEquidistant(c4);
|
|
|
|
mcv2 = coastval(c4, b);
|
|
|
|
break;
|
|
|
|
}
|
2020-01-18 15:03:32 +00:00
|
|
|
q = gmod(bsid-j, c2->type);
|
2018-08-17 22:46:45 +00:00
|
|
|
c3 = c2->move(q);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(coastval(c3, b) < mcv) {
|
2019-08-09 12:29:08 +00:00
|
|
|
cell *c4 = c2->cmodmove(bsid-1);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(c4->land == laNone && c2->mpdist <= BARLEV) setdist(c4, BARLEV, c2);
|
|
|
|
buildEquidistant(c4);
|
|
|
|
mcv2 = coastval(c4, b);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(mcv2 > mcv) mcv2 = mcv;
|
|
|
|
if(mcv2 == 0) mcv2 = mcv;
|
|
|
|
c->landparam = mcv2+1;
|
|
|
|
|
|
|
|
/* if(c->heat < 3)
|
|
|
|
raiseBuggyGeneration(c, "low heat"); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!c->landparam) {
|
|
|
|
// int z = int(c->heat);
|
|
|
|
if(c->item || c->monst)
|
|
|
|
printf("building coast over %s/%s, mpdist = %d\n", iinf[c->item].name, minf[c->monst].name,
|
|
|
|
c->mpdist);
|
|
|
|
if(c->land == laOcean) c->wall = waSea;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c->land == laEndorian) {
|
2018-08-22 11:41:01 +00:00
|
|
|
int ct = c->type;
|
2019-05-06 23:08:49 +00:00
|
|
|
#if CAP_BT
|
2019-12-14 11:05:01 +00:00
|
|
|
if(bt::in()) {
|
2019-03-23 21:25:35 +00:00
|
|
|
int skip = geometry == gHoroRec ? 3 : 2;
|
2019-12-14 11:05:01 +00:00
|
|
|
int up = bt::updir();
|
2019-03-23 21:25:35 +00:00
|
|
|
if(c->landparam == 1)
|
|
|
|
c->landflags = (hrand(100) < 20);
|
2019-12-14 11:05:01 +00:00
|
|
|
else if(WDIM == 2 && c->type == 6 && (c->landparam % 2) && c->move(bt::bd_down) && c->move(bt::bd_down)->landflags)
|
2019-03-23 21:25:35 +00:00
|
|
|
c->landflags = 1;
|
2019-05-08 16:33:08 +00:00
|
|
|
else if(WDIM == 2 && c->type == 7 && (c->landparam % 2 == 0)) {
|
2019-12-14 11:05:01 +00:00
|
|
|
for(int d: {bt::bd_down_left, bt::bd_down_right})
|
2019-03-23 21:25:35 +00:00
|
|
|
if(c->move(d) && c->move(d)->landflags)
|
|
|
|
c->landflags = 1;
|
|
|
|
}
|
2019-07-25 21:06:09 +00:00
|
|
|
else if(WDIM == 3 && c->landparam % skip != 1 && c->move(up) && c->move(up)->landflags)
|
2019-03-23 21:25:35 +00:00
|
|
|
c->landflags = 1;
|
2019-07-25 21:06:09 +00:00
|
|
|
else if(WDIM == 3 && c->landparam % skip == 1 && c->move(up) && c->move(up)->c.spin(up) == (c->c.spin(up)) && c->move(up)->move(up)->landflags)
|
2019-03-23 21:25:35 +00:00
|
|
|
c->landflags = 1;
|
2019-05-08 16:33:08 +00:00
|
|
|
if(c->landflags) c->wall = (WDIM == 3 ? waTrunk3 : waTrunk);
|
2019-03-23 21:25:35 +00:00
|
|
|
}
|
2019-05-06 23:08:49 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#if MAXMDIM >= 4
|
2019-05-08 16:33:08 +00:00
|
|
|
if(WDIM == 3 && hyperbolic) {
|
2019-03-23 21:25:35 +00:00
|
|
|
if(c->landparam == 1)
|
|
|
|
c->landflags = (hrand(100) < 20);
|
|
|
|
else if(S7 == 12) {
|
|
|
|
for(int i=0; i<S7; i++) {
|
|
|
|
cellwalker cw(c, i);
|
|
|
|
if(!cw.peek()) continue;
|
|
|
|
cw += wstep;
|
|
|
|
if(cw.at->landparam != c->landparam-1) continue;
|
|
|
|
if(!cw.at->landflags) continue;
|
|
|
|
if(S7 == 6) c->landflags = 1;
|
2020-04-05 08:53:34 +00:00
|
|
|
else for(int j=0; j<S7; j++) if(cw.at->move(j) && cw.at->move(j)->landparam == c->landparam - 2 && !cgi.dirs_adjacent[j][cw.spin])
|
2019-03-23 21:25:35 +00:00
|
|
|
if(c->landparam == 2 ? cw.at->move(j)->land != laEndorian : cw.at->move(j)->landparam)
|
|
|
|
c->landflags = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(c->landparam == 2) {
|
|
|
|
for(int i=0; i<S7; i++) {
|
|
|
|
cellwalker cw(c, i);
|
|
|
|
if(!cw.peek()) continue;
|
|
|
|
cw += wstep;
|
|
|
|
if(cw.at->landparam != 1) continue;
|
|
|
|
if(!cw.at->landflags) continue;
|
|
|
|
cw += rev;
|
|
|
|
if(cw.peek() && cw.peek()->land != laEndorian) c->landflags = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(c->landparam % 2 == 1) {
|
|
|
|
for(int i=0; i<S7; i++) {
|
|
|
|
cellwalker cw(c, i);
|
|
|
|
if(!cw.peek()) continue;
|
|
|
|
cw += wstep;
|
|
|
|
if(cw.at->landparam != c->landparam-1) continue;
|
|
|
|
if(!cw.at->landflags) continue;
|
|
|
|
if(S7 == 6) c->landflags = 1;
|
2020-04-05 08:53:34 +00:00
|
|
|
else for(int j=0; j<S7; j++) if(cw.at->move(j) && cw.at->move(j)->landparam == c->landparam - 2 && !cgi.dirs_adjacent[j][cw.spin] && cw.at->move(j)->landflags)
|
2019-03-23 21:25:35 +00:00
|
|
|
c->landflags = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for(int i=0; i<S7; i++) {
|
|
|
|
cellwalker cw(c, i);
|
|
|
|
if(!cw.peek()) continue;
|
|
|
|
cw += wstep;
|
|
|
|
if(cw.at->landparam != c->landparam-1) continue;
|
|
|
|
if(!cw.at->landflags) continue;
|
|
|
|
cw += rev;
|
|
|
|
if(cw.peek() && cw.peek()->landflags) c->landflags = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(c->landflags) c->wall = waTrunk3;
|
|
|
|
}
|
2019-05-06 23:08:49 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if(c->landparam == 1 && ctof(c)) {
|
2018-08-22 11:41:01 +00:00
|
|
|
for(int i=0; i<ct; i++) {
|
|
|
|
int i1 = (i+1) % c->type;
|
2018-08-17 22:46:45 +00:00
|
|
|
if(c->move(i) && c->move(i)->land != laEndorian && c->move(i)->land != laNone)
|
|
|
|
if(c->move(i1) && c->move(i1)->land != laEndorian && c->move(i1)->land != laNone) {
|
2017-10-08 10:10:40 +00:00
|
|
|
c->landflags = 2;
|
|
|
|
c->wall = waTrunk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-28 23:57:34 +00:00
|
|
|
else if(c->landparam == 1 && !ctof(c)) {
|
2018-08-22 11:41:01 +00:00
|
|
|
int ct = c->type;
|
|
|
|
for(int i=0; i<ct; i++) {
|
|
|
|
int i1 = (i+1) % ct;
|
|
|
|
int i2 = (i+2) % ct;
|
|
|
|
int i4 = (i+4) % ct;
|
|
|
|
int i5 = (i+5) % ct;
|
2018-08-17 22:46:45 +00:00
|
|
|
if(c->move(i) && c->move(i)->land == laBarrier && c->move(i)->type == 7)
|
|
|
|
if(c->move(i1) && c->move(i1)->land != laBarrier)
|
|
|
|
if(c->move(i2) && c->move(i2)->land != laBarrier)
|
|
|
|
if(c->move(i4) && c->move(i4)->land != laBarrier)
|
|
|
|
if(c->move(i5) && c->move(i5)->land != laBarrier) {
|
2017-10-08 10:10:40 +00:00
|
|
|
c->landflags = 2;
|
|
|
|
c->wall = waTrunk;
|
|
|
|
}
|
|
|
|
|
2018-08-17 22:46:45 +00:00
|
|
|
if(c->move(i) && c->move(i)->land != laEndorian && c->move(i)->land != laNone && c->move(i)->type == 7)
|
|
|
|
if(c->move(i1) && c->move(i1)->land != laEndorian && c->move(i1)->land != laNone)
|
|
|
|
if(c->move(i5) && c->move(i5)->land != laEndorian && c->move(i5)->land != laNone) {
|
2017-10-08 10:10:40 +00:00
|
|
|
c->landflags = 3;
|
|
|
|
c->wall = waTrunk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(c->landparam > 1) {
|
|
|
|
for(int i=0; i<c->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = c->move(i);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(c2 && c2->landparam < c->landparam && c2->landflags) {
|
|
|
|
bool ok = false;
|
|
|
|
if(c2->landflags == 3)
|
|
|
|
ok = true;
|
|
|
|
else if(c2->landflags == 2) {
|
2018-08-17 22:46:45 +00:00
|
|
|
ok = c->modmove(i+1)->landparam != c->landparam-1
|
|
|
|
&& c->modmove(i-1)->landparam != c->landparam-1;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
else for(int j=0; j<c2->type; j++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c3 = c2->move(j);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(c3 && c3->landparam < c2->landparam && c3->landflags)
|
2018-08-17 22:46:45 +00:00
|
|
|
if(c->c.spin(i) == (j+3)%c2->type || c->c.spin(i) == (j+c2->type-3)%c2->type)
|
2017-10-08 10:10:40 +00:00
|
|
|
ok = true;
|
|
|
|
}
|
|
|
|
if(ok) {
|
|
|
|
c->wall = waTrunk;
|
|
|
|
c->landflags = 1;
|
|
|
|
}
|
|
|
|
}
|
2017-10-29 13:21:42 +00:00
|
|
|
if(c2 && c2->landparam < c->landparam && c2->landflags == 1 && ctof(c)) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c3 = c->modmove(i+1);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(c3 && c3->landparam < c->landparam && c3->landflags == 1) {
|
|
|
|
c->wall = waTrunk;
|
|
|
|
c->landflags = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-23 21:25:35 +00:00
|
|
|
}
|
|
|
|
if(!c->landflags && checkInTree(c, 5)) {
|
|
|
|
int lev = hrand(100);
|
|
|
|
if(lev < 10) c->wall = waSolidBranch;
|
|
|
|
else if(lev < 20) c->wall = waWeakBranch;
|
|
|
|
else c->wall = waCanopy;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-11 21:37:28 +00:00
|
|
|
bool chance = true;
|
|
|
|
if(weirdhyperbolic) {
|
|
|
|
chance = false;
|
|
|
|
if(specialland == laCrossroads4)
|
|
|
|
chance = hrand(100) < 10;
|
|
|
|
}
|
|
|
|
|
2019-08-24 12:07:46 +00:00
|
|
|
if(c->landparam > 30 && b == laOcean && !generatingEquidistant && !hybri && hrand(10) < 5 && chance)
|
2017-10-08 10:10:40 +00:00
|
|
|
buildAnotherEquidistant(c);
|
|
|
|
|
2019-11-15 10:17:10 +00:00
|
|
|
if(c->landparam > HAUNTED_RADIUS+5 && b == laGraveyard && !generatingEquidistant && !hybri && hrand(100) < (PURE?25:5) && items[itBone] >= U10 && chance)
|
2017-10-08 10:10:40 +00:00
|
|
|
buildAnotherEquidistant(c);
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX cell *randomDown(cell *c) {
|
2020-01-18 15:03:32 +00:00
|
|
|
vector<cell*> tab;
|
2017-10-08 10:10:40 +00:00
|
|
|
for(int i=0; i<c->type; i++)
|
2018-08-17 22:46:45 +00:00
|
|
|
if(c->move(i) && coastval(c->move(i), laIvoryTower) < coastval(c, laIvoryTower))
|
2020-01-18 15:03:32 +00:00
|
|
|
tab.push_back(c->move(i));
|
|
|
|
if(isize(tab)==1) return tab[0];
|
|
|
|
return hrand_elt(tab, (cell*)nullptr);
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int edgeDepth(cell *c) {
|
2018-12-21 13:41:23 +00:00
|
|
|
if(c->land == laIvoryTower || c->land == laEndorian || c->land == laDungeon || c->land == laWestWall)
|
2017-10-08 10:10:40 +00:00
|
|
|
return coastvalEdge(c);
|
|
|
|
else if(c->land != laBarrier) {
|
2018-08-17 22:46:45 +00:00
|
|
|
for(int i=0; i<c->type; i++) if(c->move(i) && c->move(i)->land == laBarrier)
|
2017-10-08 10:10:40 +00:00
|
|
|
return -20+c->cpdist;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int getHauntedDepth(cell *c) {
|
2017-10-08 10:10:40 +00:00
|
|
|
if((tactic::on || euclid) && c->land == laHaunted) return celldist(c);
|
|
|
|
if(c->land == laHaunted) return c->landparam;
|
|
|
|
if(c->land == laHauntedWall) return 0;
|
|
|
|
if(c->land == laHauntedBorder || c->land == laGraveyard) return -c->landparam;
|
|
|
|
return -100;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int towerval(cell *c, const cellfunction& cf) {
|
2018-09-27 19:52:13 +00:00
|
|
|
cell *cp1 = ts::left_of(c, cf);
|
|
|
|
if(!cp1) return 0;
|
2017-10-08 10:10:40 +00:00
|
|
|
int under = 0;
|
2018-09-27 19:52:13 +00:00
|
|
|
int cfc = cf(c);
|
|
|
|
forCellEx(c2, c) if(cf(c2) < cfc) under++;
|
2017-10-08 10:10:40 +00:00
|
|
|
return (c->type-6) + 2*(cp1->type-6) + 4*under;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* other geometries */
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void setLandWeird(cell *c) {
|
2018-04-03 22:08:17 +00:00
|
|
|
// replaced with standard CR4
|
|
|
|
/* if(specialland == laIvoryTower || specialland == laEndorian || specialland == laDungeon || specialland == laOcean) {
|
2017-10-30 18:12:33 +00:00
|
|
|
int d = celldist(c) - (getDistLimit() - 2);
|
|
|
|
if(d <= 0)
|
|
|
|
c->land = laCrossroads4;
|
|
|
|
else
|
|
|
|
c->land = specialland, c->landparam = d;
|
2018-04-03 22:08:17 +00:00
|
|
|
} */
|
2017-10-30 18:12:33 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void setLandQuotient(cell *c) {
|
2019-02-06 15:33:14 +00:00
|
|
|
setland(c, specialland);
|
2017-10-08 10:10:40 +00:00
|
|
|
int fv = zebra40(c);
|
|
|
|
if(fv/4 == 4 || fv/4 == 6 || fv/4 == 5 || fv/4 == 10) fv ^= 2;
|
|
|
|
if(specialland == laWarpCoast)
|
|
|
|
if(fv%4==0 || fv%4 == 2) setland(c, laWarpSea);
|
|
|
|
if(specialland == laElementalWall)
|
|
|
|
setland(c, eLand(laEFire + (fv%4)));
|
2018-04-14 08:24:02 +00:00
|
|
|
if(specialland == laClearing)
|
|
|
|
c->land = laClearing;
|
2017-10-30 18:12:33 +00:00
|
|
|
if(specialland == laIvoryTower || specialland == laEndorian || specialland == laDungeon || specialland == laOcean) {
|
|
|
|
int d = celldist(c) - 1;
|
|
|
|
if(d <= 0)
|
|
|
|
c->land = laCrossroads4;
|
|
|
|
else
|
|
|
|
c->land = specialland, c->landparam = d;
|
|
|
|
}
|
2019-01-28 20:38:42 +00:00
|
|
|
if(specialland == laWestWall) c->land = laCrossroads4;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void elementalXY(cell *c, int x, int y, bool make_wall) {
|
2019-08-06 18:56:37 +00:00
|
|
|
if(x > 0 && y > 0) setland(c, laEFire);
|
|
|
|
else if(x > 0 && y < 0) setland(c, laEAir);
|
|
|
|
else if(x < 0 && y < 0) setland(c, laEWater);
|
|
|
|
else if(x < 0 && y > 0) setland(c, laEEarth);
|
|
|
|
else if(x > 0)
|
|
|
|
c->land = laElementalWall, c->barleft = laEAir, c->barright = laEFire;
|
|
|
|
else if(x < 0)
|
|
|
|
c->land = laElementalWall, c->barleft = laEEarth, c->barright = laEWater;
|
|
|
|
else if(y > 0)
|
|
|
|
c->land = laElementalWall, c->barleft = laEEarth, c->barright = laEFire;
|
|
|
|
else if(y < 0)
|
|
|
|
c->land = laElementalWall, c->barleft = laEAir, c->barright = laEWater;
|
|
|
|
if(x == 0 && y == 0)
|
|
|
|
c->land = laElementalWall, c->wall = waBarrier;
|
|
|
|
else if(c->land == laElementalWall && make_wall)
|
|
|
|
c->wall = getElementalWall(hrand(2) ? c->barleft : c->barright);
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void setLandSphere(cell *c) {
|
2019-02-06 15:33:14 +00:00
|
|
|
setland(c, specialland);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(specialland == laWarpCoast)
|
|
|
|
setland(c, getHemisphere(c, 0) > 0 ? laWarpCoast : laWarpSea);
|
2019-01-28 20:38:42 +00:00
|
|
|
if(specialland == laWestWall) c->land = laCrossroads4;
|
2018-04-14 08:24:02 +00:00
|
|
|
if(specialland == laClearing)
|
|
|
|
c->land = laClearing;
|
2017-10-08 10:10:40 +00:00
|
|
|
if(specialland == laElementalWall) {
|
|
|
|
int x = getHemisphere(c, 1);
|
|
|
|
int y = getHemisphere(c, 2);
|
2019-08-06 18:56:37 +00:00
|
|
|
elementalXY(c, x, y, (c->type != 6 || GOLDBERG));
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
2019-11-27 00:01:20 +00:00
|
|
|
if(!(euclid && quotient))
|
2017-11-03 20:12:59 +00:00
|
|
|
if(specialland == laCrossroads || specialland == laCrossroads2 || specialland == laCrossroads3 || specialland == laTerracotta) {
|
2017-10-08 10:10:40 +00:00
|
|
|
int x = getHemisphere(c, 1);
|
2017-11-03 20:12:59 +00:00
|
|
|
if(x == 0 && specialland == laTerracotta)
|
|
|
|
setland(c, laMercuryRiver), c->wall = waMercury;
|
|
|
|
else if(x == 0 || (specialland == laCrossroads3 && getHemisphere(c, 2) == 0))
|
2017-10-08 10:10:40 +00:00
|
|
|
setland(c, laBarrier), c->wall = waBarrier;
|
|
|
|
else setland(c, specialland);
|
2018-08-28 15:17:34 +00:00
|
|
|
if(specialland == laCrossroads3 && c->type != 6 && c->master->fiftyval == 1 && !GOLDBERG)
|
2017-10-08 10:10:40 +00:00
|
|
|
c->wall = waBigTree;
|
|
|
|
}
|
2018-04-10 06:01:39 +00:00
|
|
|
if(specialland == laIvoryTower || specialland == laEndorian || specialland == laDungeon || specialland == laOcean || specialland == laMountain) {
|
2017-10-30 18:12:33 +00:00
|
|
|
int d = celldist(c);
|
|
|
|
if(d <= 0)
|
|
|
|
c->land = laCrossroads4;
|
|
|
|
else
|
|
|
|
c->land = specialland, c->landparam = d;
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
2019-05-30 14:12:38 +00:00
|
|
|
vector<eLand> euland;
|
2019-04-11 22:17:50 +00:00
|
|
|
map<int, eLand> euland3;
|
|
|
|
map<int, eLand> euland3_hash;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX eLand& get_euland(int c) {
|
2019-05-30 14:12:38 +00:00
|
|
|
euland.resize(max_vec);
|
2017-12-28 15:46:10 +00:00
|
|
|
return euland[c & (max_vec-1)];
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void clear_euland(eLand first) {
|
2019-05-30 14:12:38 +00:00
|
|
|
euland.resize(max_vec);
|
2017-12-28 15:46:10 +00:00
|
|
|
for(int i=0; i<max_vec; i++) euland[i] = laNone;
|
2019-09-10 07:21:46 +00:00
|
|
|
if(!nonisotropic && !hybri) euland[0] = euland[1] = euland[max_vec-1] = first;
|
2019-04-11 22:17:50 +00:00
|
|
|
euland3.clear();
|
|
|
|
euland3[0] = laCrossroads;
|
2017-12-28 15:46:10 +00:00
|
|
|
}
|
|
|
|
|
2019-07-25 21:07:36 +00:00
|
|
|
bool valid_wall_at(int c) {
|
2019-09-10 07:21:46 +00:00
|
|
|
if(nonisotropic || hybri) return true;
|
2019-07-25 21:07:36 +00:00
|
|
|
return short(c) % 3 == 0;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX eLand switchable(eLand nearland, eLand farland, int c) {
|
2018-11-27 18:44:15 +00:00
|
|
|
if(chaosmode) {
|
|
|
|
if(hrand(6) == 0)
|
|
|
|
return getNewLand(nearland);
|
|
|
|
return nearland;
|
|
|
|
}
|
|
|
|
else if(specialland == laCrossroads4) {
|
2019-05-30 15:46:56 +00:00
|
|
|
if((dual::state && nearland == laCrossroads4) || hrand(15) == 0)
|
2017-10-08 10:10:40 +00:00
|
|
|
return getNewLand(nearland);
|
2019-09-10 07:21:46 +00:00
|
|
|
if(nearland == laCrossroads4 && (nonisotropic || hybri))
|
2019-08-06 18:59:43 +00:00
|
|
|
return getNewLand(nearland);
|
2017-10-08 10:10:40 +00:00
|
|
|
return nearland;
|
|
|
|
}
|
2019-08-06 18:59:43 +00:00
|
|
|
else if(nearland == laCrossroads && nonisotropic) {
|
2019-07-28 09:07:54 +00:00
|
|
|
return laBarrier;
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
else if(nearland == laCrossroads) {
|
2019-07-25 21:07:36 +00:00
|
|
|
if(hrand(4) == 0 && valid_wall_at(c))
|
2017-10-08 10:10:40 +00:00
|
|
|
return laBarrier;
|
|
|
|
return laCrossroads;
|
|
|
|
}
|
|
|
|
else if(nearland == laBarrier) {
|
|
|
|
return getNewLand(farland);
|
|
|
|
}
|
|
|
|
else {
|
2019-07-25 21:07:36 +00:00
|
|
|
if(hrand(20) == 0 && valid_wall_at(c))
|
2017-10-08 10:10:40 +00:00
|
|
|
return laBarrier;
|
|
|
|
return nearland;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX eLand getEuclidLand(int c) {
|
2018-11-27 20:17:00 +00:00
|
|
|
if(nonorientable && c < 0) c = -c;
|
2017-12-28 15:46:10 +00:00
|
|
|
auto& la = get_euland(c);
|
|
|
|
if(la) return la;
|
|
|
|
if(get_euland(c-2) && !get_euland(c-1)) getEuclidLand(c-1);
|
|
|
|
if(get_euland(c-1)) return
|
|
|
|
la = switchable(get_euland(c-1), get_euland(c-2), c);
|
|
|
|
if(get_euland(c+2) && !get_euland(c+1)) getEuclidLand(c+1);
|
|
|
|
if(get_euland(c+1)) return
|
|
|
|
la = switchable(get_euland(c+1), get_euland(c+2), c);
|
|
|
|
return la = laCrossroads;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void setLandSol(cell *c) {
|
2019-07-25 21:07:36 +00:00
|
|
|
setland(c, specialland);
|
2019-08-06 18:56:58 +00:00
|
|
|
if(chaosmode) {
|
|
|
|
setland(c, getEuclidLand(c->master->distance));
|
|
|
|
return;
|
|
|
|
}
|
2019-07-25 21:07:36 +00:00
|
|
|
switch(specialland) {
|
|
|
|
case laCrossroads4: case laCrossroads: case laCrossroads2:
|
|
|
|
setland(c, getEuclidLand(c->master->distance));
|
|
|
|
if(c->land == laBarrier && c->master->emeraldval % 3) c->wall = waBarrier;
|
|
|
|
break;
|
|
|
|
case laTerracotta:
|
|
|
|
if((c->master->distance & 15) == 1) {
|
|
|
|
setland(c, laMercuryRiver);
|
|
|
|
if(c->master->emeraldval % 3) c->wall = waMercury;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case laOcean: case laIvoryTower: case laEndorian: case laDungeon:
|
|
|
|
if(c->master->distance <= 0) setland(c, laRlyeh);
|
|
|
|
else c->landparam = c->master->distance;
|
|
|
|
break;
|
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-24 12:07:46 +00:00
|
|
|
EX void setLandHybrid(cell *c) {
|
2019-09-12 12:24:02 +00:00
|
|
|
if(in_s2xe() && !among(specialland, laElementalWall)) {
|
2019-09-10 07:21:46 +00:00
|
|
|
auto w = hybrid::get_where(c);
|
|
|
|
auto d = w.second;
|
|
|
|
|
|
|
|
setland(c, specialland);
|
|
|
|
if(chaosmode) {
|
|
|
|
setland(c, getEuclidLand(c->master->distance));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool ps = PIU(pseudohept(w.first));
|
|
|
|
switch(specialland) {
|
|
|
|
case laCrossroads4: case laCrossroads: case laCrossroads2:
|
|
|
|
setland(c, getEuclidLand(d));
|
|
|
|
if(c->land == laBarrier) c->wall = ps ? waNone : waBarrier;
|
|
|
|
break;
|
|
|
|
case laTerracotta:
|
|
|
|
if((d & 15) == 1) {
|
|
|
|
setland(c, laMercuryRiver);
|
|
|
|
c->wall = ps ? waNone : waMercury;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case laOcean: case laIvoryTower: case laEndorian: case laDungeon:
|
|
|
|
if(d < 0) setland(c, laCrossroads);
|
|
|
|
else if(d == 0) {
|
|
|
|
setland(c, laBarrier); c->wall = ps ? waNone : waBarrier;
|
|
|
|
}
|
|
|
|
else c->landparam = d;
|
|
|
|
break;
|
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 12:07:46 +00:00
|
|
|
auto wc = hybrid::get_where(c).first;
|
2019-08-18 13:32:46 +00:00
|
|
|
c->barleft = wc->barleft;
|
|
|
|
c->barright = wc->barright;
|
|
|
|
c->bardir = wc->bardir;
|
|
|
|
if(wc->land) setland(c, wc->land);
|
|
|
|
if(among(wc->wall, waBarrier, waMercury) || wc->land == laElementalWall)
|
|
|
|
c->wall = wc->wall;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void setLandNil(cell *c) {
|
2019-08-06 18:59:43 +00:00
|
|
|
setland(c, specialland);
|
|
|
|
|
|
|
|
if(chaosmode) {
|
|
|
|
int hash = (((c->master->zebraval + 4) >> 3) << 16) + ((c->master->emeraldval + 4) >> 3);
|
|
|
|
auto& l = euland3_hash[hash];
|
|
|
|
if(l == laNone) l = getNewLand(laNone);
|
|
|
|
setland(c, l);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(specialland) {
|
|
|
|
case laCrossroads: case laCrossroads4:
|
|
|
|
setland(c, getEuclidLand(c->master->zebraval));
|
|
|
|
if(c->land == laBarrier && c->master->emeraldval % 3) c->wall = waBarrier;
|
|
|
|
break;
|
|
|
|
case laCrossroads2:
|
|
|
|
setland(c, getEuclidLand(c->master->emeraldval));
|
|
|
|
if(c->land == laBarrier && c->master->zebraval % 3) c->wall = waBarrier;
|
|
|
|
break;
|
|
|
|
case laCrossroads3: {
|
|
|
|
int ox = c->master->zebraval - 8;
|
|
|
|
int oy = c->master->emeraldval - 8;
|
|
|
|
int hash = (((ox + 16) >> 5) << 16) + ((oy + 16) >> 5);
|
|
|
|
auto& l = euland3_hash[hash];
|
|
|
|
if(l == laNone) l = getNewLand(laCrossroads3);
|
|
|
|
if(ox % 16 == 0) setland(c, laBarrier);
|
|
|
|
else if(oy % 16 == 0) setland(c, laBarrier);
|
|
|
|
else setland(c, l);
|
|
|
|
if(c->land == laBarrier && ((c->master->zebraval & 3) || (c->master->emeraldval & 3))) c->wall = waBarrier;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case laElementalWall: {
|
|
|
|
int ox = c->master->zebraval - 4;
|
|
|
|
int oy = c->master->emeraldval - 4;
|
|
|
|
int x = (ox & 7) ? ((ox & 8) ? 1 : -1) : 0;
|
|
|
|
int y = (oy & 7) ? ((oy & 8) ? 1 : -1) : 0;
|
|
|
|
elementalXY(c, x, y, (ox & 3) || (oy & 3));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case laTerracotta:
|
|
|
|
if((c->master->zebraval & 7) == 4 && (c->master->emeraldval & 7) == 4) {
|
|
|
|
setland(c, laMercuryRiver);
|
|
|
|
c->wall = waMercury;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case laOcean: case laIvoryTower: case laEndorian: case laDungeon:
|
|
|
|
if(c->master->zebraval <= 0) setland(c, laRlyeh);
|
|
|
|
else c->landparam = c->master->zebraval;
|
|
|
|
break;
|
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void setLandEuclid(cell *c) {
|
2018-11-18 00:42:00 +00:00
|
|
|
#if CAP_RACING
|
|
|
|
if(racing::track_ready) {
|
|
|
|
setland(c, laMemory);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2017-10-08 10:10:40 +00:00
|
|
|
setland(c, specialland);
|
2018-11-27 20:39:04 +00:00
|
|
|
if(specialland == laCrossroads4 || chaosmode) {
|
2019-11-30 17:47:43 +00:00
|
|
|
auto co = euc2_coordinates(c);
|
|
|
|
int y = co.second;
|
2018-11-27 20:39:04 +00:00
|
|
|
c->land = getEuclidLand(y);
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
if(specialland == laCrossroads) {
|
2019-11-30 17:47:43 +00:00
|
|
|
auto co = euc2_coordinates(c);
|
|
|
|
int x = co.first, y = co.second;
|
2017-10-08 10:10:40 +00:00
|
|
|
setland(c, getEuclidLand(y+2*x));
|
|
|
|
}
|
2017-11-03 20:12:59 +00:00
|
|
|
if(specialland == laTerracotta) {
|
2019-11-30 17:47:43 +00:00
|
|
|
auto co = euc2_coordinates(c);
|
|
|
|
int x = co.first, y = co.second;
|
2017-12-28 15:46:10 +00:00
|
|
|
if(((y+2*x) & 15) == 1) {
|
2017-11-03 20:12:59 +00:00
|
|
|
setland(c, laMercuryRiver);
|
|
|
|
c->wall = waMercury;
|
|
|
|
}
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
if(specialland == laWhirlpool) {
|
|
|
|
c->land = laOcean;
|
|
|
|
c->landparam = 99;
|
|
|
|
}
|
|
|
|
if(specialland == laPrincessQuest) setland(c, laPalace);
|
|
|
|
if(specialland == laOcean) {
|
2019-11-30 17:47:43 +00:00
|
|
|
auto co = euc2_coordinates(c);
|
|
|
|
int y = co.second;
|
2017-12-28 15:46:10 +00:00
|
|
|
y += 10;
|
2019-11-27 00:01:20 +00:00
|
|
|
if(euclid && quotient) y = -celldistAlt(c);
|
2017-12-28 15:46:10 +00:00
|
|
|
if(y == 0)
|
2017-10-08 10:10:40 +00:00
|
|
|
{ setland(c, laBarrier); if(ishept(c)) c->land = laRlyeh; }
|
2017-12-28 15:46:10 +00:00
|
|
|
else if(y<0) setland(c, laRlyeh);
|
|
|
|
else c->landparam = y;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
2019-01-28 20:38:42 +00:00
|
|
|
if(specialland == laWestWall) {
|
2019-11-30 17:47:43 +00:00
|
|
|
auto co = euc2_coordinates(c);
|
|
|
|
int x = co.first;
|
2019-01-28 20:38:42 +00:00
|
|
|
x = -5 - x;
|
|
|
|
if(x == 0)
|
|
|
|
{setland(c, laBarrier); if(ishept(c)) setland(c, laMotion); }
|
|
|
|
else if(x<0) setland(c, laMotion);
|
|
|
|
else c->landparam = x;
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
if(specialland == laIvoryTower || specialland == laDungeon) {
|
2019-11-30 17:47:43 +00:00
|
|
|
auto co = euc2_coordinates(c);
|
|
|
|
int y = co.second;
|
|
|
|
y = -5 - y;
|
2017-12-29 13:20:38 +00:00
|
|
|
if(specialland == laDungeon) y = -10 - y;
|
2019-11-27 00:01:20 +00:00
|
|
|
if(euclid && quotient) y = -celldistAlt(c);
|
2017-12-28 15:46:10 +00:00
|
|
|
if(y == 0)
|
2017-10-08 10:10:40 +00:00
|
|
|
{setland(c, laBarrier); if(ishept(c)) setland(c, laAlchemist); }
|
2017-12-28 15:46:10 +00:00
|
|
|
else if(y<0) setland(c, laAlchemist);
|
2017-10-08 10:10:40 +00:00
|
|
|
else {
|
2017-12-28 15:46:10 +00:00
|
|
|
c->landparam = y;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(specialland == laElementalWall) {
|
2019-11-30 17:47:43 +00:00
|
|
|
auto co = euc2_coordinates(c);
|
|
|
|
int x = co.first, y = co.second;
|
2019-12-14 10:26:03 +00:00
|
|
|
int x0 = euc::in(2,4) ? x : x + (y>>1);
|
2017-12-28 15:46:10 +00:00
|
|
|
int y0 = y;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
|
|
|
int id = 0;
|
|
|
|
if(y0&16) id += 2;
|
|
|
|
if(x0&16) id += 1;
|
|
|
|
|
|
|
|
x0 += 8; y0 += 8;
|
|
|
|
|
|
|
|
y0--; x0++;
|
|
|
|
int id2 = 0;
|
|
|
|
if(y0&16) id2 += 2;
|
|
|
|
if(x0&16) id2 += 1;
|
|
|
|
|
|
|
|
setland(c, eLand(laEFire + id));
|
|
|
|
|
|
|
|
if(((y0&15) == 15 && (x0&1)) || ((x0&15) == 0 && ((y0+1)&1))) {
|
|
|
|
if(c->land == laEFire) c->wall = waEternalFire;
|
|
|
|
if(c->land == laEWater) c->wall = waSea;
|
|
|
|
if(c->land == laEAir) c->wall = waChasm;
|
|
|
|
if(c->land == laEEarth) c->wall = waStone;
|
|
|
|
c->barright = c->land;
|
|
|
|
c->barleft = eLand(laEFire+id2);
|
|
|
|
setland(c, laElementalWall);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(specialland == laCrossroads3) {
|
2019-11-30 17:47:43 +00:00
|
|
|
auto co = euc2_coordinates(c);
|
|
|
|
int x = co.first, y = co.second;
|
2019-12-14 10:26:03 +00:00
|
|
|
int y0 = euc::in(2,4) ? 2 * y - x : y;
|
|
|
|
int x0 = euc::in(2,4) ? 2 * x + y : x + y/2;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
|
|
|
x0 += 24; y0 += 8;
|
|
|
|
|
|
|
|
int id = 0;
|
|
|
|
if(y0&16) id ^= 1;
|
|
|
|
if(x0&16) id ^= 1;
|
|
|
|
|
|
|
|
setland(c, id ? laCrossroads3 : laDesert);
|
|
|
|
|
2019-12-14 10:26:03 +00:00
|
|
|
if(euc::in(2,4) ? (!(y0&15) || !(x0&15)) : ((y0&15) == 15 && (x0&1)) || ((x0&15) == 0 && ((y0+1)&1))) {
|
2017-10-08 10:10:40 +00:00
|
|
|
setland(c, laBarrier);
|
|
|
|
c->wall = waBarrier;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(specialland == laWarpCoast) {
|
2019-11-30 17:47:43 +00:00
|
|
|
auto co = euc2_coordinates(c);
|
|
|
|
int x = co.first, y = co.second;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2017-12-28 15:46:10 +00:00
|
|
|
int zz = a4 ? x : 2*x+y + 10;
|
|
|
|
zz = gmod(zz, 30);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(zz >= 15)
|
|
|
|
setland(c, laWarpSea);
|
|
|
|
else
|
|
|
|
setland(c, laWarpCoast);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX eLand get_euland3(int x) {
|
2019-04-11 22:17:50 +00:00
|
|
|
if(euland3.count(x)) return euland3[x];
|
|
|
|
if(x > 0) return euland3[x] = getNewLand(euland3[x-1]);
|
|
|
|
if(x < 0) return euland3[x] = getNewLand(euland3[x+1]);
|
|
|
|
return euland3[x] = laCrossroads;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void set_euland3(cell *c, int co10, int co11, int alt, int hash) {
|
2019-04-11 22:17:50 +00:00
|
|
|
|
|
|
|
if(chaosmode) {
|
|
|
|
setland(c, get_euland3(gdiv(co10, 60)));
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(specialland == laCrossroads) {
|
|
|
|
eLand l1 = get_euland3(gdiv(co10, 360));
|
|
|
|
eLand l2 = get_euland3(gdiv(co10+59, 360));
|
|
|
|
if(l1 != l2 && hrand(100) < 75) setland(c, laBarrier);
|
|
|
|
else setland(c, l1);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(specialland == laCrossroads2) {
|
|
|
|
setland(c, get_euland3(alt/4));
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(specialland == laCrossroads3) {
|
|
|
|
auto& l = euland3_hash[hash];
|
|
|
|
if(l == laNone) l = getNewLand(laBarrier);
|
|
|
|
setland(c, l);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(specialland == laCrossroads4) {
|
|
|
|
setland(c, get_euland3(gdiv(co10, 360)));
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(specialland == laElementalWall) {
|
|
|
|
setland(c, eLand(laEFire + ((co10 / 240)&1?0:2) + ((co11 / 240)&1?0:1)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(specialland == laCamelot) {
|
|
|
|
setland(c, laCrossroads);
|
|
|
|
buildCamelot(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(specialland == laTerracotta) {
|
|
|
|
if(((alt&15) == 8) && hrand(100) < 90)
|
|
|
|
c->wall = waMercury;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(among(specialland, laOcean, laIvoryTower, laDungeon, laEndorian)) {
|
|
|
|
if(alt == 0)
|
|
|
|
c->land = laCrossroads4;
|
|
|
|
else if(alt > 0)
|
|
|
|
c->landparam = alt;
|
|
|
|
else
|
|
|
|
c->landparam = -alt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(specialland == laWarpCoast) {
|
|
|
|
if(gmod(co10, 240) >= 120)
|
|
|
|
c->land = laWarpSea;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-08 10:10:40 +00:00
|
|
|
// the main big stuff function
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool quickfind(eLand l) {
|
2017-10-08 10:10:40 +00:00
|
|
|
if(l == cheatdest) return true;
|
2019-05-15 16:21:32 +00:00
|
|
|
if(l == specialland && (weirdhyperbolic || specialland != laIce || cheater)) return true;
|
2017-10-08 10:10:40 +00:00
|
|
|
#if CAP_TOUR
|
|
|
|
if(tour::on && tour::quickfind(l)) return true;
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define INVLUCK (items[itOrbLuck] && inv::on)
|
|
|
|
#define I2000 (INVLUCK?600:2000)
|
|
|
|
#define I10000 (INVLUCK?3000:10000)
|
|
|
|
|
2020-04-11 18:47:14 +00:00
|
|
|
EX hookset<int(cell*, bool)> hooks_wallchance;
|
2020-03-27 18:53:59 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int wallchance(cell *c, bool deepOcean) {
|
2020-03-27 18:53:59 +00:00
|
|
|
int i = callhandlers(-1, hooks_wallchance, c, deepOcean);
|
|
|
|
if(i != -1) return i;
|
2018-01-08 22:11:29 +00:00
|
|
|
eLand l = c->land;
|
|
|
|
return
|
|
|
|
inmirror(c) ? 0 :
|
|
|
|
isGravityLand(l) ? 0 :
|
|
|
|
generatingEquidistant ? 0 :
|
|
|
|
l == laPrairie ? 0 :
|
|
|
|
(yendor::on && yendor::nexttostart) ? 10000 :
|
|
|
|
princess::challenge ? 0 :
|
|
|
|
isElemental(l) ? 4000 :
|
|
|
|
(yendor::on && (yendor::generating || !(yendor::clev().flags & YF_WALLS))) ? 0 :
|
2019-10-10 11:09:31 +00:00
|
|
|
(S3 >= OINF && l == laCrossroads) ? 2000 :
|
|
|
|
(S3 >= OINF && l == laCrossroads2) ? 2500 :
|
|
|
|
(S3 >= OINF && l == laCrossroads3) ? 3333 :
|
|
|
|
(S3 >= OINF && l == laCrossroads4) ? 5000 :
|
|
|
|
(S3 >= OINF && l == laCrossroads5) ? 10000 :
|
2018-01-08 22:11:29 +00:00
|
|
|
l == laCrossroads3 ? 10000 :
|
|
|
|
l == laCrossroads ? 5000 :
|
|
|
|
l == laCrossroads2 ? 10000 :
|
|
|
|
l == laCrossroads5 ? 10000 :
|
|
|
|
l == laCrossroads4 ? (weirdhyperbolic ? 5000 : 0) :
|
|
|
|
(l == laMirror && !yendor::generating) ? 6000 :
|
|
|
|
l == laTerracotta ? 250 :
|
2020-03-27 18:57:57 +00:00
|
|
|
tactic::on ? 0 :
|
2018-11-23 01:58:16 +00:00
|
|
|
racing::on ? 0 :
|
2018-01-08 22:11:29 +00:00
|
|
|
l == laCaribbean ? 500 :
|
|
|
|
(l == laWarpSea || l == laWarpCoast) ? 500 :
|
|
|
|
l == laStorms ? 250 :
|
|
|
|
l == laCanvas ? 0 :
|
|
|
|
l == laHaunted ? 0 :
|
|
|
|
(l == laGraveyard && !deepOcean) ? 0 :
|
2018-04-23 09:49:05 +00:00
|
|
|
// (l == laGraveyard && items[itBone] >= 10) ? 120 :
|
2018-08-28 15:17:34 +00:00
|
|
|
l == laOcean ? (deepOcean ? (PURE ? 250 : 2000) : 0) :
|
2018-01-08 22:11:29 +00:00
|
|
|
l == laDragon ? 120 :
|
|
|
|
50;
|
|
|
|
}
|
|
|
|
|
2019-08-18 13:32:46 +00:00
|
|
|
/** should we generate the horocycles in the current geometry? */
|
|
|
|
EX bool horo_ok() {
|
2020-07-12 22:53:48 +00:00
|
|
|
if(INVERSE) return false;
|
2020-08-02 11:01:55 +00:00
|
|
|
return hyperbolic && !bt::in() && !arcm::in() && !kite::in() && !experimental && !hybri && !arb::in();
|
2018-04-06 21:18:40 +00:00
|
|
|
}
|
2018-04-11 21:37:28 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool gp_wall_test() {
|
2019-02-17 17:28:20 +00:00
|
|
|
#if CAP_GP
|
2018-08-28 15:17:34 +00:00
|
|
|
if(GOLDBERG) return hrand(gp::dist_3()) == 0;
|
2019-02-17 17:28:20 +00:00
|
|
|
#endif
|
|
|
|
#if CAP_IRR
|
2018-08-28 15:17:34 +00:00
|
|
|
if(IRREGULAR) return hrand(irr::cellcount * 3) < isize(irr::cells_of_heptagon);
|
2019-02-17 17:28:20 +00:00
|
|
|
#endif
|
2018-04-11 21:37:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-03-09 22:56:12 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool deep_ocean_at(cell *c, cell *from) {
|
2019-03-09 22:56:12 +00:00
|
|
|
|
|
|
|
if(generatingEquidistant) return false;
|
2017-10-28 23:57:34 +00:00
|
|
|
|
2018-04-11 21:37:28 +00:00
|
|
|
if(c->land == laOcean) {
|
2019-03-09 22:56:12 +00:00
|
|
|
if(!from) return true;
|
2018-04-11 21:37:28 +00:00
|
|
|
else for(int i=0; i<from->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = from->move(i);
|
2018-04-11 21:37:28 +00:00
|
|
|
if(c2 && c2->land == laOcean && c2->landparam > 30) {
|
2019-03-09 22:56:12 +00:00
|
|
|
return true;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
2018-04-11 21:37:28 +00:00
|
|
|
if(c2) forCellEx(c3, c2) if(c3 && c3->land == laOcean && c3->landparam > 30)
|
2019-03-09 22:56:12 +00:00
|
|
|
return true;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
2018-04-11 21:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(c->land == laGraveyard) {
|
2019-03-09 22:56:12 +00:00
|
|
|
if(!from) return true;
|
2018-04-11 21:37:28 +00:00
|
|
|
else for(int i=0; i<from->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = from->move(i);
|
2018-04-11 21:37:28 +00:00
|
|
|
if(c2 && c2->landparam > HAUNTED_RADIUS+5)
|
2019-03-09 22:56:12 +00:00
|
|
|
return true;
|
2018-04-23 09:49:05 +00:00
|
|
|
if(c2) forCellEx(c3, c2) if(c3 && c3->land == laGraveyard && c3->landparam > HAUNTED_RADIUS+5)
|
2019-03-09 22:56:12 +00:00
|
|
|
return true;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-09 22:56:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool good_for_wall(cell *c) {
|
2019-12-14 10:42:16 +00:00
|
|
|
if(arcm::in()) return true;
|
2019-05-08 16:33:08 +00:00
|
|
|
if(WDIM == 3) return true;
|
2020-07-12 22:53:48 +00:00
|
|
|
if(INVERSE) return true;
|
2019-03-13 14:26:01 +00:00
|
|
|
return pseudohept(c);
|
|
|
|
}
|
2019-10-12 11:47:41 +00:00
|
|
|
|
|
|
|
EX bool walls_not_implemented() {
|
|
|
|
return WDIM == 3 && (cgflags & qIDEAL);
|
|
|
|
}
|
2019-03-09 22:56:12 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void buildBigStuff(cell *c, cell *from) {
|
2019-12-14 11:12:24 +00:00
|
|
|
if(sphere || quotient || nonisotropic || (kite::in() && !bt::in()) || experimental) return;
|
2019-05-27 05:17:39 +00:00
|
|
|
if(chaosmode > 1) return;
|
2019-03-09 22:56:12 +00:00
|
|
|
bool deepOcean = deep_ocean_at(c, from);
|
|
|
|
|
2018-04-11 21:37:28 +00:00
|
|
|
// if(weirdhyperbolic && c->land == laOcean) deepOcean = c->landparam >= 30;
|
2017-10-08 10:10:40 +00:00
|
|
|
|
|
|
|
// buildgreatwalls
|
|
|
|
|
2019-08-24 12:07:46 +00:00
|
|
|
if(hybri) ; /* Great Walls generated via the underlying geometry */
|
2019-08-18 13:32:46 +00:00
|
|
|
|
2019-10-12 11:47:41 +00:00
|
|
|
else if(walls_not_implemented()); // walls not implemented here
|
|
|
|
|
2019-08-18 13:32:46 +00:00
|
|
|
else if(geometry == gNormal && celldist(c) < 3 && !GOLDBERG) {
|
2019-08-03 10:42:49 +00:00
|
|
|
if(top_land && c == cwt.at->master->move(3)->c7) {
|
2018-03-29 22:20:33 +00:00
|
|
|
buildBarrierStrong(c, 6, true, top_land);
|
|
|
|
}
|
|
|
|
}
|
2017-10-28 23:57:34 +00:00
|
|
|
|
|
|
|
else if(chaosmode) {
|
2019-03-13 14:26:01 +00:00
|
|
|
if(good_for_wall(c) && hrand(10000) < 9000 && c->land && !inmirror(c) && buildBarrierNowall(c, getNewLand(c->land)))
|
2017-10-08 10:10:40 +00:00
|
|
|
{}
|
2017-10-29 13:21:42 +00:00
|
|
|
else if(ctof(c) && c->land == laMirror && hrand(10000) < 2000 && !weirdhyperbolic) {
|
2017-10-08 10:10:40 +00:00
|
|
|
int bd = 2 + hrand(2) * 3;
|
|
|
|
buildBarrier(c, bd, laMirrored);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-16 22:42:51 +00:00
|
|
|
else if(good_for_wall(c) && isWarpedType(c->land) && hrand(10000) < 3000 && c->land &&
|
2017-10-08 10:10:40 +00:00
|
|
|
buildBarrierNowall(c, eLand(c->land ^ laWarpSea ^ laWarpCoast))) ;
|
|
|
|
|
2019-03-13 14:26:01 +00:00
|
|
|
else if(good_for_wall(c) && c->land == laCrossroads4 && hrand(10000) < 7000 && c->land && !c->master->alt && !tactic::on && !racing::on &&
|
2017-10-08 10:10:40 +00:00
|
|
|
buildBarrierNowall(c, getNewLand(laCrossroads4))) ;
|
|
|
|
|
2019-03-13 14:26:01 +00:00
|
|
|
else if(good_for_wall(c) && hrand(I10000) < 20 && !generatingEquidistant && !yendor::on && !tactic::on && !racing::on && !isCrossroads(c->land) &&
|
2018-08-31 02:18:19 +00:00
|
|
|
gold() >= R200 && !weirdhyperbolic && !c->master->alt &&
|
2017-10-29 09:57:57 +00:00
|
|
|
!inmirror(c) && !isSealand(c->land) && !isHaunted(c->land) && !isGravityLand(c->land) &&
|
2017-10-08 10:10:40 +00:00
|
|
|
(c->land != laRlyeh || rlyehComplete()) &&
|
|
|
|
c->land != laTortoise && c->land != laPrairie && c->land &&
|
|
|
|
!(c->land == laGraveyard && !deepOcean)
|
|
|
|
&& c->land != laCanvas
|
|
|
|
) {
|
|
|
|
buildBarrierNowall(c, laCrossroads4) ;
|
|
|
|
}
|
|
|
|
|
2018-04-11 21:37:28 +00:00
|
|
|
else if(weirdhyperbolic && specialland == laCrossroads4 && /*pseudohept(c) &&*/ hrand(I10000 /4) < wallchance(c, deepOcean) && gp_wall_test()) {
|
2018-01-08 22:11:29 +00:00
|
|
|
buildBarrierNowall(c, getNewLand(c->land));
|
|
|
|
}
|
|
|
|
|
2018-09-23 11:46:21 +00:00
|
|
|
else if(weirdhyperbolic && yendor::on && yendor::nexttostart) {
|
|
|
|
if(buildBarrierNowall(c, yendor::nexttostart))
|
|
|
|
yendor::nexttostart = laNone;
|
|
|
|
}
|
|
|
|
|
2018-04-13 11:42:22 +00:00
|
|
|
else if(weirdhyperbolic && specialland == laElementalWall && hrand(I10000) < 1000 && gp_wall_test())
|
|
|
|
buildBarrierNowall(c, getNewLand(c->land));
|
2019-10-10 11:09:31 +00:00
|
|
|
|
|
|
|
else if(S3 >= OINF && c->land && hrand(I10000) < wallchance(c, deepOcean) && c->bardir != NOBARRIERS)
|
|
|
|
buildBarrierNowall(c, getNewLand(c->land));
|
2018-04-13 11:42:22 +00:00
|
|
|
|
2017-10-29 13:21:42 +00:00
|
|
|
else if(weirdhyperbolic) ; // non-Nowall barriers not implemented yet in weird hyperbolic
|
|
|
|
|
2018-08-28 15:17:34 +00:00
|
|
|
else if(c->land == laCrossroads2 && BITRUNCATED)
|
2017-10-08 10:10:40 +00:00
|
|
|
buildCrossroads2(c);
|
|
|
|
|
2019-02-17 17:33:15 +00:00
|
|
|
#if CAP_FIELD
|
2018-05-09 19:32:31 +00:00
|
|
|
else if(c->land == laPrairie && c->LHU.fi.walldist == 0 && !euclid) {
|
2017-10-08 10:10:40 +00:00
|
|
|
for(int bd=0; bd<7; bd++) {
|
|
|
|
int fval2 = createStep(c->master, bd)->fieldval;
|
2017-10-29 13:21:42 +00:00
|
|
|
int wd = currfp_gmul(fval2, currfp_inverses(c->fval-1));
|
|
|
|
if(currfp_distwall(wd) == 0) {
|
2017-10-08 10:10:40 +00:00
|
|
|
buildBarrier(c, bd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-17 17:33:15 +00:00
|
|
|
#endif
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2018-01-08 22:11:29 +00:00
|
|
|
else if(ctof(c) && c->land && hrand(I10000) < wallchance(c, deepOcean))
|
2017-10-08 10:10:40 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
int bd = 2 + hrand(2) * 3;
|
|
|
|
|
|
|
|
buildBarrier(c, bd);
|
|
|
|
|
|
|
|
/* int bd = 2;
|
|
|
|
buildBarrier4(c, bd, 0, getNewLand(c->land), c->land); */
|
|
|
|
}
|
|
|
|
|
2020-01-29 17:18:51 +00:00
|
|
|
if((!chaosmode) && bearsCamelot(c->land) && is_master(c) && !bt::in() &&
|
|
|
|
#if MAXMDIM >= 4
|
|
|
|
!(hyperbolic && WDIM == 3 && !reg3::in_rule()) &&
|
|
|
|
#endif
|
2018-08-31 02:18:41 +00:00
|
|
|
(quickfind(laCamelot) || peace::on || (hrand(I2000) < (c->land == laCrossroads4 ? 800 : 200) && horo_ok() &&
|
2018-11-23 01:58:16 +00:00
|
|
|
items[itEmerald] >= U5 && !tactic::on && !racing::on))) {
|
2017-10-08 10:10:40 +00:00
|
|
|
int rtr = newRoundTableRadius();
|
2020-01-28 11:43:53 +00:00
|
|
|
heptagon *alt = createAlternateMap(c, rtr+(hyperbolic && WDIM == 3 ? 11 : 14), hsOrigin);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(alt) {
|
|
|
|
alt->emeraldval = rtr;
|
|
|
|
alt->fiftyval = c->land;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!chaosmode) {
|
|
|
|
|
|
|
|
// buildbigstuff
|
|
|
|
|
2018-07-16 17:53:12 +00:00
|
|
|
if(c->land == laRlyeh && ctof(c) && horo_ok() &&
|
2017-10-08 10:10:40 +00:00
|
|
|
(quickfind(laTemple) || peace::on || (hrand(I2000) < 100 &&
|
|
|
|
items[itStatue] >= U5 && !randomPatternsMode &&
|
2018-11-23 01:58:16 +00:00
|
|
|
!tactic::on && !yendor::on && !racing::on)))
|
2020-01-29 18:32:32 +00:00
|
|
|
createAlternateMap(c, horo_gen_distance(), hsA);
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2017-10-28 23:57:34 +00:00
|
|
|
if(c->land == laJungle && ctof(c) &&
|
2018-04-06 21:18:40 +00:00
|
|
|
(quickfind(laMountain) || (hrand(I2000) < 100 && horo_ok() &&
|
2018-11-23 01:58:16 +00:00
|
|
|
!randomPatternsMode && !tactic::on && !yendor::on && !racing::on && landUnlocked(laMountain))))
|
2020-01-29 18:32:32 +00:00
|
|
|
createAlternateMap(c, horo_gen_distance(), hsA);
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2018-07-16 17:53:12 +00:00
|
|
|
if(c->land == laOvergrown && ctof(c) && horo_ok() &&
|
2018-06-17 17:04:57 +00:00
|
|
|
(quickfind(laClearing) || (hrand(I2000) < 25 &&
|
2017-10-08 10:10:40 +00:00
|
|
|
!randomPatternsMode && items[itMutant] >= U5 &&
|
2018-01-08 22:11:29 +00:00
|
|
|
isLandIngame(laClearing) &&
|
2018-11-23 01:58:16 +00:00
|
|
|
!tactic::on && !yendor::on && !racing::on))) {
|
2020-01-29 18:32:32 +00:00
|
|
|
heptagon *h = createAlternateMap(c, horo_gen_distance(), hsA);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(h) clearing::bpdata[h].root = NULL;
|
|
|
|
}
|
2018-06-22 17:36:04 +00:00
|
|
|
|
2018-08-28 15:17:34 +00:00
|
|
|
if(stdhyperbolic && c->land == laStorms && ctof(c) && hrand(2000) < 1000 && horo_ok() && !randomPatternsMode) {
|
2020-01-29 18:32:32 +00:00
|
|
|
heptagon *h = createAlternateMap(c, horo_gen_distance(), hsA);
|
2017-10-08 10:10:40 +00:00
|
|
|
if(h) h->alt->emeraldval = hrand(2);
|
|
|
|
}
|
|
|
|
|
2018-04-06 21:18:40 +00:00
|
|
|
if(c->land == laOcean && ctof(c) && deepOcean && !generatingEquidistant && !peace::on && horo_ok() &&
|
2017-10-08 10:10:40 +00:00
|
|
|
(quickfind(laWhirlpool) || (
|
2018-11-23 01:58:16 +00:00
|
|
|
hrand(2000) < (PURE ? 500 : 1000) && !tactic::on && !racing::on && !yendor::on)))
|
2020-01-29 18:32:32 +00:00
|
|
|
createAlternateMap(c, horo_gen_distance(), hsA);
|
2019-01-02 21:01:00 +00:00
|
|
|
|
2019-02-17 17:37:23 +00:00
|
|
|
#if CAP_COMPLEX2
|
2019-10-27 00:45:32 +00:00
|
|
|
if(c->land == laOcean && deepOcean && !generatingEquidistant && hrand(10000) < 20 && no_barriers_in_radius(c, 2) && hyperbolic && !quotient && !tactic::on && !safety)
|
2019-01-02 21:01:00 +00:00
|
|
|
brownian::init_further(c);
|
2019-02-17 17:37:23 +00:00
|
|
|
#endif
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2018-04-13 12:00:30 +00:00
|
|
|
if(c->land == laCaribbean && horo_ok() && ctof(c) && !c->master->alt)
|
2020-01-29 18:32:32 +00:00
|
|
|
createAlternateMap(c, horo_gen_distance(), hsA);
|
2017-10-08 10:10:40 +00:00
|
|
|
|
2018-09-27 20:11:37 +00:00
|
|
|
if(c->land == laCanvas && horo_ok() && ctof(c) && !c->master->alt)
|
2020-01-29 18:32:32 +00:00
|
|
|
createAlternateMap(c, horo_gen_distance(), hsA);
|
2018-09-27 20:11:37 +00:00
|
|
|
|
2018-05-03 08:59:43 +00:00
|
|
|
if(c->land == laPalace && ctof(c) && !princess::generating && !shmup::on && multi::players == 1 && horo_ok() && !weirdhyperbolic &&
|
2018-06-28 09:55:59 +00:00
|
|
|
(princess::forceMouse ? canReachPlayer(from, moMouse) :
|
2017-10-08 10:10:40 +00:00
|
|
|
(hrand(2000) < (peace::on ? 100 : 20))) &&
|
|
|
|
!c->master->alt &&
|
2018-11-23 01:58:16 +00:00
|
|
|
(princess::challenge || kills[moVizier] || peace::on) && !tactic::on && !yendor::on && !racing::on) {
|
2017-10-08 10:10:40 +00:00
|
|
|
createAlternateMap(c, PRADIUS0, hsOrigin, waPalace);
|
|
|
|
celllister cl(c, 5, 1000000, NULL);
|
2019-03-08 21:38:44 +00:00
|
|
|
for(cell *c: cl.lst) if(c->master->alt) currentmap->generateAlts(c->master);
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hasbardir(c)) extendBarrier(c);
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool openplains(cell *c) {
|
2017-10-11 21:18:33 +00:00
|
|
|
if(chaosmode) {
|
|
|
|
forCellEx(c2, c) if(c2->land != laHunting) return false;
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-28 23:57:34 +00:00
|
|
|
int dlimit = getDistLimit();
|
2019-12-14 10:42:16 +00:00
|
|
|
if(arcm::in()) dlimit--;
|
2017-10-28 23:57:34 +00:00
|
|
|
if(dlimit < 7) {
|
|
|
|
celllister cl(c, dlimit, 1000000, NULL);
|
2017-10-11 20:16:07 +00:00
|
|
|
int bad = 0;
|
|
|
|
for(cell *c: cl.lst) {
|
|
|
|
while(c->mpdist > 8) setdist(c, c->mpdist-1, NULL);
|
|
|
|
if(c->land != laHunting) {bad++; if(bad>5) return false;}
|
|
|
|
}
|
|
|
|
return true;
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
2017-10-11 20:16:07 +00:00
|
|
|
else {
|
2017-10-28 23:57:34 +00:00
|
|
|
celllister cl(c, dlimit, 1000000, NULL);
|
2017-10-11 20:16:07 +00:00
|
|
|
for(cell *c: cl.lst) {
|
|
|
|
while(c->mpdist > 8) setdist(c, c->mpdist-1, NULL);
|
|
|
|
if(c->land != laHunting) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-08 10:10:40 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void buildCamelotWall(cell *c) {
|
2019-10-10 11:09:31 +00:00
|
|
|
if(S3 >= OINF) { c->wall = waRubble; return; }
|
2020-01-28 11:43:53 +00:00
|
|
|
if(WDIM == 3 && hyperbolic && c->master->fieldval == 0) return;
|
2017-10-08 11:31:37 +00:00
|
|
|
c->wall = waCamelot;
|
2020-01-28 11:43:53 +00:00
|
|
|
if(WDIM == 3 && hyperbolic) return;
|
2017-10-08 11:31:37 +00:00
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = createMov(c, i);
|
2018-08-09 17:28:53 +00:00
|
|
|
if(c2->wall == waNone && (eubinary || (c2->master->alt && c->master->alt)) && celldistAlt(c2) > celldistAlt(c) && c2->monst == moNone)
|
2017-10-08 11:31:37 +00:00
|
|
|
c2->wall = waCamelotMoat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool no_barriers_in_radius(cell *c, int rad) {
|
2018-10-25 00:43:14 +00:00
|
|
|
celllister cl(c, 2, 1000000, NULL);
|
|
|
|
for(cell *c: cl.lst) if(c->bardir != NODIR) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-10-10 11:10:29 +00:00
|
|
|
EX eMonster camelot_monster() {
|
|
|
|
eMonster ms[3] = { moHedge, moLancer, moFlailer };
|
|
|
|
eMonster m = ms[hrand(3)];
|
2019-12-14 11:31:20 +00:00
|
|
|
if(m == moHedge && valence() > 3)
|
2019-10-10 11:10:29 +00:00
|
|
|
m = moPyroCultist;
|
|
|
|
if(getDistLimit() <= 2 && m == moLancer) m = moGoblin;
|
|
|
|
if(getDistLimit() <= 3 && m == moPyroCultist) m = moCultist;
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void buildCamelot(cell *c) {
|
2018-12-01 22:49:14 +00:00
|
|
|
int d = celldistAltRelative(c);
|
|
|
|
if(tactic::on || (d <= 14 && roundTableRadius(c) > 20)) {
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary) currentmap->generateAlts(c->master);
|
2018-12-01 22:49:14 +00:00
|
|
|
preventbarriers(c);
|
|
|
|
if(d == 10) {
|
|
|
|
if(weirdhyperbolic ? hrand(100) < 50 : pseudohept(c)) buildCamelotWall(c);
|
|
|
|
else {
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary) for(int i=0; i<S7; i++) currentmap->generateAlts(c->master->move(i));
|
2018-12-01 22:49:14 +00:00
|
|
|
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;
|
2019-10-10 11:10:29 +00:00
|
|
|
if(d < 0 && hrand(7000) <= 10 + items[itHolyGrail] * 5)
|
|
|
|
c->monst = camelot_monster();
|
2018-12-01 22:49:14 +00:00
|
|
|
if(d == 1) {
|
|
|
|
// roughly as many knights as table cells
|
2019-08-20 22:08:39 +00:00
|
|
|
if(hrand(1000000) < 1000000 / expansion.get_growth() && !reptilecheat)
|
2018-12-01 22:49:14 +00:00
|
|
|
c->monst = moKnight;
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary) for(int i=0; i<S7; i++) currentmap->generateAlts(c->master->move(i));
|
2018-12-01 22:49:14 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int masterAlt(cell *c) {
|
2019-05-06 23:08:49 +00:00
|
|
|
#if MAXMDIM >= 4
|
2020-01-28 10:17:09 +00:00
|
|
|
if(WDIM == 3 && hyperbolic && !reg3::in_rule()) return reg3::altdist(c->master);
|
2019-05-06 23:08:49 +00:00
|
|
|
#endif
|
2019-03-09 00:00:46 +00:00
|
|
|
return c->master->alt->distance;
|
|
|
|
}
|
|
|
|
|
2019-12-14 11:35:03 +00:00
|
|
|
/** the distance between two layers of Temple of Cthulhu */
|
|
|
|
EX int temple_layer_size() {
|
|
|
|
if(among(geometry, gHoroRec, gHoroHex, gKiteDart3)) return 3;
|
|
|
|
if(sol) return 6;
|
|
|
|
if(WDIM == 3 && bt::in()) return 2;
|
2020-01-29 18:23:00 +00:00
|
|
|
if(among(geometry, gSpace435, gSpace535)) return 5;
|
2019-12-14 11:35:03 +00:00
|
|
|
if(WDIM == 3 && hyperbolic) return 3;
|
|
|
|
if(S3 == OINF) return 4;
|
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
|
2020-01-29 18:32:32 +00:00
|
|
|
EX int horo_gen_distance() {
|
2020-01-29 18:20:25 +00:00
|
|
|
return (WDIM == 3 && hyperbolic) ? 1 : 2;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void moreBigStuff(cell *c) {
|
2018-04-13 11:08:16 +00:00
|
|
|
|
2019-08-06 18:59:43 +00:00
|
|
|
if((bearsCamelot(c->land) && !euclid && !quotient && !nil) || c->land == laCamelot)
|
2019-12-14 11:05:01 +00:00
|
|
|
if(eubinary || bt::in() || c->master->alt) if(!(bt::in() && specialland != laCamelot))
|
2018-12-04 18:13:26 +00:00
|
|
|
buildCamelot(c);
|
|
|
|
|
2018-04-13 11:08:16 +00:00
|
|
|
if(quotient) return;
|
2018-08-09 17:28:53 +00:00
|
|
|
|
|
|
|
if(c->land == laPalace && !eubinary && c->master->alt) {
|
2017-10-08 11:31:37 +00:00
|
|
|
int d = celldistAlt(c);
|
2019-03-08 21:38:44 +00:00
|
|
|
if(d <= PRADIUS1) currentmap->generateAlts(c->master);
|
2017-10-08 11:31:37 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 22:49:14 +00:00
|
|
|
if(c->land == laCanvas && !eubinary && c->master->alt && !quotient)
|
2019-03-08 21:38:44 +00:00
|
|
|
currentmap->generateAlts(c->master);
|
2018-09-27 20:11:37 +00:00
|
|
|
|
2017-10-08 11:31:37 +00:00
|
|
|
if(c->land == laStorms)
|
2018-08-09 17:28:53 +00:00
|
|
|
if(!eubinary && !quotient && !sphere) {
|
2020-01-29 18:32:32 +00:00
|
|
|
if(c->master->alt && masterAlt(c) <= horo_gen_distance()) {
|
2019-03-08 21:38:44 +00:00
|
|
|
currentmap->generateAlts(c->master);
|
2017-10-08 11:31:37 +00:00
|
|
|
preventbarriers(c);
|
|
|
|
int d = celldistAlt(c);
|
|
|
|
if(d <= -2) {
|
|
|
|
c->wall = (c->master->alt->alt->emeraldval & 1) ? waCharged : waGrounded;
|
|
|
|
c->item = itNone;
|
|
|
|
c->monst = moNone;
|
|
|
|
}
|
|
|
|
else if(d <= -1)
|
|
|
|
c->wall = (hrand(100) < 20) ? waSandstone : waNone;
|
|
|
|
else if(d <= 0)
|
|
|
|
c->wall = waNone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(chaosmode && c->land == laTemple) {
|
|
|
|
for(int i=0; i<c->type; i++)
|
2018-08-17 22:46:45 +00:00
|
|
|
if(pseudohept(c) && c->move(i) && c->move(i)->land != laTemple)
|
2017-10-08 11:31:37 +00:00
|
|
|
c->wall = waColumn;
|
|
|
|
}
|
|
|
|
|
2019-12-14 11:05:01 +00:00
|
|
|
else if((c->land == laRlyeh && !euclid) || c->land == laTemple) if(!(bt::in() && specialland != laTemple && c->land == laRlyeh)) {
|
2020-01-29 18:32:32 +00:00
|
|
|
if(eubinary || in_s2xe() || (c->master->alt && (tactic::on || masterAlt(c) <= horo_gen_distance()))) {
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary && !chaosmode) currentmap->generateAlts(c->master);
|
2017-10-08 11:31:37 +00:00
|
|
|
preventbarriers(c);
|
|
|
|
int d = celldistAlt(c);
|
|
|
|
if(d <= 0) {
|
|
|
|
c->land = laTemple, c->wall = waNone, c->monst = moNone, c->item = itNone;
|
|
|
|
}
|
2019-12-14 11:35:03 +00:00
|
|
|
if(d % temple_layer_size()==0) {
|
2019-06-17 17:36:29 +00:00
|
|
|
c->landparam = 0;
|
2019-03-09 00:35:06 +00:00
|
|
|
if(geometry == gSpace534) {
|
|
|
|
int i = 0;
|
|
|
|
forCellCM(c2, c) if(celldistAlt(c2) < celldistAlt(c)) i++;
|
|
|
|
if(i > 1) c->wall = waColumn;
|
|
|
|
}
|
2020-01-29 18:23:00 +00:00
|
|
|
else if(geometry == gSpace535) {
|
|
|
|
c->wall = (c->master->fieldval % 5) ? waRubble : waColumn;
|
|
|
|
}
|
|
|
|
else if(geometry == gSpace435) {
|
|
|
|
c->wall = waRubble;
|
|
|
|
if(c->master->fieldval == 0) c->wall = waColumn;
|
|
|
|
forCellCM(c1, c) if(c1->master->fieldval == 0) c->wall = waColumn;
|
|
|
|
}
|
2019-07-25 21:07:36 +00:00
|
|
|
else if(sol) {
|
|
|
|
if(c->master->emeraldval % 3 || c->master->zebraval % 3)
|
|
|
|
c->wall = waColumn;
|
|
|
|
}
|
2019-10-02 17:22:43 +00:00
|
|
|
else if(nih) {
|
|
|
|
if(c->master->emeraldval % 2)
|
|
|
|
c->wall = waColumn;
|
|
|
|
}
|
2020-10-15 14:33:52 +00:00
|
|
|
#if CAP_BT
|
2019-03-13 12:09:57 +00:00
|
|
|
else if(geometry == gHoroTris || geometry == gHoroRec) {
|
2019-12-14 11:05:01 +00:00
|
|
|
if(c->c.spin(bt::updir()) != 0) c->wall = waColumn;
|
2019-03-10 11:26:06 +00:00
|
|
|
}
|
2019-07-25 10:24:02 +00:00
|
|
|
else if(geometry == gKiteDart3) {
|
|
|
|
if(kite::getshape(c->master) == kite::pKite) c->wall = waColumn;
|
|
|
|
}
|
2020-10-15 14:33:52 +00:00
|
|
|
#endif
|
2019-09-12 12:24:02 +00:00
|
|
|
else if(in_s2xe()) {
|
2019-09-10 07:21:46 +00:00
|
|
|
auto d = hybrid::get_where(c);
|
|
|
|
if(!PIU(pseudohept(d.first))) c->wall = waColumn;
|
|
|
|
}
|
2019-08-24 12:07:46 +00:00
|
|
|
else if(hybri) {
|
|
|
|
auto d = hybrid::get_where(c);
|
2019-08-18 13:32:46 +00:00
|
|
|
if(d.first->wall == waColumn || (d.second&1)) c->wall = waColumn;
|
|
|
|
}
|
2019-05-08 16:33:08 +00:00
|
|
|
else if(WDIM == 3) {
|
2020-01-29 18:23:00 +00:00
|
|
|
c->wall = hrand(100) < 10 ? waColumn : waRubble;
|
2019-02-22 20:04:47 +00:00
|
|
|
}
|
2019-10-10 11:09:31 +00:00
|
|
|
else if(S3 >= OINF) { }
|
2019-02-22 20:04:47 +00:00
|
|
|
else if(weirdhyperbolic && !BITRUNCATED) {
|
2018-04-06 20:23:44 +00:00
|
|
|
if(hrand(100) < 50) c->wall = waColumn;
|
|
|
|
}
|
|
|
|
else if(pseudohept(c))
|
2017-10-08 11:31:37 +00:00
|
|
|
c->wall = waColumn;
|
|
|
|
else {
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary) for(int i=0; i<S7; i++) currentmap->generateAlts(c->master->move(i));
|
2017-10-08 11:31:37 +00:00
|
|
|
int q = 0;
|
2017-10-30 09:29:15 +00:00
|
|
|
for(int t=0; t<c->type; t++) {
|
2017-10-08 11:31:37 +00:00
|
|
|
createMov(c, t);
|
2019-12-14 11:35:03 +00:00
|
|
|
if(celldistAlt(c->move(t)) % temple_layer_size() == 0 && !ishept(c->move(t))) q++;
|
2017-10-08 11:31:37 +00:00
|
|
|
}
|
|
|
|
if(q == 2) c->wall = waColumn;
|
|
|
|
}
|
2019-06-17 17:36:29 +00:00
|
|
|
c->landparam = 1;
|
2017-10-08 11:31:37 +00:00
|
|
|
}
|
2019-06-17 17:36:29 +00:00
|
|
|
else c->landparam = 2;
|
2017-10-08 11:31:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-14 11:05:01 +00:00
|
|
|
if((c->land == laOvergrown && !euclid) || c->land == laClearing) if(!(bt::in() && specialland != laClearing)) {
|
2020-01-29 18:32:32 +00:00
|
|
|
if(eubinary || (c->master->alt && (tactic::on || masterAlt(c) <= horo_gen_distance()))) {
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary) currentmap->generateAlts(c->master);
|
2017-10-08 11:31:37 +00:00
|
|
|
preventbarriers(c);
|
|
|
|
int d = celldistAlt(c);
|
|
|
|
if(d <= 0) {
|
|
|
|
c->land = laClearing, c->wall = waNone; // , c->monst = moNone, c->item = itNone;
|
|
|
|
}
|
2018-08-09 17:28:53 +00:00
|
|
|
else if(d == 1 && !tactic::on && !eubinary)
|
2019-12-26 08:40:07 +00:00
|
|
|
c->wall = waSmallTree, c->monst = moNone, c->item = itNone, c->landparam = 1;
|
2017-10-08 11:31:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-14 11:05:01 +00:00
|
|
|
if((c->land == laJungle && !euclid) || c->land == laMountain) if(!(bt::in() && specialland != laMountain)) {
|
2020-01-29 18:32:32 +00:00
|
|
|
if(eubinary || (c->master->alt && (tactic::on || masterAlt(c) <= horo_gen_distance()))) {
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary) currentmap->generateAlts(c->master);
|
2017-10-08 11:31:37 +00:00
|
|
|
preventbarriers(c);
|
|
|
|
int d = celldistAlt(c);
|
|
|
|
if(d <= 0 || (firstland == laMountain && tactic::on)) {
|
|
|
|
c->land = laMountain, c->wall = waNone; // , c->monst = moNone, c->item = itNone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-14 11:05:01 +00:00
|
|
|
if(among(c->land, laOcean, laWhirlpool, laBrownian)) if(!(bt::in() && specialland != laWhirlpool)) {
|
2017-10-08 11:31:37 +00:00
|
|
|
bool fullwhirlpool = false;
|
2018-04-11 15:44:46 +00:00
|
|
|
if(tactic::on && specialland == laWhirlpool)
|
2017-10-08 11:31:37 +00:00
|
|
|
fullwhirlpool = true;
|
|
|
|
if(yendor::on && yendor::clev().l == laWhirlpool)
|
|
|
|
fullwhirlpool = true;
|
2019-03-09 00:00:46 +00:00
|
|
|
if(eubinary || (c->master->alt && (fullwhirlpool || masterAlt(c) <= 2))) {
|
2019-03-08 21:38:44 +00:00
|
|
|
if(!eubinary) currentmap->generateAlts(c->master);
|
2017-10-08 11:31:37 +00:00
|
|
|
preventbarriers(c);
|
|
|
|
int dd = celldistAlt(c);
|
|
|
|
if(dd <= 0 || fullwhirlpool) {
|
|
|
|
c->land = laWhirlpool, c->wall = waSea, c->monst = moNone, c->item = itNone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-10 23:58:31 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void generate_mines() {
|
2019-04-04 12:36:45 +00:00
|
|
|
vector<cell*> candidates;
|
2020-07-30 19:27:51 +00:00
|
|
|
|
|
|
|
if(bounded)
|
|
|
|
for(cell *c: currentmap->allcells())
|
|
|
|
setdist(c, 7, nullptr);
|
|
|
|
|
2019-04-04 12:36:45 +00:00
|
|
|
for(cell *c: currentmap->allcells())
|
|
|
|
if(c->wall == waMineUnknown)
|
|
|
|
candidates.push_back(c);
|
|
|
|
bounded_mine_max = isize(candidates);
|
|
|
|
hrandom_shuffle(&candidates[0], bounded_mine_max);
|
|
|
|
bounded_mine_quantity = int(bounded_mine_max * bounded_mine_percentage + 0.5);
|
|
|
|
for(int i=0; i<bounded_mine_quantity; i++) candidates[i]->wall = waMineMine;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX vector<eLand> currentlands;
|
2019-05-27 05:17:39 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void pregen() {
|
2019-05-27 05:17:39 +00:00
|
|
|
currentlands.clear();
|
|
|
|
if(chaosmode > 1)
|
|
|
|
for(eLand l: land_over)
|
|
|
|
if(landUnlocked(l) && isLandIngame(l))
|
|
|
|
currentlands.push_back(l);
|
|
|
|
}
|
|
|
|
|
2019-05-30 14:12:38 +00:00
|
|
|
auto ccm_bigstuff = addHook(hooks_gamedata, 0, [] (gamedata* gd) {
|
|
|
|
gd->store(euland);
|
|
|
|
gd->store(euland3);
|
|
|
|
gd->store(euland3_hash);
|
|
|
|
});
|
|
|
|
|
2018-06-27 22:35:45 +00:00
|
|
|
}
|