diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-19 18:02:31 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-19 18:02:31 +0000 |
commit | 6e304ee422e24338bde6ca84c420702d7d719993 (patch) | |
tree | 08bee3585e67a17a8b946df063185136cd95d148 /crawl-ref/source/mapdef.cc | |
parent | db54671af1f255d5f886ff79ffe8b2232585f1c3 (diff) | |
download | crawl-ref-6e304ee422e24338bde6ca84c420702d7d719993.tar.gz crawl-ref-6e304ee422e24338bde6ca84c420702d7d719993.zip |
Separate CHANCE and WEIGHT. CHANCE is a probability, WEIGHT is a raw number used as a generation weight (i.e. WEIGHT is what the old CHANCE used to be).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7501 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.cc')
-rw-r--r-- | crawl-ref/source/mapdef.cc | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 3eaea9b11f..fb0b1b6a3a 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -1164,7 +1164,7 @@ dlua_set_map::~dlua_set_map() // map_def::map_def() - : name(), tags(), place(), depths(), orient(), chance(), + : name(), tags(), place(), depths(), orient(), chance(), weight(), welcome_messages(), map(), mons(), items(), keyspecs(), prelude("dlprelude"), main("dlmain"), validate("dlvalidate"), veto("dlveto"), rock_colour(BLACK), floor_colour(BLACK), @@ -1199,8 +1199,26 @@ void map_def::reinit() rock_colour = floor_colour = BLACK; - // Base chance; this is not a percentage. - chance = 10; + // Chance of using this level. Nonzero chance should be used + // sparingly. When selecting vaults for a place, first those + // vaults with chance > 0 are considered, in the order they were + // loaded (which is arbitrary). If random2(100) < chance, the + // vault is picked, and all other vaults are ignored for that + // random selection. weight is ignored if the vault is chosen + // based on its chance. + chance = 0; + + // If multiple alternative vaults have a chance, the order in which + // they're tested is based on chance_priority: higher priority vaults + // are checked first. Vaults with the same priority are tested in + // unspecified order. + chance_priority = 0; + + // Weight for this map. When selecting a map, if no map with a + // nonzero chance is picked, one of the other eligible vaults is + // picked with a probability of weight / (sum of weights of all + // eligible vaults). + weight = 10; // Clearing the map also zaps map transforms. map.clear(); @@ -1296,7 +1314,9 @@ void map_def::write_index(writer& outf) const marshallString4(outf, place_loaded_from.filename); marshallLong(outf, place_loaded_from.lineno); marshallShort(outf, orient); + marshallLong(outf, chance_priority); marshallLong(outf, chance); + marshallLong(outf, weight); marshallLong(outf, cache_offset); marshallString4(outf, tags); place.save(outf); @@ -1310,7 +1330,9 @@ void map_def::read_index(reader& inf) unmarshallString4(inf, place_loaded_from.filename); place_loaded_from.lineno = unmarshallLong(inf); orient = static_cast<map_section_type>( unmarshallShort(inf) ); + chance_priority = unmarshallLong(inf); chance = unmarshallLong(inf); + weight = unmarshallLong(inf); cache_offset = unmarshallLong(inf); unmarshallString4(inf, tags); place.load(inf); @@ -1757,6 +1779,11 @@ bool map_def::has_tag_suffix(const std::string &suffix) const && tags.find(suffix + " ") != std::string::npos; } +std::vector<std::string> map_def::get_tags() const +{ + return split_string(" ", tags); +} + const keyed_mapspec *map_def::mapspec_for_key(int key) const { keyed_specs::const_iterator i = keyspecs.find(key); |