2015-08-08 13:57:52 +00:00
|
|
|
// Hyperbolic Rogue
|
2016-08-26 09:58:03 +00:00
|
|
|
// main game routines: movement etc.
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// Copyright (C) 2011-2016 Zeno Rogue, see 'hyper.cpp' for details
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int lastsafety;
|
2016-08-26 09:58:03 +00:00
|
|
|
int mutantphase;
|
|
|
|
int turncount;
|
|
|
|
int rosewave, rosephase;
|
2017-07-22 23:33:27 +00:00
|
|
|
int avengers, mirrorspirits;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *lastmove;
|
|
|
|
enum eLastmovetype {lmSkip, lmMove, lmAttack, lmSpecial, lmPush, lmTree};
|
|
|
|
eLastmovetype lastmovetype;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int sval = 100000000;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool hauntedWarning;
|
|
|
|
bool survivalist;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
bool hardcore = false;
|
|
|
|
int hardcoreAt;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
flagtype havewhat, hadwhat;
|
|
|
|
|
|
|
|
#define HF_BUG (1<<0)
|
|
|
|
#define HF_EARTH (1<<1)
|
|
|
|
#define HF_BIRD (1<<2)
|
|
|
|
#define HF_LEADER (1<<3)
|
|
|
|
#define HF_HEX (1<<4)
|
|
|
|
#define HF_WHIRLPOOL (1<<5)
|
|
|
|
#define HF_WATER (1<<6)
|
|
|
|
#define HF_AIR (1<<7)
|
|
|
|
#define HF_MUTANT (1<<8)
|
|
|
|
#define HF_OUTLAW (1<<9)
|
|
|
|
#define HF_WHIRLWIND (1<<10)
|
|
|
|
#define HF_ROSE (1<<11)
|
|
|
|
#define HF_DRAGON (1<<12)
|
|
|
|
#define HF_KRAKEN (1<<13)
|
|
|
|
#define HF_SHARK (1<<14)
|
|
|
|
#define HF_BATS (1<<15)
|
|
|
|
#define HF_REPTILE (1<<16)
|
|
|
|
#define HF_EAGLES (1<<17)
|
|
|
|
#define HF_SLOW (1<<18)
|
|
|
|
#define HF_FAST (1<<19)
|
|
|
|
#define HF_WARP (1<<20)
|
|
|
|
#define HF_MOUSE (1<<21)
|
|
|
|
#define HF_RIVER (1<<22)
|
2017-07-22 23:33:27 +00:00
|
|
|
#define HF_MIRROR (1<<23)
|
2016-01-02 10:09:13 +00:00
|
|
|
|
|
|
|
bool seenSevenMines = false;
|
|
|
|
|
|
|
|
bool pureHardcore() { return hardcore && hardcoreAt < PUREHARDCORE_LEVEL; }
|
|
|
|
|
|
|
|
bool canmove = true;
|
|
|
|
|
2015-08-08 13:57:52 +00:00
|
|
|
int sagephase = 0;
|
|
|
|
|
|
|
|
// number of Grails collected, to show you as a knight
|
|
|
|
int knighted = 0;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool usedSafety = false;
|
|
|
|
eLand safetyland;
|
|
|
|
int safetyseed;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int showid = 0;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
|
|
|
bool invismove = false, invisfish = false; // last move was invisible [due to Fish]
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int noiseuntil; // noise until the given turn
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void createNoise(int t) {
|
|
|
|
noiseuntil = max(noiseuntil, turncount+t);
|
|
|
|
invismove = false;
|
|
|
|
if(shmup::on) shmup::visibleFor(100 * t);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int currentLocalTreasure;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool landvisited[landtypes];
|
2015-08-08 13:57:52 +00:00
|
|
|
|
|
|
|
extern void DEBT(const char *buf);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
#define DEBT(x) DEBB(DF_TURN, (debugfile,"%s\n", x))
|
2015-08-08 13:57:52 +00:00
|
|
|
|
|
|
|
bool eq(short a, short b) { return a==b; }
|
|
|
|
|
|
|
|
// game state
|
2017-08-17 23:40:07 +00:00
|
|
|
int items[ittypes], kills[motypes], explore[10], exploreland[10][landtypes], landcount[landtypes];
|
|
|
|
map<modecode_t, array<int, ittypes> > hiitems;
|
2016-01-02 10:09:13 +00:00
|
|
|
bool orbused[ittypes], lastorbused[ittypes];
|
2015-08-08 13:57:52 +00:00
|
|
|
bool playermoved = true; // center on the PC?
|
|
|
|
bool flipplayer = true; // flip the player image after move, do not flip after attack
|
|
|
|
int cheater = 0; // did the player cheat?
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int anthraxBonus = 0; // for using Safety in tactical Camelot
|
2015-08-08 13:57:52 +00:00
|
|
|
|
|
|
|
vector<cell*> dcal; // queue for cpdist
|
|
|
|
vector<cell*> pathq; // queue for pathdist
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
vector<cell*> offscreen; // offscreen cells to take care off
|
|
|
|
|
2015-08-08 13:57:52 +00:00
|
|
|
vector<cell*> pathqm; // list of monsters to move (pathq restriced to monsters)
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2015-08-08 13:57:52 +00:00
|
|
|
vector<cell*> targets; // list of monster targets
|
|
|
|
|
|
|
|
// monsters of specific types to move
|
2017-07-22 23:33:27 +00:00
|
|
|
vector<cell*> worms, ivies, ghosts, golems, hexsnakes;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
|
|
|
vector<cell*> temps; // temporary changes during bfs
|
|
|
|
vector<eMonster> tempval; // restore temps
|
|
|
|
|
|
|
|
// a bit nicer way of DFS
|
|
|
|
vector<int> reachedfrom;
|
|
|
|
|
|
|
|
// additional direction information for BFS algorithms
|
|
|
|
// it remembers from where we have got to this location
|
|
|
|
// the opposite cell will be added to the queue first,
|
|
|
|
// which helps the AI
|
|
|
|
vector<cell*> movesofgood[8];
|
|
|
|
|
|
|
|
int first7; // the position of the first monster at distance 7 in dcal
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
cellwalker cwt; // single player character position
|
|
|
|
|
|
|
|
inline cell*& singlepos() { return cwt.c; }
|
|
|
|
inline bool singleused() { return !(shmup::on || multi::players > 1); }
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-07-16 21:00:55 +00:00
|
|
|
#include <random>
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-07-16 21:00:55 +00:00
|
|
|
mt19937 r;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
|
|
|
void shrand(int i) {
|
|
|
|
r.seed(i);
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int hrandpos() { return r() & HRANDMAX; }
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
int hrand(int i) {
|
|
|
|
return r() % i;
|
|
|
|
}
|
|
|
|
|
2015-08-08 13:57:52 +00:00
|
|
|
void initcell(cell *c) {
|
|
|
|
c->mpdist = INFD; // minimum distance from the player, ever
|
|
|
|
c->cpdist = INFD; // current distance from the player
|
2017-03-23 10:53:57 +00:00
|
|
|
c->pathdist = PINFD;// current distance from the player, along paths (used by yetis)
|
2016-08-26 09:58:03 +00:00
|
|
|
c->landparam = 0; c->landflags = 0; c->wparam = 0;
|
|
|
|
c->aitmp = 0;
|
2015-08-08 13:57:52 +00:00
|
|
|
c->wall = waNone;
|
|
|
|
c->item = itNone;
|
|
|
|
c->monst = moNone;
|
|
|
|
c->bardir = NODIR;
|
2016-08-26 09:58:03 +00:00
|
|
|
c->mondir = NODIR;
|
|
|
|
c->barleft = c->barright = laNone;
|
2015-08-08 13:57:52 +00:00
|
|
|
c->land = laNone;
|
|
|
|
c->ligon = 0;
|
2016-01-02 10:09:13 +00:00
|
|
|
c->stuntime = 0;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool doesnotFall(cell *c) {
|
|
|
|
if(c->wall == waChasm) return false;
|
|
|
|
else if(cellUnstable(c)) {
|
|
|
|
fallingFloorAnimation(c);
|
|
|
|
c->wall = waChasm;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool doesFall(cell *c) { return !doesnotFall(c); }
|
|
|
|
|
|
|
|
bool doesFallSound(cell *c) {
|
|
|
|
if(c->land != laMotion && c->land != laZebra)
|
|
|
|
playSound(c, "trapdoor");
|
|
|
|
return !doesnotFall(c);
|
|
|
|
}
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
bool itemHidden(cell *c) {
|
2017-03-23 10:53:57 +00:00
|
|
|
return isWatery(c) && !(shmup::on && shmup::boatAt(c));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool playerInWater() {
|
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
if(multi::playerActive(i) && isWatery(playerpos(i)) && !playerInBoat(i))
|
|
|
|
return true;
|
|
|
|
return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool itemHiddenFromSight(cell *c) {
|
2017-03-23 10:53:57 +00:00
|
|
|
return isWatery(c) && !items[itOrbInvis] && !(items[itOrbFish] && playerInWater())
|
|
|
|
&& !(shmup::on && shmup::boatAt(c));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int numplayers() {
|
2017-03-23 10:53:57 +00:00
|
|
|
return multi::players;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cell *playerpos(int i) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(shmup::on) return shmup::playerpos(i);
|
|
|
|
if(multi::players > 1) return multi::player[i].c;
|
|
|
|
return singlepos();
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool allPlayersInBoats() {
|
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
if(multi::playerActive(i) && playerpos(i)->wall != waBoat) return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int whichPlayerOn(cell *c) {
|
|
|
|
if(singleused()) return c == singlepos() ? 0 : -1;
|
2016-01-02 10:09:13 +00:00
|
|
|
for(int i=0; i<numplayers(); i++)
|
2017-03-23 10:53:57 +00:00
|
|
|
if(playerpos(i) == c) return i;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPlayerOn(cell *c) {
|
|
|
|
return whichPlayerOn(c) >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPlayerInBoatOn(cell *c, int i) {
|
|
|
|
return
|
|
|
|
(playerpos(i) == c && (
|
|
|
|
c->wall == waBoat || c->wall == waStrandedBoat || (shmup::on && shmup::playerInBoat(i))
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool playerInBoat(int i) {
|
|
|
|
return isPlayerInBoatOn(playerpos(i), i);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPlayerInBoatOn(cell *c) {
|
|
|
|
for(int i=0; i<numplayers(); i++) if(isPlayerInBoatOn(c, i)) return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
void destroyBoats(cell *c, cell *c2, bool strandedToo) {
|
|
|
|
if(c->wall == waBoat) placeWater(c, c2);
|
|
|
|
if(strandedToo && c->wall == waStrandedBoat) c->wall = waNone;
|
|
|
|
shmup::destroyBoats(c);
|
|
|
|
}
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
bool playerInPower() {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(singleused())
|
|
|
|
return singlepos()->land == laPower || singlepos()->land == laHalloween;
|
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
if(multi::playerActive(i) && (playerpos(i)->land == laPower || playerpos(i)->land == laHalloween))
|
|
|
|
return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-08 13:57:52 +00:00
|
|
|
eItem localTreasureType() {
|
2017-03-23 10:53:57 +00:00
|
|
|
lastland = singlepos()->land;
|
2015-08-08 13:57:52 +00:00
|
|
|
return treasureType(lastland);
|
|
|
|
}
|
|
|
|
|
|
|
|
void countLocalTreasure() {
|
|
|
|
eItem i = localTreasureType();
|
|
|
|
currentLocalTreasure = i ? items[i] : 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(i != itHyperstone) for(int i=0; i<size(dcal); i++) {
|
|
|
|
cell *c2 = dcal[i];
|
|
|
|
if(c2->cpdist > 3) break;
|
|
|
|
eItem i2 = treasureType(c2->land);
|
|
|
|
if(i2 && items[i2] < currentLocalTreasure)
|
|
|
|
currentLocalTreasure = items[i2];
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 16:03:53 +00:00
|
|
|
int gold(int no) {
|
|
|
|
int i = 0;
|
|
|
|
if(!(no & NO_YENDOR)) i += items[itOrbYendor] * 50;
|
|
|
|
if(!(no & NO_GRAIL)) i += items[itHolyGrail] * 10;
|
|
|
|
if(!(no & NO_LOVE)) {
|
|
|
|
bool love = items[itOrbLove];
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_INV
|
2017-07-12 16:03:53 +00:00
|
|
|
if(inv::on && inv::remaining[itOrbLove])
|
|
|
|
love = true;
|
|
|
|
#endif
|
|
|
|
if(love) i += 30;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(no & NO_TREASURE))
|
|
|
|
for(int t=0; t<ittypes; t++)
|
|
|
|
if(itemclass(eItem(t)) == IC_TREASURE)
|
|
|
|
i += items[t];
|
|
|
|
return i;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int maxgold() {
|
|
|
|
int mg = 0;
|
|
|
|
for(int i=0; i<ittypes; i++)
|
|
|
|
if(itemclass(eItem(i)) == IC_TREASURE && items[i] > mg)
|
|
|
|
mg = items[i];
|
|
|
|
return mg;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int* killtable[] = {
|
|
|
|
&kills[moYeti], &kills[moWolf], &
|
|
|
|
kills[moRanger], &kills[moTroll], &kills[moGoblin], &
|
|
|
|
kills[moWorm], &kills[moDesertman], &kills[moIvyRoot], &
|
|
|
|
kills[moMonkey], &kills[moEagle], &kills[moSlime], &kills[moSeep], &
|
|
|
|
kills[moRunDog], &
|
|
|
|
kills[moCultist], &kills[moTentacle], &kills[moPyroCultist], &
|
|
|
|
kills[moLesser], &kills[moGreater], &
|
|
|
|
kills[moZombie], &kills[moGhost], &kills[moNecromancer], &
|
|
|
|
kills[moHedge], &kills[moFireFairy], &
|
|
|
|
kills[moCrystalSage], &kills[moShark], &kills[moGreaterShark], &
|
|
|
|
kills[moMiner], &kills[moFlailer], &kills[moLancer], &
|
|
|
|
kills[moVineSpirit], &kills[moVineBeast], &
|
|
|
|
kills[moBug0], &kills[moBug1], &kills[moBug2], &
|
|
|
|
kills[moDarkTroll], &kills[moEarthElemental], &
|
|
|
|
kills[moWitch], &kills[moEvilGolem], &kills[moWitchFlash], &kills[moWitchFire], &
|
|
|
|
kills[moWitchWinter], &kills[moWitchSpeed], &
|
|
|
|
kills[moCultistLeader], &
|
|
|
|
kills[moPirate], &kills[moCShark], &kills[moParrot], &
|
|
|
|
kills[moHexSnake], &kills[moRedTroll], &
|
|
|
|
kills[moPalace], &kills[moSkeleton], &kills[moFatGuard], &kills[moVizier], &
|
|
|
|
kills[moViking], &kills[moFjordTroll], &kills[moWaterElemental], &
|
|
|
|
kills[moAlbatross], &kills[moBomberbird], &
|
|
|
|
kills[moAirElemental], &kills[moFireElemental], &
|
2017-03-23 10:53:57 +00:00
|
|
|
kills[moGargoyle], &kills[moFamiliar], &kills[moOrangeDog], &
|
2016-08-26 09:58:03 +00:00
|
|
|
items[itMutant], &kills[moMetalBeast], &kills[moMetalBeast2], &
|
|
|
|
kills[moOutlaw], &kills[moForestTroll], &kills[moStormTroll], &
|
|
|
|
kills[moRedFox], &kills[moWindCrow], &
|
|
|
|
kills[moFalsePrincess], &kills[moRoseLady], &
|
|
|
|
kills[moRoseBeauty], &
|
|
|
|
kills[moRatling], &kills[moRatlingAvenger], &
|
|
|
|
kills[moDragonHead], &
|
2017-03-23 10:53:57 +00:00
|
|
|
kills[moGadfly], &kills[moSparrowhawk], &kills[moResearcher],
|
|
|
|
&kills[moKrakenH], &kills[moDraugr],
|
|
|
|
&kills[moBat], &kills[moReptile],
|
|
|
|
&kills[moHerdBull], &kills[moSleepBull], &kills[moRagingBull],
|
|
|
|
&kills[moGadfly], &kills[moButterfly],
|
2017-07-25 01:02:54 +00:00
|
|
|
&kills[moNarciss], &kills[moMirrorSpirit],
|
2016-08-26 09:58:03 +00:00
|
|
|
NULL
|
|
|
|
};
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int tkills() {
|
|
|
|
int res = 0;
|
|
|
|
for(int i=0; killtable[i]; i++) res += killtable[i][0];
|
|
|
|
return res;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int killtypes() {
|
|
|
|
int res = 0;
|
|
|
|
for(int i=0; killtable[i]; i++) if(killtable[i][0]) res++;
|
|
|
|
return res;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool isWarped(cell *c) {
|
|
|
|
return isWarped(c->land) || (items[itOrb37] && c->cpdist <= 4);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// returns ishept in the normal tiling;
|
|
|
|
// in the 'pure heptagonal' tiling, returns true for a set of cells
|
|
|
|
// which roughly corresponds to the heptagons in the normal tiling
|
|
|
|
bool pseudohept(cell *c) {
|
|
|
|
if(purehepta) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(sphere)
|
|
|
|
return
|
2017-04-04 09:13:15 +00:00
|
|
|
c->master == getDodecahedron(3) ||
|
|
|
|
c->master == getDodecahedron(5) ||
|
|
|
|
c->master == getDodecahedron(6);
|
2016-08-26 09:58:03 +00:00
|
|
|
int z = zebra40(c);
|
|
|
|
return z == 5 || z == 8 || z == 15;
|
|
|
|
}
|
|
|
|
else return ishept(c);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool nonAdjacent(cell *c, cell *c2) {
|
|
|
|
if(isWarped(c) && isWarped(c2) && !pseudohept(c) && !pseudohept(c2)) {
|
|
|
|
/* int i = neighborId(c, c2);
|
|
|
|
cell *c3 = c->mov[(i+1)%6], *c4 = c->mov[(i+5)%6];
|
|
|
|
if(c3 && !isTrihepta(c3)) return false;
|
|
|
|
if(c4 && !isTrihepta(c4)) return false; */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool nonAdjacentPlayer(cell *c, cell *c2) {
|
|
|
|
return nonAdjacent(c, c2) && !markOrb(itOrb37);
|
|
|
|
}
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
bool thruVine(cell *c, cell *c2) {
|
2016-08-26 09:58:03 +00:00
|
|
|
return (cellHalfvine(c) && c2->wall == c->wall && c2 != c);
|
|
|
|
// ((c->wall == waFloorC || c->wall == waFloorD) && c2->wall == c->wall && !c2->item && !c->item);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// === MOVEMENT FUNCTIONS ===
|
|
|
|
|
|
|
|
// w = from->mov[d]
|
|
|
|
bool againstCurrent(cell *w, cell *from) {
|
|
|
|
if(from->land != laWhirlpool) return false;
|
|
|
|
if(againstWind(from, w)) return false; // wind is stronger than current
|
|
|
|
if(!euclid && (!from->master->alt || !w->master->alt)) return false;
|
|
|
|
int dfrom = celldistAlt(from);
|
|
|
|
int dw = celldistAlt(w);
|
|
|
|
if(dw < dfrom) return false;
|
|
|
|
if(dfrom < dw) return true;
|
|
|
|
for(int d=0; d<from->type; d++)
|
|
|
|
if(from->mov[d] == w) {
|
|
|
|
cell *c3 = from->mov[(d+from->type-1) % from->type];
|
|
|
|
if(!c3) return false;
|
|
|
|
return celldistAlt(c3) < dfrom;
|
|
|
|
}
|
|
|
|
return false;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
bool boatGoesThrough(cell *c) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isGravityLand(c->land)) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
return
|
2017-03-23 10:53:57 +00:00
|
|
|
(c->wall == waNone && c->land != laMotion && c->land != laZebra && c->land != laReptile) ||
|
2016-08-26 09:58:03 +00:00
|
|
|
isAlchAny(c) ||
|
2017-03-23 10:53:57 +00:00
|
|
|
c->wall == waCavefloor || c->wall == waFrozenLake || isReptile(c->wall) ||
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall == waDeadfloor || c->wall == waCIsland || c->wall == waCIsland2 ||
|
|
|
|
c->wall == waMineUnknown || c->wall == waMineMine || c->wall == waMineOpen ||
|
|
|
|
c->wall == waBonfireOff || c->wall == waFire || c->wall == waPartialFire;
|
|
|
|
}
|
|
|
|
|
|
|
|
void placeWater(cell *c, cell *c2) {
|
|
|
|
if(isWatery(c)) ;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2 && isAlchAny(c2))
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall = c2->wall;
|
|
|
|
else if(isIcyLand(c))
|
|
|
|
c->wall = waLake;
|
|
|
|
else
|
|
|
|
c->wall = waSea;
|
2017-03-23 10:53:57 +00:00
|
|
|
// destroy the ancient treasure!
|
|
|
|
if(c->item == itBarrow) c->item = itNone;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
int incline(cell *cfrom, cell *cto) {
|
|
|
|
return snakelevel(cto) - snakelevel(cfrom);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
#define F(x) checkflags(flags,x)
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool checkflags(flagtype flags, int x) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(flags & x) return true;
|
|
|
|
if(flags & P_ISPLAYER) {
|
|
|
|
if((x & P_WINTER) && markOrb(itOrbWinter)) return true;
|
|
|
|
if((x & P_IGNORE37) && markOrb(itOrb37)) return true;
|
|
|
|
if((x & P_FISH) && markOrb(itOrbFish)) return true;
|
|
|
|
if((x & P_MARKWATER) && markOrb(itOrbWater)) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
if((x & P_AETHER) && markOrb2(itOrbAether) && !(flags&P_NOAETHER)) return true;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
if(flags & P_ISFRIEND) if(items[itOrbEmpathy])
|
|
|
|
if(checkflags(flags ^ P_ISPLAYER ^ P_ISFRIEND, x) && markOrb(itOrbEmpathy))
|
|
|
|
return true;
|
|
|
|
return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool strictlyAgainstGravity(cell *w, cell *from, bool revdir, flagtype flags) {
|
|
|
|
return
|
|
|
|
cellEdgeUnstable(w, flags) && cellEdgeUnstable(from, flags) &&
|
|
|
|
!(shmup::on && from == w) && gravityLevel(w) != gravityLevel(from) + (revdir?1:-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool passable(cell *w, cell *from, flagtype flags) {
|
2016-08-26 09:58:03 +00:00
|
|
|
bool revdir = (flags&P_REVDIR);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(from && from != w && nonAdjacent(from, w) && !F(P_IGNORE37 | P_BULLET)) return false;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<numplayers(); i++) {
|
|
|
|
cell *pp = playerpos(i);
|
|
|
|
if(!pp) continue;
|
|
|
|
if(w == pp && F(P_ONPLAYER)) return true;
|
|
|
|
if(from == pp && F(P_ONPLAYER) && F(P_REVDIR)) return true;
|
|
|
|
|
|
|
|
if(from && !((flags & P_ISPLAYER) && getMount(i))) {
|
|
|
|
int i = revdir ? incline(w, from) : incline(from, w);
|
|
|
|
if(i < -1 && F(P_ROSE)) return false;
|
|
|
|
if((i > 1) && !F(P_JUMP1 | P_JUMP2 | P_BULLET | P_FLYING | P_BLOW | P_CLIMBUP | P_AETHER | P_REPTILE))
|
|
|
|
return false;
|
|
|
|
if((i < -2) && !F(P_DEADLY | P_JUMP1 | P_JUMP2 | P_BULLET | P_FLYING | P_BLOW | P_CLIMBDOWN | P_AETHER | P_REPTILE))
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(F(P_ROSE)) {
|
|
|
|
if(airdist(w) < 3) return false;
|
|
|
|
if(againstWind(w,from)) return false;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(from && strictlyAgainstGravity(w, from, revdir, flags)
|
|
|
|
&& !F(P_GRAVITY | P_BLOW | P_JUMP1 | P_JUMP2 | P_FLYING | P_BULLET | P_AETHER)
|
|
|
|
) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(from && (revdir ? againstWind(from,w) : againstWind(w, from)) && !F(P_WIND | P_BLOW | P_JUMP1 | P_JUMP2 | P_BULLET | P_AETHER)) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(revdir && from && w->monst && passable(from, w, flags &~ (P_REVDIR|P_MONSTER)))
|
2016-01-02 10:09:13 +00:00
|
|
|
return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(!shmup::on && sword::at(w, flags & P_ISPLAYER) && !F(P_DEADLY | P_BULLET | P_ROSE))
|
|
|
|
return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool alch1 = w->wall == waFloorA && from && from->wall == waFloorB && !w->item && !from->item;
|
|
|
|
alch1 |= w->wall == waFloorB && from && from->wall == waFloorA && !w->item && !from->item;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(alch1) {
|
|
|
|
bool alchok = F(P_JUMP1 | P_JUMP2 | P_FLYING | P_TELE | P_BLOW | P_AETHER | P_BULLET)
|
|
|
|
&& !F(P_ROSE);
|
|
|
|
if(!alchok) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(from && thruVine(from, w) && !F(P_AETHER)) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(w->monst == moMouse && F(P_JUMP1)) ;
|
|
|
|
else if(w->monst && isFriendly(w) && F(P_FRIENDSWAP)) ;
|
|
|
|
else if(w->monst && !F(P_MONSTER)) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(w->wall == waMirror || w->wall == waCloud)
|
|
|
|
return F(P_MIRROR | P_AETHER);
|
|
|
|
|
2017-07-16 21:00:55 +00:00
|
|
|
if(w->wall == waMirrorWall)
|
|
|
|
return F(P_MIRRORWALL);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(F(P_BULLET)) {
|
|
|
|
if(isFire(w) || w->wall == waBonfireOff || cellHalfvine(w) ||
|
|
|
|
w->wall == waAncientGrave || w->wall == waFreshGrave || w->wall == waRoundTable)
|
|
|
|
return true;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(F(P_LEADER)) {
|
|
|
|
if(from && from->wall == waBoat && isWateryOrBoat(w) && !againstCurrent(w, from))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if(from && isWatery(from) && w->wall == waBoat && F(P_CHAIN))
|
|
|
|
return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(from && isWatery(from) && isWatery(w) && F(P_CHAIN) && !againstCurrent(w, from))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if(w->wall == waBigStatue && from && canPushStatueOn(from)) return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(F(P_EARTHELEM)) {
|
|
|
|
// cannot go through Living Caves...
|
|
|
|
if(w->wall == waCavefloor) return false;
|
|
|
|
// but can dig through...
|
|
|
|
if(w->wall == waDeadwall || w->wall == waDune || w->wall == waStone)
|
|
|
|
return true;
|
|
|
|
// and can swim through...
|
|
|
|
if(w->wall == waSea && w->land == laLivefjord)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(F(P_WATERELEM)) {
|
|
|
|
if(isWatery(w) || boatGoesThrough(w) ||
|
2017-03-23 10:53:57 +00:00
|
|
|
w->wall == waBoat ||
|
2016-08-26 09:58:03 +00:00
|
|
|
w->wall == waDeadTroll || w->wall == waDeadTroll2) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(isThorny(w->wall) && F(P_BLOW | P_DEADLY)) return true;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isFire(w)) {
|
|
|
|
if(!F(P_AETHER | P_WINTER | P_BLOW | P_JUMP1 | P_BULLET | P_DEADLY)) return false;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(isWatery(w)) {
|
|
|
|
if(from && from->wall == waBoat && F(P_USEBOAT) &&
|
|
|
|
(!againstCurrent(w, from) || F(P_MARKWATER))) ;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(!F(P_AETHER | P_FISH | P_FLYING | P_BLOW | P_JUMP1 | P_BULLET | P_DEADLY | P_REPTILE)) return false;
|
|
|
|
}
|
|
|
|
if(isChasmy(w)) {
|
|
|
|
if(!F(P_AETHER | P_FLYING | P_BLOW | P_JUMP1 | P_BULLET | P_DEADLY | P_REPTILE)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(w->wall == waRoundTable && from && from->wall != waRoundTable && (flags & P_ISPLAYER)) return true;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isNoFlight(w) && F(P_FLYING | P_BLOW | P_JUMP1)) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(isWall(w)) {
|
|
|
|
// a special case: empathic aethereal beings cannot go through Round Table
|
|
|
|
// (but truly aetheral beings can)
|
|
|
|
if(w->wall == waRoundTable) {
|
|
|
|
if(!(flags & P_AETHER)) return false;
|
|
|
|
}
|
|
|
|
else if(!F(P_AETHER)) return false;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int airdir;
|
2016-08-26 09:58:03 +00:00
|
|
|
vector<pair<cell*, int> > airmap;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
|
|
|
int airdist(cell *c) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!(havewhat & HF_AIR)) return 3;
|
2016-08-26 09:58:03 +00:00
|
|
|
vector<pair<cell*, int> >::iterator it =
|
|
|
|
lower_bound(airmap.begin(), airmap.end(), make_pair(c,0));
|
|
|
|
if(it != airmap.end() && it->first == c) return it->second;
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
void calcAirdir(cell *c) {
|
|
|
|
if(!c || c->monst == moAirElemental || !passable(c, NULL, P_BLOW))
|
|
|
|
return;
|
2016-01-02 10:09:13 +00:00
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(c2 && c2->monst == moAirElemental) {
|
2017-03-23 10:53:57 +00:00
|
|
|
airdir = c->spn(i) * S42 / c2->type;
|
2016-08-26 09:58:03 +00:00
|
|
|
return;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(!c2) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!passable(c2, c, P_BLOW | P_MONSTER)) continue;
|
|
|
|
if(!passable(c, c2, P_BLOW | P_MONSTER)) continue;
|
2016-01-02 10:09:13 +00:00
|
|
|
for(int i=0; i<c2->type; i++) {
|
|
|
|
cell *c3 = c2->mov[i];
|
|
|
|
if(c3 && c3->monst == moAirElemental) {
|
2017-03-23 10:53:57 +00:00
|
|
|
airdir = c2->spn(i) * S42 / c3->type;
|
2016-08-26 09:58:03 +00:00
|
|
|
return;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool againstWind(cell *cto, cell *cfrom) {
|
|
|
|
if(!cfrom || !cto) return false;
|
|
|
|
if(airdist(cto) < airdist(cfrom)) return true;
|
|
|
|
whirlwind::calcdirs(cfrom);
|
|
|
|
int d = neighborId(cfrom, cto);
|
|
|
|
if(whirlwind::winddir(d) == -1) return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ghostmove(eMonster m, cell* to, cell* from) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!isGhost(m) && nonAdjacent(to, from)) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(sword::at(to, 0)) return false;
|
|
|
|
if(!shmup::on && isPlayerOn(to)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(to->monst && !(to->monst == moTentacletail && isGhost(m) && m != moFriendlyGhost)
|
|
|
|
&& !(to->monst == moTortoise && isGhost(m) && m != moFriendlyGhost))
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
if((m == moWitchGhost || m == moWitchWinter) && to->land != laPower)
|
|
|
|
return false;
|
|
|
|
if(isGhost(m))
|
2017-07-16 21:00:55 +00:00
|
|
|
for(int i=0; i<to->type; i++) {
|
|
|
|
if(inmirror(to->mov[i])) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(to->mov[i] && to->mov[i] != from && isGhost(to->mov[i]->monst) &&
|
|
|
|
(to->mov[i]->monst == moFriendlyGhost) == (m== moFriendlyGhost))
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
2017-07-16 21:00:55 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isGhost(m) || m == moWitchGhost) return true;
|
|
|
|
if(m == moGreaterShark) return isWatery(to);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moWitchWinter)
|
|
|
|
return passable(to, from, P_WINTER | P_ONPLAYER);
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool slimepassable(cell *w, cell *c) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(w == c || !c) return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
int u = dirfromto(c, w);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(nonAdjacent(w,c)) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isPlayerOn(w)) return true;
|
|
|
|
int group = slimegroup(c);
|
|
|
|
if(!group) return false;
|
|
|
|
int ogroup = slimegroup(w);
|
|
|
|
if(!ogroup) return false;
|
|
|
|
bool hv = (group == ogroup);
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(sword::at(w, 0)) return false;
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
if(w->item) return false;
|
|
|
|
|
|
|
|
// only travel to halfvines correctly
|
|
|
|
if(cellHalfvine(c)) {
|
|
|
|
int i=0;
|
|
|
|
for(int t=0; t<c->type; t++) if(c->mov[t] && c->mov[t]->wall == c->wall) i=t;
|
|
|
|
int z = i-u; if(z<0) z=-z; z%=6;
|
|
|
|
if(z>1) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
hv=(group == ogroup);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
// only travel from halfvines correctly
|
|
|
|
if(cellHalfvine(w)) {
|
|
|
|
int i=0;
|
|
|
|
for(int t=0; t<w->type; t++) if(w->mov[t] && w->mov[t]->wall == w->wall) i=t;
|
2017-03-23 10:53:57 +00:00
|
|
|
int z = i-c->spn(u); if(z<0) z=-z; z%=6;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(z>1) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
hv=(group == ogroup);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
if(!hv) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool sharkpassable(cell *w, cell *c) {
|
|
|
|
if(w == c || !c) return true;
|
|
|
|
if(nonAdjacent(w,c)) return false;
|
|
|
|
if(isPlayerOn(w)) return true;
|
|
|
|
if(!isWatery(w)) return false;
|
|
|
|
if(sword::at(w, 0)) return false;
|
|
|
|
|
|
|
|
// don't go against the current
|
|
|
|
if(isWateryOrBoat(w) && isWateryOrBoat(c))
|
|
|
|
return !againstCurrent(w, c);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
bool canPushStatueOn(cell *c) {
|
2016-08-26 09:58:03 +00:00
|
|
|
return passable(c, NULL, P_MONSTER) && c->wall != waBoat && !snakelevel(c) &&
|
2017-07-04 13:38:33 +00:00
|
|
|
!isWorm(c->monst) && !isReptile(c->wall) && !peace::on;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void moveBoat(cell *to, cell *from) {
|
|
|
|
eWall x = to->wall; to->wall = from->wall; from->wall = x;
|
|
|
|
to->mondir = neighborId(to, from);
|
|
|
|
moveItem(from, to, false);
|
2017-03-23 10:53:57 +00:00
|
|
|
animateMovement(from, to, LAYER_BOAT);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void moveBoatIfUsingOne(cell *to, cell *from) {
|
|
|
|
if(from->wall == waBoat && isWatery(to)) moveBoat(to, from);
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(from->wall == waBoat && boatGoesThrough(to) && markEmpathy(itOrbWater)) {
|
|
|
|
placeWater(to, from);
|
|
|
|
moveBoat(to, from);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool passable_for(eMonster m, cell *w, cell *from, flagtype extra) {
|
|
|
|
if(w->monst && !(extra & P_MONSTER) && !isPlayerOn(w))
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
if(m == moWolf) {
|
2016-08-26 09:58:03 +00:00
|
|
|
return isIcyLand(w) && (isPlayerOn(w) || passable(w, from, extra));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(normalMover(m) || isBug(m) || isDemon(m) || m == moHerdBull) {
|
|
|
|
if((isWitch(m) || m == moEvilGolem) && w->land != laPower && w->land != laHalloween)
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
return passable(w, from, extra);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isShark(m))
|
|
|
|
return sharkpassable(w, from);
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isSlimeMover(m))
|
|
|
|
return slimepassable(w, from);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moKrakenH) {
|
|
|
|
if(extra & P_ONPLAYER) {
|
|
|
|
if(isPlayerOn(w)) return true;
|
|
|
|
}
|
|
|
|
if((extra & P_ONPLAYER) && isPlayerOn(w))
|
|
|
|
return true;
|
|
|
|
if(pseudohept(w) || pseudohept(from)) return false;
|
|
|
|
if(w->wall != waBoat && !slimepassable(w, from)) return false;
|
|
|
|
forCellEx(w2, w) if(w2->wall != waBoat && !passable(w2, w, P_FISH | P_MONSTER)) return false;
|
|
|
|
return true;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
if(m == moEarthElemental)
|
2016-08-26 09:58:03 +00:00
|
|
|
return passable(w, from, extra | P_EARTHELEM);
|
2016-01-02 10:09:13 +00:00
|
|
|
if(m == moWaterElemental)
|
2016-08-26 09:58:03 +00:00
|
|
|
return passable(w, from, extra | P_WATERELEM);
|
2016-01-02 10:09:13 +00:00
|
|
|
if(m == moGreaterShark)
|
|
|
|
return isWatery(w) || w->wall == waBoat || w->wall == waFrozenLake;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isGhostMover(m) || m == moFriendlyGhost)
|
2016-01-02 10:09:13 +00:00
|
|
|
return ghostmove(m, w, from);
|
|
|
|
// for the purpose of Shmup this is correct
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moTameBomberbird)
|
|
|
|
return passable(w, from, extra | P_FLYING | P_ISFRIEND);
|
|
|
|
if(m == moHexSnake)
|
|
|
|
return !pseudohept(w) && passable(w, from, extra|P_WIND|P_FISH);
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isBird(m))
|
2016-08-26 09:58:03 +00:00
|
|
|
return passable(w, from, extra | P_FLYING);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moReptile)
|
|
|
|
return passable(w, from, extra | P_REPTILE);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isDragon(m))
|
|
|
|
return passable(w, from, extra | P_FLYING | P_WINTER);
|
|
|
|
if(m == moAirElemental)
|
|
|
|
return passable(w, from, extra | P_FLYING | P_WIND);
|
|
|
|
if(isLeader(m)) {
|
|
|
|
if(from && from->wall == waBoat && from->item == itCoral && !from->monst) return false; // don't move Corals!
|
|
|
|
return passable(w, from, extra | P_LEADER);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isPrincess(m))
|
2016-08-26 09:58:03 +00:00
|
|
|
return passable(w, from, extra | P_ISFRIEND | P_USEBOAT);
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isGolemOrKnight(m))
|
2016-08-26 09:58:03 +00:00
|
|
|
return passable(w, from, extra | P_ISFRIEND);
|
|
|
|
if(isWorm(m))
|
2017-03-23 10:53:57 +00:00
|
|
|
return passable(w, from, extra) && !cellUnstable(w) && ((m != moWorm && m != moTentacle) || !cellEdgeUnstable(w));
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
eMonster movegroup(eMonster m) {
|
|
|
|
if(isWitch(m) || m == moEvilGolem) {
|
|
|
|
if(m == moWitchGhost) return moWitchGhost;
|
|
|
|
if(m == moWitchWinter) return moWitchWinter;
|
|
|
|
return moWitch;
|
|
|
|
}
|
|
|
|
if(normalMover(m)) return moYeti;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moShark || m == moCShark) return moShark;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isSlimeMover(m)) return moSlime;
|
|
|
|
if(m == moEarthElemental) return moEarthElemental;
|
|
|
|
if(isLeader(m)) return moPirate;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moButterfly) return moButterfly;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isAngryBird(m)) return moEagle;
|
|
|
|
if(isBird(m)) return moTameBomberbird;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moReptile) return moReptile;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(m == moGhost) return moGhost;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moFriendlyGhost) return moFriendlyGhost;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(m == moGreaterShark) return moGreaterShark;
|
|
|
|
if(m == moWolf) return moWolf;
|
|
|
|
if(isDemon(m)) return moLesser;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isDragon(m)) return moDragonHead;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isBug(m)) return m;
|
|
|
|
if(m == moWaterElemental) return moWaterElemental;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moAirElemental) return moAirElemental;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isBull(m)) return moRagingBull;
|
2016-01-02 10:09:13 +00:00
|
|
|
return moNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
void useup(cell *c) {
|
|
|
|
c->wparam--;
|
|
|
|
if(c->wparam == 0) {
|
2017-03-23 10:53:57 +00:00
|
|
|
drawParticles(c, c->wall == waFire ? 0xC00000 : winf[c->wall].color, 10, 50);
|
2016-01-02 10:09:13 +00:00
|
|
|
if(c->wall == waTempFloor)
|
|
|
|
c->wall = waChasm;
|
2017-09-03 10:01:31 +00:00
|
|
|
else if(c->wall == waTempBridge || c->wall == waTempBridgeBlocked)
|
2016-01-02 10:09:13 +00:00
|
|
|
placeWater(c, c);
|
|
|
|
else
|
|
|
|
c->wall = c->land == laCaribbean ? waCIsland2 : waNone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int realstuntime(cell *c) {
|
|
|
|
if(isMutantIvy(c)) return (c->stuntime - mutantphase) & 15;
|
|
|
|
return c->stuntime;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool childbug = false;
|
|
|
|
|
|
|
|
// is w killed if killed is killed?
|
|
|
|
bool isChild(cell *w, cell *killed) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isAnyIvy(w->monst)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int lim = 0;
|
|
|
|
// printf("w = %p mondir = %d **\n", w, w->mondir);
|
|
|
|
while(w != killed && w->mondir != NODIR) {
|
|
|
|
lim++; if(lim == 100000) {
|
|
|
|
childbug = true;
|
|
|
|
printf("childbug!\n");
|
|
|
|
w->item = itBuggy; break;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!isAnyIvy(w->monst)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
w = w->mov[w->mondir];
|
|
|
|
// printf("w = %p mondir = %d\n", w, w->mondir);
|
|
|
|
}
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return w == killed;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool canAttack(cell *c1, eMonster m1, cell *c2, eMonster m2, flagtype flags) {
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// cannot eat worms
|
|
|
|
if((flags & AF_EAT) && isWorm(m2)) return false;
|
|
|
|
|
|
|
|
if((flags & AF_GETPLAYER) && isPlayerOn(c2)) m2 = moPlayer;
|
|
|
|
|
|
|
|
if(!m2) return false;
|
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
if(m2 == moPlayer && peace::on) return false;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if((flags & AF_ONLY_FRIEND) && m2 != moPlayer && !isFriendly(c2)) return false;
|
|
|
|
if((flags & AF_ONLY_FBUG) && m2 != moPlayer && !isFriendlyOrBug(c2)) return false;
|
|
|
|
if((flags & AF_ONLY_ENEMY) && (m2 == moPlayer || isFriendlyOrBug(c2))) return false;
|
|
|
|
|
2017-06-18 16:51:46 +00:00
|
|
|
if(m2 == moHedge && !(flags & (AF_STAB | AF_TOUGH | AF_EAT | AF_MAGIC | AF_LANCE | AF_SWORD_INTO | AF_HORNS | AF_BULL)))
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!checkOrb(m1, itOrbThorns)) return false;
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
// krakens do not try to fight even with Discord
|
|
|
|
if((m1 == moKrakenT || m1 == moKrakenH) &&
|
|
|
|
(m2 == moKrakenT || m2 == moKrakenH))
|
|
|
|
return false;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m2 == moDraugr && !(flags & (AF_SWORD | AF_MAGIC | AF_SWORD_INTO | AF_HORNS))) return false;
|
|
|
|
|
|
|
|
// if(m2 == moHerdBull && !(flags & AF_MAGIC)) return false;
|
|
|
|
if(isBull(m2) && !(flags & (AF_MAGIC | AF_HORNS | AF_SWORD_INTO))) return false;
|
|
|
|
if(m2 == moButterfly && !(flags & (AF_MAGIC | AF_BULL | AF_HORNS | AF_SWORD_INTO))) return false;
|
|
|
|
|
|
|
|
if(!(flags & AF_NOSHIELD) && ((flags & AF_NEXTTURN) ? checkOrb2 : checkOrb)(m2, itOrbShield)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if((flags & AF_STAB) && m2 != moHedge)
|
|
|
|
if(!checkOrb(m1, itOrbThorns)) return false;
|
|
|
|
|
|
|
|
if(flags & AF_BACK) {
|
|
|
|
if(m2 == moFlailer && !c2->stuntime) flags |= AF_IGNORE_UNARMED;
|
|
|
|
else if(m2 == moVizier && !isUnarmed(m1)) ;
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(flags & AF_APPROACH) {
|
|
|
|
if(m2 == moLancer) ;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if((flags & AF_HORNS) && checkOrb(m1, itOrbHorns)) ;
|
2016-08-26 09:58:03 +00:00
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(flags & AF_IGNORE_UNARMED) && isUnarmed(m1)) return false;
|
|
|
|
|
|
|
|
if(m2 == moGreater || m2 == moGreaterM)
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!(flags & (AF_MAGIC | AF_SWORD_INTO | AF_HORNS))) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(!(flags & AF_GUN)) {
|
|
|
|
|
|
|
|
if(c1 && c2 && nonAdjacent(c1,c2) && !attackNonAdjacent(m1) && !attackNonAdjacent(m2) &&
|
2017-03-23 10:53:57 +00:00
|
|
|
!checkOrb(m1, itOrb37) && !checkOrb(m1, itOrbAether) && !checkOrb(m2, itOrbAether))
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if(c1 && c2 && thruVine(c1,c2) && !attackThruVine(m1) && !attackThruVine(m2) &&
|
2017-03-23 10:53:57 +00:00
|
|
|
!checkOrb(m1, itOrbAether) && !checkOrb(m2, itOrbAether))
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if(!(flags & (AF_LANCE | AF_STAB | AF_BACK | AF_APPROACH)))
|
|
|
|
if(c1 && c2 && againstRose(c1, c2) && !ignoresSmell(m1))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m2 == moShadow && !(flags & AF_SWORD)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isWorm(m2) && m2 != moTentacleGhost && !isDragon(m2)) return false;
|
|
|
|
|
|
|
|
// dragon can't attack itself, or player who mounted it
|
|
|
|
if(c1 && c2 && isWorm(c1->monst) && isWorm(c2->monst) && wormhead(c1) == wormhead(c2)
|
2017-03-23 10:53:57 +00:00
|
|
|
&& m1 != moTentacleGhost && m2 != moTentacleGhost)
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// if(m2 == moTortoise && !(flags & AF_MAGIC)) return false;
|
|
|
|
|
|
|
|
if(m2 == moRoseBeauty)
|
2017-06-18 16:51:46 +00:00
|
|
|
if(!(flags & (AF_MAGIC | AF_LANCE | AF_GUN | AF_SWORD_INTO | AF_BULL)))
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!isMimic(m1))
|
|
|
|
if(!checkOrb(m1, itOrbBeauty) && !checkOrb(m1, itOrbAether) && !checkOrb(m1, itOrbShield))
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!c1 || !c2 || !withRose(c1,c2))
|
|
|
|
return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m2 == moFlailer && !c2->stuntime)
|
2017-06-18 16:51:46 +00:00
|
|
|
if(!(flags & (AF_MAGIC | AF_TOUGH | AF_EAT | AF_HORNS | AF_LANCE | AF_BACK | AF_SWORD_INTO | AF_BULL))) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(m2 == moVizier && c2->hitpoints > 1)
|
2017-06-18 16:51:46 +00:00
|
|
|
if(!(flags & (AF_MAGIC | AF_TOUGH | AF_EAT | AF_HORNS | AF_LANCE | AF_BACK | AF_FAST | AF_BULL))) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool stalemate1::isKilled(cell *w) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(w->monst == moNone || w == killed) return true;
|
|
|
|
if(!moveto) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
for(int b=0; b<2; b++)
|
|
|
|
if((w == swordnext[b] || w == swordtransit[b]) && canAttack(moveto, who, w, w->monst, AF_SWORD))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if(isNeighbor(w, moveto) && moveto != comefrom) {
|
|
|
|
int wid = neighborId(moveto, w);
|
|
|
|
int wfrom = neighborId(moveto, comefrom);
|
|
|
|
int flag = AF_APPROACH;
|
|
|
|
if(wid >= 0 && wfrom >= 0 && angledist(moveto, wfrom, wid) >= 3) flag |= AF_HORNS;
|
|
|
|
if(canAttack(moveto, who, w, w->monst, flag)) return true;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isNeighbor(w, comefrom) && isNeighbor(w, moveto) && moveto != comefrom)
|
|
|
|
if(canAttack(moveto, who, w, w->monst, AF_STAB))
|
2016-08-26 09:58:03 +00:00
|
|
|
return true;
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(who == moPlayer && (killed || moveto != comefrom) && mirror::isKilledByMirror(w)) return true;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(w->monst == moIvyHead || w->monst == moIvyBranch || isMutantIvy(w))
|
|
|
|
return isChild(w, killed);
|
|
|
|
|
|
|
|
if(isDragon(w->monst) && killed && isDragon(killed->monst) && killed->hitpoints) {
|
|
|
|
cell *head1 = dragon::findhead(w);
|
|
|
|
cell *head2 = dragon::findhead(killed);
|
|
|
|
if(head1 == head2 && dragon::totalhp(head1) ==1) return true;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(w->monst == moKrakenT && killed && killed->monst == moKrakenT && killed->hitpoints) {
|
|
|
|
cell *head1 = w->mov[w->mondir];
|
|
|
|
cell *head2 = killed->mov[killed->mondir];
|
|
|
|
if(head1 == head2 && kraken::totalhp(head1) == 1) return true;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool stalemate::isKilled(cell *w) {
|
|
|
|
for(int f=0; f<size(moves); f++)
|
|
|
|
if(moves[f].isKilled(w)) return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
bool isNeighbor(cell *c1, cell *c2) {
|
|
|
|
for(int i=0; i<c1->type; i++) if(c1->mov[i] == c2) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool isNeighborCM(cell *c1, cell *c2) {
|
|
|
|
for(int i=0; i<c1->type; i++) if(createMov(c1, i) == c2) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int neighborId(cell *ofWhat, cell *whichOne) {
|
|
|
|
for(int i=0; i<ofWhat->type; i++) if(ofWhat->mov[i] == whichOne) return i;
|
2016-01-02 10:09:13 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// how many monsters are near
|
|
|
|
eMonster which;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool flashWouldKill(cell *c, flagtype extra) {
|
2016-01-02 10:09:13 +00:00
|
|
|
for(int t=0; t<c->type; t++) {
|
|
|
|
cell *c2 = c->mov[t];
|
|
|
|
for(int u=0; u<c2->type; u++) {
|
|
|
|
cell *c3 = c2->mov[u];
|
2015-08-08 13:57:52 +00:00
|
|
|
if(isWorm(c3)) continue; // immune to Flash
|
|
|
|
if(c3->monst == moEvilGolem) continue; // evil golems don't count
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c3 != c && (c3->monst || isPlayerOn(c3)) && !stalemate::isKilled(c3)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
bool b = canAttack(NULL, moWitchFlash, c3, c3->monst, AF_MAGIC | extra);
|
|
|
|
if(b) return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// this is not completely correct, but it works in the Wild West
|
|
|
|
bool outlawNearby(cell *c, int dist) {
|
|
|
|
if(dist == 0) return false;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(!c2) continue;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->monst == moOutlaw && !stalemate::isKilled(c2))
|
2016-08-26 09:58:03 +00:00
|
|
|
return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
if((passable(c2, NULL, 0) || (c2->monst && stalemate::isKilled(c2))) &&
|
2016-08-26 09:58:03 +00:00
|
|
|
outlawNearby(c2, dist-1))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// int monstersnear(cell *c, cell *nocount = NULL, eMonster who = moPlayer, cell *pushto = NULL) {
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
namespace stalemate {
|
|
|
|
bool anyKilled() {
|
|
|
|
for(int i=0; i<size(moves); i++) if(moves[i].killed) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isMoveto(cell *c) {
|
|
|
|
for(int i=0; i<size(moves); i++) if(moves[i].moveto == c) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isKilledDirectlyAt(cell *c) {
|
|
|
|
for(int i=0; i<size(moves); i++) if(moves[i].killed == c) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPushto(cell *c) {
|
|
|
|
for(int i=0; i<size(moves); i++) if(moves[i].pushto == c) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool onboat(stalemate1& sm) {
|
|
|
|
cell *c = sm.moveto;
|
|
|
|
cell *cf = sm.comefrom;
|
|
|
|
return (c->wall == waBoat) || (cf->wall == waBoat && c->wall == waSea);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool krakensafe(cell *c) {
|
|
|
|
return items[itOrbFish] || items[itOrbAether] ||
|
|
|
|
(c->item == itOrbFish && c->wall == waBoat) ||
|
|
|
|
(c->item == itOrbAether && c->wall == waBoat);
|
|
|
|
}
|
|
|
|
|
|
|
|
int monstersnear(stalemate1& sm) {
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
cell *c = sm.moveto;
|
2016-08-26 09:58:03 +00:00
|
|
|
bool eaten = false;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(hardcore && sm.who == moPlayer) return 0;
|
2015-08-08 13:57:52 +00:00
|
|
|
int res = 0;
|
|
|
|
bool fast = false;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
elec::builder b;
|
|
|
|
if(elec::affected(c)) { which = moLightningBolt; res++; }
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(sm.who == moPlayer || items[itOrbEmpathy]) {
|
|
|
|
fast = (items[itOrbSpeed] && (items[itOrbSpeed] & 1));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat&HF_OUTLAW)
|
2016-08-26 09:58:03 +00:00
|
|
|
if(outlawNearby(c, 3)) {
|
|
|
|
res++; which = moOutlaw;
|
|
|
|
}
|
|
|
|
|
2015-08-08 13:57:52 +00:00
|
|
|
for(int t=0; t<c->type; t++) {
|
|
|
|
cell *c2 = c->mov[t];
|
|
|
|
|
|
|
|
// consider monsters who attack from distance 2
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2) for(int u=2; u<=c2->type-2; u++) {
|
2017-03-23 10:53:57 +00:00
|
|
|
cell *c3 = c2->mov[(c->spn(t)+u) % c2->type];
|
2015-08-08 13:57:52 +00:00
|
|
|
if(!c3) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c3->monst != moWitchFlash)
|
|
|
|
if(nonAdjacent(c, c2) || nonAdjacent(c2,c3) || thruVine(c,c2) || thruVine(c2,c3))
|
|
|
|
continue;
|
2015-08-08 13:57:52 +00:00
|
|
|
// only these monsters can attack from two spots...
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c3->monst != moLancer && c3->monst != moWitchSpeed && c3->monst != moWitchFlash)
|
|
|
|
continue;
|
|
|
|
if(elec::affected(c3)) continue;
|
|
|
|
if(c3->stuntime) continue;
|
2015-08-08 13:57:52 +00:00
|
|
|
// speedwitches can only attack not-fastened monsters,
|
|
|
|
// others can only attack if the move is not fastened
|
|
|
|
if(c3->monst == moWitchSpeed && items[itOrbSpeed]) continue;
|
|
|
|
if(c3->monst != moWitchSpeed && fast) continue;
|
|
|
|
// cannot attack if the immediate cell is impassable (except flashwitches)
|
|
|
|
if(c3->monst != moWitchFlash) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!passable(c2, c3, stalemate::isKilled(c2)?0:P_MONSTER)) continue;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isPlayerOn(c2) && items[itOrbFire]) continue;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
// flashwitches cannot attack if it would kill another enemy
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c3->monst == moWitchFlash && flashWouldKill(c3, 0)) continue;
|
2017-07-22 23:33:27 +00:00
|
|
|
if(stalemate::anyKilled() && mirror::isKilledByMirror(c3)) continue;
|
2015-08-08 13:57:52 +00:00
|
|
|
res++, which = c3->monst;
|
|
|
|
}
|
|
|
|
|
|
|
|
// consider normal monsters
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2 &&
|
2017-03-23 10:53:57 +00:00
|
|
|
isArmedEnemy(c2, sm.who) &&
|
2016-08-26 09:58:03 +00:00
|
|
|
!stalemate::isKilled(c2) &&
|
2017-03-23 10:53:57 +00:00
|
|
|
(c2->monst != moLancer || isUnarmed(sm.who))) {
|
|
|
|
eMonster m = c2->monst;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(elec::affected(c2)) continue;
|
2015-08-08 13:57:52 +00:00
|
|
|
if(fast && c2->monst != moWitchSpeed) continue;
|
2017-03-23 10:53:57 +00:00
|
|
|
// Krakens just destroy boats
|
|
|
|
if(c2->monst == moKrakenT && onboat(sm)) {
|
|
|
|
if(krakensafe(c)) continue;
|
|
|
|
else if(warningprotection() && res == 0) m = moWarning;
|
|
|
|
else continue;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
// they cannot attack through vines
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!canAttack(c2, c2->monst, c, sm.who, AF_NEXTTURN)) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->monst == moWorm || c2->monst == moTentacle || c2->monst == moHexSnake) {
|
|
|
|
if(passable_for(c2->monst, c, c2, 0))
|
|
|
|
eaten = true;
|
|
|
|
else if(c2->monst != moHexSnake) continue;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
res++, which = m;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(sm.who == moPlayer && res && (markOrb2(itOrbShield) || markOrb2(itOrbShell)) && !eaten)
|
2016-01-02 10:09:13 +00:00
|
|
|
res = 0;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(sm.who == moPlayer && res && markOrb2(itOrbDomination) && c->monst)
|
2016-08-26 09:58:03 +00:00
|
|
|
res = 0;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
return res;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
namespace multi { bool aftermove; }
|
|
|
|
|
|
|
|
int monstersnear2();
|
|
|
|
|
|
|
|
int lastkills;
|
|
|
|
|
|
|
|
bool multimove() {
|
|
|
|
if(multi::cpid == 0) lastkills = tkills();
|
|
|
|
if(!multi::playerActive(multi::cpid)) return !monstersnear2();
|
|
|
|
cellwalker bcwt = cwt;
|
|
|
|
cwt = multi::player[multi::cpid];
|
|
|
|
bool b = movepcto(multi::whereto[multi::cpid]);
|
|
|
|
if(b) {
|
|
|
|
multi::aftermove = true;
|
|
|
|
multi::player[multi::cpid] = cwt;
|
|
|
|
multi::whereto[multi::cpid].d = MD_UNDECIDED;
|
|
|
|
int curkills = tkills();
|
|
|
|
multi::kills[multi::cpid] += (curkills - lastkills);
|
|
|
|
lastkills = curkills;
|
|
|
|
}
|
|
|
|
cwt = bcwt;
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace multi { bool checkonly = false; }
|
|
|
|
|
|
|
|
bool swordConflict(const stalemate1& sm1, const stalemate1& sm2) {
|
|
|
|
if(items[itOrbSword] || items[itOrbSword2])
|
|
|
|
for(int b=0; b<2; b++)
|
|
|
|
if(sm1.comefrom == sm2.swordlast[b] || sm1.comefrom == sm2.swordtransit[b] || sm1.comefrom == sm2.swordnext[b])
|
|
|
|
if(sm1.moveto == sm2.swordlast[b] || sm1.moveto == sm2.swordtransit[b] || sm1.moveto == sm2.swordnext[b])
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int monstersnear2() {
|
|
|
|
multi::cpid++;
|
|
|
|
int b = 0;
|
|
|
|
bool recorduse[ittypes];
|
|
|
|
for(int i=0; i<ittypes; i++) recorduse[i] = orbused[i];
|
|
|
|
if(multi::cpid == multi::players || multi::players == 1 || multi::checkonly) {
|
|
|
|
|
|
|
|
// check for safe orbs first
|
|
|
|
for(int i=0; i<size(stalemate::moves); i++)
|
|
|
|
if(hasSafeOrb(stalemate::moves[i].moveto)) {
|
|
|
|
multi::cpid--; return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<size(stalemate::moves); i++)
|
|
|
|
for(int j=0; j<size(stalemate::moves); j++) if(i != j) {
|
|
|
|
if(swordConflict(stalemate::moves[i], stalemate::moves[j])) {
|
|
|
|
b = 1;
|
|
|
|
which = moEnergySword;
|
|
|
|
}
|
|
|
|
if(multi::player[i].c == multi::player[j].c)
|
|
|
|
{ b = 1; which = moFireball; }
|
|
|
|
if(celldistance(multi::player[i].c, multi::player[j].c) > 8)
|
|
|
|
{ b = 1; which = moAirball; }
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; !b && i<size(stalemate::moves); i++)
|
|
|
|
b = monstersnear(stalemate::moves[i]);
|
|
|
|
}
|
|
|
|
else b = !multimove();
|
|
|
|
multi::cpid--;
|
|
|
|
for(int i=0; i<ittypes; i++) orbused[i] = recorduse[i];
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
int monstersnear(cell *c, cell *nocount, eMonster who, cell *pushto, cell *comefrom) {
|
2017-07-04 13:38:33 +00:00
|
|
|
|
|
|
|
if(peace::on) return 0; // you are safe
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
stalemate1 sm(who, c, nocount, pushto, comefrom);
|
|
|
|
|
|
|
|
if(who == moPlayer) for(int b=0; b<2; b++) sm.swordlast[b] = sword::pos(multi::cpid, b);
|
|
|
|
|
2017-08-14 18:32:22 +00:00
|
|
|
cell *none = NULL;
|
2017-03-23 10:53:57 +00:00
|
|
|
cell **wcw = &cwt.c;
|
|
|
|
if(who != moPlayer) wcw = &none;
|
|
|
|
else if(multi::players > 1) wcw = &multi::player[multi::cpid].c;
|
|
|
|
|
|
|
|
dynamicval<cell*> x5(*wcw, c);
|
2016-08-26 09:58:03 +00:00
|
|
|
dynamicval<bool> x6(stalemate::nextturn, true);
|
2017-03-23 10:53:57 +00:00
|
|
|
dynamicval<int> x7(sword::angle[multi::cpid],
|
|
|
|
who == moPlayer ? sword::shift(comefrom, c, sword::angle[multi::cpid]) :
|
|
|
|
sword::angle[multi::cpid]);
|
|
|
|
|
|
|
|
if(who == moPlayer) for(int b=0; b<2; b++) {
|
|
|
|
sm.swordnext[b] = sword::pos(multi::cpid, b);
|
|
|
|
sm.swordtransit[b] = NULL;
|
|
|
|
if(sm.swordnext[b] && sm.swordnext[b] != sm.swordlast[b] && !isNeighbor(sm.swordlast[b], sm.swordnext[b]))
|
|
|
|
forCellEx(c2, sm.swordnext[b])
|
|
|
|
if(c2 != c && c2 != comefrom && isNeighbor(c2, sm.swordlast[b]))
|
|
|
|
sm.swordtransit[b] = c2;
|
|
|
|
}
|
|
|
|
|
|
|
|
stalemate::moves.push_back(sm);
|
|
|
|
|
|
|
|
// dynamicval<eMonster> x7(stalemate::who, who);
|
|
|
|
|
|
|
|
int b;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(who == moPlayer && c->wall == waBigStatue) {
|
|
|
|
eWall w = comefrom->wall;
|
|
|
|
c->wall = waNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(doesnotFall(comefrom)) comefrom->wall = waBigStatue;
|
|
|
|
b = monstersnear2();
|
2016-08-26 09:58:03 +00:00
|
|
|
comefrom->wall = w;
|
|
|
|
c->wall = waBigStatue;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(who == moPlayer && c->wall == waThumperOn) {
|
|
|
|
c->wall = waNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
b = monstersnear2();
|
2016-08-26 09:58:03 +00:00
|
|
|
c->wall = waThumperOn;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
b = monstersnear2();
|
|
|
|
stalemate::moves.pop_back();
|
|
|
|
return b;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-09-03 10:01:31 +00:00
|
|
|
|
|
|
|
void petrify(cell *c, eWall walltype, eMonster m) {
|
|
|
|
destroyHalfvine(c);
|
|
|
|
playSound(c, "die-troll");
|
|
|
|
|
|
|
|
if(isWateryOrBoat(c) && c->land == laWhirlpool) {
|
|
|
|
c->wall = waSea;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(walltype == waGargoyle && cellUnstableOrChasm(c))
|
|
|
|
walltype = waGargoyleFloor;
|
|
|
|
else if(walltype == waGargoyle && isWatery(c))
|
|
|
|
walltype = waGargoyleBridge;
|
|
|
|
else if(walltype == waPetrified && isWatery(c))
|
|
|
|
walltype = waPetrifiedBridge;
|
|
|
|
else if((c->wall == waTempBridge || c->wall == waTempBridgeBlocked) && c->land == laWhirlpool) {
|
|
|
|
c->wall = waTempBridgeBlocked;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(!doesnotFall(c)) {
|
|
|
|
fallingFloorAnimation(c, walltype, m);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isReptile(c->wall)) kills[moReptile]++;
|
|
|
|
destroyHalfvine(c);
|
|
|
|
c->wall = walltype;
|
|
|
|
c->wparam = m;
|
|
|
|
c->item = itNone;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void killIvy(cell *c, eMonster who) {
|
2015-08-08 13:57:52 +00:00
|
|
|
if(c->monst == moIvyDead) return;
|
2017-09-03 10:01:31 +00:00
|
|
|
if(checkOrb(who, itOrbStone)) petrify(c, waPetrified, c->monst);
|
2016-08-26 09:58:03 +00:00
|
|
|
c->monst = moIvyDead; // NEWYEARFIX
|
2015-08-08 13:57:52 +00:00
|
|
|
for(int i=0; i<c->type; i++) if(c->mov[i])
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isIvy(c->mov[i]) && c->mov[i]->mondir == c->spn(i))
|
|
|
|
killIvy(c->mov[i], who);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void prespill(cell* c, eWall t, int rad, cell *from) {
|
|
|
|
if(againstWind(c, from)) return;
|
2015-08-08 13:57:52 +00:00
|
|
|
// these monsters block spilling
|
|
|
|
if(c->monst == moSeep || c->monst == moVineSpirit || c->monst == moShark ||
|
2016-01-02 10:09:13 +00:00
|
|
|
c->monst == moGreaterShark || c->monst == moParrot || c->monst == moCShark)
|
2015-08-08 13:57:52 +00:00
|
|
|
return;
|
|
|
|
// turn statues into Slimes!
|
|
|
|
if(c->wall == waBigStatue && t != waNone) {
|
|
|
|
c->wall = waNone;
|
|
|
|
c->monst = moSlimeNextTurn;
|
|
|
|
}
|
|
|
|
// slimedeath spill
|
|
|
|
if((c->monst == moSlime || c->monst == moSlimeNextTurn) && t == waNone) {
|
2017-03-23 10:53:57 +00:00
|
|
|
c->wall = waNone; attackMonster(c, 0, moNone);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-08-18 01:39:24 +00:00
|
|
|
if(c->wall == waClosedGate) {
|
|
|
|
c->wall = waPalace;
|
|
|
|
return;
|
|
|
|
}
|
2017-09-03 10:01:31 +00:00
|
|
|
// no slime in Whirlpool
|
|
|
|
if(c->land == laWhirlpool) return;
|
2015-08-08 13:57:52 +00:00
|
|
|
// these walls block spilling completely
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->wall == waIcewall || c->wall == waBarrier || c->wall == waWarpGate ||
|
2017-03-23 10:53:57 +00:00
|
|
|
c->wall == waDeadTroll || c->wall == waDeadTroll2 ||
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall == waDune || c->wall == waAncientGrave ||
|
|
|
|
c->wall == waThumperOff || c->wall == waThumperOn ||
|
2015-08-08 13:57:52 +00:00
|
|
|
c->wall == waFreshGrave || c->wall == waColumn || c->wall == waPartialFire ||
|
|
|
|
c->wall == waDeadwall || c->wall == waWaxWall || c->wall == waCamelot || c->wall == waRoundTable ||
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall == waBigStatue || c->wall == waRed1 || c->wall == waRed2 || c->wall == waRed3 ||
|
2017-03-23 10:53:57 +00:00
|
|
|
c->wall == waTower ||
|
2017-08-18 01:39:24 +00:00
|
|
|
c->wall == waPalace ||
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall == waPlatform || c->wall == waStone || c->wall == waTempWall ||
|
2017-09-03 10:01:31 +00:00
|
|
|
c->wall == waTempFloor || c->wall == waTempBridge || c->wall == waPetrifiedBridge || c->wall == waTempBridgeBlocked ||
|
2016-08-26 09:58:03 +00:00
|
|
|
c->wall == waSandstone || c->wall == waCharged || c->wall == waGrounded ||
|
2017-03-23 10:53:57 +00:00
|
|
|
c->wall == waMetal || c->wall == waSaloon || c->wall == waFan ||
|
2017-09-01 20:30:17 +00:00
|
|
|
c->wall == waBarrowDig || c->wall == waBarrowWall ||
|
|
|
|
c->wall == waMirrorWall)
|
2015-08-08 13:57:52 +00:00
|
|
|
return;
|
|
|
|
// these walls block further spilling
|
|
|
|
if(c->wall == waCavewall || cellUnstable(c) || c->wall == waSulphur ||
|
|
|
|
c->wall == waSulphurC || c->wall == waLake || c->wall == waChasm ||
|
2016-08-26 09:58:03 +00:00
|
|
|
c->wall == waBigTree || c->wall == waSmallTree || c->wall == waTemporary ||
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall == waVinePlant || isFire(c) || c->wall == waBonfireOff || c->wall == waVineHalfA || c->wall == waVineHalfB ||
|
|
|
|
c->wall == waCamelotMoat || c->wall == waSea || c->wall == waCTree ||
|
2016-08-26 09:58:03 +00:00
|
|
|
c->wall == waRubble || c->wall == waGargoyleFloor || c->wall == waGargoyle ||
|
2017-09-03 10:01:31 +00:00
|
|
|
c->wall == waRose || c->wall == waPetrified || c->wall == waPetrifiedBridge)
|
2015-08-08 13:57:52 +00:00
|
|
|
t = waTemporary;
|
|
|
|
|
|
|
|
if(c->wall == waSulphur) {
|
|
|
|
// remove the center as it would not look good
|
|
|
|
for(int i=0; i<c->type; i++) if(c->mov[i] && c->mov[i]->wall == waSulphurC)
|
|
|
|
c->mov[i]->wall = waSulphur;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(isReptile(c->wall)) {
|
|
|
|
if(c->monst || isPlayerOn(c)) kills[moReptile]++;
|
|
|
|
else c->monst = moReptile, c->stuntime = 3, c->hitpoints = 3;
|
|
|
|
}
|
|
|
|
|
2015-08-08 13:57:52 +00:00
|
|
|
destroyHalfvine(c);
|
|
|
|
c->wall = t;
|
|
|
|
// destroy items...
|
|
|
|
c->item = itNone;
|
|
|
|
// block spill
|
|
|
|
if(t == waTemporary) return;
|
|
|
|
// cwt.c->item = itNone;
|
|
|
|
if(rad) for(int i=0; i<c->type; i++) if(c->mov[i])
|
2016-08-26 09:58:03 +00:00
|
|
|
prespill(c->mov[i], t, rad-1, c);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void spillfix(cell* c, eWall t, int rad) {
|
|
|
|
if(c->wall == waTemporary) c->wall = t;
|
|
|
|
if(rad) for(int i=0; i<c->type; i++) if(c->mov[i])
|
|
|
|
spillfix(c->mov[i], t, rad-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void spill(cell* c, eWall t, int rad) {
|
2016-08-26 09:58:03 +00:00
|
|
|
prespill(c,t,rad, c); spillfix(c,t,rad);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void degradeDemons() {
|
|
|
|
addMessage(XLAT("You feel more experienced in demon fighting!"));
|
|
|
|
int dcs = size(dcal);
|
|
|
|
for(int i=0; i<dcs; i++) {
|
|
|
|
cell *c = dcal[i];
|
|
|
|
if(c->monst == moGreaterM || c->monst == moGreater)
|
|
|
|
achievement_gain("DEMONSLAYER");
|
|
|
|
if(c->monst == moGreaterM) c->monst = moLesserM;
|
|
|
|
if(c->monst == moGreater) c->monst = moLesser;
|
2016-01-02 10:09:13 +00:00
|
|
|
shmup::degradeDemons();
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ivynext(cell *c);
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
bool earthFloor(cell *c) {
|
|
|
|
if(c->monst) return false;
|
|
|
|
if(c->wall == waDeadwall) { c->wall = waDeadfloor; return true; }
|
|
|
|
if(c->wall == waDune) { c->wall = waNone; return true; }
|
|
|
|
if(c->wall == waStone) { c->wall = waNone; return true; }
|
|
|
|
if(c->wall == waAncientGrave || c->wall == waFreshGrave) {
|
|
|
|
c->wall = waNone;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if((c->wall == waSea || c->wall == waNone) && c->land == laOcean) {
|
|
|
|
c->wall = waCIsland;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(c->wall == waSea && c->land == laCaribbean) {
|
|
|
|
c->wall = waCIsland;
|
|
|
|
return true;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->wall == waSea && c->land == laWarpSea)
|
2016-08-26 09:58:03 +00:00
|
|
|
c->wall = waNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->wall == waBoat && c->land == laWarpSea)
|
2016-08-26 09:58:03 +00:00
|
|
|
c->wall = waStrandedBoat;
|
2017-03-23 10:53:57 +00:00
|
|
|
if((c->wall == waBarrowDig || c->wall == waBarrowWall) && c->land == laBurial) {
|
|
|
|
c->item = itNone;
|
|
|
|
c->wall = waNone;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(c->wall == waPlatform && c->land == laMountain) {
|
|
|
|
c->wall = waNone;
|
|
|
|
return true;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool earthWall(cell *c) {
|
|
|
|
if(c->wall == waDeadfloor || c->wall == waDeadfloor2 || c->wall == waEarthD) {
|
|
|
|
c->item = itNone;
|
|
|
|
c->wall = waDeadwall;
|
|
|
|
return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->wall == waNone && c->land == laMountain) {
|
|
|
|
c->wall = waPlatform;
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
if(c->wall == waNone && c->land == laDesert) {
|
|
|
|
c->item = itNone;
|
|
|
|
c->wall = waDune;
|
2016-01-02 10:09:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(c->wall == waNone && isElemental(c->land)) {
|
|
|
|
c->item = itNone;
|
|
|
|
c->wall = waStone;
|
|
|
|
return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
if(c->wall == waNone && c->land == laRedRock) {
|
|
|
|
c->item = itNone;
|
|
|
|
c->wall = waRed3;
|
|
|
|
return true;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->wall == waNone && c->land == laBurial) {
|
|
|
|
c->item = itNone;
|
|
|
|
c->wall = waBarrowDig;
|
|
|
|
return true;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
if(c->wall == waCIsland || c->wall == waCIsland2 || (c->wall == waNone && c->land == laOcean)) {
|
|
|
|
c->item = itNone;
|
|
|
|
c->wall = waSea;
|
|
|
|
if(c->land == laOcean) c->landparam = 40;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool snakepile(cell *c, eMonster m) {
|
2016-01-02 10:09:13 +00:00
|
|
|
if(c->wall == waRed1 || c->wall == waOpenGate) c->wall = waRed2;
|
|
|
|
else if(c->wall == waRed2) c->wall = waRed3;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(doesFall(c)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if((c->wall == waSea && c->land == laLivefjord))
|
|
|
|
c->wall = waNone;
|
|
|
|
else if((c->wall == waSea && isWarped(c->land)))
|
|
|
|
c->wall = waNone;
|
|
|
|
else if(isGravityLand(c->land)) {
|
|
|
|
if(m == moHexSnake)
|
|
|
|
c->wall = waPlatform;
|
|
|
|
else
|
|
|
|
c->wall = waDeadTroll2;
|
|
|
|
}
|
|
|
|
else if(c->wall == waNone || isAlchAny(c) ||
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall == waCIsland || c->wall == waCIsland2 ||
|
|
|
|
(c->wall == waSea && c->land == laOcean) ||
|
|
|
|
c->wall == waOpenPlate || c->wall == waClosePlate ||
|
2017-03-23 10:53:57 +00:00
|
|
|
c->wall == waMineUnknown || c->wall == waMineOpen || isReptile(c->wall)) {
|
|
|
|
if(isReptile(c->wall)) kills[moReptile]++;
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall = waRed1;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moDarkTroll) c->wall = waDeadfloor2;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
else if(c->wall == waDeadfloor)
|
|
|
|
c->wall = waDeadfloor2;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c->wall == waDeadfloor2) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moDarkTroll && c->land == laDeadCaves) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
else
|
|
|
|
c->wall = waDeadwall;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
else if(c->wall == waRubble || c->wall == waGargoyleFloor || c->wall == waGargoyleBridge ||
|
2017-09-03 10:01:31 +00:00
|
|
|
c->wall == waTempFloor || c->wall == waTempBridge || c->wall == waPetrifiedBridge) {
|
|
|
|
if(c->land == laWhirlpool) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall = waRed2;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moDarkTroll) c->wall = waDeadwall;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
else if(c->wall == waCavefloor) c->wall = waCavewall;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c->wall == waSea && c->land == laCaribbean) c->wall = waCIsland;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c->wall == waSea && c->land == laWhirlpool) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c->wall == waSea) c->wall = waNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
else if(isWateryOrBoat(c) || c->wall == waFrozenLake) c->wall = waNone;
|
|
|
|
else if(isWateryOrBoat(c) || c->wall == waFrozenLake) c->wall = waNone;
|
|
|
|
else if(cellHalfvine(c)) {
|
|
|
|
destroyHalfvine(c, waRed1);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->wall == waRed1 && m == moDarkTroll) c->wall = waDeadfloor2;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else return false;
|
|
|
|
return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool makeflame(cell *c, int timeout, bool checkonly) {
|
2016-01-02 10:09:13 +00:00
|
|
|
if(itemBurns(c->item)) {
|
|
|
|
if(checkonly) return true;
|
|
|
|
addMessage(XLAT("%The1 burns!", c->item)), c->item = itNone;
|
|
|
|
}
|
|
|
|
if(cellUnstable(c)) {
|
|
|
|
if(checkonly) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
doesFall(c);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c->wall == waChasm || c->wall == waOpenGate || c->wall == waRed2 || c->wall == waRed3 ||
|
|
|
|
c->wall == waTower)
|
2016-01-02 10:09:13 +00:00
|
|
|
return false;
|
|
|
|
else if(c->wall == waBoat) {
|
|
|
|
if(checkonly) return true;
|
|
|
|
addMessage(XLAT("%The1 burns!", winf[c->wall].name));
|
2017-03-23 10:53:57 +00:00
|
|
|
drawFireParticles(c, 24);
|
2016-08-26 09:58:03 +00:00
|
|
|
placeWater(c, c);
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isIcyLand(c)) HEAT(c) += 1;
|
|
|
|
}
|
|
|
|
else if(c->wall == waNone && c->land == laCocytus) {
|
|
|
|
if(checkonly) return true;
|
|
|
|
c->wall = waLake, HEAT(c) += 1;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c->wall == waFrozenLake) {
|
2016-01-02 10:09:13 +00:00
|
|
|
if(checkonly) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
drawParticles(c, MELTCOLOR, 8, 8);
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall = waLake, HEAT(c) += 1;
|
|
|
|
}
|
|
|
|
else if(c->wall == waIcewall) {
|
|
|
|
if(checkonly) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
drawParticles(c, MELTCOLOR, 8, 8);
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall = waNone;
|
|
|
|
}
|
|
|
|
else if(c->wall == waMineMine) {
|
|
|
|
if(checkonly) return true;
|
|
|
|
explodeMine(c);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c->wall != waCTree && c->wall != waBigTree && c->wall != waSmallTree &&
|
|
|
|
c->wall != waVinePlant && !passable(c, NULL, P_MONSTER | P_MIRROR) &&
|
|
|
|
c->wall != waSaloon && c->wall != waRose) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
// reptiles are able to use the water to put the fire off
|
|
|
|
else if(c->wall == waReptileBridge) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
else {
|
|
|
|
eWall w = eternalFire(c) ? waEternalFire : waFire;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!checkonly) drawFireParticles(c, 10);
|
2016-01-02 10:09:13 +00:00
|
|
|
if(w == c->wall) return false;
|
|
|
|
if(checkonly) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isReptile(c->wall)) kills[moReptile]++;
|
2016-01-02 10:09:13 +00:00
|
|
|
destroyHalfvine(c);
|
|
|
|
if(!isFire(c)) c->wparam = 0;
|
|
|
|
c->wall = w;
|
|
|
|
c->wparam = max(c->wparam, (char) timeout);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void explodeMine(cell *c) {
|
|
|
|
if(c->wall != waMineMine)
|
|
|
|
return;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c, "explosion");
|
|
|
|
drawFireParticles(c, 30, 150);
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall = waMineOpen;
|
|
|
|
makeflame(c, 20, false);
|
|
|
|
|
|
|
|
for(int i=0; i<c->type; i++) if(c->mov[i]) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(c2->wall == waRed2 || c2->wall == waRed3)
|
|
|
|
c2->wall = waRed1;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c2->wall == waDeadTroll || c2->wall == waDeadTroll2 || c2->wall == waPetrified || c2->wall == waGargoyle) {
|
2016-01-02 10:09:13 +00:00
|
|
|
c2->wall = waNone;
|
|
|
|
makeflame(c2, 10, false);
|
|
|
|
}
|
2017-09-03 10:01:31 +00:00
|
|
|
else if(c2->wall == waPetrifiedBridge || c2->wall == waGargoyleBridge) {
|
|
|
|
placeWater(c, c);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->wall == waPalace || c2->wall == waOpenGate || c2->wall == waClosedGate ||
|
|
|
|
c2->wall == waSandstone || c2->wall == waMetal || c2->wall == waSaloon) {
|
2016-01-02 10:09:13 +00:00
|
|
|
c2->wall = waNone;
|
|
|
|
makeflame(c2, 10, false);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c2->wall == waTower)
|
|
|
|
c2->wall = waRubble;
|
|
|
|
else if(c2->wall == waBarrowWall)
|
|
|
|
c2->wall = waBarrowDig;
|
|
|
|
else if(c2->wall == waBarrowDig)
|
|
|
|
c2->wall = waNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
else makeflame(c2, 20, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool mayExplodeMine(cell *c, eMonster who) {
|
|
|
|
if(c->wall != waMineMine) return false;
|
|
|
|
if(ignoresPlates(who)) return false;
|
|
|
|
explodeMine(c);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
void stunMonster(cell *c2) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->monst != moSkeleton && !isMetalBeast(c2->monst) && c2->monst != moTortoise &&
|
|
|
|
c2->monst != moReptile) {
|
2016-01-02 10:09:13 +00:00
|
|
|
c2->hitpoints--;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->monst == moPrincess)
|
|
|
|
playSound(c2, princessgender() ? "hit-princess" : "hit-prince");
|
2017-06-18 16:51:46 +00:00
|
|
|
}
|
|
|
|
int newtime = (
|
2016-01-02 10:09:13 +00:00
|
|
|
c2->monst == moFatGuard ? 2 :
|
2017-03-23 10:53:57 +00:00
|
|
|
c2->monst == moSkeleton && c2->land != laPalace && c2->land != laHalloween ? 7 :
|
2016-08-26 09:58:03 +00:00
|
|
|
isMetalBeast(c2->monst) ? 7 :
|
|
|
|
c2->monst == moTortoise ? 7 :
|
2017-03-23 10:53:57 +00:00
|
|
|
c2->monst == moReptile ? 7 :
|
|
|
|
isPrincess(c2->monst) ? 6 :
|
|
|
|
// spear stunning
|
|
|
|
isBull(c2->monst) ? 3 :
|
|
|
|
(c2->monst == moGreater || c2->monst == moGreaterM) ? 5 :
|
|
|
|
c2->monst == moButterfly ? 2 :
|
|
|
|
c2->monst == moDraugr ? 1 :
|
|
|
|
c2->monst == moVizier ? 1 :
|
|
|
|
c2->monst == moHedge ? 1 :
|
|
|
|
c2->monst == moFlailer ? 1 :
|
2016-01-02 10:09:13 +00:00
|
|
|
3);
|
2017-06-18 16:51:46 +00:00
|
|
|
if(c2->stuntime < newtime) c2->stuntime = newtime;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isBull(c2->monst)) c2->mondir = NODIR;
|
|
|
|
checkStunKill(c2);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool attackJustStuns(cell *c2) {
|
|
|
|
return isStunnable(c2->monst) && c2->hitpoints > 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void moveEffect(cell *ct, cell *cf, eMonster m);
|
|
|
|
|
|
|
|
void flameHalfvine(cell *c, int val) {
|
|
|
|
if(itemBurns(c->item)) {
|
|
|
|
c->item = itNone;
|
|
|
|
addMessage(XLAT("%The1 burns!", c->item)), c->item = itNone;
|
|
|
|
}
|
|
|
|
c->wall = waPartialFire;
|
|
|
|
c->wparam = val;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void minerEffect(cell *c) {
|
2017-03-23 10:53:57 +00:00
|
|
|
eWall ow = c->wall;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->wall == waOpenGate || c->wall == waFrozenLake || c->wall == waBoat ||
|
|
|
|
c->wall == waStrandedBoat ||
|
|
|
|
c->wall == waCIsland || c->wall == waCIsland2 || c->wall == waTrapdoor ||
|
|
|
|
c->wall == waGiantRug) ;
|
|
|
|
else if(c->wall == waMineUnknown || c->wall == waMineMine || c->wall == waMineOpen)
|
|
|
|
c->wall = waMineOpen;
|
|
|
|
else if(c->wall == waRed2) c->wall = waRed1;
|
|
|
|
else if(c->wall == waRed3) c->wall = waRed2;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(isReptile(c->wall))
|
|
|
|
c->wparam = 1; // wake up next turn
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c->wall == waTempFloor) c->wall = waChasm;
|
2017-09-03 10:01:31 +00:00
|
|
|
else if(c->wall == waTempBridge || c->wall == waPetrifiedBridge || c->wall == waTempBridgeBlocked)
|
|
|
|
placeWater(c, NULL);
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(doesFall(c))
|
|
|
|
ow = waNone;
|
2016-08-26 09:58:03 +00:00
|
|
|
else
|
|
|
|
c->wall = waNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->wall != ow && ow) drawParticles(c, winf[ow].color, 16);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isRatling(eMonster m) {
|
|
|
|
return m == moRatling || m == moRatlingAvenger;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void killMutantIvy(cell *c, eMonster who) {
|
2017-09-03 10:01:31 +00:00
|
|
|
if(checkOrb(who, itOrbStone)) petrify(c, waPetrified, moMutant);
|
2017-03-23 10:53:57 +00:00
|
|
|
removeIvy(c);
|
|
|
|
for(int i=0; i<c->type; i++)
|
|
|
|
if(c->mov[i]->mondir == c->spn(i) && (isMutantIvy(c->mov[i]) || c->mov[i]->monst == moFriendlyIvy))
|
|
|
|
killMutantIvy(c->mov[i], who);
|
|
|
|
}
|
|
|
|
|
|
|
|
void killMonster(cell *c, eMonster who, flagtype deathflags) {
|
2015-08-08 13:57:52 +00:00
|
|
|
eMonster m = c->monst;
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBB(DF_TURN, (debugfile,"killmonster %s", dnameof(m)));
|
2015-08-08 13:57:52 +00:00
|
|
|
|
|
|
|
if(!m) return;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(m == moKrakenH) return;
|
|
|
|
if(m == moKrakenT) {
|
|
|
|
if(c->hitpoints && m == moKrakenT) kills[moKrakenT]++;
|
|
|
|
c->hitpoints = 0;
|
|
|
|
c->stuntime = 1;
|
|
|
|
cell *head = kraken::head(c);
|
|
|
|
if(kraken::totalhp(head) == 0) kraken::kill(head, who);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isDragon(m)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->hitpoints && m != moDragonHead) kills[moDragonTail]++;
|
2016-08-26 09:58:03 +00:00
|
|
|
c->hitpoints = 0;
|
|
|
|
c->stuntime = 1;
|
|
|
|
cell *head = dragon::findhead(c);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(dragon::totalhp(head) == 0) dragon::kill(head, who);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isWorm(c) && m != moTentacleGhost) return;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int pcount = (deathflags & AF_FALL) ? 0 : 16;
|
2015-08-08 13:57:52 +00:00
|
|
|
if(m == moShadow) return;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
#ifdef HASLINEVIEW
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!isBug(m) && !isAnyIvy(m)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
conformal::killhistory.push_back(make_pair(c,m));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-08-08 13:57:52 +00:00
|
|
|
if(m == moGolemMoved) m = moGolem;
|
|
|
|
if(m == moKnightMoved) m = moKnight;
|
|
|
|
if(m == moSlimeNextTurn) m = moSlime;
|
|
|
|
if(m == moLesserM) m = moLesser;
|
|
|
|
if(m == moGreater) m = moLesser;
|
|
|
|
if(m == moGreaterM) m = moLesser;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isPrincess(m)) m = moPrincess;
|
|
|
|
if(m == moTentacleGhost) m = moGhost;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!isBulletType(m)) kills[m]++;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(!c->item) if(m == moButterfly && (deathflags & AF_BULL))
|
|
|
|
c->item = itBull;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isRatling(m) && c->wall == waBoat) {
|
|
|
|
bool avenge = false;
|
|
|
|
for(int i=0; i<c->type; i++) if(!isWarped(c->mov[i]->land))
|
|
|
|
avenge = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(avenge) { avengers += 2; }
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(m == moMirrorSpirit && who != moMimic && !(deathflags & AF_MAGIC)) {
|
|
|
|
kills[m]--;
|
|
|
|
mirrorspirits++;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isMutantIvy(m) || m == moFriendlyIvy) {
|
|
|
|
pcount = 0;
|
|
|
|
killMutantIvy(c, who);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(m == moPrincess) {
|
|
|
|
princess::info *i = princess::getPrincessInfo(c);
|
|
|
|
if(i) {
|
2016-01-02 10:09:13 +00:00
|
|
|
i->princess = NULL;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(i->bestdist == OUT_OF_PALACE) {
|
|
|
|
items[itSavedPrincess]--;
|
2017-07-16 21:00:55 +00:00
|
|
|
if(items[itSavedPrincess] < 0) {
|
|
|
|
printf("princess below 0\n");
|
|
|
|
items[itSavedPrincess] = 0;
|
|
|
|
}
|
2017-07-12 16:03:53 +00:00
|
|
|
if(items[itSavedPrincess] == 0 && !inv::on) {
|
2017-03-23 10:53:57 +00:00
|
|
|
items[itOrbLove] = 0;
|
2017-07-12 16:03:53 +00:00
|
|
|
princess::reviveAt = gold(NO_LOVE) + 20;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
if(princess::challenge) showMissionScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m == moGargoyle && c->wall != waMineMine) {
|
|
|
|
bool connected = false;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isGravityLand(c->land)) {
|
2016-01-02 10:09:13 +00:00
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(c2->wall == waPlatform || c2->wall == waGargoyle || c2->wall == waBarrier ||
|
2017-03-23 10:53:57 +00:00
|
|
|
c2->wall == waDeadTroll || c2->wall == waDeadTroll2 || c2->wall == waTrunk ||
|
|
|
|
c2->wall == waPetrified || isAlchAny(c2->wall))
|
2016-01-02 10:09:13 +00:00
|
|
|
connected = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(!cellUnstableOrChasm(c2) && !isWatery(c2)) connected = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-03 10:01:31 +00:00
|
|
|
if(connected) petrify(c, waGargoyle, m), pcount = 0;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moTroll) {
|
2017-09-03 10:01:31 +00:00
|
|
|
petrify(c, waDeadTroll, m); pcount = 0;
|
2015-08-08 13:57:52 +00:00
|
|
|
for(int i=0; i<c->type; i++) if(c->mov[i]) {
|
2016-08-26 09:58:03 +00:00
|
|
|
c->mov[i]->item = itNone;
|
2015-08-08 13:57:52 +00:00
|
|
|
if(c->mov[i]->wall == waDeadwall || c->mov[i]->wall == waDeadfloor2) c->mov[i]->wall = waCavewall;
|
|
|
|
if(c->mov[i]->wall == waDeadfloor) c->mov[i]->wall = waCavefloor;
|
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moFjordTroll || m == moForestTroll || m == moStormTroll) {
|
2017-09-03 10:01:31 +00:00
|
|
|
petrify(c, waDeadTroll2, m);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
if(m == moMiner) {
|
2017-03-23 10:53:57 +00:00
|
|
|
pcount = 32;
|
|
|
|
playSound(c, "splash" + pick12());
|
2015-08-08 13:57:52 +00:00
|
|
|
destroyHalfvine(c);
|
2016-08-26 09:58:03 +00:00
|
|
|
minerEffect(c);
|
|
|
|
for(int i=0; i<c->type; i++) if(passable(c->mov[i], c, P_MONSTER | P_MIRROR | P_CLIMBUP | P_CLIMBDOWN)) {
|
2015-08-08 13:57:52 +00:00
|
|
|
destroyHalfvine(c->mov[i]);
|
2016-08-26 09:58:03 +00:00
|
|
|
minerEffect(c->mov[i]);
|
2015-08-08 13:57:52 +00:00
|
|
|
if(c->mov[i]->monst == moSlime || c->mov[i]->monst == moSlimeNextTurn)
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(c->mov[i], who);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moOrangeDog) {
|
|
|
|
if(pcount) for(int i=0; i<8; i++) {
|
|
|
|
drawParticle(c, 0xFFFFFF);
|
|
|
|
drawParticle(c, 0x202020);
|
|
|
|
}
|
|
|
|
pcount = 0;
|
|
|
|
}
|
|
|
|
if(m == moDraugr) {
|
|
|
|
if(pcount) drawParticles(c, 0x804000, 8);
|
|
|
|
pcount = 0;
|
|
|
|
}
|
|
|
|
if(m == moPalace) {
|
|
|
|
if(pcount) {
|
|
|
|
pcount = 4;
|
|
|
|
for(int i=0; i<12; i++) drawParticle(c, 0x20C020);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(m == moPrincess) {
|
|
|
|
playSound(c, princessgender() ? "die-princess" : "die-prince");
|
|
|
|
}
|
2017-09-03 10:01:31 +00:00
|
|
|
if(m == moVineBeast)
|
|
|
|
petrify(c, waVinePlant, m), pcount = 0;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isBird(m)) moveEffect(c, c, moDeadBird);
|
|
|
|
if(m == moBomberbird || m == moTameBomberbird) {
|
2017-03-23 10:53:57 +00:00
|
|
|
pcount = 0;
|
|
|
|
playSound(c, "die-bomberbird");
|
2016-01-02 10:09:13 +00:00
|
|
|
if(c->wall == waNone || c->wall == waMineUnknown || c->wall == waMineOpen ||
|
|
|
|
c->wall == waCavefloor || c->wall == waDeadfloor || c->wall == waDeadfloor2 ||
|
|
|
|
c->wall == waRubble || c->wall == waGargoyleFloor ||
|
|
|
|
c->wall == waCIsland || c->wall == waCIsland2 ||
|
2017-03-23 10:53:57 +00:00
|
|
|
c->wall == waStrandedBoat || c->wall == waRed1 || c->wall == waGiantRug) {
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall = waMineMine;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->item) explodeMine(c);
|
2017-09-03 10:01:31 +00:00
|
|
|
else if(c->land == laMinefield) c->landparam = 1;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
else if(c->wall == waFrozenLake)
|
|
|
|
c->wall = waLake;
|
|
|
|
else if(c->wall == waGargoyleBridge)
|
|
|
|
placeWater(c, c);
|
|
|
|
else if(c->wall == waRed3 || c->wall == waRed2) {
|
|
|
|
c->wall = waRed1;
|
|
|
|
for(int i=0; i<c->type; i++) if(c->mov[i]->wall == waRed3)
|
|
|
|
c->mov[i]->wall = waRed2;
|
|
|
|
c->item = itNone;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
eWall w = c->wall;
|
|
|
|
if(isFire(c) || c->wall == waRose || isReptile(c->wall)) {
|
2016-01-02 10:09:13 +00:00
|
|
|
c->wall = waMineMine;
|
|
|
|
explodeMine(c);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isReptile(w)) kills[moReptile]++;
|
|
|
|
if(w == waReptile) c->wall = waChasm;
|
|
|
|
if(w == waReptileBridge) placeWater(c, NULL);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
if(m == moVineSpirit) {
|
2017-03-23 10:53:57 +00:00
|
|
|
pcount = 32;
|
|
|
|
playSound(c, "die-vinespirit");
|
2015-08-08 13:57:52 +00:00
|
|
|
destroyHalfvine(c);
|
2016-01-02 10:09:13 +00:00
|
|
|
if(!isFire(c)) c->wall = waNone;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moRedTroll) {
|
|
|
|
playSound(c, "die-troll");
|
|
|
|
if(doesFall(c)) fallingFloorAnimation(c, waRed1, m), pcount = 0;
|
|
|
|
else if(snakepile(c, m)) pcount = 0;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moDarkTroll) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c, "die-troll");
|
|
|
|
if(doesFall(c)) fallingFloorAnimation(c, waDeadwall, m), pcount = 0;
|
|
|
|
else if(c->wall == waRed1 || c->wall == waRed2 || c->wall == waRed3)
|
|
|
|
c->wall = waDeadwall, pcount = 0;
|
|
|
|
else if(snakepile(c, m))
|
|
|
|
pcount = 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
if(isWitch(m) && (isFire(c) || passable(c, NULL, P_MONSTER)) && !c->item) {
|
2015-08-08 13:57:52 +00:00
|
|
|
if(m == moWitchFire) c->item = itOrbFire;
|
|
|
|
if(m == moWitchFlash) c->item = itOrbFlash;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moWitchGhost) c->item = itOrbAether;
|
2015-08-08 13:57:52 +00:00
|
|
|
if(m == moWitchWinter) c->item = itOrbWinter;
|
|
|
|
if(m == moWitchSpeed) c->item = itOrbSpeed;
|
2016-01-02 10:09:13 +00:00
|
|
|
if(isFire(c) && itemBurns(c->item))
|
2015-08-08 13:57:52 +00:00
|
|
|
c->item = itNone;
|
|
|
|
}
|
2017-09-03 10:01:31 +00:00
|
|
|
if(checkOrb(who, itOrbStone))
|
|
|
|
petrify(c, waPetrified, m), pcount = 0;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moFireFairy) {
|
|
|
|
drawFireParticles(c, 16); pcount = 0;
|
|
|
|
playSound(c, "die-fairy");
|
|
|
|
playSound(c, "fire");
|
2016-01-02 10:09:13 +00:00
|
|
|
makeflame(c, 50, false);
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
if(c->monst == moMetalBeast2 && !c->item && who == moLightningBolt && c->wall != waPetrified && c->wall != waChasm)
|
|
|
|
c->item = itFulgurite; // this is actually redundant in many cases
|
|
|
|
if(m == moPyroCultist && c->item == itNone && c->wall != waChasm && c->wall != waPetrified) {
|
2015-08-08 13:57:52 +00:00
|
|
|
// a reward for killing him before he shoots!
|
|
|
|
c->item = itOrbDragon;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moOutlaw && (c->item == itNone || c->item == itRevolver) && c->wall != waChasm)
|
|
|
|
c->item = itBounty;
|
2016-01-02 10:09:13 +00:00
|
|
|
// note: an Orb appears underwater!
|
|
|
|
if(m == moWaterElemental && c->item == itNone)
|
|
|
|
c->item = itOrbWater;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moPirate && isOnCIsland(c) && c->item == itNone && (
|
|
|
|
euclid ||
|
|
|
|
(c->master->alt && celldistAlt(c) <= (purehepta ? -3 : -5)) ||
|
|
|
|
isHaunted(c->land))) {
|
2016-01-02 10:09:13 +00:00
|
|
|
bool toomany = false;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2 && c2->item == itCompass) toomany = true;
|
|
|
|
if(c2 && !purehepta) for(int j=0; j<c2->type; j++)
|
2016-01-02 10:09:13 +00:00
|
|
|
if(c2->mov[j] && c2->mov[j]->item == itCompass)
|
|
|
|
toomany = true;
|
|
|
|
}
|
|
|
|
if(!toomany) c->item = itCompass;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moSlime) {
|
|
|
|
pcount = 0;
|
|
|
|
drawParticles(c, winf[c->wall].color, 80, 200);
|
|
|
|
playSound(c, "splash" + pick12());
|
|
|
|
c->monst = moNone;
|
|
|
|
spill(c, c->wall, 2);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
// if(c->monst == moShark) c->heat += 1;
|
|
|
|
// if(c->monst == moGreaterShark) c->heat += 10;
|
|
|
|
if(isIcyLand(c)) {
|
2016-01-02 10:09:13 +00:00
|
|
|
if(m == moCultist) HEAT(c) += 3;
|
|
|
|
if(m == moPyroCultist) HEAT(c) += 6;
|
|
|
|
if(m == moLesser) HEAT(c) += 10;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
if(m == moLesser && !(kills[m] % 10))
|
|
|
|
degradeDemons();
|
|
|
|
if(isIvy(c)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
pcount = 0;
|
2015-08-08 13:57:52 +00:00
|
|
|
eMonster m = c->monst;
|
|
|
|
/*if((m == moIvyBranch || m == moIvyHead) && c->mov[c->mondir]->monst == moIvyRoot)
|
|
|
|
ivynext(c, moIvyNext); */
|
2017-03-23 10:53:57 +00:00
|
|
|
killIvy(c, who);
|
2015-08-08 13:57:52 +00:00
|
|
|
if(m == moIvyBranch || m == moIvyHead || m == moIvyNext) {
|
|
|
|
int qty = 0;
|
|
|
|
cell *c2 = c->mov[c->mondir];
|
|
|
|
for(int i=0; i<c2->type; i++)
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->mov[i]->monst == moIvyWait && c2->mov[i]->mondir == c2->spn(i))
|
2015-08-08 13:57:52 +00:00
|
|
|
qty++;
|
|
|
|
if(c->mov[c->mondir]->monst == moIvyRoot || qty) {
|
|
|
|
c->monst = moIvyNext;
|
|
|
|
/* c->monst = moIvyHead;
|
|
|
|
ivynext(c);
|
|
|
|
if(c->monst == moIvyHead) c->monst = moIvyNext;
|
|
|
|
else c->monst = moNone; */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c->mov[c->mondir]->monst = moIvyHead;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
else if(c->monst == moTentacleGhost)
|
|
|
|
c->monst = moTentacletail;
|
2015-08-08 13:57:52 +00:00
|
|
|
else c->monst = moNone;
|
|
|
|
|
|
|
|
if(m == moEarthElemental) earthWall(c);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moAlbatross && items[itOrbLuck])
|
|
|
|
useupOrb(itOrbLuck, items[itOrbLuck] / 2);
|
|
|
|
|
|
|
|
if(m == moAirElemental) {
|
|
|
|
airmap.clear();
|
|
|
|
for(int i=0; i<size(dcal); i++)
|
|
|
|
if(dcal[i]->monst == moAirElemental)
|
|
|
|
airmap.push_back(make_pair(dcal[i],0));
|
|
|
|
buildAirmap();
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
drawParticles(c, minf[m].color, pcount);
|
|
|
|
if(deathflags & AF_FALL)
|
|
|
|
fallingMonsterAnimation(c, m);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void fightmessage(eMonster victim, eMonster attacker, bool stun, int flags) {
|
|
|
|
|
|
|
|
if(isBird(attacker)) {
|
|
|
|
playSound(NULL, "hit-axe"+pick123());
|
|
|
|
addMessage(XLAT("%The1 claws %the2!", attacker, victim));
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(isGhost(attacker))
|
|
|
|
addMessage(XLAT("%The1 scares %the2!", attacker, victim));
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(isSlimeMover(attacker) && !stun) {
|
|
|
|
playSound(NULL, "hit-crush"+pick123());
|
|
|
|
addMessage(XLAT("%The1 eats %the2!", attacker, victim));
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(flags & AF_EAT) {
|
|
|
|
playSound(NULL, "hit-crush"+pick123());
|
|
|
|
addMessage(XLAT("%The1 eats %the2!", attacker, victim));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(attacker == moLancer) {
|
|
|
|
playSound(NULL, "hit-rose");
|
|
|
|
addMessage(XLAT("%The1 pierces %the2!", attacker, victim));
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(attacker == moEarthElemental) {
|
|
|
|
playSound(NULL, "hit-crush"+pick123());
|
|
|
|
addMessage(XLAT("%The1 punches %the2!", attacker, victim));
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(attacker == moPlayer) {
|
|
|
|
if(flags & (AF_SWORD | AF_SWORD_INTO)) {
|
|
|
|
playSound(NULL, "hit-axe"+pick123());
|
|
|
|
addMessage(XLAT("You slash %the1.", victim));
|
|
|
|
if(victim == moGoblin)
|
|
|
|
achievement_gain("GOBLINSWORD");
|
|
|
|
}
|
|
|
|
else if(victim == moKrakenT || victim == moDragonTail || victim == moDragonHead) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("You hit %the1.", victim)); // normal
|
|
|
|
}
|
|
|
|
else if(stun && victim == moVizier) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("You hit %the1.", victim)); // normal
|
|
|
|
}
|
|
|
|
else if(stun) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("You stun %the1.", victim)); // normal
|
|
|
|
}
|
|
|
|
else if(isNonliving(victim)) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("You destroy %the1.", victim)); // normal
|
|
|
|
}
|
|
|
|
else if(flags & AF_STAB) {
|
|
|
|
playSound(NULL, "hit-axe"+pick123());
|
|
|
|
addMessage(XLAT("You stab %the1.", victim)); // normal
|
|
|
|
}
|
|
|
|
else if(flags & AF_APPROACH) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
if(victim == moLancer)
|
|
|
|
addMessage(XLAT("You trick %the1.", victim)); // normal
|
|
|
|
else
|
|
|
|
addMessage(XLAT("You pierce %the1.", victim)); // normal
|
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
else if(!peace::on) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("You kill %the1.", victim)); // normal
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
if(victim == moKrakenT || victim == moDragonTail || victim == moDragonHead) {
|
|
|
|
playSound(NULL, "hit-crush"+pick123());
|
|
|
|
addMessage(XLAT("%The1 hits %the2.", attacker, victim)); // normal
|
|
|
|
}
|
|
|
|
else if(stun && victim == moVizier) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("%The1 hits %the2.", attacker, victim)); // normal
|
|
|
|
}
|
|
|
|
else if(stun) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("%The1 attacks %the2!", attacker, victim)); // normal
|
|
|
|
}
|
|
|
|
else if(isNonliving(victim)) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("%The1 destroys %the2!", attacker, victim)); // normal
|
|
|
|
}
|
|
|
|
else if(flags & AF_STAB) {
|
|
|
|
playSound(NULL, "hit-axe"+pick123());
|
|
|
|
addMessage(XLAT("%The1 stabs %the2.", attacker, victim));
|
|
|
|
}
|
|
|
|
else if(flags & AF_APPROACH) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("%The1 tricks %the2.", attacker, victim));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
addMessage(XLAT("%The1 kills %the2!", attacker, victim));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void fallMonster(cell *c, flagtype flags) {
|
|
|
|
attackMonster(c, flags, moNone);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool notthateasy(eMonster m) {
|
|
|
|
return
|
|
|
|
isMultitile(m) || isStunnable(m) || m == moDraugr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool attackMonster(cell *c, flagtype flags, eMonster killer) {
|
|
|
|
|
|
|
|
if((flags & AF_GETPLAYER) && isPlayerOn(c)) {
|
|
|
|
killThePlayerAt(killer, c, flags);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
eMonster m = c->monst;
|
|
|
|
int tk = tkills();
|
|
|
|
|
|
|
|
int tkt = killtypes();
|
|
|
|
|
|
|
|
bool dostun = (flags & AF_ORSTUN) && attackJustStuns(c);
|
|
|
|
|
|
|
|
if((flags & AF_HORNS) && hornStuns(c)) dostun = true;
|
2017-06-18 16:51:46 +00:00
|
|
|
if((flags & AF_BULL) && c->monst == moVizier && c->hitpoints > 1) {
|
|
|
|
dostun = true;
|
|
|
|
c->stuntime = 2;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(c->monst == moSkeleton && (flags & AF_SWORD)) dostun = false;
|
|
|
|
|
|
|
|
bool eu = elementalUnlocked();
|
|
|
|
bool tu = trollUnlocked();
|
|
|
|
|
|
|
|
if(flags & AF_MSG) fightmessage(m, killer, dostun, flags);
|
|
|
|
if(dostun)
|
|
|
|
stunMonster(c);
|
|
|
|
else
|
|
|
|
killMonster(c, killer, flags);
|
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
if(peace::on) return false;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int ntk = tkills();
|
|
|
|
int ntkt = killtypes();
|
|
|
|
|
|
|
|
if(tkt < 20 && ntkt >= 20) {
|
|
|
|
addMessage(XLAT("You hear a distant roar!"));
|
|
|
|
playSound(NULL, "message-roar");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tk == 0 && ntk > 0 && !tactic::on && !euclid && !sphere) {
|
|
|
|
if(notthateasy(m))
|
|
|
|
addMessage(XLAT("Quite tough, for your first fight."));
|
|
|
|
else
|
|
|
|
addMessage(XLAT("That was easy, but groups could be dangerous."));
|
|
|
|
}
|
|
|
|
|
2017-07-12 16:03:53 +00:00
|
|
|
if(tk < 10 && ntk >= 10 && !tactic::on && !euclid && !sphere && !inv::on)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("Good to know that your fighting skills serve you well in this strange world."));
|
|
|
|
|
2017-07-12 16:03:53 +00:00
|
|
|
if(tk < R100/2 && ntk >= R100/2 && !euclid && !sphere)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You wonder where all these monsters go, after their death..."));
|
|
|
|
|
2017-07-12 16:03:53 +00:00
|
|
|
if(tk < R100 && ntk >= R100 && !euclid && !sphere)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You feel that the souls of slain enemies pull you to the Graveyard..."));
|
|
|
|
|
|
|
|
if(!tu && trollUnlocked()) {
|
|
|
|
playSound(c, "message-troll");
|
|
|
|
addMessage(XLAT("%The1 says, \"I die, but my clan in Trollheim will avenge me!\"", m));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!eu && elementalUnlocked())
|
|
|
|
addMessage(XLAT("After killing %the1, you feel able to reach the Elemental Planes!", m));
|
|
|
|
|
|
|
|
if(m == moVizier && c->monst != moVizier && kills[moVizier] == 1) {
|
|
|
|
addMessage(XLAT("Hmm, he has been training in the Emerald Mine. Interesting..."));
|
|
|
|
princess::forceMouse = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m == moIvyRoot && ntk>tk)
|
|
|
|
achievement_gain("IVYSLAYER");
|
|
|
|
|
|
|
|
return ntk > tk;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pushMonster(cell *ct, cell *cf) {
|
|
|
|
moveMonster(ct, cf);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool destroyHalfvine(cell *c, eWall newwall, int tval) {
|
|
|
|
if(cellHalfvine(c)) {
|
|
|
|
for(int t=0; t<c->type; t++) if(c->mov[t]->wall == c->wall) {
|
|
|
|
if(newwall == waPartialFire) flameHalfvine(c->mov[t], tval);
|
|
|
|
else if(newwall == waRed1) c->mov[t]->wall = waVinePlant;
|
|
|
|
else c->mov[t]->wall = newwall;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
if(newwall == waPartialFire) flameHalfvine(c, tval);
|
2015-08-08 13:57:52 +00:00
|
|
|
else c->wall = newwall;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int coastvalEdge(cell *c) { return coastval(c, laIvoryTower); }
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int gravityLevel(cell *c) {
|
|
|
|
if(c->land == laIvoryTower || c->land == laEndorian)
|
|
|
|
return coastval(c, laIvoryTower);
|
|
|
|
if(c->land == laDungeon)
|
|
|
|
return -coastval(c, laIvoryTower);
|
|
|
|
if(c->land == laMountain)
|
|
|
|
return 1-celldistAlt(c);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool canUnstable(eWall w, flagtype flags) {
|
|
|
|
return w == waNone || w == waCanopy || w == waOpenPlate || w == waClosePlate ||
|
|
|
|
w == waOpenGate || ((flags & MF_STUNNED) && (w == waLadder || w == waTrunk || w == waSolidBranch || w == waWeakBranch
|
|
|
|
|| w == waBigBush || w == waSmallBush));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cellEdgeUnstable(cell *c, flagtype flags) {
|
|
|
|
if(!isGravityLand(c->land) || !canUnstable(c->wall, flags)) return false;
|
|
|
|
int d = gravityLevel(c);
|
|
|
|
for(int i=0; i<c->type; i++) if(c->mov[i]) {
|
|
|
|
if(isAnyIvy(c->mov[i]->monst) &&
|
|
|
|
c->land == laMountain && !(flags & MF_IVY)) return false;
|
|
|
|
if(gravityLevel(c->mov[i]) == d-1) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(againstWind(c->mov[i], c)) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!passable(c->mov[i], NULL, P_MONSTER | P_DEADLY))
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
if(isWorm(c->mov[i]))
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// find worms and ivies
|
|
|
|
void settemp(cell *c) {
|
|
|
|
temps.push_back(c); tempval.push_back(c->monst); c->monst = moNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void findWormIvy(cell *c) {
|
|
|
|
while(true) {
|
|
|
|
if(c->monst == moWorm || c->monst == moTentacle || c->monst == moWormwait || c->monst == moTentaclewait ||
|
|
|
|
c->monst == moTentacleEscaping) {
|
|
|
|
worms.push_back(c); settemp(c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if(c->monst == moHexSnake) {
|
|
|
|
hexsnakes.push_back(c); settemp(c);
|
|
|
|
}
|
|
|
|
else if(c->monst == moWormtail || c->monst == moHexSnakeTail) {
|
|
|
|
bool bug = true;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell* c2 = c->mov[i];
|
|
|
|
if(c2 && isWorm(c2) && c2->mov[c2->mondir] == c) {
|
|
|
|
settemp(c);
|
|
|
|
c = c2;
|
|
|
|
bug = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(bug) break;
|
|
|
|
}
|
|
|
|
else if(c->monst == moIvyWait) {
|
|
|
|
cell* c2 = c->mov[c->mondir];
|
|
|
|
settemp(c); c=c2;
|
|
|
|
}
|
|
|
|
else if(c->monst == moIvyHead) {
|
|
|
|
ivies.push_back(c); settemp(c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if(c->monst == moIvyBranch || c->monst == moIvyRoot) {
|
|
|
|
bool bug = true;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell* c2 = c->mov[i];
|
|
|
|
if(c2 && (c2->monst == moIvyHead || c2->monst == moIvyBranch) && c2->mov[c2->mondir] == c) {
|
|
|
|
settemp(c);
|
|
|
|
c = c2;
|
|
|
|
bug = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(bug) break;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else break;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
bool bugsfighting;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool keepLightning = false;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int statuecount;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int tidalphase;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int tidalsize, tide[200];
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void calcTidalPhase() {
|
|
|
|
if(!tidalsize) {
|
|
|
|
for(int i=0; i<5; i++) tide[tidalsize++] = 1;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=1; i<4; i++) for(int j=0; j<3; j++)
|
|
|
|
tide[tidalsize++] = i;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=4; i<7; i++) for(int j=0; j<2; j++)
|
|
|
|
tide[tidalsize++] = i;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=7; i<20; i++)
|
|
|
|
tide[tidalsize++] = i;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=20; i<23; i++) for(int j=0; j<2; j++)
|
|
|
|
tide[tidalsize++] = i;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=23; i<26; i++) for(int j=0; j<3; j++)
|
|
|
|
tide[tidalsize++] = i;
|
|
|
|
|
|
|
|
for(int i=0; i+i<tidalsize; i++) tide[tidalsize++] = 27 - tide[i];
|
|
|
|
|
|
|
|
/* printf("tidalsize = %d\n", tidalsize);
|
|
|
|
for(int i=0; i<tidalsize; i++) printf("%d ", tide[i]);
|
|
|
|
printf("\n"); */
|
|
|
|
}
|
|
|
|
tidalphase = tide[
|
|
|
|
(shmup::on ? shmup::curtime/600 : turncount)
|
|
|
|
% tidalsize];
|
2017-07-04 13:38:33 +00:00
|
|
|
if(peace::on)
|
|
|
|
tidalphase = 5 + tidalphase / 6;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int tidespeed() {
|
|
|
|
return tide[(turncount+6) % tidalsize] - tidalphase;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool recalcTide;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
#define SEADIST LHU.bytes[0]
|
|
|
|
#define LANDDIST LHU.bytes[1]
|
|
|
|
#define CHAOSPARAM LHU.bytes[2]
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void checkTide(cell *c) {
|
|
|
|
if(c->land == laOcean) {
|
|
|
|
int t = c->landparam;
|
|
|
|
|
|
|
|
if(chaosmode) {
|
|
|
|
char& csd(c->SEADIST); if(csd == 0) csd = 7;
|
|
|
|
char& cld(c->LANDDIST); if(cld == 0) cld = 7;
|
|
|
|
int seadist=csd, landdist=cld;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(!c2) continue;
|
|
|
|
if(c2->land == laBarrier || c2->land == laOceanWall) ;
|
|
|
|
else if(c2->land == laOcean)
|
|
|
|
seadist = min(seadist, c2->SEADIST ? c2->SEADIST+1 : 7),
|
|
|
|
landdist = min(landdist, c2->LANDDIST ? c2->LANDDIST+1 : 7);
|
|
|
|
else if(isSealand(c2->land)) seadist = 1;
|
|
|
|
else landdist = 1;
|
|
|
|
}
|
|
|
|
if(seadist < csd) csd = seadist, recalcTide = true;
|
|
|
|
if(landdist < cld) cld = landdist, recalcTide = true;
|
|
|
|
if(seadist == 1 && landdist == 1) t = 15;
|
|
|
|
else t = c->CHAOSPARAM = 1 + (29 * (landdist-1)) / (seadist+landdist-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c->wall == waStrandedBoat || c->wall == waBoat)
|
|
|
|
c->wall = t >= tidalphase ? waBoat : waStrandedBoat;
|
|
|
|
if(c->wall == waSea || c->wall == waNone)
|
|
|
|
c->wall = t >= tidalphase ? waSea : waNone;
|
|
|
|
if(isFire(c) && t >= tidalphase)
|
|
|
|
c->wall = waSea;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void buildAirmap() {
|
|
|
|
for(int k=0; k<size(airmap); k++) {
|
|
|
|
int d = airmap[k].second;
|
|
|
|
if(d == 2) break;
|
|
|
|
cell *c = airmap[k].first;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(!c2) continue;
|
|
|
|
if(!passable(c2, c, P_BLOW | P_MONSTER)) continue;
|
|
|
|
if(!passable(c, c2, P_BLOW | P_MONSTER)) continue;
|
|
|
|
airmap.push_back(make_pair(c2, d+1));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
sort(airmap.begin(), airmap.end());
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
map<cell*, int> rosemap;
|
|
|
|
// rosemap&3:
|
|
|
|
// 0 - wave not reached
|
|
|
|
// 1 - wave expanding
|
|
|
|
// 2 - wave phase 1
|
|
|
|
// 3 - wave phase 2
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int rosedist(cell *c) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!(havewhat&HF_ROSE)) return 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
int&r (rosemap[c]);
|
|
|
|
if((r&7) == 7) return 0;
|
|
|
|
if(r&3) return (r&3)-1;
|
|
|
|
return 0;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool againstRose(cell *cfrom, cell *cto) {
|
|
|
|
if(rosedist(cfrom) != 1) return false;
|
|
|
|
if(cto && rosedist(cto) == 2) return false;
|
|
|
|
return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool withRose(cell *cfrom, cell *cto) {
|
|
|
|
if(rosedist(cfrom) != 1) return false;
|
|
|
|
if(rosedist(cto) != 2) return false;
|
|
|
|
return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void buildRosemap() {
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
rosephase++; rosephase &= 7;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if((havewhat&HF_ROSE) && !rosephase) {
|
2016-08-26 09:58:03 +00:00
|
|
|
rosewave++;
|
|
|
|
for(int k=0; k<size(dcal); k++) {
|
|
|
|
cell *c = dcal[k];
|
|
|
|
if(c->wall == waRose && c->cpdist <= 5)
|
|
|
|
rosemap[c] = rosewave * 8 + 2;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(map<cell*, int>::iterator it = rosemap.begin(); it != rosemap.end(); it++) {
|
|
|
|
cell *c = it->first;
|
|
|
|
int r = it->second;
|
|
|
|
if(r < (rosewave) * 8) continue;
|
|
|
|
if((r&7) == 2) if(c->wall == waRose || !isWall(c)) for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(!c2) continue;
|
|
|
|
// if(snakelevel(c2) <= snakelevel(c) - 2) continue;
|
|
|
|
if(!passable(c2, c, P_BLOW | P_MONSTER | P_ROSE)) continue;
|
|
|
|
int& r2 = rosemap[c2];
|
|
|
|
if(r2 < r) r2 = r-1;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(map<cell*, int>::iterator it = rosemap.begin(); it != rosemap.end(); it++) {
|
|
|
|
int& r = it->second;
|
|
|
|
if((r&7) == 1 || (r&7) == 2 || (r&7) == 3) r++;
|
|
|
|
if(airdist(it->first) < 3 || whirlwind::cat(it->first)) r |= 7;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int getDistLimit() { return purehepta?5:7; }
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool nogoSlow(cell *to, cell *from) {
|
|
|
|
if(cellEdgeUnstable(to) && gravityLevel(to) >= gravityLevel(from)) return true;
|
|
|
|
if(cellUnstable(to)) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// pathdist begin
|
|
|
|
void computePathdist(eMonster param) {
|
|
|
|
int pqs = size(pathq);
|
|
|
|
for(int i=0; i<pqs; i++) pathq[i]->pathdist = PINFD;
|
|
|
|
pathq.clear();
|
|
|
|
pathqm.clear();
|
|
|
|
reachedfrom.clear();
|
|
|
|
|
|
|
|
for(int i=0; i<size(targets); i++) {
|
|
|
|
pathq.push_back(targets[i]);
|
|
|
|
targets[i]->pathdist = isPlayerOn(targets[i]) ? 0 : 1;
|
|
|
|
reachedfrom.push_back(hrand(targets[i]->type));
|
|
|
|
}
|
|
|
|
|
|
|
|
int qtarg = size(targets);
|
|
|
|
|
|
|
|
for(int qb=0; qb < size(pathq); qb++) {
|
|
|
|
int fd = reachedfrom[qb] + 3;
|
|
|
|
cell *c = pathq[qb];
|
|
|
|
if(c->monst && !isBug(c) && !(isFriendly(c) && !c->stuntime)) {
|
|
|
|
pathqm.push_back(c);
|
|
|
|
continue; // no paths going through monsters
|
|
|
|
}
|
|
|
|
for(int i=0; i<numplayers(); i++) {
|
|
|
|
cell *pc = playerpos(i);
|
|
|
|
if(!pc) continue;
|
|
|
|
if(c->monst && c != pc && getMount(i) && !isDragon(c->monst) && sameMonster(c, pc)) {
|
|
|
|
// don't treat the Worm you are riding as passable
|
|
|
|
pathqm.push_back(c);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(c->cpdist > 7 && !(c->land == laTrollheim && turncount < c->landparam)) continue;
|
|
|
|
int d = c->pathdist;
|
|
|
|
if(d == PINFD - 1) continue;
|
|
|
|
for(int j=0; j<c->type; j++) {
|
|
|
|
int i = (fd+j) % c->type;
|
|
|
|
// printf("i=%d cd=%d\n", i, c->mov[i]->cpdist);
|
|
|
|
|
|
|
|
if(c->mov[i] && c->mov[i]->pathdist == PINFD &&
|
|
|
|
passable(c->mov[i], (qb<qtarg) && !nonAdjacent(c,c->mov[i]) && !thruVine(c,c->mov[i]) ?NULL:c, P_MONSTER | P_REVDIR)) {
|
|
|
|
|
|
|
|
if(qb >= qtarg) {
|
|
|
|
if(param == moTortoise && nogoSlow(c, c->mov[i])) continue;
|
|
|
|
if(param == moIvyRoot && strictlyAgainstGravity(c, c->mov[i], false, MF_IVY)) continue;
|
|
|
|
if(param == moWorm && (cellUnstable(c) || cellEdgeUnstable(c))) continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->mov[i]->pathdist = d+1;
|
|
|
|
pathq.push_back(c->mov[i]); reachedfrom.push_back(c->spn(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// pathdist end
|
|
|
|
|
|
|
|
vector<pair<cell*, int> > butterflies;
|
|
|
|
|
|
|
|
void addButterfly(cell *c) {
|
|
|
|
for(int i=0; i<size(butterflies); i++)
|
|
|
|
if(butterflies[i].first == c) {
|
|
|
|
butterflies[i].second = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
butterflies.push_back(make_pair(c, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate cpdist, 'have' flags, and do general fixings
|
2016-08-26 09:58:03 +00:00
|
|
|
void bfs() {
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
calcTidalPhase();
|
|
|
|
|
|
|
|
yendor::onpath();
|
|
|
|
|
|
|
|
int dcs = size(dcal);
|
|
|
|
for(int i=0; i<dcs; i++) dcal[i]->cpdist = INFD;
|
2017-07-22 23:33:27 +00:00
|
|
|
worms.clear(); ivies.clear(); ghosts.clear(); golems.clear();
|
2016-08-26 09:58:03 +00:00
|
|
|
temps.clear(); tempval.clear(); targets.clear();
|
|
|
|
statuecount = 0;
|
|
|
|
hexsnakes.clear();
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
hadwhat = havewhat;
|
|
|
|
havewhat = 0;
|
|
|
|
if(!(hadwhat & HF_WARP)) { avengers = 0; }
|
2017-07-22 23:33:27 +00:00
|
|
|
if(!(hadwhat & HF_MIRROR)) { mirrorspirits = 0; }
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
elec::havecharge = false;
|
2017-03-23 10:53:57 +00:00
|
|
|
elec::afterOrb = false;
|
|
|
|
elec::haveelec = false;
|
2016-08-26 09:58:03 +00:00
|
|
|
airmap.clear();
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!(hadwhat & HF_ROSE)) rosemap.clear();
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
dcal.clear(); reachedfrom.clear();
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
recalcTide = false;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<numplayers(); i++) {
|
|
|
|
cell *c = playerpos(i);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!c) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->cpdist == 0) continue;
|
|
|
|
c->cpdist = 0;
|
|
|
|
checkTide(c);
|
|
|
|
dcal.push_back(c);
|
|
|
|
reachedfrom.push_back(hrand(c->type));
|
|
|
|
if(!invismove) targets.push_back(c);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int distlimit = getDistLimit();
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<numplayers(); i++) {
|
|
|
|
cell *c = playerpos(i);
|
|
|
|
if(!c) continue;
|
|
|
|
if(getMount(i) && (c->monst == moTentacle || c->monst == moTentaclewait || c->monst == moTentacleEscaping))
|
|
|
|
worms.push_back(c);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int qb = 0;
|
|
|
|
while(true) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(qb == size(dcal)) break;
|
2016-08-26 09:58:03 +00:00
|
|
|
int i, fd = reachedfrom[qb] + 3;
|
|
|
|
cell *c = dcal[qb++];
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int d = c->cpdist;
|
|
|
|
if(d == distlimit) { first7 = qb; break; }
|
|
|
|
for(int j=0; j<c->type; j++) if(i = (fd+j) % c->type, c->mov[i]) {
|
|
|
|
// printf("i=%d cd=%d\n", i, c->mov[i]->cpdist);
|
|
|
|
cell *c2 = c->mov[i];
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!c2) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isWarped(c2->land)) havewhat |= HF_WARP;
|
2017-07-22 23:33:27 +00:00
|
|
|
if(c2->land == laMirror) havewhat |= HF_MIRROR;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if((c->wall == waBoat || c->wall == waSea) &&
|
|
|
|
(c2->wall == waSulphur || c2->wall == waSulphurC))
|
|
|
|
c2->wall = waSea;
|
|
|
|
|
|
|
|
if(c2 && signed(c2->cpdist) > d+1) {
|
|
|
|
c2->cpdist = d+1;
|
|
|
|
|
|
|
|
// remove treasures
|
2017-07-04 13:38:33 +00:00
|
|
|
if(!peace::on && c2->item && c2->cpdist == distlimit && itemclass(c2->item) == IC_TREASURE &&
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->item != itBabyTortoise &&
|
2017-03-23 10:53:57 +00:00
|
|
|
(items[c2->item] >= (chaosmode?10:20) + currentLocalTreasure || getGhostcount() >= 2)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->item = itNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->land == laMinefield) { c2->landparam &= ~3; }
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->item == itBombEgg && c2->cpdist == distlimit && items[itBombEgg] >= c2->landparam) {
|
|
|
|
c2->item = itNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
c2->landparam |= 2;
|
|
|
|
c2->landparam &= ~1;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!c2->monst) c2->monst = moBomberbird;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->item == itBarrow && c2->cpdist == distlimit && c2->wall != waBarrowDig) {
|
|
|
|
c2->item = itNone;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->item == itLotus && c2->cpdist == distlimit && items[itLotus] >= getHauntedDepth(c2)) {
|
|
|
|
c2->item = itNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->item == itMutant2 && timerghost) {
|
2016-08-26 09:58:03 +00:00
|
|
|
bool rotten = true;
|
|
|
|
for(int i=0; i<c2->type; i++)
|
|
|
|
if(c2->mov[i] && c2->mov[i]->monst == moMutant)
|
|
|
|
rotten = false;
|
|
|
|
if(rotten) c2->item = itNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c2->item == itDragon && (shmup::on ? shmup::curtime-c2->landparam>300000 :
|
|
|
|
turncount-c2->landparam > 500))
|
|
|
|
c2->item = itNone;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->item == itTrollEgg && c2->cpdist == distlimit && !shmup::on && c2->landparam && turncount-c2->landparam > 650)
|
|
|
|
c2->item = itNone;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->item == itMutant && c2->cpdist == distlimit && items[itMutant] >= c2->landparam) {
|
|
|
|
c2->item = itNone;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->item == itIvory && c2->cpdist == distlimit && items[itIvory] >= c2->landparam) {
|
|
|
|
c2->item = itNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c2->item == itAmethyst && c2->cpdist == distlimit && items[itAmethyst] >= -celldistAlt(c2)/5) {
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->item = itNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!keepLightning) c2->ligon = 0;
|
|
|
|
dcal.push_back(c2);
|
2017-03-23 10:53:57 +00:00
|
|
|
reachedfrom.push_back(c->spn(i));
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
checkTide(c2);
|
|
|
|
|
|
|
|
if(c2->wall == waBigStatue && c2->land != laTemple)
|
|
|
|
statuecount++;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(cellHalfvine(c2) && isWarped(c2)) {
|
|
|
|
addMessage(XLAT("%The1 is destroyed!", c2->wall));
|
|
|
|
destroyHalfvine(c2);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(c2->wall == waCharged) elec::havecharge = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->land == laStorms) elec::haveelec = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->land == laWhirlpool) havewhat |= HF_WHIRLPOOL;
|
|
|
|
if(c2->land == laWhirlwind) havewhat |= HF_WHIRLWIND;
|
|
|
|
if(c2->land == laPrairie) havewhat |= HF_RIVER;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->wall == waRose) havewhat |= HF_ROSE;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if((hadwhat & HF_ROSE) && (rosemap[c2] & 3)) havewhat |= HF_ROSE;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(c2->monst) {
|
|
|
|
if(isHaunted(c2->land) &&
|
|
|
|
c2->monst != moGhost && c2->monst != moZombie && c2->monst != moNecromancer)
|
|
|
|
survivalist = false;
|
|
|
|
if(c2->monst == moHexSnake || c2->monst == moHexSnakeTail) {
|
2017-03-23 10:53:57 +00:00
|
|
|
havewhat |= HF_HEX;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->monst == moHexSnake) hexsnakes.push_back(c2);
|
|
|
|
else findWormIvy(c2);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c2->monst == moKrakenT || c2->monst == moKrakenH) {
|
|
|
|
havewhat |= HF_KRAKEN;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->monst == moDragonHead || c2->monst == moDragonTail) {
|
2017-03-23 10:53:57 +00:00
|
|
|
havewhat |= HF_DRAGON;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c2->monst == moWitchSpeed)
|
|
|
|
havewhat |= HF_FAST;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->monst == moMutant)
|
2017-03-23 10:53:57 +00:00
|
|
|
havewhat |= HF_MUTANT;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->monst == moOutlaw)
|
2017-03-23 10:53:57 +00:00
|
|
|
havewhat |= HF_OUTLAW;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(isGhostMover(c2->monst))
|
|
|
|
ghosts.push_back(c2);
|
|
|
|
else if(isWorm(c2) || isIvy(c2)) findWormIvy(c2);
|
|
|
|
else if(isBug(c2)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
havewhat |= HF_BUG;
|
2016-08-26 09:58:03 +00:00
|
|
|
targets.push_back(c2);
|
|
|
|
}
|
|
|
|
else if(isFriendly(c2)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->monst != moMouse && !markEmpathy(itOrbInvis) &&
|
|
|
|
!c2->stuntime) targets.push_back(c2);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->monst == moGolem) golems.push_back(c2);
|
|
|
|
if(c2->monst == moFriendlyGhost) golems.push_back(c2);
|
|
|
|
if(c2->monst == moKnight) golems.push_back(c2);
|
|
|
|
if(c2->monst == moTameBomberbird) golems.push_back(c2);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->monst == moMouse) { golems.push_back(c2); havewhat |= HF_MOUSE; }
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->monst == moPrincess || c2->monst == moPrincessArmed) golems.push_back(c2);
|
|
|
|
if(c2->monst == moIllusion) {
|
|
|
|
if(items[itOrbIllusion]) items[itOrbIllusion]--;
|
|
|
|
else c2->monst = moNone;
|
|
|
|
}
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c2->monst == moButterfly) {
|
|
|
|
addButterfly(c2);
|
|
|
|
}
|
|
|
|
else if(isAngryBird(c2->monst)) {
|
|
|
|
havewhat |= HF_BIRD;
|
|
|
|
if(c2->monst == moBat) havewhat |= HF_BATS | HF_EAGLES;
|
|
|
|
if(c2->monst == moEagle) havewhat |= HF_EAGLES;
|
|
|
|
}
|
|
|
|
else if(c2->monst == moReptile) havewhat |= HF_REPTILE;
|
|
|
|
else if(isLeader(c2->monst)) havewhat |= HF_LEADER;
|
|
|
|
else if(c2->monst == moEarthElemental) havewhat |= HF_EARTH;
|
|
|
|
else if(c2->monst == moWaterElemental) havewhat |= HF_WATER;
|
|
|
|
else if(c2->monst == moShark || c2->monst == moCShark) havewhat |= HF_SHARK;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->monst == moAirElemental)
|
2017-03-23 10:53:57 +00:00
|
|
|
havewhat |= HF_AIR, airmap.push_back(make_pair(c2,0));
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
// pheromones!
|
|
|
|
if(c2->land == laHive && c2->landparam >= 50 && c2->wall != waWaxWall)
|
2017-03-23 10:53:57 +00:00
|
|
|
havewhat |= HF_BUG;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->wall == waThumperOn)
|
|
|
|
targets.push_back(c2);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
while(recalcTide) {
|
|
|
|
recalcTide = false;
|
|
|
|
for(int i=0; i<size(dcal); i++) checkTide(dcal[i]);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int qtemp = size(temps);
|
|
|
|
for(int i=0; i<qtemp; i++) temps[i]->monst = tempval[i];
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
buildAirmap();
|
|
|
|
|
|
|
|
if(overgenerate) doOvergenerate();
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool makeEmpty(cell *c) {
|
|
|
|
if(c->monst != moPrincess) {
|
|
|
|
if(isAnyIvy(c->monst)) killMonster(c, moPlayer, 0);
|
|
|
|
else if(isWorm(c->monst)) {
|
|
|
|
if(!items[itOrbDomination]) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else c->monst = moNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->land == laCocytus)
|
|
|
|
c->wall = waFrozenLake;
|
|
|
|
else if(c->land == laAlchemist || c->land == laCanvas)
|
|
|
|
;
|
|
|
|
else if(c->land == laCaves || c->land == laEmerald)
|
|
|
|
c->wall = waCavefloor;
|
|
|
|
else if(c->land == laDeadCaves)
|
|
|
|
c->wall = waDeadfloor2;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c->land == laCaribbean || c->land == laOcean || c->land == laWhirlpool || c->land == laLivefjord || c->land == laWarpSea || c->land == laKraken)
|
2016-08-26 09:58:03 +00:00
|
|
|
c->wall = waBoat; // , c->item = itOrbYendor;
|
|
|
|
else if(c->land == laMinefield)
|
|
|
|
c->wall = waMineOpen;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c->wall == waFan && sphere)
|
|
|
|
;
|
|
|
|
else if(c->wall == waOpenPlate && sphere)
|
|
|
|
;
|
|
|
|
else if(c->wall == waGiantRug)
|
|
|
|
;
|
|
|
|
else if(c->wall == waFreshGrave && (sphere || quotient))
|
|
|
|
;
|
|
|
|
else if(isReptile(c->wall))
|
|
|
|
c->wparam = reptilemax();
|
|
|
|
else if(c->wall == waAncientGrave && sphere)
|
|
|
|
;
|
2016-08-26 09:58:03 +00:00
|
|
|
else
|
|
|
|
c->wall = waNone;
|
|
|
|
c->item = itNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->land == laWildWest) {
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
cell *c2 = c->mov[i];
|
|
|
|
if(c2) for(int j=0; j<c->type; j++) {
|
|
|
|
cell *c3 = c2->mov[j];
|
|
|
|
if(c3) c3->wall = waNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
return true;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int numgates = 0;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void toggleGates(cell *ct, eWall type, int rad) {
|
|
|
|
if(!ct) return;
|
|
|
|
if(ct->wall == waOpenGate && type == waClosePlate) {
|
|
|
|
bool onWorm = false;
|
|
|
|
if(isWorm(ct)) onWorm = true;
|
|
|
|
for(int i=0; i<ct->type; i++)
|
|
|
|
if(ct->mov[i] && ct->mov[i]->wall == waOpenGate && isWorm(ct->mov[i])) onWorm = true;
|
|
|
|
if(!onWorm) {
|
2017-03-23 10:53:57 +00:00
|
|
|
ct->wall = waClosedGate, numgates++;
|
|
|
|
if(rad<1) rad=1;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(ct->item) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(ct, "hit-crush"+pick123());
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("%The1 is crushed!", ct->item));
|
|
|
|
ct->item = itNone;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(ct->wall == waClosedGate && type == waOpenPlate)
|
2017-03-23 10:53:57 +00:00
|
|
|
ct->wall = waOpenGate, rad = 1, numgates++;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(rad) for(int i=0; i<ct->type; i++)
|
|
|
|
toggleGates(ct->mov[i], type, rad-1);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void toggleGates(cell *ct, eWall type) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(ct, "click");
|
|
|
|
numgates = 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(type == waClosePlate && purehepta)
|
|
|
|
toggleGates(ct, type, 2);
|
|
|
|
else
|
|
|
|
toggleGates(ct, type, 3);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(numgates && type == waClosePlate)
|
|
|
|
playSound(ct, "closegate");
|
|
|
|
if(numgates && type == waOpenPlate)
|
|
|
|
playSound(ct, "opengate");
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void destroyWeakBranch(cell *cf, cell *ct, eMonster who) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(cf && ct && cf->wall == waWeakBranch && cellEdgeUnstable(ct) &&
|
2017-03-23 10:53:57 +00:00
|
|
|
gravityLevel(ct) >= gravityLevel(cf) && !ignoresPlates(who)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
cf->wall = waCanopy;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!cellEdgeUnstable(cf)) { cf->wall = waWeakBranch; return; }
|
|
|
|
playSound(cf, "trapdoor");
|
|
|
|
drawParticles(cf, winf[waWeakBranch].color, 4);
|
|
|
|
}
|
|
|
|
if(cf && ct && cf->wall == waSmallBush && cellEdgeUnstable(ct) &&
|
|
|
|
gravityLevel(ct) >= gravityLevel(cf) && !ignoresPlates(who)) {
|
|
|
|
cf->wall = waNone;
|
|
|
|
if(!cellEdgeUnstable(cf)) { cf->wall = waSmallBush; return; }
|
|
|
|
playSound(cf, "trapdoor");
|
|
|
|
drawParticles(cf, winf[waWeakBranch].color, 4);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// effect of moving monster m from cf to ct
|
|
|
|
// this is called from moveMonster, or separately from moveIvy/moveWorm,
|
|
|
|
// or when a dead bird falls (then m == moDeadBird)
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveEffect(cell *ct, cell *cf, eMonster m) {
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(cf) destroyWeakBranch(cf, ct, m);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
mayExplodeMine(ct, m);
|
|
|
|
|
|
|
|
if(ct->wall == waMineUnknown && !ct->item && !ignoresPlates(m))
|
|
|
|
ct->landparam |= 2; // mark as safe
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if((ct->wall == waClosePlate || ct->wall == waOpenPlate) && !ignoresPlates(m))
|
2016-08-26 09:58:03 +00:00
|
|
|
toggleGates(ct, ct->wall);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(cf && isPrincess(m)) princess::move(ct, cf);
|
|
|
|
|
|
|
|
if(cf && m == moTortoise) {
|
|
|
|
tortoise::emap[ct] = tortoise::get(cf);
|
|
|
|
tortoise::emap.erase(cf);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(cf && ct->item == itBabyTortoise && !cf->item) {
|
|
|
|
cf->item = itBabyTortoise;
|
|
|
|
ct->item = itNone;
|
|
|
|
tortoise::babymap[cf] = tortoise::babymap[ct];
|
|
|
|
tortoise::babymap.erase(ct);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void updateHi(eItem it, int v) {
|
|
|
|
if(!yendor::on)
|
|
|
|
if(v > hiitems[modecode()][it]) hiitems[modecode()][it] = v;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void gainItem(eItem it) {
|
|
|
|
int g = gold();
|
|
|
|
items[it]++; if(it != itLotus) updateHi(it, items[it]);
|
|
|
|
achievement_collection(it, gold(), g);
|
2017-03-23 10:53:57 +00:00
|
|
|
multi::treasures[multi::cpid]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
string itemcounter(int qty) {
|
|
|
|
string s = ""; s += " ("; s += its(qty); s += ")"; return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gainShard(cell *c2, const char *msg) {
|
|
|
|
invismove = false;
|
|
|
|
string s = XLAT(msg);
|
2017-07-22 23:33:27 +00:00
|
|
|
if(c2->land == laMirror && !peace::on) {
|
2017-03-23 10:53:57 +00:00
|
|
|
gainItem(itShard);
|
|
|
|
s += itemcounter(items[itShard]);
|
|
|
|
collectMessage(c2, itShard);
|
|
|
|
}
|
|
|
|
addMessage(s);
|
|
|
|
c2->wall = waNone;
|
|
|
|
invismove = false;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
void playerMoveEffects(cell *c1, cell *c2) {
|
|
|
|
|
|
|
|
if(peace::on) items[itOrbSword] = c2->land == laBurial ? 100 : 0;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
sword::angle[multi::cpid] = sword::shift(c1, c2, sword::angle[multi::cpid]);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
destroyWeakBranch(c1, c2, moPlayer);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool nomine = (c2->wall == waMineMine || c2->wall == waMineUnknown) && markOrb(itOrbAether);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!nomine) {
|
|
|
|
uncoverMines(c2,
|
|
|
|
items[itBombEgg] < 10 && hiitemsMax(itBombEgg) < 25 && !shmup::on ? 0 :
|
|
|
|
items[itBombEgg] < 20 ? 1 :
|
|
|
|
items[itBombEgg] < 30 ? 2 :
|
2017-03-23 10:53:57 +00:00
|
|
|
3, 0
|
2016-08-26 09:58:03 +00:00
|
|
|
);
|
2017-03-23 10:53:57 +00:00
|
|
|
mayExplodeMine(c2, moPlayer);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if((c2->wall == waClosePlate || c2->wall == waOpenPlate) && !markOrb(itOrbAether))
|
2016-08-26 09:58:03 +00:00
|
|
|
toggleGates(c2, c2->wall);
|
|
|
|
|
|
|
|
princess::playernear(c2);
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->wall == waGlass && items[itOrbAether] > ORBBASE+1) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("Your Aether powers are drained by %the1!", c2->wall));
|
2017-03-23 10:53:57 +00:00
|
|
|
drainOrb(itOrbAether, 2);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(cellUnstable(c2) && !markOrb(itOrbAether)) doesFallSound(c2);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(c2->wall == waStrandedBoat && markOrb(itOrbWater))
|
|
|
|
c2->wall = waBoat;
|
|
|
|
|
|
|
|
if(c2->land == laOcean && c2->wall == waBoat && c2->landparam < 30 && markOrb(itOrbWater))
|
|
|
|
c2->landparam = 40;
|
|
|
|
|
|
|
|
if((c2->land == laHauntedWall || c2->land == laHaunted) && !hauntedWarning) {
|
|
|
|
hauntedWarning = true;
|
|
|
|
addMessage(XLAT("You become a bit nervous..."));
|
|
|
|
addMessage(XLAT("Better not to let your greed make you stray from your path."));
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c2, "nervous");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void beastcrash(cell *c, cell *beast) {
|
|
|
|
if(c->wall == waPetrified || c->wall == waDeadTroll || c->wall == waDeadTroll2 ||
|
|
|
|
c->wall == waGargoyle) {
|
|
|
|
addMessage(XLAT("%The1 crashes into %the2!", beast->monst, c->wall));
|
|
|
|
c->wall = waNone;
|
|
|
|
}
|
|
|
|
else if(c->wall == waDeadwall || c->wall == waCavewall || c->wall == waSandstone ||
|
|
|
|
c->wall == waVinePlant || c->wall == waIcewall ||
|
|
|
|
c->wall == waMirror || c->wall == waCloud || c->wall == waBigTree || c->wall ==
|
|
|
|
waSmallTree || c->wall == waGlass || c->wall == waClosedGate || c->wall == waStone) {
|
|
|
|
addMessage(XLAT("%The1 crashes into %the2!", beast->monst, c->wall));
|
|
|
|
c->wall = waNone;
|
|
|
|
}
|
|
|
|
else if(cellHalfvine(c)) {
|
|
|
|
addMessage(XLAT("%The1 crashes into %the2!", beast->monst, c->wall));
|
|
|
|
destroyHalfvine(c);
|
|
|
|
}
|
|
|
|
else if(c->wall == waThumperOff) {
|
|
|
|
addMessage(XLAT("%The1 crashes into %the2!", beast->monst, c->wall));
|
|
|
|
c->wall = waThumperOn;
|
|
|
|
c->wparam = 100;
|
|
|
|
}
|
|
|
|
else if(isBull(c->monst)) {
|
|
|
|
addMessage(XLAT("%The1 crashes into %the2!", beast->monst, c->monst));
|
|
|
|
if(c->monst == moSleepBull) c->monst = moRagingBull, c->stuntime = 3;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void stayEffect(cell *c) {
|
|
|
|
eMonster m = c->monst;
|
|
|
|
if(m == moAirElemental) airmap.push_back(make_pair(c, 0));
|
|
|
|
if(m == moRagingBull && c->mondir != NODIR) {
|
|
|
|
playSound(NULL, "hit-axe"+pick123());
|
|
|
|
forCellIdEx(c2, d, c) {
|
|
|
|
bool opposite = angledist(c, d, c->mondir) >= 3;
|
|
|
|
if(opposite) beastcrash(c2, c);
|
|
|
|
}
|
|
|
|
c->mondir = NODIR; c->stuntime = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void makeTrollFootprints(cell *c) {
|
|
|
|
if(c->land != laTrollheim) return;
|
|
|
|
if(c->item == itTrollEgg && c->landparam) return;
|
|
|
|
c->landparam = turncount + 100;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveMonster(cell *ct, cell *cf) {
|
2017-03-23 10:53:57 +00:00
|
|
|
eMonster m = cf->monst;
|
|
|
|
bool fri = isFriendly(cf);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isDragon(m)) {
|
|
|
|
printf("called for Dragon\n");
|
|
|
|
return;
|
|
|
|
}
|
2017-07-22 23:33:27 +00:00
|
|
|
if(m != moMimic) animateMovement(cf, ct, LAYER_SMALL);
|
2017-03-23 10:53:57 +00:00
|
|
|
// the following line is necessary because otherwise plates disappear only inside the sight range
|
|
|
|
if(cellUnstable(cf) && !ignoresPlates(m)) cf->wall = waChasm;
|
2016-08-26 09:58:03 +00:00
|
|
|
moveEffect(ct, cf, m);
|
|
|
|
if(ct->wall == waCamelotMoat &&
|
|
|
|
(m == moShark || m == moCShark || m == moGreaterShark))
|
|
|
|
achievement_gain("MOATSHARK");
|
|
|
|
if(m == moTentacleGhost) {
|
|
|
|
cf->monst = moTentacletail;
|
|
|
|
m = moGhost;
|
|
|
|
}
|
|
|
|
else cf->monst = moNone;
|
|
|
|
if(ct->monst == moTentacletail && m == moGhost) {
|
|
|
|
ct->monst = moTentacleGhost;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ct->monst = m;
|
|
|
|
if(m == moWolf) ct->monst = moWolfMoved;
|
|
|
|
if(ct->monst != moTentacleGhost)
|
|
|
|
ct->mondir = neighborId(ct, cf);
|
|
|
|
}
|
|
|
|
ct->hitpoints = cf->hitpoints;
|
|
|
|
ct->stuntime = cf->stuntime;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(fri || isBug(m) || items[itOrbDiscord]) stabbingAttack(cf, ct, m);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(isLeader(m)) {
|
|
|
|
if(ct->wall == waBigStatue) {
|
|
|
|
ct->wall = cf->wall;
|
|
|
|
cf->wall = waBigStatue;
|
2017-03-23 10:53:57 +00:00
|
|
|
animateMovement(ct, cf, LAYER_BOAT);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
moveBoatIfUsingOne(ct, cf);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isTroll(m)) { makeTrollFootprints(ct); makeTrollFootprints(cf); }
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moEarthElemental) {
|
|
|
|
if(!passable(ct, cf, 0)) earthFloor(ct);
|
|
|
|
earthMove(cf, neighborId(cf, ct));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m == moWaterElemental) {
|
|
|
|
placeWater(ct, cf);
|
|
|
|
for(int i=0; i<ct->type; i++) {
|
|
|
|
cell *c2 = ct->mov[i];
|
|
|
|
if(!c2) continue;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->wall == waBoat && !(isPlayerOn(c2) && markOrb(itOrbWater))) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("%The1 is washed away!", c2->wall, moWaterElemental));
|
|
|
|
placeWater(c2, ct);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->wall == waStrandedBoat) {
|
|
|
|
addMessage(XLAT("%The1 is washed away!", c2->wall, moWaterElemental));
|
|
|
|
c2->wall = waNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->wall == waDeadTroll) {
|
|
|
|
addMessage(XLAT("%The1 is washed away!", c2->wall, moWaterElemental));
|
|
|
|
c2->wall = waCavefloor;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->wall == waDeadTroll2) {
|
|
|
|
addMessage(XLAT("%The1 is washed away!", c2->wall, moWaterElemental));
|
|
|
|
c2->wall = waNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(isFire(c2) && c2->wall != waEternalFire) {
|
|
|
|
addMessage(XLAT("%The1 is extinguished!", c2->wall, moWaterElemental));
|
|
|
|
c2->wall = waNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(shmup::on && isWatery(c2)) shmup::destroyBoats(c2);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m == moGreaterShark) for(int i=0; i<ct->type; i++) {
|
|
|
|
cell *c3 = ct->mov[i];
|
|
|
|
if(c3 && c3->wall == waBoat)
|
|
|
|
makeflame(c3, 5, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// lancers pierce our friends :(
|
|
|
|
if(m == moLancer) {
|
|
|
|
// printf("lancer stab?\n");
|
|
|
|
for(int u=2; u<=ct->type-2; u++) {
|
|
|
|
cell *c3 = ct->mov[(ct->mondir+u)%ct->type];
|
|
|
|
if(canAttack(ct, moLancer, c3, c3->monst, AF_LANCE | AF_GETPLAYER)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c3, AF_LANCE | AF_ORSTUN | AF_MSG | AF_GETPLAYER, m);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moWitchFire) makeflame(cf, 10, false);
|
|
|
|
if(m == moFireElemental) { makeflame(cf, 20, false); if(cf->wparam < 20) cf->wparam = 20; }
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool adj = false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(ct->cpdist == 1 && (items[itOrb37] || !nonAdjacent(cf,ct)) && markOrb(itOrbBeauty))
|
2016-08-26 09:58:03 +00:00
|
|
|
adj = true;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!adj && items[itOrbEmpathy] && items[itOrbBeauty]) {
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<ct->type; i++) if(ct->mov[i] && isFriendly(ct->mov[i]))
|
2017-03-23 10:53:57 +00:00
|
|
|
adj = true, markOrb(itOrbEmpathy), markOrb(itOrbBeauty);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(adj && ct->stuntime == 0 && !isMimic(m)) {
|
|
|
|
ct->stuntime = 2;
|
|
|
|
checkStunKill(ct);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!cellEdgeUnstable(ct)) {
|
|
|
|
if(isMetalBeast(m)) ct->stuntime += 2;
|
|
|
|
if(m == moTortoise) ct->stuntime += 3;
|
|
|
|
if(m == moDraugr && ct->land != laBurial && ct->land != laHalloween) ct->stuntime += 2;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(isWitch(m) && ct->item == itOrbLife && passable(cf, NULL, P_MIRROR)) {
|
|
|
|
// note that Fire Witches don't pick up Orbs of Life,
|
|
|
|
addMessage(XLAT("%The1 picks up %the2!", moWitch, ct->item));
|
|
|
|
cf->monst = moEvilGolem; ct->item = itNone;
|
|
|
|
}
|
|
|
|
else if(m == moWitch) {
|
|
|
|
bool pickup = false;
|
|
|
|
if(ct->item == itOrbFlash)
|
|
|
|
pickup = true, m = moWitchFlash;
|
|
|
|
if(ct->item == itOrbWinter)
|
|
|
|
pickup = true, m = moWitchWinter;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(ct->item == itOrbAether)
|
2016-08-26 09:58:03 +00:00
|
|
|
pickup = true, m = moWitchGhost;
|
|
|
|
if(ct->item == itOrbFire)
|
|
|
|
pickup = true, m = moWitchFire;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(ct->item == itOrbSpeed)
|
|
|
|
pickup = true, m = moWitchSpeed;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(ct->item == itOrbLife)
|
|
|
|
pickup = true, cf->monst = moEvilGolem;
|
|
|
|
if(pickup) {
|
|
|
|
addMessage(XLAT("%The1 picks up %the2!", moWitch, ct->item));
|
|
|
|
ct->monst = m; ct->item = itNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
// speedwitches are stunned to prevent them from making a move
|
|
|
|
// immediately
|
|
|
|
if(m == moWitchSpeed) ct->stuntime = 1;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(m == moAirElemental) airmap.push_back(make_pair(ct, 0));
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int inc = incline(cf, ct);
|
|
|
|
if(inc == -3 && ct->monst == moReptile)
|
|
|
|
ct->stuntime =3;
|
|
|
|
else if(inc == 2 && ct->monst == moReptile)
|
|
|
|
ct->stuntime = 2;
|
|
|
|
else if(inc == 3 && ct->monst == moReptile)
|
|
|
|
ct->stuntime = 3;
|
|
|
|
else if(inc == -3 && !survivesFall(ct->monst)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("%The1 falls!", ct->monst));
|
2017-03-23 10:53:57 +00:00
|
|
|
fallMonster(ct);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
if(isThorny(ct->wall) && !survivesThorns(ct->monst)) {
|
|
|
|
addMessage(XLAT("%The1 is killed by thorns!", ct->monst));
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(ct, "hit-rose");
|
|
|
|
if(isBull(ct->monst)) ct->wall = waNone;
|
|
|
|
fallMonster(ct);
|
|
|
|
}
|
|
|
|
if(sword::at(ct) && canAttack(NULL, moPlayer, ct, m, AF_SWORD_INTO)) {
|
|
|
|
attackMonster(ct, AF_SWORD_INTO | AF_ORSTUN | AF_MSG, moPlayer);
|
|
|
|
achievement_gain("GOSWORD");
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool cannotGo(eMonster m, cell *c) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moCrystalSage && (c->land != laCocytus || HEAT(c) > SAGEMELT || allPlayersInBoats()))
|
2016-08-26 09:58:03 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool wantsToStay(eMonster m) {
|
2017-03-23 10:53:57 +00:00
|
|
|
return m == moCrystalSage && allPlayersInBoats();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool batsAfraid(cell *c) {
|
|
|
|
// bats
|
|
|
|
for(int i=-1; i<size(targets); i++)
|
|
|
|
if(c == targets[i] || isNeighbor(c, targets[i])) {
|
|
|
|
if(!targets[i]->monst && invismove) continue;
|
|
|
|
bool enear = false;
|
|
|
|
forCellEx(c, targets[i])
|
|
|
|
forCellEx(c2, c)
|
|
|
|
forCellEx(c3, c2)
|
|
|
|
if(isActiveEnemy(c3, targets[i]->monst) && c3->monst != moBat &&
|
|
|
|
passable_for(c3->monst, c2, c3, 0) &&
|
|
|
|
passable_for(c3->monst, c, c2, 0)
|
|
|
|
)
|
|
|
|
enear = true;
|
|
|
|
if(!enear) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int angledist(int t, int d1, int d2) {
|
|
|
|
int dd = d1 - d2;
|
|
|
|
while(dd<0) dd += t;
|
|
|
|
while(dd>t/2) dd -= t;
|
|
|
|
if(dd<0) dd = -dd;
|
|
|
|
return dd;
|
|
|
|
}
|
|
|
|
|
|
|
|
int angledistButterfly(int t, int d1, int d2) {
|
|
|
|
int dd = d1 - d2;
|
|
|
|
while(dd<0) dd += t;
|
|
|
|
return dd;
|
|
|
|
}
|
|
|
|
|
|
|
|
int angledist(cell *c, int d1, int d2) {
|
|
|
|
return angledist(c->type, d1, d2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int bulldist(cell *c) {
|
|
|
|
int low = 0;
|
|
|
|
forCellEx(c2, c) if(c2->cpdist < c->cpdist) low++;
|
|
|
|
return 8 * c->cpdist - low;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bulldistance(cell *c, cell *d) {
|
|
|
|
int low = 0;
|
|
|
|
int cd = celldistance(c, d);
|
|
|
|
forCellEx(c2, c) if(celldistance(c2, d) < cd) low++;
|
|
|
|
return 8 * cd - low;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// move value
|
|
|
|
int moveval(cell *c1, cell *c2, int d, int mf) {
|
|
|
|
if(!c2) return -5000;
|
|
|
|
|
|
|
|
eMonster m = c1->monst;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
// Angry Beasts can only go forward
|
|
|
|
if(m == moRagingBull && c1->mondir != NODIR && angledist(c1, c1->mondir, d) < 3) return -1700;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// never move against a rose
|
|
|
|
if(againstRose(c1, c2) && !ignoresSmell(m)) return -1600;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// worms cannot attack if they cannot move
|
|
|
|
if(isWorm(m) && !passable_for(c1->monst, c2, c1, P_MONSTER)) return -1700;
|
|
|
|
|
|
|
|
if(canAttack(c1, m, c2, c2->monst, AF_GETPLAYER | mf) && !(mf & MF_NOATTACKS)) {
|
2017-06-18 16:51:46 +00:00
|
|
|
if(m == moRagingBull && c1->mondir != NODIR) return -1700;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(mf & MF_MOUNT) {
|
|
|
|
if(c2 == dragon::target) return 3000;
|
|
|
|
else if(isFriendlyOrBug(c2)) return 500;
|
|
|
|
else return 2000;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
if(isPlayerOn(c2)) return peace::on ? -1700 : 2500;
|
2017-07-22 23:33:27 +00:00
|
|
|
else if(isFriendlyOrBug(c2)) return peace::on ? -1600 : 2000;
|
2016-08-26 09:58:03 +00:00
|
|
|
else return 500;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!passable_for(c1->monst, c2, c1, 0))
|
|
|
|
return
|
|
|
|
// never move into a wall
|
|
|
|
(passable_for(c1->monst, c2, c1, P_DEADLY)) ? -1300 :
|
|
|
|
-1700; // move impossible
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(slowMover(m) && nogoSlow(c2, c1)) return -1300;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isPlayerOn(c2)) return -1700; // probably shielded
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if((mf & MF_MOUNT) && c2 == dragon::target) return 3000;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// crystal sages would die out of Cocytus
|
|
|
|
if(cannotGo(m, c2)) return -600;
|
|
|
|
|
|
|
|
// Rose Beauties keep to the Rose Garden
|
|
|
|
if(m == moRoseBeauty && c2->land != laRose) return -600;
|
|
|
|
|
|
|
|
if(wantsToStay(m)) return 750;
|
|
|
|
|
|
|
|
if((m == moRatling || m == moRatlingAvenger) && lastmovetype == lmSkip) return 650;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moLancer) {
|
|
|
|
bool lancerok = true;
|
|
|
|
for(int u=2; u<=c2->type-2; u++) {
|
2017-03-23 10:53:57 +00:00
|
|
|
cell *c3 = c2->mov[(c1->spn(d)+u)%c2->type];
|
|
|
|
if(c3 && canAttack(c2, moLancer, c3, c3->monst, AF_LANCE | AF_ONLY_ENEMY))
|
2016-08-26 09:58:03 +00:00
|
|
|
lancerok = false;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!lancerok) return 750;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moWolf) {
|
|
|
|
int val = 1500;
|
|
|
|
if(heat::absheat(c2) <= heat::absheat(c1))
|
|
|
|
return 900;
|
|
|
|
for(int i=0; i<c1->type; i++) {
|
|
|
|
cell *c3 = c1->mov[i];
|
|
|
|
if(heat::absheat(c3) > heat::absheat(c2))
|
|
|
|
val--;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return val;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if((mf & MF_MOUNT) && dragon::target)
|
|
|
|
return 1500 + celldistance(c1, dragon::target) - celldistance(c2, dragon::target);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
// Goblins avoid getting near the Sword
|
|
|
|
if(m == moGoblin && sword::near(c2)) return 790;
|
|
|
|
if(m == moBat && batsAfraid(c2)) return 790;
|
|
|
|
|
|
|
|
if(m == moButterfly)
|
|
|
|
return 1500 + angledistButterfly(c1->type, c1->mondir, d);
|
|
|
|
|
|
|
|
if(m == moRagingBull && c1->mondir != NODIR)
|
|
|
|
return 1500 - bulldist(c2);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
if((mf & MF_PATHDIST) && c2->pathdist < c1->pathdist && !peace::on) return 1500; // good move
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
// prefer straight direction when wandering
|
2017-03-23 10:53:57 +00:00
|
|
|
int dd = angledist(c1, c1->mondir, d);
|
|
|
|
|
|
|
|
// goblins blocked by anglophobia prefer to move around than to stay
|
|
|
|
if(m == moGoblin) {
|
|
|
|
bool swn = false;
|
|
|
|
forCellEx(c3, c1) if(sword::near(c3)) swn = true;
|
|
|
|
if(swn) dd += 210;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
return 800 + dd;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// stay value
|
2017-03-23 10:53:57 +00:00
|
|
|
int stayval(cell *c, flagtype mf) {
|
|
|
|
if(isShark(c->monst) && !isWatery(c))
|
|
|
|
return 525;
|
|
|
|
if(againstRose(c, NULL) && !ignoresSmell(c->monst)) return -1500;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!passable_for(c->monst, c, NULL, P_MONSTER | P_MIRROR))
|
|
|
|
return 525;
|
|
|
|
if(cellEdgeUnstable(c))
|
2017-03-23 10:53:57 +00:00
|
|
|
return -1500;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isRatling(c->monst) && lastmovetype != lmSkip)
|
|
|
|
return 700;
|
2017-03-23 10:53:57 +00:00
|
|
|
// Goblins avoid staying near the Sword (if there is no choice, movement is preferred)
|
|
|
|
if(c->monst == moGoblin && sword::near(c)) return 780;
|
|
|
|
// Vikings move in a roughly straight line even if they cannot detect you
|
|
|
|
if(c->monst == moViking && c->wall == waBoat)
|
|
|
|
return 750;
|
2017-07-04 13:38:33 +00:00
|
|
|
// in peaceful, all monsters are wandering
|
|
|
|
if(peace::on && c->monst != moTortoise) return 750;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isWorm(c->monst)) return 550;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->monst == moRagingBull) return -1690; // worse than to stay in place
|
|
|
|
if(c->monst == moBat && batsAfraid(c)) return 575;
|
2016-08-26 09:58:03 +00:00
|
|
|
return 1000;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-06-18 16:51:46 +00:00
|
|
|
int totalbulldistance(cell *c, int k) {
|
|
|
|
int tbd = 0;
|
|
|
|
for(int p=0; p<numplayers(); p++) {
|
|
|
|
cell *c2 = shpos[p][(cshpos+SHSIZE-k-1)%SHSIZE];
|
|
|
|
if(c2) tbd += bulldistance(c, c2);
|
|
|
|
}
|
|
|
|
return tbd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void determinizeBull(cell *c, int *posdir, int& nc) {
|
|
|
|
// determinize the Angry Beast movement:
|
|
|
|
// use the previous PC's positions as the tiebreaker
|
|
|
|
for(int k=0; k<SHSIZE && nc>1; k++) {
|
|
|
|
int pts[10];
|
|
|
|
for(int d=0; d<nc; d++) pts[d] = totalbulldistance(c->mov[posdir[d]], k);
|
|
|
|
|
|
|
|
int bestpts = 1000;
|
|
|
|
for(int d=0; d<nc; d++) if(pts[d] < bestpts) bestpts = pts[d];
|
|
|
|
int nc0 = 0;
|
|
|
|
for(int d=0; d<nc; d++) if(pts[d] == bestpts) posdir[nc0++] = posdir[d];
|
|
|
|
nc = nc0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int determinizeBullPush(cellwalker bull) {
|
|
|
|
int nc = 2;
|
|
|
|
int dirs[2], positive;
|
|
|
|
cwstep(bull);
|
|
|
|
cell *c2 = bull.c;
|
|
|
|
if(c2->type == 6) return 1; // irrelevant
|
|
|
|
cwspin(bull, 3); dirs[0] = positive = bull.spin;
|
|
|
|
cwspin(bull, -6); dirs[1] = bull.spin;
|
|
|
|
determinizeBull(c2, dirs, nc);
|
|
|
|
if(dirs[0] == positive) return -1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int pickMoveDirection(cell *c, flagtype mf) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int posdir[10], nc = 0, bestval = stayval(c, mf);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// printf("stayval [%p, %s]: %d\n", c, dnameof(c->monst), bestval);
|
|
|
|
for(int d=0; d<c->type; d++) {
|
|
|
|
cell *c2 = c->mov[d];
|
|
|
|
int val = moveval(c, c2, d, mf);
|
|
|
|
// printf("[%d] %p: val=%5d pass=%d\n", d, c2, val, passable(c2,c,0));
|
|
|
|
if(val > bestval) nc = 0, bestval = val;
|
|
|
|
if(val == bestval) posdir[nc++] = d;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-06-18 16:51:46 +00:00
|
|
|
if(c->monst == moRagingBull)
|
|
|
|
determinizeBull(c, posdir, nc);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!nc) return -1;
|
|
|
|
nc = hrand(nc);
|
|
|
|
return posdir[nc];
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int pickDownDirection(cell *c, flagtype mf) {
|
|
|
|
int downs[10], qdowns = 0;
|
|
|
|
int bestdif = -100;
|
|
|
|
forCellIdEx(c2, i, c) {
|
|
|
|
if(gravityLevel(c2) < gravityLevel(c) && passable_for(c->monst, c2, c, P_MIRROR) &&
|
|
|
|
!isPlayerOn(c2)) {
|
|
|
|
int cdif = i-c->mondir;
|
|
|
|
if(cdif < 0) cdif += c->type;
|
|
|
|
if(cdif > c->type/2) cdif = cdif - c->type;
|
|
|
|
if(cdif < 0) cdif = -2*cdif+1; else cdif = 2*cdif;
|
|
|
|
// printf("i=%d md=%d dif=%d\n", i, c->mondir, cdif);
|
|
|
|
if(c2->wall == waClosePlate || c->wall == waClosePlate)
|
|
|
|
cdif += 20;
|
|
|
|
if(cdif > bestdif) bestdif = cdif, qdowns = 0;
|
|
|
|
if(cdif == bestdif) downs[qdowns++] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!qdowns) return -1;
|
|
|
|
return downs[hrand(qdowns)];
|
|
|
|
}
|
|
|
|
|
2017-06-18 16:51:46 +00:00
|
|
|
template<class T>
|
|
|
|
cell *determinePush(cellwalker who, cell *c2, int subdir, T valid) {
|
|
|
|
cellwalker push = who;
|
|
|
|
cwstep(push);
|
|
|
|
cwspin(push, 3 * -subdir);
|
|
|
|
cwstep(push);
|
|
|
|
if(valid(push.c)) return push.c;
|
|
|
|
if(c2->type == 7) {
|
|
|
|
cwstep(push);
|
|
|
|
cwspin(push, 1 * -subdir);
|
|
|
|
cwstep(push);
|
|
|
|
if(valid(push.c)) return push.c;
|
|
|
|
}
|
|
|
|
if(gravityLevel(push.c) < gravityLevel(c2)) {
|
|
|
|
cwstep(push); cwspin(push, 1); cwstep(push);
|
|
|
|
if(gravityLevel(push.c) < gravityLevel(c2)) {
|
|
|
|
cwstep(push); cwspin(push, -2); cwstep(push);
|
|
|
|
}
|
|
|
|
if(gravityLevel(push.c) < gravityLevel(c2)) {
|
|
|
|
cwstep(push); cwspin(push, 1); cwstep(push);
|
|
|
|
}
|
|
|
|
if(valid(push.c)) return push.c;
|
|
|
|
}
|
|
|
|
return c2;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
// Angry Beast attack
|
|
|
|
// note: this is done both before and after movement
|
|
|
|
void beastAttack(cell *c, bool player) {
|
|
|
|
if(c->mondir == NODIR) return;
|
|
|
|
forCellIdEx(c2, d, c) {
|
|
|
|
bool opposite = angledist(c, d, c->mondir) >= 3;
|
|
|
|
int flags = AF_BULL | AF_ORSTUN;
|
|
|
|
if(player) flags |= AF_GETPLAYER;
|
|
|
|
if(!opposite) flags |= AF_ONLY_FBUG;
|
2017-06-18 16:51:46 +00:00
|
|
|
if(canAttack(c, moRagingBull, c2, c2->monst, flags)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c2, flags | AF_MSG, moRagingBull);
|
2017-06-18 16:51:46 +00:00
|
|
|
if(c2->monst && c2->stuntime) {
|
|
|
|
cellwalker bull (c, d);
|
|
|
|
int subdir = determinizeBullPush(bull);
|
|
|
|
cell *c3 = determinePush(bull, c2, subdir, [c2] (cell *c) { return passable(c, c2, P_BLOW); });
|
|
|
|
if(c3 && c3 != c2)
|
|
|
|
pushMonster(c3, c2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(c2->wall == waThumperOff) {
|
|
|
|
playSound(c2, "click");
|
|
|
|
c2->wall = waThumperOn;
|
|
|
|
}
|
|
|
|
if(c2->wall == waThumperOn) {
|
|
|
|
cellwalker bull (c, d);
|
|
|
|
int subdir = determinizeBullPush(bull);
|
|
|
|
cell *c3 = determinePush(bull, c2, subdir, [c2] (cell *c) { return canPushThumperOn(c, c2, c); });
|
|
|
|
if(c3 && c3 != c2)
|
|
|
|
pushThumper(c2, c3);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cell *moveNormal(cell *c, flagtype mf) {
|
2016-08-26 09:58:03 +00:00
|
|
|
eMonster m = c->monst;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int d;
|
|
|
|
|
|
|
|
if(c->stuntime) {
|
|
|
|
if(cellEdgeUnstable(c, MF_STUNNED)) d = pickDownDirection(c, mf);
|
|
|
|
else return NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Angry Beasts attack all neighbors first
|
|
|
|
if(m == moRagingBull) beastAttack(c, true);
|
|
|
|
d = pickMoveDirection(c, mf);
|
|
|
|
}
|
|
|
|
if(d == -1) {
|
|
|
|
stayEffect(c);
|
|
|
|
return c;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c2 = c->mov[d];
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isPlayerOn(c2)) {
|
|
|
|
killThePlayerAt(m, c2, 0);
|
|
|
|
return c2;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
eMonster m2 = c2->monst;
|
|
|
|
if(m2) {
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c2, AF_ORSTUN | AF_MSG, m);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m == moFlailer && m2 == moIllusion)
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c, 0, m2);
|
2016-08-26 09:58:03 +00:00
|
|
|
return c2;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
moveMonster(c2, c);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moRagingBull) beastAttack(c2, false);
|
2016-08-26 09:58:03 +00:00
|
|
|
return c2;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void explodeAround(cell *c) {
|
|
|
|
for(int j=0; j<c->type; j++) {
|
|
|
|
cell* c2 = c->mov[j];
|
|
|
|
if(c2) {
|
|
|
|
if(isIcyLand(c2)) HEAT(c2) += 0.5;
|
2017-03-23 10:53:57 +00:00
|
|
|
eWall ow = c2->wall;
|
2016-08-26 09:58:03 +00:00
|
|
|
if((c2->wall == waDune || c2->wall == waIcewall ||
|
|
|
|
c2->wall == waAncientGrave || c2->wall == waFreshGrave ||
|
|
|
|
c2->wall == waColumn || c2->wall == waThumperOff || c2->wall == waThumperOn ||
|
|
|
|
(isFire(c2) && !eternalFire(c2)) ||
|
|
|
|
c2->wall == waBigTree || c2->wall == waSmallTree ||
|
|
|
|
c2->wall == waVinePlant || c2->wall == waVineHalfA || c2->wall == waVineHalfB)) {
|
|
|
|
destroyHalfvine(c2);
|
|
|
|
c2->wall = waNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->wall == waCavewall || c2->wall == waDeadTroll) c2->wall = waCavefloor;
|
|
|
|
if(c2->wall == waDeadTroll2) c2->wall = waNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->wall == waPetrified) c2->wall = waNone;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->wall == waDeadfloor2) c2->wall = waDeadfloor;
|
|
|
|
if(c2->wall == waGargoyleFloor) c2->wall = waChasm;
|
2017-09-03 10:01:31 +00:00
|
|
|
if(c2->wall == waGargoyleBridge || c2->wall == waPetrifiedBridge) placeWater(c2, c2);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->wall == waRubble) c2->wall = waNone;
|
|
|
|
if(c2->wall == waPlatform) c2->wall = waNone;
|
|
|
|
if(c2->wall == waStone) c2->wall = waNone;
|
|
|
|
if(c2->wall == waRose) c2->wall = waNone;
|
|
|
|
if(c2->wall == waLadder) c2->wall = waNone;
|
|
|
|
if(c2->wall == waGargoyle) c2->wall = waNone;
|
|
|
|
if(c2->wall == waSandstone) c2->wall = waNone;
|
|
|
|
if(c2->wall == waSaloon) c2->wall = waNone;
|
|
|
|
if(c2->wall == waDeadwall) c2->wall = waDeadfloor2;
|
|
|
|
if(c2->wall == waBigStatue) c2->wall = waNone;
|
|
|
|
if(c2->wall == waPalace || c2->wall == waOpenGate || c2->wall == waClosedGate)
|
|
|
|
c2->wall = waNone;
|
|
|
|
if(isAlch(c2) && isAlch(c))
|
|
|
|
c2->wall = c->wall;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->wall != ow && ow) drawParticles(c2, winf[ow].color, 16);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-08-06 12:50:16 +00:00
|
|
|
void killHardcorePlayer(int id, flagtype flags) {
|
|
|
|
charstyle& cs = getcs(id);
|
|
|
|
cell *c = playerpos(id);
|
|
|
|
if(flags & AF_FALL)
|
|
|
|
fallingMonsterAnimation(c, moPlayer);
|
|
|
|
else for(int i=0; i<6; i++) {
|
|
|
|
drawParticle(c, cs.skincolor >> 8, 100);
|
|
|
|
drawParticle(c, cs.haircolor >> 8, 125);
|
|
|
|
if(cs.charid)
|
|
|
|
drawParticle(c, cs.dresscolor >> 8, 150);
|
|
|
|
else
|
|
|
|
drawParticle(c, cs.skincolor >> 8, 150);
|
|
|
|
if(cs.charid == 3)
|
|
|
|
drawParticle(c, cs.dresscolor2 >> 8, 175);
|
|
|
|
else
|
|
|
|
drawParticle(c, cs.skincolor >> 8, 150);
|
|
|
|
drawParticle(c, cs.swordcolor >> 8, 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(multi::players > 1 && multi::activePlayers() > 1) {
|
|
|
|
multi::leaveGame(id);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
canmove = false;
|
|
|
|
achievement_final(true);
|
|
|
|
msgscroll = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void killThePlayer(eMonster m, int id, flagtype flags) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(markOrb(itOrbShield)) return;
|
|
|
|
if(shmup::on) {
|
2017-03-23 10:53:57 +00:00
|
|
|
multi::cpid = id;
|
2016-08-26 09:58:03 +00:00
|
|
|
shmup::killThePlayer(m);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(items[itOrbDomination] && playerpos(id)->monst) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("%The1 tries to dismount you!", m));
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(playerpos(id), AF_ORSTUN, m);
|
2016-08-26 09:58:03 +00:00
|
|
|
useupOrb(itOrbDomination, items[itOrbDomination]/2);
|
|
|
|
}
|
|
|
|
else if(items[itOrbShell] && !(flags & AF_EAT)) {
|
|
|
|
addMessage(XLAT("%The1 attacks your shell!", m));
|
|
|
|
useupOrb(itOrbShell, 10);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(items[itOrbShell] < 1) items[itOrbShell] = 1, orbused[itOrbShell] = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
else if(hardcore) {
|
|
|
|
addMessage(XLAT("You are killed by %the1!", m));
|
2017-08-06 12:50:16 +00:00
|
|
|
killHardcorePlayer(id, flags);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(m == moLightningBolt && lastmovetype == lmAttack && isAlchAny(playerpos(id))) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("You are killed by %the1!", m));
|
|
|
|
addMessage(XLAT("Don't play with slime and electricity next time, okay?"));
|
|
|
|
kills[moPlayer]++;
|
|
|
|
items[itOrbSafety] = 0;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else {
|
|
|
|
printf("confused!\n");
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("%The1 is confused!", m));
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void killThePlayerAt(eMonster m, cell *c, flagtype flags) {
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
if(playerpos(i) == c)
|
|
|
|
killThePlayer(m, i, flags);
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void afterplayermoved() {
|
|
|
|
setdist(cwt.c, 0, NULL);
|
|
|
|
prairie::treasures();
|
|
|
|
if(generatingEquidistant) {
|
|
|
|
printf("Warning: generatingEquidistant set to true\n");
|
|
|
|
generatingEquidistant = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mountmove(cell *c, int spin, bool fp, int id) {
|
|
|
|
if(multi::players > 1) {
|
|
|
|
multi::player[id].c = c;
|
|
|
|
multi::player[id].spin = spin;
|
|
|
|
multi::flipped[id] = fp;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cwt.c = c;
|
|
|
|
cwt.spin = spin;
|
|
|
|
flipplayer = fp;
|
|
|
|
}
|
|
|
|
afterplayermoved();
|
|
|
|
}
|
|
|
|
|
|
|
|
void mountmove(cell *c, int spin, bool fp, cell *ppos) {
|
|
|
|
for(int i=0; i<numplayers(); i++) if(playerpos(i) == ppos) {
|
|
|
|
animateMovement(ppos, c, LAYER_SMALL);
|
|
|
|
mountmove(c, spin, fp, i);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void moveWorm(cell *c) {
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool mounted = false;
|
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
if(multi::playerActive(i) && getMount(i) && sameMonster(c, playerpos(i)))
|
|
|
|
mounted = true;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst == moWormwait) { c->monst = moWorm; return; }
|
|
|
|
else if(c->monst == moTentaclewait) { c->monst = moTentacle; return; }
|
|
|
|
else if(c->monst == moTentacleEscaping) {
|
|
|
|
// explodeAround(c);
|
|
|
|
forCellEx(c2, c)
|
2017-03-23 10:53:57 +00:00
|
|
|
if(canAttack(c, c->monst, c2, c2->monst, mounted ? AF_ONLY_ENEMY : (AF_GETPLAYER | AF_ONLY_FBUG))) {
|
|
|
|
attackMonster(c2, AF_ORSTUN | AF_MSG | AF_GETPLAYER, c->monst);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c2 = c;
|
2017-03-23 10:53:57 +00:00
|
|
|
vector<cell*> allcells;
|
2016-08-26 09:58:03 +00:00
|
|
|
while(c2->mondir != NODIR) {
|
2017-03-23 10:53:57 +00:00
|
|
|
allcells.push_back(c2);
|
2016-08-26 09:58:03 +00:00
|
|
|
c2 = c2->mov[c2->mondir];
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
allcells.push_back(c2);
|
|
|
|
for(int i=size(allcells)-2; i>=0; i--) {
|
|
|
|
cell *cmt = allcells[i+1];
|
|
|
|
cell *cft = allcells[i];
|
|
|
|
if(cft->monst != moTentacleGhost && cmt->monst != moTentacleGhost)
|
|
|
|
mountmove(cmt, cft->spn(cft->mondir), false, cft);
|
|
|
|
animateMovement(cft, cmt, LAYER_BIG);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
c->monst = moNone;
|
|
|
|
if(c->mondir != NODIR) c->mov[c->mondir]->monst = moTentacleEscaping;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(c->monst != moWorm && c->monst != moTentacle) return;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
eMonster m = c->monst;
|
|
|
|
int id = m - moWorm;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
int mf = MF_PATHDIST | AF_EAT;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(mounted) mf ^= (MF_MOUNT | MF_PATHDIST);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
int dir = pickMoveDirection(c, mf);
|
|
|
|
|
|
|
|
if(c->wall == waRose) {
|
|
|
|
addMessage(XLAT("%The1 eats %the2!", c->monst, c->wall));
|
|
|
|
c->wall = waNone;
|
|
|
|
dir = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dir == -1) {
|
|
|
|
int spices = 0;
|
|
|
|
if(id) {
|
|
|
|
addMessage(XLAT("Cthulhu withdraws his tentacle!"));
|
|
|
|
kills[moTentacle]++;
|
|
|
|
c->monst = moTentacleEscaping;
|
|
|
|
moveWorm(c);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else {
|
|
|
|
kills[moWorm]++;
|
|
|
|
spices = 3;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
eItem loc = treasureType(c->land);
|
|
|
|
bool spiceSeen = false;
|
|
|
|
while(c->monst == moWorm || c->monst == moWormtail || c->monst == moTentacle || c->monst == moTentacletail) {
|
|
|
|
// if(!id)
|
|
|
|
explodeAround(c);
|
2017-03-23 10:53:57 +00:00
|
|
|
drawParticles(c, minf[c->monst].color, 16);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(spices > 0 && c->land == laDesert) {
|
|
|
|
if(notDippingForExtra(itSpice, loc)) {
|
|
|
|
c->item = itSpice;
|
|
|
|
if(c->cpdist <= 6) spiceSeen = true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
spices--;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
c->monst = moNone;
|
|
|
|
if(c->mondir != NODIR) c = c->mov[c->mondir];
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!id) {
|
|
|
|
if(spiceSeen)
|
|
|
|
addMessage(XLAT("The sandworm explodes in a cloud of Spice!"));
|
|
|
|
else
|
|
|
|
addMessage(XLAT("The sandworm explodes!"));
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(NULL, "explosion");
|
|
|
|
achievement_gain("ZEBRAWORM", 'q');
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cell* goal = c->mov[dir];
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isPlayerOn(goal) || goal->monst)
|
|
|
|
attackMonster(goal, AF_EAT | AF_MSG | AF_GETPLAYER, c->monst);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
for(int j=0; j<c->type; j++) if(c->mov[j] == goal) {
|
|
|
|
goal->monst = eMonster(moWormwait + id);
|
|
|
|
moveEffect(goal, NULL, eMonster(moWormwait + id));
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
animateMovement(c, goal, LAYER_BIG);
|
2016-08-26 09:58:03 +00:00
|
|
|
c->monst = eMonster(moWormtail + id);
|
2017-03-23 10:53:57 +00:00
|
|
|
goal->mondir = c->spn(j);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
mountmove(goal, goal->mondir, true, c);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(id) {
|
|
|
|
cell *c2 = c, *c3 = c2;
|
|
|
|
while(c2->monst == moTentacletail || c2->monst == moTentacleGhost) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->mondir == NODIR) {
|
|
|
|
drawParticles(c2, (linf[c2->land].color & 0xF0F0F0), 16, 50);
|
|
|
|
return;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
c3 = c2, c2 = c3->mov[c2->mondir];
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c3->monst != moTentacleGhost && c2->monst != moTentacleGhost)
|
|
|
|
mountmove(c3, c3->mondir, true, c2);
|
|
|
|
animateMovement(c2, c3, LAYER_BIG);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c2 = c, *c3 = c2;
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int a=0; a<WORMLENGTH; a++) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->monst == moWormtail) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->mondir == NODIR) {
|
|
|
|
drawParticles(c2, (linf[c2->land].color & 0xF0F0F0), 16);
|
|
|
|
return;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
c3 = c2, c2 = c3->mov[c2->mondir];
|
2017-03-23 10:53:57 +00:00
|
|
|
mountmove(c3, c3->mondir, true, c2);
|
|
|
|
animateMovement(c2, c3, LAYER_BIG);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->monst == moWormtail) c2->monst = moNone, c3->mondir = NODIR;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ivynext(cell *c) {
|
|
|
|
cellwalker cw(c, c->mondir);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
// check the mirroring status
|
|
|
|
cell *c2 = c;
|
|
|
|
while(true) {
|
|
|
|
if(c2->monst == moIvyRoot) break;
|
|
|
|
if(!isIvy(c2->monst)) break;
|
|
|
|
if(c2->mirror(c2->mondir)) cw.mirrored = !cw.mirrored;
|
|
|
|
c2 = c2->mov[c2->mondir];
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
cw.c->monst = moIvyWait;
|
|
|
|
bool findleaf = false;
|
|
|
|
while(true) {
|
|
|
|
cwspin(cw, 1);
|
|
|
|
if(cw.spin == signed(cw.c->mondir)) {
|
|
|
|
if(findleaf) {
|
|
|
|
cw.c->monst = moIvyHead; break;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
cw.c->monst = moIvyWait;
|
|
|
|
cwstep(cw);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
cwstep(cw);
|
|
|
|
if(cw.c->monst == moIvyWait && signed(cw.c->mondir) == cw.spin) {
|
|
|
|
cw.c->monst = moIvyBranch;
|
|
|
|
findleaf = true; continue;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
cwstep(cw);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// this removes Ivy, but also potentially causes Vines to grow
|
|
|
|
void removeIvy(cell *c) {
|
2017-03-23 10:53:57 +00:00
|
|
|
eMonster m = c->monst;
|
2016-08-26 09:58:03 +00:00
|
|
|
c->monst = moNone; // NEWYEARFIX
|
|
|
|
for(int i=0; i<c->type; i++)
|
|
|
|
// note that semi-vines don't count
|
|
|
|
if(c->mov[i]->wall == waVinePlant) {
|
|
|
|
destroyHalfvine(c);
|
|
|
|
c->wall = waVinePlant;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->wall != waVinePlant) {
|
|
|
|
if(m == moIvyDead)
|
|
|
|
m = moIvyWait;
|
|
|
|
drawParticles(c, minf[m].color, 2);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveivy() {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(size(ivies) == 0) return;
|
|
|
|
computePathdist(moIvyRoot);
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<size(ivies); i++) {
|
|
|
|
cell *c = ivies[i];
|
|
|
|
cell *co = c;
|
|
|
|
if(c->monst != moIvyHead) continue;
|
|
|
|
ivynext(c);
|
|
|
|
|
|
|
|
cell *mto = NULL;
|
|
|
|
int pd = c->pathdist;
|
|
|
|
int sp = 0;
|
|
|
|
|
|
|
|
while(c->monst != moIvyRoot) {
|
|
|
|
if(!isIvy(c->monst)) {
|
|
|
|
raiseBuggyGeneration(c, "that's not an Ivy!");
|
|
|
|
}
|
|
|
|
if(c->mondir == NODIR)
|
|
|
|
raiseBuggyGeneration(c, "wrong mondir!");
|
|
|
|
for(int j=0; j<c->type; j++) {
|
|
|
|
if(c->mov[j] && canAttack(c, c->monst, c->mov[j], c->mov[j]->monst, AF_ONLY_FRIEND | AF_GETPLAYER)) {
|
2017-07-04 13:38:33 +00:00
|
|
|
if(isPlayerOn(c->mov[j]))
|
2016-08-26 09:58:03 +00:00
|
|
|
killThePlayerAt(c->monst, c->mov[j], 0);
|
|
|
|
else {
|
|
|
|
if(attackJustStuns(c->mov[j]))
|
|
|
|
addMessage(XLAT("The ivy attacks %the1!", c->mov[j]->monst));
|
|
|
|
else if(isNonliving(c->mov[j]->monst))
|
|
|
|
addMessage(XLAT("The ivy destroys %the1!", c->mov[j]->monst));
|
|
|
|
else
|
|
|
|
addMessage(XLAT("The ivy kills %the1!", c->mov[j]->monst));
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c->mov[j], AF_ORSTUN, c->monst);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
continue;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->mov[j] && signed(c->mov[j]->pathdist) < pd && passable(c->mov[j], c, 0)
|
|
|
|
&& !strictlyAgainstGravity(c->mov[j], c, false, MF_IVY))
|
|
|
|
mto = c->mov[j], pd = mto->pathdist, sp = c->spn(j);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
c = c->mov[c->mondir];
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(mto && mto->cpdist) {
|
|
|
|
animateMovement(mto->mov[sp], mto, LAYER_BIG);
|
2016-08-26 09:58:03 +00:00
|
|
|
mto->monst = moIvyWait, mto->mondir = sp;
|
|
|
|
moveEffect(mto, NULL, moIvyWait);
|
|
|
|
// if this is the only branch, we want to move the head immediately to mto instead
|
|
|
|
if(mto->mov[mto->mondir]->monst == moIvyHead) {
|
|
|
|
mto->monst = moIvyHead; co->monst = moIvyBranch;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(co->mov[co->mondir]->monst != moIvyRoot) {
|
|
|
|
// shrink useless branches, but do not remove them completely (at the root)
|
|
|
|
if(co->monst == moIvyHead) co->mov[co->mondir]->monst = moIvyHead;
|
|
|
|
removeIvy(co);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool earthMove(cell *from, int dir) {
|
|
|
|
bool b = false;
|
|
|
|
cell *c2 = from->mov[dir];
|
2017-03-23 10:53:57 +00:00
|
|
|
int d = from->spn(dir);
|
2016-08-26 09:58:03 +00:00
|
|
|
b |= earthWall(from);
|
|
|
|
if(c2) for(int u=2; u<=c2->type-2; u++) {
|
|
|
|
cell *c3 = c2->mov[(d + u)% c2->type];
|
|
|
|
if(c3) b |= earthFloor(c3);
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
vector<cell*> gendfs;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool isMounted(cell *c) {
|
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
if(multi::playerActive(i) && sameMonster(c, playerpos(i)))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int targetcount;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool isTargetOrAdjacent(cell *c) {
|
|
|
|
for(int i=0; i<targetcount; i++)
|
|
|
|
if(gendfs[i] == c || isNeighbor(gendfs[i], c))
|
|
|
|
return true;
|
|
|
|
return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void groupmove2(cell *c, cell *from, int d, eMonster movtype, flagtype mf) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!c) return;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(eq(c->aitmp, sval)) return;
|
|
|
|
|
|
|
|
if(movtype == moKrakenH && isTargetOrAdjacent(from)) ;
|
|
|
|
/* else if(passable_for(movtype, from, c, P_ONPLAYER | P_CHAIN | P_MONSTER)) ;
|
|
|
|
else if(canAttack(c, movtype, from, from->monst, AF_GETPLAYER)) ; */
|
|
|
|
else if(passable_for(movtype, from, c, P_CHAIN | P_MONSTER)) ;
|
|
|
|
else if(canAttack(c, movtype, from, from->monst, AF_GETPLAYER)) ;
|
|
|
|
else return;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(from->monst) {
|
|
|
|
if(mf & MF_MOUNT) {
|
|
|
|
// don't go through friends
|
|
|
|
if(isFriendlyOrBug(from)) return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// go through the player (even mounted)
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isPlayerOn(from)) ;
|
2016-08-26 09:58:03 +00:00
|
|
|
// go through the mounted dragon
|
|
|
|
else if(isDragon(from->monst) && isFriendlyOrBug(from)) ;
|
|
|
|
// but not through other worms
|
|
|
|
else if(isWorm(from)) return;
|
|
|
|
// go through other friends
|
|
|
|
else if(isFriendlyOrBug(from)) ;
|
|
|
|
else return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
// Kraken movement
|
|
|
|
if(movtype == moKrakenH && c->monst == moKrakenT && c->stuntime == 0)
|
|
|
|
kraken::trymove(c);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(movegroup(c->monst) == movtype) {
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int af = AF_ONLY_FBUG | AF_GETPLAYER;
|
|
|
|
if(mf & MF_MOUNT) af = 0;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!passable_for(movtype, from, c, P_ONPLAYER | P_MONSTER)) return;
|
|
|
|
if(!ignoresSmell(c->monst) && againstRose(c, from)) return;
|
2017-07-22 23:33:27 +00:00
|
|
|
if((mf & MF_ONLYEAGLE) && c->monst != moEagle && c->monst != moBat)
|
|
|
|
return;
|
2017-03-23 10:53:57 +00:00
|
|
|
// in the gravity lands, eagles cannot ascend in their second move
|
|
|
|
if((mf & MF_ONLYEAGLE) && gravityLevel(c) < gravityLevel(from)) {
|
|
|
|
c->aitmp = sval; return;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if((mf & MF_NOFRIEND) && isFriendly(c)) return;
|
2017-03-23 10:53:57 +00:00
|
|
|
if((mf & MF_MOUNT) && !isMounted(c)) return;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isRatling(c->monst) && lastmovetype == lmSkip) return;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->stuntime) return;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->monst == moBat && batsAfraid(from)) return;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// note: move from 'c' to 'from'!
|
|
|
|
if(!(mf & MF_NOATTACKS)) for(int j=0; j<c->type; j++)
|
|
|
|
if(c->mov[j] && canAttack(c, c->monst, c->mov[j], c->mov[j]->monst, af)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c->mov[j], AF_ORSTUN | AF_GETPLAYER | AF_MSG, c->monst);
|
2016-08-26 09:58:03 +00:00
|
|
|
c->aitmp = sval;
|
|
|
|
// XLATC eagle
|
|
|
|
return;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(from->cpdist == 0 || from->monst) { c->aitmp = sval; return; }
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(movtype == moDragonHead) {
|
|
|
|
dragon::move(from, c);
|
|
|
|
return;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
moveMonster(from, c);
|
2017-03-23 10:53:57 +00:00
|
|
|
from->aitmp = sval;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
c->aitmp = sval;
|
|
|
|
// MAXGCELL
|
|
|
|
if(size(gendfs) < 1000 || c->cpdist <= 6) gendfs.push_back(c);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void groupmove(eMonster movtype, flagtype mf) {
|
2016-08-26 09:58:03 +00:00
|
|
|
sval++;
|
|
|
|
gendfs.clear();
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(mf & MF_MOUNT) {
|
|
|
|
if(dragon::target) gendfs.push_back(dragon::target);
|
|
|
|
if(movtype == moDragonHead) {
|
|
|
|
for(int i=0; i<size(dcal); i++) {
|
|
|
|
cell *c = (i == 0 && dragon::target) ? dragon::target : dcal[i];
|
|
|
|
if(!c->monst) continue;
|
|
|
|
if(isFriendlyOrBug(c)) continue;
|
2017-03-23 10:53:57 +00:00
|
|
|
forCellIdEx(c2, d, c) if(c2->monst && isMounted(c2)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
groupmove2(c2,c,d,movtype,mf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2017-07-04 13:38:33 +00:00
|
|
|
if(!peace::on) for(int i=0; i<size(targets); i++) gendfs.push_back(targets[i]);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(invisfish && (movtype == moSlime || movtype == moShark || movtype == moKrakenH)) for(int i=0; i<numplayers(); i++) {
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c = playerpos(i);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!c) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
gendfs.push_back(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
targetcount = size(gendfs);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<size(gendfs); i++) {
|
|
|
|
cell *c = gendfs[i];
|
2017-03-23 10:53:57 +00:00
|
|
|
int dirtable[10], qdirtable=0;
|
|
|
|
|
|
|
|
forCellIdAll(c2,t,c) dirtable[qdirtable++] = t;
|
|
|
|
random_shuffle(dirtable, dirtable + qdirtable);
|
|
|
|
while(qdirtable--) {
|
|
|
|
int t = dirtable[qdirtable];
|
|
|
|
groupmove2(c->mov[t],c,t,movtype,mf);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(movtype == moEagle && c->monst == moNone && !isPlayerOn(c)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c2 = whirlwind::jumpFromWhereTo(c, false);
|
|
|
|
groupmove2(c2, c, NODIR, movtype, mf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(movtype != moDragonHead) for(int i=0; i<size(dcal); i++) {
|
|
|
|
cell *c = dcal[i];
|
2017-03-23 10:53:57 +00:00
|
|
|
if((mf & MF_ONLYEAGLE) && c->monst != moEagle && c->monst != moBat) return;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(movegroup(c->monst) == movtype && !eq(c->aitmp, sval)) {
|
|
|
|
cell *c2 = moveNormal(c, mf);
|
|
|
|
if(c2) c2->aitmp = sval;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// Hex monsters
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
vector<cell*> hexdfs;
|
|
|
|
|
|
|
|
// note: move from 'c' to 'from'!
|
|
|
|
void moveHexSnake(cell *from, cell *c, int d, bool mounted) {
|
|
|
|
if(from->wall == waBoat) from->wall = waSea;
|
|
|
|
moveEffect(from, c, c->monst);
|
|
|
|
from->monst = c->monst; from->mondir = d;
|
|
|
|
c->monst = moHexSnakeTail;
|
2017-03-23 10:53:57 +00:00
|
|
|
preventbarriers(from);
|
|
|
|
|
|
|
|
animateMovement(c, from, LAYER_BIG);
|
|
|
|
mountmove(from, from->mondir, true, c);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c2 = c, *c3=c2;
|
|
|
|
for(int a=0;; a++) if(c2->monst == moHexSnakeTail) {
|
|
|
|
if(a == ROCKSNAKELENGTH) { c2->monst = moNone, c3->mondir = NODIR; break; }
|
|
|
|
if(c2->mondir == NODIR) break;
|
2017-03-23 10:53:57 +00:00
|
|
|
mountmove(c2, c2->mondir, true, c2->mov[c2->mondir]);
|
|
|
|
animateMovement(c2->mov[c2->mondir], c2, LAYER_BIG);
|
2016-08-26 09:58:03 +00:00
|
|
|
c3 = c2, c2 = c3->mov[c2->mondir];
|
|
|
|
}
|
|
|
|
else break;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void snakeAttack(cell *c, bool mounted) {
|
|
|
|
for(int j=0; j<c->type; j++)
|
|
|
|
if(c->mov[j] && canAttack(c, moHexSnake, c->mov[j], c->mov[j]->monst,
|
|
|
|
mounted ? AF_ONLY_ENEMY : (AF_ONLY_FBUG | AF_GETPLAYER))) {
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c->mov[j], AF_ORSTUN | AF_GETPLAYER | AF_MSG, moHexSnake);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool goodmount(cell *c, bool mounted) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(mounted) return isMounted(c);
|
|
|
|
else return !isMounted(c);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// note: move from 'c' to 'from'!
|
|
|
|
void hexvisit(cell *c, cell *from, int d, bool mounted) {
|
|
|
|
if(!c) return;
|
|
|
|
if(cellUnstable(c) || cellEdgeUnstable(c)) return;
|
|
|
|
if(eq(c->aitmp, sval)) return;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(cellUnstableOrChasm(c) || cellUnstableOrChasm(from)) return;
|
|
|
|
|
|
|
|
/* if(c->monst == moHexSnake)
|
|
|
|
printf("%p:%p %s %d\n", from, c, dnameof(from->monst), passable(from, c, true, false, false)); */
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(from->cpdist && (!passable(from, c, P_MONSTER|P_WIND|P_FISH))) return;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst == moHexSnake) {
|
|
|
|
// printf("got snake\n");
|
|
|
|
|
|
|
|
if(pseudohept(from)) return;
|
|
|
|
if(!goodmount(c, mounted)) return;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(canAttack(c, moHexSnake, from, from->monst, AF_EAT | (mounted ? AF_ONLY_ENEMY : AF_ONLY_FBUG | AF_GETPLAYER))) {
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(from, AF_MSG | AF_EAT | AF_GETPLAYER, c->monst);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(from->cpdist == 0 || from->monst) return;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
snakeAttack(c, mounted);
|
2017-03-23 10:53:57 +00:00
|
|
|
moveHexSnake(from, c, d, mounted);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
c->aitmp = sval;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// MAXGCELL
|
|
|
|
if(size(hexdfs) < 2000 || c->cpdist <= 6)
|
|
|
|
hexdfs.push_back(c);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void movehex(bool mounted) {
|
|
|
|
sval++;
|
|
|
|
hexdfs.clear();
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(mounted) {
|
|
|
|
if(dragon::target && dragon::target->monst != moHexSnake) {
|
|
|
|
hexdfs.push_back(dragon::target);
|
|
|
|
dragon::target->aitmp = sval;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else for(int i=0; i<size(targets); i++) {
|
|
|
|
hexdfs.push_back(targets[i]);
|
|
|
|
targets[i]->aitmp = sval;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
//hexdfs.push_back(cwt.c);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<size(hexdfs); i++) {
|
|
|
|
cell *c = hexdfs[i];
|
2017-03-23 10:53:57 +00:00
|
|
|
int dirtable[10], qdirtable=0;
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int t=0; t<c->type; t++) if(c->mov[t] && !pseudohept(c->mov[t]))
|
2017-03-23 10:53:57 +00:00
|
|
|
dirtable[qdirtable++] = t;
|
|
|
|
|
|
|
|
random_shuffle(dirtable, dirtable+qdirtable);
|
|
|
|
while(qdirtable--) {
|
|
|
|
int t = dirtable[qdirtable];
|
2016-08-26 09:58:03 +00:00
|
|
|
hexvisit(c->mov[t], c, t, mounted);
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
for(int i=0; i<size(hexsnakes); i++) {
|
|
|
|
cell *c = hexsnakes[i];
|
|
|
|
if(c->monst == moHexSnake) {
|
|
|
|
if(!goodmount(c, mounted)) continue;
|
|
|
|
int t[7];
|
|
|
|
for(int i=0; i<c->type; i++) t[i] = i;
|
|
|
|
for(int j=1; j<c->type; j++) swap(t[j], t[hrand(j+1)]);
|
|
|
|
for(int u=0; u<c->type; u++) {
|
|
|
|
createMov(c, t[u]);
|
|
|
|
if(!pseudohept(c->mov[t[u]]))
|
2017-03-23 10:53:57 +00:00
|
|
|
hexvisit(c, c->mov[t[u]], c->spn(t[u]), mounted);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst == moHexSnake) {
|
|
|
|
snakeAttack(c, mounted);
|
|
|
|
kills[moHexSnake]++;
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c, "die-troll");
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c2 = c;
|
|
|
|
while(c2->monst == moHexSnakeTail || c2->monst == moHexSnake) {
|
|
|
|
if(c2->monst != moHexSnake && c2->mondir != NODIR)
|
|
|
|
snakepile(c2, moHexSnake);
|
|
|
|
snakepile(c2, moHexSnake);
|
|
|
|
c2->monst = moNone;
|
|
|
|
if(c2->mondir == NODIR) break;
|
|
|
|
c2 = c2->mov[c2->mondir];
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void movemutant() {
|
|
|
|
vector<cell*> young;
|
|
|
|
for(int i=0; i<size(dcal); i++)
|
|
|
|
if(dcal[i]->monst == moMutant && dcal[i]->stuntime == mutantphase)
|
|
|
|
young.push_back(dcal[i]);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int j=1; j<size(young); j++)
|
|
|
|
swap(young[j], young[hrand(j+1)]);
|
|
|
|
|
|
|
|
mutantphase++;
|
|
|
|
mutantphase &= 15;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<size(young); i++) {
|
|
|
|
cell *c = young[i];
|
|
|
|
if(clearing::buggyplant) { if(c->monst == moMutant) c->monst=moNone; continue; }
|
|
|
|
for(int j=0; j<c->type; j++) {
|
|
|
|
cell *c2 = c->mov[j];
|
|
|
|
if(!c2) continue;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->monst != moMutant && canAttack(c, moMutant, c2, c2->monst, AF_ONLY_FBUG | AF_GETPLAYER)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c2, AF_ORSTUN | AF_MSG | AF_GETPLAYER, moMutant);
|
2016-08-26 09:58:03 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isPlayerOn(c2)) continue;
|
|
|
|
|
|
|
|
if((c2->land == laOvergrown || !pseudohept(c2)) && passable(c2, c, 0)) {
|
|
|
|
if(c2->land == laClearing && c2->mpdist > 7) continue;
|
|
|
|
c2->monst = moMutant;
|
2017-03-23 10:53:57 +00:00
|
|
|
c2->mondir = c->spn(j);
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->stuntime = mutantphase;
|
2017-03-23 10:53:57 +00:00
|
|
|
animateMovement(c, c2, LAYER_BIG);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
cell *shpos[MAXPLAYER][SHSIZE];
|
2016-08-26 09:58:03 +00:00
|
|
|
int cshpos = 0;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void clearshadow() {
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<SHSIZE; i++) for(int p=0; p<MAXPLAYER; p++)
|
|
|
|
shpos[p][i] = NULL;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveshadow() {
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
cell *shfrom = NULL;
|
|
|
|
|
|
|
|
for(int p=0; p<numplayers(); p++) {
|
|
|
|
cell *c = shpos[p][cshpos];
|
|
|
|
if(c && c->monst == moShadow) {
|
|
|
|
for(int j=0; j<c->type; j++)
|
|
|
|
if(c->mov[j] && canAttack(c, moShadow, c->mov[j], c->mov[j]->monst, AF_ONLY_FBUG | AF_GETPLAYER))
|
|
|
|
attackMonster(c->mov[j], AF_ORSTUN | AF_MSG | AF_GETPLAYER, c->monst);
|
|
|
|
c->monst = moNone;
|
|
|
|
shfrom = c;
|
|
|
|
}
|
|
|
|
shpos[p][cshpos] = playerpos(p);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
cshpos = (cshpos+1) % SHSIZE;
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int p=0; p<numplayers(); p++) {
|
|
|
|
cell* where = shpos[p][cshpos];
|
|
|
|
if(where && where->monst == moNone && where->cpdist && where->land == laGraveyard &&
|
|
|
|
!sword::at(where)) {
|
|
|
|
if(shfrom) animateMovement(shfrom, where, LAYER_SMALL);
|
|
|
|
where->monst = moShadow;
|
|
|
|
where->hitpoints = p;
|
|
|
|
where->stuntime = 0;
|
|
|
|
// the Shadow sets off the mines
|
|
|
|
mayExplodeMine(where, moShadow);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveghosts() {
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(invismove) return;
|
|
|
|
for(int d=0; d<8; d++) movesofgood[d].clear();
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<size(ghosts); i++) {
|
|
|
|
cell *c = ghosts[i];
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->stuntime) return;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isGhostMover(c->monst)) {
|
|
|
|
int goodmoves = 0;
|
|
|
|
|
|
|
|
for(int k=0; k<c->type; k++) if(c->mov[k] && c->mov[k]->cpdist < c->cpdist)
|
2017-03-23 10:53:57 +00:00
|
|
|
if(ghostmove(c->monst, c->mov[k], c) && !isPlayerOn(c->mov[k]))
|
2016-08-26 09:58:03 +00:00
|
|
|
goodmoves++;
|
|
|
|
|
|
|
|
movesofgood[goodmoves].push_back(c);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int d=0; d<8; d++) for(int i=0; i<size(movesofgood[d]); i++) {
|
|
|
|
cell *c = movesofgood[d][i];
|
|
|
|
if(c->stuntime) return;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isGhostMover(c->monst) && c->cpdist >= 1) {
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
int mdir[7];
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int j=0; j<c->type; j++)
|
|
|
|
if(c->mov[j] && canAttack(c, c->monst, c->mov[j], c->mov[j]->monst, AF_GETPLAYER | AF_ONLY_FBUG)) {
|
|
|
|
// XLATC ghost/greater shark
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c->mov[j], AF_ORSTUN | AF_MSG | AF_GETPLAYER, c->monst);
|
|
|
|
goto nextghost;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int qmpos = 0;
|
|
|
|
for(int k=0; k<c->type; k++) if(c->mov[k] && c->mov[k]->cpdist < c->cpdist)
|
|
|
|
if(ghostmove(c->monst, c->mov[k], c))
|
|
|
|
mdir[qmpos++] = k;
|
|
|
|
if(!qmpos) continue;
|
|
|
|
int d = mdir[hrand(qmpos)];
|
|
|
|
cell *c2 = c->mov[d];
|
|
|
|
if(c2->monst == moTortoise && c2->stuntime > 1) {
|
|
|
|
addMessage(XLAT("%The1 scares %the2 a bit!", c->monst, c2->monst));
|
|
|
|
c2->stuntime = 1;
|
|
|
|
}
|
|
|
|
else moveMonster(c2, c);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
nextghost: ;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int lastdouble = -3;
|
|
|
|
|
|
|
|
void produceGhost(cell *c, eMonster victim, eMonster who) {
|
|
|
|
if(who != moPlayer && !items[itOrbEmpathy]) return;
|
|
|
|
if(markOrb(itOrbUndeath) && !c->monst && isGhostable(victim)) {
|
|
|
|
c->monst = moFriendlyGhost, c->stuntime = 0;
|
|
|
|
if(who != moPlayer) markOrb(itOrbEmpathy);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool swordAttack(cell *mt, eMonster who, cell *c, int bb) {
|
|
|
|
eMonster m = c->monst;
|
|
|
|
if(c->wall == waCavewall) markOrb(bb ? itOrbSword2: itOrbSword);
|
|
|
|
if(c->wall == waSmallTree || c->wall == waBigTree || c->wall == waRose || c->wall == waCTree || c->wall == waVinePlant ||
|
2017-06-09 01:41:33 +00:00
|
|
|
thruVine(mt, c) || c->wall == waBigBush || c->wall == waSmallBush || c->wall == waSolidBranch || c->wall == waWeakBranch) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(NULL, "hit-axe"+pick123());
|
|
|
|
markOrb(bb ? itOrbSword2: itOrbSword);
|
|
|
|
drawParticles(c, winf[c->wall].color, 16);
|
|
|
|
addMessage(XLAT("You chop down %the1.", c->wall));
|
|
|
|
destroyHalfvine(c);
|
|
|
|
c->wall = waNone;
|
|
|
|
}
|
|
|
|
if(c->wall == waBarrowDig) {
|
|
|
|
playSound(NULL, "hit-axe"+pick123());
|
|
|
|
markOrb(bb ? itOrbSword2: itOrbSword);
|
|
|
|
drawParticles(c, winf[c->wall].color, 16);
|
|
|
|
c->wall = waNone;
|
|
|
|
}
|
|
|
|
if(c->wall == waBarrowWall && items[itBarrow] >= 25) {
|
|
|
|
playSound(NULL, "hit-axe"+pick123());
|
|
|
|
markOrb(bb ? itOrbSword2: itOrbSword);
|
|
|
|
drawParticles(c, winf[c->wall].color, 16);
|
|
|
|
c->wall = waNone;
|
|
|
|
}
|
2017-07-24 22:21:36 +00:00
|
|
|
if(!peace::on && canAttack(mt, who, c, m, AF_SWORD)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
markOrb(bb ? itOrbSword2: itOrbSword);
|
|
|
|
int k = tkills();
|
|
|
|
attackMonster(c, AF_ORSTUN | AF_MSG | AF_SWORD, who);
|
|
|
|
if(c->monst == moShadow) c->monst = moNone;
|
|
|
|
produceGhost(c, m, who);
|
|
|
|
if(tkills() > k) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-08-14 19:32:02 +00:00
|
|
|
void swordAttackStatic(int bb) {
|
|
|
|
swordAttack(cwt.c, moPlayer, sword::pos(multi::cpid, bb), bb);
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void swordAttackStatic() {
|
|
|
|
for(int bb = 0; bb < 2; bb++)
|
|
|
|
if(sword::orbcount(bb))
|
2017-08-14 19:32:02 +00:00
|
|
|
swordAttackStatic(bb);
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void stabbingAttack(cell *mf, cell *mt, eMonster who, int bonuskill) {
|
|
|
|
int numsh = 0, numflail = 0, numlance = 0, numslash = 0;
|
|
|
|
|
|
|
|
int backdir = neighborId(mt, mf);
|
|
|
|
|
|
|
|
for(int bb=0; bb<2; bb++) if(who == moPlayer && sword::orbcount(bb)) {
|
|
|
|
int numbb = 0;
|
|
|
|
cell *sf = sword::pos(mf, sword::angle[multi::cpid] + (bb?S21:0));
|
|
|
|
cell *st = sword::pos(mt, sword::shift(mf, mt, sword::angle[multi::cpid]) + (bb?S21:0));
|
|
|
|
if(swordAttack(mt, who, st, bb)) numbb++;
|
|
|
|
if(sf != st && !isNeighbor(sf,st)) {
|
|
|
|
// also attack the in-transit cell
|
|
|
|
forCellEx(sb, sf) if(isNeighbor(sb, st) && sb != mf && sb != mt)
|
|
|
|
if(swordAttack(mt, who, sb, bb)) numbb++;
|
|
|
|
}
|
|
|
|
achievement_count("SLASH", numbb, 0);
|
|
|
|
numslash += numbb;
|
|
|
|
}
|
2017-07-24 22:21:36 +00:00
|
|
|
|
|
|
|
if(peace::on) return;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int t=0; t<mf->type; t++) {
|
|
|
|
cell *c = mf->mov[t];
|
|
|
|
if(!c) continue;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
bool stabthere = false, away = true;
|
|
|
|
for(int u=0; u<c->type; u++) if(c->mov[u] == mt) stabthere = true, away = false;
|
|
|
|
|
|
|
|
if(stabthere && canAttack(mt,who,c,c->monst,AF_STAB)) {
|
|
|
|
if(c->monst != moHedge) {
|
|
|
|
markOrb(itOrbThorns); if(who != moPlayer) markOrb(itOrbEmpathy);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
eMonster m = c->monst;
|
|
|
|
int k = tkills();
|
|
|
|
if(attackMonster(c, AF_ORSTUN | AF_STAB | AF_MSG, who))
|
|
|
|
produceGhost(c, m, who);
|
|
|
|
if(tkills() > k) numsh++;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(away && c != mt && canAttack(mt,who,c,c->monst,AF_BACK)) {
|
|
|
|
if(c->monst == moVizier && c->hitpoints > 1) {
|
|
|
|
fightmessage(c->monst, who, true, AF_BACK);
|
|
|
|
c->hitpoints--;
|
|
|
|
// c->stuntime = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
eMonster m = c->monst;
|
|
|
|
if(c->monst != moFlailer) {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
|
|
|
fightmessage(c->monst, who, false, AF_BACK);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
playSound(NULL, "hit-sword"+pick123());
|
2016-08-26 09:58:03 +00:00
|
|
|
if(who != moPlayer)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("%The1 tricks %the2.", who, c->monst));
|
2016-08-26 09:58:03 +00:00
|
|
|
else
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You trick %the1.", c->monst));
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->monst == moFlailer && isPrincess(who) && isUnarmed(who))
|
|
|
|
achievement_gain("PRINCESS_PACIFIST");
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(attackMonster(c, 0, who)) numflail++;
|
|
|
|
if(m == moVizier) produceGhost(c, m, who);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!isUnarmed(who)) for(int t=0; t<mt->type; t++) {
|
|
|
|
cell *c = mt->mov[t];
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!c) continue;
|
|
|
|
eMonster mm = c->monst;
|
|
|
|
int flag = AF_APPROACH;
|
|
|
|
if(angledist(mt, backdir, t) >= 3) flag |= AF_HORNS;
|
|
|
|
if(canAttack(mt,who,c,c->monst, flag)) {
|
|
|
|
if(attackMonster(c, flag | AF_MSG, who)) numlance++;
|
|
|
|
produceGhost(c, mm, who);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(numsh) achievement_count("STAB", numsh, 0);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(numlance && numflail && numsh) achievement_gain("MELEE3");
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(numlance + numflail + numsh + numslash + bonuskill >= 5) achievement_gain("MELEE5");
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(numsh == 2) {
|
|
|
|
if(lastdouble == turncount-1) achievement_count("STAB", 4, 0);
|
|
|
|
lastdouble = turncount;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool cellDangerous(cell *c) {
|
|
|
|
return cellUnstableOrChasm(c) || isFire(c) || c->wall == waClosedGate;
|
|
|
|
}
|
|
|
|
|
|
|
|
// negative: die, attack friend, stay against rose, hit a wall, move against rose, hit the player
|
|
|
|
|
|
|
|
bool hasPrincessWeapon(eMonster m) {
|
|
|
|
return m == moPalace || m == moFatGuard;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int stayvalue(eMonster m, cell *c) {
|
|
|
|
if(!passable_for(c->monst, c, NULL, P_MONSTER | P_MIRROR))
|
|
|
|
return -1501;
|
|
|
|
if(cellEdgeUnstable(c))
|
|
|
|
return -1501;
|
|
|
|
if(againstRose(c, NULL) && !ignoresSmell(c->monst)) return -1500;
|
|
|
|
return 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
// friendly version of moveval
|
|
|
|
int movevalue(eMonster m, cell *c, cell *c2, flagtype flags) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int val = 0;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isPlayerOn(c2)) val = -3000;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(againstRose(c, c2) && !ignoresSmell(m)) return -1200;
|
|
|
|
else if(m == moPrincess && c2->stuntime && hasPrincessWeapon(c2->monst) &&
|
|
|
|
!cellDangerous(c) && !cellDangerous(c2) && canAttack(c, m, c2, c2->monst, AF_IGNORE_UNARMED | flags)) {
|
|
|
|
val = 15000;
|
|
|
|
}
|
|
|
|
else if(canAttack(c,m,c2,c2->monst,flags))
|
2017-03-23 10:53:57 +00:00
|
|
|
val =
|
2016-08-26 09:58:03 +00:00
|
|
|
(m == moPrincessArmed && isPrincess(c2->monst)) ? 14000 : // jealousy!
|
2017-03-23 10:53:57 +00:00
|
|
|
isActiveEnemy(c2,m) ? 12000 :
|
|
|
|
(c2->monst == moSkeleton || c2->monst == moMetalBeast ||
|
|
|
|
c2->monst == moReptile || c2->monst == moTortoise) ? -400 :
|
2016-08-26 09:58:03 +00:00
|
|
|
isIvy(c2) ? 8000 :
|
|
|
|
isInactiveEnemy(c2,m) ? 1000 :
|
|
|
|
-500;
|
|
|
|
|
|
|
|
else if(monstersnear(c2, NULL, m, NULL, c)) val = 50; // linked with mouse suicide!
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(passable_for(m, c2, c, 0)) {
|
|
|
|
if(mineMarked(c2) && !ignoresPlates(m))
|
|
|
|
val = 50;
|
|
|
|
else
|
|
|
|
val = 4000;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(passable_for(m, c2, c, P_DEADLY)) val = -1100;
|
2017-03-23 10:53:57 +00:00
|
|
|
else val = -1750;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst == moGolem )
|
|
|
|
val -= c2->cpdist;
|
|
|
|
else if(c->monst == moFriendlyGhost )
|
|
|
|
val += c2->cpdist - 40;
|
|
|
|
else if(c->monst == moMouse) {
|
|
|
|
int d;
|
|
|
|
if(!euclid && (c2->land != laPalace || !c2->master->alt)) d = 200;
|
|
|
|
else d = celldistAlt(c2);
|
|
|
|
// first rule: suicide if the Princess is killed,
|
|
|
|
// by monstersnear or jumping into a chasm
|
|
|
|
princess::info *i = princess::getPrisonInfo(c);
|
|
|
|
if(i && !i->princess) {
|
|
|
|
if(val == 50 || c2->wall == waChasm) val = 20000;
|
|
|
|
}
|
|
|
|
// second rule: move randomly if the Princess is saved
|
|
|
|
if(i && i->bestdist > 6)
|
|
|
|
;
|
|
|
|
// third rule: do not get too far from the Princess
|
|
|
|
else if(d > 150)
|
|
|
|
val -= (700+d);
|
|
|
|
// fourth rule: do not get too far from the Rogue
|
|
|
|
// NOTE: since Mouse is not a target, we can use
|
|
|
|
// the full pathfinding here instead of cpdist!
|
|
|
|
else if(c2->pathdist > 3 && c2->pathdist <= 19)
|
|
|
|
val -= (500+c2->pathdist * 10);
|
|
|
|
else if(c2->pathdist > 19)
|
|
|
|
val -= (700);
|
|
|
|
// fifth rule: get close to the Princess, to point the way
|
|
|
|
else
|
|
|
|
val -= (250+d);
|
|
|
|
/*
|
|
|
|
// avoid stepping on trapdoors and plates
|
|
|
|
// (REMOVED BECAUSE MICE NO LONGER ACTIVATE TRAPDOORS AND PLATES)
|
|
|
|
// note that the Mouse will still step on the trapdoor
|
|
|
|
// if it wants to get close to you and there is no other way
|
|
|
|
if(c2->wall == waTrapdoor)
|
|
|
|
val -= 5;
|
|
|
|
*/
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isPrincess(c->monst)) {
|
|
|
|
|
|
|
|
int d = c2->cpdist;
|
|
|
|
if(d <= 3) val -= d;
|
|
|
|
else val -= 10 * d;
|
|
|
|
|
|
|
|
// the Princess also avoids stepping on pressure plates
|
|
|
|
if(c2->wall == waClosePlate || c2->wall == waOpenPlate || c2->wall == waTrapdoor)
|
|
|
|
val -= 5;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst == moTameBomberbird) {
|
|
|
|
int d = c2->cpdist;
|
|
|
|
if(d == 1 && c->cpdist > 1) d = 5;
|
|
|
|
if(d == 2 && c->cpdist > 2) d = 4;
|
|
|
|
val -= d;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!euclid && c->monst == moKnight && c2->master->alt) {
|
2016-08-26 09:58:03 +00:00
|
|
|
val -= celldistAlt(c2);
|
2017-03-23 10:53:57 +00:00
|
|
|
// don't go to external towers
|
|
|
|
if(c2->wall == waTower && c2->wparam == 1 && !c2->monst)
|
|
|
|
return 60;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return val;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
#define STRONGWIND 99
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void movegolems(flagtype flags) {
|
|
|
|
computePathdist(moMouse);
|
2016-08-26 09:58:03 +00:00
|
|
|
int qg = 0;
|
|
|
|
for(int i=0; i<size(golems); i++) {
|
|
|
|
cell *c = golems[i];
|
|
|
|
eMonster m = c->monst;
|
|
|
|
if(c->stuntime) continue;
|
|
|
|
if(m == moGolem || m == moKnight || m == moTameBomberbird || m == moPrincess ||
|
|
|
|
m == moPrincessArmed || m == moMouse || m == moFriendlyGhost) {
|
|
|
|
if(m == moGolem) qg++;
|
|
|
|
if(m == moFriendlyGhost) markOrb(itOrbUndeath);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool recorduse[ittypes];
|
|
|
|
for(int i=0; i<ittypes; i++) recorduse[i] = orbused[i];
|
|
|
|
|
|
|
|
DEBT("stayval");
|
|
|
|
int bestv = stayvalue(m, c), bq = 0, bdirs[7];
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
DEBT("moveval");
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int k=0; k<c->type; k++) if(c->mov[k]) {
|
|
|
|
cell *c2 = c->mov[k];
|
|
|
|
int val = movevalue(m, c, c2, flags);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(val > bestv) bestv = val, bq = 0;
|
|
|
|
if(val == bestv) bdirs[bq++] = k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m == moTameBomberbird) {
|
|
|
|
cell *c2 = whirlwind::jumpDestination(c);
|
|
|
|
if(c2 && !c2->monst) {
|
|
|
|
int val = movevalue(m, c, c2, flags);
|
|
|
|
// printf("val = %d bestv = %d\n",
|
|
|
|
if(val > bestv) bestv = val, bq = 0;
|
|
|
|
if(val == bestv) bdirs[bq++] = STRONGWIND;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
for(int i=0; i<ittypes; i++) orbused[i] = recorduse[i];
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
// printf("stayvalue = %d, result = %d, bq = %d\n", stayvalue(m,c), bestv, bq);
|
|
|
|
|
|
|
|
if(bq == 0) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
int dir = bdirs[hrand(bq)];
|
|
|
|
cell *c2 = dir != STRONGWIND ? c->mov[dir] : whirlwind::jumpDestination(c);
|
|
|
|
if(c2->monst) {
|
2017-03-23 10:53:57 +00:00
|
|
|
bool revenge = (m == moPrincess);
|
|
|
|
bool jealous = (isPrincess(c->monst) && isPrincess(c2->monst));
|
|
|
|
eMonster m2 = c2->monst;
|
|
|
|
if(revenge) {
|
|
|
|
playSound(c2, princessgender() ? "dzia-princess" : "dzia-prince");
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("%The1 takes %his1 revenge on %the2!", m, c2->monst));
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c2, ((revenge||jealous)?0:AF_ORSTUN) | AF_MSG, m);
|
|
|
|
produceGhost(c2, m2, m);
|
|
|
|
if(revenge) c->monst = m = moPrincessArmed;
|
|
|
|
if(jealous) {
|
|
|
|
playSound(c2, princessgender() ? "dzia-princess" : "dzia-prince");
|
|
|
|
addMessage("\"That should teach you to take me seriously!\"");
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else {
|
2017-03-23 10:53:57 +00:00
|
|
|
passable_for(m, c2, c, P_DEADLY);
|
|
|
|
DEBT("move");
|
2016-08-26 09:58:03 +00:00
|
|
|
moveMonster(c2, c);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m != moTameBomberbird && m != moFriendlyGhost)
|
2016-08-26 09:58:03 +00:00
|
|
|
moveBoatIfUsingOne(c2, c);
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->monst == m) {
|
|
|
|
if(m == moGolem) c2->monst = moGolemMoved;
|
|
|
|
if(m == moMouse) c2->monst = moMouseMoved;
|
|
|
|
if(m == moPrincess) c2->monst = moPrincessMoved;
|
|
|
|
if(m == moPrincessArmed) c2->monst = moPrincessArmedMoved;
|
|
|
|
if(m == moTameBomberbird) c2->monst = moTameBomberbirdMoved;
|
|
|
|
if(m == moKnight) c2->monst = moKnightMoved;
|
|
|
|
if(m == moFriendlyGhost) c2->stuntime = 1;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
empathyMove(c, c2, dir);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
DEBT("other");
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
achievement_count("GOLEM", qg, 0);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void sageheat(cell *c, double v) {
|
|
|
|
HEAT(c) += v;
|
|
|
|
if(c->wall == waFrozenLake && HEAT(c) > .6) c->wall = waLake;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void activateFlashFrom(cell *cf, eMonster who, flagtype flags);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
vector<cell*> nonmovers;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool sagefresh = true;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int nearestPathPlayer(cell *c) {
|
|
|
|
for(int i=0; i<numplayers(); i++) if(playerpos(i) == c) return i;
|
|
|
|
forCellEx(c2, c) if(c2->pathdist < c->pathdist) return nearestPathPlayer(c2);
|
|
|
|
for(int i=0; i<numplayers(); i++) if(multi::playerActive(i)) return i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// note: butterflies don't use moveNormal for two reasons:
|
|
|
|
// 1) to make sure that they move AFTER bulls
|
|
|
|
// 2) to make sure that they move offscreen
|
|
|
|
void moveButterflies() {
|
|
|
|
int j = 0;
|
|
|
|
for(int i=0; i<size(butterflies); i++) {
|
|
|
|
cell* c = butterflies[i].first;
|
|
|
|
if(c->monst == moButterfly) {
|
|
|
|
/* // don't move if under attack of a bull
|
|
|
|
bool underattack = false;
|
|
|
|
forCellEx(c3, c)
|
|
|
|
if(c3->monst == moRagingBull && c3->mondir != NODIR &&
|
|
|
|
angledist(c3->type, c3->mondir, neighborId(c3, c)) == 3 &&
|
|
|
|
canAttack(c3, moRagingBull, c, c->monst, AF_BULL)
|
|
|
|
)
|
|
|
|
underattack = true;
|
|
|
|
if(underattack) continue; */
|
|
|
|
cell *c2 = moveNormal(c, 0);
|
|
|
|
if(butterflies[i].second < 50 && c2)
|
|
|
|
butterflies[j++] = make_pair(c2, butterflies[i].second+1);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
butterflies.resize(j);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
// assume pathdist
|
|
|
|
void specialMoves() {
|
|
|
|
for(int i=0; i<size(dcal); i++) {
|
|
|
|
cell *c = dcal[i];
|
|
|
|
|
|
|
|
if(c->stuntime) continue;
|
|
|
|
|
|
|
|
eMonster m = c->monst;
|
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
if(m == moSleepBull && !peace::on) {
|
2017-03-23 10:53:57 +00:00
|
|
|
bool wakeup = false;
|
|
|
|
forCellEx(c2, c) if(c2->monst == moGadfly) {
|
|
|
|
addMessage(XLAT("%The1 wakes up %the2.", c2->monst, m));
|
|
|
|
wakeup = true;
|
|
|
|
}
|
|
|
|
for(int i=0; i<size(targets); i++) {
|
|
|
|
cell *t = targets[i];
|
|
|
|
if(celldistance(c, t) <= 2) wakeup = true;
|
|
|
|
}
|
|
|
|
if(wakeup) {
|
|
|
|
playSound(NULL, "bull");
|
|
|
|
c->monst = m = moRagingBull;
|
|
|
|
c->mondir = NODIR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m == moNecromancer) {
|
|
|
|
computePathdist(moNecromancer);
|
2016-08-26 09:58:03 +00:00
|
|
|
int gravenum = 0, zombienum = 0;
|
|
|
|
cell *gtab[8], *ztab[8];
|
|
|
|
for(int j=0; j<c->type; j++) if(c->mov[j]) {
|
|
|
|
if(c->mov[j]->wall == waFreshGrave) gtab[gravenum++] = c->mov[j];
|
|
|
|
if(passable(c->mov[j], c, 0) && c->mov[j]->pathdist < c->pathdist)
|
|
|
|
ztab[zombienum++] = c->mov[j];
|
|
|
|
}
|
|
|
|
if(gravenum && zombienum) {
|
|
|
|
cell *gr = gtab[hrand(gravenum)];
|
|
|
|
gr->wall = waAncientGrave;
|
|
|
|
gr->monst = moGhost;
|
|
|
|
ztab[hrand(zombienum)]->monst = moZombie;
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("%The1 raises some undead!", m));
|
|
|
|
playSound(c, "necromancy");
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(m == moOutlaw && c->pathdist <= GUNRANGE) {
|
|
|
|
killThePlayer(m, nearestPathPlayer(c), 0);
|
|
|
|
c->stuntime = 1;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(m == moWitchFlash && flashWouldKill(c, AF_GETPLAYER | AF_ONLY_FBUG) && !flashWouldKill(c, false)) {
|
|
|
|
addMessage(XLAT("%The1 activates her Flash spell!", m));
|
|
|
|
m = moWitch;
|
|
|
|
activateFlashFrom(c, moWitchFlash, AF_MAGIC | AF_GETPLAYER | AF_MSG);
|
|
|
|
c->stuntime = 1;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(m == moCrystalSage && c->cpdist <= 4 && isIcyLand(cwt.c) && cwt.c->wall != waBoat) {
|
2016-08-26 09:58:03 +00:00
|
|
|
// only one sage attacks
|
|
|
|
if(sagefresh) {
|
|
|
|
sagefresh = false;
|
|
|
|
if(sagephase == 0) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("%The1 shows you two fingers.", m));
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("You wonder what does it mean?"));
|
|
|
|
}
|
|
|
|
else if(sagephase == 1) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("%The1 shows you a finger.", m));
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("You think about possible meanings."));
|
|
|
|
}
|
|
|
|
else {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("%The1 moves his finger downwards.", m));
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("Your brain is steaming."));
|
|
|
|
}
|
|
|
|
sagephase++;
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<size(targets); i++) {
|
|
|
|
cell *t = targets[i];
|
|
|
|
if(celldistance(c, t) > 4) continue;
|
|
|
|
sageheat(t, .0);
|
|
|
|
for(int i=0; i<t->type; i++)
|
|
|
|
sageheat(t->mov[i], .3);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
c->stuntime = 1;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-07-24 22:21:36 +00:00
|
|
|
else if(m == moPyroCultist && !peace::on) {
|
2017-03-23 10:53:57 +00:00
|
|
|
bool shot = false;
|
|
|
|
bool dont_approach = false;
|
|
|
|
// smaller range on the sphere
|
|
|
|
int firerange = sphere ? 2 : 4;
|
|
|
|
for(int i=0; i<size(targets); i++) {
|
|
|
|
cell *t = targets[i];
|
|
|
|
if(celldistance(c,t) <= firerange && makeflame(t, 20, true)) {
|
|
|
|
if(isPlayerOn(t))
|
|
|
|
addMessage(XLAT("%The1 throws fire at you!", m));
|
|
|
|
else
|
|
|
|
addMessage(XLAT("%The1 throws fire at %the2!", m, t->monst));
|
|
|
|
makeflame(t, 20, false);
|
|
|
|
playSound(t, "fire");
|
|
|
|
c->monst = moCultist;
|
|
|
|
shot = true;
|
|
|
|
}
|
|
|
|
if(celldistance(c,t) <= 3 && !sphere) dont_approach = true;
|
|
|
|
}
|
|
|
|
if(shot || dont_approach) c->stuntime = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(m == moVampire) {
|
|
|
|
for(int i=0; i<size(targets); i++) {
|
|
|
|
cell *t = targets[i];
|
|
|
|
if(celldistance(c,t) <= 2) {
|
|
|
|
bool msg = false;
|
|
|
|
for(int i=0; i<ittypes; i++)
|
|
|
|
if(itemclass(eItem(i)) == IC_ORB && items[i] && items[itOrbTime] && !orbused[i]) {
|
|
|
|
orbused[i] = true;
|
|
|
|
msg = true;
|
|
|
|
}
|
|
|
|
if(msg) addMessage(XLAT("%The1 drains your powers!", m));
|
|
|
|
c->stuntime = 1;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveworms() {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!size(worms)) return;
|
|
|
|
computePathdist(moWorm);
|
2016-08-26 09:58:03 +00:00
|
|
|
int wrm = size(worms);
|
|
|
|
for(int i=0; i<wrm; i++) {
|
|
|
|
moveWorm(worms[i]);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void refreshFriend(cell *c) {
|
|
|
|
if(c->monst == moGolemMoved) c->monst = moGolem;
|
|
|
|
if(c->monst == moMouseMoved) c->monst = moMouse;
|
|
|
|
if(c->monst == moPrincessMoved) c->monst = moPrincess;
|
|
|
|
if(c->monst == moPrincessArmedMoved) c->monst = moPrincessArmed;
|
|
|
|
if(c->monst == moKnightMoved) c->monst = moKnight;
|
|
|
|
if(c->monst == moTameBomberbirdMoved) c->monst = moTameBomberbird;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void moverefresh(bool turn = true) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int dcs = size(dcal);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<dcs; i++) {
|
|
|
|
cell *c = dcal[i];
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst == moWolfMoved) c->monst = moWolf;
|
|
|
|
if(c->monst == moIvyNext) {
|
|
|
|
c->monst = moIvyHead; ivynext(c);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst == moIvyDead)
|
|
|
|
removeIvy(c);
|
|
|
|
refreshFriend(c);
|
|
|
|
if(c->monst == moSlimeNextTurn) c->monst = moSlime;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->monst == moLesser && !cellEdgeUnstable(c)) c->monst = moLesserM;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c->monst == moLesserM) c->monst = moLesser;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->monst == moGreater && !cellEdgeUnstable(c)) c->monst = moGreaterM;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c->monst == moGreaterM) c->monst = moGreater;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->stuntime && !isMutantIvy(c)) {
|
|
|
|
c->stuntime--;
|
2017-03-23 10:53:57 +00:00
|
|
|
int breathrange = sphere ? 2 : 3;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->stuntime == 0 && c->monst == moDragonHead) {
|
|
|
|
if(!c->hitpoints) c->hitpoints = 1;
|
|
|
|
else if(shmup::on && dragon::totalhp(c) > 2 && shmup::dragonbreath(c)) {
|
|
|
|
c->hitpoints = 0;
|
|
|
|
}
|
|
|
|
else if(dragon::totalhp(c) <= 2) ;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(items[itOrbDomination] && isMounted(c)) {
|
|
|
|
if(dragon::target && celldistance(c, dragon::target) <= breathrange && makeflame(dragon::target, 5, true)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("%The1 breathes fire!", c->monst));
|
|
|
|
makeflame(dragon::target, 5, false);
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(dragon::target, "fire");
|
2016-08-26 09:58:03 +00:00
|
|
|
c->hitpoints = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<size(targets); i++) {
|
|
|
|
cell *t = targets[i];
|
|
|
|
if(celldistance(c, t) <= breathrange && makeflame(t, 5, true)) {
|
|
|
|
if(isPlayerOn(t)) addMessage(XLAT("%The1 breathes fire at you!", c->monst));
|
|
|
|
else if(t->monst)
|
|
|
|
addMessage(XLAT("%The1 breathes fire at %the2!", c->monst, t->monst));
|
|
|
|
else
|
|
|
|
addMessage(XLAT("%The1 breathes fire!", c->monst));
|
|
|
|
makeflame(t, 5, false);
|
|
|
|
playSound(t, "fire");
|
|
|
|
c->hitpoints = 0;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// tortoises who have found their children no longer move
|
|
|
|
if(c->monst == moTortoise && c->item == itBabyTortoise &&
|
|
|
|
!((tortoise::getb(c) ^ tortoise::babymap[c]) & tortoise::mask))
|
|
|
|
c->stuntime = 2;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->monst == moReptile) {
|
|
|
|
if(c->wall == waChasm || cellUnstable(c)) {
|
|
|
|
c->monst = moNone;
|
|
|
|
c->wall = waReptile;
|
|
|
|
c->wparam = reptilemax();
|
|
|
|
playSound(c, "click");
|
|
|
|
}
|
|
|
|
else if(isChasmy(c) || isWatery(c)) {
|
|
|
|
c->wall = waReptileBridge;
|
|
|
|
c->item = itNone;
|
|
|
|
c->wparam = reptilemax();
|
|
|
|
c->monst = moNone;
|
|
|
|
playSound(c, "click");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->wall == waChasm) {
|
|
|
|
if(c->land != laWhirlwind) c->item = itNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(c->monst && !survivesChasm(c->monst) && c->monst != moReptile) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst != moRunDog && c->land == laMotion)
|
|
|
|
achievement_gain("FALLDEATH1");
|
|
|
|
addMessage(XLAT("%The1 falls!", c->monst));
|
2017-03-23 10:53:57 +00:00
|
|
|
fallMonster(c, AF_FALL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(isReptile(c->wall) && turn) {
|
|
|
|
if(c->monst || isPlayerOn(c)) c->wparam = -1;
|
|
|
|
else if(c->cpdist <= 7) {
|
|
|
|
c->wparam--;
|
|
|
|
if(c->wparam == 0) {
|
|
|
|
if(c->wall == waReptile) c->wall = waChasm;
|
|
|
|
else placeWater(c, NULL);
|
|
|
|
c->monst = moReptile;
|
|
|
|
c->hitpoints = 3;
|
|
|
|
c->stuntime = 0;
|
2017-07-04 13:38:33 +00:00
|
|
|
int gooddirs[7], qdirs = 0;
|
|
|
|
// in the peace mode, a reptile will
|
|
|
|
// prefer to walk on the ground, rather than the chasm
|
|
|
|
for(int i=0; i<c->type; i++) {
|
|
|
|
int i0 = (i+3) % c->type;
|
|
|
|
int i1 = (i+c->type-3) % c->type;
|
|
|
|
if(c->mov[i0] && passable(c->mov[i0], c, 0))
|
|
|
|
if(c->mov[i1] && passable(c->mov[i1], c, 0))
|
|
|
|
gooddirs[qdirs++] = i;
|
|
|
|
}
|
|
|
|
if(qdirs) c->mondir = gooddirs[hrand(qdirs)];
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c, "click");
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(isFire(c)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst && !survivesFire(c->monst)) {
|
|
|
|
addMessage(XLAT("%The1 burns!", c->monst));
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isBull(c->monst)) {
|
|
|
|
addMessage(XLAT("Fire is extinguished!"));
|
|
|
|
c->wall = waNone;
|
|
|
|
}
|
|
|
|
fallMonster(c);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
if(c->item && itemBurns(c->item)) {
|
|
|
|
addMessage(XLAT("%The1 burns!", c->item));
|
|
|
|
c->item = itNone;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(isWatery(c)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->monst == moLesser || c->monst == moLesserM || c->monst == moGreater || c->monst == moGreaterM)
|
|
|
|
c->monst = moGreaterShark;
|
|
|
|
if(c->monst && !survivesWater(c->monst)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c, "splash"+pick12());
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isNonliving(c->monst))
|
|
|
|
addMessage(XLAT("%The1 sinks!", c->monst));
|
|
|
|
else
|
|
|
|
addMessage(XLAT("%The1 drowns!", c->monst));
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isBull(c->monst)) {
|
|
|
|
addMessage(XLAT("%The1 is filled!", c->wall));
|
|
|
|
c->wall = waNone;
|
|
|
|
}
|
|
|
|
fallMonster(c, AF_FALL);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(!isWateryOrBoat(c)) {
|
|
|
|
if(c->monst == moGreaterShark)
|
|
|
|
c->monst = moGreaterM;
|
|
|
|
else if(c->monst == moShark || c->monst == moCShark) {
|
|
|
|
addMessage(XLAT("%The1 suffocates!", c->monst));
|
|
|
|
fallMonster(c);
|
|
|
|
}
|
|
|
|
else if(c->monst == moKrakenH) {
|
|
|
|
addMessage(XLAT("%The1 suffocates!", c->monst));
|
|
|
|
kraken::kill(c, moNone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c->monst == moVineSpirit && !cellHalfvine(c) && c->wall != waVinePlant) {
|
|
|
|
addMessage(XLAT("%The1 is destroyed!", c->monst));
|
|
|
|
fallMonster(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c->monst) mayExplodeMine(c, c->monst);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(c->monst && c->wall == waClosedGate && !survivesWall(c->monst)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c, "hit-crush"+pick123());
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("%The1 is crushed!", c->monst));
|
2017-03-23 10:53:57 +00:00
|
|
|
fallMonster(c);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->monst && cellUnstable(c) && !ignoresPlates(c->monst) && !shmup::on)
|
|
|
|
doesFallSound(c);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void consMove(cell *c, eMonster param) {
|
|
|
|
eMonster m = c->monst;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!normalMover(m)) return;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m == moWitchSpeed) havewhat |= HF_FAST;
|
|
|
|
bool slow = slowMover(m);
|
|
|
|
if(slow) havewhat |= HF_SLOW;
|
|
|
|
|
|
|
|
if(param == moYeti && slow) return;
|
|
|
|
if(param == moTortoise && !slow) return;
|
|
|
|
if(param == moWitchSpeed && m != moWitchSpeed) return;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isActiveEnemy(c, moPlayer)) {
|
|
|
|
int goodmoves = 0;
|
|
|
|
for(int t=0; t<c->type; t++) {
|
|
|
|
cell *c2 = c->mov[t];
|
|
|
|
if(c2 && c2->pathdist < c->pathdist)
|
|
|
|
goodmoves++;
|
|
|
|
}
|
|
|
|
movesofgood[goodmoves].push_back(c);
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else
|
|
|
|
movesofgood[0].push_back(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void moveNormals(eMonster param) {
|
|
|
|
computePathdist(param);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int d=0; d<8; d++) movesofgood[d].clear();
|
|
|
|
|
|
|
|
for(int i=0; i<size(pathqm); i++)
|
|
|
|
consMove(pathqm[i], param);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int dcs = size(dcal);
|
|
|
|
for(int i=0; i<dcs; i++) {
|
2016-01-02 10:09:13 +00:00
|
|
|
cell *c = dcal[i];
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->pathdist == PINFD) consMove(c, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int d=0; d<8; d++) for(int i=0; i<size(movesofgood[d]); i++) {
|
|
|
|
cell *c = movesofgood[d][i];
|
|
|
|
if(normalMover(c->monst)) {
|
|
|
|
moveNormal(c, MF_PATHDIST);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void movemonsters() {
|
|
|
|
|
|
|
|
sagefresh = true;
|
|
|
|
turncount++;
|
|
|
|
|
|
|
|
specialMoves();
|
|
|
|
|
|
|
|
DEBT("ghosts");
|
|
|
|
moveghosts();
|
|
|
|
|
|
|
|
DEBT("butterflies");
|
|
|
|
moveButterflies();
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
DEBT("normal");
|
|
|
|
moveNormals(moYeti);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
DEBT("slow");
|
|
|
|
if(havewhat & HF_SLOW) moveNormals(moTortoise);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(sagefresh) sagephase = 0;
|
|
|
|
|
|
|
|
DEBT("ivy");
|
|
|
|
moveivy();
|
|
|
|
DEBT("slimes");
|
|
|
|
groupmove(moSlime, 0);
|
2017-03-23 10:53:57 +00:00
|
|
|
DEBT("sharks");
|
|
|
|
if(havewhat & HF_SHARK) groupmove(moShark, 0);
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("eagles");
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_BIRD) groupmove(moEagle, 0);
|
|
|
|
if(havewhat & HF_EAGLES) groupmove(moEagle, MF_NOATTACKS | MF_ONLYEAGLE);
|
|
|
|
DEBT("eagles");
|
|
|
|
if(havewhat & HF_REPTILE) groupmove(moReptile, 0);
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("air");
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_AIR) {
|
2016-08-26 09:58:03 +00:00
|
|
|
airmap.clear();
|
|
|
|
groupmove(moAirElemental, 0);
|
|
|
|
buildAirmap();
|
|
|
|
}
|
|
|
|
DEBT("earth");
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_EARTH) groupmove(moEarthElemental, 0);
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("water");
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_WATER) groupmove(moWaterElemental, 0);
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("leader");
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_LEADER) groupmove(moPirate, 0);
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("mutant");
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_MUTANT) movemutant();
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("bugs");
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_BUG) hive::movebugs();
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("whirlpool");
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_WHIRLPOOL) whirlpool::move();
|
|
|
|
DEBT("whirlwind");
|
|
|
|
if(havewhat & HF_WHIRLWIND) whirlwind::move();
|
|
|
|
DEBT("river");
|
|
|
|
if(havewhat & HF_RIVER) prairie::move();
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("worm");
|
2017-03-23 10:53:57 +00:00
|
|
|
cell *savepos[MAXPLAYER];
|
|
|
|
|
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
savepos[i] = playerpos(i);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
moveworms();
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_HEX) {
|
|
|
|
movehex(false);
|
|
|
|
if(haveMount()) movehex(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(havewhat & HF_KRAKEN) kraken::attacks(), groupmove(moKrakenH, 0);
|
|
|
|
if(havewhat & HF_DRAGON) groupmove(moDragonHead, MF_NOFRIEND);
|
|
|
|
if(haveMount()) groupmove(moDragonHead, MF_MOUNT);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("golems");
|
|
|
|
movegolems(0);
|
|
|
|
|
|
|
|
DEBT("fresh");
|
|
|
|
moverefresh();
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("shadow");
|
|
|
|
moveshadow();
|
|
|
|
|
|
|
|
DEBT("wandering");
|
|
|
|
wandering();
|
|
|
|
|
|
|
|
DEBT("rosemap");
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat & HF_ROSE) buildRosemap();
|
|
|
|
|
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
if(savepos[i] != playerpos(i)) {
|
|
|
|
bfs(); break;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// move heat
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// move the PC in direction d (or stay in place for d == -1)
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool checkNeedMove(bool checkonly, bool attacking) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(items[itOrbDomination] > ORBBASE && cwt.c->monst)
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
2017-08-06 12:50:16 +00:00
|
|
|
int flags = 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(cwt.c->monst) {
|
|
|
|
if(checkonly) return true;
|
|
|
|
if(isMountable(cwt.c->monst))
|
|
|
|
addMessage(XLAT("You need to dismount %the1!", cwt.c->monst));
|
|
|
|
else
|
|
|
|
addMessage(XLAT("You need to move to give space to %the1!", cwt.c->monst));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(cwt.c->wall == waRoundTable) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(markOrb2(itOrbAether)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
|
|
|
addMessage(XLAT("It would be impolite to land on the table!"));
|
|
|
|
}
|
|
|
|
else if(cwt.c->wall == waLake) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(markOrb2(itOrbAether)) return false;
|
|
|
|
if(markOrb2(itOrbFish)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
2017-08-06 12:50:16 +00:00
|
|
|
flags |= AF_FALL;
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("Ice below you is melting! RUN!"));
|
|
|
|
}
|
|
|
|
else if(!attacking && cellEdgeUnstable(cwt.c)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(markOrb2(itOrbAether)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
|
|
|
addMessage(XLAT("Nothing to stand on here!"));
|
|
|
|
}
|
|
|
|
else if(cwt.c->wall == waSea || cwt.c->wall == waCamelotMoat) {
|
|
|
|
if(markOrb(itOrbFish)) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(markOrb2(itOrbAether)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
|
|
|
addMessage(XLAT("You have to run away from the water!"));
|
|
|
|
}
|
|
|
|
else if(cwt.c->wall == waClosedGate) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(markOrb2(itOrbAether)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
|
|
|
addMessage(XLAT("The gate is closing right on you! RUN!"));
|
|
|
|
}
|
|
|
|
else if(isFire(cwt.c) && !markOrb(itOrbWinter) && !markOrb2(itOrbShield)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(markOrb2(itOrbAether)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
|
|
|
addMessage(XLAT("This spot will be burning soon! RUN!"));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(cwt.c->wall == waChasm) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(markOrb2(itOrbAether)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
2017-08-06 12:50:16 +00:00
|
|
|
flags |= AF_FALL;
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("The floor has collapsed! RUN!"));
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(items[itOrbAether] > ORBBASE && !passable(cwt.c, NULL, P_ISPLAYER | P_NOAETHER)) {
|
|
|
|
if(markOrb2(itOrbAether)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(!passable(cwt.c, NULL, P_ISPLAYER)) {
|
|
|
|
if(isFire(cwt.c)) return false; // already checked: have Shield
|
|
|
|
if(markOrb2(itOrbAether)) return false;
|
|
|
|
if(checkonly) return true;
|
|
|
|
addMessage(XLAT("Your Aether power has expired! RUN!"));
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else return false;
|
2017-08-06 12:50:16 +00:00
|
|
|
if(hardcore)
|
|
|
|
killHardcorePlayer(multi::cpid, flags);
|
2016-08-26 09:58:03 +00:00
|
|
|
return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int countMyGolems(eMonster m) {
|
|
|
|
int g=0, dcs = size(dcal);
|
|
|
|
for(int i=0; i<dcs; i++) {
|
|
|
|
cell *c = dcal[i];
|
|
|
|
if(c->monst == m) g++;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return g;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int savePrincesses() {
|
|
|
|
int g=0, dcs = size(dcal);
|
|
|
|
for(int i=0; i<dcs; i++) {
|
|
|
|
cell *c = dcal[i];
|
|
|
|
if(isPrincess(c->monst)) princess::save(c);
|
|
|
|
}
|
|
|
|
return g;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int countMyGolemsHP(eMonster m) {
|
|
|
|
int g=0, dcs = size(dcal);
|
|
|
|
for(int i=0; i<dcs; i++) {
|
|
|
|
cell *c = dcal[i];
|
|
|
|
if(c->monst == m) g += c->hitpoints;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return g;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void restoreGolems(int qty, eMonster m, int hp = 0) {
|
|
|
|
int dcs = size(dcal);
|
|
|
|
for(int i=1; qty && i<dcs; i++) {
|
|
|
|
cell *c = dcal[i];
|
|
|
|
if(m == moTameBomberbird ?
|
|
|
|
(c->mpdist >= 3 && passable(c, NULL, P_FLYING)) :
|
|
|
|
passable(c, NULL, 0)) {
|
|
|
|
c->hitpoints = hp / qty;
|
|
|
|
c->monst = m, qty--, hp -= c->hitpoints;
|
|
|
|
if(m == moPrincess || m == moPrincessArmed)
|
|
|
|
princess::newFakeInfo(c);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
cell *recallCell;
|
|
|
|
|
|
|
|
bool activateRecall() {
|
|
|
|
if(!recallCell) {
|
|
|
|
addMessage("Error: no recall");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
items[itOrbRecall] = 0; items[itOrbSafety] = 0;
|
|
|
|
if(!makeEmpty(recallCell)) {
|
|
|
|
addMessage(XLAT("Your Orb of Recall is blocked by something big!"));
|
|
|
|
recallCell = NULL;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
killFriendlyIvy();
|
|
|
|
movecost(cwt.c, recallCell);
|
|
|
|
playerMoveEffects(cwt.c, recallCell);
|
2017-07-22 23:33:27 +00:00
|
|
|
mirror::destroyAll();
|
2017-08-14 21:48:46 +00:00
|
|
|
|
|
|
|
sword::reset();
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
cwt.c = recallCell; recallCell = NULL;
|
|
|
|
cwt.spin = hrand(cwt.c->type); flipplayer = !!(hrand(2));
|
|
|
|
fullcenter();
|
|
|
|
makeEmpty(cwt.c);
|
|
|
|
forCellEx(c2, cwt.c)
|
|
|
|
if(c2->monst != moMutant)
|
|
|
|
c2->stuntime = 4;
|
|
|
|
if(shmup::on) shmup::recall();
|
|
|
|
if(multi::players > 1) multi::recall();
|
|
|
|
bfs();
|
|
|
|
checkmove();
|
|
|
|
drawSafety();
|
|
|
|
addMessage(XLAT("You are recalled!"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void saveRecall(cell *c2) {
|
|
|
|
if(!recallCell) recallCell = c2;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void activateSafety(eLand l) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(recallCell && activateRecall())
|
|
|
|
return;
|
2016-08-26 09:58:03 +00:00
|
|
|
savePrincesses();
|
|
|
|
int gg = countMyGolems(moGolem);
|
|
|
|
int gb = countMyGolems(moTameBomberbird);
|
|
|
|
int gp1 = countMyGolems(moPrincess);
|
|
|
|
int gp2 = countMyGolems(moPrincessArmed);
|
|
|
|
int gph1 = countMyGolemsHP(moPrincess);
|
|
|
|
int gph2 = countMyGolemsHP(moPrincessArmed);
|
|
|
|
drawSafety();
|
|
|
|
addMessage(XLAT("You fall into a wormhole!"));
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
eLand f = firstland;
|
|
|
|
if(l == laTemple) l = laRlyeh;
|
|
|
|
if(l == laClearing) l = laOvergrown;
|
|
|
|
if(l == laWhirlpool) l = laOcean;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(l == laCrossroads5) l = laCrossroads2; // could not fit!
|
2016-08-26 09:58:03 +00:00
|
|
|
if(l == laCamelot && !(tactic::on && tactic::lasttactic == laCamelot))
|
|
|
|
l = laCrossroads;
|
|
|
|
firstland = l;
|
|
|
|
safetyland = l;
|
|
|
|
safetyseed = time(NULL);
|
|
|
|
for(int i=0; i<65536; i++) euland[i] = laNone;
|
|
|
|
euland[0] = euland[1] = firstland;
|
|
|
|
safety = true; avengers = 0;
|
|
|
|
clearMemory();
|
|
|
|
initcells();
|
|
|
|
initgame();
|
|
|
|
firstland = f;
|
|
|
|
safety = false;
|
|
|
|
restoreGolems(gg, moGolem);
|
|
|
|
restoreGolems(gb, moTameBomberbird);
|
|
|
|
restoreGolems(gp1, moPrincess, gph1);
|
|
|
|
restoreGolems(gp2, moPrincessArmed, gph2);
|
|
|
|
restartGraph();
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-31 19:41:09 +00:00
|
|
|
bool legalmoves[8];
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool hasSafeOrb(cell *c) {
|
|
|
|
return
|
|
|
|
c->item == itOrbSafety ||
|
|
|
|
c->item == itOrbShield ||
|
2017-03-23 10:53:57 +00:00
|
|
|
c->item == itOrbShell ||
|
2017-08-06 12:50:16 +00:00
|
|
|
(c->item == itOrbYendor && yendor::state(c) == yendor::ysUnlocked);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void checkmove() {
|
2017-07-16 21:00:55 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_INV
|
2017-07-16 21:00:55 +00:00
|
|
|
if(inv::on) inv::compute();
|
|
|
|
#endif
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(multi::players > 1 && !multi::checkonly) return;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(hardcore) return;
|
|
|
|
msgscroll = 0;
|
|
|
|
bool orbusedbak[ittypes];
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// do not activate orbs!
|
|
|
|
for(int i=0; i<ittypes; i++) orbusedbak[i] = orbused[i];
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-31 19:41:09 +00:00
|
|
|
for(int i=0; i<8; i++) legalmoves[i] = false;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
canmove = false;
|
2017-03-23 10:53:57 +00:00
|
|
|
items[itWarning]+=2;
|
2017-03-31 19:41:09 +00:00
|
|
|
if(movepcto(-1, 0, true)) canmove = legalmoves[7] = true;
|
|
|
|
|
|
|
|
if(ISMOBILE || !canmove)
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<cwt.c->type; i++)
|
2017-03-31 19:41:09 +00:00
|
|
|
if(movepcto(1, -1, true))
|
|
|
|
canmove = legalmoves[cwt.spin] = true;
|
|
|
|
if(ISMOBILE || !canmove)
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<cwt.c->type; i++)
|
2017-03-31 19:41:09 +00:00
|
|
|
if(movepcto(1, 1, true))
|
|
|
|
canmove = legalmoves[cwt.spin] = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(kills[moPlayer]) canmove = false;
|
2017-07-10 18:47:38 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_INV
|
2017-08-17 23:44:35 +00:00
|
|
|
if(inv::on && !canmove && !inv::incheck) {
|
2017-07-16 21:00:55 +00:00
|
|
|
if(inv::remaining[itOrbSafety])
|
|
|
|
canmove = true;
|
|
|
|
else {
|
|
|
|
inv::check(1);
|
|
|
|
checkmove();
|
|
|
|
inv::check(-1);
|
|
|
|
}
|
|
|
|
if(canmove)
|
|
|
|
pushScreen(inv::show);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
if(!canmove) {
|
2016-08-26 09:58:03 +00:00
|
|
|
achievement_final(true);
|
2017-07-12 17:50:39 +00:00
|
|
|
if(cmode & sm::NORMAL) showMissionScreen();
|
2017-07-10 18:47:38 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(canmove && timerstopped) {
|
|
|
|
timerstart = time(NULL);
|
|
|
|
timerstopped = false;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
items[itWarning]-=2;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<ittypes; i++) orbused[i] = orbusedbak[i];
|
2017-07-16 21:00:55 +00:00
|
|
|
if(recallCell && !markOrb(itOrbRecall)) activateRecall();
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// move the PC. Warning: a very long function! todo: refactor
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void placeGolem(cell *on, cell *moveto, eMonster m) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(on->monst == moFriendlyIvy)
|
|
|
|
killMonster(on, moPlayer);
|
|
|
|
if(on->monst) {
|
|
|
|
addMessage(XLAT("There is no room for %the1!", m));
|
|
|
|
return;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(passable(on, moveto, m == moTameBomberbird ? P_FLYING : 0))
|
2017-03-23 10:53:57 +00:00
|
|
|
on->monst = m;
|
2016-08-26 09:58:03 +00:00
|
|
|
else {
|
2017-03-23 10:53:57 +00:00
|
|
|
on->monst = m;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isFire(on))
|
|
|
|
addMessage(XLAT("%The1 burns!", m));
|
|
|
|
else if(on->wall == waChasm)
|
|
|
|
addMessage(XLAT("%The1 falls!", m));
|
|
|
|
else if(isWatery(on) && isNonliving(m))
|
|
|
|
addMessage(XLAT("%The1 sinks!", m));
|
|
|
|
else if(isWatery(on))
|
|
|
|
addMessage(XLAT("%The1 drowns!", m));
|
|
|
|
else if(isWall(on))
|
|
|
|
addMessage(XLAT("%The1 is crushed!", m));
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(m == moTameBomberbird && cwt.c->wall == waBoat)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
addMessage(XLAT("%The1 is destroyed!", m));
|
|
|
|
|
|
|
|
printf("mondir = %d\n", on->mondir);
|
|
|
|
fallMonster(cwt.c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool multiRevival(cell *on, cell *moveto) {
|
|
|
|
int fl = 0;
|
|
|
|
if(items[itOrbAether]) fl |= P_AETHER;
|
|
|
|
if(items[itOrbFish]) fl |= P_FISH;
|
|
|
|
if(items[itOrbWinter]) fl |= P_WINTER;
|
|
|
|
if(passable(on, moveto, fl)) {
|
|
|
|
int id = multi::revive_queue[0];
|
|
|
|
for(int i=1; i<size(multi::revive_queue); i++)
|
|
|
|
multi::revive_queue[i-1] = multi::revive_queue[i];
|
|
|
|
multi::revive_queue.pop_back();
|
|
|
|
multi::player[id].c = on;
|
|
|
|
multi::player[id].spin = neighborId(moveto, on);
|
|
|
|
if(multi::player[id].spin < 0) multi::player[id].spin = 0;
|
|
|
|
multi::flipped[id] = true;
|
|
|
|
multi::whereto[id].d = MD_UNDECIDED;
|
2017-08-14 21:48:46 +00:00
|
|
|
sword::reset();
|
2017-03-23 10:53:57 +00:00
|
|
|
return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
return false;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void movecost(cell* from, cell *to) {
|
|
|
|
if(from->land == laPower && to->land != laPower) {
|
|
|
|
int n=0;
|
|
|
|
for(int i=0; i<ittypes; i++)
|
|
|
|
if(itemclass(eItem(i)) == IC_ORB && items[i] >= 2 && i != itOrbFire)
|
|
|
|
items[i] = 2, n++;
|
|
|
|
if(n)
|
|
|
|
addMessage(XLAT("As you leave, your powers are drained!"));
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_TOUR
|
2017-04-14 18:12:23 +00:00
|
|
|
if(from->land != to->land && tour::on)
|
|
|
|
tour::checkGoodLand(to->land);
|
2017-04-15 02:48:59 +00:00
|
|
|
#endif
|
2017-04-14 18:12:23 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(to->land ==laCrossroads4 && !chaosUnlocked) {
|
|
|
|
achievement_gain("CR4");
|
|
|
|
chaosUnlocked = true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isHaunted(from->land) && !isHaunted(to->land)) {
|
|
|
|
updateHi(itLotus, truelotus = items[itLotus]);
|
|
|
|
if(items[itLotus] >= 1) achievement_gain("LOTUS1");
|
2017-08-14 18:38:17 +00:00
|
|
|
if(items[itLotus] >= (inv::on ? 25 : 10)) achievement_gain("LOTUS2");
|
|
|
|
if(items[itLotus] >= (inv::on ? 50 : 25)) achievement_gain("LOTUS3");
|
|
|
|
if(items[itLotus] >= 50 && !inv::on) achievement_gain("LOTUS4");
|
2016-08-26 09:58:03 +00:00
|
|
|
achievement_final(false);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(celldist(to) == 0 && !usedSafety && gold() >= 100)
|
|
|
|
achievement_gain("COMEBACK");
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool tortoiseOK =
|
|
|
|
to->land == from->land || to->land == laTortoise ||
|
2017-03-23 10:53:57 +00:00
|
|
|
(to->land == laDragon && from->land != laTortoise) ||
|
|
|
|
chaosmode;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(tortoise::seek() && !from->item && !tortoiseOK && passable(from, NULL, 0)) {
|
|
|
|
from->item = itBabyTortoise;
|
|
|
|
tortoise::babymap[from] = tortoise::seekbits;
|
|
|
|
addMessage(XLAT("You leave %the1.", itBabyTortoise));
|
|
|
|
items[itBabyTortoise]--;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool cantGetGrimoire(cell *c2, bool verbose = true) {
|
|
|
|
if(chaosmode) return false;
|
|
|
|
if(!euclid && !c2->master->alt) return false;
|
|
|
|
if(c2->item == itGrimoire && items[itGrimoire] > celldistAlt(c2)/-TEMPLE_EACH) {
|
|
|
|
if(verbose)
|
|
|
|
addMessage(XLAT("You already have this Grimoire! Seek new tomes in the inner circles."));
|
|
|
|
return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void gainLife() {
|
|
|
|
items[itOrbLife] ++;
|
2017-07-16 21:00:55 +00:00
|
|
|
if(items[itOrbLife] > 5 && !shmup::on) items[itOrbLife] = 5;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void collectMessage(cell *c2, eItem which) {
|
|
|
|
bool specialmode =
|
|
|
|
yendor::on || tactic::on || princess::challenge || euclid || sphere;
|
2017-07-04 13:38:33 +00:00
|
|
|
|
|
|
|
if(which == itDodeca && peace::on) return;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(which == itTreat) ;
|
|
|
|
else if(isElementalShard(which)) {
|
|
|
|
int tsh =
|
|
|
|
items[itFireShard] + items[itAirShard] + items[itWaterShard] + items[itEarthShard] +
|
|
|
|
items[itElemental];
|
|
|
|
if(tsh == 0) {
|
|
|
|
addMessage(XLAT("Collect four different Elemental Shards!"));
|
|
|
|
addMessage(XLAT("Unbalanced shards in your inventory are dangerous."));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
string t = XLAT("You collect %the1. (%2)", which, its(items[which]+1));
|
|
|
|
addMessage(t);
|
|
|
|
}
|
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
else if(which == itKey) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You have found the Key! Now unlock this Orb of Yendor!"));
|
2017-07-04 13:38:33 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(which == itGreenStone && !items[itGreenStone])
|
|
|
|
addMessage(XLAT("This orb is dead..."));
|
|
|
|
else if(which == itGreenStone)
|
|
|
|
addMessage(XLAT("Another Dead Orb."));
|
2017-08-06 12:50:16 +00:00
|
|
|
else if(itemclass(which) != IC_TREASURE) {
|
|
|
|
if(c2->wall != waBoat)
|
|
|
|
addMessage(XLAT("You have found %the1!", which));
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(which == itBabyTortoise) {
|
|
|
|
playSound(c2, playergender() ? "speak-princess" : "speak-prince");
|
|
|
|
addMessage(XLAT("Aww, poor %1... where is your family?", which));
|
|
|
|
}
|
|
|
|
else if(gold() == 0 && !specialmode)
|
|
|
|
addMessage(XLAT("Wow! %1! This trip should be worth it!", which));
|
|
|
|
else if(gold() == 1 && !specialmode)
|
|
|
|
addMessage(XLAT("For now, collect as much treasure as possible..."));
|
|
|
|
else if(gold() == 2 && !specialmode)
|
|
|
|
addMessage(XLAT("Prove yourself here, then find new lands, with new quests..."));
|
|
|
|
else if(!items[which] && itemclass(which) == IC_TREASURE)
|
|
|
|
addMessage(XLAT("You collect your first %1!", which));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(items[which] == 4 && maxgold() == U5-1 && !specialmode) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You feel that %the2 become%s2 more dangerous.", which, c2->land));
|
|
|
|
addMessage(XLAT("With each %1 you collect...", which, c2->land));
|
|
|
|
}
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(items[which] == 9 && maxgold() == 9 && !specialmode) {
|
|
|
|
if(inv::on) {
|
|
|
|
addMessage(XLAT("The treasure gives your magical powers!", c2->land));
|
|
|
|
if(!ISMOBILE)
|
|
|
|
addMessage(XLAT("Press 'i' to access your magical powers.", c2->land));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
addMessage(XLAT("Are there any magical orbs in %the1?...", c2->land));
|
|
|
|
}
|
|
|
|
else if(items[which] == R10 && maxgold() == R10 && !specialmode && !inv::on) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You feel that %the1 slowly become%s1 dangerous...", c2->land));
|
|
|
|
addMessage(XLAT("Better find some other place."));
|
|
|
|
}
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itSpice && items[itSpice] == U10*7/10 && !specialmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You have a vision of the future, fighting demons in Hell..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itSpice && items[itSpice] == U10-1 && !specialmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You will be fighting red rock snakes, too..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itKraken && items[itKraken] == U10-1 && !specialmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You feel that a magical weapon is waiting for you..."));
|
|
|
|
// else if(which == itFeather && items[itFeather] == 10)
|
|
|
|
// addMessage(XLAT("There should be a Palace somewhere nearby..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itElixir && items[itElixir] == U5-1 && !specialmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("With this Elixir, your life should be long and prosperous..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itRuby && items[itRuby] == U5-1 && !specialmode) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You feel something strange about gravity here..."));
|
|
|
|
}
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itPalace && items[itPalace] == U5-1 && !specialmode) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("The rug depicts a man in a deep dungeon, unable to leave."));
|
|
|
|
}
|
2017-08-06 12:50:16 +00:00
|
|
|
else if(which == itFeather && items[itFeather] == 25-1 && !specialmode && inv::on)
|
|
|
|
addMessage(XLAT("You feel the presence of free saves on the Crossroads."));
|
|
|
|
else if(which == itHell && items[itHell] == 25-1 && !specialmode && inv::on)
|
|
|
|
addMessage(XLAT("You feel the Orbs of Yendor nearby..."));
|
|
|
|
else if(which == itHell && items[itHell] == 50-1 && !specialmode && inv::on)
|
|
|
|
addMessage(XLAT("You feel the Orbs of Yendor in the Crossroads..."));
|
|
|
|
else if(which == itHell && items[itHell] == 100-1 && !specialmode && inv::on)
|
|
|
|
addMessage(XLAT("You feel the Orbs of Yendor everywhere..."));
|
|
|
|
else if(which == itBone && items[itBone] % 25 == 24 && !specialmode && inv::on)
|
|
|
|
addMessage(XLAT("You have gained an offensive power!"));
|
|
|
|
else if(which == itHell && items[itHell] >= 100 && items[itHell] % 25 == 24 && !specialmode && inv::on)
|
|
|
|
addMessage(XLAT("A small reward for braving the Hell."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itIvory && items[itIvory] == U5-1 && !specialmode) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You feel attuned to gravity, ready to face mountains and dungeons."));
|
|
|
|
}
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itBone && items[itBone] == U5+1 && !specialmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("The Necromancer's Totem contains hellish incantations..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itStatue && items[itStatue] == U5+1 && !specialmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("The inscriptions on the Statue of Cthulhu point you toward your destiny..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itStatue && items[itStatue] == U5-1 && !specialmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("There must be some temples of Cthulhu in R'Lyeh..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itDiamond && items[itDiamond] == U10-2 && !specialmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("Still, even greater treasures lie ahead..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itFernFlower && items[itFernFlower] == U5-1 && !specialmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You overheard Hedgehog Warriors talking about emeralds..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itEmerald && items[itEmerald] == U5-1 && !specialmode && !chaosmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You overhear miners talking about a castle..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(which == itEmerald && items[itEmerald] == U5 && !specialmode && !chaosmode)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("A castle in the Crossroads..."));
|
|
|
|
else if(which == itShard) ;
|
|
|
|
else {
|
|
|
|
int qty = (which == itBarrow) ? c2->landparam : 1;
|
|
|
|
string t;
|
|
|
|
if(which == itBarrow && items[which] < 25 && items[which] + qty >= 25)
|
|
|
|
t = XLAT("Your energy swords get stronger!");
|
|
|
|
else if(maxgold() < 25 && items[which] + qty >= 25)
|
|
|
|
t = XLAT("You feel even more attuned to the magic of this land!");
|
|
|
|
else t = XLAT("You collect %the1. (%2)", which, its(items[which]+qty));
|
|
|
|
addMessage(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool collectItem(cell *c2, bool telekinesis) {
|
|
|
|
|
|
|
|
int pg = gold();
|
|
|
|
bool dopickup = true;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(itemHidden(c2) && !telekinesis && !(isWatery(c2) && markOrb(itOrbFish)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* if(c2->item == itHolyGrail && telekinesis)
|
|
|
|
return false; */
|
|
|
|
|
|
|
|
if(c2->item) {
|
|
|
|
invismove = false;
|
|
|
|
if(shmup::on) shmup::visibleFor(2000);
|
|
|
|
string s0 = "";
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->item == itPalace && items[c2->item] == 12)
|
|
|
|
princess::forceVizier = true;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!cantGetGrimoire(c2, false)) collectMessage(c2, c2->item);
|
2017-09-01 20:05:31 +00:00
|
|
|
if(c2->item == itDodeca && peace::on) peace::simon::extend();
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isRevivalOrb(c2->item) && multi::revive_queue.size()) {
|
|
|
|
multiRevival(cwt.c, c2);
|
|
|
|
}
|
2017-07-16 21:00:55 +00:00
|
|
|
else if(isShmupLifeOrb(c2->item) && shmup::on) {
|
|
|
|
playSound(c2, "pickup-orb"); // TODO summon
|
|
|
|
gainLife();
|
|
|
|
}
|
|
|
|
else if(orbcharges(c2->item)) {
|
|
|
|
eItem it = c2->item;
|
|
|
|
if(it == itOrbRecall) saveRecall(c2);
|
|
|
|
if(it == itOrbFire) playSound(c2, "fire");
|
|
|
|
else if(it == itOrbFire) playSound(c2, "fire");
|
|
|
|
else if(it == itOrbWinter) playSound(c2, "pickup-winter");
|
|
|
|
else if(it == itOrbSpeed) playSound(c2, "pickup-speed");
|
|
|
|
else if(it == itRevolver) playSound(c2, "pickup-key");
|
|
|
|
else playSound(c2, "pickup-orb");
|
|
|
|
if(!items[it]) items[it]++;
|
|
|
|
items[it] += orbcharges(it);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->item == itOrbLife) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c2, "pickup-orb"); // TODO summon
|
2017-07-16 21:00:55 +00:00
|
|
|
placeGolem(cwt.c, c2, moGolem);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->item == itOrbFriend) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c2, "pickup-orb"); // TODO summon
|
2017-07-16 21:00:55 +00:00
|
|
|
placeGolem(cwt.c, c2, moTameBomberbird);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_TOUR
|
2017-04-14 18:12:23 +00:00
|
|
|
else if(tour::on && (c2->item == itOrbSafety || c2->item == itOrbRecall)) {
|
|
|
|
addMessage(XLAT("This Orb is not compatible with the Tutorial."));
|
|
|
|
return true;
|
|
|
|
}
|
2017-04-15 02:48:59 +00:00
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->item == itOrbSafety) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c2, "pickup-orb"); // TODO safety
|
2016-08-26 09:58:03 +00:00
|
|
|
items[c2->item] += 7;
|
|
|
|
if(shmup::on)
|
|
|
|
shmup::safety = true;
|
|
|
|
else
|
|
|
|
activateSafety(c2->land);
|
|
|
|
return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(c2->item == itBabyTortoise) {
|
|
|
|
using namespace tortoise;
|
|
|
|
int bnew = babymap[c2];
|
|
|
|
babymap.erase(c2);
|
|
|
|
int bold = seekbits;
|
|
|
|
seekbits = bnew;
|
2017-05-28 22:16:17 +00:00
|
|
|
last = seekbits;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(seek()) {
|
|
|
|
cell *c = passable(cwt.c, NULL, 0) ? cwt.c : c2;
|
|
|
|
c->item = itBabyTortoise;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c == c2) dopickup = false;
|
2016-08-26 09:58:03 +00:00
|
|
|
babymap[c] = bold;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else items[itBabyTortoise]++;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
else if(c2->item == itOrbYendor && peace::on) {
|
|
|
|
if(!items[itDodeca]) {
|
|
|
|
addMessage(XLAT("Collect as many Dodecahedra as you can, then return here!"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
addMessage(XLAT("Your score: %1", its(items[itDodeca])));
|
|
|
|
peace::simon::restore();
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
dopickup = false;
|
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
else if(c2->item == itOrbYendor && yendor::state(c2) != yendor::ysUnlocked) {
|
|
|
|
dopickup = false;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
else if(c2->item == itOrbYendor)
|
|
|
|
yendor::collected(c2);
|
2016-01-02 10:09:13 +00:00
|
|
|
else if(c2->item == itHolyGrail) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c2, "tada");
|
2016-01-02 10:09:13 +00:00
|
|
|
int v = newRoundTableRadius() + 12;
|
|
|
|
items[itOrbTeleport] += v;
|
|
|
|
items[itOrbSpeed] += v;
|
2016-08-26 09:58:03 +00:00
|
|
|
items[itHolyGrail]++;
|
|
|
|
addMessage(XLAT("Congratulations! You have found the Holy Grail!"));
|
|
|
|
if(!euclid) c2->master->alt->emeraldval |= GRAIL_FOUND;
|
|
|
|
achievement_collection(c2->item, pg, gold());
|
|
|
|
}
|
|
|
|
else if(c2->item == itKey) {
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c2, "pickup-key");
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<size(yendor::yi); i++) if(yendor::yi[i].path[YDIST-1] == c2)
|
|
|
|
yendor::yi[i].found = true;
|
|
|
|
items[itKey]++;
|
|
|
|
}
|
|
|
|
else if(!telekinesis && cantGetGrimoire(c2)) {
|
|
|
|
// telekinesis checks the condition earlier
|
|
|
|
dopickup = false;
|
|
|
|
}
|
|
|
|
else if(c2->item == itCompass) {
|
|
|
|
dopickup = false;
|
|
|
|
}
|
|
|
|
else if(c2->item == itBuggy || c2->item == itBuggy2) {
|
|
|
|
items[itOrbSafety] += 7;
|
|
|
|
if(shmup::on)
|
|
|
|
shmup::safety = true;
|
|
|
|
else {
|
|
|
|
buggyGeneration = false;
|
|
|
|
activateSafety(laCrossroads);
|
|
|
|
}
|
|
|
|
return true;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c2->item == itTreat) {
|
|
|
|
playSound(c2, "pickup-scroll");
|
|
|
|
halloween::getTreat(c2);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else {
|
|
|
|
bool lhu = hellUnlocked();
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->item == itBarrow)
|
|
|
|
for(int i=0; i<c2->landparam; i++) gainItem(c2->item);
|
|
|
|
else if(c2->item) gainItem(c2->item);
|
2016-08-26 09:58:03 +00:00
|
|
|
int g2 = gold();
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(c2->item) {
|
|
|
|
char ch = iinf[c2->item].glyph;
|
|
|
|
if(ch == '*') playSound(c2, "pickup-gem");
|
|
|
|
else if(ch == '$' || ch == 'x') playSound(c2, "pickup-gold");
|
|
|
|
else if(ch == '%' || ch == ';') playSound(c2, "pickup-potion");
|
|
|
|
else playSound(c2, "pickup-scroll");
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(items[itFireShard] && items[itAirShard] && items[itWaterShard] && items[itEarthShard]) {
|
|
|
|
items[itFireShard]--;
|
|
|
|
items[itAirShard]--;
|
|
|
|
items[itWaterShard]--;
|
|
|
|
items[itEarthShard]--;
|
|
|
|
gainItem(itElemental);
|
|
|
|
gainItem(itElemental);
|
|
|
|
gainItem(itElemental);
|
|
|
|
gainItem(itElemental);
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You construct some Elemental Gems!", c2->item) + itemcounter(items[itElemental]));
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->item == itBounty)
|
|
|
|
items[itRevolver] = 6;
|
|
|
|
|
|
|
|
if(c2->item == itHyperstone && items[itHyperstone] == 10)
|
|
|
|
achievement_victory(true);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(chaosmode && gold() >= 300 && !chaosAchieved) {
|
|
|
|
achievement_gain("CHAOS", 'C');
|
|
|
|
chaosAchieved = true;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISMOBILE==1
|
2017-07-12 16:03:53 +00:00
|
|
|
if(pg < lastsafety + R30*3/2 && g2 >= lastsafety + R30*3/2)
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("The Orb of Safety from the Land of Eternal Motion might save you."));
|
|
|
|
#endif
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-08-06 12:50:16 +00:00
|
|
|
#define IF(x) if(pg < (x) && g2 >= x && !peace::on)
|
2017-07-12 16:03:53 +00:00
|
|
|
|
|
|
|
IF(R60/4)
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("Collect treasure to access more different lands..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
IF(R30)
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("You feel that you have enough treasure to access new lands!"));
|
2017-07-12 16:03:53 +00:00
|
|
|
IF(R30*3/2)
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("Collect more treasures, there are still more lands waiting..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
IF(R60)
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("You feel that the stars are right, and you can access R'Lyeh!"));
|
2017-07-12 16:03:53 +00:00
|
|
|
IF(R30*5/2)
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("Kill monsters and collect treasures, and you may get access to Hell..."));
|
2017-07-12 16:03:53 +00:00
|
|
|
IF(R10 * 9)
|
2017-07-04 13:38:33 +00:00
|
|
|
addMessage(XLAT("To access Hell, collect %1 treasures each of 9 kinds...", its(R10)));
|
2016-08-26 09:58:03 +00:00
|
|
|
if(hellUnlocked() && !lhu) {
|
|
|
|
addMessage(XLAT("Abandon all hope, the gates of Hell are opened!"));
|
|
|
|
addMessage(XLAT("And the Orbs of Yendor await!"));
|
|
|
|
}
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(dopickup && c2->item) {
|
|
|
|
#ifdef HASLINEVIEW
|
|
|
|
// (eItem) to avoid the "cannot bind bitfield" problem in C++11
|
|
|
|
conformal::findhistory.push_back(make_pair(c2, (eItem) c2->item));
|
|
|
|
#endif
|
|
|
|
c2->item = itNone;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
// if(c2->land == laHive)
|
|
|
|
// c2->heat = 1;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
int numOrb = 0;
|
|
|
|
for(int i=0; i<ittypes; i++)
|
|
|
|
if(itemclass(eItem(i)) == IC_ORB && items[i])
|
|
|
|
numOrb++;
|
|
|
|
if(numOrb) achievement_count("ORB", numOrb, 0);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-07-12 16:03:53 +00:00
|
|
|
if(princess::reviveAt && gold(NO_LOVE) >= princess::reviveAt && !inv::on) {
|
2017-03-23 10:53:57 +00:00
|
|
|
princess::reviveAt = 0,
|
|
|
|
items[itSavedPrincess] = 1;
|
|
|
|
addMessage("You have enough treasure now to revive the Princess!");
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void dropGreenStone(cell *c) {
|
|
|
|
if(!passable(c, NULL, P_MONSTER)) {
|
|
|
|
// NOTE: PL/CZ translations assume that itGreenStone is dropped to avoid extra forms!
|
|
|
|
addMessage("Cannot drop %the1 here!", itGreenStone);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(items[itGreenStone] && c->item == itNone) {
|
|
|
|
items[itGreenStone]--;
|
|
|
|
if(false) {
|
|
|
|
c->item = itNone;
|
|
|
|
spill(c, eWall(c->wall ^ waFloorA ^ waFloorB), 3);
|
|
|
|
addMessage(XLAT("The slime reacts with %the1!", itGreenStone));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c->item = itGreenStone;
|
|
|
|
addMessage(XLAT("You drop %the1.", itGreenStone));
|
|
|
|
if(isHaunted(cwt.c->land)) survivalist = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(gold() >= 300)
|
|
|
|
addMessage(XLAT("You feel great, like a true treasure hunter."));
|
|
|
|
else if(gold() >= 200)
|
|
|
|
addMessage(XLAT("Your eyes shine like gems."));
|
|
|
|
else if(gold() >= 100)
|
|
|
|
addMessage(XLAT("Your eyes shine as you glance at your precious treasures."));
|
|
|
|
else if(gold() >= 50)
|
|
|
|
addMessage(XLAT("You glance at your great treasures."));
|
|
|
|
else if(gold() >= 10)
|
|
|
|
addMessage(XLAT("You glance at your precious treasures."));
|
|
|
|
else if(gold() > 0)
|
|
|
|
addMessage(XLAT("You glance at your precious treasure."));
|
|
|
|
else
|
|
|
|
addMessage(XLAT("Your inventory is empty."));
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void roundTableMessage(cell *c2) {
|
|
|
|
if(!euclid && !cwt.c->master->alt) return;
|
|
|
|
if(!euclid && !c2->master->alt) return;
|
|
|
|
int dd = celldistAltRelative(c2) - celldistAltRelative(cwt.c);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool tooeasy = (roundTableRadius(c2) < newRoundTableRadius());
|
|
|
|
|
|
|
|
if(dd>0) {
|
|
|
|
if(grailWasFound(cwt.c)) {
|
|
|
|
addMessage(XLAT("The Knights congratulate you on your success!"));
|
|
|
|
knighted = roundTableRadius(cwt.c);
|
|
|
|
}
|
|
|
|
else if(!tooeasy)
|
|
|
|
addMessage(XLAT("The Knights laugh at your failure!"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(grailWasFound(cwt.c))
|
|
|
|
addMessage(XLAT("The Knights stare at you!"));
|
|
|
|
else if(tooeasy) {
|
|
|
|
if(!tactic::on)
|
|
|
|
addMessage(XLAT("Come on, this is too easy... find a bigger castle!"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
addMessage(XLAT("The Knights wish you luck!"));
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
long long circlesize[100], disksize[100];
|
2017-07-12 16:03:53 +00:00
|
|
|
ld circlesizeD[10000];
|
|
|
|
int lastsize;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
void computeSizes() {
|
2017-07-12 16:03:53 +00:00
|
|
|
lastsize = purehepta ? 44 : 76;
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
circlesize[0] = 1;
|
|
|
|
|
|
|
|
if(!purehepta) {
|
|
|
|
circlesize[1] = 1*7;
|
|
|
|
circlesize[2] = 2*7;
|
|
|
|
circlesize[3] = 4*7;
|
|
|
|
circlesize[4] = 7*7;
|
|
|
|
for(int i=5; i<100; i++)
|
|
|
|
circlesize[i] = circlesize[i-1] + circlesize[i-2] + circlesize[i-3] - circlesize[i-4];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// actually these are each second Fibonacci number
|
|
|
|
circlesize[1] = 1*7;
|
|
|
|
circlesize[2] = 3*7;
|
|
|
|
for(int i=3; i<100; i++)
|
|
|
|
circlesize[i] = 3*circlesize[i-1] - circlesize[i-2];
|
|
|
|
}
|
|
|
|
|
|
|
|
disksize[0] = 0;
|
|
|
|
for(int i=1; i<100; i++)
|
|
|
|
disksize[i] = disksize[i-1] + circlesize[i-1];
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void knightFlavorMessage(cell *c2) {
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!euclid && !c2->master->alt) {
|
|
|
|
addMessage(XLAT("\"I am lost...\""));
|
|
|
|
return;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(tactic::on) {
|
|
|
|
addMessage(XLAT("\"The Knights of the Horocyclic Table salute you!\""));
|
|
|
|
return;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
computeSizes();
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
bool grailfound = grailWasFound(c2);
|
|
|
|
int rad = roundTableRadius(c2);
|
|
|
|
bool tooeasy = (rad < newRoundTableRadius());
|
|
|
|
|
|
|
|
static int msgid = 0;
|
|
|
|
|
|
|
|
retry:
|
|
|
|
if(msgid >= 32) msgid = 0;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(msgid == 0 && grailfound) {
|
|
|
|
addMessage(XLAT("\"I would like to congratulate you again!\""));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(msgid == 1 && !tooeasy) {
|
|
|
|
addMessage(XLAT("\"Find the Holy Grail to become one of us!\""));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(msgid == 2 && !tooeasy) {
|
|
|
|
addMessage(XLAT("\"The Holy Grail is in the center of the Round Table.\""));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-07-24 22:21:36 +00:00
|
|
|
else if(msgid == 3 && !peace::on) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("\"I enjoy watching the hyperbug battles.\""));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(msgid == 4) {
|
|
|
|
addMessage(XLAT("\"Have you visited a temple in R'Lyeh?\""));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(msgid == 5) {
|
|
|
|
addMessage(XLAT("\"Nice castle, eh?\""));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-07-24 22:21:36 +00:00
|
|
|
else if(msgid == 6 && items[itSpice] < 10 && !peace::on) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("\"The Red Rock Valley is dangerous, but beautiful.\""));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-07-24 22:21:36 +00:00
|
|
|
else if(msgid == 7 && items[itSpice] < 10 && !peace::on) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("\"Train in the Desert first!\""));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(msgid == 8) {
|
2017-07-12 16:03:53 +00:00
|
|
|
if(rad <= lastsize)
|
2017-05-27 19:40:40 +00:00
|
|
|
addMessage(XLAT("\"Our Table seats %1 Knights!\"", llts(circlesize[rad])));
|
2016-08-26 09:58:03 +00:00
|
|
|
else
|
|
|
|
addMessage(XLAT("\"By now, you should have your own formula, you know?\""));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-07-12 16:03:53 +00:00
|
|
|
else if(msgid == 9 && rad <= lastsize) {
|
2017-05-27 19:40:40 +00:00
|
|
|
addMessage(XLAT("\"There are %1 floor tiles inside our Table!\"", llts(disksize[rad])));
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-07-24 22:21:36 +00:00
|
|
|
else if(msgid == 10 && !items[itPirate] && !items[itWhirlpool] && !peace::on) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("\"Have you tried to take a boat and go into the Ocean? Try it!\""));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(msgid == 11 && !princess::saved) {
|
|
|
|
addMessage(XLAT("\"When I visited the Palace, a mouse wanted me to go somewhere.\""));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(msgid == 12 && !princess::saved) {
|
|
|
|
addMessage(XLAT("\"I wonder what was there...\""));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-07-24 22:21:36 +00:00
|
|
|
else if(msgid == 13 && !peace::on) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("\"Be careful in the Rose Garden! It is beautiful, but very dangerous!\""));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(msgid == 14) {
|
|
|
|
addMessage(XLAT("\"There is no royal road to geometry.\""));
|
|
|
|
}
|
|
|
|
else if(msgid == 15) {
|
|
|
|
addMessage(XLAT("\"There is no branch of mathematics, however abstract, "));
|
|
|
|
addMessage(XLAT("which may not some day be applied to phenomena of the real world.\""));
|
|
|
|
}
|
|
|
|
else if(msgid == 16) {
|
|
|
|
addMessage(XLAT("\"It is not possession but the act of getting there, "));
|
|
|
|
addMessage(XLAT("which grants the greatest enjoyment.\""));
|
|
|
|
}
|
|
|
|
else if(msgid == 17) {
|
|
|
|
addMessage(XLAT("\"We live in a beautiful and orderly world, "));
|
|
|
|
addMessage(XLAT("and not in a chaos without norms.\""));
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(msgid == 25) {
|
|
|
|
addMessage(XLAT("\"Thank you very much for talking, and have a great rest of your day!\""));
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else {
|
|
|
|
msgid++; goto retry;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
msgid++;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void uncoverMines(cell *c, int lev, int dist) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->wall == waMineUnknown)
|
|
|
|
c->wall = waMineOpen;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool minesNearby = false;
|
|
|
|
bool nominesNearby = false;
|
|
|
|
bool mineopens = false;
|
|
|
|
|
|
|
|
forCellEx(c2, c) {
|
|
|
|
if(c2->wall == waMineMine) minesNearby = true;
|
|
|
|
if(c2->wall == waMineOpen) mineopens = true;
|
|
|
|
if(c2->wall == waMineUnknown && !c2->item) nominesNearby = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(lev && (nominesNearby || mineopens) && !minesNearby) for(int i=0; i<c->type; i++)
|
|
|
|
if(c->mov[i] && (c->mov[i]->wall == waMineUnknown || c->mov[i]->wall == waMineOpen))
|
|
|
|
uncoverMines(c->mov[i], lev-1, dist+1);
|
|
|
|
|
|
|
|
if(minesNearby && !nominesNearby && dist == 0) {
|
|
|
|
forCellEx(c2, c)
|
|
|
|
if(c2->wall == waMineMine && c2->land == laMinefield)
|
|
|
|
c2->landparam |= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace orbbull {
|
|
|
|
cell *prev[MAXPLAYER];
|
|
|
|
eLastmovetype prevtype[MAXPLAYER];
|
|
|
|
int count;
|
|
|
|
|
|
|
|
bool is(cell *c1, cell *c2, cell *c3) {
|
|
|
|
int lp = neighborId(c2, c1);
|
|
|
|
int ln = neighborId(c2, c3);
|
|
|
|
return lp >= 0 && ln >= 0 && angledist(c2, lp, ln) == 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gainBullPowers() {
|
|
|
|
items[itOrbShield]++; orbused[itOrbShield] = true;
|
|
|
|
items[itOrbThorns]++; orbused[itOrbThorns] = true;
|
|
|
|
items[itOrbHorns]++; orbused[itOrbHorns] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void check() {
|
|
|
|
int cp = multi::cpid;
|
|
|
|
if(cp < 0 || cp >= MAXPLAYER) cp = 0;
|
|
|
|
|
|
|
|
if(!items[itOrbBull]) {
|
|
|
|
prev[cp] = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool seq = false;
|
|
|
|
|
|
|
|
if(prev[cp] && prevtype[cp] == lmMove && lastmovetype == lmMove)
|
|
|
|
seq = is(prev[cp], lastmove, cwt.c);
|
|
|
|
|
|
|
|
if(prev[cp] && prevtype[cp] == lmMove && lastmovetype == lmAttack)
|
|
|
|
seq = is(prev[cp], cwt.c, lastmove);
|
|
|
|
|
|
|
|
if(prev[cp] && prevtype[cp] == lmAttack && lastmovetype == lmAttack && count)
|
|
|
|
seq = lastmove == prev[cp];
|
|
|
|
|
|
|
|
if(prev[cp] && prevtype[cp] == lmAttack && lastmovetype == lmMove && count)
|
|
|
|
seq = cwt.c == prev[cp];
|
|
|
|
|
|
|
|
prev[cp] = lastmove; prevtype[cp] = lastmovetype;
|
|
|
|
|
|
|
|
if(seq) {
|
|
|
|
if(lastmovetype == lmMove) count++;
|
|
|
|
gainBullPowers();
|
|
|
|
}
|
|
|
|
else count = 0;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void monstersTurn() {
|
2017-07-22 23:33:27 +00:00
|
|
|
mirror::breakAll();
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("bfs");
|
|
|
|
bfs();
|
|
|
|
DEBT("charge");
|
|
|
|
if(elec::havecharge) elec::act();
|
|
|
|
DEBT("mmo");
|
|
|
|
int phase2 = (1 & items[itOrbSpeed]);
|
|
|
|
if(!phase2) movemonsters();
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(playerInPower() && (phase2 || !items[itOrbSpeed]) && (havewhat & HF_FAST))
|
|
|
|
moveNormals(moWitchSpeed);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(phase2 && markOrb(itOrbEmpathy)) {
|
|
|
|
bfs();
|
|
|
|
movegolems(AF_FAST);
|
|
|
|
for(int i=0; i<size(dcal); i++) {
|
|
|
|
if(dcal[i]->monst == moFriendlyGhost && dcal[i]->stuntime)
|
|
|
|
dcal[i]->stuntime--;
|
|
|
|
refreshFriend(dcal[i]);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
DEBT("rop");
|
|
|
|
reduceOrbPowers();
|
|
|
|
int phase1 = (1 & items[itOrbSpeed]);
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("lc");
|
|
|
|
if(!phase1) livecaves();
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!phase1) ca::simulate();
|
2017-09-02 22:33:35 +00:00
|
|
|
if(!phase1) heat::processfires();
|
2017-03-23 10:53:57 +00:00
|
|
|
DEBT("heat");
|
|
|
|
heat::processheat();
|
2016-08-26 09:58:03 +00:00
|
|
|
// if(elec::havecharge) elec::drawcharges();
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(items[itOrbFreedom])
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
if(multi::playerActive(i))
|
|
|
|
checkFreedom(playerpos(i));
|
|
|
|
|
|
|
|
orbbull::check();
|
|
|
|
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
DEBT("check");
|
|
|
|
checkmove();
|
|
|
|
if(canmove) elec::checklightningfast();
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
#ifdef HASLINEVIEW
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<numplayers(); i++)
|
|
|
|
if(multi::playerActive(i))
|
|
|
|
conformal::movehistory.push_back(playerpos(i));
|
2016-08-26 09:58:03 +00:00
|
|
|
#endif
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void pushThumper(cell *th, cell *cto) {
|
|
|
|
eWall w = th->wall;
|
|
|
|
cto->wparam = th->wparam;
|
|
|
|
if(th->land == laAlchemist)
|
|
|
|
th->wall = isAlch(cwt.c) ? cwt.c->wall : cto->wall;
|
|
|
|
else th->wall = waNone;
|
|
|
|
if(cto->wall == waOpenPlate || cto->wall == waClosePlate) {
|
|
|
|
toggleGates(cto, cto->wall);
|
|
|
|
addMessage(XLAT("%The1 destroys %the2!", waThumperOn, cto->wall));
|
|
|
|
}
|
|
|
|
if(cellUnstable(cto) && cto->land == laMotion) {
|
|
|
|
addMessage(XLAT("%The1 falls!", waThumperOn));
|
2017-03-23 10:53:57 +00:00
|
|
|
doesFallSound(cto);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-08-18 01:39:55 +00:00
|
|
|
else if(cellUnstableOrChasm(cto)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("%The1 fills the hole!", waThumperOn));
|
|
|
|
cto->wall = waTempFloor;
|
|
|
|
}
|
|
|
|
else if(isWatery(cto)) {
|
|
|
|
addMessage(XLAT("%The1 fills the hole!", waThumperOn));
|
|
|
|
cto->wall = waTempBridge;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cto->wall = w;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool canPushThumperOn(cell *tgt, cell *thumper, cell *player) {
|
|
|
|
if(tgt->wall == waBoat) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isReptile(tgt->wall)) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isWatery(tgt) && !tgt->monst)
|
|
|
|
return true;
|
|
|
|
if(tgt->wall == waChasm && !tgt->monst)
|
|
|
|
return true;
|
|
|
|
return
|
|
|
|
passable(tgt, thumper, P_MIRROR) &&
|
|
|
|
passable(tgt, player, P_MIRROR) &&
|
|
|
|
!tgt->item;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void activateActiv(cell *c, bool msg) {
|
|
|
|
if(msg) addMessage(XLAT("You activate %the1.", c->wall));
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->wall == waThumperOff) {
|
|
|
|
playSound(c, "click");
|
|
|
|
c->wall = waThumperOn;
|
|
|
|
}
|
|
|
|
if(c->wall == waBonfireOff) {
|
|
|
|
playSound(c, "fire");
|
|
|
|
c->wall = waFire;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
c->wparam = 100;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool scentResistant() {
|
2017-03-23 10:53:57 +00:00
|
|
|
return markOrb(itOrbBeauty) || markOrb(itOrbAether) || markOrb(itOrbShield);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wouldkill(const char *msg) {
|
|
|
|
if(which == moWarning)
|
|
|
|
addMessage(XLAT("This move appears dangerous -- are you sure?"));
|
|
|
|
else if(which == moFireball)
|
|
|
|
addMessage(XLAT("Cannot move into the current location of another player!"));
|
|
|
|
else if(which == moAirball)
|
|
|
|
addMessage(XLAT("Players cannot get that far away!"));
|
|
|
|
else
|
|
|
|
addMessage(XLAT(msg, which));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool havePushConflict(cell *pushto, bool checkonly) {
|
|
|
|
if(pushto && multi::activePlayers() > 1) {
|
|
|
|
for(int i=0; i<multi::players; i++) if(i != multi::cpid && multi::playerActive(i))
|
|
|
|
if(multi::origpos[i] == pushto || multi::origtarget[i] == pushto) {
|
|
|
|
if(!checkonly)
|
|
|
|
addMessage(XLAT("Cannot push into another player!"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
for(int i=0; i<size(stalemate::moves); i++) {
|
|
|
|
if(pushto == stalemate::moves[i].pushto) {
|
|
|
|
if(!checkonly)
|
|
|
|
addMessage(XLAT("Cannot push into the same location!"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
cell *global_pushto;
|
|
|
|
|
|
|
|
void killFriendlyIvy() {
|
|
|
|
forCellEx(c2, cwt.c) if(c2->monst == moFriendlyIvy)
|
|
|
|
killMonster(c2, moPlayer, 0);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2017-06-18 16:51:46 +00:00
|
|
|
bool monsterPushable(cell *c2) {
|
|
|
|
return (c2->monst != moFatGuard && !(isMetalBeast(c2->monst) && c2->stuntime < 2) && c2->monst != moTortoise);
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool movepcto(int d, int subdir, bool checkonly) {
|
2017-03-23 10:53:57 +00:00
|
|
|
global_pushto = NULL;
|
|
|
|
bool switchplaces = false;
|
|
|
|
|
|
|
|
if(d == MD_USE_ORB)
|
|
|
|
return targetRangedOrb(multi::whereto[multi::cpid].tgt, roMultiGo);
|
|
|
|
|
|
|
|
bool errormsgs = multi::players == 1 || multi::cpid == multi::players-1;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(hardcore && !canmove) return false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(hardcore && checkonly) { return false; }
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly && haveRangedTarget()) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!checkonly && d >= 0) {
|
|
|
|
flipplayer = false;
|
|
|
|
if(multi::players > 1) multi::flipped[multi::cpid] = false;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!checkonly) { DEBB(DF_TURN, (debugfile,"movepc\n")); }
|
2017-03-23 10:53:57 +00:00
|
|
|
int origd = d;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(d >= 0) {
|
|
|
|
cwspin(cwt, d);
|
2017-07-22 23:33:27 +00:00
|
|
|
mirror::act(d, mirror::SPINSINGLE);
|
2016-08-26 09:58:03 +00:00
|
|
|
d = cwt.spin;
|
|
|
|
}
|
|
|
|
if(d != -1 && !checkonly) playermoved = true;
|
|
|
|
if(!checkonly) invismove = false;
|
|
|
|
bool boatmove = false;
|
|
|
|
|
|
|
|
if(againstRose(cwt.c, NULL) && d<0 && !scentResistant()) {
|
|
|
|
if(checkonly) return false;
|
|
|
|
addMessage("You just cannot stand in place, those roses smell too nicely.");
|
|
|
|
return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(d >= 0) {
|
|
|
|
cell *c2 = cwt.c->mov[d];
|
2017-07-04 13:38:33 +00:00
|
|
|
bool goodTortoise = c2->monst == moTortoise && tortoise::seek() && !tortoise::diff(tortoise::getb(c2)) && !c2->item;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(againstRose(cwt.c, c2) && !scentResistant()) {
|
|
|
|
if(checkonly) return false;
|
|
|
|
addMessage("Those roses smell too nicely. You have to come towards them.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(items[itOrbDomination] > ORBBASE && isMountable(c2->monst) && !monstersnear2()) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
|
|
|
if(!isMountable(cwt.c->monst)) dragon::target = NULL;
|
|
|
|
movecost(cwt.c, c2);
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
flipplayer = true; if(multi::players > 1) multi::flipped[multi::cpid] = true;
|
|
|
|
invismove = (turncount >= noiseuntil) && items[itOrbInvis] > 0;
|
|
|
|
killFriendlyIvy();
|
2016-08-26 09:58:03 +00:00
|
|
|
goto mountjump;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!passable(c2, cwt.c, P_ISPLAYER | P_MIRROR | P_USEBOAT | P_FRIENDSWAP) && items[itOrbFlash]) {
|
|
|
|
if(checkonly) return true;
|
2017-09-01 21:01:10 +00:00
|
|
|
if(orbProtection(itOrbFlash)) return true;
|
2016-08-26 09:58:03 +00:00
|
|
|
activateFlash();
|
|
|
|
bfs();
|
2017-03-23 10:53:57 +00:00
|
|
|
if(multi::players > 1) { multi::whereto[multi::cpid].d = MD_UNDECIDED; return false; }
|
2016-08-26 09:58:03 +00:00
|
|
|
checkmove();
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!passable(c2, cwt.c, P_ISPLAYER | P_MIRROR | P_USEBOAT | P_FRIENDSWAP) && items[itOrbLightning]) {
|
|
|
|
if(checkonly) return true;
|
2017-09-01 21:01:10 +00:00
|
|
|
if(orbProtection(itOrbLightning)) return true;
|
2016-08-26 09:58:03 +00:00
|
|
|
activateLightning();
|
|
|
|
keepLightning = true;
|
|
|
|
bfs();
|
|
|
|
keepLightning = false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(multi::players > 1) { multi::whereto[multi::cpid].d = MD_UNDECIDED; return false; }
|
2016-08-26 09:58:03 +00:00
|
|
|
checkmove();
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isActivable(c2)) {
|
|
|
|
if(checkonly) return true;
|
|
|
|
activateActiv(c2, true);
|
|
|
|
bfs();
|
2017-03-23 10:53:57 +00:00
|
|
|
if(multi::players > 1) { multi::whereto[multi::cpid].d = MD_UNDECIDED; return false; }
|
2016-08-26 09:58:03 +00:00
|
|
|
checkmove();
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->wall == waThumperOn && !c2->monst && !nonAdjacentPlayer(c2, cwt.c)) {
|
2017-06-18 16:51:46 +00:00
|
|
|
cell *c3 = determinePush(cwt, c2, subdir, [c2] (cell *c) { return canPushThumperOn(c, c2, cwt.c); });
|
|
|
|
if(c3 == c2) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return false;
|
|
|
|
addMessage(XLAT("No room to push %the1.", c2->wall));
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(monstersnear(c2, NULL, moPlayer, NULL, cwt.c)) {
|
|
|
|
if(!checkonly && errormsgs) wouldkill("%The1 would kill you there!");
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-18 16:51:46 +00:00
|
|
|
global_pushto = c3;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
|
|
|
addMessage(XLAT("You push %the1.", c2->wall));
|
|
|
|
lastmovetype = lmPush; lastmove = cwt.c;
|
2017-06-18 16:51:46 +00:00
|
|
|
pushThumper(c2, c3);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->item == itHolyGrail && roundTableRadius(c2) < newRoundTableRadius()) {
|
|
|
|
if(checkonly) return false;
|
|
|
|
addMessage(XLAT("That was not a challenge. Find a larger castle!"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-09-17 12:00:28 +00:00
|
|
|
if(c2->item == itOrbYendor && !checkonly && !peace::on && !itemHiddenFromSight(c2) && yendor::check(c2)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isWatery(c2) && !nonAdjacentPlayer(cwt.c,c2) && !c2->monst && cwt.c->wall == waBoat) {
|
|
|
|
|
|
|
|
if(havePushConflict(cwt.c, checkonly)) return false;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(againstWind(c2, cwt.c)) {
|
|
|
|
if(!checkonly)
|
|
|
|
addMessage(XLAT(airdist(c2) < 3 ? "The Air Elemental blows you away!" : "You cannot go against the wind!"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(againstCurrent(c2, cwt.c) && !markOrb(itOrbWater)) {
|
|
|
|
if(markOrb(itOrbFish)) goto escape;
|
|
|
|
if(!checkonly)
|
|
|
|
addMessage(XLAT("You cannot go against the current!"));
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(monstersnear(c2, NULL, moPlayer, NULL, cwt.c)) {
|
|
|
|
if(!checkonly && errormsgs) wouldkill("%The1 would kill you there!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
|
|
|
moveBoat(c2, cwt.c);
|
|
|
|
boatmove = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
goto boatjump;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-08-18 00:23:53 +00:00
|
|
|
if(!c2->monst && cwt.c->wall == waBoat && boatGoesThrough(c2) && markOrb(itOrbWater) && !nonAdjacentPlayer(c2, cwt.c)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(havePushConflict(cwt.c, checkonly)) return false;
|
|
|
|
if(monstersnear(c2,NULL,moPlayer,NULL,cwt.c)) {
|
|
|
|
if(!checkonly && errormsgs) wouldkill("%The1 would kill you there!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
2017-08-18 00:21:50 +00:00
|
|
|
if(c2->item && !cwt.c->item) moveItem(c2, cwt.c, false), boatmove = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
placeWater(c2, cwt.c);
|
|
|
|
moveBoat(c2, cwt.c);
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->mondir = neighborId(c2, cwt.c);
|
2017-08-18 00:21:50 +00:00
|
|
|
if(c2->item) boatmove = !boatmove;
|
2017-03-23 10:53:57 +00:00
|
|
|
goto boatjump;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
escape:
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->wall == waBigStatue && !c2->monst && !nonAdjacentPlayer(c2, cwt.c)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!canPushStatueOn(cwt.c)) {
|
|
|
|
if(checkonly) return false;
|
|
|
|
if(isFire(cwt.c))
|
|
|
|
addMessage(XLAT("You have to escape first!"));
|
|
|
|
else
|
|
|
|
addMessage(XLAT("There is not enough space!"));
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(havePushConflict(cwt.c, checkonly)) return false;
|
|
|
|
|
|
|
|
eWall save_c2 = c2->wall;
|
|
|
|
eWall save_cw = cwt.c->wall;
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->wall = cwt.c->wall;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(doesnotFall(cwt.c))
|
2016-08-26 09:58:03 +00:00
|
|
|
cwt.c->wall = waBigStatue;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(monstersnear(c2,NULL,moPlayer,NULL,cwt.c)) {
|
|
|
|
if(!checkonly && errormsgs) wouldkill("%The1 would kill you there!");
|
|
|
|
c2->wall = save_c2; cwt.c->wall = save_cw;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(checkonly) { c2->wall = save_c2; cwt.c->wall = save_cw; return true; }
|
|
|
|
addMessage(XLAT("You push %the1 behind you!", waBigStatue));
|
|
|
|
animateMovement(c2, cwt.c, LAYER_BOAT);
|
|
|
|
goto statuejump;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
bool attackable;
|
|
|
|
attackable =
|
|
|
|
c2->wall == waBigTree ||
|
|
|
|
c2->wall == waSmallTree ||
|
|
|
|
c2->wall == waMirrorWall;
|
|
|
|
attackable = attackable && (!c2->monst || isFriendly(c2));
|
|
|
|
if(attackable && markOrb(itOrbAether) && c2->wall != waMirrorWall)
|
|
|
|
attackable = false;
|
|
|
|
attackable = attackable && !nonAdjacentPlayer(cwt.c,c2);
|
|
|
|
|
|
|
|
if(attackable) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkNeedMove(checkonly, true)) return false;
|
2017-07-22 23:33:27 +00:00
|
|
|
if(monstersnear(cwt.c,c2,moPlayer,NULL,cwt.c)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!checkonly && errormsgs) wouldkill("%The1 would get you!");
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
2017-07-22 23:33:27 +00:00
|
|
|
if(c2->wall == waSmallTree) {
|
|
|
|
drawParticles(c2, winf[c2->wall].color, 4);
|
2017-10-17 06:01:57 +00:00
|
|
|
addMessage(XLAT("You chop down the tree."));
|
2017-07-22 23:33:27 +00:00
|
|
|
playSound(c2, "hit-axe" + pick123());
|
|
|
|
c2->wall = waNone;
|
|
|
|
}
|
|
|
|
else if(c2->wall == waBigTree) {
|
|
|
|
drawParticles(c2, winf[c2->wall].color, 8);
|
2017-10-17 06:01:57 +00:00
|
|
|
addMessage(XLAT("You start chopping down the tree."));
|
2017-07-22 23:33:27 +00:00
|
|
|
playSound(c2, "hit-axe" + pick123());
|
|
|
|
c2->wall = waSmallTree;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(!peace::on)
|
|
|
|
addMessage(XLAT("You swing your sword at the mirror."));
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(survivalist && isHaunted(c2->land))
|
|
|
|
survivalist = false;
|
2017-07-22 23:33:27 +00:00
|
|
|
mirror::act(origd, mirror::SPINMULTI | mirror::ATTACK);
|
2016-08-26 09:58:03 +00:00
|
|
|
lastmovetype = lmTree; lastmove = c2;
|
2017-03-23 10:53:57 +00:00
|
|
|
swordAttackStatic();
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
else if(c2->monst == moKnight) {
|
|
|
|
if(checkonly) return false;
|
|
|
|
knightFlavorMessage(c2);
|
|
|
|
return false;
|
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
else if(c2->monst && (!isFriendly(c2) || c2->monst == moTameBomberbird || isMountable(c2->monst))
|
|
|
|
&& !(peace::on && !isMultitile(c2->monst) && !goodTortoise)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
bool fast = !((!items[itOrbSpeed]) || (items[itOrbSpeed]&1));
|
|
|
|
|
|
|
|
if(!canAttack(cwt.c, moPlayer, c2, c2->monst, fast ? AF_FAST : 0)) {
|
|
|
|
if(checkonly) return false;
|
|
|
|
if(c2->monst == moWorm || c2->monst == moWormtail || c2->monst == moWormwait)
|
|
|
|
addMessage(XLAT("You cannot attack Sandworms directly!"));
|
|
|
|
else if(c2->monst == moHexSnake || c2->monst == moHexSnakeTail)
|
|
|
|
addMessage(XLAT("You cannot attack Rock Snakes directly!"));
|
|
|
|
else if(nonAdjacent(c2, cwt.c))
|
|
|
|
addMessage(XLAT("You cannot attack diagonally!"));
|
|
|
|
else if(thruVine(c2, cwt.c))
|
|
|
|
addMessage(XLAT("You cannot attack through the Vine!"));
|
|
|
|
else if(c2->monst == moTentacle || c2->monst == moTentacletail || c2->monst == moTentaclewait || c2->monst == moTentacleEscaping)
|
|
|
|
addMessage(XLAT("You cannot attack Tentacles directly!"));
|
|
|
|
else if(c2->monst == moHedge && !markOrb(itOrbThorns)) {
|
|
|
|
addMessage(XLAT("You cannot attack %the1 directly!", c2->monst));
|
|
|
|
addMessage(XLAT("Stab them by walking around them."));
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c2->monst == moRoseBeauty || isBull(c2->monst) || c2->monst == moButterfly)
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("You cannot attack %the1!", c2->monst));
|
|
|
|
else if(c2->monst == moFlailer && !c2->stuntime) {
|
|
|
|
addMessage(XLAT("You cannot attack %the1 directly!", c2->monst));
|
|
|
|
addMessage(XLAT("Make him hit himself by walking away from him."));
|
|
|
|
}
|
|
|
|
else if(c2->monst == moVizier && c2->hitpoints > 1 && !fast) {
|
|
|
|
addMessage(XLAT("You cannot attack %the1 directly!", c2->monst));
|
|
|
|
addMessage(XLAT("Hit him by walking away from him."));
|
|
|
|
}
|
|
|
|
else if(c2->monst == moShadow)
|
|
|
|
addMessage(XLAT("You cannot defeat the Shadow!"));
|
|
|
|
else if(c2->monst == moGreater || c2->monst == moGreaterM)
|
|
|
|
addMessage(XLAT("You cannot defeat the Greater Demon yet!"));
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(c2->monst == moDraugr)
|
|
|
|
addMessage(XLAT("Your mundane weapon cannot hurt %the1!", c2->monst));
|
2016-08-26 09:58:03 +00:00
|
|
|
else
|
|
|
|
addMessage(XLAT("For some reason... cannot attack!"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-18 16:51:46 +00:00
|
|
|
// pushto=c2 means that the monster is not killed and thus
|
|
|
|
// still counts for lightning in monstersnear
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *pushto = NULL;
|
|
|
|
if(isStunnable(c2->monst) && c2->hitpoints > 1) {
|
2017-06-18 16:51:46 +00:00
|
|
|
if(monsterPushable(c2))
|
|
|
|
pushto = determinePush(cwt, c2, subdir, [c2] (cell *c) { return passable(c, c2, P_BLOW); });
|
|
|
|
else
|
|
|
|
pushto = c2;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
if(c2->monst == moTroll || c2->monst == moFjordTroll ||
|
|
|
|
c2->monst == moForestTroll || c2->monst == moStormTroll || c2->monst == moVineSpirit)
|
|
|
|
pushto = c2;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
global_pushto = pushto;
|
|
|
|
|
|
|
|
if(havePushConflict(pushto, checkonly)) return false;
|
|
|
|
|
|
|
|
if(!(isWatery(cwt.c) && c2->monst == moWaterElemental) && checkNeedMove(checkonly, true))
|
|
|
|
return false;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(monstersnear(cwt.c, c2, moPlayer, pushto, cwt.c)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(errormsgs && !checkonly)
|
|
|
|
wouldkill("You would be killed by %the1!");
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
|
|
|
|
|
|
|
|
|
|
|
/* if(c2->monst == moTortoise) {
|
|
|
|
printf("seek=%d get=%d <%x/%x> item=%d\n",
|
|
|
|
tortoise::seeking,
|
|
|
|
!tortoise::diff(tortoise::getb(c2)),
|
|
|
|
tortoise::getb(c2) & tortoise::mask,
|
|
|
|
tortoise::seekbits & tortoise::mask,
|
|
|
|
!c2->item);
|
|
|
|
} */
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
mirror::act(origd, mirror::SPINMULTI | mirror::ATTACK);
|
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
if(goodTortoise) {
|
2016-08-26 09:58:03 +00:00
|
|
|
items[itBabyTortoise] += 4;
|
|
|
|
updateHi(itBabyTortoise, items[itBabyTortoise]);
|
|
|
|
c2->item = itBabyTortoise;
|
|
|
|
tortoise::babymap[c2] = tortoise::seekbits;
|
2017-03-23 10:53:57 +00:00
|
|
|
playSound(c2, playergender() ? "heal-princess" : "heal-prince");
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT(playergender() == GEN_F ? "You are now a tortoise heroine!" : "You are now a tortoise hero!"));
|
|
|
|
c2->stuntime = 2;
|
|
|
|
achievement_collection(itBabyTortoise, 0, 0);
|
|
|
|
}
|
|
|
|
else if(isStunnable(c2->monst) && c2->hitpoints > 1) {
|
2017-03-23 10:53:57 +00:00
|
|
|
attackMonster(c2, AF_ORSTUN | AF_MSG, moPlayer);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(pushto && pushto != c2) pushMonster(pushto, c2);
|
|
|
|
}
|
|
|
|
else if(c2->monst == moVizier && c2->hitpoints > 1) {
|
2017-03-23 10:53:57 +00:00
|
|
|
fightmessage(c2->monst, moPlayer, true, 0);
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->hitpoints--;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(isDragon(c2->monst) || isKraken(c2->monst)) {
|
|
|
|
attackMonster(c2, AF_ORSTUN | AF_MSG, moPlayer);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
eMonster m = c2->monst;
|
2017-07-22 23:33:27 +00:00
|
|
|
if(m) {
|
|
|
|
attackMonster(c2, AF_MSG, moPlayer);
|
|
|
|
produceGhost(c2, m, moPlayer);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lastmovetype = lmAttack; lastmove = c2;
|
2017-03-23 10:53:57 +00:00
|
|
|
swordAttackStatic();
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
else if(!passable(c2, cwt.c, P_USEBOAT | P_ISPLAYER | P_MIRROR | P_MONSTER)) {
|
|
|
|
if(checkonly) return false;
|
|
|
|
if(nonAdjacent(cwt.c,c2))
|
|
|
|
addMessage(XLAT(
|
|
|
|
purehepta ?
|
|
|
|
"You cannot move between the cells without dots here!" :
|
|
|
|
"You cannot move between the triangular cells here!"
|
|
|
|
));
|
|
|
|
else if(isAlch(c2))
|
|
|
|
addMessage(XLAT("Wrong color!"));
|
|
|
|
else if(c2->wall == waRoundTable)
|
|
|
|
addMessage(XLAT("It would be impolite to land on the table!"));
|
|
|
|
else if(cwt.c->wall == waRed3 && snakelevel(c2) == 0)
|
|
|
|
addMessage(XLAT("You would get hurt!", c2->wall));
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(cwt.c->wall == waTower && snakelevel(c2) == 0)
|
|
|
|
addMessage(XLAT("You would get hurt!", c2->wall));
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(cellEdgeUnstable(cwt.c) && cellEdgeUnstable(c2))
|
|
|
|
addMessage(XLAT("Gravity does not allow this!"));
|
|
|
|
else if(againstWind(c2, cwt.c))
|
|
|
|
addMessage(XLAT(airdist(c2) < 3 ? "The Air Elemental blows you away!" : "You cannot go against the wind!"));
|
|
|
|
else {
|
|
|
|
addMessage(XLAT("You cannot move through %the1!", c2->wall));
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(mineMarked(c2) && !minesafe() && !checkonly && warningprotection()) {
|
|
|
|
addMessage("Are you sure you want to step there?");
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(monstersnear(c2, NULL, moPlayer, NULL, cwt.c)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return false;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(items[itOrbFlash]) {
|
|
|
|
if(checkonly) return true;
|
2017-09-01 21:01:10 +00:00
|
|
|
if(orbProtection(itOrbFlash)) return true;
|
2016-08-26 09:58:03 +00:00
|
|
|
activateFlash();
|
|
|
|
checkmove();
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(items[itOrbLightning]) {
|
|
|
|
if(checkonly) return true;
|
2017-09-01 21:01:10 +00:00
|
|
|
if(orbProtection(itOrbLightning)) return true;
|
2016-08-26 09:58:03 +00:00
|
|
|
activateLightning();
|
|
|
|
checkmove();
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(which == moOutlaw && items[itRevolver]) {
|
|
|
|
for(int i=0; i<c2->type; i++) {
|
|
|
|
cell *c3 = c2->mov[i];
|
|
|
|
if(c3) for(int i=0; i<c3->type; i++) {
|
|
|
|
cell *c4 = c3->mov[i];
|
|
|
|
if(c4 && c4->monst == moOutlaw) {
|
|
|
|
eItem i = targetRangedOrb(c4, roCheck);
|
|
|
|
if(i == itRevolver) {
|
|
|
|
targetRangedOrb(c4, roKeyboard);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!checkonly && errormsgs)
|
|
|
|
wouldkill("%The1 would kill you there!");
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(checkonly) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
boatjump:
|
|
|
|
statuejump:
|
|
|
|
flipplayer = true; if(multi::players > 1) multi::flipped[multi::cpid] = true;
|
2017-08-18 00:07:56 +00:00
|
|
|
if(c2->item && isAlch(c2)) {
|
|
|
|
if(cwt.c->wall == waBoat)
|
|
|
|
c2->wall = waNone;
|
|
|
|
else
|
|
|
|
c2->wall = cwt.c->wall;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->wall == waRoundTable) {
|
|
|
|
addMessage(XLAT("You jump over the table!"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cwt.c->wall == waRoundTable)
|
|
|
|
roundTableMessage(c2);
|
|
|
|
|
|
|
|
invismove = (turncount >= noiseuntil) && items[itOrbInvis] > 0;
|
|
|
|
|
|
|
|
if(items[itOrbFire]) {
|
|
|
|
invismove = false;
|
|
|
|
if(makeflame(cwt.c, 10, false)) markOrb(itOrbFire);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
{
|
|
|
|
bool haveIvy = false;
|
|
|
|
forCellEx(c3, cwt.c) if(c3->monst == moFriendlyIvy) haveIvy = true;
|
|
|
|
|
|
|
|
bool killIvy = haveIvy;
|
|
|
|
|
|
|
|
if(items[itOrbNature]) {
|
|
|
|
if(c2->monst != moFriendlyIvy && strictlyAgainstGravity(c2, cwt.c, false, MF_IVY)) {
|
|
|
|
invismove = false;
|
|
|
|
}
|
|
|
|
else if(cwt.c->monst) invismove = false;
|
|
|
|
else if(haveIvy || !cellEdgeUnstable(cwt.c, MF_IVY)) {
|
|
|
|
cwt.c->monst = moFriendlyIvy;
|
|
|
|
cwt.c->mondir = neighborId(cwt.c, c2);
|
|
|
|
invismove = false;
|
|
|
|
markOrb(itOrbNature);
|
|
|
|
killIvy = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(killIvy) killFriendlyIvy();
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(items[itOrbDigging]) {
|
|
|
|
invismove = false;
|
|
|
|
if(earthMove(cwt.c, d)) markOrb(itOrbDigging);
|
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!boatmove && collectItem(c2)) return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isIcyLand(cwt.c) && cwt.c->wall == waNone && markOrb(itOrbWinter)) {
|
|
|
|
invismove = false;
|
|
|
|
cwt.c->wall = waIcewall;
|
|
|
|
}
|
|
|
|
|
|
|
|
movecost(cwt.c, c2);
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
{
|
|
|
|
bool pushpast = false;
|
|
|
|
pushpast =
|
|
|
|
c2->monst == moGolem || c2->monst == moIllusion || isPrincess(c2->monst) || c2->monst == moMouse ||
|
|
|
|
c2->monst == moFriendlyGhost;
|
|
|
|
|
|
|
|
if(peace::on) pushpast |= c2->monst && !isMultitile(c2->monst);
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(pushpast) {
|
2017-03-23 10:53:57 +00:00
|
|
|
bool pswitch = false;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->monst == moMouse)
|
|
|
|
princess::mouseSqueak(c2);
|
|
|
|
else if(isPrincess(c2->monst)) {
|
|
|
|
princess::line(c2);
|
|
|
|
princess::move(cwt.c, c2);
|
|
|
|
}
|
|
|
|
else
|
2017-03-23 10:53:57 +00:00
|
|
|
pswitch = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
cwt.c->hitpoints = c2->hitpoints;
|
|
|
|
cwt.c->stuntime = c2->stuntime;
|
|
|
|
placeGolem(cwt.c, c2, c2->monst);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(cwt.c->monst != moNone && pswitch)
|
|
|
|
addMessage(XLAT("You switch places with %the1.", c2->monst));
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->monst = moNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
switchplaces = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
mountjump:
|
|
|
|
lastmovetype = lmMove; lastmove = cwt.c;
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
stabbingAttack(cwt.c, c2, moPlayer);
|
|
|
|
cell *c1 = cwt.c;
|
|
|
|
cwstep(cwt);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(switchplaces)
|
|
|
|
animateReplacement(c1, cwt.c, LAYER_SMALL);
|
|
|
|
else
|
|
|
|
animateMovement(c1, cwt.c, LAYER_SMALL);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
mirror::act(origd, mirror::SPINMULTI | mirror::ATTACK | mirror::GO);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
playerMoveEffects(c1, c2);
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->monst == moFriendlyIvy) c2->monst = moNone;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
countLocalTreasure();
|
|
|
|
landvisited[cwt.c->land] = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
afterplayermoved();
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else {
|
|
|
|
lastmovetype = lmSkip; lastmove = NULL;
|
|
|
|
if(checkNeedMove(checkonly, false))
|
|
|
|
return false;
|
|
|
|
if(monstersnear(cwt.c, NULL, moPlayer, NULL, cwt.c)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(errormsgs && !checkonly)
|
|
|
|
wouldkill("%The1 would get you!");
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(checkonly) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
swordAttackStatic();
|
2016-08-26 09:58:03 +00:00
|
|
|
if(d == -2)
|
|
|
|
dropGreenStone(cwt.c);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(cellUnstable(cwt.c) && !markOrb(itOrbAether))
|
|
|
|
doesFallSound(cwt.c);
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
invisfish = false;
|
|
|
|
if(items[itOrbFish]) {
|
|
|
|
invisfish = true;
|
|
|
|
for(int i=0; i<numplayers(); i++)
|
2017-03-23 10:53:57 +00:00
|
|
|
if(multi::playerActive(i) && !isWatery(playerpos(i)))
|
2016-08-26 09:58:03 +00:00
|
|
|
invisfish = false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(d < 0) invisfish = false; // no invisibility if staying still
|
2016-08-26 09:58:03 +00:00
|
|
|
if(invisfish) invismove = true, markOrb(itOrbFish);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(multi::players == 1) monstersTurn();
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2017-07-16 21:00:55 +00:00
|
|
|
check_total_victory();
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(items[itWhirlpool] && cwt.c->land != laWhirlpool && !whirlpool::escaped) {
|
|
|
|
whirlpool::escaped = true;
|
|
|
|
achievement_gain("WHIRL1");
|
2016-01-02 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(items[itLotus] >= 25 && !isHaunted(cwt.c->land) && survivalist) {
|
|
|
|
survivalist = false;
|
|
|
|
achievement_gain("SURVIVAL");
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(seenSevenMines && cwt.c->land != laMinefield) {
|
|
|
|
seenSevenMines = false;
|
|
|
|
achievement_gain("SEVENMINE");
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
DEBT("done");
|
|
|
|
return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
/* bool isPsiTarget(cell *dst) {
|
|
|
|
return
|
|
|
|
dst->cpdist > 1 &&
|
|
|
|
dst->monst &&
|
|
|
|
!(isWorm(dst) || dst->monst == moShadow);
|
2017-03-23 10:53:57 +00:00
|
|
|
} */
|
2015-08-08 13:57:52 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveItem1(cell *from, cell *to, bool activateYendor) {
|
|
|
|
if(from->item == itOrbYendor) {
|
|
|
|
bool xnew = true;
|
|
|
|
for(int i=0; i<size(yendor::yi); i++)
|
|
|
|
if(yendor::yi[i].path[0] == from) xnew = false;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(xnew && activateYendor) yendor::check(from);
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<size(yendor::yi); i++)
|
|
|
|
if(yendor::yi[i].path[0] == from)
|
|
|
|
yendor::yi[i].path[0] = to;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(from->item == itKey) {
|
|
|
|
for(int i=0; i<size(yendor::yi); i++) if(yendor::yi[i].path[YDIST-1] == from)
|
|
|
|
yendor::yi[i].path[YDIST-1] = to;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(from->item == itBabyTortoise) {
|
|
|
|
tortoise::babymap[to] = tortoise::babymap[from];
|
|
|
|
tortoise::babymap.erase(from);
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
eItem i = to->item;
|
|
|
|
to->item = from->item;
|
|
|
|
from->item = i;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void moveItem (cell *from, cell *to, bool activateYendor) {
|
|
|
|
static cell dummy;
|
|
|
|
dummy.item = itNone;
|
|
|
|
moveItem1(from, &dummy, activateYendor);
|
|
|
|
moveItem1(to, from, activateYendor);
|
|
|
|
moveItem1(&dummy, to, activateYendor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fixWormBug(cell *c) {
|
2017-04-14 18:12:23 +00:00
|
|
|
if(conformal::includeHistory) return;
|
2017-03-23 10:53:57 +00:00
|
|
|
printf("worm bug!\n");
|
|
|
|
if(c->monst == moWormtail) c->monst = moWormwait;
|
|
|
|
if(c->monst == moTentacletail || c->monst == moTentacleGhost) c->monst = moTentacle;
|
|
|
|
if(c->monst == moHexSnakeTail) c->monst = moHexSnake;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *wormhead(cell *c) {
|
|
|
|
// cell *cor = c;
|
|
|
|
findhead:
|
|
|
|
if(c->monst == moTentacle || c->monst == moWorm || c->monst == moHexSnake ||
|
|
|
|
c->monst == moWormwait || c->monst == moTentacleEscaping || c->monst == moTentaclewait ||
|
|
|
|
c->monst == moDragonHead) return c;
|
|
|
|
for(int i=0; i<c->type; i++)
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->mov[i] && isWorm(c->mov[i]->monst) && c->mov[i]->mondir == c->spn(i)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
c = c->mov[i]; goto findhead;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
fixWormBug(c);
|
2016-08-26 09:58:03 +00:00
|
|
|
return c;
|
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int wormpos(cell *c) {
|
|
|
|
// cell *cor = c;
|
|
|
|
int cnt = 0;
|
|
|
|
findhead:
|
|
|
|
if(c->monst == moTentacle || c->monst == moWorm || c->monst == moHexSnake ||
|
|
|
|
c->monst == moWormwait || c->monst == moTentacleEscaping || c->monst == moTentaclewait ||
|
|
|
|
c->monst == moDragonHead) return cnt;
|
|
|
|
for(int i=0; i<c->type; i++)
|
|
|
|
if(c->mov[i] && isWorm(c->mov[i]->monst) && c->mov[i]->mondir == c->spn(i)) {
|
|
|
|
c = c->mov[i]; cnt++; goto findhead;
|
|
|
|
}
|
|
|
|
fixWormBug(c);
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// currently works for worms only
|
|
|
|
bool sameMonster(cell *c1, cell *c2) {
|
|
|
|
if(c1 == c2) return true;
|
|
|
|
if(isWorm(c1->monst) && isWorm(c2->monst))
|
|
|
|
return wormhead(c1) == wormhead(c2);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isKraken(c1->monst) && isKraken(c2->monst))
|
|
|
|
return kraken::head(c1) == kraken::head(c2);
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
eMonster getMount(int i) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!items[itOrbDomination]) return moNone;
|
2017-03-23 10:53:57 +00:00
|
|
|
return playerpos(i)->monst;
|
|
|
|
}
|
|
|
|
|
|
|
|
eMonster haveMount() {
|
|
|
|
for(int i=0; i<numplayers(); i++) if(multi::playerActive(i)) {
|
|
|
|
eMonster m = getMount(i);
|
|
|
|
if(m) return m;
|
|
|
|
}
|
|
|
|
return moNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mightBeMine(cell *c) {
|
|
|
|
return c->wall == waMineUnknown || c->wall == waMineMine;
|
|
|
|
}
|
|
|
|
|
|
|
|
void performMarkCommand(cell *c) {
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_ROGUEVIZ
|
2017-06-09 01:41:33 +00:00
|
|
|
rogueviz::mark(c);
|
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c->land == laCA && c->wall == waNone)
|
|
|
|
c->wall = waFloorA;
|
|
|
|
else if(c->land == laCA && c->wall == waFloorA)
|
|
|
|
c->wall = waNone;
|
|
|
|
if(c->land != laMinefield) return;
|
|
|
|
if(c->item) return;
|
|
|
|
if(!mightBeMine(c)) return;
|
|
|
|
bool adj = false;
|
|
|
|
forCellEx(c2, c) if(c2->wall == waMineOpen) adj = true;
|
|
|
|
if(adj) c->landparam ^= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mineMarked(cell *c) {
|
|
|
|
if(!mightBeMine(c)) return false;
|
|
|
|
if(c->item) return false;
|
|
|
|
if(c->land != laMinefield) return true;
|
|
|
|
return c->landparam & 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mineMarkedSafe(cell *c) {
|
|
|
|
if(!mightBeMine(c)) return false;
|
|
|
|
if(c->item) return true;
|
|
|
|
if(c->land != laMinefield) return false;
|
|
|
|
return c->landparam & 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool minesafe() {
|
|
|
|
return items[itOrbAether];
|
|
|
|
}
|
|
|
|
|
|
|
|
bool warningprotection() {
|
|
|
|
if(hardcore) return false;
|
|
|
|
if(multi::activePlayers() > 1) return false;
|
|
|
|
if(items[itWarning]) return false;
|
|
|
|
items[itWarning] = 1;
|
|
|
|
return true;
|
2015-08-08 13:57:52 +00:00
|
|
|
}
|
2016-01-02 10:09:13 +00:00
|
|
|
|