diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-03-13 20:24:52 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-03-13 20:24:52 +0000 |
commit | 05778102b466f438185552dfb314423635fdf8a6 (patch) | |
tree | a107d01fb0a63a3e39656417539b2633527d1bbf /crawl-ref/source/misc.cc | |
parent | 888862b18bb90bc415fc308809e73111881b78fa (diff) | |
download | crawl-ref-05778102b466f438185552dfb314423635fdf8a6.tar.gz crawl-ref-05778102b466f438185552dfb314423635fdf8a6.zip |
Fix for 1661786: autoprayer now works with run delays.
Perhaps we should a note to the docs mentioning the possibility
of setting runrest_ignore_message appropriately to make it
work well with autoprayer.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1032 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/misc.cc')
-rw-r--r-- | crawl-ref/source/misc.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 8e0845748b..f545c5184f 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -53,6 +53,7 @@ #include "ouch.h" #include "overmap.h" #include "player.h" +#include "religion.h" #include "shopping.h" #include "skills.h" #include "skills2.h" @@ -2199,3 +2200,44 @@ int str_to_shoptype(const std::string &s) } return (-1); } + +/* Decides whether autoprayer Right Now is a good idea. */ +static bool should_autopray() +{ + if ( Options.autoprayer_on == false || + you.religion == GOD_NO_GOD || + you.duration[DUR_PRAYER] || + grid_altar_god( grd[you.x_pos][you.y_pos] ) != GOD_NO_GOD || + !i_feel_safe() ) + return false; + + // We already know that we're not praying now. So if you + // just autoprayed, there's a problem. + if ( you.just_autoprayed ) + { + mpr("Autoprayer failed, deactivating.", MSGCH_WARN); + Options.autoprayer_on = false; + return false; + } + + return true; +} + +/* Actually performs autoprayer. */ +bool do_autopray() +{ + if ( you.turn_is_over ) // can happen with autopickup, I think + return false; + + if ( should_autopray() ) + { + pray(); + you.just_autoprayed = true; + return true; + } + else + { + you.just_autoprayed = false; + return false; + } +} |