mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-02 12:19:18 +00:00
more movei
This commit is contained in:
parent
e6853e6540
commit
bf584b5429
23
complex.cpp
23
complex.cpp
@ -141,7 +141,7 @@ EX namespace whirlwind {
|
||||
for(int i=0; i<z-1; i++) {
|
||||
moveItem(whirlline[i], whirlline[i+1], true);
|
||||
if(whirlline[i]->item)
|
||||
animateMovement(whirlline[i+1], whirlline[i], LAYER_BOAT, NOHINT);
|
||||
animateMovement(match(whirlline[i+1], whirlline[i]), LAYER_BOAT);
|
||||
}
|
||||
for(int i=0; i<z; i++)
|
||||
pickupMovedItems(whirlline[i]);
|
||||
@ -1036,7 +1036,7 @@ EX namespace whirlpool {
|
||||
if(wfrom && wto && wfrom->wall == waBoat && wto->wall == waSea && !wto->monst) {
|
||||
wfrom->wall = waSea; wto->wall = waBoat;
|
||||
wto->mondir = neighborId(wto, wfrom);
|
||||
animateMovement(wfrom, wto, LAYER_BOAT, NOHINT);
|
||||
animateMovement(moveimon(wto).rev(), LAYER_BOAT);
|
||||
}
|
||||
|
||||
if(wfrom && wto && wfrom->item && !wto->item && wfrom->wall != waBoat) {
|
||||
@ -2499,14 +2499,14 @@ EX namespace dragon {
|
||||
void pullback(cell *c) {
|
||||
int maxlen = 1000;
|
||||
while(maxlen-->0) {
|
||||
cell *c2 = c->move(c->mondir);
|
||||
mountmove(c, c->mondir, true, c2);
|
||||
c->monst = c2->monst;
|
||||
c->hitpoints = c2->hitpoints;
|
||||
animateMovement(c2, c, LAYER_BIG, c->c.spin(c->mondir));
|
||||
auto mi = moveimon(c).rev();
|
||||
mountmove(mi, true);
|
||||
c->monst = mi.s->monst;
|
||||
c->hitpoints = mi.s->hitpoints;
|
||||
animateMovement(mi, LAYER_BIG);
|
||||
c->stuntime = 2;
|
||||
if(c2->mondir == NODIR) { c->mondir = NODIR; c2->monst = moNone; return; }
|
||||
c = c2;
|
||||
if(mi.s->mondir == NODIR) { c->mondir = NODIR; mi.s->monst = moNone; return; }
|
||||
c = mi.s;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2622,8 +2622,9 @@ EX namespace dragon {
|
||||
cmt->hitpoints = cft->hitpoints;
|
||||
cmt->monst = cft->monst;
|
||||
cft->monst = moNone;
|
||||
mountmove(cmt, cmt->mondir, true, cft);
|
||||
animateMovement(cft, cmt, LAYER_BIG, allcells[i]->mondir);
|
||||
auto mi = moveimon(cft);
|
||||
mountmove(mi, true);
|
||||
animateMovement(mi, LAYER_BIG);
|
||||
}
|
||||
while(c->mondir != NODIR) {
|
||||
c = c->move(c->mondir);
|
||||
|
@ -249,7 +249,7 @@ EX namespace westwall {
|
||||
for(int i=0; i<z-1; i++) {
|
||||
moveItem(whirlline[i], whirlline[i+1], true);
|
||||
if(whirlline[i]->item)
|
||||
animateMovement(whirlline[i+1], whirlline[i], LAYER_BOAT, NOHINT);
|
||||
animateMovement(match(whirlline[i+1], whirlline[i]), LAYER_BOAT);
|
||||
}
|
||||
for(int i=0; i<z; i++)
|
||||
pickupMovedItems(whirlline[i]);
|
||||
|
85
game.cpp
85
game.cpp
@ -4678,30 +4678,26 @@ EX void afterplayermoved() {
|
||||
}
|
||||
}
|
||||
|
||||
EX void mountmove(cell *c, int spin, bool fp, int id) {
|
||||
EX void mountmove(const movei& mi, bool fp) {
|
||||
for(int i=0; i<numplayers(); i++) {
|
||||
if(playerpos(i) == mi.s) {
|
||||
animateMovement(mi, LAYER_SMALL);
|
||||
if(multi::players > 1) {
|
||||
multi::player[id].at = c;
|
||||
multi::player[id].spin = spin;
|
||||
multi::flipped[id] = fp;
|
||||
multi::player[i].at = mi.t;
|
||||
multi::player[i].spin = mi.rev_dir();
|
||||
multi::flipped[i] = fp;
|
||||
}
|
||||
else {
|
||||
cwt.at = c;
|
||||
cwt.spin = spin;
|
||||
cwt.at = mi.t;
|
||||
cwt.spin = mi.rev_dir();
|
||||
flipplayer = fp;
|
||||
}
|
||||
afterplayermoved();
|
||||
}
|
||||
|
||||
EX 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, revhint(c, spin));
|
||||
mountmove(c, spin, fp, i);
|
||||
if(lastmountpos[i] == mi.s && mi.s) {
|
||||
lastmountpos[i] = mi.t;
|
||||
}
|
||||
if(lastmountpos[i] == ppos && ppos != NULL) {
|
||||
lastmountpos[i] = c;
|
||||
}
|
||||
else if(lastmountpos[i] == c) {
|
||||
else if(lastmountpos[i] == mi.t) {
|
||||
lastmountpos[i] = NULL;
|
||||
}
|
||||
}
|
||||
@ -4729,9 +4725,10 @@ EX void moveWorm(cell *c) {
|
||||
for(int i=isize(allcells)-2; i>=0; i--) {
|
||||
cell *cmt = allcells[i+1];
|
||||
cell *cft = allcells[i];
|
||||
auto mi = moveimon(cft);
|
||||
if(cft->monst != moTentacleGhost && cmt->monst != moTentacleGhost)
|
||||
mountmove(cmt, cft->c.spin(cft->mondir), false, cft);
|
||||
animateMovement(cft, cmt, LAYER_BIG, cft->mondir);
|
||||
mountmove(mi, false);
|
||||
animateMovement(mi, LAYER_BIG);
|
||||
}
|
||||
c->monst = moNone;
|
||||
if(c->mondir != NODIR) c->move(c->mondir)->monst = moTentacleEscaping;
|
||||
@ -4812,33 +4809,31 @@ EX void moveWorm(cell *c) {
|
||||
goal->mondir = mi.rev_dir_or(NODIR);
|
||||
goal->monmirror = c->monmirror ^ c->c.mirror(dir);
|
||||
|
||||
mountmove(goal, goal->mondir, true, c);
|
||||
mountmove(mi, true);
|
||||
|
||||
if(id) {
|
||||
cell *c2 = c, *c3 = c2;
|
||||
while(c2->monst == moTentacletail || c2->monst == moTentacleGhost) {
|
||||
if(c2->mondir == NODIR) {
|
||||
// drawParticles(c2, (linf[c2->land].color & 0xF0F0F0), 16, 50);
|
||||
return;
|
||||
}
|
||||
c3 = c2, c2 = c3->move(c2->mondir);
|
||||
auto mi = moveimon(c2);
|
||||
if(!mi.proper()) return;
|
||||
c3 = c2, c2 = mi.t;
|
||||
if(c3->monst != moTentacleGhost && c2->monst != moTentacleGhost)
|
||||
mountmove(c3, c3->mondir, true, c2);
|
||||
animateMovement(c2, c3, LAYER_BIG, c2->c.spin(c2->mondir));
|
||||
mountmove(mi, true);
|
||||
animateMovement(mi.rev(), LAYER_BIG);
|
||||
}
|
||||
}
|
||||
|
||||
cell *c2 = c, *c3 = c2;
|
||||
for(int a=0; a<WORMLENGTH; a++) {
|
||||
if(c2->monst == moWormtail) {
|
||||
if(c2->mondir == NODIR) {
|
||||
movei mim = moveimon(c2).rev();
|
||||
if(!mim.proper()) {
|
||||
drawParticles(c2, (linf[c2->land].color & 0xF0F0F0), 16);
|
||||
return;
|
||||
}
|
||||
movei mim(c2, c2->mondir);
|
||||
c3 = c2, c2 = mim.t;
|
||||
mountmove(c3, c3->mondir, true, c2);
|
||||
animateMovement(mim.rev(), LAYER_BIG);
|
||||
c3 = c2, c2 = mim.s;
|
||||
mountmove(mim, true);
|
||||
animateMovement(mim, LAYER_BIG);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5153,15 +5148,16 @@ EX void moveHexSnake(const movei& mi, bool mounted) {
|
||||
preventbarriers(from);
|
||||
|
||||
animateMovement(mi, LAYER_BIG);
|
||||
mountmove(from, from->mondir, true, c);
|
||||
mountmove(mi, true);
|
||||
|
||||
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;
|
||||
mountmove(c2, c2->mondir, true, c2->move(c2->mondir));
|
||||
animateMovement(movei(c2, c2->mondir).rev(), LAYER_BIG);
|
||||
c3 = c2, c2 = c3->move(c2->mondir);
|
||||
auto mim = moveimon(c2).rev();
|
||||
if(!mim.proper()) break;
|
||||
mountmove(mim, true);
|
||||
animateMovement(mim, LAYER_BIG);
|
||||
c3 = c2, c2 = mim.s;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
@ -5307,7 +5303,8 @@ EX void movemutant() {
|
||||
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->move(j);
|
||||
movei mi(c, j);
|
||||
auto& c2 = mi.t;
|
||||
if(!c2) continue;
|
||||
|
||||
if(c2->monst != moMutant && canAttack(c, moMutant, c2, c2->monst, AF_ONLY_FBUG | AF_GETPLAYER)) {
|
||||
@ -5322,7 +5319,7 @@ EX void movemutant() {
|
||||
c2->monst = moMutant;
|
||||
c2->mondir = c->c.spin(j);
|
||||
c2->stuntime = mutantphase;
|
||||
animateMovement(c, c2, LAYER_BIG, j);
|
||||
animateMovement(mi, LAYER_BIG);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5364,7 +5361,7 @@ EX void moveshadow() {
|
||||
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, NOHINT);
|
||||
if(shfrom) animateMovement(match(shfrom, where), LAYER_SMALL);
|
||||
where->monst = moShadow;
|
||||
where->hitpoints = p;
|
||||
where->stuntime = 0;
|
||||
@ -8264,7 +8261,7 @@ EX bool movepcto(int d, int subdir IS(1), bool checkonly IS(false)) {
|
||||
|
||||
if(checkonly) { c2->wall = save_c2; cwt.at->wall = save_cw; nextmovetype = lmMove; return true; }
|
||||
addMessage(XLAT("You push %the1 behind you!", waBigStatue));
|
||||
animateMovement(c2, cwt.at, LAYER_BOAT, cwt.at->c.spin(d));
|
||||
animateMovement(mi.rev(), LAYER_BOAT);
|
||||
goto statuejump;
|
||||
}
|
||||
|
||||
@ -8623,16 +8620,14 @@ EX bool movepcto(int d, int subdir IS(1), bool checkonly IS(false)) {
|
||||
|
||||
stabbingAttack(cwt.at, c2, moPlayer);
|
||||
cell *c1 = cwt.at;
|
||||
int d = cwt.spin;
|
||||
cwt += wstep;
|
||||
if(switchplaces) {
|
||||
movei m(c1, cwt.at, cwt.spin);
|
||||
indAnimateMovement(m, LAYER_SMALL);
|
||||
indAnimateMovement(m.rev(), LAYER_SMALL);
|
||||
indAnimateMovement(mi, LAYER_SMALL);
|
||||
indAnimateMovement(mi.rev(), LAYER_SMALL);
|
||||
commitAnimations(LAYER_SMALL);
|
||||
}
|
||||
else
|
||||
animateMovement(c1, cwt.at, LAYER_SMALL, d);
|
||||
animateMovement(mi, LAYER_SMALL);
|
||||
|
||||
mirror::act(origd, mirror::SPINMULTI | mirror::ATTACK | mirror::GO);
|
||||
|
||||
|
@ -4094,8 +4094,9 @@ EX void drawMarkers() {
|
||||
cell *c1 = mouseover;
|
||||
for(int it=0; it<10; it++) {
|
||||
int di;
|
||||
cell *c2 = blowoff_destination(c1, di);
|
||||
if(!c2) break;
|
||||
auto mib = blowoff_destination(c1, di);
|
||||
if(!mib.proper()) break;
|
||||
auto& c2 = mib.t;
|
||||
transmatrix T1 = ggmatrix(c1);
|
||||
transmatrix T2 = ggmatrix(c2);
|
||||
transmatrix T = T1 * rspintox(inverse(T1)*T2*C0) * xpush(hdist(T1*C0, T2*C0) * fractick(50, 0));
|
||||
@ -5050,10 +5051,6 @@ EX void animateMovement(const movei& m, int layer) {
|
||||
a.mirrored = !a.mirrored;
|
||||
}
|
||||
|
||||
EX void animateMovement(cell *src, cell *tgt, int layer, int direction_hint) {
|
||||
animateMovement(movei(src, tgt, direction_hint), layer);
|
||||
}
|
||||
|
||||
EX void animateAttack(const movei& m, int layer) {
|
||||
if(vid.mspeed >= 5) return; // no animations!
|
||||
transmatrix T = iadj(m);
|
||||
|
@ -457,7 +457,7 @@ struct movei {
|
||||
bool proper() const { return d >= 0 && d < s->type && s->move(d) == t; }
|
||||
movei(cell *_s, int _d) : s(_s), d(_d) {
|
||||
if(d == STRONGWIND) t = whirlwind::jumpDestination(s);
|
||||
else if(d == FALL || d == NO_SPACE) t = s;
|
||||
else if(d < 0 || d >= s->type) t = s;
|
||||
else t = s->move(d);
|
||||
}
|
||||
movei(cell *_s, cell *_t, int _d) : s(_s), t(_t), d(_d) {}
|
||||
@ -465,10 +465,13 @@ struct movei {
|
||||
movei rev() const { return movei(t, s, rev_dir_or(d)); }
|
||||
int dir_or(int x) const { return proper() ? d : x; }
|
||||
int rev_dir_or(int x) const { return proper() ? s->c.spin(d) : x; }
|
||||
int rev_dir() const { return s->c.spin(d); }
|
||||
bool mirror() { return s->c.mirror(d); }
|
||||
};
|
||||
#endif
|
||||
|
||||
EX movei moveimon(cell *c) { return movei(c, c->mondir); }
|
||||
|
||||
EX movei match(cell *f, cell *t) {
|
||||
for(int i=0; i<f->type; i++) if(f->move(i) == t) return movei(f, t, i);
|
||||
return movei(f, t, -1);
|
||||
|
2
orbs.cpp
2
orbs.cpp
@ -601,7 +601,7 @@ EX void jumpTo(cell *dest, eItem byWhat, int bonuskill IS(0), eMonster dashmon I
|
||||
killFriendlyIvy();
|
||||
|
||||
cell *c1 = cwt.at;
|
||||
animateMovement(cwt.at, dest, LAYER_SMALL, NOHINT);
|
||||
animateMovement(match(cwt.at, dest), LAYER_SMALL);
|
||||
cwt.at = dest;
|
||||
forCellIdEx(c2, i, dest) if(c2->cpdist < dest->cpdist) {
|
||||
cwt.spin = i;
|
||||
|
@ -530,7 +530,7 @@ void moved() {
|
||||
cwt.spin = neighborId(centerover, cwt.at);
|
||||
flipplayer = true;
|
||||
}
|
||||
animateMovement(cwt.at, centerover, LAYER_SMALL, NODIR);
|
||||
animateMovement(match(cwt.at, centerover), LAYER_SMALL);
|
||||
cwt.at = centerover;
|
||||
save_memory();
|
||||
return;
|
||||
|
@ -1043,7 +1043,7 @@ void movePlayer(monster *m, int delta) {
|
||||
m->base->wall = waChasm;
|
||||
else {
|
||||
m->base->wall = waBigStatue;
|
||||
animateMovement(c2, m->base, LAYER_BOAT, NOHINT);
|
||||
animateMovement(match(c2, m->base), LAYER_BOAT);
|
||||
}
|
||||
}
|
||||
else if(m->inBoat && !isWateryOrBoat(c2) && passable(c2, m->base, P_ISPLAYER | P_MIRROR | reflectflag)) {
|
||||
@ -2295,7 +2295,7 @@ void moveMonster(monster *m, int delta) {
|
||||
m->base->wall = waChasm;
|
||||
else
|
||||
m->base->wall = waBigStatue;
|
||||
animateMovement(c2, m->base, LAYER_BOAT, NOHINT);
|
||||
animateMovement(match(c2, m->base), LAYER_BOAT);
|
||||
}
|
||||
if(passable_for(m->type, c2, m->base, P_CHAIN | P_ONPLAYER | reflectflag) && !isWatery(c2) && m->inBoat) {
|
||||
if(isWatery(m->base))
|
||||
|
Loading…
Reference in New Issue
Block a user