From 6482a6dab4fdad99dff8a2f0b1106f2fef608c95 Mon Sep 17 00:00:00 2001 From: Jared Tinney (Twinge) Date: Tue, 9 Feb 2010 01:50:34 -0800 Subject: [PATCH] mons.mimic check returns mimic type. place-pop script now groups mimics, dancing weapons, and very ugly things properly. Added sort by count option. --- crawl-ref/source/l_mons.cc | 15 +++++++++++++ crawl-ref/source/scripts/place-population.lua | 29 ++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/crawl-ref/source/l_mons.cc b/crawl-ref/source/l_mons.cc index 721939a..38a28e8 100644 --- a/crawl-ref/source/l_mons.cc +++ b/crawl-ref/source/l_mons.cc @@ -114,7 +115,20 @@ MDEF(mimic) { ASSERT_DLUA; if (mons_genus(mons->type) == MONS_GOLD_MIMIC) - lua_pushstring(ls, "mimic"); + { + if (mons->type == MONS_GOLD_MIMIC) + lua_pushstring(ls, "gold mimic"); + else if (mons->type == MONS_WEAPON_MIMIC) + lua_pushstring(ls, "weapon mimic"); + else if (mons->type == MONS_ARMOUR_MIMIC) + lua_pushstring(ls, "armour mimic"); + else if (mons->type == MONS_POTION_MIMIC) + lua_pushstring(ls, "potion mimic"); + else if (mons->type == MONS_SCROLL_MIMIC) + lua_pushstring(ls, "scroll mimic"); + else + lua_pushstring(ls, "unknown mimic"); + } else lua_pushnil(ls); diff --git a/crawl-ref/source/scripts/place-population.lua b/crawl-ref/source/scripts/place-population.lua index 92f24cf..3137fdd 100644 --- a/crawl-ref/source/scripts/place-population.lua +++ b/crawl-ref/source/scripts/place-population.lua @@ -9,6 +9,7 @@ local start_level = nil local end_level = nil local ignore_uniques = true local group_uniques = false +local sort_type = "XP" local function canonical_name(mons) local shapeshifter = mons.shapeshifter @@ -16,8 +17,22 @@ local function canonical_name(mons) return shapeshifter end + local mimic = mons.mimic + if mimic then + return mimic + end + + local dancing_weapon = mons.dancing_weapon + if dancing_weapon then + return dancing_weapon + end + local mname = mons.name + if string.find(mname, 'very ugly thing$') then + return "very ugly thing" + end + if string.find(mname, 'ugly thing$') then return "ugly thing" end @@ -71,9 +86,14 @@ local function report_monster_counts_at(place, mcount_map) local monster_counts = util.pairs(mcount_map) table.sort(monster_counts, function (a, b) - return a[2].etotal > b[2].etotal - end) - +-- Further sort options can be added later if desired. Default is XP, -sort_count sorts by count/percentage instead. + if sort_type == 'count' then + return a[2].total > b[2].total + else + return a[2].etotal > b[2].etotal + end + end) + local total = 0 for _, monster_pop in ipairs(monster_counts) do if monster_pop[1] ~= 'TOTAL' then @@ -289,6 +309,9 @@ local function branch_resets() if arg == '-groupuniques' then group_uniques = true end + if arg == '-sort_count' then + sort_type = "count" + end local _, _, optiters = string.find(arg, "^-n=(%d+)") if optiters then niters = tonumber(optiters) -- 1.6.5.1