1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726
|
// Hyperbolic Rogue -- Orb Strategy Mode
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
/** \file inventory.cpp
* \brief Orb Strategy Mode
*/
#include "hyper.h"
namespace hr {
/** \brief Implementation of the Orb Strategy Mode.
*
* The most important functions called outside is hr::inv::show().
*/
EX namespace inv {
#if CAP_INV
/** \brief is the Orb Strategy Mode active? */
EX bool on;
/** \brief the number of Orbs used up in each type */
EX array<int, ittypes> usedup;
/** \brief the number of Orbs remaining in each type -- it is recalculated based on your treasure and hr::inv::usedup after every move */
EX array<int, ittypes> remaining;
/** \brief extra orbs can be added to OSM using -IX commandline option */
EX array<int, ittypes> extra_orbs;
/** \brief random seed used for hr::inv::invr */
EX int rseed;
/** \brief have we used any 'forbidden' orbs? */
EX bool usedForbidden;
/** \brief initialize the OSM data for a new game */
EX void init() {
rseed = hrandpos();
usedForbidden = false;
for(int i=0; i<ittypes; i++) usedup[i] = 0;
}
static const int MIRRORED = 1000;
static const int TESTMIRRORED = 900;
struct lateextraorb {
eItem treasure;
eItem orb;
};
vector<lateextraorb> lateextraorbs = {
{itPower, itOrbFlash},
{itPower, itOrbSpeed},
{itPower, itOrbAether},
{itPower, itOrbWinter},
{itTrollEgg, itOrbFish},
{itTrollEgg, itOrbStunning},
{itTrollEgg, itOrbLuck},
{itTrollEgg, itOrbLife},
{itTrollEgg, itOrbDigging},
{itTrollEgg, itOrbSpace},
{itFulgurite, itOrbLightning},
{itWindstone, itOrbSpeed},
{itDragon, itOrbDragon},
{itSlime, itOrbFlash},
{itDodeca, itOrbShield},
{itGreenGrass, itOrbHorns},
{itGreenGrass, itOrbShield},
{itGreenGrass, itOrbThorns}
};
/** \brief how many orbs can we get from Orb-of-Mirroring orb */
int mirrorqty0(eItem orb) {
if(shmup::on && isShmupLifeOrb(orb))
return 3;
if(orb == itOrbWater) return 10;
if(orb == itOrbSummon) return 9;
if(orb == itOrbEmpathy) return 9;
if(orb == itOrbMatter) return 9;
if(orb == itOrbIntensity) return 8;
if(orb == itOrbLuck) return 8;
if(orb == itOrbSpace) return 7;
if(orb == itOrbWinter) return 6;
if(orb == itOrbLife) return 6;
if(orb == itOrbLove) return 6;
if(orb == itOrbRecall) return 6;
if(orb == itOrbDigging) return 6;
if(orb == itOrbGravity) return 6;
if(orb == itOrbImpact) return 6;
if(orb == itOrbTime) return 5;
if(orb == itOrbAir) return 5;
if(orb == itOrbFish) return 5;
if(orb == itOrbStunning) return 5;
if(orb == itOrbUndeath) return 5;
if(orb == itOrb37) return 5;
if(orb == itOrbDomination) return 5;
if(orb == itOrbBull) return 5;
if(orb == itOrbHorns) return 5;
if(orb == itOrbAether) return 4;
if(orb == itOrbInvis) return 4;
if(orb == itOrbFire) return 4;
if(orb == itOrbDragon) return 4;
if(orb == itOrbIllusion) return 4;
if(orb == itOrbDiscord) return 4;
if(orb == itOrbBeauty) return 4;
if(orb == itOrbMirror) return 1;
return 3;
}
int mirrorqty(eItem orb) {
if(orb == itOrbMirror) return 1;
return int(mirrorqty0(orb) * sqrt(1.000001+items[itPower]/20.));
}
/** \brief PRNG used for calculating how many Orbs you get for your collected treasure */
std::mt19937 invr;
/** \brief initialize hr::inv::invr */
void sirand(int i) {
invr.seed(i);
}
/** \brief get the next random value from hr::inv::invr */
int irand(int i) {
return invr() % i;
}
EX eItem whichorbinfo;
EX string orbinfoline, extra;
string extraline(eItem it, string s) {
return " "+XLAT1(iinf[it].name) + " ("+s+")";
}
void gainOrbs(eItem it, eItem o) {
int qty = items[it];
if(it == itHolyGrail) {
remaining[itOrbIllusion] += qty;
if(it == itOrbIllusion) {
orbinfoline += XLAT("Unlocked by: %1 in %2", it, landof(it));
orbinfoline += XLAT(" (next at %1)", its(qty+1));
}
}
else {
bool nextfound = false;
int fst = (ls::any_chaos() ? 5 : 10);
if(qty >= fst) remaining[o]++;
else {
if(whichorbinfo == o) {
if(it == itHyperstone) {
extra += extraline(it, its(fst));
}
else {
orbinfoline += XLAT("Unlocked by: %1 in %2", it, landof(it));
orbinfoline += XLAT(" (next at %1)", its(10));
}
}
nextfound = true;
}
int last = fst;
for(int k=0; k<30 || !nextfound; k++) {
int maxstep = ls::any_chaos() ? 10 + 2 * k : 15 + 5 * k;
if(o == itOrbMirror)
maxstep += 5 * (k-1) * (k-2);
else
maxstep += (k-1) * (k-2);
int xnext;
if(k >= 30 || o == itOrbMirror) {
xnext = last + maxstep/2; last = xnext-1;
maxstep = 1;
}
else
xnext = last + 1 + irand(maxstep);
if(xnext > qty && !nextfound) {
if(whichorbinfo == o) {
if(it == itHyperstone) {
extra += extraline(it, its(last+maxstep));
}
else {
orbinfoline += XLAT("Unlocked by: %1 in %2", it, landof(it));
if(maxstep == 1)
orbinfoline += XLAT(" (next at %1)", its(last+1));
else
orbinfoline += XLAT(" (next at %1 to %2)", its(last+1), its(last + maxstep));
}
}
nextfound = true;
}
if(xnext <= qty) remaining[o]++;
last = xnext;
}
}
}
int nextp2(int i) {
int z = 1;
while(z <= i) z <<= 1;
return z;
}
void gainMirrors(eItem forwhich) {
int qtl = items[forwhich];
while(qtl > 0) qtl >>= 1, remaining[itOrbMirror]++;
if(whichorbinfo == itOrbMirror)
extra += extraline(forwhich, its(nextp2(items[forwhich])));
}
vector<eItem> offensiveOrbs = {
itOrbFlash, itOrbLightning, itOrbPsi, itOrbThorns,
itOrbFreedom, itOrbSword, itOrbSword2,
itOrbHorns, itOrbDragon, itOrbStunning
};
vector<eItem> elementalOrbs = {itOrbFire, itOrbWater, itOrbDigging, itOrbAir};
vector<eItem> demonicOrbs = {itOrbFire, itOrbHorns, itOrbSummon};
bool isIn(eItem o, vector<eItem>& l) {
for(auto it: l) if(it == o) return true;
return false;
}
void gainRandomOrbs(vector<eItem> orblist, eItem which, int each, int reduce) {
const int qoff = isize(orblist);
for(int i=1; i<qoff; i++) swap(orblist[i], orblist[irand(1+i)]);
for(int i=0; i<20; i++) {
int nextat = (i+1)*each + reduce;
if(items[which] >= nextat) {
remaining[orblist[i%qoff]]++;
}
else {
if(isIn(whichorbinfo, orblist))
extra += extraline(which, its(nextat) + "?");
break;
}
}
}
void gainGuestOrbs() {
for(auto& oi: orbinfos) {
if(oi.flags & orbgenflags::OSM_AT10) {
eItem it = treasureType(oi.l);
int fst = ls::any_chaos() ? 5 : 10;
if(items[it] >= fst) {
remaining[oi.orb]++;
}
if(whichorbinfo == oi.orb) extra += extraline(it, its(fst));
}
}
}
void gainLove() {
if(princess::reviveAt) {
remaining[itOrbLove]++;
int s = gold(NO_LOVE);
int last = princess::reviveAt;
for(int k=0;; k++) {
int nextstep = 50 + 20 * k;
last += nextstep;
if(last > s) {
if(whichorbinfo == itOrbLove) {
orbinfoline += XLAT("Unlocked by: %1 in %2", itSavedPrincess, laPrincessQuest);
orbinfoline += XLAT(" (next at %1)", its(last));
}
break;
}
else { last += nextstep; remaining[itOrbLove]++; }
}
}
}
void gainLate(eItem tr, eItem orb) {
int at = 10 + irand(41);
int itr = items[tr];
if(itr >= at) remaining[orb]++;
if(whichorbinfo == orb)
extra += extraline(tr, itr >= at ? (its(at)+"!") : "10-50");
}
/** \brief Compute how many orbs you get for your current treasure. This is called after every move, and should give consistent results */
EX void compute() {
extra = "";
orbinfoline = "";
for(int i=0; i<ittypes; i++) remaining[i] = extra_orbs[i]-usedup[i];
for(int i=0; i<ittypes; i++) if(usedup[i] >= TESTMIRRORED) {
remaining[i] += MIRRORED;
remaining[i] -= mirrorqty0(eItem(i));
remaining[i] += mirrorqty(eItem(i));
}
sirand(rseed);
gainGuestOrbs();
gainOrbs(itShard, itOrbMirror);
gainOrbs(itHyperstone, itOrbMirror);
gainOrbs(itDiamond, itOrbFlash);
gainOrbs(itGold, itOrbLife);
gainOrbs(itSpice, itOrbShield);
gainOrbs(itRuby, itOrbLightning);
gainOrbs(itElixir, itOrbSpeed);
gainOrbs(itBone, itGreenStone);
gainOrbs(itHell, itOrbYendor);
gainOrbs(itStatue, itOrbTeleport);
gainOrbs(itFeather, itOrbSafety);
gainOrbs(itSapphire, itOrbMorph);
gainOrbs(itFernFlower, itOrbThorns);
gainOrbs(itWine, itOrbAether);
gainOrbs(itSilver, itOrbDigging);
gainOrbs(itRoyalJelly, itOrbInvis);
gainOrbs(itEmerald, itOrbPsi);
gainOrbs(itPower, itOrbFire);
gainOrbs(itHolyGrail, itOrbIllusion);
gainOrbs(itGrimoire, itOrbDragon);
gainOrbs(itPirate, itOrbTime);
gainOrbs(itRedGem, itOrbSpace);
gainOrbs(itBombEgg, itOrbFriend);
gainOrbs(itCoast, itOrbEmpathy);
gainOrbs(itWhirlpool, itOrbWater);
gainOrbs(itPalace, itOrbDiscord);
gainOrbs(itFjord, itOrbFish);
gainOrbs(itSavedPrincess, itOrbLove);
gainOrbs(itIvory, itOrbMatter);
gainOrbs(itZebra, itOrbFrog);
gainOrbs(itElemental, itOrbSummon);
gainOrbs(itFulgurite, itOrbStunning);
gainOrbs(itMutant, itOrbWoods);
gainOrbs(itMutant2, itOrbFreedom);
gainOrbs(itLotus, itOrbUndeath);
gainOrbs(itWindstone, itOrbAir);
gainOrbs(itRose, itOrbBeauty);
gainOrbs(itCoral, itOrb37);
gainOrbs(itBabyTortoise, itOrbShell);
gainOrbs(itApple, itOrbEnergy);
gainOrbs(itDragon, itOrbDomination);
gainOrbs(itKraken, itOrbSword);
gainOrbs(itBarrow, itOrbSword2);
gainOrbs(itTrollEgg, itOrbStone);
gainOrbs(itSlime, itOrbRecall);
gainOrbs(itAmethyst, itOrbNature);
gainOrbs(itDodeca, itOrbDash);
gainOrbs(itGreenGrass, itOrbBull);
gainOrbs(itBull, itOrbHorns);
if(items[itOrbYendor]) remaining[itOrbMirror]++;
gainMirrors(itOrbYendor);
gainMirrors(itHolyGrail);
gainLove();
gainRandomOrbs(offensiveOrbs, itBone, 25, 0);
gainRandomOrbs(elementalOrbs, itElemental, 12, 0);
gainRandomOrbs(demonicOrbs, itHell, 20, 100);
gainOrbs(itLavaLily, itOrbLava);
gainOrbs(itHunting, itOrbSide3);
gainOrbs(itBlizzard, itOrbWinter);
gainOrbs(itTerra, itOrbSide1);
for(auto& it: lateextraorbs) gainLate(it.treasure, it.orb);
gainOrbs(itGlowCrystal, itOrbSide2);
gainOrbs(itSwitch, itOrbPhasing);
gainOrbs(itMagnet, itOrbMagnetism);
gainOrbs(itRuins, itOrbSlaying);
gainOrbs(itWest, itOrbGravity);
gainOrbs(itVarTreasure, itOrbIntensity);
gainOrbs(itBrownian, itOrbChoice);
gainOrbs(itFrog, itOrbImpact);
gainOrbs(itWet, itOrbPlague);
gainOrbs(itEclectic, itOrbChaos);
gainOrbs(itCursed, itOrbPurity);
gainOrbs(itDice, itOrbLuck);
#if CAP_DAILY
daily::gifts();
#endif
if(items[itOrbLove] && !items[itSavedPrincess]) items[itSavedPrincess] = 1;
int& r = remaining[itGreenStone];
if(items[itBone] >= 0) {
for(int i=0; i<ittypes; i++) if(i != itGreenStone) {
r += usedup[i];
if(usedup[i] >= TESTMIRRORED) r -= (MIRRORED - mirrorqty0(eItem(i)));
}
}
items[itGreenStone] += r;
usedup[itGreenStone] += r;
r = 0;
if(shmup::on) for(int i=0; i<ittypes; i++) {
if(remaining[i] && isShmupLifeOrb(eItem(i))) {
gainLife();
remaining[i]--;
usedup[i]++;
}
}
items[itInventory] = 0;
for(int i=0; i<ittypes; i++)
if(i != itGreenStone && i != itOrbYendor)
items[itInventory] += remaining[i];
}
map<char, eItem> orbmap;
string orbkeys = "zfwplSetsTaMIYgCcPOWAFydLGRUkouE.,bVNxDjJZnrvhBm!23456789@#$%()";
typedef pair<int, int> pxy;
vector<pxy> orbcoord;
int sq(pxy p) {
int zz = (2*p.first+p.second)*(2*p.first+p.second) + 3*p.second*p.second;
zz *= 20; zz += abs(p.second);
zz *= 20; zz += abs(p.first);
zz *= 4; zz += (p.first>0)*2+(p.second>0);
return zz;
}
bool plain;
eItem which;
bool mirroring;
EX const char* helptext =
"You are playing in the Orb Strategy Mode. Collecting treasure "
"gives you access to magical Orb powers. In this mode, "
"unlocking requirements are generally higher, and "
"several quests and lands "
"give you extremely powerful Orbs of the Mirror.\n";
void evokeBeautyAt(cell *c) {
forCellEx(c2, c)
if(c2->monst && !isFriendly(c2->monst) && !isIvy(c2->monst)) {
c2->stuntime += 3;
checkStunKill(c2);
}
}
void evokeOrb(eItem it) {
if(it == itOrbFreedom)
for(cell *pc: player_positions())
checkFreedom(pc);
if(it == itOrbBeauty) {
for(cell *pc: player_positions())
evokeBeautyAt(pc);
if(items[itOrbEmpathy])
for(cell *c: dcal) if(isFriendly(c->monst))
evokeBeautyAt(c);
}
if(it == itOrbDigging) {
forCellCM(c2, cwt.at) {
earthFloor(c2);
if(c2->wall == waCavewall && !c2->monst)
c2->wall = waNone;
}
}
if(it == itOrbSword || it == itOrbSword2) {
for(int i: player_indices()) {
cwt.at = playerpos(i);
multi::cpid = i;
swordAttackStatic(it == itOrbSword2);
}
}
}
EX string osminfo(eItem orb) {
string s = XLAT("Number of uses left: %1", its(remaining[orb]));
int us = usedup[orb];
if(us >= TESTMIRRORED) s += XLAT(" (mirrored)"), us = us - MIRRORED + mirrorqty0(orb);
if(us) s += XLAT(" (used %1 times)", its(us));
return s;
}
EX bool activating;
/** \brief show the OSM Orb screen */
EX void show() {
multi::cpid = 0; /* just in case */
if(remaining[itOrbSword]) items[itOrbSword]++;
if(remaining[itOrbSword2]) items[itOrbSword2]++;
cmode = sm::CENTER | sm::DARKEN;
gamescreen();
if(remaining[itOrbSword]) items[itOrbSword]--;
if(remaining[itOrbSword2]) items[itOrbSword2]--;
orbcoord.clear();
for(int y=-3; y<=3; y++) for(int x=-5; x<=5; x++) if(x+y<=6 && x+y >= -6 && (x||y))
orbcoord.emplace_back(x,y);
sort(orbcoord.begin(), orbcoord.end(), [](pxy p1, pxy p2) {
return sq(p1) < sq(p2); });
ld rad = min(vid.xres, vid.yres) / 20;
ld rad3 = int(rad * sqrt(3));
compute();
orbmap.clear();
which = itNone;
if(plain) {
dialog::init(mirroring ? XLAT("mirror what?") : XLAT("inventory"), forecolor, 150, 100);
dialog::start_list(2000, 2000);
}
int j = 0, oc = 6;
if(1) {
flat_model_enabler fme;
for(int i=0; i<ittypes; i++) {
eItem o = eItem(i);
if(itemclass(o) == IC_ORB && !(classflag(o) & IF_CURSE)) {
char c = orbkeys[j++];
if(c == 0) println(hlog, "missing char for ", dnameof(o));
if(remaining[i] || usedup[i]) {
orbmap[c] = o;
if(plain)
dialog::addSelItem(XLAT1(iinf[o].name), its(remaining[i]), c);
else {
if(oc >= isize(orbcoord)) {
println(hlog, "error: oc=", oc, " with only ", isize(orbcoord), " positions");
continue;
}
auto pos = orbcoord[oc++];
ld px = current_display->xcenter + 2*rad*pos.first + rad*pos.second;
ld py = current_display->ycenter + pos.second * rad3;
int icol = iinf[o].color;
if(!remaining[i]) icol = gradient(icol, 0, 0, .5, 1);
bool gg = graphglyph(false);
bool b = hypot(mousex-px, mousey-py) < rad;
if(!hiliteclick) {
if(gg) {
initquickqueue();
poly_outline = OUTLINE_DEFAULT;
transmatrix V = atscreenpos(px, py, rad*2);
drawItemType(o, NULL, shiftless(V), icol, ticks/3 + i * 137, false);
quickqueue();
}
string s = remaining[i] <= 0 ? "X" : its(remaining[i]);
if(vid.orbmode < 2) {
int tcol = remaining[i] ? darkenedby(icol, 1) : 0;
if(remaining[i] != 1 || !gg)
displaystr(px, py, 2, gg?rad:rad*3/2, s, tcol, 8);
}
else {
if(remaining[i] != 1 || !gg) {
displayfr(px + rad/2, py + rad/2, 2, gg?rad:rad*3/2, remaining[i] <= 0 ? "X" : remaining[i] == 1 ? "o" : its(remaining[i]), dialog::dialogcolor_over(b), 8);
}
}
}
if(b) {
getcstat = c,
which = o;
}
}
}
}
}
}
if(plain) {
dialog::end_list();
dialog::addBreak(50);
dialog::addItem(XLAT("help"), SDLK_F1);
dialog::addItem(XLAT("return to the game"), 'i');
dialog::display();
which = orbmap[getcstat];
}
else {
if(which == itNone) {
displaystr(vid.xres/2, vid.fsize*2, 2, vid.fsize*2, XLAT("Which orb to use?"), 0xC0C0C0, 8);
}
else {
int icol = iinf[which].color;
displaystr(vid.xres/2, vid.fsize*2, 2, vid.fsize*2, XLAT1(iinf[which].name), icol, 8);
if(mirroring)
displaystr(vid.xres/2, vid.fsize*4, 2, vid.fsize, usedup[which] >= TESTMIRRORED ? XLAT("already mirrored") : XLAT("Uses to gain: %1", its(mirrorqty(which))), icol, 8);
else {
whichorbinfo = which;
compute();
displaystr(vid.xres/2, vid.fsize*4, 2, vid.fsize, orbinfoline, icol, 8);
if(extra != "")
displaystr(vid.xres/2, vid.fsize*5, 2, vid.fsize, XLAT("Extras:")+extra, icol, 8);
}
if(remaining[which] != 1 || usedup[which]) {
displaystr(vid.xres/2, vid.yres - vid.fsize*6, 2, vid.fsize, osminfo(which), icol, 8);
}
#if !ISMOBILE
string hot = XLAT1("Hotkey: "); hot += getcstat;
displaystr(vid.xres/2, vid.yres - vid.fsize*5, 2, vid.fsize, hot, icol, 8);
#endif
eLand pl = getPrizeLand();
eOrbLandRelation olr = getOLR(which, pl);
color_t col = 0;
const char *fmsg = NULL;
if(olr == olrDangerous)
col = 0xC00000,
fmsg = "Using %the1 in %the2 sounds dangerous...";
else if(olr == olrUseless)
col = 0xC00000,
fmsg = "%The1 is mostly useless in %the2...";
else if(olr == olrForbidden)
col = 0x804000,
fmsg = "%The1 is forbidden in %the2 (disables some achievements)";
if(fmsg)
displaystr(vid.xres/2, vid.yres - vid.fsize*4, 2, vid.fsize, XLAT(fmsg, which, pl), col, 8);
}
}
dialog::displayPageButtons(7, 0);
mouseovers = "";
keyhandler = [] (int sym, int uni) {
if(plain) dialog::handleNavigation(sym, uni);
if(orbmap.count(uni)) {
eItem orb = orbmap[uni];
if(remaining[orb] <= 0) ;
else if(orb == itOrbMirror) {
mirroring = !mirroring;
// an amusing message
if(remaining[itOrbMirror] >= 2 && !mirroring)
addMessage(XLAT("You mirror %the1.", orb));
if(mirroring) {
bool next = false;
forCellEx(c2, cwt.at) if(c2->wall == waMirror || c2->wall == waCloud || c2->wall == waMirrorWall)
next = true;
if(!next) {
addMessage(XLAT("You need to stand next to a magic mirror or cloud to use %the1.", itOrbMirror));
mirroring = false;
}
}
}
else if(mirroring) {
if(usedup[orb] >= TESTMIRRORED) {
addMessage(XLAT("Each orb type can be mirrored only once."));
mirroring = false;
}
else if(remaining[orb] > 0) {
usedup[itOrbMirror]++;
usedup[orb] += MIRRORED;
usedup[orb] -= mirrorqty0(orb);
addMessage(XLAT("You mirror %the1.", orb));
mirroring = false;
}
else mirroring = false;
}
else if((isHaunted(cwt.at->land) || cwt.at->land == laDungeon) && orb == itOrbSafety) {
addMessage(XLAT("This would only move you deeper into the trap!"));
}
else {
eItem it = cwt.at->item;
cwt.at->item = orbmap[uni];
inv::activating = true;
collectItem(cwt.at, cwt.at, true);
inv::activating = false;
addMessage(XLAT("You activate %the1.", orbmap[uni]));
if(!cwt.at->item) usedup[orbmap[uni]]++;
if(getOLR(it, getPrizeLand()) == olrForbidden)
usedForbidden = true;
cwt.at->item = it;
evokeOrb(orbmap[uni]);
checkmove();
popScreenAll();
}
}
else if(uni == '1') plain = !plain;
else if(sym == SDLK_F1)
gotoHelp(which ? generateHelpForItem(which) : XLAT(helptext));
else if(doexiton(sym, uni)) {
if(mirroring) mirroring = false;
popScreen();
}
};
}
#if CAP_SAVE
EX void applyBox(eItem it) {
scores::applyBoxNum(inv::usedup[it], "@inv-" + dnameof(it));
}
#endif
EX int incheck;
EX void check(int delta) {
incheck += delta;
for(int i=0; i<ittypes; i++) {
eItem it = eItem(i);
if(itemclass(it) == IC_ORB)
items[it] += delta * remaining[it] * orbcharges(it);
}
}
#endif
#if !CAP_INV
EX always_false on, activating;
#endif
EX }
}
|