summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/misc.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-19 03:26:36 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-19 03:26:36 +0000
commit478bb9ee6ad07a89755cd4314a703bfce4f2c395 (patch)
tree6c5f577621308346bd6abc51309131e27e813639 /crawl-ref/source/misc.cc
parent6b01578aea5d2f44172181e9aacd65d068e21a58 (diff)
downloadcrawl-ref-478bb9ee6ad07a89755cd4314a703bfce4f2c395.tar.gz
crawl-ref-478bb9ee6ad07a89755cd4314a703bfce4f2c395.zip
player_in_a_dangerous_place() can now optionally return if any hostile
invisible monsters are nearby; for future use. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5967 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/misc.cc')
-rw-r--r--crawl-ref/source/misc.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 0033d0c0c4..b6851642de 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2485,8 +2485,11 @@ int str_to_shoptype(const std::string &s)
// General threat = sum_of_logexpervalues_of_nearby_unfriendly_monsters.
// Highest threat = highest_logexpervalue_of_nearby_unfriendly_monsters.
-void monster_threat_values(double *general, double *highest)
+static void monster_threat_values(double *general, double *highest,
+ bool *invis)
{
+ *invis = false;
+
double sum = 0;
int highest_xp = -1;
@@ -2505,17 +2508,23 @@ void monster_threat_values(double *general, double *highest)
highest_xp = xp;
*highest = log_xp;
}
+ if (!you.can_see(monster))
+ *invis = true;
}
}
*general = sum;
}
-bool player_in_a_dangerous_place()
+bool player_in_a_dangerous_place(bool *invis)
{
+ bool junk;
+ if (invis == NULL)
+ invis = &junk;
+
const double logexp = log((double)you.experience);
double gen_threat = 0.0, hi_threat = 0.0;
- monster_threat_values(&gen_threat, &hi_threat);
+ monster_threat_values(&gen_threat, &hi_threat, invis);
return (gen_threat > logexp * 1.3 || hi_threat > logexp / 2);
}