1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-27 18:40:35 +00:00

crossbow:: reverse shoot order

This commit is contained in:
Zeno Rogue 2023-10-29 07:59:44 +01:00
parent 1926fd8434
commit 0c0bf1dd84

View File

@ -275,7 +275,7 @@ EX void shoot() {
if(items[itOrbSlaying]) attackflags |= AF_CRUSH; if(items[itOrbSlaying]) attackflags |= AF_CRUSH;
if(items[itCurseWeakness]) attackflags |= AF_WEAK; if(items[itCurseWeakness]) attackflags |= AF_WEAK;
reverse(bowpath.begin(), bowpath.end()); vector<bowpoint> pushes;
for(auto& mov: bowpath) { for(auto& mov: bowpath) {
cell *c = mov.prev.at; cell *c = mov.prev.at;
@ -309,6 +309,10 @@ EX void shoot() {
continue; continue;
} }
changes.ccell(c); changes.ccell(c);
bool push = (items[itCurseWeakness] || (isStunnable(c->monst) && c->hitpoints > 1));
push = push && (!(mov.flags & bpLAST) && monsterPushable(c));
if(m) attackMonster(c, attackflags | AF_MSG, who); if(m) attackMonster(c, attackflags | AF_MSG, who);
if(!c->monst || isAnyIvy(m)) { if(!c->monst || isAnyIvy(m)) {
@ -316,8 +320,12 @@ EX void shoot() {
produceGhost(c, m, moPlayer); produceGhost(c, m, moPlayer);
} }
if(items[itCurseWeakness] || (isStunnable(c->monst) && c->hitpoints > 1)) { if(push) pushes.push_back(mov);
if(!(mov.flags & bpLAST) && monsterPushable(c)) { }
while(!pushes.empty()) {
auto& mov = pushes.back();
cell *c = mov.prev.at;
cell *ct = mov.next.cpeek(); cell *ct = mov.next.cpeek();
bool can_push = passable(ct, c, P_BLOW); bool can_push = passable(ct, c, P_BLOW);
if(can_push) { if(can_push) {
@ -325,8 +333,7 @@ EX void shoot() {
changes.ccell(ct); changes.ccell(ct);
pushMonster(mov.next); pushMonster(mov.next);
} }
} pushes.pop_back();
}
} }
reverse(bowpath.begin(), bowpath.end()); reverse(bowpath.begin(), bowpath.end());