From e45fb6bb20ced3777ab8f42819f1065bd70b6901 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 27 Feb 2018 23:43:21 +0100 Subject: [PATCH] added dragon dismounting easier --- flags.cpp | 17 +++++++++++----- game.cpp | 58 ++++++++++++++++++++++++++---------------------------- hyper.h | 2 ++ system.cpp | 1 + 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/flags.cpp b/flags.cpp index 54524b5b..ea851a64 100644 --- a/flags.cpp +++ b/flags.cpp @@ -137,13 +137,20 @@ bool isFriendlyOrPlayer(eMonster m) { return isFriendly(m) || m == moPlayer; } -bool isFriendly(cell *c) { - if(items[itOrbDomination] && c->monst && c->monst != moTentacleGhost) { - for(int i=0; imonst && c->monst != moTentacleGhost) { + for(int i=0; imonst && sameMonster(c, playerpos(i))) return true; + if(lastmountpos[i] && lastmountpos[i]->monst && sameMonster(c, lastmountpos[i])) + return true; + } } - return isFriendly(c->monst); + return false; + } + +bool isFriendly(cell *c) { + return isMounted(c) || isFriendly(c->monst); } bool isBug(eMonster m) { diff --git a/game.cpp b/game.cpp index a6d959d5..d712b3aa 100644 --- a/game.cpp +++ b/game.cpp @@ -482,7 +482,7 @@ bool passable(cell *w, cell *from, flagtype flags) { if(w == pp && F(P_ONPLAYER)) return true; if(from == pp && F(P_ONPLAYER) && F(P_REVDIR)) return true; - if(from && !((flags & P_ISPLAYER) && getMount(i))) { + if(from && !((flags & P_ISPLAYER) && pp->monst)) { int i = vrevdir ? incline(w, from) : incline(from, w); if(i < -1 && F(P_ROSE)) return false; if((i > 1) && !F(P_JUMP1 | P_JUMP2 | P_BULLET | P_FLYING | P_BLOW | P_CLIMBUP | P_AETHER | P_REPTILE)) @@ -2760,14 +2760,10 @@ void computePathdist(eMonster param) { pathqm.push_back(c); continue; // no paths going through monsters } - for(int i=0; imonst && c != pc && getMount(i) && !isDragon(c->monst) && sameMonster(c, pc)) { - // don't treat the Worm you are riding as passable - pathqm.push_back(c); - continue; - } + if(isMounted(c) && !isPlayerOn(c)) { + // don't treat the Worm you are riding as passable + pathqm.push_back(c); + continue; } if(c->cpdist > 7 && !(c->land == laTrollheim && turncount < c->landparam)) continue; int d = c->pathdist; @@ -2853,7 +2849,8 @@ void bfs() { for(int i=0; imonst == moTentacle || c->monst == moTentaclewait || c->monst == moTentacleEscaping)) + if(items[itOrbDomination]) + if(c->monst == moTentacle || c->monst == moTentaclewait || c->monst == moTentacleEscaping) worms.push_back(c); } @@ -4131,18 +4128,23 @@ void mountmove(cell *c, int spin, bool fp, int id) { } void mountmove(cell *c, int spin, bool fp, cell *ppos) { - for(int i=0; imonst == moWormwait) { c->monst = moWorm; return; } else if(c->monst == moTentaclewait) { c->monst = moTentacle; return; } @@ -4395,13 +4397,6 @@ bool earthMove(cell *from, int dir) { vector gendfs; -bool isMounted(cell *c) { - for(int i=0; i 1) + lastmountpos[multi::cpid] = cwt.c; + else + lastmountpos[0] = cwt.c; + if(againstRose(cwt.c, NULL) && d<0 && !scentResistant()) { if(checkonly) return false; addMessage("You just cannot stand in place, those roses smell too nicely."); @@ -7922,6 +7924,7 @@ int wormpos(cell *c) { // currently works for worms only bool sameMonster(cell *c1, cell *c2) { + if(!c1 || !c2) return false; if(c1 == c2) return true; if(isWorm(c1->monst) && isWorm(c2->monst)) return wormhead(c1) == wormhead(c2); @@ -7930,14 +7933,9 @@ bool sameMonster(cell *c1, cell *c2) { return false; } -eMonster getMount(int i) { - if(!items[itOrbDomination]) return moNone; - return playerpos(i)->monst; - } - eMonster haveMount() { for(int i=0; imonst; if(m) return m; } return moNone; diff --git a/hyper.h b/hyper.h index 13195bfe..e9b1dcd3 100644 --- a/hyper.h +++ b/hyper.h @@ -2673,3 +2673,5 @@ extern bool nohud, nofps; template array make_array(T a, T b, T c) { array x; x[0] = a; x[1] = b; x[2] = c; return x; } template array make_array(T a, T b) { array x; x[0] = a; x[1] = b; return x; } +extern cell *lastmountpos[MAXPLAYER]; + diff --git a/system.cpp b/system.cpp index 9181f2f4..a1edeceb 100644 --- a/system.cpp +++ b/system.cpp @@ -1199,6 +1199,7 @@ auto cgm = addHook(clearmemory, 40, [] () { pathq.clear(); dcal.clear(); clearshadow(); + for(int i=0; i