summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-03 06:31:03 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-03 06:31:03 +0000
commite0c16e3e44b4b97c89f590fa063c0d6bb341fe50 (patch)
treee91429b6374df49fc8fb8fe691fdc2c52c7ba6c0
parent07eadf8e4cf3dd61fa66d194720143685ab84174 (diff)
downloadcrawl-ref-e0c16e3e44b4b97c89f590fa063c0d6bb341fe50.tar.gz
crawl-ref-e0c16e3e44b4b97c89f590fa063c0d6bb341fe50.zip
Merge r7726 from trunk: set acquirement source on items early enough that
it can be used by make_item_randart(). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.4@7727 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/effects.cc20
-rw-r--r--crawl-ref/source/makeitem.cc8
-rw-r--r--crawl-ref/source/makeitem.h2
-rw-r--r--crawl-ref/source/randart.cc84
-rw-r--r--crawl-ref/source/religion.cc11
-rw-r--r--crawl-ref/source/xom.cc9
6 files changed, 92 insertions, 42 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 159b55b263..869c00756e 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -1494,7 +1494,20 @@ bool acquirement(object_class_type class_wanted, int agent,
if (!silenced(you.pos()) && !quiet)
mprf(MSGCH_SOUND, grid_item_destruction_message(grd(you.pos())));
- item_was_destroyed(mitm[igrd(you.pos())], NON_MONSTER);
+ if (agent > GOD_NO_GOD && agent < NUM_GODS)
+ {
+ if (agent == GOD_XOM)
+ simple_god_message(" snickers.", GOD_XOM);
+ else
+ {
+ ASSERT(!"God gave gift item while player was on grid which "
+ "destroys items.");
+ mprf(MSGCH_ERROR, "%s gave a god gift while you were on "
+ "terrain which destroys items.",
+ god_name((god_type) agent).c_str());
+ }
+ }
+
*item_index = NON_ITEM;
}
else
@@ -1509,7 +1522,8 @@ bool acquirement(object_class_type class_wanted, int agent,
class_wanted = OBJ_POTIONS;
thing_created = items( 1, class_wanted, type_wanted, true,
- MAKE_GOOD_ITEM, MAKE_ITEM_RANDOM_RACE );
+ MAKE_GOOD_ITEM, MAKE_ITEM_RANDOM_RACE,
+ 0, 0, agent );
if (thing_created == NON_ITEM)
continue;
@@ -1729,7 +1743,6 @@ bool acquirement(object_class_type class_wanted, int agent,
thing.inscription = "god gift";
if (is_random_artefact(thing))
{
- origin_acquired(thing, agent);
if ( !is_unrandom_artefact(thing) )
{
// give another name that takes god gift into account
@@ -1747,7 +1760,6 @@ bool acquirement(object_class_type class_wanted, int agent,
{
if (!quiet)
canned_msg(MSG_SOMETHING_APPEARS);
- origin_acquired(mitm[thing_created], agent);
}
*item_index = thing_created;
}
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index cdb337188e..3239939309 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -2700,7 +2700,8 @@ int items( int allow_uniques, // not just true-false,
int item_race, // weapon / armour racial categories
// item_race also gives type of rune!
unsigned mapmask,
- int force_ego) // desired ego/brand
+ int force_ego, // desired ego/brand
+ int agent) // acquirement agent, if not -1
{
// TODO: Allow a combination of force_ego > 0 and
// force_type == OBJ_RANDOM, so that (for example) you could have
@@ -2719,6 +2720,11 @@ int items( int allow_uniques, // not just true-false,
item_def& item(mitm[p]);
+ // make_item_randart() might do things differently based upon the
+ // acquirement agent, especially for god gifts.
+ if (agent != -1)
+ origin_acquired(item, agent);
+
const bool force_good = (item_level == MAKE_GOOD_ITEM);
if (force_ego > 0)
diff --git a/crawl-ref/source/makeitem.h b/crawl-ref/source/makeitem.h
index 5409f008dc..b5d1889109 100644
--- a/crawl-ref/source/makeitem.h
+++ b/crawl-ref/source/makeitem.h
@@ -24,7 +24,7 @@ enum item_make_species_type
int items( int allow_uniques, object_class_type force_class, int force_type,
bool dont_place, int item_level, int item_race,
- unsigned mapmask = 0, int force_ego = 0 );
+ unsigned mapmask = 0, int force_ego = 0, int agent = -1 );
void item_colour( item_def &item );
void init_rod_mp(item_def &item);
diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc
index 65c2c512be..ba240dbe49 100644
--- a/crawl-ref/source/randart.cc
+++ b/crawl-ref/source/randart.cc
@@ -42,11 +42,67 @@
// dungeon.cc and consists of giving it a few random things - plus &
// plus2 mainly.
-static bool _god_fits_artefact(const god_type which_god, const item_def &item)
+static bool _god_fits_artefact(const god_type which_god, const item_def &item,
+ bool name_check_only = false)
{
if (which_god == GOD_NO_GOD)
return (false);
+ // First check the item's base_type and sub_type, then check the
+ // item's brand and other randart properties.
+ bool type_bad = false;
+ switch (which_god)
+ {
+ case GOD_ELYVILON: // peaceful healer god, no weapons, no berserking
+ if (item.base_type == OBJ_WEAPONS)
+ type_bad = true;
+
+ if (item.base_type == OBJ_JEWELLERY && item.sub_type == AMU_RAGE)
+ type_bad = true;
+ break;
+
+ case GOD_OKAWARU: // precision fighter
+ if (item.base_type == OBJ_JEWELLERY && item.sub_type == AMU_INACCURACY)
+ type_bad = true;
+ break;
+
+ case GOD_ZIN:
+ if (item.base_type == OBJ_JEWELLERY && item.sub_type == RING_HUNGER)
+ type_bad = true;
+ break;
+
+ case GOD_SIF_MUNA:
+ case GOD_KIKUBAAQUDGHA:
+ case GOD_VEHUMET:
+ // The magic gods: no weapons, no preventing spellcasting.
+ if (item.base_type == OBJ_WEAPONS)
+ type_bad = true;
+ break;
+
+ case GOD_TROG: // hates anything enhancing magic
+ if (item.base_type == OBJ_JEWELLERY && (item.sub_type == RING_WIZARDRY
+ || item.sub_type == RING_FIRE || item.sub_type == RING_ICE
+ || item.sub_type == RING_MAGICAL_POWER))
+ {
+ type_bad = true;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (type_bad && !name_check_only)
+ {
+ ASSERT(!"God attempting to gift invalid type of item.");
+ mprf(MSGCH_ERROR, "%s attempting to gift invalid type of item.");
+ // Prevent infinite loop in make_item_randart()
+ return (true);
+ }
+
+ if (type_bad)
+ return (false);
+
const int brand = get_weapon_brand(item);
if (is_evil_god(which_god) && brand == SPWPN_HOLY_WRATH)
@@ -67,12 +123,6 @@ static bool _god_fits_artefact(const god_type which_god, const item_def &item)
break;
case GOD_ELYVILON: // peaceful healer god, no weapons, no berserking
- if (item.base_type == OBJ_WEAPONS)
- return (false);
-
- if (item.base_type == OBJ_JEWELLERY && item.sub_type == AMU_RAGE)
- return (false);
-
if (randart_wpn_property( item, RAP_ANGRY )
|| randart_wpn_property( item, RAP_BERSERK ))
{
@@ -80,15 +130,7 @@ static bool _god_fits_artefact(const god_type which_god, const item_def &item)
}
break;
- case GOD_OKAWARU: // precision fighter
- if (item.base_type == OBJ_JEWELLERY && item.sub_type == AMU_INACCURACY)
- return (false);
- break;
-
case GOD_ZIN:
- if (item.base_type == OBJ_JEWELLERY && item.sub_type == RING_HUNGER)
- return (false); // goes against food theme
-
if (randart_wpn_property( item, RAP_MUTAGENIC ))
return (false); // goes against anti-mutagenic theme
break;
@@ -112,21 +154,11 @@ static bool _god_fits_artefact(const god_type which_god, const item_def &item)
case GOD_SIF_MUNA:
case GOD_KIKUBAAQUDGHA:
case GOD_VEHUMET:
- // The magic gods: no weapons, no preventing spellcasting.
- if (item.base_type == OBJ_WEAPONS)
- return (false);
-
if (randart_wpn_property( item, RAP_PREVENT_SPELLCASTING ))
return (false);
break;
case GOD_TROG: // hates anything enhancing magic
- if (item.base_type == OBJ_JEWELLERY && (item.sub_type == RING_WIZARDRY
- || item.sub_type == RING_FIRE || item.sub_type == RING_ICE
- || item.sub_type == RING_MAGICAL_POWER))
- {
- return (false);
- }
if (brand == SPWPN_PAIN) // involves magic
return (false);
@@ -244,7 +276,7 @@ static std::string _replace_name_parts(const std::string name_in,
{
which_god = static_cast<god_type>(random2(NUM_GODS - 1) + 1);
}
- while (!_god_fits_artefact(which_god, item));
+ while (!_god_fits_artefact(which_god, item), true);
}
name = replace_all(name, "@god_name@", god_name(which_god, false));
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 0e7c1cdaaa..b5282efd3b 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -1023,7 +1023,8 @@ static void _give_nemelex_gift()
_update_sacrifice_weights(choice);
int thing_created = items( 1, OBJ_MISCELLANY, gift_type,
- true, 1, MAKE_ITEM_RANDOM_RACE );
+ true, 1, MAKE_ITEM_RANDOM_RACE,
+ 0, 0, GOD_NEMELEX_XOBEH );
if (thing_created != NON_ITEM)
{
@@ -1060,7 +1061,6 @@ static void _give_nemelex_gift()
deck.inscription = "god gift";
move_item_to_grid( &thing_created, you.x_pos, you.y_pos );
- origin_acquired(deck, you.religion);
simple_god_message(" grants you a gift!");
more();
@@ -1873,7 +1873,8 @@ static void _do_god_gift(bool prayed_for)
else
{
int thing_created = items(1, OBJ_BOOKS, gift, true, 1,
- MAKE_ITEM_RANDOM_RACE);
+ MAKE_ITEM_RANDOM_RACE,
+ 0, 0, you.religion);
if (thing_created == NON_ITEM)
return;
@@ -1883,7 +1884,6 @@ static void _do_god_gift(bool prayed_for)
{
success = true;
mitm[thing_created].inscription = "god gift";
- origin_acquired(mitm[thing_created], you.religion);
}
}
@@ -3882,7 +3882,8 @@ static bool _beogh_retribution()
// Create item.
int slot = items(0, OBJ_WEAPONS, WPN_CLUB + random2(13),
true, you.experience_level,
- am_orc ? MAKE_ITEM_NO_RACE : MAKE_ITEM_ORCISH);
+ am_orc ? MAKE_ITEM_NO_RACE : MAKE_ITEM_ORCISH,
+ 0, 0, GOD_BEOGH);
if (slot == -1)
continue;
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index e67afa4598..2b0930c5d8 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -203,8 +203,11 @@ static void _xom_makes_you_cast_random_spell(int sever)
static void _xom_make_item(object_class_type base, int subtype, int power)
{
+ god_acting gdact(GOD_XOM);
+
int thing_created =
- items(true, base, subtype, true, power, MAKE_ITEM_RANDOM_RACE);
+ items(true, base, subtype, true, power, MAKE_ITEM_RANDOM_RACE,
+ 0, 0, GOD_XOM);
if (thing_created == NON_ITEM)
{
@@ -212,14 +215,10 @@ static void _xom_make_item(object_class_type base, int subtype, int power)
return;
}
- god_acting gdact(GOD_XOM);
-
move_item_to_grid(&thing_created, you.x_pos, you.y_pos);
mitm[thing_created].inscription = "god gift";
canned_msg(MSG_SOMETHING_APPEARS);
stop_running();
-
- origin_acquired(mitm[thing_created], GOD_XOM);
}
static object_class_type _get_unrelated_wield_class(object_class_type ref)