split sight/game/generation range; bonuses instead of absolute values

This commit is contained in:
Zeno Rogue 2018-04-03 23:34:47 +02:00
parent f2c5bbcea3
commit 229f717678
17 changed files with 93 additions and 102 deletions

View File

@ -13,6 +13,8 @@ int utfsize(char c) {
return 4;
}
int get_sightrange() { return getDistLimit() + sightrange_bonus; }
namespace stereo {
eStereo mode;
ld ipd;
@ -820,7 +822,7 @@ ld realradius() {
vradius = 1e12; // use the following
}
if(euclid)
vradius = vid.radius * sightrange / (1 + vid.alpha) / 2.5;
vradius = vid.radius * get_sightrange() / (1 + vid.alpha) / 2.5;
vradius = min<ld>(vradius, min(vid.xres, vid.yres) / 2);
return vradius;
}

View File

@ -1135,16 +1135,6 @@ bool openplains(cell *c) {
}
}
void doOvergenerate() {
int dcs = size(dcal);
for(int i=0; i<dcs; i++) {
cell *c = dcal[i];
if(weirdhyperbolic && (c->land == laCaribbean)) continue;
if(weirdhyperbolic && (c->land == laStorms || c->land == laCamelot || c->land == laTemple || c->land == laOcean)) continue;
if(c->cpdist <= sightrange-6) setdist(c, 1, NULL);
}
}
void buildCamelotWall(cell *c) {
c->wall = waCamelot;
for(int i=0; i<c->type; i++) {

View File

@ -467,11 +467,11 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
}
else if(argis("-sr")) {
PHASEFROM(2);
shift(); sightrange = argi();
shift(); sightrange_bonus = argi();
}
else if(argis("-srx")) {
PHASEFROM(2);
shift(); sightrange = argi(); overgenerate = true; autocheat = true;
shift(); sightrange_bonus = genrange_bonus = gamerange_bonus = argi(); autocheat = true;
}
else if(argis("-we")) {
PHASEFROM(2);

View File

@ -1045,7 +1045,7 @@ namespace mirror {
static const int LIGHTNING = -1; // passed instead of cpid
bool noMirrorOn(cell *c) {
return c->monst || (!shmup::on && isPlayerOn(c)) || (geometry != gQuotient2 && geometry != gTorus && c->cpdist > 7);
return c->monst || (!shmup::on && isPlayerOn(c)) || (geometry != gQuotient2 && geometry != gTorus && c->cpdist > gamerange());
}
bool cellMirrorable(cell *c) {
@ -1527,7 +1527,7 @@ namespace hive {
#include <set>
bool fightspam(cell *c) {
return c->cpdist >= 7 ||
return c->cpdist >= gamerange() ||
isMetalBeast(c->monst) || c->monst == moSkeleton ||
isIvy(c->monst) || isMutantIvy(c->monst);
}
@ -1780,8 +1780,10 @@ namespace heat {
sval++;
int gr = gamerange();
for(cell *c: offscreen_heat) {
if(c->cpdist > 7 && !doall) {
if(c->cpdist > gr && !doall) {
if(eq(c->aitmp, sval)) continue;
c->aitmp = sval;
if(isIcyLand(c)) {
@ -1818,7 +1820,7 @@ namespace heat {
double xrate = (c->land == laCocytus && shmup::on) ? 1/3. : 1;
if(nonbitrunc) xrate *= 1.7;
if(!shmup::on) xrate /= FIX94;
if(c->cpdist > 7 && !doall) break;
if(c->cpdist > gr && !doall) break;
if(isIcyLand(c)) {
ld hmod = 0;
@ -2027,10 +2029,11 @@ void livecaves() {
int dcs = size(allcells);
vector<cell*> bringlife;
int gr = gamerange();
for(int i=0; i<dcs; i++) {
cell *c = allcells[i];
if(!doall && c->cpdist > 8) break;
if(!doall && c->cpdist > gr+1) break;
if(c->wall == waCavefloor || c->wall == waCavewall || c->wall == waDeadTroll) {
c->aitmp = 0;
@ -2134,7 +2137,7 @@ void livecaves() {
for(int i=0; i<dcs; i++) {
cell *c = allcells[i];
if(!doall && c->cpdist > 8) break;
if(!doall && c->cpdist > gr+1) break;
if(c->wall == waCavefloor || c->wall == waCavewall) {
// if(c->land != laCaves) continue;
@ -2834,7 +2837,7 @@ namespace prairie {
int qty = size(whirlline);
// for(int i=0; i<qty; i++) whirlline[i]->aitmp = sval;
if(shmup::on) {
for(int i=0; i<qty; i++) if(whirlline[i]->cpdist <= 7) {
for(int i=0; i<qty; i++) if(whirlline[i]->cpdist <= gamerange()) {
generateBeast(whirlline[i]);
break;
}

View File

@ -540,10 +540,9 @@ void loadOldConfig(FILE *f) {
aa=vid.revcontrol; bb=vid.drawmousecircle;
d = vid.mspeed;
err=fscanf(f, "%d%d%d%f%d%d", &aa, &bb, &sightrange, &d, &effvolume, &vid.particles);
int sr;
err=fscanf(f, "%d%d%d%f%d%d", &aa, &bb, &sr, &d, &effvolume, &vid.particles);
vid.mspeed = d;
if(sightrange < 3) sightrange = 3;
if(sightrange > 7) sightrange = 7;
vid.revcontrol = aa; vid.drawmousecircle = bb;
readf(f, geom3::depth); readf(f, geom3::camera); readf(f, geom3::wall_height);
@ -706,7 +705,7 @@ void showGraphConfig() {
dialog::addSelItem(XLAT("font scale"), its(fontscale), 'b');
dialog::addSelItem(XLAT("sight range"), its(sightrange), 'r');
dialog::addSelItem(XLAT("sight range"), its(sightrange_bonus), 'r');
dialog::addSelItem(XLAT("compass size"), its(vid.mobilecompasssize), 'c');
@ -743,11 +742,13 @@ void showGraphConfig() {
XLAT("+5 = move instantly"));
if(xuni == 'r') {
dialog::editNumber(sightrange, 4, allowIncreasedSight() ? 10 : 7, 1, 7, XLAT("sight range"),
dialog::editNumber(sightrange_bonus, -3, allowIncreasedSight() ? 3 : 0, 1, 0, XLAT("sight range"),
XLAT("Roughly 42% cells are on the edge of your sight range. Reducing "
"the sight range makes HyperRogue work faster, but also makes "
"the game effectively harder."));
dialog::reaction = [] () { if(overgenerate) doOvergenerate(); };
dialog::reaction = [] () {
doOvergenerate();
};
}
if(xuni == 'k') {

View File

@ -430,7 +430,7 @@ namespace conformal {
SDL_Surface *bbuf = SDL_CreateRGBSurface(SDL_SWSURFACE,bandfull,bandfull,32,0,0,0,0);
s = bbuf;
int ssr = sightrange; sightrange = 10; int sch = cheater; cheater = 0;
int ssr = sightrange_bonus; sightrange_bonus = 3; int sch = cheater; cheater = 0;
videopar vid2 = vid; vid.xres = vid.yres = bandfull; vid.scale = 1;
calcparam();
vid.radius = bandhalf;
@ -518,7 +518,7 @@ namespace conformal {
SDL_FreeSurface(band);
SDL_FreeSurface(sav);
s = sav; vid = vid2; sightrange = ssr; cheater = sch;
s = sav; vid = vid2; sightrange_bonus = ssr; cheater = sch;
if(includeHistory) restoreBack();
if(dospiral) {

View File

@ -611,13 +611,13 @@ namespace dialog {
// if(ne.editwhat == &whatever) resetGeometry();
if(ne.intval == &sightrange && sightrange < 4)
*ne.editwhat = sightrange = 4, affect('v');
if(ne.intval == &sightrange_bonus && sightrange_bonus < -3)
*ne.editwhat = sightrange_bonus = -3, affect('v');
int msr = allowIncreasedSight() ? 15 : 7;
int msr = allowIncreasedSight() ? 10 : 0;
if(ne.intval == &sightrange && sightrange > msr)
*ne.editwhat = sightrange = msr, affect('v');
if(ne.intval == &sightrange_bonus && sightrange_bonus > msr)
*ne.editwhat = sightrange_bonus = msr, affect('v');
if(ne.intval == &conformal::bandhalf && conformal::bandhalf < 5)
*ne.editwhat = *ne.intval = 5, affect('v');
@ -695,8 +695,10 @@ namespace dialog {
addBoolItem("all directional lands", conformal::do_rotate == 2, 'd');
}
if(ne.editwhat == &ne.intbuf && ne.intval == &sightrange && cheater)
addBoolItem("overgenerate", overgenerate, 'o');
if(ne.editwhat == &ne.intbuf && ne.intval == &sightrange_bonus && cheater) {
addSelItem("generation range bonus", its(genrange_bonus), 'o');
addSelItem("game range bonus", its(gamerange_bonus), 'O');
}
if(ne.editwhat == &vid.linewidth)
addBoolItem("finer lines at the boundary", vid.antialias & AA_LINEWIDTH, 'o');
@ -751,9 +753,12 @@ namespace dialog {
conformal::do_rotate = 1;
else if(uni == 'd' && ne.editwhat == &conformal::rotation)
conformal::do_rotate = 2;
else if(uni == 'o' && ne.editwhat == &ne.intbuf && ne.intval == &sightrange && cheater) {
overgenerate = !overgenerate;
if(overgenerate) doOvergenerate();
else if(uni == 'o' && ne.editwhat == &ne.intbuf && ne.intval == &sightrange_bonus && cheater) {
genrange_bonus = sightrange_bonus;
doOvergenerate();
}
else if(uni == 'O' && ne.editwhat == &ne.intbuf && ne.intval == &sightrange_bonus && cheater) {
gamerange_bonus = sightrange_bonus;
}
else if(uni == 'o' && ne.editwhat == &vid.linewidth)
vid.antialias ^= AA_LINEWIDTH;

View File

@ -9,6 +9,9 @@ int turncount;
int rosewave, rosephase;
int avengers, mirrorspirits, wandering_jiangshi, jiangshi_on_screen;
int gamerange_bonus = 0;
int gamerange() { return getDistLimit() + gamerange_bonus; }
cell *lastmove;
enum eLastmovetype {lmSkip, lmMove, lmAttack, lmSpecial, lmPush, lmTree};
eLastmovetype lastmovetype;
@ -2731,7 +2734,7 @@ void buildRosemap() {
}
int getDistLimit() { return ginf[geometry].distlimit[nonbitrunc]; }
int getDistLimit() { return base_distlimit; }
bool nogoSlow(cell *to, cell *from) {
if(cellEdgeUnstable(to) && gravityLevel(to) >= gravityLevel(from)) return true;
@ -2754,6 +2757,8 @@ void computePathdist(eMonster param) {
}
int qtarg = size(targets);
int limit = gamerange();
for(int qb=0; qb < size(pathq); qb++) {
int fd = reachedfrom[qb] + 3;
@ -2767,7 +2772,7 @@ void computePathdist(eMonster param) {
pathqm.push_back(c);
continue;
}
if(c->cpdist > 7 && !(c->land == laTrollheim && turncount < c->landparam)) continue;
if(c->cpdist > limit && !(c->land == laTrollheim && turncount < c->landparam)) continue;
int d = c->pathdist;
if(d == PINFD - 1) continue;
for(int j=0; j<c->type; j++) {
@ -2846,7 +2851,7 @@ void bfs() {
if(!invismove) targets.push_back(c);
}
int distlimit = getDistLimit();
int distlimit = gamerange();
for(int i=0; i<numplayers(); i++) {
cell *c = playerpos(i);
@ -4110,7 +4115,7 @@ void killThePlayerAt(eMonster m, cell *c, flagtype flags) {
}
void afterplayermoved() {
setdist(cwt.c, 0, NULL);
setdist(cwt.c, 7 - getDistLimit() - genrange_bonus, NULL);
prairie::treasures();
if(generatingEquidistant) {
printf("Warning: generatingEquidistant set to true\n");
@ -6459,7 +6464,7 @@ int ambushSize(cell *c, eItem what) {
}
int ambush(cell *c, eItem what) {
int maxdist = getDistLimit();
int maxdist = gamerange();
celllister cl(c, maxdist, 1000000, NULL);
cell *c0 = c;
int d = 0;

View File

@ -16,6 +16,8 @@ ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf;
// hepvdist: distance between heptagon vertex and hexagon center (either hcrossf or something else)
// rhexf: distance from heptagon center to heptagon vertex (either hexf or hcrossf)
int base_distlimit;
hyperpoint Crad[MAX_S84];
transmatrix heptmove[MAX_EDGE], hexmove[MAX_EDGE];

View File

@ -38,7 +38,7 @@ bool camelotcheat;
eItem orbToTarget;
eMonster monsterToSummon;
int sightrange = 7;
int sightrange_bonus = 0;
bool overgenerate = false; // generate a bigger area with high sightrange
string mouseovers;
@ -3268,7 +3268,7 @@ void pushdown(cell *c, int& q, const transmatrix &V, double down, bool rezoom, b
bool dodrawcell(cell *c) {
// todo: fix when scrolling
if(!buggyGeneration && !debugmode && c->land != laCanvas && sightrange < 10) {
if(!buggyGeneration && !debugmode && c->land != laCanvas && sightrange_bonus < 3) {
// not yet created
if(c->mpdist > 7 && !cheater) return false;
// always show on the torus rug
@ -3277,7 +3277,7 @@ bool dodrawcell(cell *c) {
// in the Yendor Challenge, scrolling back is forbidden
if(c->cpdist > 7 && (yendor::on && !cheater)) return false;
// (incorrect comment) too far, no bugs nearby
if(playermoved && sightrange <= 7 && c->cpdist > sightrange && c->cpdist > ambush_distance) return false;
if(playermoved && c->cpdist > get_sightrange() && c->cpdist > ambush_distance) return false;
}
return true;
@ -3505,7 +3505,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
viewBuggyCells(c,V);
if(conformal::on || inHighQual || sightrange > 7) checkTide(c);
if(conformal::on || inHighQual || sightrange_bonus > gamerange_bonus) checkTide(c);
// save the player's view center
if(isPlayerOn(c) && !shmup::on) {
@ -4993,7 +4993,7 @@ void drawMarkers() {
cell *keycell = NULL;
int i;
for(i=0; i<YDIST; i++)
if(yi[yii].path[i]->cpdist <= sightrange) {
if(yi[yii].path[i]->cpdist <= get_sightrange()) {
keycell = yi[yii].path[i];
break;
}
@ -5173,10 +5173,8 @@ void drawthemap() {
wavephase = (-(ticks / 100)) & 7;
if(!allowIncreasedSight()) {
if(sightrange > 7) sightrange = 7;
overgenerate = false;
}
if(sightrange_bonus > 0 && !allowIncreasedSight())
sightrange_bonus = 0;
profile_frame();
profile_start(0);
@ -5238,7 +5236,7 @@ void drawthemap() {
if(euclid)
drawEuclidean();
else {
int sr = max(sightrange, ambush_distance);
int sr = max(get_sightrange(), ambush_distance);
maxreclevel =
conformal::on ? sr + 2:
(!playermoved) ? sr+1 : sr + 4;
@ -5880,6 +5878,6 @@ cell *viewcenter() {
}
bool inscreenrange(cell *c) {
return celldistance(viewcenter(), c) <= (euclid ? sightrange : nonbitrunc ? 9 : 13);
return celldistance(viewcenter(), c) <= (euclid ? get_sightrange() : nonbitrunc ? 9 : 13);
}

11
hyper.h
View File

@ -120,9 +120,10 @@ struct gcell {
unsigned ligon : 1; // is it sparkling with lightning?
unsigned
pathdist : 7, // player distance wrt usual movement
cpdist : 8, mpdist : 8; // current/minimum player distance
signed
mpdist : 7,
pathdist : 8, // player distance wrt usual movement
cpdist : 8; // current/minimum player distance
unsigned
mondir : 4, // monster direction, for multi-tile monsters and graphics
@ -1016,7 +1017,7 @@ extern bool safety;
#define PRIZEMUL 7
#define INF 9999
#define INFD 20
#define INFD 60
#define PINFD 125
#ifndef BARLEV
#define BARLEV ((ISANDROID||ISIOS||ISFAKEMOBILE||getDistLimit()<7)?9:10)
@ -1396,7 +1397,7 @@ namespace svg {
void render(const char *fname = NULL);
}
extern int sightrange;
extern int sightrange_bonus, genrange_bonus, gamerange_bonus;
namespace halloween {
void getTreat(cell *where);

View File

@ -13,9 +13,17 @@ int lastexplore;
bool randomPatternsMode = false;
int randompattern[landtypes];
int genrange_bonus = 0;
bool chaosUnlocked = false;
bool chaosAchieved = false;
void doOvergenerate() {
if(overgenerate)
for(int i=0; i<numplayers(); i++)
setdist(playerpos(i), 7 - getDistLimit() - genrange_bonus, NULL);
}
bool notDippingFor(eItem i) {
if(peace::on) return false;
int v = items[i] - currentLocalTreasure;
@ -2240,37 +2248,9 @@ void repairLandgen(cell *c) {
}
}
int dnext(int d) {
switch(getDistLimit()&7) {
case 0:
case 1:
// 0,7
return d+(d<7?7:1);
case 2:
// 0,1,7
return d+(d>=1 && d<7?6:1);
case 3:
// 0,1,4,7
return d+(d>=1 && d<7?3:1);
case 4:
//0,1,3,5,7
return d+(d>=1 && d<7?2:1);
case 5:
// 0,1,2,3,5,7
return d+(d>=3 && d<7?2:1);
case 6:
// 0,1,2,3,4,5,7
return d+(d==5?2:1);
case 7:
//0,1,2,3,4,5,6,7
return d+1;
}
return d+1;
}
void setdist(cell *c, int d, cell *from) {
if(signed(c->mpdist) <= d) return;
if(c->mpdist <= d) return;
if(c->mpdist > d+1 && d != BARLEV) setdist(c, d+1, from);
c->mpdist = d;
// printf("setdist %p %d [%p]\n", c, d, from);
@ -2292,7 +2272,7 @@ void setdist(cell *c, int d, cell *from) {
if(buggyGeneration) {
if(d < BARLEV) for(int i=0; i<c->type; i++) {
setdist(createMov(c, i), d+(nonbitrunc?2:1), c);
setdist(createMov(c, i), d+1, c);
}
if(d >= BARLEV) c->item = itBuggy2;
return;
@ -2337,12 +2317,14 @@ void setdist(cell *c, int d, cell *from) {
if(buggyGeneration) return;
if(d < 10) {
explore[d]++;
exploreland[d][c->land]++;
if(d >= 0) {
explore[d]++;
exploreland[d][c->land]++;
}
if(d < BARLEV) for(int i=0; i<c->type; i++) {
setdist(createMov(c, i), dnext(d), c);
setdist(createMov(c, i), d+1, c);
if(buggyGeneration) return;
}

View File

@ -426,7 +426,7 @@ void wandering() {
playSeenSound(c);
continue;
}
if(b) forCellEx(c2, c) if((sphere || c2->cpdist > 7) && !pseudohept(c2)) {
if(b) forCellEx(c2, c) if((sphere || c2->cpdist > gamerange()) && !pseudohept(c2)) {
forCellCM(c3, c2) if(c3->monst || c3->wall != waSea)
goto notfound;
c2->monst = moKrakenH;

View File

@ -2620,7 +2620,7 @@ namespace svg {
if(!uselatex)
fprintf(f, "font-family='%s' font-size='%s' ", font.c_str(), coord(size));
fprintf(f, "%s>%s</text>",
stylestr(col, frame ? 0x0000000FF : 0, (1<<sightrange)*dfc/40), str2.c_str());
stylestr(col, frame ? 0x0000000FF : 0, (1<<get_sightrange())*dfc/40), str2.c_str());
stopstring();
fprintf(f, "\n");
}
@ -2673,7 +2673,7 @@ namespace svg {
dynamicval<int> v5(ringcolor, 0x808080FF);
vid.usingGL = false;
vid.xres = vid.yres = svgsize ? svgsize : min(1 << (sightrange+7), 16384);
vid.xres = vid.yres = svgsize ? svgsize : min(1 << (get_sightrange()+7), 16384);
calcparam();
#if CAP_ROGUEVIZ
rogueviz::fixparam();
@ -2692,7 +2692,7 @@ namespace svg {
drawfullmap();
fprintf(f, "</svg>\n");
fclose(f);
addMessage(XLAT("Saved the SVG shot to %1 (sightrange %2)", fname, its(sightrange)));
addMessage(XLAT("Saved the SVG shot to %1 (sightrange %2)", fname, its(get_sightrange())));
}
}
#endif

View File

@ -1416,7 +1416,7 @@ void rvvideo(const char *fname) {
drawthemap();
centerpc(100); optimizeview();
fixmatrix(View);
bfs(); setdist(cwt.c, 0, NULL);
bfs(); setdist(cwt.c, 7 - getDistLimit() - genrange_bonus, NULL);
vertexdata& vd = vdata[id];
for(int e=0; e<size(vd.edges); e++) {
int id2 = vd.edges[e].first;

View File

@ -553,7 +553,7 @@ void buildRug() {
return;
}
celllister cl(centerover.c ? centerover.c : cwt.c, sightrange, vertex_limit, NULL);
celllister cl(centerover.c ? centerover.c : cwt.c, get_sightrange(), vertex_limit, NULL);
map<cell*, rugpoint *> vptr;
@ -1114,7 +1114,7 @@ void drawTriangle(triangle& t) {
using namespace hyperpoint_vec;
for(int i: {0,1,2}) {
if(!t.m[i]->valid) return;
if(t.m[i]->dist >= sightrange+.51) return;
if(t.m[i]->dist >= get_sightrange()+.51) return;
}
dt++;

View File

@ -152,7 +152,7 @@ void initgame() {
cell *c = euclideanAtCreate(pair_to_vec(EPX, EPY));
princess::generating = true;
c->land = laPalace;
for(int j=BARLEV; j>=0; j--) setdist(c, j, NULL);
setdist(c, 7 - getDistLimit() - genrange_bonus, NULL);
princess::generating = false;
}
@ -174,7 +174,7 @@ void initgame() {
// extern int sightrange; sightrange = 9;
// cwt.c->land = laHell; items[itHell] = 10;
for(int i=BARLEV; i>=0; i--) {
for(int i=BARLEV; i>=7 - getDistLimit() - genrange_bonus; i--) {
if(tactic::trailer && cwt.c->land != laClearing) safety = trailer_safety;
setdist(cwt.c, i, NULL);
if(tactic::trailer) safety = false;
@ -205,7 +205,7 @@ void initgame() {
multi::player[1].c = cwt.c;
if(firstland == laCrossroads2 && i == 6)
multi::player[6].c = createMov(createMov(cwt.c, 0), 3);
setdist(cwt.c->mov[idir], 0, cwt.c);
setdist(cwt.c->mov[idir], 7 - getDistLimit() - genrange_bonus, cwt.c);
multi::player[i].spin = 0;
multi::flipped[i] = true;
multi::whereto[i].d = MD_UNDECIDED;
@ -268,6 +268,8 @@ void initgame() {
bfs();
checkmove();
playermoved = true;
if(!cheater) gamerange_bonus = genrange_bonus = 0;
}
bool havesave = true;