1 /**
2  * @file
3  * @brief Orb-related functionality.
4 **/
5 
6 #include "AppHdr.h"
7 
8 #include "orb.h"
9 
10 #include "areas.h"
11 #include "god-passive.h" // passive_t::slow_orb_run
12 #include "shout.h"
13 #include "view.h"
14 #include "religion.h"
15 #include "message.h"
16 #include "xom.h"
17 
18 
19 /**
20  * Make a "noise" caused by the orb.
21  *
22  * Alerts monsters via fake_noisy. If the area is silenced, perform a "flashing
23  * lights" visual effect.
24  *
25  * @param where      The location the "noise" comes from.
26  * @param loudness   The loudness of the noise, determining distance travelled.
27  * @return           True if the area was unsilenced and thus an actual noise
28  *                   occurred, otherwise false, denoting that flashing lights
29  *                   occurred.
30 **/
_orb_noise(const coord_def & where,int loudness)31 static bool _orb_noise(const coord_def& where, int loudness)
32 {
33     // XXX: Fake noisy doesn't work. Oops.
34     fake_noisy(loudness, where);
35 
36     if (silenced(where))
37     {
38         flash_view_delay(UA_MONSTER, MAGENTA, 100);
39         flash_view_delay(UA_MONSTER, LIGHTMAGENTA, 100);
40         flash_view_delay(UA_MONSTER, MAGENTA, 100);
41         flash_view_delay(UA_MONSTER, LIGHTMAGENTA, 100);
42 
43         return false;
44     }
45 
46     return true;
47 }
48 
49 /**
50  * Make a "noise" upon picking up the orb.
51  *
52  * Calls orb_noise(where, loudness), and, depending on the result of that
53  * function, prints one of two messages.
54  *
55  * @param where       Passed to orb_noise.
56  * @param loudness    Passed to orb_noise.
57  * @param msg         The message to be printed if orb_noise returned true.
58  * @param msg2        The message to be printed if orb_noise returned false.
59 **/
orb_pickup_noise(const coord_def & where,int loudness,const char * msg,const char * msg2)60 void orb_pickup_noise(const coord_def& where, int loudness, const char* msg, const char* msg2)
61 {
62     if (_orb_noise(where, loudness))
63     {
64         if (msg)
65             mprf(MSGCH_ORB, "%s", msg);
66         else
67             mprf(MSGCH_ORB, "The Orb lets out a hideous shriek!");
68     }
69     else
70     {
71         if (msg2)
72             mprf(MSGCH_ORB, "%s", msg2);
73         else
74             mprf(MSGCH_ORB, "The Orb lets out a furious burst of light!");
75     }
76 }
77 
78 /**
79  * Is the Orb interfering with translocations?
80  * @return True if the player is carrying the Orb or if the player is in Zot.
81  *         Returns false otherwise.
82  */
orb_limits_translocation()83 bool orb_limits_translocation()
84 {
85     return player_in_branch(BRANCH_ZOT) || player_has_orb();
86 }
87 
start_orb_run(game_chapter chapter,const char * message)88 void start_orb_run(game_chapter chapter, const char* message)
89 {
90     if (you.chapter != CHAPTER_ANGERED_PANDEMONIUM)
91     {
92         mprf(MSGCH_WARN, "The lords of Pandemonium are not amused. Beware!");
93         if (have_passive(passive_t::slow_orb_run))
94             simple_god_message(" tells them not to hurry.");
95     }
96 
97     mprf(MSGCH_ORB, "%s", message);
98     you.chapter = chapter;
99     xom_is_stimulated(200, XM_INTRIGUED);
100     invalidate_agrid(true);
101 }
102