1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-08-11 00:04:09 +00:00

fixed the direction setup by Orb of Chaos

This commit is contained in:
Zeno Rogue 2021-06-16 11:02:02 +02:00
parent 56556ca1e1
commit 7b38fc4de1
2 changed files with 17 additions and 8 deletions

View File

@ -260,6 +260,11 @@ template<class T> struct walker {
return tie(at, spin, mirrored) < tie(cw2.at, cw2.spin, cw2.mirrored); return tie(at, spin, mirrored) < tie(cw2.at, cw2.spin, cw2.mirrored);
} }
/** how much should we spin to face direction dir */
int to_spin(int dir) {
return gmod(dir - spin, at->type) * (mirrored ? -1 : 1);
}
walker<T>& operator ++ (int) { return (*this) += 1; } walker<T>& operator ++ (int) { return (*this) += 1; }
walker<T>& operator -- (int) { return (*this) -= 1; } walker<T>& operator -- (int) { return (*this) -= 1; }
template<class U> walker operator + (U t) const { walker<T> w = *this; w += t; return w; } template<class U> walker operator + (U t) const { walker<T> w = *this; w += t; return w; }

View File

@ -535,14 +535,22 @@ bool switch_lhu_in(eLand l) {
return among(l, laBrownian, laMinefield, laTerracotta, laHive); return among(l, laBrownian, laMinefield, laTerracotta, laHive);
} }
/** \brief how should be the direction from 'src' be mirrored to 'dst' */
EX int chaos_mirror_dir(int dir, cellwalker src, cellwalker dst) {
if(dir >= dst.at->type) return dir;
return (dst-src.to_spin(dir)).spin;
}
/** \brief Apply the Orb of Chaos. /** \brief Apply the Orb of Chaos.
* *
* We assume that the player moves from cwt.peek, in * We assume that the player moves from cwt.peek, in
* in the direction given by cwt.spin. * in the direction given by cwt.spin.
*/ */
void apply_chaos() { void apply_chaos() {
cell *ca = (cwt+1).cpeek(); auto wa = cwt+1+wstep;
cell *cb = (cwt-1).cpeek(); auto wb = cwt-1+wstep;
cell *ca = wa.at;
cell *cb = wb.at;
if(!items[itOrbChaos] || chaos_forbidden(ca) || chaos_forbidden(cb)) return; if(!items[itOrbChaos] || chaos_forbidden(ca) || chaos_forbidden(cb)) return;
if(ca && is_paired(ca->monst)) killMonster(ca, moPlayer); if(ca && is_paired(ca->monst)) killMonster(ca, moPlayer);
if(cb && is_paired(cb->monst)) killMonster(cb, moPlayer); if(cb && is_paired(cb->monst)) killMonster(cb, moPlayer);
@ -560,18 +568,14 @@ void apply_chaos() {
copy_metadata(cb, &coa); copy_metadata(cb, &coa);
if(!switch_lhu_in(ca->land)) ca->LHU = coa.LHU; if(!switch_lhu_in(ca->land)) ca->LHU = coa.LHU;
if(!switch_lhu_in(cb->land)) cb->LHU = cob.LHU; if(!switch_lhu_in(cb->land)) cb->LHU = cob.LHU;
int sa = ca->mondir - ((cwt+1)+wstep).spin;
int sb = cb->mondir - ((cwt-1)+wstep).spin;
if(ca->monst && !(isFriendly(ca) && markOrb(itOrbEmpathy))) if(ca->monst && !(isFriendly(ca) && markOrb(itOrbEmpathy)))
ca->stuntime = min(ca->stuntime + 3, 15), markOrb(itOrbChaos); ca->stuntime = min(ca->stuntime + 3, 15), markOrb(itOrbChaos);
if(cb->monst && !(isFriendly(cb) && markOrb(itOrbEmpathy))) if(cb->monst && !(isFriendly(cb) && markOrb(itOrbEmpathy)))
cb->stuntime = min(cb->stuntime + 3, 15), markOrb(itOrbChaos); cb->stuntime = min(cb->stuntime + 3, 15), markOrb(itOrbChaos);
ca->monmirror = !ca->monmirror; ca->monmirror = !ca->monmirror;
cb->monmirror = !cb->monmirror; cb->monmirror = !cb->monmirror;
if(ca->mondir < ca->type) ca->mondir = chaos_mirror_dir(ca->mondir, wb, wa);
ca->mondir = ((cwt+1)+wstep-sb).spin; cb->mondir = chaos_mirror_dir(cb->mondir, wa, wb);
if(cb->mondir < cb->type)
cb->mondir = ((cwt+1)+wstep-sa).spin;
if(isPrincess(ca) && !isPrincess(cb)) if(isPrincess(ca) && !isPrincess(cb))
princess::move(movei{cb, ca, JUMP}); princess::move(movei{cb, ca, JUMP});
if(isPrincess(cb) && !isPrincess(ca)) if(isPrincess(cb) && !isPrincess(ca))