From 1d413a7d97a5cb98cf7616b962f47773002809a3 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 23 Dec 2018 13:11:30 +0100 Subject: [PATCH] racing:: blockoff false routes --- landgen.cpp | 15 ++++--- racing.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 118 insertions(+), 7 deletions(-) diff --git a/landgen.cpp b/landgen.cpp index 330a2339..0ab4e35f 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -182,6 +182,13 @@ const array variant_features {{ }}; #undef VF +void place_elemental_wall(cell *c) { + if(c->land == laEFire) c->wall = waEternalFire; + else if(c->land == laEWater) c->wall = waSea; + else if(c->land == laEAir) c->wall = waChasm; + else if(c->land == laEEarth) c->wall = waStone; + } + void giantLandSwitch(cell *c, int d, cell *from) { switch(c->land) { @@ -2195,12 +2202,8 @@ void giantLandSwitch(cell *c, int d, cell *from) { case laEFire: // but not case laElementalWall: if(d==8) { - if(hrand(c->land == laEAir ? 6 : 25) == 0) { - if(c->land == laEFire) c->wall = waEternalFire; - else if(c->land == laEWater) c->wall = waSea; - else if(c->land == laEAir) c->wall = waChasm; - else if(c->land == laEEarth) c->wall = waStone; - } + if(hrand(c->land == laEAir ? 6 : 25) == 0) + place_elemental_wall(c); } ONEMPTY { eItem localshard = localshardof(c->land); diff --git a/racing.cpp b/racing.cpp index 296f38a5..9d5e363c 100644 --- a/racing.cpp +++ b/racing.cpp @@ -25,6 +25,7 @@ struct race_cellinfo { cell *c; int from_track; int completion; + int from_start, from_goal; }; vector rti; @@ -173,7 +174,7 @@ int trackval(cell *c) { void tie_info(cell *c, int from_track, int comp) { rti_id[c] = isize(rti); - rti.emplace_back(race_cellinfo{c, from_track, comp}); + rti.emplace_back(race_cellinfo{c, from_track, comp, -1, -1}); } race_cellinfo& get_info(cell *c) { @@ -391,6 +392,7 @@ void generate_track() { transmatrix T = straight * parabolic1(cleaner * dir); cell *at = s; virtualRebase(at, T, true); + get_info(at).from_start = 0; for(ld u=0; u<50; u++) { if(at->wall != waBarrier) makeEmpty(at); @@ -432,6 +434,112 @@ void generate_track() { } } + if(1) { + map > cdists; + manual_celllister cl; + cl.add(s); + for(auto cc: rti) if(cc.from_start == 0) cl.add(cc.c); + + for(int i=0; i > cdists; + manual_celllister cl; + for(auto cc: rti) if(among(cc.c->wall, waCloud, waMirror)) + cc.from_goal = 0, cl.add(cc.c); + + for(int i=0; i 3; + }; + + auto blockbound = [&blockoff] (cell *c) { + forCellEx(c2, c) if(passable(c2, c, P_ISPLAYER) && !blockoff(get_info(c2))) return true; + return false; + }; + + vector to_block; + + for(auto cc: rti) if(blockoff(cc)) to_block.push_back(cc.c); + + hrandom_shuffle(&to_block[0], isize(to_block)); + + for(cell *c: to_block) switch(specialland) { + case laIce: + c->wall = waIcewall; + break; + + case laHell: + c->wall = waSulphur; + break; + + case laJungle: { + vector dirs; + forCellIdEx(c2, i, c) if(among(c2->monst, moIvyRoot, moIvyWait)) dirs.push_back(i); + if(dirs.empty()) c->monst = moIvyRoot; + else c->monst = moIvyWait, c->mondir = dirs[hrand(isize(dirs))]; + break; + } + + case laDeadCaves: + if(blockbound(c)) c->wall = waDeadwall; + break; + + case laRedRock: + if(blockbound(c)) c->wall = waRed3; + break; + + case laDragon: + c->wall = waChasm; + break; + + case laDryForest: + if(blockbound(c)) c->wall = waBigTree; + break; + + case laDesert: + if(blockbound(c)) c->wall = waDune; + break; + + case laRuins: + if(blockbound(c)) c->wall = waRuinWall; + break; + + case laElementalWall: + if(blockbound(c)) { + if(c->land == laEFire) c->wall = waEternalFire; + else if(c->land == laEWater) c->wall = waSea; + else if(c->land == laEAir) c->wall = waChasm; + else if(c->land == laEEarth) c->wall = waStone; + } + break; + + default: break; + } + + // for(cell *c: to_block) if(blockbound(c)) c->land = laOvergrown; + /* for(cell *c: track) { int i = trackval(c) - celldist(c);