summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/zotdef.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-03-21 05:23:36 +0100
committerAdam Borowski <kilobyte@angband.pl>2013-03-21 05:45:35 +0100
commit34b3b447c5096fe864dc8a9500c1f44706977b3e (patch)
tree2bf8408602a033370e419826d93ada02702a3a90 /crawl-ref/source/zotdef.cc
parentaf4a235e5fc769a5c81a40885c68354630f01905 (diff)
parent6a66c87f159d4a26f1d6d09557ffc61334ca907f (diff)
downloadcrawl-ref-34b3b447c5096fe864dc8a9500c1f44706977b3e.tar.gz
crawl-ref-34b3b447c5096fe864dc8a9500c1f44706977b3e.zip
Merge branch 'mon-pick'
The behaviour should be preserved exactly or almost exactly, only the code changes from totally, utterly unreadable to merely hard to read. Actual differences: * strong OODs in shallow branches would degenerate into picking a monster randomly from the whole branch, now they pick from the bottom level (or so-called OOD cap of Elf:7, Tomb:5, D:31 and Vaults:15). * Zot no longer replaces requests for Zot:5 by Zot:4, and proper hells, $(HELL):4-7 by $(HELL):3. * this means hell monster sets need fixing! * zombie size doesn't affect their spawning * zombie selection obeys the depth passed * which makes zombie sets pretty limited -- needs review/redesign? The new format is: { 9, 19, 826, SEMI, MONS_YAK }, which means: yaks can spawn on D:9-19, with _linear_ rarity 826 in the middle of the range. A "SEMI" distribution means that at the edges, D:9 and D:19, the effective rarity is half that, 413. Distributions: FLAT 100% 100% 100% SEMI 50% 100% 50% PEAK 0% 100% 0% UP 0% 50% 100% DOWN 100% 50% 0% That "0%" doesn't mean the monster won't spawn on the top/bottom level (D:9 and D:19 for yaks), the range is fudged so D:8 receives 0% chance, D:9 16.6%, linearly up to 100% on D:14. Yes, this sounds and is complex, but at least the complexity is not strewn around obscure code anymore, and a number of limitations have been lifted. ZotDef still uses the old code via an emulation layer.
Diffstat (limited to 'crawl-ref/source/zotdef.cc')
-rw-r--r--crawl-ref/source/zotdef.cc42
1 files changed, 20 insertions, 22 deletions
diff --git a/crawl-ref/source/zotdef.cc b/crawl-ref/source/zotdef.cc
index 5729d734f1..1d622606d7 100644
--- a/crawl-ref/source/zotdef.cc
+++ b/crawl-ref/source/zotdef.cc
@@ -43,7 +43,7 @@
static monster_type _pick_unique(int level);
-static int _fuzz_mons_level(int level)
+static int _fuzz_mons_depth(int level)
{
if (level > 1 && one_chance_in(7))
{
@@ -138,17 +138,10 @@ static int _mon_strength(monster_type mon_type)
// Fix for skeletons and zombies
switch (mon_type)
{
- case MONS_SKELETON_SMALL:
- case MONS_ZOMBIE_SMALL:
+ case MONS_SKELETON:
+ case MONS_ZOMBIE:
strength += 3;
break;
- case MONS_SKELETON_LARGE:
- case MONS_ZOMBIE_LARGE:
- strength += 4;
- break;
- case MONS_PANDEMONIUM_LORD: // base init has 4HD (!)
- strength = 30;
- break;
default:
break;
}
@@ -559,19 +552,19 @@ static monster_type _get_zotdef_monster(level_id &place, int power)
monster_type mon_type;
for (int i = 0; i <= 10000; ++i)
{
- int count = 0;
int rarity;
- do
+ if (place.branch == NUM_BRANCHES)
{
- mon_type = static_cast<monster_type>(random2(NUM_MONSTERS));
- count++;
- rarity = (place.branch == NUM_BRANCHES) ? 30 : mons_rarity(mon_type, place);
+ mon_type = static_cast<monster_type>(random2(NUM_MONSTERS - 1) + 1);
+ rarity = 30;
+ }
+ else
+ {
+ mon_type = pick_monster_no_rarity(place.branch);
+ rarity = mons_rarity(mon_type, place.branch);
+ ASSERT(rarity > 0);
}
- while (rarity == 0 && count < 2000);
-
- if (rarity == 0)
- return MONS_PROGRAM_BUG;
// Calculate strength
const monsterentry *mentry = get_monster_data(mon_type);
@@ -595,7 +588,7 @@ static monster_type _get_zotdef_monster(level_id &place, int power)
// get default level
int lev_mons = (place.branch == NUM_BRANCHES)
? ((strength * 3) / 2)
- : mons_level(mon_type, place)
+ : mons_depth(mon_type, place.branch)
+ absdungeon_depth(place.branch, 0);
// if >50, bail out - these are special flags
@@ -656,7 +649,7 @@ static void _zotdef_set_random_branch_wave(int power)
for (int i = 0; i < NSLOTS; i++)
{
level_id l(_zotdef_random_branch(), -1);
- env.mons_alloc[i] = _get_zotdef_monster(l, _fuzz_mons_level(power));
+ env.mons_alloc[i] = _get_zotdef_monster(l, _fuzz_mons_depth(power));
}
level_id l(_zotdef_random_branch(), -1);
env.mons_alloc[BOSS_SLOT] = _get_zotdef_monster(l,
@@ -671,7 +664,7 @@ static void _zotdef_set_branch_wave(branch_type b, int power)
(b == NUM_BRANCHES) ? "RANDOM" : branches[b].shortname);
wave_name(buf);
for (int i = 0; i < NSLOTS; i++)
- env.mons_alloc[i] = _get_zotdef_monster(l, _fuzz_mons_level(power));
+ env.mons_alloc[i] = _get_zotdef_monster(l, _fuzz_mons_depth(power));
env.mons_alloc[BOSS_SLOT] = _get_zotdef_monster(l,
power + ZOTDEF_BOSS_EXTRA_POWER);
}
@@ -792,6 +785,11 @@ monster* zotdef_spawn(bool boss)
mg.proximity = PROX_NEAR_STAIRS;
mg.flags |= MG_PERMIT_BANDS;
+ // Hack: emulate old mg.power
+ mg.place = level_id(BRANCH_MAIN_DUNGEON, you.num_turns / (ZOTDEF_CYCLE_LENGTH * 3) + 1);
+ // but only for item generation/etc, not for actual monster selection.
+ ASSERT(mt != RANDOM_MONSTER);
+
monster *mon = mons_place(mg);
// Boss monsters which aren't uniques are named, and beefed a bit further