From 03dcd5fa175294693aad1ce2ef8d73a1aa14095c Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 29 Feb 2020 03:52:33 +0100 Subject: [PATCH] canReachPlayer now can put frogs --- monstergen.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/monstergen.cpp b/monstergen.cpp index 5baa35bb..a0d2206b 100644 --- a/monstergen.cpp +++ b/monstergen.cpp @@ -253,14 +253,21 @@ EX bool canReachPlayer(cell *cf, eMonster m) { cl.add(cf); for(int i=0; itype; j++) { - cell *c2 = c->move(j); - if(!c2) continue; - if(cl.listed(c2)) continue; - if(!passable_for(m, c2, c, P_MONSTER | P_ONPLAYER | P_CHAIN)) continue; - if(isPlayerOn(c2)) return true; + bool found = false; + + auto test = [&] (cell *c2) { + if(cl.listed(c2)) return; + if(!passable_for(m, c2, c, P_MONSTER | P_ONPLAYER | P_CHAIN)) return; + if(isPlayerOn(c2)) found = true; cl.add(c2); + }; + + forCellEx(c2, c) { + if(among(m, moFrog, moVaulter, moPhaser)) forCellEx(c3, c2) test(c3); + test(c2); } + + if(found) return true; } return false; }