2019-08-10 11:43:24 +00:00
|
|
|
// Hyperbolic Rogue -- minor modes
|
|
|
|
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-08-10 11:43:24 +00:00
|
|
|
/** \file yendor.cpp
|
|
|
|
* \brief Yendor Quest/Challenge, Pure Tactics Mode, Peace Mode
|
|
|
|
*/
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-09-05 07:15:40 +00:00
|
|
|
#include "hyper.h"
|
2018-06-10 23:58:31 +00:00
|
|
|
namespace hr {
|
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
namespace peace { extern bool on; }
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX int hiitemsMax(eItem it) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int mx = 0;
|
2017-08-17 23:40:07 +00:00
|
|
|
for(auto& a: hiitems) if(a.second[it] > mx) mx = a.second[it];
|
2016-08-26 09:58:03 +00:00
|
|
|
return mx;
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:04:18 +00:00
|
|
|
/** 1 - just return UNKNOWN if id not assigned; 2 - assign without writing to file; 3 - assign with writing to file */
|
|
|
|
EX modecode_t modecode(int mode IS(3));
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
typedef vector<pair<int, string> > subscoreboard;
|
|
|
|
|
|
|
|
void displayScore(subscoreboard& s, int x) {
|
|
|
|
int vf = min((vid.yres-64) / 70, vid.xres/80);
|
|
|
|
|
2018-05-15 21:23:12 +00:00
|
|
|
if(get_sync_status() == 1) {
|
2016-08-26 09:58:03 +00:00
|
|
|
displayfr(x, 56, 1, vf, "(syncing)", 0xC0C0C0, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sort(s.begin(), s.end());
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(s); i++) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int i0 = 56 + i * vf;
|
|
|
|
displayfr(x, i0, 1, vf, its(-s[i].first), 0xC0C0C0, 16);
|
|
|
|
displayfr(x+8, i0, 1, vf, s[i].second, 0xC0C0C0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 23:20:47 +00:00
|
|
|
EX namespace yendor {
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-08-09 23:20:47 +00:00
|
|
|
EX bool on = false;
|
|
|
|
EX bool generating = false;
|
2019-09-05 10:00:55 +00:00
|
|
|
EX bool path = false;
|
|
|
|
EX bool everwon = false;
|
|
|
|
EX bool won = false;
|
2016-08-26 09:58:03 +00:00
|
|
|
bool easy = false;
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX int challenge; // id of the challenge
|
|
|
|
EX int lastchallenge;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-08-09 23:20:47 +00:00
|
|
|
#if HDR
|
|
|
|
#define YF_DEAD 1
|
|
|
|
#define YF_WALLS 2
|
|
|
|
#define YF_END 4
|
|
|
|
#define YF_DEAD5 8
|
|
|
|
|
|
|
|
#define YF_NEAR_IVY 16
|
|
|
|
#define YF_NEAR_ELEM 32
|
|
|
|
#define YF_NEAR_OVER 64
|
|
|
|
#define YF_NEAR_RED 128
|
|
|
|
#define YF_REPEAT 512
|
|
|
|
#define YF_NEAR_TENT 1024
|
|
|
|
|
|
|
|
#define YF_START_AL 2048
|
|
|
|
#define YF_START_CR 4096
|
|
|
|
#define YF_CHAOS 8192
|
|
|
|
#define YF_RECALL 16384
|
|
|
|
#define YF_NEAR_FJORD 32768
|
|
|
|
|
|
|
|
#define YF_START_ANY (YF_START_AL|YF_START_CR)
|
|
|
|
|
|
|
|
struct yendorlevel {
|
|
|
|
eLand l;
|
|
|
|
int flags;
|
|
|
|
};
|
2019-09-05 10:00:55 +00:00
|
|
|
|
2020-02-28 23:16:35 +00:00
|
|
|
#define YENDORLEVELS 34
|
2019-09-05 10:00:55 +00:00
|
|
|
#endif
|
2017-08-17 23:40:07 +00:00
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX map<modecode_t, array<int, YENDORLEVELS>> bestscore;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-08-09 23:20:47 +00:00
|
|
|
EX eLand nexttostart;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
yendorlevel levels[YENDORLEVELS] = {
|
|
|
|
{laNone, 0},
|
|
|
|
{laHell, YF_DEAD}, // FORCE BARRIERS?
|
|
|
|
{laGraveyard, YF_DEAD5},
|
|
|
|
{laDesert, YF_NEAR_IVY}, // IVY OR TENTACLE?
|
|
|
|
{laMinefield, YF_END}, // NOT WON, SEEMS OKAY
|
|
|
|
{laEmerald, 0}, // WON FINE
|
|
|
|
{laOvergrown, 0}, // WON, TOO EASY?
|
|
|
|
{laMotion, YF_START_AL | YF_END}, // NOT WON, SEEMS OKAY
|
|
|
|
{laAlchemist, 0}, // ALMOST WON
|
|
|
|
{laIvoryTower,YF_START_CR | YF_NEAR_ELEM | YF_REPEAT}, // won cool
|
2017-07-22 23:33:27 +00:00
|
|
|
{laMirrorOld, YF_NEAR_OVER}, // OK
|
2016-08-26 09:58:03 +00:00
|
|
|
{laWhirlpool, 0}, // cool
|
|
|
|
{laIce, YF_NEAR_ELEM}, // OK
|
|
|
|
{laHive, YF_NEAR_RED}, // OK
|
|
|
|
{laCaribbean, 0}, // seems OK
|
|
|
|
{laOcean, YF_WALLS}, // well... stupid, add Caribbean/Fjord
|
|
|
|
{laPalace, 0}, // more trapdoors!
|
|
|
|
{laZebra, 0}, // TOO HARD?
|
|
|
|
{laWineyard, 0}, // hard-ish
|
|
|
|
{laStorms, 0}, // ?
|
|
|
|
{laLivefjord, 0},
|
|
|
|
{laJungle, 0},
|
|
|
|
{laPower, YF_START_CR},
|
|
|
|
{laWildWest, 0},
|
|
|
|
{laWhirlwind, YF_NEAR_TENT},
|
|
|
|
{laHell, YF_CHAOS | YF_DEAD},
|
2017-03-23 10:53:57 +00:00
|
|
|
{laDragon, YF_DEAD},
|
|
|
|
{laReptile, 0},
|
|
|
|
{laTortoise, YF_RECALL},
|
2018-01-06 21:41:28 +00:00
|
|
|
{laCocytus, YF_NEAR_FJORD},
|
2018-02-11 22:30:36 +00:00
|
|
|
{laRuins, YF_DEAD},
|
2018-12-22 21:39:16 +00:00
|
|
|
{laCaves, YF_DEAD5},
|
|
|
|
{laWestWall, YF_START_CR},
|
2020-02-28 23:16:35 +00:00
|
|
|
{laEclectic, 0},
|
2019-01-16 23:45:36 +00:00
|
|
|
// {laVariant, YF_DEAD5}, (I do not think this works)
|
2016-08-26 09:58:03 +00:00
|
|
|
};
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
int tscorelast;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2024-06-02 10:25:22 +00:00
|
|
|
EX int compute_tscore(modecode_t mc) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int tscore = 0;
|
|
|
|
for(int i=1; i<YENDORLEVELS; i++)
|
2024-06-02 10:25:22 +00:00
|
|
|
if(bestscore[mc][i]) tscore += 999 + bestscore[0][i];
|
|
|
|
return tscore;
|
|
|
|
}
|
|
|
|
|
|
|
|
EX void uploadScore() {
|
|
|
|
int tscore = compute_tscore(0);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(tscore > tscorelast) {
|
|
|
|
tscorelast = tscore;
|
2018-04-09 16:05:23 +00:00
|
|
|
if(tscore >= 1000) achievement_gain("YENDC1", rg::global);
|
|
|
|
if(tscore >= 5000) achievement_gain("YENDC2", rg::global);
|
|
|
|
if(tscore >= 15000) achievement_gain("YENDC3", rg::global);
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
achievement_score(LB_YENDOR_CHALLENGE, tscore);
|
|
|
|
}
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX yendorlevel& clev() { return levels[challenge]; }
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2021-07-31 09:55:27 +00:00
|
|
|
EX eLand changeland(int i, eLand l) {
|
2018-09-23 11:46:21 +00:00
|
|
|
if(l == laIvoryTower) return laNone;
|
2016-08-26 09:58:03 +00:00
|
|
|
if((clev().flags & YF_START_ANY) && i < 20 && l != clev().l) return clev().l;
|
|
|
|
if((clev().flags & YF_END) && i > 80 && l == clev().l) return laIce;
|
|
|
|
return laNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
eLand first, second, last;
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
#if HDR
|
2016-08-26 09:58:03 +00:00
|
|
|
struct yendorinfo {
|
|
|
|
cell *path[YDIST];
|
2018-12-22 21:39:16 +00:00
|
|
|
cell *actualKey;
|
2016-08-26 09:58:03 +00:00
|
|
|
bool found;
|
|
|
|
bool foundOrb;
|
|
|
|
int howfar;
|
2018-12-22 21:39:16 +00:00
|
|
|
bignum age;
|
|
|
|
yendorinfo() { actualKey = NULL; }
|
2017-08-06 12:50:16 +00:00
|
|
|
cell* key() { return path[YDIST-1]; }
|
2018-12-22 21:39:16 +00:00
|
|
|
cell *actual_key() { return actualKey ? actualKey : key(); }
|
2017-08-06 12:50:16 +00:00
|
|
|
cell* orb() { return path[0]; }
|
2016-08-26 09:58:03 +00:00
|
|
|
};
|
2019-09-05 10:00:55 +00:00
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX vector<yendorinfo> yi;
|
2019-09-06 06:17:02 +00:00
|
|
|
|
|
|
|
#if HDR
|
2017-03-23 10:53:57 +00:00
|
|
|
#define NOYENDOR 999999
|
2019-09-06 06:17:02 +00:00
|
|
|
#endif
|
|
|
|
EX int yii = NOYENDOR;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX int hardness() {
|
2017-07-04 13:38:33 +00:00
|
|
|
if(peace::on) return 15; // just to generate monsters
|
2017-07-12 16:03:53 +00:00
|
|
|
if(!yendor::generating && !yendor::path && !yendor::on) return 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
int thf = 0;
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(yi); i++) {
|
2016-08-26 09:58:03 +00:00
|
|
|
yendorinfo& ye ( yi[i] );
|
|
|
|
if(!ye.foundOrb && ye.howfar > 25)
|
|
|
|
thf += (ye.howfar - 25);
|
|
|
|
}
|
|
|
|
thf -= 2 * (YDIST - 25);
|
|
|
|
if(thf<0) thf = 0;
|
|
|
|
return items[itOrbYendor] * 5 + (thf * 5) / (YDIST-25);
|
|
|
|
}
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
#if HDR
|
2016-08-26 09:58:03 +00:00
|
|
|
enum eState { ysUntouched, ysLocked, ysUnlocked };
|
2019-09-05 10:00:55 +00:00
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX eState state(cell *yendor) {
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(yi); i++) if(yi[i].path[0] == yendor)
|
2016-08-26 09:58:03 +00:00
|
|
|
return yi[i].found ? ysUnlocked : ysLocked;
|
|
|
|
return ysUntouched;
|
|
|
|
}
|
2019-11-15 01:51:25 +00:00
|
|
|
|
2021-07-31 09:55:27 +00:00
|
|
|
EX bool control(pathgen& p, int i, cellwalker& ycw) {
|
|
|
|
|
|
|
|
// change lands in the Challenge
|
|
|
|
if(i > BARLEV-6) {
|
|
|
|
p.last_id = i+7-BARLEV;
|
|
|
|
setdist(p.path[p.last_id], 7, p.path[i+6-BARLEV]);
|
|
|
|
if(yendor::challenge && !euclid && ycw.at->land != laIvoryTower) {
|
|
|
|
eLand ycl = yendor::changeland(i, ycw.at->land);
|
|
|
|
if(ycl) {
|
|
|
|
if(weirdhyperbolic) {
|
|
|
|
buildBarrierNowall(ycw.at, ycl);
|
|
|
|
}
|
|
|
|
else if(hyperbolic && ishept(ycw.at)) {
|
|
|
|
int bd = 2 + hrand(2) * 3;
|
|
|
|
buildBarrier(ycw.at, bd, ycl);
|
|
|
|
if(ycw.at->bardir != NODIR && ycw.at->bardir != NOBARRIERS)
|
|
|
|
extendBarrier(ycw.at);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// follow the branch in Yendorian
|
|
|
|
if(ycw.at->land == laEndorian) {
|
|
|
|
int bestval = -2000;
|
|
|
|
int best = 0, qbest = 0;
|
|
|
|
for(int d=0; d<ycw.at->type; d++) {
|
|
|
|
setdist(ycw.at, 7, ycw.peek());
|
|
|
|
cell *c1 = (ycw+d).cpeek();
|
|
|
|
int val = d * (ycw.at->type - d);
|
|
|
|
if(c1->wall == waTrunk) val += (i < YDIST-20 ? 1000 : -1000);
|
|
|
|
if(val > bestval) qbest = 0, bestval = val;
|
|
|
|
if(val == bestval) if(hrand(++qbest) == 0) best = d;
|
|
|
|
}
|
|
|
|
ycw += best;
|
|
|
|
return true;
|
|
|
|
}
|
2019-11-15 01:51:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-07-31 09:55:27 +00:00
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX bool check(cell *yendor) {
|
2018-06-22 12:47:24 +00:00
|
|
|
int byi = isize(yi);
|
|
|
|
for(int i=0; i<isize(yi); i++) if(yi[i].path[0] == yendor) byi = i;
|
|
|
|
if(byi < isize(yi) && yi[byi].found) return false;
|
|
|
|
if(byi == isize(yi)) {
|
2020-09-16 19:03:23 +00:00
|
|
|
retry:
|
|
|
|
int creation_attempt = 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
yendorinfo nyi;
|
|
|
|
nyi.howfar = 0;
|
|
|
|
|
2018-09-23 11:46:21 +00:00
|
|
|
generating = true;
|
|
|
|
|
2021-07-31 09:55:27 +00:00
|
|
|
auto p = generate_random_path_randomdir(yendor, YDIST-1, true);
|
|
|
|
for(int i=0; i<YDIST; i++) nyi.path[i] = p.path[i];
|
2018-09-23 11:46:21 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
nyi.found = false;
|
|
|
|
nyi.foundOrb = false;
|
|
|
|
|
2018-12-22 21:39:16 +00:00
|
|
|
for(int i=1; i<YDIST; i++) {
|
|
|
|
setdist(nyi.path[i], 7, nyi.path[i-1]);
|
|
|
|
if(isEquidLand(nyi.path[i]->land)) {
|
|
|
|
// println(hlog, i, ": ", coastvalEdge(nyi.path[i]));
|
|
|
|
buildEquidistant(nyi.path[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-23 11:46:21 +00:00
|
|
|
setdist(nyi.path[YDIST-1], 7, nyi.path[YDIST-2]);
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *key = nyi.path[YDIST-1];
|
2020-09-16 19:03:23 +00:00
|
|
|
|
2021-07-31 09:55:27 +00:00
|
|
|
yendor::generating = false;
|
2020-09-21 10:04:50 +00:00
|
|
|
|
2020-09-16 19:03:23 +00:00
|
|
|
for(int b=10; b>=5; b--) setdist(key, b, nyi.path[YDIST-2]);
|
2020-09-21 10:04:50 +00:00
|
|
|
|
2020-09-16 19:03:23 +00:00
|
|
|
if(inmirror(key) || (geometry == gNormal && celldistance(key, yendor) < YDIST/2)) {
|
|
|
|
creation_attempt++;
|
2020-09-21 10:04:50 +00:00
|
|
|
if(creation_attempt > 100) {
|
2020-09-16 19:03:23 +00:00
|
|
|
yendor->item = itNone;
|
|
|
|
addMessage(XLAT("%The1 turned out to be an illusion!", itOrbYendor));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
goto retry;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2024-04-07 22:45:03 +00:00
|
|
|
auto rollbacks = std::move(changes.rollbacks);
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=-1; i<key->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = i >= 0 ? key->move(i) : key;
|
2016-08-26 09:58:03 +00:00
|
|
|
checkTide(c2);
|
2024-04-07 22:45:03 +00:00
|
|
|
makeNoMonster(c2);
|
|
|
|
c2->item = itNone;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!passable(c2, NULL, P_MIRROR | P_MONSTER)) {
|
|
|
|
if(c2->wall == waCavewall) c2->wall = waCavefloor;
|
|
|
|
else if(c2->wall == waDeadwall) c2->wall = waDeadfloor2;
|
|
|
|
else if(c2->wall == waLake) c2->wall = waFrozenLake;
|
|
|
|
else if(c2->land == laCaribbean) c2->wall = waCIsland;
|
|
|
|
else if(c2->land == laOcean) c2->wall = waCIsland;
|
|
|
|
else if(c2->land == laRedRock) c2->wall = waRed3;
|
|
|
|
else if(c2->land == laWhirlpool)
|
|
|
|
c2->wall = waBoat, c2->monst = moPirate, c2->item = itOrbWater;
|
|
|
|
else c2->wall = waNone;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->wall == waReptile) c2->wall = waNone;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->wall == waMineMine || c2->wall == waMineUnknown)
|
|
|
|
c2->wall = waMineOpen;
|
|
|
|
if(c2->wall == waTrapdoor && i == -1)
|
|
|
|
c2->wall = waGargoyleFloor;
|
|
|
|
if(c2->land == laLivefjord) {
|
|
|
|
c2->wall = waSea;
|
|
|
|
for(int i=0; i<c2->type; i++)
|
2018-08-17 22:46:45 +00:00
|
|
|
c2->move(i)->wall = waSea;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2018-12-22 21:39:16 +00:00
|
|
|
if(isGravityLand(c2->land) && key->land == c2->land && c2->land != laWestWall &&
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->landparam < key->landparam && c2->wall != waTrunk)
|
|
|
|
c2->wall = waPlatform;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->land == laReptile && i >= 0)
|
|
|
|
c2->wall = waChasm;
|
2017-07-16 21:00:55 +00:00
|
|
|
if(c2->land == laMirrorWall && i == -1)
|
|
|
|
c2->wall = waNone;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2024-04-07 22:45:03 +00:00
|
|
|
changes.rollbacks = std::move(rollbacks);
|
2016-08-26 09:58:03 +00:00
|
|
|
key->item = itKey;
|
2018-12-22 21:39:16 +00:00
|
|
|
|
|
|
|
bool split_found = false;
|
|
|
|
|
|
|
|
if(key->land == laWestWall && trees_known()) {
|
|
|
|
|
2021-12-11 22:28:05 +00:00
|
|
|
auto& expansion = get_expansion();
|
2018-12-22 21:39:16 +00:00
|
|
|
int t = type_in(expansion, yendor, [yendor] (cell *c) { return celldistance(yendor, c); });
|
|
|
|
int maxage = 10;
|
|
|
|
for(int i=0; i<min(items[itOrbYendor], 8); i++)
|
|
|
|
maxage *= 10;
|
|
|
|
|
|
|
|
nyi.age = maxage - hrand(maxage/2);
|
2021-07-31 09:55:27 +00:00
|
|
|
bignum full_id = p.full_id_0 - nyi.age;
|
2018-12-22 21:39:16 +00:00
|
|
|
bool onlychild = true;
|
|
|
|
|
2021-07-31 09:55:27 +00:00
|
|
|
cellwalker ycw = p.start;
|
2018-12-22 21:39:16 +00:00
|
|
|
ycw--; if(S3 == 3) ycw--;
|
|
|
|
|
|
|
|
for(int i=0; i<YDIST-1; i++) {
|
|
|
|
|
|
|
|
if(i == 1) onlychild = true;
|
|
|
|
if(!onlychild) ycw++;
|
2019-12-14 11:31:20 +00:00
|
|
|
if(valence() == 3) ycw++;
|
2018-12-22 21:39:16 +00:00
|
|
|
|
|
|
|
onlychild = false;
|
|
|
|
|
|
|
|
for(int tch: expansion.children[t]) {
|
|
|
|
ycw++;
|
|
|
|
if(i == 1)
|
|
|
|
tch = type_in(expansion, ycw.cpeek(), [yendor] (cell *c) { return celldistance(yendor, c); });
|
|
|
|
auto& sub_id = expansion.get_descendants(YDIST-i-2, tch);
|
|
|
|
if(full_id < sub_id) {
|
2021-07-31 09:55:27 +00:00
|
|
|
if(!split_found && !(p.full_id_0 < sub_id)) {
|
2019-11-22 22:10:36 +00:00
|
|
|
// ycw.at->item = itRuby;
|
2018-12-22 21:39:16 +00:00
|
|
|
split_found = true;
|
|
|
|
setdist(ycw.at, 6, NULL);
|
|
|
|
auto tt = type_in(expansion, ycw.at, coastvalEdge);
|
|
|
|
// println(hlog, "at split, ydist-type: ", t, " coast-type: ", tt);
|
|
|
|
if(t != tt) {
|
|
|
|
// try again!
|
|
|
|
key->item = itNone;
|
|
|
|
return check(yendor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t = tch;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
full_id.addmul(sub_id, -1);
|
2021-07-31 09:55:27 +00:00
|
|
|
if(!split_found) p.full_id_0.addmul(sub_id, -1);
|
2018-12-22 21:39:16 +00:00
|
|
|
onlychild = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(inmirror(ycw)) ycw = mirror::reflect(ycw);
|
|
|
|
ycw += wstep;
|
|
|
|
setdist(ycw.at, 8, ycw.peek());
|
|
|
|
buildEquidistant(ycw.at);
|
|
|
|
// println(hlog, "actual key #", i, ": ", ycw.at->landparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
nyi.actualKey = ycw.at;
|
|
|
|
ycw.at->item = itKey;
|
2019-01-24 13:52:27 +00:00
|
|
|
key->item = itNone;
|
2018-12-22 21:39:16 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
yi.push_back(nyi);
|
|
|
|
}
|
2020-03-16 20:42:26 +00:00
|
|
|
dynamicval<bool> b(changes.on, false);
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("You need to find the right Key to unlock this Orb of Yendor!"));
|
2018-12-22 21:39:16 +00:00
|
|
|
if(yi[byi].actualKey)
|
|
|
|
addMessage(XLAT("You feel that these directions are %1 turns old.", yi[byi].age.get_str(100)));
|
2017-03-23 10:53:57 +00:00
|
|
|
if(yii != byi) {
|
|
|
|
yii = byi;
|
2020-04-06 07:22:05 +00:00
|
|
|
achievement_gain_once("YENDOR1");
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(yendor, "pickup-yendor");
|
|
|
|
return true;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX void onpath() {
|
2016-08-26 09:58:03 +00:00
|
|
|
path = false;
|
2018-06-22 12:47:24 +00:00
|
|
|
if(yii < isize(yi)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<YDIST; i++) if(yi[yii].path[i]->cpdist <= 7) {
|
|
|
|
if(i > yi[yii].howfar) yi[yii].howfar = i;
|
|
|
|
path = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-11 20:15:40 +00:00
|
|
|
|
|
|
|
EX eLandStructure get_land_structure() {
|
|
|
|
if(clev().flags & YF_CHAOS)
|
|
|
|
return lsChaos;
|
|
|
|
if(clev().l == laWhirlpool)
|
|
|
|
return lsSingle;
|
|
|
|
return lsNiceWalls;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX void init(int phase) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!on) return;
|
|
|
|
|
|
|
|
if(phase == 1) {
|
|
|
|
won = false;
|
|
|
|
if(!easy) items[itOrbYendor] = bestscore[modecode()][challenge];
|
2021-04-11 20:15:40 +00:00
|
|
|
land_structure = get_land_structure();
|
2018-04-14 07:34:33 +00:00
|
|
|
specialland = clev().l;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(clev().flags & YF_START_AL) {
|
2018-04-14 07:34:33 +00:00
|
|
|
specialland = laAlchemist;
|
2016-08-26 09:58:03 +00:00
|
|
|
items[itElixir] = 50;
|
|
|
|
items[itFeather] = 50;
|
|
|
|
}
|
2018-04-14 07:34:33 +00:00
|
|
|
if(specialland == laPower)
|
2016-08-26 09:58:03 +00:00
|
|
|
items[itOrbSpeed] = 60, items[itOrbWinter] = 60;
|
|
|
|
if(clev().flags & YF_START_CR) {
|
2018-04-14 07:34:33 +00:00
|
|
|
specialland = laCrossroads;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2018-04-14 07:34:33 +00:00
|
|
|
if(specialland == laGraveyard) items[itBone] = 10;
|
|
|
|
if(specialland == laEmerald) items[itEmerald] = 10;
|
|
|
|
if(specialland == laCocytus) items[itFjord] = 10;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!euclid) {
|
|
|
|
if(clev().flags & YF_DEAD) items[itGreenStone] = 100;
|
|
|
|
if(clev().flags & YF_DEAD5) items[itGreenStone] = 5;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(clev().flags & YF_RECALL) {
|
|
|
|
int yq = items[itOrbYendor];
|
|
|
|
items[itOrbRecall] = 60 - yq;
|
|
|
|
items[itOrbTime] = 60 - yq;
|
|
|
|
items[itOrbEnergy] = 60 - yq;
|
|
|
|
items[itOrbTeleport] = 60 - yq;
|
|
|
|
items[itOrbSpace] = 60 - yq;
|
|
|
|
items[itOrbDash] = 60 - yq;
|
|
|
|
items[itOrbFrog] = 60 - yq;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
nexttostart = laNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(phase == 2) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = cwt.at->move(0);
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->land = firstland;
|
|
|
|
if(firstland == laRlyeh) c2->wall = waNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
yendor::check(c2);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(clev().flags & YF_NEAR_IVY)
|
|
|
|
nexttostart = laJungle;
|
2017-08-06 12:50:16 +00:00
|
|
|
if(clev().flags & YF_NEAR_FJORD)
|
|
|
|
nexttostart = laLivefjord;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(clev().flags & YF_NEAR_TENT)
|
|
|
|
nexttostart = laRlyeh;
|
|
|
|
if(clev().flags & YF_NEAR_ELEM) {
|
|
|
|
if(firstland == laIce) {
|
|
|
|
nexttostart = laEWater;
|
|
|
|
items[itWaterShard] = 10;
|
|
|
|
}
|
|
|
|
else nexttostart = laEAir;
|
|
|
|
}
|
|
|
|
if(clev().flags & YF_NEAR_OVER)
|
|
|
|
nexttostart = laOvergrown;
|
|
|
|
if(clev().flags & YF_NEAR_RED) {
|
|
|
|
nexttostart = laRedRock;
|
|
|
|
items[itRedGem] = 25;
|
|
|
|
}
|
|
|
|
if(clev().flags & YF_WALLS) {
|
|
|
|
items[itPirate] += 25;
|
|
|
|
items[itFjord] += 25;
|
|
|
|
}
|
|
|
|
if(clev().l == laWhirlpool) {
|
|
|
|
items[itWhirlpool] += 10;
|
|
|
|
items[itOrbWater] += 150;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(phase == 3) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = cwt.at->move(0);
|
2016-08-26 09:58:03 +00:00
|
|
|
makeEmpty(c2);
|
|
|
|
c2->item = itOrbYendor;
|
|
|
|
nexttostart = laNone;
|
2019-12-27 22:02:07 +00:00
|
|
|
if(clev().flags & YF_RECALL)
|
|
|
|
saveRecall(cwt);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool levelUnlocked(int i) {
|
|
|
|
yendorlevel& ylev(levels[i]);
|
|
|
|
|
|
|
|
eItem t = treasureType(ylev.l);
|
|
|
|
if(ylev.l != laWildWest && hiitemsMax(t) < 10) return false;
|
|
|
|
if((ylev.flags & YF_NEAR_ELEM) && hiitemsMax(itElemental) < 10) return false;
|
|
|
|
if((ylev.flags & YF_NEAR_RED) && hiitemsMax(itRedGem) < 10) return false;
|
|
|
|
if((ylev.flags & YF_NEAR_OVER) && hiitemsMax(itMutant) < 10) return false;
|
|
|
|
if((ylev.flags & YF_NEAR_TENT) && hiitemsMax(itStatue) < 10) return false;
|
2017-08-06 12:50:16 +00:00
|
|
|
if((ylev.flags & YF_NEAR_FJORD) && hiitemsMax(itFjord) < 10) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if((ylev.flags & YF_CHAOS) && !chaosUnlocked) return false;
|
|
|
|
if((ylev.flags & (YF_DEAD|YF_DEAD5)) && hiitemsMax(itBone) < 10) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if((ylev.flags & YF_RECALL) && hiitemsMax(itSlime) < 10) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct scoredata {
|
|
|
|
string username;
|
|
|
|
int scores[landtypes];
|
|
|
|
};
|
|
|
|
vector<scoredata> scoreboard;
|
|
|
|
|
2019-09-06 06:17:02 +00:00
|
|
|
EX const char *chelp =
|
2017-07-10 18:47:38 +00:00
|
|
|
"There are many possible solutions to the Yendor Quest. In the Yendor "
|
|
|
|
"Challenge, you will try many of them!\n\n"
|
|
|
|
"Each challenge takes part in a specific land, and you have to use what "
|
|
|
|
"you have available.\n\n"
|
|
|
|
|
|
|
|
"You need to obtain an Orb of Yendor in the normal game to activate "
|
|
|
|
"this challenge, and (ever) collect 10 treasures in one or two lands "
|
|
|
|
"to activate a specific level.\n\n"
|
|
|
|
|
|
|
|
"After you complete each challenge, you can try it again, on a harder "
|
|
|
|
"difficulty level.\n\n"
|
|
|
|
|
|
|
|
"All the solutions showcased in the Yendor Challenge work in the normal "
|
|
|
|
"play too. However, passages to other lands, and (sometimes) some land features "
|
|
|
|
"are disabled in the Yendor "
|
|
|
|
"Challenge, so that you have to use the expected method. Also, "
|
|
|
|
"the generation rules are changed slightly for the Palace "
|
|
|
|
"and Minefield while you are looking for the Orb of Yendor, "
|
|
|
|
"to make the challenge more balanced "
|
|
|
|
"(but these changes are also active during the normal Yendor Quest).\n\n"
|
|
|
|
|
|
|
|
"You get 1000 points for each challenge won, and 1 extra point for "
|
|
|
|
"each extra difficulty level.";
|
2018-02-11 22:31:04 +00:00
|
|
|
|
|
|
|
int char_to_yendor(char c) {
|
|
|
|
if(c >= 'a' && c <= 'z')
|
|
|
|
return c - 'a' + 1;
|
|
|
|
if(c >= 'A' && c <= 'Z')
|
|
|
|
return c - 'A' + 1 + 26;
|
|
|
|
return 0;
|
|
|
|
}
|
2020-01-06 21:03:45 +00:00
|
|
|
|
|
|
|
EX string name(int i) {
|
|
|
|
yendorlevel& ylev(levels[i]);
|
|
|
|
|
|
|
|
string s = XLATT1(ylev.l);
|
|
|
|
if(!euclid) {
|
|
|
|
if(ylev.flags & YF_CHAOS) { s = "Chaos mode"; }
|
|
|
|
if(ylev.flags & YF_NEAR_IVY) { s += "+"; s += XLATT1(laJungle); }
|
|
|
|
if(ylev.flags & YF_NEAR_FJORD) { s += "+"; s += XLATT1(laLivefjord); }
|
|
|
|
if(ylev.flags & YF_NEAR_TENT) { s += "+"; s += XLATT1(laRlyeh); }
|
|
|
|
if(ylev.flags & YF_NEAR_ELEM) { s += "+"; s += XLATT1(laElementalWall); }
|
|
|
|
if(ylev.flags & YF_NEAR_OVER) { s += "+"; s += XLATT1(laOvergrown); }
|
|
|
|
if(ylev.flags & YF_NEAR_RED) { s += "+"; s += XLATT1(laRedRock); }
|
|
|
|
if(ylev.flags & YF_START_AL) { s += "+"; s += XLATT1(laAlchemist); }
|
|
|
|
if(ylev.flags & YF_DEAD) { s += "+"; s += XLATT1(itGreenStone); }
|
|
|
|
if(ylev.flags & YF_RECALL) { s += "+"; s += XLATT1(itOrbRecall); }
|
|
|
|
}
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
|
2019-09-06 06:17:02 +00:00
|
|
|
EX void showMenu() {
|
2018-05-15 21:23:12 +00:00
|
|
|
set_priority_board(LB_YENDOR_CHALLENGE);
|
2016-08-26 09:58:03 +00:00
|
|
|
int s = vid.fsize;
|
|
|
|
vid.fsize = vid.fsize * 4/5;
|
2017-03-23 10:53:57 +00:00
|
|
|
dialog::init(XLAT("Yendor Challenge"), iinf[itOrbYendor].color, 150, 100);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2022-10-21 09:27:49 +00:00
|
|
|
dialog::start_list(2000, 2000);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=1; i<YENDORLEVELS; i++) {
|
|
|
|
string s;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(autocheat || levelUnlocked(i)) {
|
2020-01-06 21:03:45 +00:00
|
|
|
s = name(i);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
s = "(locked)";
|
|
|
|
}
|
|
|
|
|
|
|
|
string v;
|
|
|
|
if(bestscore[modecode()][i] == 1)
|
|
|
|
v = XLAT(" (won!)");
|
|
|
|
else if(bestscore[modecode()][i])
|
|
|
|
v = XLAT(" (won at level %1!)", its(bestscore[modecode()][i]));
|
|
|
|
|
2018-02-11 22:31:04 +00:00
|
|
|
dialog::addSelItem(s, v, i > 26 ? 'A' + i - 27 : 'a' + i-1);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2022-10-21 09:27:49 +00:00
|
|
|
dialog::end_list();
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
dialog::addBreak(60);
|
2017-10-31 01:44:54 +00:00
|
|
|
if (yendor::on)
|
|
|
|
dialog::addItem(XLAT("Return to the normal game"), '0');
|
2021-05-23 12:33:25 +00:00
|
|
|
dialog::addSelItem(
|
|
|
|
easy ? XLAT("Challenges do not get harder") : XLAT("Each challenge gets harder after each victory"),
|
2021-05-29 10:17:51 +00:00
|
|
|
" " + (easy ? XLAT("easy") : XLAT("challenge")), '1');
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2018-06-12 22:00:01 +00:00
|
|
|
dialog::addBack();
|
|
|
|
dialog::addHelp();
|
2017-03-23 10:53:57 +00:00
|
|
|
dialog::display();
|
|
|
|
|
2018-02-11 22:31:04 +00:00
|
|
|
int yc = char_to_yendor(getcstat);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(yc > 0 && yc < YENDORLEVELS) {
|
|
|
|
subscoreboard scorehere;
|
|
|
|
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(scoreboard); i++) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int sc = scoreboard[i].scores[yc];
|
|
|
|
if(sc > 0)
|
|
|
|
scorehere.push_back(
|
|
|
|
make_pair(-sc, scoreboard[i].username));
|
|
|
|
}
|
|
|
|
|
2022-11-03 18:37:38 +00:00
|
|
|
displayScore(scorehere, vid.fsize);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yendor::uploadScore();
|
|
|
|
vid.fsize = s;
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
keyhandler = [] (int sym, int uni) {
|
|
|
|
dialog::handleNavigation(sym, uni);
|
2018-02-11 22:31:04 +00:00
|
|
|
int new_challenge = char_to_yendor(uni);
|
|
|
|
if(new_challenge && new_challenge < YENDORLEVELS) {
|
2018-12-14 17:21:52 +00:00
|
|
|
if(levelUnlocked(new_challenge) || autocheat) dialog::do_if_confirmed([new_challenge] {
|
2018-02-11 22:31:04 +00:00
|
|
|
challenge = new_challenge;
|
2018-06-10 22:58:38 +00:00
|
|
|
restart_game(yendor::on ? rg::nothing : rg::yendor);
|
2018-12-14 17:21:52 +00:00
|
|
|
});
|
2017-07-10 18:47:38 +00:00
|
|
|
else
|
|
|
|
addMessage("Collect 10 treasures in various lands to unlock the challenges there");
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-07-10 18:47:38 +00:00
|
|
|
else if(uni == '0') {
|
2018-06-10 22:58:38 +00:00
|
|
|
if(yendor::on) restart_game(rg::yendor);
|
2017-07-10 18:47:38 +00:00
|
|
|
}
|
|
|
|
else if(uni == '1') easy = !easy;
|
|
|
|
else if(uni == '2' || sym == SDLK_F1) gotoHelp(chelp);
|
|
|
|
else if(doexiton(sym, uni)) popScreen();
|
|
|
|
};
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-07-10 18:47:38 +00:00
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX void collected(cell* c2) {
|
2020-02-29 16:58:59 +00:00
|
|
|
LATE( collected(c2); )
|
2017-07-04 13:38:33 +00:00
|
|
|
playSound(c2, "tada");
|
|
|
|
items[itOrbShield] += 31;
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(yendor::yi); i++)
|
2017-07-04 13:38:33 +00:00
|
|
|
if(yendor::yi[i].path[0] == c2)
|
2020-03-02 17:04:11 +00:00
|
|
|
changes.value_set(yendor::yi[i].foundOrb, true);
|
2017-07-04 13:38:33 +00:00
|
|
|
// Shielding always, so that we know that it protects!
|
2020-04-02 11:21:51 +00:00
|
|
|
int powers = 0;
|
|
|
|
for(int i=0; i<1000 && powers < 4; i++) {
|
|
|
|
vector< pair<eItem, int> > choices = {
|
|
|
|
{itOrbSpeed, 31},
|
|
|
|
{itOrbLightning, 78},
|
|
|
|
{itOrbFlash, 78},
|
|
|
|
{itOrbTime, 78},
|
|
|
|
{itOrbWinter, 151},
|
|
|
|
{itOrbDigging, 151},
|
|
|
|
{itOrbTeleport, 151},
|
|
|
|
{itOrbThorns, 151},
|
|
|
|
{itOrbInvis, 151},
|
|
|
|
{itOrbPsi, 151},
|
|
|
|
{itOrbAether, 151},
|
|
|
|
{itOrbFire, 151},
|
|
|
|
{itOrbSpace, 78}
|
|
|
|
};
|
|
|
|
auto p = hrand_elt(choices);
|
|
|
|
auto orb = p.first;
|
|
|
|
if(items[orb] && i < 500) continue;
|
|
|
|
if(among(getOLR(orb, getPrizeLand()), olrDangerous, olrUseless, olrForbidden)) continue;
|
|
|
|
items[orb] += p.second;
|
|
|
|
powers++;
|
2017-07-04 13:38:33 +00:00
|
|
|
}
|
|
|
|
items[itOrbYendor]++;
|
|
|
|
items[itKey]--;
|
2020-03-02 17:04:11 +00:00
|
|
|
changes.value_set(yendor::everwon, true);
|
2017-07-04 13:38:33 +00:00
|
|
|
if(yendor::on) {
|
2020-03-02 17:04:11 +00:00
|
|
|
changes.value_set(yendor::won, true);
|
2017-07-04 13:38:33 +00:00
|
|
|
if(!cheater) {
|
|
|
|
yendor::bestscore[modecode()][yendor::challenge] =
|
|
|
|
max(yendor::bestscore[modecode()][yendor::challenge], items[itOrbYendor]);
|
|
|
|
yendor::uploadScore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addMessage(XLAT("CONGRATULATIONS!"));
|
2019-11-03 12:56:42 +00:00
|
|
|
achievement_collection(itOrbYendor);
|
2017-07-04 13:38:33 +00:00
|
|
|
achievement_victory(false);
|
|
|
|
}
|
2017-07-10 18:47:38 +00:00
|
|
|
|
2020-04-11 18:40:12 +00:00
|
|
|
auto hooks = addHook(hooks_clearmemory, 0, [] () {
|
2017-07-10 18:47:38 +00:00
|
|
|
yendor::yii = NOYENDOR; yendor::yi.clear();
|
2018-01-26 00:45:49 +00:00
|
|
|
}) + addHook(hooks_removecells, 0, [] () {
|
|
|
|
eliminate_if(yendor::yi, [] (yendorinfo& i) {
|
|
|
|
for(int j=0; j<YDIST; j++) if(is_cell_removed(i.path[j])) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_MEMORY, ("removing a Yendor"));
|
2018-01-26 00:45:49 +00:00
|
|
|
if(&yi[yii] == &i) yii = NOYENDOR;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-10 18:47:38 +00:00
|
|
|
});
|
2019-08-09 23:20:47 +00:00
|
|
|
EX }
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
#define MAXTAC 20
|
2019-08-09 23:20:47 +00:00
|
|
|
EX namespace tactic {
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-08-09 23:20:47 +00:00
|
|
|
EX bool on = false;
|
2019-09-05 10:00:55 +00:00
|
|
|
EX int id;
|
2017-08-17 23:40:07 +00:00
|
|
|
|
|
|
|
map<modecode_t, array<int, landtypes>> recordsum;
|
|
|
|
map<modecode_t, array<array<int, MAXTAC>, landtypes> > lsc;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
eLand lasttactic;
|
|
|
|
|
|
|
|
struct scoredata {
|
|
|
|
string username;
|
|
|
|
int scores[landtypes];
|
|
|
|
};
|
2017-08-17 23:40:07 +00:00
|
|
|
map<modecode_t, vector<scoredata>> scoreboard;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2020-08-02 00:04:18 +00:00
|
|
|
EX int chances(eLand l, modecode_t xc IS(modecode())) {
|
|
|
|
if(xc != 0 && l != laCamelot) return 3;
|
2017-11-03 18:31:42 +00:00
|
|
|
for(auto& ti: land_tac)
|
|
|
|
if(ti.l == l)
|
|
|
|
return ti.tries;
|
2016-08-26 09:58:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tacmultiplier(eLand l) {
|
|
|
|
if(modecode() != 0 && l != laCamelot) return 1;
|
|
|
|
if(modecode() != 0 && l == laCamelot) return 3;
|
2017-11-03 18:31:42 +00:00
|
|
|
for(auto& ti: land_tac)
|
|
|
|
if(ti.l == l)
|
|
|
|
return ti.multiplier;
|
2016-08-26 09:58:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-11-03 18:31:42 +00:00
|
|
|
bool tacticUnlocked(eLand l) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(autocheat) return true;
|
2017-10-30 08:05:16 +00:00
|
|
|
if(l == laWildWest || l == laDual) return true;
|
2016-08-26 09:58:03 +00:00
|
|
|
return hiitemsMax(treasureType(l)) * landMultiplier(l) >= 20;
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:04:18 +00:00
|
|
|
EX void record(eLand land, int score, modecode_t xc IS(modecode())) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(land >=0 && land < landtypes) {
|
|
|
|
for(int i=MAXTAC-1; i; i--) lsc[xc][land][i] = lsc[xc][land][i-1];
|
|
|
|
tactic::lsc[xc][land][0] = score;
|
|
|
|
}
|
2020-08-02 00:04:18 +00:00
|
|
|
int t = chances(land, xc);
|
2016-08-26 09:58:03 +00:00
|
|
|
int csum = 0;
|
|
|
|
for(int i=0; i<t; i++) if(lsc[xc][land][i] > 0) csum += lsc[xc][land][i];
|
|
|
|
if(csum > recordsum[xc][land]) recordsum[xc][land] = csum;
|
|
|
|
}
|
|
|
|
|
2024-05-16 18:35:38 +00:00
|
|
|
EX void record() {
|
2016-08-26 09:58:03 +00:00
|
|
|
record(lasttactic, items[treasureType(lasttactic)]);
|
|
|
|
}
|
|
|
|
|
2024-05-16 18:35:38 +00:00
|
|
|
EX void unrecord(eLand land, flagtype xc IS(modecode())) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(land >=0 && land < landtypes) {
|
|
|
|
for(int i=0; i<MAXTAC-1; i++) lsc[xc][land][i] = lsc[xc][land][i+1];
|
|
|
|
lsc[xc][land][MAXTAC-1] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-16 18:35:38 +00:00
|
|
|
EX void unrecord() {
|
2016-08-26 09:58:03 +00:00
|
|
|
unrecord(lasttactic);
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int tscorelast;
|
|
|
|
|
2024-06-02 10:25:22 +00:00
|
|
|
int compute_tscore(modecode_t code) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int tscore = 0;
|
|
|
|
for(int i=0; i<landtypes; i++)
|
|
|
|
tscore += recordsum[code][i] * tacmultiplier(eLand(i));
|
2024-06-02 10:25:22 +00:00
|
|
|
return tscore;
|
|
|
|
}
|
|
|
|
|
|
|
|
void uploadScoreCode(modecode_t code, int lb) {
|
|
|
|
int tscore = compute_tscore(code);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(code == 0 && tscore > tscorelast) {
|
|
|
|
tscorelast = tscore;
|
|
|
|
if(tscore >= 1000) achievement_gain("PTM1", 'x');
|
|
|
|
if(tscore >= 5000) achievement_gain("PTM2", 'x');
|
|
|
|
if(tscore >= 15000) achievement_gain("PTM3", 'x');
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
achievement_score(lb, tscore);
|
|
|
|
}
|
|
|
|
|
2024-05-16 18:35:38 +00:00
|
|
|
EX void uploadScore() {
|
2016-08-26 09:58:03 +00:00
|
|
|
uploadScoreCode(0, LB_PURE_TACTICS);
|
|
|
|
uploadScoreCode(2, LB_PURE_TACTICS_SHMUP);
|
|
|
|
uploadScoreCode(4, LB_PURE_TACTICS_COOP);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2019-09-06 06:17:02 +00:00
|
|
|
EX void showMenu() {
|
2018-05-15 21:23:12 +00:00
|
|
|
|
2020-04-06 06:39:31 +00:00
|
|
|
flagtype xc = modecode();
|
2018-05-15 21:23:12 +00:00
|
|
|
|
|
|
|
if(xc == 0) set_priority_board(LB_PURE_TACTICS);
|
|
|
|
if(xc == 2) set_priority_board(LB_PURE_TACTICS_SHMUP);
|
|
|
|
if(xc == 4) set_priority_board(LB_PURE_TACTICS_COOP);
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
cmode = sm::ZOOMABLE;
|
2021-05-28 22:38:41 +00:00
|
|
|
if(mouseovers == "" || mouseovers == " ")
|
|
|
|
mouseovers = XLAT("pure tactics mode");
|
|
|
|
else
|
|
|
|
mouseovers = XLAT("pure tactics mode") + " - " + mouseovers;
|
|
|
|
|
|
|
|
if(dialog::infix != "") mouseovers = mouseovers + " - " + dialog::infix;
|
|
|
|
else mouseovers = mouseovers + " - " + XLAT("press letters to search");
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-11-03 18:31:42 +00:00
|
|
|
{
|
|
|
|
dynamicval<bool> t(tactic::on, true);
|
2021-05-28 22:38:41 +00:00
|
|
|
generateLandList([] (eLand l) {
|
|
|
|
if(dialog::infix != "" && !dialog::hasInfix(linf[l].name)) return false;
|
|
|
|
return !!(land_validity(l).flags & lv::appears_in_ptm);
|
|
|
|
});
|
2017-11-03 18:31:42 +00:00
|
|
|
}
|
|
|
|
|
2018-06-22 12:47:24 +00:00
|
|
|
int nl = isize(landlist);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2021-05-28 22:38:41 +00:00
|
|
|
int nlm = nl;
|
|
|
|
int ofs = dialog::infix != "" ? 0 : dialog::handlePage(nl, nlm, (nl+1)/2);
|
|
|
|
|
|
|
|
int vf = nlm ? min((vid.yres-64-vid.fsize) / nlm, vid.xres/40) : vid.xres/40;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
int xr = vid.xres / 64;
|
|
|
|
|
2018-04-11 15:44:46 +00:00
|
|
|
if(on) record(specialland, items[treasureType(specialland)]);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
getcstat = SDLK_ESCAPE;
|
2021-05-28 22:38:41 +00:00
|
|
|
|
|
|
|
map<int, int> land_for;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
for(int i=0; i<nl; i++) {
|
2017-03-23 10:53:57 +00:00
|
|
|
int i1 = i + ofs;
|
2017-11-03 18:31:42 +00:00
|
|
|
eLand l = landlist[i1];
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int i0 = 56 + i * vf;
|
2018-09-04 17:53:42 +00:00
|
|
|
color_t col;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
int ch = chances(l);
|
|
|
|
|
|
|
|
if(!ch) continue;
|
|
|
|
|
2017-11-03 18:31:42 +00:00
|
|
|
bool unlocked = tacticUnlocked(l);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(unlocked) col = linf[l].color; else col = 0x202020;
|
|
|
|
|
2021-05-28 22:38:41 +00:00
|
|
|
int keyhere;
|
|
|
|
if(nlm <= 9) {
|
|
|
|
keyhere = '1' + i;
|
|
|
|
if(displayfrZH(xr*1, i0, 1, vf-4, s0+char(keyhere), 0xFFFFFF, 0))
|
|
|
|
getcstat = keyhere;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2021-05-28 22:38:41 +00:00
|
|
|
else
|
|
|
|
keyhere = 1000 + i1;
|
|
|
|
land_for[keyhere] = i1;
|
|
|
|
|
|
|
|
if(displayfrZH(xr*(nlm <= 9 ? 2.5 : 1), i0, 1, vf-4, XLAT1(linf[l].name), col, 0) && unlocked)
|
|
|
|
getcstat = keyhere;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(unlocked || autocheat) {
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int ii=0; ii<ch; ii++)
|
2018-07-22 10:54:05 +00:00
|
|
|
if(displayfrZH(xr*(24+2*ii), i0, 1, (vf-4)*4/5, lsc[xc][l][ii] > 0 ? its(lsc[xc][l][ii]) : "-", col, 16))
|
2021-05-28 22:38:41 +00:00
|
|
|
getcstat = keyhere;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2018-07-22 10:54:05 +00:00
|
|
|
if(displayfrZH(xr*(24+2*10), i0, 1, (vf-4)*4/5,
|
2016-08-26 09:58:03 +00:00
|
|
|
its(recordsum[xc][l]) + " x" + its(tacmultiplier(l)), col, 0))
|
2021-05-28 22:38:41 +00:00
|
|
|
getcstat = keyhere;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
int m = landMultiplier(l);
|
2017-03-23 10:53:57 +00:00
|
|
|
displayfrZ(xr*26, i0, 1, (vf-4)*4/5,
|
2016-08-26 09:58:03 +00:00
|
|
|
XLAT("Collect %1x %2 to unlock", its((20+m-1)/m), treasureType(l)),
|
|
|
|
col, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-28 22:38:41 +00:00
|
|
|
dialog::displayPageButtons(3, dialog::infix == "");
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
uploadScore();
|
2018-04-11 15:44:46 +00:00
|
|
|
if(on) unrecord(specialland);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2021-05-28 22:38:41 +00:00
|
|
|
if(land_for.count(getcstat)) {
|
|
|
|
int ld = landlist[land_for.at(getcstat)];
|
2016-08-26 09:58:03 +00:00
|
|
|
subscoreboard scorehere;
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(scoreboard[xc]); i++) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int sc = scoreboard[xc][i].scores[ld];
|
|
|
|
if(sc > 0)
|
|
|
|
scorehere.push_back(
|
|
|
|
make_pair(-sc, scoreboard[xc][i].username));
|
|
|
|
}
|
|
|
|
displayScore(scorehere, xr * 50);
|
|
|
|
}
|
2017-07-10 18:47:38 +00:00
|
|
|
|
2021-05-28 22:38:41 +00:00
|
|
|
keyhandler = [land_for] (int sym, int uni) {
|
|
|
|
if(land_for.count(uni)) {
|
|
|
|
eLand ll = landlist[land_for.at(uni)];
|
|
|
|
dialog::do_if_confirmed([ll] {
|
|
|
|
stop_game();
|
|
|
|
specialland = ll;
|
|
|
|
restart_game(tactic::on ? rg::nothing : rg::tactic);
|
|
|
|
});
|
|
|
|
}
|
2017-07-10 18:47:38 +00:00
|
|
|
else if(uni == '0') {
|
2018-07-08 12:19:12 +00:00
|
|
|
if(tactic::on) {
|
|
|
|
stop_game();
|
|
|
|
firstland = laIce;
|
|
|
|
restart_game(rg::tactic);
|
|
|
|
}
|
2017-07-16 21:00:55 +00:00
|
|
|
else popScreen();
|
2017-07-10 18:47:38 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
else if(sym == SDLK_F1) gotoHelp(
|
2016-08-26 09:58:03 +00:00
|
|
|
"In the pure tactics mode, you concentrate on a specific land. "
|
|
|
|
"Your goal to obtain as high score as possible, without using "
|
|
|
|
"features of the other lands. You can then compare your score "
|
|
|
|
"with your friends!\n\n"
|
|
|
|
|
|
|
|
"You need to be somewhat proficient in the normal game to "
|
|
|
|
"unlock the given land in this challenge "
|
|
|
|
"(collect 20 treasure in the given land, or 2 in case of Camelot).\n\n"
|
|
|
|
|
|
|
|
"Since getting high scores in some lands is somewhat luck dependent, "
|
|
|
|
"you play each land N times, and your score is based on N consecutive "
|
|
|
|
"plays. The value of N depends on how 'fast' the land is to play, and "
|
|
|
|
"how random it is.\n\n"
|
|
|
|
|
|
|
|
"In the Caribbean, you can access Orbs of Thorns, Aether, and "
|
|
|
|
"Space if you have ever collected 25 treasure in their native lands.\n\n"
|
|
|
|
|
|
|
|
"The rate of treasure spawn is static in this mode. It is not "
|
|
|
|
"increased by killing monsters.\n\n"
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
"Good luck, and have fun!"
|
|
|
|
);
|
2022-11-03 18:37:50 +00:00
|
|
|
else if(dialog::infix == "" && dialog::handlePageButtons(uni)) ;
|
2022-10-21 10:47:20 +00:00
|
|
|
else if(dialog::editInfix(uni)) dialog::list_skip = 0;
|
2017-07-10 18:47:38 +00:00
|
|
|
else if(doexiton(sym, uni)) popScreen();
|
|
|
|
};
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-07-10 18:47:38 +00:00
|
|
|
|
2021-05-28 22:38:41 +00:00
|
|
|
EX void start() {
|
|
|
|
dialog::infix = "";
|
|
|
|
popScreenAll();
|
|
|
|
pushScreen(tactic::showMenu);
|
|
|
|
}
|
2019-08-09 23:20:47 +00:00
|
|
|
EX }
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2020-08-02 00:04:18 +00:00
|
|
|
map<string, modecode_t> code_for;
|
|
|
|
EX map<modecode_t, string> meaning;
|
2024-06-02 10:27:01 +00:00
|
|
|
EX map<modecode_t, modecode_t> identify_modes;
|
2017-08-17 23:40:07 +00:00
|
|
|
|
2020-08-02 00:04:18 +00:00
|
|
|
char xcheat;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2024-03-14 18:28:33 +00:00
|
|
|
EX void save_mode_data(hstream& f) {
|
2020-08-02 00:04:18 +00:00
|
|
|
mapstream::save_geometry(f);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2021-04-15 17:08:10 +00:00
|
|
|
if(yendor::on || tactic::on)
|
2020-08-02 00:04:18 +00:00
|
|
|
f.write<char>(0);
|
|
|
|
else
|
2021-04-11 20:15:40 +00:00
|
|
|
f.write<char>(land_structure);
|
2020-08-02 00:04:18 +00:00
|
|
|
f.write<char>(shmup::on);
|
|
|
|
f.write<char>(inv::on);
|
2020-10-15 14:33:52 +00:00
|
|
|
#if CAP_TOUR
|
2020-08-02 00:04:18 +00:00
|
|
|
f.write<char>(tour::on);
|
2020-10-15 14:33:52 +00:00
|
|
|
#else
|
|
|
|
f.write<char>(false);
|
|
|
|
#endif
|
2020-08-02 00:04:18 +00:00
|
|
|
f.write<char>(peace::on);
|
|
|
|
f.write<char>(peace::otherpuzzles);
|
|
|
|
f.write<char>(peace::explore_other);
|
|
|
|
f.write<char>(multi::players);
|
|
|
|
f.write<char>(xcheat);
|
2021-05-27 10:57:12 +00:00
|
|
|
if(casual) {
|
|
|
|
f.write<char>(1);
|
|
|
|
}
|
2023-10-27 20:46:11 +00:00
|
|
|
if(bow::weapon) {
|
|
|
|
f.write<char>(2);
|
|
|
|
f.write<char>(bow::weapon);
|
|
|
|
f.write<char>(bow::style);
|
|
|
|
}
|
2024-03-14 18:27:08 +00:00
|
|
|
if(use_custom_land_list) {
|
|
|
|
f.write<char>(3);
|
|
|
|
f.write<int>(landtypes);
|
|
|
|
for(int i=0; i<landtypes; i++) {
|
|
|
|
f.write<char>(custom_land_list[i]);
|
|
|
|
f.write<int>(custom_land_treasure[i]);
|
|
|
|
f.write<int>(custom_land_difficulty[i]);
|
|
|
|
f.write<int>(custom_land_wandering[i]);
|
|
|
|
}
|
|
|
|
}
|
2024-03-14 18:27:50 +00:00
|
|
|
if(ls::horodisk_structure()) {
|
|
|
|
f.write<char>(4);
|
|
|
|
f.write<int>(horodisk_from);
|
|
|
|
}
|
|
|
|
if(land_structure == lsChaosRW) {
|
|
|
|
f.write<char>(5);
|
|
|
|
f.write<int>(randomwalk_size);
|
|
|
|
}
|
2024-03-21 19:15:45 +00:00
|
|
|
if(land_structure == lsLandscape) {
|
|
|
|
f.write<char>(6);
|
|
|
|
f.write<int>(landscape_div);
|
|
|
|
}
|
2024-03-23 23:41:36 +00:00
|
|
|
if(shmup::on && vid.creature_scale != 1) {
|
|
|
|
f.write<char>(7);
|
|
|
|
f.write<ld>(vid.creature_scale);
|
|
|
|
}
|
2020-08-02 00:04:18 +00:00
|
|
|
}
|
2017-08-17 23:40:07 +00:00
|
|
|
|
2024-03-14 18:28:33 +00:00
|
|
|
EX void load_mode_data_with_zero(hstream& f) {
|
|
|
|
mapstream::load_geometry(f);
|
|
|
|
|
|
|
|
land_structure = (eLandStructure) f.get<char>();
|
|
|
|
shmup::on = f.get<char>();
|
|
|
|
inv::on = f.get<char>();
|
|
|
|
#if CAP_TOUR
|
|
|
|
tour::on = f.get<char>();
|
|
|
|
#else
|
|
|
|
f.get<char>();
|
|
|
|
#endif
|
|
|
|
peace::on = f.get<char>();
|
|
|
|
peace::otherpuzzles = f.get<char>();
|
|
|
|
peace::explore_other = f.get<char>();
|
|
|
|
multi::players = f.get<char>();
|
|
|
|
xcheat = f.get<char>();
|
|
|
|
casual = false;
|
|
|
|
bow::weapon = bow::wBlade;
|
2024-03-24 10:15:33 +00:00
|
|
|
if(shmup::on) vid.creature_scale = 1;
|
2024-03-14 18:28:33 +00:00
|
|
|
|
|
|
|
while(true) {
|
|
|
|
char option = f.get<char>();
|
|
|
|
switch(option) {
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
casual = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
bow::weapon = (bow::eWeapon) f.get<char>();
|
|
|
|
bow::style = (bow::eCrossbowStyle) f.get<char>();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: {
|
|
|
|
use_custom_land_list = true;
|
|
|
|
int lt = f.get<int>();
|
2024-03-27 20:31:58 +00:00
|
|
|
if(lt > landtypes) throw hstream_exception("too many landtypes");
|
2024-03-14 18:28:33 +00:00
|
|
|
for(int i=0; i<lt; i++) {
|
|
|
|
custom_land_list[i] = f.get<char>();
|
|
|
|
custom_land_treasure[i] = f.get<int>();
|
|
|
|
custom_land_difficulty[i] = f.get<int>();
|
|
|
|
custom_land_wandering[i] = f.get<int>();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
horodisk_from = f.get<int>();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
randomwalk_size = f.get<int>();
|
|
|
|
break;
|
|
|
|
|
2024-03-21 19:15:45 +00:00
|
|
|
case 6:
|
|
|
|
landscape_div = f.get<int>();
|
|
|
|
break;
|
|
|
|
|
2024-03-23 23:41:36 +00:00
|
|
|
case 7:
|
|
|
|
vid.creature_scale = f.get<ld>();
|
|
|
|
|
2024-03-14 18:28:33 +00:00
|
|
|
default:
|
2024-03-27 20:31:58 +00:00
|
|
|
throw hstream_exception("wrong option");
|
2024-03-14 18:28:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-02 10:27:01 +00:00
|
|
|
#if HDR
|
|
|
|
constexpr int FIRST_MODECODE = 100000;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EX modecode_t get_identify(modecode_t xc) {
|
|
|
|
if(xc < FIRST_MODECODE) {
|
|
|
|
meaning[xc] = "LEGACY";
|
|
|
|
return xc;
|
|
|
|
}
|
|
|
|
return identify_modes[xc];
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:04:18 +00:00
|
|
|
EX modecode_t modecode(int mode) {
|
|
|
|
modecode_t x = legacy_modecode();
|
|
|
|
if(x != UNKNOWN) return x;
|
|
|
|
|
|
|
|
xcheat = (cheater ? 1 : 0);
|
|
|
|
shstream ss;
|
|
|
|
ss.write(ss.vernum);
|
|
|
|
save_mode_data(ss);
|
2024-06-02 10:27:01 +00:00
|
|
|
string code = ss.s;
|
|
|
|
string nover = ss.s.substr(2);
|
2018-01-06 20:45:13 +00:00
|
|
|
|
2024-06-02 10:27:01 +00:00
|
|
|
if(code_for.count(nover)) return code_for[nover];
|
2020-08-02 00:04:18 +00:00
|
|
|
|
|
|
|
if(mode == 1) return UNKNOWN;
|
2018-12-14 20:35:46 +00:00
|
|
|
|
2024-06-02 10:27:01 +00:00
|
|
|
modecode_t next = FIRST_MODECODE;
|
2020-08-02 00:04:18 +00:00
|
|
|
while(meaning.count(next)) next++;
|
2018-12-15 13:16:57 +00:00
|
|
|
|
2024-06-02 10:27:01 +00:00
|
|
|
meaning[next] = code;
|
|
|
|
code_for[nover] = next;
|
|
|
|
identify_modes[next] = next;
|
2018-12-14 18:24:27 +00:00
|
|
|
|
2020-08-02 00:04:18 +00:00
|
|
|
if(mode == 2) return next;
|
2022-09-15 10:38:39 +00:00
|
|
|
|
|
|
|
if(scorefile == "") return next;
|
2018-12-14 18:24:27 +00:00
|
|
|
|
2022-09-15 10:38:39 +00:00
|
|
|
FILE *f = fopen(scorefile.c_str(), "at");
|
|
|
|
if(!f) return next;
|
2020-08-02 00:04:18 +00:00
|
|
|
string s = as_hexstring(ss.s);
|
|
|
|
fprintf(f, "MODE %d %s\n", next, s.c_str());
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
EX void load_modecode_line(string s) {
|
|
|
|
int code = atoi(&s[5]);
|
|
|
|
int pos = 5;
|
|
|
|
while(s[pos] != ' ' && s[pos]) pos++;
|
|
|
|
if(!s[pos]) return;
|
|
|
|
pos++;
|
|
|
|
string t = from_hexstring(s.substr(pos));
|
2024-06-02 10:27:01 +00:00
|
|
|
string nover = t.substr(2);
|
2020-08-02 00:04:18 +00:00
|
|
|
meaning[code] = t;
|
2024-06-02 10:27:01 +00:00
|
|
|
if(code_for.count(nover))
|
|
|
|
code = identify_modes[code] = code_for[nover];
|
|
|
|
else identify_modes[code] = code;
|
|
|
|
code_for[nover] = code;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 23:20:47 +00:00
|
|
|
EX namespace peace {
|
2017-07-04 13:38:33 +00:00
|
|
|
|
2019-08-09 23:20:47 +00:00
|
|
|
EX bool on = false;
|
2019-09-05 10:00:55 +00:00
|
|
|
EX bool hint = false;
|
2017-07-04 13:38:33 +00:00
|
|
|
|
2020-07-29 21:01:15 +00:00
|
|
|
EX bool otherpuzzles = true;
|
2017-07-04 13:38:33 +00:00
|
|
|
|
2020-07-29 21:01:15 +00:00
|
|
|
EX bool explore_other = false;
|
|
|
|
|
|
|
|
vector<eLand> simonlevels = {
|
|
|
|
laCrossroads, laCrossroads2, laRlyeh,
|
|
|
|
laDesert, laCaves, laAlchemist, laEmerald,
|
2017-07-04 13:38:33 +00:00
|
|
|
laWineyard, laDeadCaves, laRedRock, laPalace,
|
2020-07-29 21:01:15 +00:00
|
|
|
laLivefjord, laDragon
|
2017-07-04 13:38:33 +00:00
|
|
|
};
|
|
|
|
|
2020-07-29 21:01:15 +00:00
|
|
|
vector<eLand> puzzlelevels = {
|
|
|
|
laBurial, laTortoise, laCamelot, laPalace
|
|
|
|
};
|
|
|
|
|
|
|
|
vector<eLand> explorelevels = {
|
2017-07-04 13:38:33 +00:00
|
|
|
laIce, laJungle, laMirror, laDryForest, laCaribbean, laOcean, laZebra,
|
|
|
|
laOvergrown, laWhirlwind, laWarpCoast, laReptile,
|
2020-07-29 21:01:15 +00:00
|
|
|
laElementalWall, laAlchemist
|
2017-07-04 13:38:33 +00:00
|
|
|
};
|
|
|
|
|
2020-07-29 21:01:15 +00:00
|
|
|
vector<eLand> levellist;
|
2017-07-04 13:38:33 +00:00
|
|
|
|
|
|
|
eLand getNext(eLand last) {
|
2017-07-10 18:47:38 +00:00
|
|
|
if(!peace::on) return laNone;
|
2020-07-29 21:01:15 +00:00
|
|
|
if(levellist.empty()) showMenu();
|
2017-07-04 13:38:33 +00:00
|
|
|
if(isElemental(last) && hrand(100) < 90)
|
|
|
|
return laNone;
|
|
|
|
else if(createOnSea(last))
|
|
|
|
return getNewSealand(last);
|
|
|
|
else if(isCrossroads(last)) {
|
|
|
|
while(isCrossroads(last) || last == laCaribbean || last == laCamelot)
|
2020-07-29 21:01:15 +00:00
|
|
|
last = hrand_elt(levellist);
|
2017-07-04 13:38:33 +00:00
|
|
|
if(last == laElementalWall) last = laEFire;
|
|
|
|
return last;
|
|
|
|
}
|
|
|
|
else return pick(laCrossroads, laCrossroads2);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isAvailable(eLand l) {
|
|
|
|
for(int i=0; explorelevels[i]; i++) if(explorelevels[i] == l) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX namespace simon {
|
2017-07-04 13:38:33 +00:00
|
|
|
|
|
|
|
vector<cell*> path;
|
|
|
|
int tobuild;
|
|
|
|
|
|
|
|
void build() {
|
|
|
|
if(otherpuzzles || !on) return;
|
2018-06-22 12:47:24 +00:00
|
|
|
while(isize(path) < tobuild) {
|
|
|
|
cell *cp = path[isize(path)-1];
|
|
|
|
cell *cp2 = path[isize(path)-2];
|
2017-07-04 13:38:33 +00:00
|
|
|
vector<pair<cell*, cell*>> clister;
|
|
|
|
clister.emplace_back(cp, cp);
|
|
|
|
|
|
|
|
int id = 0;
|
2018-06-28 11:35:03 +00:00
|
|
|
manual_celllister cl;
|
2018-06-22 12:47:24 +00:00
|
|
|
while(id < isize(clister)) {
|
2017-07-04 13:38:33 +00:00
|
|
|
cell *c = clister[id].first;
|
|
|
|
cell *fr = clister[id].second;
|
|
|
|
setdist(c, 5, NULL);
|
|
|
|
|
|
|
|
forCellEx(c2,c)
|
2018-06-28 10:59:35 +00:00
|
|
|
if(!cl.listed(c2) && passable(c2, c, 0) && (c2->land == specialland || c2->land == laTemple) && !c2->item) {
|
2017-07-04 13:38:33 +00:00
|
|
|
if(!id) fr = c2;
|
|
|
|
bool next;
|
2017-08-06 12:50:16 +00:00
|
|
|
if(specialland == laRlyeh)
|
2017-07-04 13:38:33 +00:00
|
|
|
next = c2->land == laTemple && (cp2->land == laRlyeh || celldistAlt(c2) < celldistAlt(cp2) - 8);
|
|
|
|
else
|
|
|
|
next = celldistance(c2, cp2) == 8;
|
|
|
|
if(next) {
|
|
|
|
path.push_back(fr);
|
|
|
|
fr->item = itDodeca;
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
clister.emplace_back(c2, fr);
|
2018-06-28 10:59:35 +00:00
|
|
|
cl.add(c2);
|
2017-07-04 13:38:33 +00:00
|
|
|
}
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
printf("Path broken, searched = %d\n", id);
|
|
|
|
for(auto t: clister) t.first->item = itPirate;
|
|
|
|
return;
|
|
|
|
again: ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX void extend() {
|
2017-07-04 13:38:33 +00:00
|
|
|
int i = 0;
|
2018-06-22 12:47:24 +00:00
|
|
|
while(i<isize(path) && path[i]->item != itDodeca) i++;
|
2017-07-04 13:38:33 +00:00
|
|
|
if(tobuild == i+9)
|
|
|
|
addMessage("You must collect all the dodecahedra on the path!");
|
|
|
|
tobuild = i + 9;
|
|
|
|
build();
|
|
|
|
}
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX void init() {
|
2017-07-04 13:38:33 +00:00
|
|
|
tobuild = 0;
|
|
|
|
if(!on) return;
|
|
|
|
if(otherpuzzles) { items[itGreenStone] = 500; return; }
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = cwt.at->move(0);
|
2017-07-04 13:38:33 +00:00
|
|
|
makeEmpty(c2);
|
|
|
|
c2->item = itOrbYendor;
|
|
|
|
|
|
|
|
path.clear();
|
2018-08-17 22:46:45 +00:00
|
|
|
path.push_back(cwt.at);
|
2017-07-04 13:38:33 +00:00
|
|
|
path.push_back(c2);
|
|
|
|
extend();
|
|
|
|
}
|
|
|
|
|
2019-09-05 10:00:55 +00:00
|
|
|
EX void restore() {
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=1; i<isize(path); i++)
|
2017-07-04 13:38:33 +00:00
|
|
|
if(path[i]->item == itNone && items[itDodeca])
|
|
|
|
path[i]->item = itDodeca, items[itDodeca]--;
|
|
|
|
}
|
2019-09-05 10:00:55 +00:00
|
|
|
EX }
|
2017-08-06 12:50:16 +00:00
|
|
|
|
2019-09-06 06:17:02 +00:00
|
|
|
EX void showMenu() {
|
2022-06-16 23:03:05 +00:00
|
|
|
dialog::init();
|
|
|
|
|
|
|
|
int kind = 0;
|
|
|
|
|
|
|
|
if(true) {
|
|
|
|
dialog::addBreak(100);
|
|
|
|
dialog::addBoolItem(XLAT("puzzles"), otherpuzzles, '1');
|
|
|
|
dialog::add_action([] { otherpuzzles = true; explore_other = false; });
|
|
|
|
dialog::addBoolItem(XLAT("exploration"), explore_other, '2');
|
|
|
|
dialog::add_action([] { otherpuzzles = true; explore_other = true; });
|
|
|
|
dialog::addBoolItem(XLAT("memory game"), !otherpuzzles && !explore_other, '2');
|
|
|
|
dialog::add_action([] { otherpuzzles = false; explore_other = false; });
|
|
|
|
dialog::addBreak(50);
|
|
|
|
}
|
|
|
|
|
2021-05-23 12:17:06 +00:00
|
|
|
string title =
|
|
|
|
!otherpuzzles ? XLAT("memory game") :
|
|
|
|
explore_other ? XLAT("exploration") :
|
|
|
|
XLAT("puzzles");
|
2022-06-16 23:03:05 +00:00
|
|
|
dialog::addBreak(100);
|
|
|
|
dialog::addTitle(title, 0x40A040, 150);
|
|
|
|
dialog::addBreak(100);
|
2020-07-29 21:01:15 +00:00
|
|
|
|
|
|
|
if(!otherpuzzles) {
|
|
|
|
levellist = simonlevels, kind = 1;
|
|
|
|
dialog::addInfo("Collect as many dodecahedra as you can!");
|
|
|
|
dialog::addInfo("You have to return to the starting location!");
|
|
|
|
dialog::addBreak(50);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dialog::addInfo("This mode removes roguelike elements,");
|
|
|
|
dialog::addInfo("focusing on puzzles and exploration");
|
|
|
|
dialog::addBreak(50);
|
2022-06-16 23:03:05 +00:00
|
|
|
if(explore_other)
|
|
|
|
levellist = explorelevels, kind = 2;
|
|
|
|
else
|
|
|
|
levellist = puzzlelevels, kind = 0;
|
2020-07-29 21:01:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char key = 'a';
|
|
|
|
for(auto lev: levellist) {
|
2022-06-16 23:03:05 +00:00
|
|
|
dialog::addItem(XLAT1(linf[lev].name), key++);
|
2020-07-29 21:01:15 +00:00
|
|
|
dialog::add_action([lev] {
|
|
|
|
dialog::do_if_confirmed([lev] {
|
2022-06-16 23:03:05 +00:00
|
|
|
stop_game();
|
2020-07-29 21:01:15 +00:00
|
|
|
firstland = specialland = lev;
|
|
|
|
if(!peace::on)
|
|
|
|
stop_game_and_switch_mode(rg::peace);
|
|
|
|
start_game();
|
|
|
|
popScreenAll();
|
|
|
|
});
|
|
|
|
});
|
2022-06-16 23:03:05 +00:00
|
|
|
if(kind == 0) {
|
|
|
|
switch(lev) {
|
|
|
|
case laBurial:
|
|
|
|
dialog::addInfo("excavate the treasures using your magical shovel");
|
|
|
|
break;
|
|
|
|
case laTortoise:
|
|
|
|
dialog::addInfo("find an adult tortoise matching the baby");
|
|
|
|
break;
|
|
|
|
case laCamelot:
|
|
|
|
dialog::addInfo("find the center of the Round Table in Camelot");
|
|
|
|
break;
|
|
|
|
case laPalace:
|
|
|
|
dialog::addInfo("follow the mouse");
|
|
|
|
break;
|
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
dialog::addBreak(100);
|
|
|
|
}
|
2020-07-29 21:01:15 +00:00
|
|
|
}
|
2022-06-16 23:03:05 +00:00
|
|
|
dialog::addBreak(1400 - 100 * isize(levellist) * (kind == 0 ? 3 : 1));
|
2020-07-29 21:01:15 +00:00
|
|
|
|
2022-06-16 23:03:05 +00:00
|
|
|
dialog::addBoolItem(XLAT("display hints"), hint, '4');
|
2020-07-29 21:01:15 +00:00
|
|
|
dialog::add_action([] {
|
|
|
|
hint = !hint; popScreen();
|
|
|
|
});
|
2017-07-10 18:47:38 +00:00
|
|
|
dialog::addItem(XLAT("Return to the normal game"), '0');
|
2020-07-29 21:01:15 +00:00
|
|
|
dialog::add_action([] {
|
2022-06-16 23:03:05 +00:00
|
|
|
stop_game();
|
2020-07-29 21:01:15 +00:00
|
|
|
if(peace::on) stop_game_and_switch_mode(rg::peace);
|
|
|
|
});
|
2018-06-12 22:00:01 +00:00
|
|
|
|
|
|
|
dialog::addBack();
|
2017-07-10 18:47:38 +00:00
|
|
|
dialog::display();
|
2017-07-04 13:38:33 +00:00
|
|
|
}
|
2017-07-10 18:47:38 +00:00
|
|
|
|
|
|
|
auto aNext = addHook(hooks_nextland, 100, getNext);
|
2020-02-23 01:51:27 +00:00
|
|
|
}
|
2018-07-19 21:46:58 +00:00
|
|
|
|
|
|
|
#if CAP_COMMANDLINE
|
|
|
|
int read_mode_args() {
|
|
|
|
using namespace arg;
|
|
|
|
if(argis("-Y")) {
|
|
|
|
yendor::on = true;
|
|
|
|
shift(); yendor::challenge = argi();
|
|
|
|
}
|
|
|
|
else if(argis("-peace")) {
|
|
|
|
peace::otherpuzzles = true;
|
|
|
|
stop_game_and_switch_mode(peace::on ? 0 : rg::peace);
|
|
|
|
}
|
|
|
|
else if(argis("-pmem")) {
|
|
|
|
peace::otherpuzzles = false;
|
|
|
|
stop_game_and_switch_mode(peace::on ? 0 : rg::peace);
|
|
|
|
}
|
|
|
|
TOGGLE('T', tactic::on, stop_game_and_switch_mode(rg::tactic))
|
|
|
|
|
|
|
|
else return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ah = addHook(hooks_args, 0, read_mode_args);
|
|
|
|
#endif
|
2018-06-10 23:58:31 +00:00
|
|
|
}
|