1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-30 03:50:34 +00:00
hyperrogue/orbs.cpp

1706 lines
50 KiB
C++
Raw Normal View History

// Hyperbolic Rogue -- orbs
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
2016-08-26 09:58:03 +00:00
/** \file orbs.cpp
* \brief Implementation of various Orb effects, and their properties such as default and maximum charges
*/
2016-08-26 09:58:03 +00:00
#include "hyper.h"
namespace hr {
EX bool orbused[ittypes], lastorbused[ittypes];
2019-08-09 19:00:52 +00:00
EX bool markOrb(eItem it) {
2016-08-26 09:58:03 +00:00
if(!items[it]) return false;
orbused[it] = true;
return true;
}
2019-08-09 19:00:52 +00:00
EX bool markEmpathy(eItem it) {
2016-08-26 09:58:03 +00:00
if(!items[itOrbEmpathy]) return false;
if(!markOrb(it)) return false;
markOrb(itOrbEmpathy);
return true;
}
2019-08-09 19:00:52 +00:00
EX bool markEmpathy2(eItem it) {
2017-03-23 10:53:57 +00:00
if(items[itOrbEmpathy] < 2) return false;
if(!markOrb2(it)) return false;
markOrb2(itOrbEmpathy);
return true;
}
2019-08-09 19:00:52 +00:00
EX bool markOrb2(eItem it) {
2017-03-23 10:53:57 +00:00
return markOrb(it);
/* if(!items[it]) return false;
2016-08-26 09:58:03 +00:00
orbused[it] = true;
2017-03-23 10:53:57 +00:00
return items[it] > 1; */
2016-08-26 09:58:03 +00:00
}
2019-08-09 19:00:52 +00:00
EX int fixpower(int qty) {
2016-08-26 09:58:03 +00:00
if(markOrb(itOrbEnergy)) qty = (qty+1)/2;
return qty;
}
2019-08-09 19:00:52 +00:00
EX void useupOrb(eItem it, int qty) {
2016-08-26 09:58:03 +00:00
items[it] -= fixpower(qty);
if(items[it] < 0) items[it] = 0;
}
2019-08-09 21:24:33 +00:00
EX void drainOrb(eItem it, int target IS(0)) {
2016-08-26 09:58:03 +00:00
if(items[it] > target) useupOrb(it, items[it] - target);
}
EX void empathyMove(const movei& mi) {
2016-08-26 09:58:03 +00:00
if(!items[itOrbEmpathy]) return;
if(items[itOrbFire]) {
invismove = false;
if(makeflame(mi.s, 10, false)) markEmpathy(itOrbFire);
2016-08-26 09:58:03 +00:00
}
2021-05-02 13:16:29 +00:00
if(items[itCurseWater]) {
invismove = false;
if(makeshallow(mi.s, 10, false)) markEmpathy(itCurseWater);
}
2016-08-26 09:58:03 +00:00
if(items[itOrbDigging]) {
if(mi.proper() && earthMove(mi))
2016-08-26 09:58:03 +00:00
markEmpathy(itOrbDigging), invismove = false;
}
if(items[itOrbWinter] && isIcyLand(mi.s) && mi.s->wall == waNone) {
2016-08-26 09:58:03 +00:00
invismove = false;
mi.s->wall = waIcewall;
2016-08-26 09:58:03 +00:00
markEmpathy(itOrbWinter);
}
}
2019-11-27 23:14:22 +00:00
EX int intensify(int val) {
return inv::on ? 2 * val : val * 6 / 5;
}
2019-08-09 19:00:52 +00:00
EX bool reduceOrbPower(eItem it, int cap) {
2021-05-02 13:16:29 +00:00
if(items[it] && markOrb(itCurseDraining)) {
items[it] -= (markOrb(itOrbEnergy) ? 1 : 2) * multi::activePlayers();
if(items[it] < 0) items[it] = 0;
if(items[it] == 0 && it == itOrbLove)
princess::bringBack();
}
2017-03-23 10:53:57 +00:00
if(items[it] && (lastorbused[it] || (it == itOrbShield && items[it]>3) || !markOrb(itOrbTime))) {
items[it] -= multi::activePlayers();
2020-02-29 16:58:59 +00:00
if(isHaunted(cwt.at->land))
fail_survivalist();
2016-08-26 09:58:03 +00:00
if(items[it] < 0) items[it] = 0;
2019-11-27 23:14:22 +00:00
if(items[it] > cap && markOrb(itOrbIntensity)) cap = intensify(cap);
2017-03-23 10:53:57 +00:00
if(items[it] > cap && timerghost) items[it] = cap;
2016-08-26 09:58:03 +00:00
if(items[it] == 0 && it == itOrbLove)
princess::bringBack();
return true;
}
2017-03-23 10:53:57 +00:00
if(items[it] > cap && timerghost) items[it] = cap;
2016-08-26 09:58:03 +00:00
return false;
}
2019-08-09 19:00:52 +00:00
EX void reduceOrbPowerAlways(eItem it) {
2016-08-26 09:58:03 +00:00
if(items[it]) {
2017-03-23 10:53:57 +00:00
items[it] -= multi::activePlayers();
2016-08-26 09:58:03 +00:00
if(items[it] < 0) items[it] = 0;
}
}
EX void reverse_curse(eItem curse, eItem orb, bool cancel) {
2021-05-02 13:16:29 +00:00
if(items[curse] && markOrb(itOrbPurity)) {
items[orb] += items[curse];
if(curse == itCurseWater) items[itOrbWinter] += items[curse];
2021-05-02 13:16:29 +00:00
items[curse] = 0;
}
if(cancel && items[curse] && items[orb]) {
int m = min(items[curse], items[orb]);
items[curse] -= m;
items[orb] -= m;
}
2021-05-02 13:16:29 +00:00
}
2019-08-09 19:00:52 +00:00
EX void reduceOrbPowers() {
2021-05-02 13:16:29 +00:00
reverse_curse(itCurseWeakness, itOrbSlaying, true);
reverse_curse(itCurseFatigue, itOrbSpeed, false); // OK
reverse_curse(itCurseRepulsion, itOrbMagnetism, true); // OK
reverse_curse(itCurseWater, itOrbFire, true); // OK
reverse_curse(itCurseDraining, itOrbTime, false); // OK
reverse_curse(itCurseGluttony, itOrbChoice, true); // OK
2021-05-02 13:16:29 +00:00
2017-03-23 10:53:57 +00:00
if(haveMount()) markOrb(itOrbDomination);
2016-08-26 09:58:03 +00:00
for(int i=0; i<ittypes; i++)
lastorbused[i] = orbused[i], orbused[i] = false;
if(items[itOrbShield]) orbused[itOrbShield] = lastorbused[itOrbShield];
reduceOrbPower(itOrbTime, cwt.at->land == laCaribbean ? 777 : 150);
2016-08-26 09:58:03 +00:00
if(invismove && !invisfish) markOrb(itOrbInvis);
reduceOrbPower(itOrbLightning, 777);
reduceOrbPower(itOrbSpeed, 67);
reduceOrbPower(itOrbShield, 77);
reduceOrbPower(itOrbShell, 150);
reduceOrbPower(itOrbFlash, 777);
reduceOrbPower(itOrbWinter, 77);
reduceOrbPower(itOrbFire, 77);
reduceOrbPower(itOrbIllusion, 111);
reduceOrbPower(itOrbDragon, 111);
reduceOrbPower(itOrbPsi, 111);
reduceOrbPower(itOrbInvis, 77);
2017-03-23 10:53:57 +00:00
reduceOrbPower(itOrbAether, 77);
2021-05-21 23:57:22 +00:00
reduceOrbPower(itOrbWoods, 100);
2016-08-26 09:58:03 +00:00
reduceOrbPower(itOrbDigging, 100);
reduceOrbPower(itOrbTeleport, 200);
2017-03-23 10:53:57 +00:00
reduceOrbPower(itOrbSpace, 150);
2017-12-30 23:08:55 +00:00
reduceOrbPower(itOrbMagnetism, 150);
2016-08-26 09:58:03 +00:00
reduceOrbPowerAlways(itOrbSafety);
reduceOrbPower(itOrbThorns, 150);
reduceOrbPower(itOrbWater, 150);
reduceOrbPower(itOrbAir, 150);
reduceOrbPower(itOrbFrog, 77);
2017-03-23 10:53:57 +00:00
reduceOrbPower(itOrbDash, 77);
2017-12-30 23:08:55 +00:00
reduceOrbPower(itOrbPhasing, 77);
2016-08-26 09:58:03 +00:00
reduceOrbPower(itOrbDiscord, 67);
reduceOrbPower(itOrbSummon, 333);
reduceOrbPower(itOrbMatter, 333);
2017-03-23 10:53:57 +00:00
reduceOrbPower(itOrbFish, 57 + 20 * multi::activePlayers());
2016-08-26 09:58:03 +00:00
if(!items[itSavedPrincess]) items[itOrbLove] = 0;
reduceOrbPower(itOrbLove, 777);
reduceOrbPower(itOrbStunning, 100);
reduceOrbPower(itOrbLuck, 333);
reduceOrbPower(itOrbUndeath, 77);
reduceOrbPower(itOrbFreedom, 77);
reduceOrbPower(itOrbEmpathy, 77);
markOrb(itOrb37); reduceOrbPower(itOrb37, 333);
2017-03-23 10:53:57 +00:00
reduceOrbPower(itOrbBeauty, 77);
2016-08-26 09:58:03 +00:00
reduceOrbPower(itOrbEnergy, 77);
reduceOrbPower(itOrbDomination, 120);
2017-03-23 10:53:57 +00:00
reduceOrbPower(itOrbSword, 100 + 20 * multi::activePlayers());
reduceOrbPower(itOrbSword2, 100 + 20 * multi::activePlayers());
reduceOrbPower(itOrbStone, 120);
reduceOrbPower(itOrbNature, 120);
reduceOrbPower(itOrbRecall, 77);
reduceOrbPower(itOrbBull, 120);
reduceOrbPower(itOrbHorns, 77);
reduceOrbPower(itOrbLava, 80);
reduceOrbPower(itOrbMorph, 80);
reduceOrbPower(itOrbSlaying, 120);
reduceOrbPower(itOrbGravity, 120);
reduceOrbPower(itOrbChoice, 120);
2018-12-25 18:27:19 +00:00
reduceOrbPower(itOrbIntensity, 120);
reduceOrbPower(itOrbImpact, 120);
2020-02-26 00:18:31 +00:00
reduceOrbPower(itOrbChaos, 120);
2020-02-26 01:49:35 +00:00
reduceOrbPower(itOrbPlague, 120);
reduceOrbPower(itOrbSide1, 120);
reduceOrbPower(itOrbSide2, 120);
reduceOrbPower(itOrbSide3, 120);
if(cwt.at->land != laWildWest)
2016-08-26 09:58:03 +00:00
reduceOrbPower(itRevolver, 6);
2021-05-02 11:39:09 +00:00
reduceOrbPower(itOrbPurity, 30);
reduceOrbPower(itCurseWeakness, 199);
reduceOrbPower(itCurseDraining, 199);
reduceOrbPower(itCurseWater, 199);
reduceOrbPower(itCurseFatigue, 199);
reduceOrbPower(itCurseRepulsion, 199);
reduceOrbPower(itCurseGluttony, 199);
2021-05-02 11:39:09 +00:00
#if CAP_COMPLEX2
mine::auto_teleport_charges();
#endif
whirlwind::calcdirs(cwt.at);
items[itStrongWind] = !items[itOrbAether] && whirlwind::qdirs == 1;
2017-03-23 10:53:57 +00:00
items[itWarning] = 0;
2016-08-26 09:58:03 +00:00
}
2019-08-09 19:00:52 +00:00
EX void flashAlchemist(cell *c) {
2016-08-26 09:58:03 +00:00
if(isAlch(c)) {
if(isAlch(cwt.at))
c->wall = cwt.at->wall;
2016-08-26 09:58:03 +00:00
else
c->wall = eWall(c->wall ^ waFloorB ^ waFloorA);
}
}
2019-08-09 19:00:52 +00:00
EX void flashCell(cell *c, eMonster killer, flagtype flags) {
2020-02-29 18:19:30 +00:00
changes.ccell(c);
2017-03-23 10:53:57 +00:00
eWall ow = c->wall;
2016-08-26 09:58:03 +00:00
flashAlchemist(c);
2017-03-23 10:53:57 +00:00
if((flags & AF_MSG) && c->monst && !isWorm(c) && c->monst != moShadow)
2016-08-26 09:58:03 +00:00
addMessage(XLAT("%The1 is destroyed by the Flash.", c->monst));
2020-03-02 19:35:32 +00:00
if(c->monst || isPlayerOn(c))
if(canAttack(nullptr, killer, c, c->monst, flags))
attackMonster(c, flags, killer);
2016-08-26 09:58:03 +00:00
if(isIcyLand(c))
HEAT(c) += 2;
if(c->land == laDryForest)
c->landparam += 2;
if(c->wall == waCavewall) c->wall = waCavefloor;
if(c->wall == waDeadTroll) c->wall = waCavefloor;
if(c->wall == waDeadTroll2) c->wall = waNone;
2017-03-23 10:53:57 +00:00
if(c->wall == waPetrified) c->wall = waNone;
2016-08-26 09:58:03 +00:00
if(c->wall == waDeadfloor2) c->wall = waDeadfloor;
if(c->wall == waGargoyleFloor) c->wall = waChasm;
if(c->wall == waGargoyleBridge) placeWater(c, c);
if(c->wall == waGargoyle) c->wall = waNone;
if(c->wall == waTerraWarrior) c->wall = waNone, kills[moTerraWarrior]++;
2016-08-26 09:58:03 +00:00
if(c->wall == waPlatform) c->wall = waNone;
2017-10-08 12:02:03 +00:00
if(c->wall == waStone) c->wall = waNone, destroyTrapsAround(c);
2016-08-26 09:58:03 +00:00
if(c->wall == waRubble) c->wall = waNone;
if(c->wall == waDeadwall) c->wall = waDeadfloor2;
if(c->wall == waGiantRug) c->wall = waNone;
if(c->wall == waMirror) c->wall = waNone;
if(c->wall == waCloud) c->wall = waNone;
if(c->wall == waExplosiveBarrel) explodeBarrel(c);
if(c->wall == waRuinWall) c->wall = waNone;
2016-08-26 09:58:03 +00:00
if(c->wall == waDune) c->wall = waNone;
if(c->wall == waSaloon) c->wall = waNone;
if(c->wall == waSandstone) c->wall = waNone;
if(c->wall == waAncientGrave) c->wall = waNone;
if(c->wall == waFreshGrave) c->wall = waNone;
if(c->wall == waColumn) c->wall = waNone;
if(c->wall == waGlass) c->wall = waNone;
if(c->wall == waBigTree || c->wall == waSmallTree) c->wall = waNone;
if(c->wall == waBigStatue) c->wall = waNone;
if(c->wall == waCTree) c->wall = waCIsland2;
if(c->wall == waPalace) c->wall = waRubble;
if(c->wall == waRose) c->wall = waNone;
if(c->wall == waOpenGate || c->wall == waClosedGate) {
eWall w = c->wall;
c->wall = waNone;
for(int i=0; i<c->type; i++) if(c->move(i) && c->move(i)->wall == w)
flashCell(c->move(i), killer, flags);
2016-08-26 09:58:03 +00:00
}
if(c->wall == waRed1) c->wall = waNone;
else if(c->wall == waRed2) c->wall = waRed1;
else if(c->wall == waRed3) c->wall = waRed2;
2017-03-23 10:53:57 +00:00
if(c->wall == waBarrowWall) c->wall = waBarrowDig;
else if(c->wall == waBarrowDig) c->wall = waNone;
if(c->wall != ow && ow) drawParticles(c, winf[ow].color, 16);
2016-08-26 09:58:03 +00:00
if(hasTimeout(c) && c->wparam < 77) c->wparam = 77;
if(isActivable(c))
activateActiv(c, false);
}
2019-08-09 19:00:52 +00:00
EX void activateFlashFrom(cell *cf, eMonster who, flagtype flags) {
2016-08-26 09:58:03 +00:00
drawFlash(cf);
2017-03-23 10:53:57 +00:00
playSound(cf, "storm");
2018-06-22 12:47:24 +00:00
for(int i=0; i<isize(dcal); i++) {
2016-08-26 09:58:03 +00:00
cell *c = dcal[i];
if(c == cf) continue;
for(int t=0; t<c->type; t++)
for(int u=0; u<cf->type; u++)
if(c->move(t) == cf->move(u) && c->move(t) != NULL) {
2017-03-23 10:53:57 +00:00
flashCell(c, who, flags);
goto nexti;
2016-08-26 09:58:03 +00:00
}
2017-03-23 10:53:57 +00:00
nexti: ;
2016-08-26 09:58:03 +00:00
}
}
2019-08-09 19:00:52 +00:00
EX bool distanceBound(cell *c1, cell *c2, int d) {
2016-08-26 09:58:03 +00:00
if(!c1 || !c2) return false;
if(d == 0) return c1 == c2;
for(int i=0; i<c2->type; i++)
if(distanceBound(c1, c2->move(i), d-1)) return true;
2016-08-26 09:58:03 +00:00
return false;
}
2019-08-09 19:00:52 +00:00
EX void checkFreedom(cell *cf) {
2018-06-28 11:35:03 +00:00
manual_celllister cl;
cl.add(cf);
for(int i=0; i<isize(cl.lst); i++) {
cell *c = cl.lst[i];
2016-08-26 09:58:03 +00:00
if(c->cpdist >= 5) return;
for(int i=0; i<c->type; i++) {
cell *c2 = c->move(i);
2016-08-26 09:58:03 +00:00
// todo leader
if(cl.listed(c2)) continue;
2016-08-26 09:58:03 +00:00
if(!passable(c2, c, P_ISPLAYER | P_MIRROR | P_LEADER)) continue;
if(againstRose(c, c2) && !scentResistant()) continue;
if(c2->wall == waArrowTrap && c2->wparam == 2) continue;
2016-08-26 09:58:03 +00:00
bool monsterhere = false;
for(int j=0; j<c2->type; j++) {
cell *c3 = c2->move(j);
2016-08-26 09:58:03 +00:00
if(c3 && c3->monst && !isFriendly(c3))
monsterhere = true;
}
if(!monsterhere) cl.add(c2);
2016-08-26 09:58:03 +00:00
}
}
addMessage(XLAT("Your %1 activates!", itOrbFreedom));
drainOrb(itOrbFreedom);
2021-03-06 10:46:13 +00:00
for(cell *pc: player_positions())
drawBigFlash(pc);
2018-06-22 12:47:24 +00:00
for(int i=0; i<isize(dcal); i++) {
2016-08-26 09:58:03 +00:00
cell *c = dcal[i];
2017-03-23 10:53:57 +00:00
if(c == cf && !shmup::on) continue;
2016-08-26 09:58:03 +00:00
if(c->cpdist > 5) break;
2017-03-23 10:53:57 +00:00
flashCell(c, moPlayer, AF_MAGIC);
2016-08-26 09:58:03 +00:00
}
}
2019-08-09 19:00:52 +00:00
EX void activateFlash() {
2016-08-26 09:58:03 +00:00
int tk = tkills();
2017-03-23 10:53:57 +00:00
2021-03-06 10:46:13 +00:00
for(cell *pc: player_positions())
drawFlash(pc);
2017-03-23 10:53:57 +00:00
2016-08-26 09:58:03 +00:00
addMessage(XLAT("You activate the Flash spell!"));
playSound(cwt.at, "storm");
2016-08-26 09:58:03 +00:00
drainOrb(itOrbFlash);
2018-06-22 12:47:24 +00:00
for(int i=0; i<isize(dcal); i++) {
2016-08-26 09:58:03 +00:00
cell *c = dcal[i];
if(c->cpdist > 2) break;
2017-03-23 10:53:57 +00:00
flashCell(c, moPlayer, AF_MAGIC);
2016-08-26 09:58:03 +00:00
}
achievement_count("FLASH", tkills(), tk);
}
2019-08-09 19:00:52 +00:00
EX bool reflectingBarrierAt(cell *c) {
2017-03-23 10:53:57 +00:00
return
c->wall == waBarrier || c->wall == waCamelot ||
c->wall == waPalace || c->wall == waPlatform ||
c->wall == waTempWall || c->wall == waWarpGate || c->wall == waBarrowDig || c->wall == waBarrowWall;
}
2019-08-09 19:00:52 +00:00
EX bool reflectingBarrierAt(cellwalker& c, int d) {
2017-03-23 10:53:57 +00:00
if(d >= 3) return true;
if(d <= -3) return true;
2020-01-18 15:03:32 +00:00
d = gmod(c.spin + d, c.at->type);
if(!c.at->move(d)) return true;
2017-03-23 10:53:57 +00:00
return reflectingBarrierAt(c.at->move(d));
2016-08-26 09:58:03 +00:00
// WAS:
// if(c.at->move(d)->wall == waBarrier) return true;
2017-03-23 10:53:57 +00:00
// THEN:
// if(c.at->move(d)->land == laBarrier || c.at->move(d)->land == laOceanWall ||
// c.at->move(d)->land == laHauntedWall ||
// c.at->move(d)->land == laElementalWall) ;
2017-03-23 10:53:57 +00:00
// return false;
2016-08-26 09:58:03 +00:00
}
2019-08-09 19:00:52 +00:00
EX void killAdjacentSharks(cell *c) {
2016-08-26 09:58:03 +00:00
for(int i=0; i<c->type; i++) {
cell *c2 = c->move(i);
2017-03-23 10:53:57 +00:00
if(!c2) continue;
if(isShark(c2->monst)) {
2020-02-29 18:19:30 +00:00
changes.ccell(c2);
2016-08-26 09:58:03 +00:00
c2->ligon = true;
2017-03-23 10:53:57 +00:00
killMonster(c2, moLightningBolt);
2016-08-26 09:58:03 +00:00
killAdjacentSharks(c2);
}
2017-03-23 10:53:57 +00:00
if(isKraken(c2->monst) && isWatery(c2)) {
2020-02-29 18:19:30 +00:00
changes.ccell(c2);
2017-03-23 10:53:57 +00:00
cell *c3 = kraken::head(c2);
2020-02-29 18:19:30 +00:00
changes.ccell(c3);
2017-03-23 10:53:57 +00:00
c3->ligon = true;
2020-02-29 18:19:30 +00:00
forCellEx(c4, c3) changes.ccell(c4), killMonster(c4, moLightningBolt); // kill-all
2017-03-23 10:53:57 +00:00
forCellEx(c4, c3) if(isWatery(c4)) {
c4->ligon = true;
killAdjacentSharks(c4);
}
}
2016-08-26 09:58:03 +00:00
}
}
2019-08-09 19:00:52 +00:00
EX void castLightningBolt(cellwalker lig) {
2016-08-26 09:58:03 +00:00
int bnc = 0;
int counter = 1000;
2016-08-26 09:58:03 +00:00
while(true) {
counter--; if(counter < 0) break;
2016-08-26 09:58:03 +00:00
// printf("at: %p i=%d d=%d\n", lig.c, i, lig.spin);
killAdjacentSharks(lig.at);
2016-08-26 09:58:03 +00:00
if(lig.peek() == NULL) break;
2016-08-26 09:58:03 +00:00
2018-03-24 11:59:01 +00:00
lig += wstep;
2017-07-16 21:00:55 +00:00
if(inmirror(lig)) lig = mirror::reflect(lig);
2016-08-26 09:58:03 +00:00
cell *c = lig.at;
2020-02-29 18:19:30 +00:00
changes.ccell(c);
2016-08-26 09:58:03 +00:00
2017-03-23 10:53:57 +00:00
eWall ow = c->wall;
2016-08-26 09:58:03 +00:00
flashAlchemist(c);
if(c->monst == moMetalBeast2 && !c->item) c->item = itFulgurite;
2020-03-02 19:35:32 +00:00
if(c->monst)
if(canAttack(nullptr, moPlayer, c, c->monst, AF_MAGIC))
attackMonster(c, AF_MAGIC, moLightningBolt);
2016-08-26 09:58:03 +00:00
if(isIcyLand(c)) HEAT(c) += 2;
if(c->land == laDryForest) c->landparam += 2;
bool first = !c->ligon;
c->ligon = 1;
bool brk = false, spin = false;
2017-03-23 10:53:57 +00:00
2016-08-26 09:58:03 +00:00
if(c->wall == waGargoyle) brk = true;
if(c->wall == waExplosiveBarrel) explodeBarrel(c), brk = true;
2016-08-26 09:58:03 +00:00
if(c->wall == waCavewall) c->wall = waCavefloor, brk = true;
if(c->wall == waDeadTroll) c->wall = waCavefloor, brk = true;
if(c->wall == waDeadTroll2)c->wall = waNone, brk = true;
2017-03-23 10:53:57 +00:00
if(c->wall == waPetrified) c->wall = waNone, brk = true;
2016-08-26 09:58:03 +00:00
if(c->wall == waDeadfloor2)c->wall = waDeadfloor;
if(c->wall == waRubble) c->wall = waNone;
if(c->wall == waDeadwall) c->wall = waDeadfloor2, brk = true;
if(c->wall == waGlass) c->wall = waNone, spin = true;
if(c->wall == waDune) c->wall = waNone, brk = true;
if(c->wall == waRuinWall) c->wall = waNone;
2016-08-26 09:58:03 +00:00
if(c->wall == waIcewall) c->wall = waNone, brk = true;
if(c->wall == waAncientGrave) c->wall = waNone, spin = true;
if(c->wall == waFreshGrave) c->wall = waNone, spin = true;
2017-03-23 10:53:57 +00:00
if(c->wall == waFreshGrave) c->wall = waNone, spin = true;
2016-08-26 09:58:03 +00:00
if(c->wall == waBigStatue) c->wall = waNone, spin = true;
if(c->wall == waColumn) c->wall = waNone, spin = true;
2017-10-08 12:02:03 +00:00
if(c->wall == waStone) c->wall = waNone, brk = true, destroyTrapsAround(c);
if(c->wall == waArrowTrap) activateArrowTrap(c);
if(c->wall == waTerraWarrior) c->wall = waNone, kills[moTerraWarrior]++;
2016-08-26 09:58:03 +00:00
2017-03-23 10:53:57 +00:00
if(c->wall == waCanopy || c->wall == waTrunk || c->wall == waBigBush || c->wall == waSmallBush) {
makeflame(c, 12, false); brk = true;
}
2016-08-26 09:58:03 +00:00
if(c->wall == waGrounded) brk = true;
if(c->wall == waFan) spin = true;
if(c->wall == waMetal) c->wall = waCharged, brk = true;
2020-02-26 00:37:55 +00:00
if(c->wall == waSandstone) {
c->wall = waNone, brk = true;
if(c->land == laStorms) c->item = itFulgurite;
}
2016-08-26 09:58:03 +00:00
if(c->wall == waCharged && first) {
for(int i=0; i<c->type; i++)
// do not do strange things in horocyclic spires
if(c->move(i) && c->move(i)->wall != waCharged) {
2016-08-26 09:58:03 +00:00
cellwalker lig2(c, i);
castLightningBolt(lig2);
}
brk = true;
}
if(c->wall == waBoat && c != cwt.at) become_water(c), spin = true;
if(c->wall == waStrandedBoat && c !=cwt.at) c->wall = waNone, spin = true;
2016-08-26 09:58:03 +00:00
if((c->wall == waNone || c->wall == waSea) && c->land == laLivefjord)
c->wall = eWall(c->wall ^ waSea ^ waNone);
if(c->wall == waRed1) c->wall = waNone;
if(c->wall == waRed2) c->wall = waRed1;
if(c->wall == waRed3) c->wall = waRed2, brk = true;
if(isActivable(c)) activateActiv(c, false);
if(c->wall == waBigTree || c->wall == waSmallTree || c->wall == waVinePlant ||
c->wall == waSaloon) {
makeflame(c, 4, false);
brk = true;
}
2017-12-29 00:10:47 +00:00
if(c->wall == waDock) makeflame(c, 5, false);
2016-08-26 09:58:03 +00:00
if(c->wall == waCTree) makeflame(c, 12, false);
if(c->wall == waRose) makeflame(c, 60, false);
if(cellHalfvine(c) && c->wall == lig.peek()->wall) {
2016-08-26 09:58:03 +00:00
destroyHalfvine(c, waPartialFire, 4);
brk = true;
}
2017-03-23 10:53:57 +00:00
if(c->wall != ow && ow)
drawParticles(c, winf[ow].color, 16);
if(c == cwt.at) {bnc++; if(bnc > 10) break; }
if(spin) lig += hrand(lig.at->type);
2016-08-26 09:58:03 +00:00
if(brk) break;
2017-03-23 10:53:57 +00:00
if(reflectingBarrierAt(c)) {
2016-08-26 09:58:03 +00:00
int left = -1;
int right = 1;
2017-03-23 10:53:57 +00:00
while(!reflectingBarrierAt(lig, left)) left--;
while(!reflectingBarrierAt(lig, right)) right++;
2018-03-24 11:59:01 +00:00
lig += right + left;
2017-03-23 10:53:57 +00:00
if(c->wall == waBarrowWall) c->wall = waBarrowDig;
else if(c->wall == waBarrowDig) c->wall = waNone;
2016-08-26 09:58:03 +00:00
bnc++; if(bnc > 10) break;
}
2018-03-24 11:59:01 +00:00
else
lig += rev;
2017-07-22 23:33:27 +00:00
if(lig.at->wall == waCloud) {
lig.at->wall = waNone;
2017-07-22 23:33:27 +00:00
mirror::createMirages(lig, mirror::LIGHTNING);
2016-08-26 09:58:03 +00:00
}
if(lig.at->wall == waMirror) {
lig.at->wall = waNone;
2017-07-22 23:33:27 +00:00
mirror::createMirrors(lig, mirror::LIGHTNING);
2016-08-26 09:58:03 +00:00
}
}
}
2019-08-09 19:00:52 +00:00
EX void castLightningBoltFrom(cell *c) {
2017-03-23 10:53:57 +00:00
for(int i=0; i<c->type; i++) castLightningBolt(cellwalker(c, i));
}
2019-08-09 19:00:52 +00:00
EX void activateLightning() {
2016-08-26 09:58:03 +00:00
int tk = tkills();
drawLightning();
addMessage(XLAT("You activate the Lightning spell!"));
2018-06-22 12:47:24 +00:00
for(int i=0; i<isize(dcal); i++) if(dcal[i]) dcal[i]->ligon = 0;
2016-08-26 09:58:03 +00:00
drainOrb(itOrbLightning);
2017-03-23 10:53:57 +00:00
2021-03-06 10:46:13 +00:00
for(cell *pc: player_positions())
castLightningBoltFrom(pc);
2016-08-26 09:58:03 +00:00
elec::afterOrb = true;
elec::act();
elec::afterOrb = false;
achievement_count("LIGHTNING", tkills(), tk);
playSound(cwt.at, "storm");
2016-08-26 09:58:03 +00:00
}
// roCheck: return orb type if successful, 0 otherwise
// roMouse/roKeyboard:
// return orb type if successful, eItem(-1) if do nothing, 0 otherwise
2019-08-09 19:00:52 +00:00
EX bool haveRangedTarget() {
2016-08-26 09:58:03 +00:00
if(!haveRangedOrb())
return false;
2018-06-22 12:47:24 +00:00
for(int i=0; i<isize(dcal); i++) {
2016-08-26 09:58:03 +00:00
cell *c = dcal[i];
if(targetRangedOrb(c, roCheck)) {
return true;
}
}
return false;
}
2017-03-23 10:53:57 +00:00
void checkmoveO() {
if(multi::players > 1 && multi::activePlayers() == 1)
multi::checklastmove();
if(multi::players == 1) checkmove();
}
int teleportAction() {
// normal teleport
if(shmup::on || numplayers() == 1) return 1;
// multi-player, but all in -- do nothing
else if(numplayers() == multi::activePlayers()) return 0;
// otherwise teleport to the game
else return 2;
}
2020-03-07 22:45:30 +00:00
EX void teleportTo(cell *dest) {
2017-03-23 10:53:57 +00:00
playSound(dest, "other-teleport");
2016-08-26 09:58:03 +00:00
if(dest->monst) {
cwt.at->monst = dest->monst;
2016-08-26 09:58:03 +00:00
dest->monst = moNone;
}
2017-03-23 10:53:57 +00:00
if(teleportAction() == 2) {
bool b = multiRevival(dest, NULL);
if(b) {
killFriendlyIvy();
drainOrb(itOrbTeleport);
movecost(cwt.at, dest, 3);
playerMoveEffects(movei(cwt.at, dest, TELEPORT));
afterplayermoved();
2017-03-23 10:53:57 +00:00
bfs();
}
return;
}
addMessage(XLAT("You teleport to a new location!"));
2017-03-23 10:53:57 +00:00
killFriendlyIvy();
cell *from = cwt.at;
movecost(from, dest, 1);
playerMoveEffects(movei(cwt.at, dest, TELEPORT));
fix_whichcopy(dest);
cwt.at = dest; cwt.spin = hrand(dest->type); flipplayer = !!(hrand(2));
2016-08-26 09:58:03 +00:00
drainOrb(itOrbTeleport);
2017-07-22 23:33:27 +00:00
mirror::destroyAll();
2016-08-26 09:58:03 +00:00
afterplayermoved();
2016-08-26 09:58:03 +00:00
bfs();
sword::reset();
2017-03-23 10:53:57 +00:00
items[itOrbSword2] = 0;
2016-08-26 09:58:03 +00:00
if(shmup::on)
shmup::teleported();
else
2017-03-23 10:53:57 +00:00
checkmoveO();
movecost(from, dest, 2);
2020-10-15 14:33:52 +00:00
#if CAP_COMPLEX2
mine::auto_teleport_charges();
2020-10-15 14:33:52 +00:00
#endif
2016-08-26 09:58:03 +00:00
}
2020-02-29 16:58:59 +00:00
EX bool jumpTo(orbAction a, cell *dest, eItem byWhat, int bonuskill IS(0), eMonster dashmon IS(moNone)) {
2017-03-23 10:53:57 +00:00
if(byWhat != itStrongWind) playSound(dest, "orb-frog");
cell *from = cwt.at;
2020-02-29 18:19:16 +00:00
changes.value_keep(cwt);
changes.ccell(dest);
changes.ccell(cwt.at);
if(byWhat == itOrbFrog) {
useupOrb(itOrbFrog, 5);
addMessage(XLAT("You jump!"));
}
if(byWhat == itOrbDash) {
useupOrb(itOrbDash, 5);
2020-02-29 20:05:55 +00:00
if(dashmon) addMessage(XLAT("You vault over %the1!", dashmon));
}
if(byWhat == itOrbPhasing) {
useupOrb(itOrbPhasing, 5);
addMessage(XLAT("You jump!"));
}
movecost(from, dest, 1);
2017-03-23 10:53:57 +00:00
killFriendlyIvy();
2016-08-26 09:58:03 +00:00
cell *c1 = cwt.at;
2019-11-22 17:48:51 +00:00
animateMovement(match(cwt.at, dest), LAYER_SMALL);
cwt.at = dest;
2017-03-23 10:53:57 +00:00
forCellIdEx(c2, i, dest) if(c2->cpdist < dest->cpdist) {
cwt.spin = i;
flipplayer = true;
}
2020-02-29 16:58:59 +00:00
sword::reset();
auto mi = movei(c1, dest, JUMP);
stabbingAttack(mi, moPlayer, bonuskill);
playerMoveEffects(mi);
2020-02-29 18:19:16 +00:00
if(itemclass(byWhat) == IC_ORB)
apply_impact(dest);
// do not apply movecost later, when from no longer exists
if(cwt.at->item == itOrbSafety) {
movecost(from, dest, 2);
from = NULL;
}
2020-02-29 18:19:16 +00:00
if(cwt.at->item != itOrbYendor && cwt.at->item != itHolyGrail) {
auto c = collectItem(cwt.at, true);
if(c) {
return true;
}
}
2017-07-22 23:33:27 +00:00
mirror::destroyAll();
2020-02-29 18:19:16 +00:00
if(monstersnearO(a, dest)) {
2020-02-29 18:19:16 +00:00
changes.rollback();
return false;
}
if(isCheck(a)) {
changes.rollback();
return true;
}
changes.commit();
2016-08-26 09:58:03 +00:00
fix_whichcopy(dest);
2020-02-29 18:19:16 +00:00
countLocalTreasure();
2016-08-26 09:58:03 +00:00
for(int i=9; i>=0; i--)
setdist(cwt.at, i, NULL);
2016-08-26 09:58:03 +00:00
if(from) movecost(from, dest, 2);
2016-08-26 09:58:03 +00:00
createNoise(1);
if(shmup::on)
shmup::teleported();
else
monstersTurn();
2020-02-29 16:58:59 +00:00
return true;
2016-08-26 09:58:03 +00:00
}
void growIvyTo(const movei& mi) {
auto& dest = mi.t;
2017-03-23 10:53:57 +00:00
if(dest->monst)
attackMonster(dest, AF_NORMAL | AF_MSG, moFriendlyIvy);
2017-03-23 10:53:57 +00:00
else {
dest->monst = moFriendlyIvy;
dest->mondir = mi.rev_dir_or(NODIR);
animateMovement(mi, LAYER_BIG);
moveEffect(mi, moFriendlyIvy);
empathyMove(mi);
2017-03-23 10:53:57 +00:00
}
createNoise(1);
monstersTurn();
}
pair<int, bool> spacedrain(cell *c) {
int d = c->cpdist;
bool usemagnet = items[itOrbMagnetism] && d > 0;
if(usemagnet) d--;
return {d * d, usemagnet};
}
2016-08-26 09:58:03 +00:00
void telekinesis(cell *dest) {
auto cost = spacedrain(dest);
2016-08-26 09:58:03 +00:00
if(dest->land == laAlchemist && isAlchAny(dest) && isAlchAny(cwt.at))
dest->wall = cwt.at->wall;
2016-08-26 09:58:03 +00:00
if(dest->land == laPower && cwt.at->land != laPower && dest->item != itOrbFire && dest->item != itOrbLife) {
2016-08-26 09:58:03 +00:00
if(itemclass(dest->item) != IC_ORB)
items[dest->item] ++;
else
items[dest->item] += 2;
addMessage(XLAT("The Orb loses its power as it leaves the Land of Power!"));
dest->item = itNone;
}
if(dest->wall == waGlass) {
2017-03-23 10:53:57 +00:00
drainOrb(itOrbSpace);
2016-08-26 09:58:03 +00:00
addMessage(XLAT("Your power is drained by %the1!", dest->wall));
}
moveItem(dest, cwt.at, true);
collectItem(cwt.at, true);
useupOrb(itOrbSpace, cost.first);
if(cost.second)
markOrb(itOrbMagnetism);
2016-08-26 09:58:03 +00:00
createNoise(3);
checkSwitch();
2016-08-26 09:58:03 +00:00
bfs();
2017-03-23 10:53:57 +00:00
if(!shmup::on) checkmoveO();
2016-08-26 09:58:03 +00:00
}
2019-08-09 19:00:52 +00:00
EX eMonster summonedAt(cell *dest) {
2016-08-26 09:58:03 +00:00
if(dest->monst) return moNone;
if(dest->wall == waVineHalfA || dest->wall == waVineHalfB || dest->wall == waVinePlant)
return moVineSpirit;
if(dest->wall == waCTree)
return moParrot;
if(dest->wall == waLake)
return moGreaterShark;
if(dest->wall == waAncientGrave || dest->wall == waFreshGrave)
return moGhost;
if(dest->wall == waClosePlate || dest->wall == waOpenPlate)
2017-03-23 10:53:57 +00:00
return dest->land == laPalace ? moPalace : moBat;
2016-08-26 09:58:03 +00:00
if(dest->wall == waFloorA || dest->wall == waFloorB)
return moSlime;
if(dest->wall == waCavefloor)
return moTroll;
if(dest->wall == waDeadfloor)
return moEarthElemental;
if(dest->wall == waDeadfloor2)
return moMiner;
if(dest->wall == waMineOpen || dest->wall == waMineMine || dest->wall == waMineUnknown)
return moBomberbird;
2021-05-27 11:00:20 +00:00
if(dest->wall == waRichDie)
return moAnimatedDie;
2021-05-29 13:45:37 +00:00
if(dest->wall == waHappyDie)
return moAngryDie;
2016-08-26 09:58:03 +00:00
if(dest->wall == waTrapdoor)
return dest->land == laPalace ? moFatGuard : moOrangeDog;
2020-02-29 03:07:17 +00:00
if(dest->land == laFrog && dest->wall == waNone) {
forCellEx(c1, dest) if(c1->wall == waShrub) return moVaulter;
forCellEx(c1, dest) if(c1->wall == waDeepWater) return moFrog;
forCellEx(c1, dest) if(c1->wall == waStone) return moPhaser;
}
2016-08-26 09:58:03 +00:00
if(dest->wall == waSea)
return
isElemental(dest->land) ? moWaterElemental :
dest->land == laLivefjord ? moViking :
2017-03-23 10:53:57 +00:00
dest->land == laKraken ? moViking :
dest->land == laWarpCoast ? moRatling :
dest->land == laDocks ? moWaterElemental :
2016-08-26 09:58:03 +00:00
moPirate;
2017-03-23 10:53:57 +00:00
if(isReptile(dest->wall))
return moReptile;
2016-08-26 09:58:03 +00:00
if(dest->wall == waChasm)
return moAirElemental;
2017-10-08 12:02:03 +00:00
if(isFire(dest) || dest->wall == waMagma)
2016-08-26 09:58:03 +00:00
return moFireElemental;
if(dest->wall == waCavewall || dest->wall == waDeadwall)
return moSeep;
if(dest->wall == waRed1 || dest->wall == waRed2 || dest->wall == waRed3)
return moRedTroll;
if(dest->wall == waFrozenLake)
return moFireElemental;
if(dest->wall == waCIsland || dest->wall == waCIsland2)
return moWaterElemental;
if(dest->wall == waRubble || dest->wall == waGargoyleFloor || dest->wall == waGargoyleBridge || dest->wall == waLadder)
return moGargoyle;
if(dest->wall == waStrandedBoat)
return moWaterElemental;
if(dest->wall == waBoat)
return moAirElemental;
if(dest->wall == waStone || dest->wall == waRuinWall)
2016-08-26 09:58:03 +00:00
return moEarthElemental;
if(dest->wall == waGiantRug)
return moVizier;
if(dest->wall == waNone) {
2017-10-10 12:24:39 +00:00
if(dest->land == laHunting) return moAirElemental;
2017-03-23 10:53:57 +00:00
if(dest->land == laBull) return moRagingBull;
if(dest->land == laPrairie) return moAirElemental;
if(dest->land == laZebra) return moAirElemental;
if(dest->land == laMirror) return moAirElemental;
if(dest->land == laMountain) return moAirElemental; // unfortunately Ivies are too large
if(dest->land == laDungeon) return moBat;
2016-08-26 09:58:03 +00:00
if(dest->land == laIce) return moFireElemental;
if(dest->land == laDesert) return moEarthElemental;
if(dest->land == laJungle) return moWaterElemental;
if(dest->land == laGraveyard) return moZombie;
if(dest->land == laRlyeh || dest->land == laTemple) return moPyroCultist;
if(dest->land == laHell) return moWaterElemental;
if(dest->land == laPower) return moWitchFire;
if(dest->land == laWineyard) return moVineBeast;
if(dest->land == laEmerald) return moMiner;
if(dest->land == laHive) return dest->type == 7 ? moBug1 : moBug0;
if(dest->land == laRedRock) return moRedTroll;
if(dest->land == laOcean) return moEarthElemental;
if(dest->land == laDryForest) return moFireFairy;
if(dest->land == laLivefjord) return moFjordTroll;
if(dest->land == laStorms) return moStormTroll;
if(dest->land == laOvergrown) return moForestTroll;
if(dest->land == laIvoryTower) return moAirElemental;
if(dest->land == laEndorian) return moAirElemental;
if(dest->land == laEAir) return moAirElemental;
if(dest->land == laEWater) return moWaterElemental;
if(dest->land == laEEarth) return moEarthElemental;
if(dest->land == laEFire) return moFireElemental;
if(dest->land == laMotion) return moRunDog;
if(dest->land == laWildWest) return moOutlaw;
if(dest->land == laClearing) return moForestTroll;
if(dest->land == laWhirlwind) return moAirElemental;
2017-03-23 10:53:57 +00:00
if(dest->land == laWarpCoast) return moRatling;
2016-08-26 09:58:03 +00:00
if(dest->land == laRose) return moRoseLady;
if(dest->land == laDragon) return moFireElemental;
if(dest->land == laTortoise) return moTortoise;
2017-03-23 10:53:57 +00:00
if(dest->land == laBurial) return moEarthElemental;
2017-10-08 12:02:03 +00:00
if(dest->land == laVolcano) return moFireElemental;
if(dest->land == laBlizzard) return moAirElemental;
if(dest->land == laTerracotta) return moEarthElemental;
if(dest->land == laRuins) return moEarthElemental;
if(dest->land == laSwitch) return passive_switch;
if(dest->land == laSnakeNest) return moEarthElemental;
if(dest->land == laBrownian) return moAcidBird;
if(dest->land == laVariant) return moFireElemental;
if(dest->land == laWestWall) return moAirElemental;
2016-08-26 09:58:03 +00:00
if(isHaunted(dest->land)) return moGhost;
}
return moNone;
}
void summonAt(cell *dest) {
2017-03-23 10:53:57 +00:00
playSound(dest, "orb-ranged");
2016-08-26 09:58:03 +00:00
dest->monst = summonedAt(dest);
dest->stuntime = 3;
if(dest->monst == moPirate || dest->monst == moViking || (dest->monst == moRatling && dest->wall == waSea))
2017-03-23 10:53:57 +00:00
dest->wall = waBoat, dest->item = itNone;
2021-05-27 11:00:20 +00:00
if(dest->monst == moAnimatedDie)
dest->wall = waNone;
2021-05-29 13:45:37 +00:00
if(dest->monst == moAngryDie)
dest->wall = waNone;
2017-03-23 10:53:57 +00:00
if(dest->monst == moViking && dest->land == laKraken)
dest->item = itOrbFish;
2016-08-26 09:58:03 +00:00
if(dest->wall == waStrandedBoat)
dest->wall = waBoat;
else if(dest->monst == moWaterElemental)
placeWater(dest, dest);
if(dest->wall == waStone)
dest->wall = waNone;
if(dest->monst == moFireElemental && isFire(dest))
dest->wall = waNone;
if(dest->monst == moTortoise)
tortoise::emap[dest] = getBits(dest), dest->hitpoints = 3;
2016-08-26 09:58:03 +00:00
addMessage(XLAT("You summon %the1!", dest->monst));
moveEffect(movei(dest, FALL), dest->monst);
if(dest->wall == waClosePlate || dest->wall == waOpenPlate)
toggleGates(dest, dest->wall);
2016-08-26 09:58:03 +00:00
if(hasHitpoints(dest->monst))
dest->hitpoints = palaceHP();
useupOrb(itOrbSummon, 20);
createNoise(2);
bfs();
2017-03-23 10:53:57 +00:00
checkmoveO();
2016-08-26 09:58:03 +00:00
}
bool tempWallPossibleAt(cell *dest) {
if(dest->land == laWestWall) return false;
2016-08-26 09:58:03 +00:00
if(dest->monst || (dest->item && !itemHidden(dest))) return false;
return dest->wall == waChasm || isWatery(dest) || dest->wall == waNone ||
dest->wall == waTempBridge;
2016-08-26 09:58:03 +00:00
}
void tempWallAt(cell *dest) {
if(dest->wall == waChasm)
dest->wall = waTempFloor;
else if(dest->wall == waNone)
dest->wall = waTempWall;
else if(dest->wall == waTempBridge) {
dest->wall = waTempBridgeBlocked;
return;
}
2016-08-26 09:58:03 +00:00
else if(isWatery(dest))
dest->wall = waTempBridge;
int len = (items[itOrbMatter]+1) / 2;
dest->wparam = len;
useupOrb(itOrbMatter, len);
dest->item = itNone; // underwater items are destroyed by this
createNoise(2);
bfs();
2017-03-23 10:53:57 +00:00
checkmoveO();
2016-08-26 09:58:03 +00:00
}
void psi_attack(cell *dest) {
2017-03-23 10:53:57 +00:00
playSound(dest, "other-mind");
2016-08-26 09:58:03 +00:00
if(isNonliving(dest->monst))
addMessage(XLAT("You destroy %the1 with a mental blast!", dest->monst));
2017-03-23 10:53:57 +00:00
else if(isDragon(dest->monst) || isKraken(dest->monst))
2016-08-26 09:58:03 +00:00
addMessage(XLAT("You damage %the1 with a mental blast!", dest->monst));
else
addMessage(XLAT("You kill %the1 with a mental blast!", dest->monst));
2017-03-23 10:53:57 +00:00
// note: psi attack works with Petrify!
attackMonster(dest, AF_PSI, moPlayer);
2016-08-26 09:58:03 +00:00
useupOrb(itOrbPsi, 30);
createNoise(2);
bfs();
2017-03-23 10:53:57 +00:00
checkmoveO();
2016-08-26 09:58:03 +00:00
}
2020-03-11 09:27:33 +00:00
bool gun_attack(orbAction a, cell *dest) {
2017-03-23 10:53:57 +00:00
playSound(dest, "orb-ranged");
2016-08-26 09:58:03 +00:00
addMessage(XLAT("You shoot %the1!", dest->monst));
2020-03-11 09:27:33 +00:00
changes.ccell(dest);
2017-03-23 10:53:57 +00:00
attackMonster(dest, AF_GUN, moNone);
2020-03-11 09:27:33 +00:00
apply_impact(dest);
if(monstersnearO(a, cwt.at)) {
2020-03-11 09:27:33 +00:00
changes.rollback();
return false;
}
if(isCheck(a)) {
changes.rollback();
return true;
}
changes.commit();
2016-08-26 09:58:03 +00:00
items[itRevolver] --;
bfs();
2017-03-23 10:53:57 +00:00
checkmoveO();
2016-08-26 09:58:03 +00:00
createNoise(5);
monstersTurn();
2020-03-11 09:27:33 +00:00
return true;
2016-08-26 09:58:03 +00:00
}
2019-08-09 19:00:52 +00:00
EX void checkStunKill(cell *dest) {
2016-08-26 09:58:03 +00:00
if(isBird(dest->monst)) {
moveEffect(movei(dest, FALL), moDeadBird);
2017-03-23 10:53:57 +00:00
doesFall(dest);
if(isWatery(dest) || dest->wall == waChasm || isFire(dest)) {
addMessage(XLAT("%The1 falls!", dest->monst));
fallMonster(dest);
return;
}
2016-08-26 09:58:03 +00:00
}
2017-03-23 10:53:57 +00:00
/* if(!isPermanentFlying(dest->monst) && cellEdgeUnstable(dest)) {
addMessage(XLAT("%The1 falls!", dest->monst));
fallMonster(dest);
} */
}
void stun_attack(cell *dest) {
playSound(dest, "orb-ranged");
addMessage(XLAT("You stun %the1!", dest->monst));
dest->stuntime += 5;
checkStunKill(dest);
2016-08-26 09:58:03 +00:00
useupOrb(itOrbStunning, 10);
createNoise(3);
bfs();
2017-03-23 10:53:57 +00:00
checkmoveO();
2016-08-26 09:58:03 +00:00
}
2017-10-10 12:18:11 +00:00
void poly_attack(cell *dest) {
playSound(dest, "orb-ranged");
eMonster orig = dest->monst;
2017-10-10 12:18:11 +00:00
auto polymonsters = {
moYeti, moRunDog, moRanger,
moMonkey, moCultist,
moFallingDog, moVariantWarrior, moFamiliar, moOrangeDog,
2017-10-10 12:18:11 +00:00
moRedFox, moFalsePrincess, moResearcher,
moNarciss,
2017-10-10 12:18:11 +00:00
};
int ssf = 0;
2018-06-22 12:47:24 +00:00
eMonster target = *(polymonsters.begin() + hrand(isize(polymonsters)));
2017-10-10 12:18:11 +00:00
for(eMonster m: polymonsters)
if(kills[m] && m != dest->monst) {
ssf += kills[m];
if(hrand(ssf) < kills[m])
target = m;
}
addMessage(XLAT("You polymorph %the1 into %the2!", dest->monst, target));
dest->monst = target;
if(!dest->stuntime) dest->stuntime = 1;
if(orig == moPair) {
cell *dest2 = dest->move(dest->mondir);
if(dest2->monst == moPair) {
dest2->monst = dest->monst;
if(!dest2->stuntime) dest2->stuntime = 1;
}
}
2017-10-10 12:18:11 +00:00
checkStunKill(dest);
useupOrb(itOrbMorph, 3);
2017-10-10 12:18:11 +00:00
createNoise(3);
bfs();
checkmoveO();
}
2016-08-26 09:58:03 +00:00
void placeIllusion(cell *c) {
c->monst = moIllusion;
useupOrb(itOrbIllusion, 5);
addMessage(XLAT("You create an Illusion!"));
bfs();
2017-03-23 10:53:57 +00:00
checkmoveO();
2016-08-26 09:58:03 +00:00
}
void blowoff(const movei& mi) {
auto& cf = mi.s;
auto& ct = mi.t;
2021-05-27 13:56:28 +00:00
bool die = cf->wall == waRichDie;
2017-03-23 10:53:57 +00:00
playSound(ct, "orb-ranged");
if(cf->monst)
2016-08-26 09:58:03 +00:00
addMessage(XLAT("You blow %the1 away!", cf->monst));
if(cf->wall == waThumperOff) activateActiv(cf, false);
if(isPushable(cf->wall) || cf->wall == waBigStatue)
pushThumper(mi);
else if(isBoat(cf) && !cf->monst) {
bool was_stranded = cf->wall == waStrandedBoat;
bool willbe_stranded = ct->wall == waNone;
if(was_stranded) cf->wall = waBoat;
if(willbe_stranded) become_water(ct);
moveBoat(mi);
if(was_stranded) cf->wall = waNone;
if(willbe_stranded) ct->wall = waStrandedBoat;
}
else
pushMonster(mi);
if(cf->item == itBabyTortoise) {
if(ct->item) ct->item = itNone;
2017-03-23 10:53:57 +00:00
moveItem(cf, ct, true);
}
2021-06-09 02:33:55 +00:00
#if CAP_COMPLEX2
2021-05-27 13:56:28 +00:00
if(ct->monst == moAnimatedDie && dice::data[ct].happy() > 0) {
ct->monst = moNone;
2021-05-27 14:38:20 +00:00
ct->wall = waHappyDie;
2021-05-27 13:56:28 +00:00
if(ct->land == laDice && cf->land == laDice) {
cf->item = itDice;
addMessage(XLAT("The die is now happy, and you are rewarded!"));
}
}
2021-05-27 14:38:20 +00:00
if(die && ct->wall == waHappyDie) {
2021-05-27 13:56:28 +00:00
/* pushMonster already awarded us -- place the reward on cf instead */
cf->item = itDice;
items[itDice]--;
}
2021-05-29 13:45:37 +00:00
if(ct->wall == waHappyDie && dice::data[ct].happy() <= 0) {
ct->monst = moAngryDie;
ct->wall = waNone;
ct->stuntime = 5;
addMessage(XLAT("You have made a Happy Die angry!"));
}
2021-06-09 02:33:55 +00:00
#endif
2016-08-26 09:58:03 +00:00
items[itOrbAir]--;
createNoise(2);
bfs();
2017-03-23 10:53:57 +00:00
checkmoveO();
2016-08-26 09:58:03 +00:00
}
void useOrbOfDragon(cell *c) {
makeflame(c, 20, false);
2017-03-23 10:53:57 +00:00
playSound(c, "fire");
2016-08-26 09:58:03 +00:00
addMessage(XLAT("You throw fire!"));
useupOrb(itOrbDragon, 5);
createNoise(3);
bfs();
2017-03-23 10:53:57 +00:00
checkmoveO();
2016-08-26 09:58:03 +00:00
}
EX bool monstersnearO(orbAction a, cell *c) {
2017-03-23 10:53:57 +00:00
// printf("[a = %d] ", a);
if(shmup::on) return false;
2017-03-23 10:53:57 +00:00
if(a == roCheck && multi::players > 1)
return true;
else if(a == roMultiCheck) return false;
else return monstersnear(c, moPlayer);
}
2019-08-09 19:00:52 +00:00
EX bool isCheck(orbAction a) { return a == roCheck || a == roMultiCheck; }
EX bool isWeakCheck(orbAction a) { return a == roCheck || a == roMultiCheck || a == roMouse; }
2017-03-23 10:53:57 +00:00
EX movei blowoff_destination(cell *c, int& di) {
int d = 0;
for(; d<c->type; d++) if(c->move(d) && c->move(d)->cpdist < c->cpdist) break;
if(d<c->type) for(int e=d; e<d+c->type; e++) {
int di = e % c->type;
cell *c2 = c->move(di);
2021-06-09 02:33:55 +00:00
#if CAP_COMPLEX2
if(dice::on(c) && !dice::can_roll(movei(c, di)))
2021-05-29 13:45:37 +00:00
continue;
2021-06-09 02:33:55 +00:00
#endif
if(c2 && c2->cpdist > c->cpdist && passable(c2, c, P_BLOW)) return movei(c, c2, di);
}
return movei(c, c, NO_SPACE);
}
EX int check_jump(cell *cf, cell *ct, flagtype flags, cell*& jumpthru) {
int partial = 1;
forCellCM(c2, cf) {
if(isNeighbor(c2, ct)) {
jumpthru = c2;
if(passable(c2, cf, flags | P_JUMP1)) {
partial = 2;
if(passable(ct, c2, flags | P_JUMP2)) {
return 3;
}
}
}
}
return partial;
}
EX int check_phase(cell *cf, cell *ct, flagtype flags, cell*& jumpthru) {
int partial = 1;
forCellCM(c2, cf) {
if(isNeighbor(c2, ct) && !nonAdjacent(cf, c2) && !nonAdjacent(c2, ct)) {
jumpthru = c2;
if(passable(ct, cf, flags | P_PHASE)) {
partial = 2;
if(c2->monst || (isWall(c2) && c2->wall != waShrub)) {
return 3;
}
}
}
}
return partial;
}
EX cell *common_neighbor(cell *cf, cell *ct) {
forCellCM(cc, cf) {
if(isNeighbor(cc, ct)) return cc;
}
return nullptr;
}
EX void apply_impact(cell *c) {
if(markOrb(itOrbImpact))
forCellEx(c1, c) {
if(!c1->monst) continue;
2021-07-10 05:50:17 +00:00
if(c1->monst == moMimic) continue;
if(isMultitile(c1->monst)) continue;
addMessage(XLAT("You stun %the1!", c1->monst));
2020-03-07 22:52:25 +00:00
changes.ccell(c1);
c1->stuntime = min(c1->stuntime + 5, 7);
checkStunKill(c1);
}
}
EX int check_vault(cell *cf, cell *ct, flagtype flags, cell*& jumpthru) {
cell *c2 = NULL, *c3 = NULL;
forCellCM(cc, cf) {
if(isNeighbor(cc, ct)) c3 = c2, c2 = cc;
}
jumpthru = c2;
if(!c2) return 0;
bool cutwall = among(c2->wall, waShrub, waExplosiveBarrel, waSmallTree, waBigTree);
if(!c2->monst && !cutwall) return 1;
bool for_monster = !(flags & P_ISPLAYER);
2020-02-29 19:45:01 +00:00
if(for_monster && c2->monst && frog_power(c2->monst) && !items[itOrbDiscord]) return 1;
if(c3) return 2;
if(!cutwall && !passable(c2, cwt.at, flags | P_JUMP1 | P_MONSTER)) return 3;
if(!passable(ct, c2, flags | P_JUMP2)) return 4;
if(!cutwall && !canAttack(cwt.at, moPlayer, c2, c2->monst, 0)) return 5;
return 6;
}
2019-08-09 19:00:52 +00:00
EX eItem targetRangedOrb(cell *c, orbAction a) {
2016-08-26 09:58:03 +00:00
2017-03-23 10:53:57 +00:00
if(!haveRangedOrb()) {
return itNone;
}
2016-08-26 09:58:03 +00:00
if(rosedist(cwt.at) == 1) {
int r = rosemap[cwt.at];
2016-08-26 09:58:03 +00:00
int r2 = rosemap[c];
if(r2 <= r && !markOrb(itOrbBeauty)) {
2016-08-26 09:58:03 +00:00
if(a == roKeyboard || a == roMouseForce )
addMessage(XLAT("Those roses smell too nicely. You can only target cells closer to them!"));
return itNone;
}
}
// (-2) shmup variants
eItem shmupEffect = shmup::targetRangedOrb(a);
if(shmupEffect) return shmupEffect;
// (-1) distance
if(c == cwt.at || isNeighbor(cwt.at, c)) {
2017-03-23 10:53:57 +00:00
if(!isWeakCheck(a))
2016-08-26 09:58:03 +00:00
addMessage(XLAT("You cannot target that close!"));
return itNone;
}
if(c->cpdist > 7) {
2017-03-23 10:53:57 +00:00
if(!isWeakCheck(a))
2016-08-26 09:58:03 +00:00
addMessage(XLAT("You cannot target that far away!"));
return itNone;
}
// (0-) strong wind
2020-02-29 16:58:59 +00:00
if(items[itStrongWind] && c->cpdist == 2 && cwt.at == whirlwind::jumpFromWhereTo(c, true)) {
2020-02-29 18:19:16 +00:00
changes.init(isCheck(a));
2020-02-29 16:58:59 +00:00
if(jumpTo(a, c, itStrongWind)) return itStrongWind;
2016-08-26 09:58:03 +00:00
}
// (0x) control
2017-03-23 10:53:57 +00:00
if(haveMount() && items[itOrbDomination] && dragon::whichturn != turncount) {
if(!isCheck(a)) {
2016-08-26 09:58:03 +00:00
dragon::target = c;
dragon::whichturn = turncount;
2017-03-23 10:53:57 +00:00
addMessage(XLAT("Commanded %the1!", haveMount()));
checkmoveO();
2016-08-26 09:58:03 +00:00
}
return itOrbDomination;
}
// (0) telekinesis
if(c->item && !itemHiddenFromSight(c) && !cwt.at->item && items[itOrbSpace] >= fixpower(spacedrain(c).first) && !cantGetGrimoire(c, !isCheck(a))
2017-03-23 10:53:57 +00:00
&& c->item != itBarrow) {
if(!isCheck(a)) {
bool saf = c->item == itOrbSafety;
telekinesis(c);
if(!saf) apply_impact(c);
}
2017-03-23 10:53:57 +00:00
return itOrbSpace;
2016-08-26 09:58:03 +00:00
}
// (0') air blow
bool nowhereToBlow = false;
if(items[itOrbAir] && (isBlowableMonster(c->monst) || isPushable(c->wall) || c->wall == waBigStatue || isBoat(c))) {
int di = NODIR;
movei mi = blowoff_destination(c, di);
auto& c2 = mi.t;
if(!mi.op()) nowhereToBlow = true;
else if(isBoat(c) && !isWatery(c2) && c2->wall != waNone) nowhereToBlow = true;
2020-09-15 18:01:30 +00:00
else if(c->wall == waBigStatue && !canPushStatueOn(c2, P_BLOW)) nowhereToBlow = true;
else {
if(!isCheck(a)) blowoff(mi), apply_impact(c);
return itOrbAir;
2016-08-26 09:58:03 +00:00
}
}
2017-03-23 10:53:57 +00:00
// nature
if(items[itOrbNature] && numplayers() == 1 && c->monst != moFriendlyIvy) {
2020-01-18 15:03:32 +00:00
vector<int> dirs;
forCellIdCM(cf, d, c)
2017-03-23 10:53:57 +00:00
if(cf->monst == moFriendlyIvy) {
if(c->monst) {
if(!canAttack(cf, moFriendlyIvy, c, c->monst, 0)) continue;
if(monstersnear(cwt.at, moPlayer)) continue;
2017-03-23 10:53:57 +00:00
}
else {
if(!passable(c, cf, P_ISPLAYER | P_MONSTER)) continue;
if(strictlyAgainstGravity(c, cf, false, MF_IVY)) continue;
if(monstersnear(cwt.at, moPlayer)) continue;
2017-03-23 10:53:57 +00:00
}
2020-01-18 15:03:32 +00:00
dirs.push_back(d);
2017-03-23 10:53:57 +00:00
}
2020-01-18 15:03:32 +00:00
int di = hrand_elt(dirs, -1);
if(di != -1) {
if(!isCheck(a)) growIvyTo(movei(c, di).rev()), apply_impact(c);
2017-03-23 10:53:57 +00:00
return itOrbNature;
}
}
2016-08-26 09:58:03 +00:00
// (0'') jump
int jumpstate = 0;
cell *jumpthru = NULL;
2017-03-23 10:53:57 +00:00
// orb of vaulting
if(!shmup::on && items[itOrbDash] && c->cpdist == 2) {
int i = items[itOrbAether];
if(i) items[itOrbAether] = i-1;
jumpstate = 10 + check_vault(cwt.at, c, P_ISPLAYER, jumpthru);
2017-03-23 10:53:57 +00:00
items[itOrbAether] = i;
2020-02-29 20:05:55 +00:00
if(jumpstate == 16) {
2020-02-29 18:19:16 +00:00
changes.init(isCheck(a));
2020-02-29 16:58:59 +00:00
int k = tkills();
eMonster m = jumpthru->monst;
if(jumpthru->wall == waShrub) {
addMessage(XLAT("You chop down the shrub."));
jumpthru->wall = waNone;
2017-03-23 10:53:57 +00:00
}
if(jumpthru->wall == waSmallTree) {
addMessage(XLAT("You chop down the tree."));
jumpthru->wall = waNone;
}
if(jumpthru->wall == waBigTree) {
addMessage(XLAT("You start chopping down the tree."));
jumpthru->wall = waSmallTree;
}
if(jumpthru->wall == waExplosiveBarrel) {
explodeBarrel(jumpthru);
}
2020-02-29 16:58:59 +00:00
if(m)
attackMonster(jumpthru, AF_NORMAL | AF_MSG, moPlayer);
k = tkills() - k;
2020-02-29 20:05:55 +00:00
if(jumpTo(a, c, itOrbDash, k, m)) jumpstate = 17;
if(jumpstate == 17) return itOrbDash;
2017-03-23 10:53:57 +00:00
}
}
2016-08-26 09:58:03 +00:00
if(items[itOrbFrog] && c->cpdist == 2) {
2017-03-23 10:53:57 +00:00
int i = items[itOrbAether];
if(i) items[itOrbAether] = i-1;
jumpstate = check_jump(cwt.at, c, P_ISPLAYER, jumpthru);
2017-03-23 10:53:57 +00:00
items[itOrbAether] = i;
2020-02-29 16:58:59 +00:00
if(jumpstate == 3) {
2020-02-29 18:19:16 +00:00
changes.init(isCheck(a));
2020-02-29 16:58:59 +00:00
if(jumpTo(a, c, itOrbFrog)) jumpstate = 4;
if(jumpstate == 4) return itOrbFrog;
2016-08-26 09:58:03 +00:00
}
}
if(items[itOrbPhasing] && c->cpdist == 2) {
if(shmup::on) shmup::pushmonsters();
int i = items[itOrbAether];
if(i) items[itOrbAether] = i-1;
jumpstate = 20 + check_phase(cwt.at, c, P_ISPLAYER, jumpthru);
items[itOrbAether] = i;
2020-02-29 16:58:59 +00:00
if(jumpstate == 23) {
2020-02-29 18:19:16 +00:00
changes.init(isCheck(a));
2020-02-29 16:58:59 +00:00
if(jumpTo(a, c, itOrbPhasing)) jumpstate = 24;
}
if(shmup::on) shmup::popmonsters();
if(jumpstate == 24) return itOrbPhasing;
}
2016-08-26 09:58:03 +00:00
// (1) switch with an illusion
if(items[itOrbTeleport] && c->monst == moIllusion && !cwt.at->monst && teleportAction() == 1) {
if(!isCheck(a)) teleportTo(c), apply_impact(c);
2016-08-26 09:58:03 +00:00
return itOrbTeleport;
}
// (2) place illusion
if(!shmup::on && items[itOrbIllusion] && c->monst == moNone && c->item == itNone && passable(c, NULL, P_MIRROR)) {
if(!isCheck(a)) placeIllusion(c), apply_impact(c);
2016-08-26 09:58:03 +00:00
return itOrbIllusion;
}
// (3) teleport
if(items[itOrbTeleport] && c->monst == moNone && (c->item == itNone || itemHidden(c)) &&
2017-03-23 10:53:57 +00:00
passable(c, NULL, P_ISPLAYER | P_TELE) && teleportAction() && shmup::verifyTeleport()) {
if(!isCheck(a)) teleportTo(c), apply_impact(c);
2016-08-26 09:58:03 +00:00
return itOrbTeleport;
}
// (4) remove an illusion
if(!shmup::on && items[itOrbIllusion] && c->monst == moIllusion) {
2017-03-23 10:53:57 +00:00
if(!isCheck(a)) {
2016-08-26 09:58:03 +00:00
addMessage(XLAT("You take the Illusion away."));
items[itOrbIllusion] += 3; // 100% effective with the Orb of Energy!
apply_impact(c);
2016-08-26 09:58:03 +00:00
c->monst = moNone;
}
return itOrbIllusion;
}
// (4a) colt
if(!shmup::on && items[itRevolver] && c->monst && canAttack(cwt.at, moPlayer, c, c->monst, AF_GUN)) {
bool inrange = false;
for(cell *c1: gun_targets(cwt.at)) if(c1 == c) inrange = true;
2020-02-29 16:58:59 +00:00
if(inrange) {
2020-02-29 18:19:16 +00:00
changes.init(isCheck(a));
2020-03-11 09:27:33 +00:00
if(gun_attack(a, c)) return itRevolver;
}
}
2016-08-26 09:58:03 +00:00
// (5) psi blast (non-shmup variant)
2017-03-23 10:53:57 +00:00
if(!shmup::on && items[itOrbPsi] && c->monst && (isDragon(c->monst) || !isWorm(c)) && c->monst != moShadow && c->monst != moKrakenH) {
if(!isCheck(a)) psi_attack(c), apply_impact(c);
2016-08-26 09:58:03 +00:00
return itOrbPsi;
}
// (5a) summoning
if(items[itOrbSummon] && summonedAt(c)) {
if(!isCheck(a)) summonAt(c), apply_impact(c);
2016-08-26 09:58:03 +00:00
return itOrbSummon;
}
// (5b) matter
if(items[itOrbMatter] && tempWallPossibleAt(c)) {
if(!isCheck(a)) tempWallAt(c), apply_impact(c);
2016-08-26 09:58:03 +00:00
return itOrbMatter;
}
// (5c) stun
2021-07-10 05:50:17 +00:00
if(items[itOrbStunning] && c->monst && !isMultitile(c->monst) && c->monst != moMimic && c->stuntime < 3 && !shmup::on) {
if(!isCheck(a)) stun_attack(c), apply_impact(c);
2016-08-26 09:58:03 +00:00
return itOrbStunning;
}
2017-10-10 12:18:11 +00:00
// (5d) poly
if(items[itOrbMorph] && c->monst && !isMultitile(c->monst) && !shmup::on) {
if(!isCheck(a)) poly_attack(c), apply_impact(c);
2017-10-10 12:18:11 +00:00
return itOrbMorph;
}
2016-08-26 09:58:03 +00:00
// (6) place fire (non-shmup variant)
if(!shmup::on && items[itOrbDragon] && makeflame(c, 20, true)) {
if(!isCheck(a)) useOrbOfDragon(c), apply_impact(c);
2016-08-26 09:58:03 +00:00
return itOrbDragon;
}
2017-03-23 10:53:57 +00:00
if(isWeakCheck(a)) return itNone;
2016-08-26 09:58:03 +00:00
if(nowhereToBlow && isBlowableMonster(c->monst)) {
2016-08-26 09:58:03 +00:00
addMessage(XLAT("Nowhere to blow %the1!", c->monst));
}
else if(nowhereToBlow) {
addMessage(XLAT("Nowhere to blow %the1!", c->wall));
}
2016-08-26 09:58:03 +00:00
else if(jumpstate == 1 && jumpthru && jumpthru->monst) {
addMessage(XLAT("Cannot jump through %the1!", jumpthru->monst));
}
else if(jumpstate == 1 && jumpthru) {
addMessage(XLAT("Cannot jump through %the1!", jumpthru->wall));
}
else if(jumpstate == 2 && c->monst) {
addMessage(XLAT("Cannot jump on %the1!", c->monst));
}
else if(jumpstate == 2 && c->wall) {
addMessage(XLAT("Cannot jump on %the1!", c->wall));
}
else if(jumpstate == 3)
wouldkill("%The1 would get you there!");
2016-08-26 09:58:03 +00:00
else if(items[itOrbAir] && c->monst) {
addMessage(XLAT("%The1 is immune to wind!", c->monst));
}
else if(items[itOrbPsi] && c->monst) {
addMessage(XLAT("%The1 is immune to mental blasts!", c->monst));
}
else if(items[itOrbTeleport] && c->monst) {
addMessage(XLAT("Cannot teleport on a monster!"));
}
2017-03-23 10:53:57 +00:00
else if(items[itOrbSpace] && c->item == itBarrow)
addMessage(XLAT("%The1 is protected from this kind of magic!", c->item));
else if(items[itOrbSpace] && saved_tortoise_on(c))
addMessage(XLAT("No, that would be heartless!"));
2017-03-23 10:53:57 +00:00
else if(c->item && items[itOrbSpace] && !itemHiddenFromSight(c)) {
if(cwt.at->item)
2017-03-23 10:53:57 +00:00
addMessage(XLAT("Cannot use %the1 here!", itOrbSpace));
2016-08-26 09:58:03 +00:00
addMessage(XLAT("Not enough power for telekinesis!"));
}
else if(items[itOrbIllusion] && c->item)
addMessage(XLAT("Cannot cast illusion on an item!"));
else if(items[itOrbIllusion] && c->monst)
addMessage(XLAT("Cannot cast illusion on a monster!"));
else if(items[itOrbIllusion] && !passable(c, NULL, P_MIRROR))
addMessage(XLAT("Cannot cast illusion here!"));
2017-03-23 10:53:57 +00:00
else if(items[itOrbTeleport] && teleportAction() == 0) {
addMessage(XLAT("All players are in the game!"));
}
2016-08-26 09:58:03 +00:00
else if(items[itOrbTeleport] && !passable(c, NULL, P_TELE | P_ISPLAYER)) {
addMessage(XLAT("Cannot teleport here!"));
}
else if(items[itOrbMatter] && !tempWallPossibleAt(c)) {
if(c->monst)
addMessage(XLAT("Cannot create temporary matter on a monster!"));
else if(c->item)
addMessage(XLAT("Cannot create temporary matter on an item!"));
else addMessage(XLAT("Cannot create temporary matter here!"));
}
else if(items[itOrbSummon] && !summonedAt(c)) {
if(c->monst)
addMessage(XLAT("Cannot summon on a monster!"));
else
addMessage(XLAT("No summoning possible here!"));
}
else if(items[itOrbTeleport] && c->item) {
addMessage(XLAT("Cannot teleport on an item!"));
}
else if(items[itOrbDragon] && !makeflame(c, 20, true)) {
addMessage(XLAT("Cannot throw fire there!"));
}
else return eItem(0);
return eItem(-1);
}
2019-08-09 19:00:52 +00:00
EX int orbcharges(eItem it) {
2017-07-16 21:00:55 +00:00
switch(it) {
case itRevolver: //pickup-key
return 6 - items[itRevolver];
2017-07-16 21:00:55 +00:00
case itOrbShield:
return inv::on ? 30 : 20;
case itOrbDiscord:
return inv::on ? 46 : 23;
case itOrbLove:
case itOrbUndeath:
case itOrbSpeed: //"pickup-speed");
case itOrbInvis:
case itOrbAether:
return 30;
case itOrbGravity:
return 45;
case itOrbChoice:
return 60;
2018-12-25 18:27:19 +00:00
case itOrbIntensity:
2019-11-27 23:14:22 +00:00
return inv::on ? 150 : 50;
2017-07-16 21:00:55 +00:00
case itOrbWinter: // "pickup-winter"
return inv::on ? 45 : 30;
case itOrbBeauty:
case itOrbEmpathy:
case itOrbFreedom:
return 40;
case itOrbFrog:
case itOrbDash:
2017-12-30 23:08:55 +00:00
case itOrbPhasing:
2021-05-21 23:57:22 +00:00
case itOrbWoods:
2017-07-16 21:00:55 +00:00
return 45;
case itOrb37:
case itOrbEnergy:
return 50;
case itOrbRecall:
case itOrbNature:
case itOrbStone:
case itOrbStunning:
case itOrbLuck:
return 60;
case itOrbWater:
case itOrbMatter:
case itOrbHorns:
case itOrbBull:
case itOrbShell:
2017-08-13 19:11:40 +00:00
case itOrbAir:
case itOrbSlaying:
2017-07-16 21:00:55 +00:00
return 66;
case itOrbTime:
case itOrbSpace:
case itOrbThorns:
case itOrbLightning:
case itOrbFlash:
case itOrbIllusion:
case itOrbPsi:
case itOrbDigging:
case itOrbTeleport:
2017-12-30 23:08:55 +00:00
case itOrbMagnetism:
2017-07-16 21:00:55 +00:00
return 77;
case itOrbDomination:
return 90;
case itOrbSummon:
return 120;
case itOrbSword:
return 60 + 30 * multi::activePlayers();
case itOrbSword2:
return 40 + 20 * multi::activePlayers();
case itOrbFish:
return 20 + 10 * multi::activePlayers();
case itOrbFire:
return sphere ? 3 : 30;
case itOrbDragon:
return sphere ? 10 : 77;
case itOrbMorph:
return 60;
case itOrbLava:
return 50;
case itOrbSide1:
case itOrbSide2:
case itOrbSide3:
return 50;
case itOrbImpact:
return 50;
2020-02-26 00:18:31 +00:00
case itOrbChaos:
return 60;
2020-02-26 01:49:35 +00:00
case itOrbPlague:
return 30;
2021-05-02 11:39:09 +00:00
case itOrbPurity:
return 15;
case itCurseWeakness:
return 20;
case itCurseDraining:
return 30;
2021-05-02 11:39:09 +00:00
case itCurseWater:
return 20;
case itCurseFatigue:
return 30;
case itCurseRepulsion:
return 30;
case itCurseGluttony:
return 30;
2020-02-26 00:45:08 +00:00
2017-07-16 21:00:55 +00:00
default:
return 0;
}
}
2019-08-09 19:00:52 +00:00
EX bool isShmupLifeOrb(eItem it) {
2017-07-16 21:00:55 +00:00
return
it == itOrbLife || it == itOrbFriend ||
it == itOrbNature || it == itOrbEmpathy ||
it == itOrbUndeath || it == itOrbLove ||
it == itOrbDomination || it == itOrbGravity;
2017-07-16 21:00:55 +00:00
}
2017-10-08 09:12:03 +00:00
2019-08-09 19:00:52 +00:00
EX void makelava(cell *c, int i) {
2017-10-08 09:12:03 +00:00
if(!pseudohept(c)) return;
if(isPlayerOn(c)) return;
if(c->wall == waFire && c->wparam < i)
c->wparam = i, orbused[itOrbLava] = true;
else if(makeflame(c, i, false)) orbused[itOrbLava] = true;
2017-10-08 09:12:03 +00:00
}
2019-08-09 20:07:03 +00:00
EX void orboflava(int i) {
2017-10-08 09:12:03 +00:00
if(items[itOrbLava])
for(cell *c: dcal) {
if(c->cpdist > 5) break;
if(!c->monst || isFriendly(c) || survivesFire(c->monst)) continue;
forCellEx(c2, c) makelava(c2, i);
}
}
}