1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 13:07:16 +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

@ -259,6 +259,11 @@ template<class T> struct walker {
bool operator < (const walker<T>& cw2) const {
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; }

View File

@ -535,14 +535,22 @@ bool switch_lhu_in(eLand l) {
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.
*
* We assume that the player moves from cwt.peek, in
* in the direction given by cwt.spin.
*/
void apply_chaos() {
cell *ca = (cwt+1).cpeek();
cell *cb = (cwt-1).cpeek();
auto wa = cwt+1+wstep;
auto wb = cwt-1+wstep;
cell *ca = wa.at;
cell *cb = wb.at;
if(!items[itOrbChaos] || chaos_forbidden(ca) || chaos_forbidden(cb)) return;
if(ca && is_paired(ca->monst)) killMonster(ca, moPlayer);
if(cb && is_paired(cb->monst)) killMonster(cb, moPlayer);
@ -560,18 +568,14 @@ void apply_chaos() {
copy_metadata(cb, &coa);
if(!switch_lhu_in(ca->land)) ca->LHU = coa.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)))
ca->stuntime = min(ca->stuntime + 3, 15), markOrb(itOrbChaos);
if(cb->monst && !(isFriendly(cb) && markOrb(itOrbEmpathy)))
cb->stuntime = min(cb->stuntime + 3, 15), markOrb(itOrbChaos);
ca->monmirror = !ca->monmirror;
cb->monmirror = !cb->monmirror;
if(ca->mondir < ca->type)
ca->mondir = ((cwt+1)+wstep-sb).spin;
if(cb->mondir < cb->type)
cb->mondir = ((cwt+1)+wstep-sa).spin;
ca->mondir = chaos_mirror_dir(ca->mondir, wb, wa);
cb->mondir = chaos_mirror_dir(cb->mondir, wa, wb);
if(isPrincess(ca) && !isPrincess(cb))
princess::move(movei{cb, ca, JUMP});
if(isPrincess(cb) && !isPrincess(ca))