summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/command.cc18
-rw-r--r--crawl-ref/source/mon-pick.cc143
-rw-r--r--crawl-ref/source/mon-pick.h1
3 files changed, 152 insertions, 10 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index fba34c036e..9b9411a270 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -700,9 +700,8 @@ static bool compare_mon_names(MenuEntry *entry_a, MenuEntry* entry_b)
return ( lowercase(a_name) < lowercase(b_name));
}
-// Compare monsters by level if there's a place where they both have a
-// level defined, or by hitdice otherwise. If monsters are of equal
-// toughness, compare names.
+// Compare monsters by location-independant level, or by hitdice if
+// levels are equal, or by name if both level and hitdice are equal.
static bool compare_mon_toughness(MenuEntry *entry_a, MenuEntry* entry_b)
{
int a = (int) entry_a->data;
@@ -711,12 +710,10 @@ static bool compare_mon_toughness(MenuEntry *entry_a, MenuEntry* entry_b)
if (a == b)
return false;
- int a_toughness = (*mons_standard_level)(a);
- int b_toughness = (*mons_standard_level)(b);
+ int a_toughness = mons_global_level(a);
+ int b_toughness = mons_global_level(b);
- if (a_toughness < 1 || a_toughness >= 99
- || b_toughness < 1 || b_toughness >= 99
- || a_toughness == b_toughness)
+ if (a_toughness == b_toughness)
{
a_toughness = mons_type_hit_dice(a);
b_toughness = mons_type_hit_dice(b);
@@ -830,7 +827,7 @@ static std::vector<std::string> get_monster_keys(unsigned char showchar)
for (int i = 0; i < NUM_MONSTERS; i++)
{
- if (i == MONS_PROGRAM_BUG)
+ if (i == MONS_PROGRAM_BUG || mons_global_level(i) == 0)
continue;
monsterentry *me = get_monster_data(i);
@@ -853,7 +850,8 @@ static std::vector<std::string> get_monster_keys(unsigned char showchar)
static bool monster_filter(std::string key, std::string body)
{
- return (get_monster_by_name(key.c_str(), true) == MONS_PROGRAM_BUG);
+ int mon_num = get_monster_by_name(key.c_str(), true);
+ return (mon_num == MONS_PROGRAM_BUG || mons_global_level(mon_num) == 0);
}
static bool spell_filter(std::string key, std::string body)
diff --git a/crawl-ref/source/mon-pick.cc b/crawl-ref/source/mon-pick.cc
index 9c8e17620a..cf4f03fcd4 100644
--- a/crawl-ref/source/mon-pick.cc
+++ b/crawl-ref/source/mon-pick.cc
@@ -17,6 +17,7 @@
#include "externs.h"
#include "branch.h"
#include "misc.h"
+#include "mon-util.h"
#include "place.h"
// NB - When adding new branches or levels above 50, you must
@@ -35,6 +36,134 @@ int mons_level(int mcls, const level_id &place)
return monster_level;
}
+typedef int (*mons_level_function)(int);
+
+struct global_level_info
+{
+ mons_level_function level_func;
+ branch_type branch;
+ int avg_depth;
+};
+
+static int mons_misc_level(int mcls)
+{
+ switch(mons_char(mcls))
+ {
+ case '&':
+ return 35;
+
+ case '1':
+ return 30;
+
+ case '2':
+ return 25;
+
+ case '3':
+ return 20;
+
+ case '4':
+ return 15;
+
+ case '5':
+ return 10;
+ }
+
+ if (mons_is_unique(mcls))
+ return (mons_type_hit_dice(mcls) * 14 / 10 + 1);
+
+ switch(mcls)
+ {
+ case MONS_HUMAN:
+ case MONS_ELF:
+ return 1;
+
+ case MONS_BIG_FISH:
+ case MONS_GIANT_GOLDFISH:
+ case MONS_JELLYFISH:
+ return 8;
+
+ case MONS_ANT_LARVA:
+ return 10;
+
+ case MONS_ELECTRICAL_EEL:
+ case MONS_LAVA_FISH:
+ case MONS_LAVA_SNAKE:
+ case MONS_LAVA_WORM:
+ case MONS_SALAMANDER:
+ case MONS_HOG:
+ return 14;
+
+ case MONS_FIRE_VORTEX:
+ return 18;
+
+ case MONS_MINOTAUR:
+ case MONS_BALL_LIGHTNING:
+ case MONS_ORANGE_STATUE:
+ case MONS_SILVER_STATUE:
+ case MONS_ICE_STATUE:
+ case MONS_SPATIAL_VORTEX:
+ case MONS_MOLTEN_GARGOYLE:
+ case MONS_WATER_ELEMENTAL:
+ return 20;
+
+ case MONS_METAL_GARGOYLE:
+ case MONS_VAULT_GUARD:
+ return 24;
+
+ case MONS_QUEEN_ANT:
+ return 25;
+
+ case MONS_ANGEL:
+ return 27;
+
+ case MONS_DAEVA:
+ return 28;
+ }
+
+ return 0;
+}
+
+static global_level_info g_lev_infos[] = {
+ {mons_standard_level, BRANCH_MAIN_DUNGEON, 1},
+ {mons_misc_level, BRANCH_MAIN_DUNGEON, 1},
+ {mons_mineorc_level, BRANCH_ORCISH_MINES, 8},
+ {mons_lair_level, BRANCH_LAIR, 10},
+ {mons_hallelf_level, BRANCH_ELVEN_HALLS, 11},
+ {mons_swamp_level, BRANCH_SWAMP, 14},
+ {mons_shoals_level, BRANCH_SHOALS, 14},
+ {mons_pitsnake_level, BRANCH_SNAKE_PIT, 15},
+ {mons_pitslime_level, BRANCH_SLIME_PITS, 16},
+ {mons_crypt_level, BRANCH_CRYPT, 19},
+ {mons_tomb_level, BRANCH_TOMB, 21},
+ {mons_hallzot_level, BRANCH_HALL_OF_ZOT, 27},
+ {mons_dis_level, BRANCH_DIS, 29},
+ {mons_gehenna_level, BRANCH_GEHENNA, 29},
+ {mons_cocytus_level, BRANCH_COCYTUS, 29},
+ {mons_tartarus_level, BRANCH_TARTARUS, 29},
+
+ {NULL, NUM_BRANCHES, 0}
+};
+
+int mons_global_level(int mcls)
+{
+ for (int i = 0; g_lev_infos[i].level_func != NULL; i++)
+ {
+ int level = (*g_lev_infos[i].level_func)(mcls);
+ int rel_level = level - absdungeon_depth(g_lev_infos[i].branch, 1);
+
+ if (g_lev_infos[i].branch == BRANCH_HALL_OF_ZOT)
+ rel_level++;
+
+ if (level >= 1 && level < 99 && rel_level != 0)
+ {
+ level = rel_level + g_lev_infos[i].avg_depth - 1;
+ return (level);
+ }
+ }
+
+ return (0);
+}
+
// higher values returned means the monster is "more common"
// a return value of zero means the monster will never appear {dlb}
int mons_rarity(int mcls, const level_id &place)
@@ -1423,6 +1552,9 @@ int mons_pitslime_level(int mcls)
mlev += 5;
break;
+ case MONS_ROYAL_JELLY:
+ mlev += 6;
+
default:
mlev += 0;
break;
@@ -1525,6 +1657,7 @@ int mons_crypt_level(int mcls)
case MONS_REAPER:
case MONS_ANCIENT_LICH:
case MONS_LICH:
+ case MONS_CURSE_SKULL:
mlev += 5;
break;
@@ -1836,6 +1969,10 @@ int mons_tomb_level(int mcls)
mlev += 3;
break;
+ case MONS_GREATER_MUMMY:
+ mlev += 4;
+ break;
+
default:
mlev += 99;
}
@@ -1974,6 +2111,7 @@ int mons_swamp_level(int mcls)
case MONS_RAT:
case MONS_SWAMP_DRAKE:
case MONS_WORM:
+ case MONS_SWAMP_WORM:
mlev++;
break;
@@ -2140,6 +2278,7 @@ int mons_hallzot_level(int mcls)
case MONS_SKELETAL_DRAGON:
case MONS_STORM_DRAGON:
case MONS_CURSE_TOE:
+ case MONS_ORB_GUARDIAN:
mlev += 5;
break;
case MONS_DEATH_COB:
@@ -2526,6 +2665,10 @@ int mons_standard_level(int mcls)
case MONS_TITAN:
return 30;
+ case MONS_DEEP_ELF_BLADEMASTER:
+ case MONS_DEEP_ELF_MASTER_ARCHER:
+ return 33;
+
case MONS_BIG_FISH:
case MONS_ELECTRICAL_EEL:
case MONS_GIANT_GOLDFISH:
diff --git a/crawl-ref/source/mon-pick.h b/crawl-ref/source/mon-pick.h
index 1f8bac453c..aefaec9204 100644
--- a/crawl-ref/source/mon-pick.h
+++ b/crawl-ref/source/mon-pick.h
@@ -27,6 +27,7 @@ int mons_rarity(int mcls, const level_id &place = level_id::current());
* *********************************************************************** */
int mons_level(int mcls, const level_id &place = level_id::current());
+int mons_global_level(int mcls);
// last updated 12may2000 {dlb}
/* ***********************************************************************