diff options
author | Pete Hurst <pete@streamuniverse.tv> | 2013-05-29 22:20:41 +0100 |
---|---|---|
committer | Pete Hurst <pete@streamuniverse.tv> | 2013-06-21 18:26:13 +0100 |
commit | caba246645aa69161dafcabe6111ec341383e54d (patch) | |
tree | 9f79344f0295a8b02cc5a7fa0b305309490db2cb /crawl-ref/source/mon-pick.h | |
parent | 6f4e5b9996c5fd8ef5e1ef43ee8ec3fb40af18ef (diff) | |
download | crawl-ref-caba246645aa69161dafcabe6111ec341383e54d.tar.gz crawl-ref-caba246645aa69161dafcabe6111ec341383e54d.zip |
Allow mon-pick to be used with arbitrary pop_entry lists
The pick_monster_from function can now be called with a pop_entry
table and a depth to allow reuse of the mon-pick algorithm
in other situations (e.g. spawn lists for summoning effects).
Diffstat (limited to 'crawl-ref/source/mon-pick.h')
-rw-r--r-- | crawl-ref/source/mon-pick.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crawl-ref/source/mon-pick.h b/crawl-ref/source/mon-pick.h index 55383463d5..47ddce1755 100644 --- a/crawl-ref/source/mon-pick.h +++ b/crawl-ref/source/mon-pick.h @@ -11,12 +11,32 @@ #define DEPTH_NOWHERE 999 +enum distrib_type +{ + FLAT, // full chance throughout the range + SEMI, // 50% chance at range ends, 100% in the middle + PEAK, // 0% chance just outside range ends, 100% in the middle, range + // ends typically get ~20% or more + UP, // linearly from near-zero to 100%, increasing with depth + DOWN, // linearly from 100% at the start to near-zero +}; + +typedef struct +{ + int minr; + int maxr; + int rarity; // 0..1000 + distrib_type distrib; + monster_type mons; +} pop_entry; + typedef bool (*mon_pick_vetoer)(monster_type); int mons_rarity(monster_type mcls, branch_type branch); int mons_depth(monster_type mcls, branch_type branch); monster_type pick_monster(level_id place, mon_pick_vetoer veto = nullptr); +monster_type pick_monster_from(const pop_entry *fpop, int depth, mon_pick_vetoer veto = nullptr); monster_type pick_monster_no_rarity(branch_type branch); monster_type pick_monster_by_hash(branch_type branch, uint32_t hash); monster_type pick_monster_all_branches(int absdepth0, mon_pick_vetoer veto = nullptr); |