summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/xom.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-28 08:27:29 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-28 08:27:29 +0000
commit3205c9289fd9ff8bcf739903a49215f75212128e (patch)
tree6a9b4a29e9e8bd96d4e8b87934d17ce84987a8e0 /crawl-ref/source/xom.cc
parentdc3aa32db050e7923a4e802b874fccd997c1d6c6 (diff)
downloadcrawl-ref-3205c9289fd9ff8bcf739903a49215f75212128e.tar.gz
crawl-ref-3205c9289fd9ff8bcf739903a49215f75212128e.zip
crawl_state now keeps track of whether or not the current code is being
executed because of a god's actions, and if so which god (with "actions" not including god-supplied invocations). Currently only used to prevent Xom from being amused/stimulated by his own actions. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2235 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/xom.cc')
-rw-r--r--crawl-ref/source/xom.cc37
1 files changed, 36 insertions, 1 deletions
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 8293fc4925..ed8b244b5c 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -25,6 +25,7 @@
#include "spells3.h"
#include "spl-cast.h"
#include "spl-util.h"
+#include "state.h"
#include "stuff.h"
#include "view.h"
@@ -113,6 +114,11 @@ void xom_is_stimulated(int maxinterestingness)
{
if (you.religion != GOD_XOM)
return;
+
+ // Xom is not stimulated by his own acts, at least not directly.
+ if (crawl_state.which_god_acting() == GOD_XOM)
+ return;
+
int interestingness = random2(maxinterestingness);
if (interestingness < 12)
return;
@@ -135,6 +141,8 @@ void xom_makes_you_cast_random_spell(int sever)
{
int spellenum = sever;
+ crawl_state.inc_god_acting(GOD_XOM);
+
const int nxomspells = ARRAYSIZE(xom_spells);
if (spellenum >= nxomspells)
spellenum = nxomspells - 1;
@@ -149,6 +157,8 @@ void xom_makes_you_cast_random_spell(int sever)
#endif
your_spells(spell, sever, false);
+
+ crawl_state.dec_god_acting(GOD_XOM);
}
static void xom_make_item(object_class_type base,
@@ -165,11 +175,15 @@ static void xom_make_item(object_class_type base,
return;
}
+ crawl_state.inc_god_acting(GOD_XOM);
+
move_item_to_grid( &thing_created, you.x_pos, you.y_pos );
canned_msg(MSG_SOMETHING_APPEARS);
stop_running();
origin_acquired(mitm[thing_created], GOD_XOM);
+
+ crawl_state.dec_god_acting(GOD_XOM);
}
static object_class_type get_unrelated_wield_class(object_class_type ref)
@@ -197,11 +211,16 @@ static object_class_type get_unrelated_wield_class(object_class_type ref)
(temp_rand == 1) ? OBJ_STAVES :
OBJ_MISCELLANY;
}
+
return (objtype);
}
static bool xom_annoyance_gift(int power)
{
+ // Can't simply use unwind_var because of the way that god act
+ // state is maintained.
+ crawl_state.inc_god_acting(GOD_XOM);
+
if (coinflip() && player_in_a_dangerous_place())
{
const item_def *weapon = you.weapon();
@@ -216,6 +235,7 @@ static bool xom_annoyance_gift(int power)
xom_make_item(weapon->base_type, weapon->sub_type, power * 3);
else
acquirement(weapon->base_type, GOD_XOM);
+ crawl_state.dec_god_acting(GOD_XOM);
return (true);
}
@@ -228,6 +248,7 @@ static bool xom_annoyance_gift(int power)
// A random ring. (Not necessarily a good one.)
god_speaks(GOD_XOM, RANDOM_ELEMENT(xom_try_this));
xom_make_item(OBJ_JEWELLERY, get_random_ring_type(), power * 3);
+ crawl_state.dec_god_acting(GOD_XOM);
return (true);
};
@@ -238,6 +259,7 @@ static bool xom_annoyance_gift(int power)
// you an amulet. Ha ha!
god_speaks(GOD_XOM, RANDOM_ELEMENT(xom_try_this));
xom_make_item(OBJ_JEWELLERY, get_random_amulet_type(), power * 3);
+ crawl_state.dec_god_acting(GOD_XOM);
return (true);
};
@@ -250,6 +272,7 @@ static bool xom_annoyance_gift(int power)
// a ring. Ha ha!
god_speaks(GOD_XOM, RANDOM_ELEMENT(xom_try_this_ring));
xom_make_item(OBJ_JEWELLERY, get_random_ring_type(), power * 3);
+ crawl_state.dec_god_acting(GOD_XOM);
return (true);
}
@@ -266,9 +289,12 @@ static bool xom_annoyance_gift(int power)
acquirement(objtype, GOD_XOM);
else
xom_make_item(objtype, OBJ_RANDOM, power * 3);
+ crawl_state.dec_god_acting(GOD_XOM);
return (true);
}
}
+
+ crawl_state.dec_god_acting(GOD_XOM);
return (false);
}
@@ -276,7 +302,7 @@ bool xom_gives_item(int power)
{
if (xom_annoyance_gift(power))
return (true);
-
+
const item_def *cloak = you.slot_item(EQ_CLOAK);
if (coinflip() && cloak && cloak->cursed())
{
@@ -310,7 +336,10 @@ bool xom_gives_item(int power)
(r == 5) ? OBJ_FOOD :
(r == 6) ? OBJ_MISCELLANY :
OBJ_GOLD;
+
+ crawl_state.inc_god_acting(GOD_XOM);
acquirement(objtype, GOD_XOM);
+ crawl_state.dec_god_acting(GOD_XOM);
}
else
{
@@ -397,6 +426,7 @@ static bool xom_is_good(int sever)
// Okay, now for the nicer stuff (note: these things are not
// necessarily nice):
+ crawl_state.inc_god_acting(GOD_XOM);
if (random2(sever) <= 1)
{
temp_rand = random2(4);
@@ -579,6 +609,7 @@ static bool xom_is_good(int sever)
done = true;
}
+ crawl_state.dec_god_acting(GOD_XOM);
return (done);
}
@@ -590,6 +621,8 @@ static bool xom_is_bad(int sever)
bolt beam;
+ crawl_state.inc_god_acting(GOD_XOM);
+
// begin "Bad Things"
while (!done)
{
@@ -778,6 +811,8 @@ static bool xom_is_bad(int sever)
}
}
+ crawl_state.dec_god_acting(GOD_XOM);
+
return (done);
}