diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index fefad3516a2..70bcd9f7de5 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -2020,15 +2020,11 @@ void direction_chooser::do_redraws() coord_def direction_chooser::find_summoner() { - const monster* mon = monster_at(target()); - - if (mon && mon->is_summoned() - // Don't leak information about rakshasa mirrored illusions. - && !mon->has_ench(ENCH_PHANTOM_MIRROR) - // Don't leak information about invisible or out-of-los summons. - && you.can_see(*mon)) + const auto *mon = monster_at(target()); + if (mon && mon->is_summoned() && you.can_see(*mon)) { - const monster *summ = monster_by_mid(mon->summoner); + monster_info mi(mon); + const monster *summ = monster_by_mid(mi.summoner_id); // Don't leak information about invisible summoners. if (summ && you.can_see(*summ)) return summ->pos(); @@ -2039,8 +2035,7 @@ coord_def direction_chooser::find_summoner() void direction_chooser::highlight_summoner(crawl_view_buffer &vbuf) { const coord_def summ_loc = find_summoner(); - - if (summ_loc == INVALID_COORD || !you.see_cell(summ_loc)) + if (summ_loc == INVALID_COORD) return; auto& cell = vbuf(grid2view(summ_loc) - 1); diff --git a/crawl-ref/source/l-moninf.cc b/crawl-ref/source/l-moninf.cc index 1039a0d943f..7e5d12dc041 100644 --- a/crawl-ref/source/l-moninf.cc +++ b/crawl-ref/source/l-moninf.cc @@ -841,6 +841,32 @@ LUAFN(moninf_get_name) return 1; } +/* + * The x,y coordinates of the monster that summoned this monster, in player + * centered coordinates. If the monster was not summoned by another monster + * that's currently in LOS, return nil. + * @treturn int + * @treturn int + * @function pos + */ +LUAFN(moninf_get_summoner_pos) +{ + MONINF(ls, 1, mi); + + const auto *summoner = monster_by_mid(mi->summoner_id); + if (summoner && you.can_see(*summoner)) + { + lua_pushnumber(ls, summoner->pos().x - you.pos().x); + lua_pushnumber(ls, summoner->pos().y - you.pos().y); + return 2; + } + else + { + lua_pushnil(ls); + return 1; + } +} + static const struct luaL_reg moninf_lib[] = { MIREG(type), @@ -895,6 +921,7 @@ static const struct luaL_reg moninf_lib[] = MIREG(x_pos), MIREG(y_pos), MIREG(pos), + MIREG(summoner_pos), MIREG(avg_local_depth), MIREG(avg_local_prob), diff --git a/crawl-ref/source/mon-info.cc b/crawl-ref/source/mon-info.cc index 6cc51a74c97..41c155da240 100644 --- a/crawl-ref/source/mon-info.cc +++ b/crawl-ref/source/mon-info.cc @@ -391,7 +391,8 @@ monster_info::monster_info(monster_type p_type, monster_type p_base_type) props[MUTANT_BEAST_FACETS].get_vector().push_back(i); } - client_id = 0; + client_id = MID_NOBODY; + summoner_id = MID_NOBODY; } static description_level_type _article_for(const actor* a) @@ -448,17 +449,22 @@ monster_info::monster_info(const monster* m, int milev) _colour = m->colour; + summoner_id = MID_NOBODY; if (m->is_summoned() && !(m->flags & MF_PERSISTS) && (!m->has_ench(ENCH_PHANTOM_MIRROR) || m->friendly())) { mb.set(MB_SUMMONED); + if (m->is_abjurable()) mb.set(MB_ABJURABLE); else mb.set(MB_MINION); + if (m->type == MONS_SPELLFORGED_SERVITOR && m->summoner == MID_PLAYER) mb.set(MB_PLAYER_SERVITOR); + + summoner_id = m->summoner; } else if ((m->is_unrewarding() || testbits(m->flags, MF_NO_REWARD) diff --git a/crawl-ref/source/mon-info.h b/crawl-ref/source/mon-info.h index 923ba528130..a061b0622bb 100644 --- a/crawl-ref/source/mon-info.h +++ b/crawl-ref/source/mon-info.h @@ -296,7 +296,8 @@ struct monster_info_base bool umbraed; int shield_bonus; - uint32_t client_id; + mid_t client_id; + mid_t summoner_id; }; // Monster info used by the pane; precomputes some data