diff options
author | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2009-10-18 18:09:22 +0530 |
---|---|---|
committer | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2009-10-18 18:17:47 +0530 |
commit | 20499e4d29a0af3143ca2aaa163390d97c04c258 (patch) | |
tree | 4506fe40fa455e02bc8ba0dbcf1175e675e5a374 /crawl-ref/source/monstuff.cc | |
parent | ebf9ea59c9613529a05e9e8a1b74a5d2d388195b (diff) | |
download | crawl-ref-20499e4d29a0af3143ca2aaa163390d97c04c258.tar.gz crawl-ref-20499e4d29a0af3143ca2aaa163390d97c04c258.zip |
Add test for monster placement.
Adds test/monplace.lua to test placing monsters using the Lua direct monster creation binding (does not exercise all the map code).
Allow choosing what tests to run with "crawl -test test1,test2".
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r-- | crawl-ref/source/monstuff.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 4a90029b39..a63b23d233 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -9775,3 +9775,52 @@ bool shift_monster(monsters *mon, coord_def p) return (count > 0); } + +// Make all of the monster's original equipment disappear, unless it's a fixed +// artefact or unrand artefact. +static void _vanish_orig_eq(monsters* mons) +{ + for (int i = 0; i < NUM_MONSTER_SLOTS; ++i) + { + if (mons->inv[i] == NON_ITEM) + continue; + + item_def &item(mitm[mons->inv[i]]); + + if (!is_valid_item(item)) + continue; + + if (item.orig_place != 0 || item.orig_monnum != 0 + || !item.inscription.empty() + || is_unrandom_artefact(item) + || (item.flags & (ISFLAG_DROPPED | ISFLAG_THROWN | ISFLAG_NOTED_GET + | ISFLAG_BEEN_IN_INV) ) ) + { + continue; + } + item.flags |= ISFLAG_SUMMONED; + } +} + +int dismiss_monsters(std::string pattern) { + // Make all of the monsters' original equipment disappear unless "keepitem" + // is found in the regex (except for fixed arts and unrand arts). + const bool keep_item = strip_tag(pattern, "keepitem"); + + // Dismiss by regex + text_pattern tpat(pattern); + int ndismissed = 0; + for (int mon = 0; mon < MAX_MONSTERS; mon++) + { + monsters *monster = &menv[mon]; + if (monster->alive() && + (tpat.empty() || tpat.matches(monster->name(DESC_PLAIN, true)))) + { + if (!keep_item) + _vanish_orig_eq(monster); + monster_die(monster, KILL_DISMISSED, NON_MONSTER, false, true); + ++ndismissed; + } + } + return (ndismissed); +} |