mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-05-01 15:04:06 +00:00
determinePush now accepts movei instead of c
This commit is contained in:
parent
b0333a6ab7
commit
d7e2b491ac
4
game.cpp
4
game.cpp
@ -402,7 +402,9 @@ EX void pushThumper(const movei& mi) {
|
|||||||
cto->wparam = th->wparam;
|
cto->wparam = th->wparam;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX bool canPushThumperOn(cell *tgt, cell *thumper, cell *player) {
|
EX bool canPushThumperOn(movei mi, cell *player) {
|
||||||
|
cell *thumper = mi.s;
|
||||||
|
cell *tgt = mi.t;
|
||||||
if(among(thumper->wall, waRichDie, waHappyDie) && ctof(tgt))
|
if(among(thumper->wall, waRichDie, waHappyDie) && ctof(tgt))
|
||||||
return false;
|
return false;
|
||||||
if(tgt->wall == waBoat || tgt->wall == waStrandedBoat) return false;
|
if(tgt->wall == waBoat || tgt->wall == waStrandedBoat) return false;
|
||||||
|
@ -935,17 +935,19 @@ movei determinePush(cellwalker who, int subdir, const T& valid) {
|
|||||||
auto rd = reverse_directions(push.at, push.spin);
|
auto rd = reverse_directions(push.at, push.spin);
|
||||||
for(int i: rd) {
|
for(int i: rd) {
|
||||||
push.spin = i;
|
push.spin = i;
|
||||||
if(valid(push.cpeek())) return movei(push.at, push.spin);
|
movei mi = movei(push.at, i);
|
||||||
|
if(valid(mi)) return mi;
|
||||||
}
|
}
|
||||||
return movei(c2, NO_SPACE);
|
return movei(c2, NO_SPACE);
|
||||||
}
|
}
|
||||||
int pd = push.at->type/2;
|
int pd = push.at->type/2;
|
||||||
push += pd * -subdir;
|
push += pd * -subdir;
|
||||||
|
movei mi(push.at, push.spin);
|
||||||
push += wstep;
|
push += wstep;
|
||||||
if(valid(push.at)) return movei(c2, (push+wstep).spin);
|
if(valid(mi)) return mi;
|
||||||
if(c2->type&1) {
|
if(c2->type&1) {
|
||||||
push = push + wstep - subdir + wstep;
|
push = push + wstep - subdir + wstep;
|
||||||
if(valid(push.at)) return movei(c2, (push+wstep).spin);
|
if(valid(mi)) return mi;
|
||||||
}
|
}
|
||||||
if(gravityLevelDiff(push.at, c2) < 0) {
|
if(gravityLevelDiff(push.at, c2) < 0) {
|
||||||
push = push + wstep + 1 + wstep;
|
push = push + wstep + 1 + wstep;
|
||||||
@ -955,7 +957,8 @@ movei determinePush(cellwalker who, int subdir, const T& valid) {
|
|||||||
if(gravityLevelDiff(push.at, c2) < 0) {
|
if(gravityLevelDiff(push.at, c2) < 0) {
|
||||||
push = push + wstep + 1 + wstep;
|
push = push + wstep + 1 + wstep;
|
||||||
}
|
}
|
||||||
if(valid(push.at)) return movei(c2, (push+wstep).spin);
|
movei mi = movei(c2, (push+wstep).spin);
|
||||||
|
if(valid(mi)) return mi;
|
||||||
}
|
}
|
||||||
return movei(c2, NO_SPACE);
|
return movei(c2, NO_SPACE);
|
||||||
}
|
}
|
||||||
|
@ -655,7 +655,7 @@ EX void beastAttack(cell *c, bool player, bool targetdir) {
|
|||||||
if(c2->monst && c2->stuntime) {
|
if(c2->monst && c2->stuntime) {
|
||||||
cellwalker bull (c, d);
|
cellwalker bull (c, d);
|
||||||
int subdir = determinizeBullPush(bull);
|
int subdir = determinizeBullPush(bull);
|
||||||
auto mi = determinePush(bull, subdir, [c2] (cell *c) { return passable(c, c2, P_BLOW); });
|
auto mi = determinePush(bull, subdir, [c2] (movei mi) { return passable(mi.t, c2, P_BLOW); });
|
||||||
if(mi.proper())
|
if(mi.proper())
|
||||||
pushMonster(mi);
|
pushMonster(mi);
|
||||||
}
|
}
|
||||||
@ -672,7 +672,7 @@ EX void beastAttack(cell *c, bool player, bool targetdir) {
|
|||||||
if(c2->wall == waThumperOn) {
|
if(c2->wall == waThumperOn) {
|
||||||
cellwalker bull (c, d);
|
cellwalker bull (c, d);
|
||||||
int subdir = determinizeBullPush(bull);
|
int subdir = determinizeBullPush(bull);
|
||||||
auto mi = determinePush(bull, subdir, [c2] (cell *c) { return canPushThumperOn(c, c2, c); });
|
auto mi = determinePush(bull, subdir, [c, c2] (movei mi) { return canPushThumperOn(mi, c); });
|
||||||
if(mi.proper())
|
if(mi.proper())
|
||||||
pushThumper(mi);
|
pushThumper(mi);
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ bool pcmove::actual_move() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(c2->monst == moAnimatedDie) {
|
if(c2->monst == moAnimatedDie) {
|
||||||
mip = determinePush(cwt, subdir, [c2] (cell *c) { return canPushThumperOn(c, c2, cwt.at); });
|
mip = determinePush(cwt, subdir, [c2] (movei mi) { return canPushThumperOn(mi, cwt.at); });
|
||||||
if(mip.proper()) {
|
if(mip.proper()) {
|
||||||
auto tgt = roll_effect(mip, dice::data[c2]);
|
auto tgt = roll_effect(mip, dice::data[c2]);
|
||||||
if(tgt.happy() > 0) {
|
if(tgt.happy() > 0) {
|
||||||
@ -642,7 +642,7 @@ bool pcmove::actual_move() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(isPushable(c2->wall) && !c2->monst && !nonAdjacentPlayer(c2, cwt.at) && fmsMove) {
|
if(isPushable(c2->wall) && !c2->monst && !nonAdjacentPlayer(c2, cwt.at) && fmsMove) {
|
||||||
mip = determinePush(cwt, subdir, [c2] (cell *c) { return canPushThumperOn(c, c2, cwt.at); });
|
mip = determinePush(cwt, subdir, [c2] (movei mi) { return canPushThumperOn(mi, cwt.at); });
|
||||||
if(mip.t) changes.ccell(mip.t);
|
if(mip.t) changes.ccell(mip.t);
|
||||||
if(mip.d == NO_SPACE) {
|
if(mip.d == NO_SPACE) {
|
||||||
if(vmsg(miWALL)) addMessage(XLAT("No room to push %the1.", c2->wall));
|
if(vmsg(miWALL)) addMessage(XLAT("No room to push %the1.", c2->wall));
|
||||||
@ -978,7 +978,7 @@ bool pcmove::attack() {
|
|||||||
|
|
||||||
if(items[itCurseWeakness] || (isStunnable(c2->monst) && c2->hitpoints > 1)) {
|
if(items[itCurseWeakness] || (isStunnable(c2->monst) && c2->hitpoints > 1)) {
|
||||||
if(monsterPushable(c2))
|
if(monsterPushable(c2))
|
||||||
mip = determinePush(cwt, subdir, [c2] (cell *c) { return passable(c, c2, P_BLOW); });
|
mip = determinePush(cwt, subdir, [c2] (movei mi) { return passable(mi.t, mi.s, P_BLOW); });
|
||||||
else
|
else
|
||||||
mip.t = c2;
|
mip.t = c2;
|
||||||
if(mip.t) changes.ccell(mip.t);
|
if(mip.t) changes.ccell(mip.t);
|
||||||
|
@ -1123,7 +1123,7 @@ void movePlayer(monster *m, int delta) {
|
|||||||
if(d<bestd) bestd=d, subdir = di;
|
if(d<bestd) bestd=d, subdir = di;
|
||||||
}
|
}
|
||||||
pushmonsters();
|
pushmonsters();
|
||||||
auto mip = determinePush(cellwalker(c2, sd1)+wstep, subdir, [m, c2] (cell *c) { return canPushThumperOn(c, c2, m->base); });
|
auto mip = determinePush(cellwalker(c2, sd1)+wstep, subdir, [m, c2] (movei mi) { return canPushThumperOn(mi, m->base); });
|
||||||
visibleFor(300);
|
visibleFor(300);
|
||||||
if(!mip.proper()) go = false;
|
if(!mip.proper()) go = false;
|
||||||
else pushThumper(mip);
|
else pushThumper(mip);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user