Added mon-pick related function mons_global_level(), which returns a reasonable level value for monsters independant of the place of the monster, primarily useful for comparing the levels of two monsters which might never show up in the same place (in which case mons_level() is useless).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2186 c06c8d41-db1a-0410-9941-cceddc491573
22QSFI3GQEJGETOKQHXI6JHR5VQV7GUC76VCLZCFYECSTSUIDRBQC
PAYI4UTJCR3XZSFOX5L35EURHRXQ6STO4Z7AQ3525QPNL3QYLNBAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
5UVDIVD4NSXA52U4QMQIVST3GSZJ2A2YZK3RUEXKPM43YVQ7LI5AC
SVY2PTCLXR3KNPQAWXVXTTGCC5DR334HOAKHYO3VDDRWM2BWMALAC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
ZIFFVCQ72K35WGIUMZYN3KOXIUXF2CNXWKG6ZWEZ6LT3NSF3XOQAC
VRFQK6S2TXOFFO5K5HRDXPR7QEKKAZAVCASSIJVPWQ4GE26UOGTQC
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);
}
// 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.