determinePush now accepts movei instead of c

This commit is contained in:
Zeno Rogue 2021-05-29 15:44:07 +02:00
parent b0333a6ab7
commit d7e2b491ac
5 changed files with 16 additions and 11 deletions

View File

@ -402,7 +402,9 @@ EX void pushThumper(const movei& mi) {
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))
return false;
if(tgt->wall == waBoat || tgt->wall == waStrandedBoat) return false;

View File

@ -935,17 +935,19 @@ movei determinePush(cellwalker who, int subdir, const T& valid) {
auto rd = reverse_directions(push.at, push.spin);
for(int i: rd) {
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);
}
int pd = push.at->type/2;
push += pd * -subdir;
movei mi(push.at, push.spin);
push += wstep;
if(valid(push.at)) return movei(c2, (push+wstep).spin);
if(valid(mi)) return mi;
if(c2->type&1) {
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) {
push = push + wstep + 1 + wstep;
@ -955,7 +957,8 @@ movei determinePush(cellwalker who, int subdir, const T& valid) {
if(gravityLevelDiff(push.at, c2) < 0) {
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);
}

View File

@ -655,7 +655,7 @@ EX void beastAttack(cell *c, bool player, bool targetdir) {
if(c2->monst && c2->stuntime) {
cellwalker bull (c, d);
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())
pushMonster(mi);
}
@ -672,7 +672,7 @@ EX void beastAttack(cell *c, bool player, bool targetdir) {
if(c2->wall == waThumperOn) {
cellwalker bull (c, d);
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())
pushThumper(mi);
}

View File

@ -630,7 +630,7 @@ bool pcmove::actual_move() {
}
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()) {
auto tgt = roll_effect(mip, dice::data[c2]);
if(tgt.happy() > 0) {
@ -642,7 +642,7 @@ bool pcmove::actual_move() {
}
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.d == NO_SPACE) {
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(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
mip.t = c2;
if(mip.t) changes.ccell(mip.t);

View File

@ -1123,7 +1123,7 @@ void movePlayer(monster *m, int delta) {
if(d<bestd) bestd=d, subdir = di;
}
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);
if(!mip.proper()) go = false;
else pushThumper(mip);