diff options
author | DracoOmega <draco_omega@live.com> | 2013-02-13 12:58:09 -0330 |
---|---|---|
committer | DracoOmega <draco_omega@live.com> | 2013-03-03 18:36:47 -0330 |
commit | 1bd74f58a62e72d0ffebc7184334b0d6b5a7fdac (patch) | |
tree | 69ef1e05b7317e393306061659d81b411095ad43 /crawl-ref/source/godcompanions.cc | |
parent | 82ac2224c72061ef69f27ba69f7f69326b850989 (diff) | |
download | crawl-ref-1bd74f58a62e72d0ffebc7184334b0d6b5a7fdac.tar.gz crawl-ref-1bd74f58a62e72d0ffebc7184334b0d6b5a7fdac.zip |
Interlevel recall for Yred and Beogh
Allow the god-given recall abilities for Yred and Beogh to recall
all god-associated permenant allies, regardless of where in the dungeon
they reside. (Note that this only includes Yred gifts and not zombies;
ie: things that could already follow you between levels)
This is done by actively tracking all of these allies in a seperate list
which is updated whenever a tracked ally is gained, dies, changes level,
or the player changes level.
The fact that permanent allies from these gods make interlevel travel
unusable is one of the largest sources of tedium associated with those gods,
and a major reason for their lack of popularity. Being able to recall from
previous levels means you no longer have to manually herd and count allies
at the top and bottom of every stair, sometimes having to make multiple
trips if the terrain surrounding the stair is too confined. This should
make these gods much more playable (and if their power level is now more
obvious and considered too high, it can be adjusted in other ways than via
tedium)
Diffstat (limited to 'crawl-ref/source/godcompanions.cc')
-rw-r--r-- | crawl-ref/source/godcompanions.cc | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/crawl-ref/source/godcompanions.cc b/crawl-ref/source/godcompanions.cc new file mode 100644 index 0000000000..ab2dd09ae7 --- /dev/null +++ b/crawl-ref/source/godcompanions.cc @@ -0,0 +1,115 @@ +/** + * @file + * @brief Tracking peramallies granted by Yred and Beogh. +**/ + +#include "AppHdr.h" + +#include <algorithm> + +#include "godcompanions.h" + +#include "coord.h" +#include "coordit.h" +#include "actor.h" +#include "mon-stuff.h" +#include "mon-util.h" +#include "religion.h" +#include "stuff.h" + +map<mid_t, companion> companion_list; + +companion::companion(const monster& m) +{ + mons = follower(m); + level = level_id::current(); + timestamp = you.elapsed_time; +} + +void add_companion(monster* mons) +{ + companion_list[mons->mid] = companion(*mons); +} + +void remove_companion(monster* mons) +{ + companion_list.erase(mons->mid); +} + +void remove_all_companions(god_type god) +{ + for(map<mid_t, companion>::iterator i = companion_list.begin(); + i != companion_list.end(); ++i ) + { + monster* mons = monster_by_mid(i->first); + if (!mons) + mons = &i->second.mons.mons; + if ((god == GOD_YREDELEMNUL && is_yred_undead_slave(mons)) + || (god == GOD_BEOGH && mons->wont_attack() && mons_is_god_gift(mons, GOD_BEOGH))) + { + companion_list.erase(i); + } + } +} + +void move_companion_to(const monster* mons, const level_id lid) +{ + companion_list[mons->mid].level = lid; + companion_list[mons->mid].mons = follower(*mons); + companion_list[mons->mid].timestamp = you.elapsed_time; +} + +void update_companions() +{ + for(map<mid_t, companion>::iterator i = companion_list.begin(); + i != companion_list.end(); ++i ) + { + monster* mons = monster_by_mid(i->first); + if (mons) + { + if (mons->is_divine_companion()) + { + i->second.mons = follower(*mons); + i->second.timestamp = you.elapsed_time; + } + else // We must have angered this creature or lost our religion + { + companion_list.erase(i); + } + } + } +} + +bool recall_offlevel_companions() +{ + bool recalled = false; + + for(map<mid_t, companion>::iterator i = companion_list.begin(); + i != companion_list.end(); ++i ) + { + int mid = i->first; + companion* comp = &i->second; + if (comp->level != level_id::current()) + { + if (comp->mons.place(true)) + { + // The monster is now on this level + remove_monster_from_transit(comp->level, mid); + comp->level = level_id::current(); + simple_monster_message(monster_by_mid(mid), " is recalled."); + recalled = true; + } + } + } + + return recalled; +} + +bool companion_is_elsewhere(const monster* mons) +{ + if (companion_list.find(mons->mid) != companion_list.end()) + { + return (companion_list[mons->mid].level != level_id::current()); + } + return false; +}
\ No newline at end of file |