diff options
author | DracoOmega <draco_omega@live.com> | 2013-03-09 03:01:25 -0330 |
---|---|---|
committer | DracoOmega <draco_omega@live.com> | 2013-03-09 14:38:06 -0330 |
commit | 3eaf7e59e043fa7391e1caf0cc4376f516c5edc8 (patch) | |
tree | 4ffd5b23d24737aa30ce52a6e66451b5bc62fc3c /crawl-ref/source/mon-transit.cc | |
parent | 365bd5147c3c3036501a515cd024c3c0e5a0261d (diff) | |
download | crawl-ref-3eaf7e59e043fa7391e1caf0cc4376f516c5edc8.tar.gz crawl-ref-3eaf7e59e043fa7391e1caf0cc4376f516c5edc8.zip |
Apply dactions to transiting monsters, refactor related code
Dactions which affect monsters (such as abandoning or joining certain
gods, enslaving new souls, killing Pikel) now apply not only to
monsters currently on a level, but monsters that have yet to transit
to a level (eg: fell down a shaft or were banished, but the player
has not yet visited their destination).
Previously, it was possible to visit the Abyss and find (say)
still-friendly undead slaves there after abandoning Yred in the
meantime. This also fixes the unfortunate case of shafted Pikel slave
not getting the news about their cruel slavemaster's death.
Diffstat (limited to 'crawl-ref/source/mon-transit.cc')
-rw-r--r-- | crawl-ref/source/mon-transit.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/crawl-ref/source/mon-transit.cc b/crawl-ref/source/mon-transit.cc index e04eec7805..708deae8a9 100644 --- a/crawl-ref/source/mon-transit.cc +++ b/crawl-ref/source/mon-transit.cc @@ -12,6 +12,7 @@ #include "artefact.h" #include "coord.h" #include "coordit.h" +#include "dactions.h" #include "dungeon.h" #include "env.h" #include "godcompanions.h" @@ -244,6 +245,39 @@ void place_transiting_items() ilist = keep; } +void apply_daction_to_transit(daction_type act) +{ + for (monsters_in_transit::iterator i = the_lost_ones.begin(); + i != the_lost_ones.end(); ++i) + { + m_transit_list* m = &i->second; + for (m_transit_list::iterator j = m->begin(); j != m->end(); ++j) + { + monster* mon = &j->mons; + if (mons_matches_daction(mon, act)) + apply_daction_to_mons(mon, act, false); + } + } +} + +int count_daction_in_transit(daction_type act) +{ + int count = 0; + for (monsters_in_transit::iterator i = the_lost_ones.begin(); + i != the_lost_ones.end(); ++i) + { + m_transit_list* m = &i->second; + for (m_transit_list::iterator j = m->begin(); j != m->end(); ++j) + { + monster* mon = &j->mons; + if (mons_matches_daction(mon, act)) + count++; + } + } + + return count; +} + ////////////////////////////////////////////////////////////////////////// // follower |