object_prep(q_ptr, lookup_kind(TV_FLASK, SV_ANY));
/* Fuel with oil (move pval to xtra4) */
- apply_magic(q_ptr, 1, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, 1, 0L);
q_ptr->number = (byte)rand_range(7, 12);
object_aware(q_ptr);
int number;
bool small;
- bool great = FALSE;
+ u32b mode = AM_OKAY | AM_GOOD;
object_type forge;
object_type *q_ptr;
{
number = 5;
small = FALSE;
- great = TRUE;
+ mode |= AM_GREAT;
object_level = o_ptr->xtra3;
}
else
else
{
/* Make a good object */
- if (!make_object(q_ptr, TRUE, great)) continue;
+ if (!make_object(q_ptr, mode)) continue;
}
/* If chest scatters its contents, pick any floor square. */
if (randint0(100) < (15 - dun_level/2))
{
/* Create a simple object */
- place_object(y, x, FALSE, FALSE);
+ place_object(y, x, AM_OKAY);
/* Observe new object */
if (player_can_see_bold(y, x))
TRC_TELEPORT | TRC_DRAIN_HP | TRC_DRAIN_MANA)
+
+/*
+ * Bit flags for apply_magic() (etc)
+ */
+#define AM_OKAY 0x00000001 /* Allow roll for fixed artifacts */
+#define AM_GOOD 0x00000002 /* Generate good items */
+#define AM_GREAT 0x00000004 /* Generate great items */
+#define AM_SPECIAL 0x00000008 /* Generate artifacts (for debug mode only) */
+#define AM_CURSED 0x00000010 /* Generate cursed/worthless items */
+
+
/*** Monster blow constants ***/
extern void object_wipe(object_type *o_ptr);
extern void object_prep(object_type *o_ptr, int k_idx);
extern void object_copy(object_type *o_ptr, object_type *j_ptr);
-extern void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great, bool curse);
-extern bool make_object(object_type *j_ptr, bool good, bool great);
-extern void place_object(int y, int x, bool good, bool great);
+extern void apply_magic(object_type *o_ptr, int lev, u32b mode);
+extern bool make_object(object_type *j_ptr, u32b mode);
+extern void place_object(int y, int x, u32b mode);
extern bool make_gold(object_type *j_ptr);
extern void place_gold(int y, int x);
extern s16b drop_near(object_type *o_ptr, int chance, int y, int x);
case ALLOC_TYP_OBJECT:
{
- place_object(y, x, FALSE, FALSE);
+ place_object(y, x, AM_OKAY);
break;
}
}
/* Place an item */
if (randint0(100) < 75)
{
- place_object(j, k, FALSE, FALSE);
+ place_object(j, k, AM_OKAY);
}
/* Place gold */
*/
if (randint0(100) < 75)
{
- place_object(*y, *x, FALSE, FALSE);
+ place_object(*y, *x, AM_OKAY);
}
else
{
/* Create an out of deep object */
if (randint0(100) < 75)
- place_object(*y, *x, FALSE, FALSE);
+ place_object(*y, *x, AM_OKAY);
else if (randint0(100) < 80)
- place_object(*y, *x, TRUE, FALSE);
+ place_object(*y, *x, AM_OKAY | AM_GOOD);
else
- place_object(*y, *x, TRUE, TRUE);
+ place_object(*y, *x, AM_OKAY | AM_GOOD | AM_GREAT);
object_level = base_level;
}
}
/* Apply magic (no messages, no artifacts) */
- apply_magic(o_ptr, base_level, FALSE, TRUE, FALSE, FALSE);
+ apply_magic(o_ptr, base_level, AM_GOOD);
(void)drop_near(o_ptr, -1, *y, *x);
}
/* Very good */
if (power > 1)
{
- if (one_in_(30))
+ if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
create_artifact(o_ptr, FALSE);
else
/* Special Ego-item */
/* Very Good */
if (power > 1)
{
- if (one_in_(40))
+ if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
{
create_artifact(o_ptr, FALSE);
break;
/* Very good */
if (power > 1)
{
- if (one_in_(20))
+ if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
{
create_artifact(o_ptr, FALSE);
break;
/* Very good */
if (power > 1)
{
+ if (power > 2) /* power > 2 is debug only */
+ {
+ create_artifact(o_ptr, FALSE);
+ break;
+ }
+
o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
switch (o_ptr->name2)
{
/* Rating boost */
rating += 30;
- if(one_in_(50))
+ if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
create_artifact(o_ptr, FALSE);
/* Mention the item */
break;
}
- if (one_in_(20))
+ if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
{
create_artifact(o_ptr, FALSE);
break;
/* Very good */
if (power > 1)
{
- if (one_in_(20))
+ if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
{
create_artifact(o_ptr, FALSE);
break;
}
if (power > 1)
{
- if (one_in_(20))
+ if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
{
create_artifact(o_ptr, FALSE);
break;
/* Very good */
if (power > 1)
{
- if (one_in_(20))
+ if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
{
create_artifact(o_ptr, FALSE);
break;
/* Very good */
if (power > 1)
{
- if (one_in_(20))
+ if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
{
create_artifact(o_ptr, FALSE);
break;
/* Very good */
if (power > 1)
{
- if (one_in_(20))
+ if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
{
create_artifact(o_ptr, FALSE);
break;
/* Very good */
if (power > 1)
{
- if (one_in_(20))
+ if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
{
create_artifact(o_ptr, FALSE);
break;
break;
}
}
- if (one_in_(400) && (power > 0) && !cursed_p(o_ptr) && (level > 79))
+ if ((one_in_(400) && (power > 0) && !cursed_p(o_ptr) && (level > 79))
+ || (power > 2)) /* power > 2 is debug only */
{
- o_ptr->pval = MIN(o_ptr->pval,4);
+ o_ptr->pval = MIN(o_ptr->pval, 4);
/* Randart amulet */
create_artifact(o_ptr, FALSE);
}
break;
}
}
- if (one_in_(150) && (power > 0) && !cursed_p(o_ptr) && (level > 79))
+ if ((one_in_(150) && (power > 0) && !cursed_p(o_ptr) && (level > 79))
+ || (power > 2)) /* power > 2 is debug only */
{
- o_ptr->pval = MIN(o_ptr->pval,4);
+ o_ptr->pval = MIN(o_ptr->pval, 4);
/* Randart amulet */
create_artifact(o_ptr, FALSE);
}
o_ptr->pval = 0;
}
- if ((power == 2) || ((power == 1) && one_in_(3)))
+ if (power > 2) /* power > 2 is debug only */
+ {
+ create_artifact(o_ptr, FALSE);
+ }
+ else if ((power == 2) || ((power == 1) && one_in_(3)))
{
while (!o_ptr->name2)
{
* "good" and "great" arguments are false. As a total hack, if "great" is
* true, then the item gets 3 extra "attempts" to become an artifact.
*/
-void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great, bool curse)
+void apply_magic(object_type *o_ptr, int lev, u32b mode)
{
-
int i, rolls, f1, f2, power;
if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
power = 0;
/* Roll for "good" */
- if (good || magik(f1))
+ if ((mode & AM_GOOD) || magik(f1))
{
/* Assume "good" */
power = 1;
/* Roll for "great" */
- if (great || magik(f2)) power = 2;
+ if ((mode & AM_GREAT) || magik(f2))
+ {
+ power = 2;
+
+ /* Roll for "special" */
+ if (mode & AM_SPECIAL) power = 3;
+ }
}
/* Roll for "cursed" */
}
/* Apply curse */
- if (curse)
+ if (mode & AM_CURSED)
{
/* Assume 'cursed' */
if (power > 0)
/* Get one roll if excellent */
if (power >= 2) rolls = 1;
- /* Hack -- Get four rolls if forced great */
- if (great) rolls = 4;
+ /* Hack -- Get four rolls if forced great or special */
+ if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
/* Hack -- Get no rolls if not allowed */
- if (!okay || o_ptr->name1) rolls = 0;
+ if (!(mode & AM_OKAY) || o_ptr->name1) rolls = 0;
/* Roll for artifacts if allowed */
for (i = 0; i < rolls; i++)
*
* We assume that the given object has been "wiped".
*/
-bool make_object(object_type *j_ptr, bool good, bool great)
+bool make_object(object_type *j_ptr, u32b mode)
{
int prob, base;
byte obj_level;
/* Chance of "special object" */
- prob = (good ? 10 : 1000);
+ prob = ((mode & AM_GOOD) ? 10 : 1000);
/* Base level for the object */
- base = (good ? (object_level + 10) : object_level);
+ base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
/* Generate a special object, or a normal object */
int k_idx;
/* Good objects */
- if (good)
+ if (mode & AM_GOOD)
{
/* Activate restriction */
get_obj_num_hook = kind_is_good;
}
/* Apply magic (allow artifacts) */
- apply_magic(j_ptr, object_level, TRUE, good, great, FALSE);
+ apply_magic(j_ptr, object_level, mode);
/* Hack -- generate multiple spikes/missiles */
switch (j_ptr->tval)
*
* This routine requires a clean floor grid destination.
*/
-void place_object(int y, int x, bool good, bool great)
+void place_object(int y, int x, u32b mode)
{
s16b o_idx;
object_wipe(q_ptr);
/* Make an object (if possible) */
- if (!make_object(q_ptr, good, great)) return;
+ if (!make_object(q_ptr, mode)) return;
/* Make an object */
{
object_type *i_ptr;
object_type object_type_body;
+ u32b mode = AM_OKAY | AM_GOOD | (great ? AM_GREAT : 0L);
/* Acquirement */
while (num--)
object_wipe(i_ptr);
/* Make a good (or great) object (if possible) */
- if (!make_object(i_ptr, TRUE, great)) continue;
+ if (!make_object(i_ptr, mode)) continue;
if (known)
{
q_ptr->number = (byte)rand_range(15,30);
object_aware(q_ptr);
object_known(q_ptr);
- apply_magic(q_ptr, p_ptr->lev, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, p_ptr->lev, 0L);
q_ptr->discount = 99;
(void)inven_carry(q_ptr);
q_ptr->number = (byte)rand_range(5,10);
object_aware(q_ptr);
object_known(q_ptr);
- apply_magic(q_ptr, p_ptr->lev, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, p_ptr->lev, 0L);
q_ptr->discount = 99;
q_ptr->number = (byte)rand_range(4,8);
object_aware(q_ptr);
object_known(q_ptr);
- apply_magic(q_ptr, p_ptr->lev, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, p_ptr->lev, 0L);
q_ptr->discount = 99;
}
/* Place a treasure in the vault */
- place_object(yval, xval, FALSE, FALSE);
+ place_object(yval, xval, AM_OKAY);
/* Let's guard the treasure well */
vault_monsters(yval, xval, randint0(2) + 3);
/* Object (80%) */
if (randint0(100) < 80)
{
- place_object(yval, xval, FALSE, FALSE);
+ place_object(yval, xval, AM_OKAY);
}
/* Stairs (20%) */
vault_monsters(yval, xval + 2, randint1(2));
/* Objects */
- if (one_in_(3)) place_object(yval, xval - 2, FALSE, FALSE);
- if (one_in_(3)) place_object(yval, xval + 2, FALSE, FALSE);
+ if (one_in_(3)) place_object(yval, xval - 2, AM_OKAY);
+ if (one_in_(3)) place_object(yval, xval + 2, AM_OKAY);
}
break;
case '*':
if (randint0(100) < 75)
{
- place_object(y, x, FALSE, FALSE);
+ place_object(y, x, AM_OKAY);
}
else
{
case 'A':
/* Reward for Pattern walk */
object_level = base_level + 12;
- place_object(y, x, TRUE, FALSE);
+ place_object(y, x, AM_OKAY | AM_GOOD);
object_level = base_level;
break;
}
place_monster(y, x, PM_ALLOW_SLEEP);
monster_level = base_level;
object_level = base_level + 7;
- place_object(y, x, TRUE, FALSE);
+ place_object(y, x, AM_OKAY | AM_GOOD);
object_level = base_level;
break;
}
place_monster(y, x, PM_ALLOW_SLEEP);
monster_level = base_level;
object_level = base_level + 20;
- place_object(y, x, TRUE, TRUE);
+ place_object(y, x, AM_OKAY | AM_GOOD | AM_GREAT);
object_level = base_level;
break;
}
if (randint0(100) < 50)
{
object_level = base_level + 7;
- place_object(y, x, FALSE, FALSE);
+ place_object(y, x, AM_OKAY);
object_level = base_level;
}
break;
place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
monster_level = base_level;
object_level = base_level + 20;
- place_object(y, x, TRUE, FALSE);
+ place_object(y, x, AM_OKAY | AM_GOOD);
object_level = base_level;
}
else if (value < 5)
place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
monster_level = base_level;
object_level = base_level + 10;
- place_object(y, x, TRUE, FALSE);
+ place_object(y, x, AM_OKAY | AM_GOOD);
object_level = base_level;
}
else if (value < 10)
/* Object or trap */
if (randint0(100) < 25)
{
- place_object(y, x, FALSE, FALSE);
+ place_object(y, x, AM_OKAY);
}
else
{
if (randint0(100) < 50)
{
object_level = base_level + 7;
- place_object(y, x, FALSE, FALSE);
+ place_object(y, x, AM_OKAY);
object_level = base_level;
}
}
}
else if (randint0(100) < 50)
{
- place_object(y, x, FALSE, FALSE);
+ place_object(y, x, AM_OKAY);
}
}
build_small_room(x0, y0);
/* Place a treasure in the vault */
- place_object(y0, x0, FALSE, FALSE);
+ place_object(y0, x0, AM_OKAY);
/* Let's guard the treasure well */
vault_monsters(y0, x0, randint0(2) + 3);
}
/* Place gold */
- place_object(y, x, FALSE, FALSE);
+ place_object(y, x, AM_OKAY);
}
}
object_prep(q_ptr, i);
/* Apply some "low-level" magic (no artifacts) */
- apply_magic(q_ptr, level, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, level, 0L);
/* Require valid object */
if (!store_will_buy(q_ptr)) continue;
case 'w': case 'W':
{
object_prep(q_ptr, o_ptr->k_idx);
- apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, TRUE);
+ apply_magic(q_ptr, dun_level, AM_GOOD | AM_GREAT | AM_CURSED);
break;
}
/* Apply bad magic, but first clear object */
case 'c': case 'C':
{
object_prep(q_ptr, o_ptr->k_idx);
- apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, TRUE);
+ apply_magic(q_ptr, dun_level, AM_GOOD | AM_CURSED);
break;
}
/* Apply normal magic, but first clear object */
case 'n': case 'N':
{
object_prep(q_ptr, o_ptr->k_idx);
- apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, dun_level, 0L);
break;
}
/* Apply good magic, but first clear object */
case 'g': case 'G':
{
object_prep(q_ptr, o_ptr->k_idx);
- apply_magic(q_ptr, dun_level, FALSE, TRUE, FALSE, FALSE);
+ apply_magic(q_ptr, dun_level, AM_GOOD);
break;
}
/* Apply great magic, but first clear object */
case 'e': case 'E':
{
object_prep(q_ptr, o_ptr->k_idx);
- apply_magic(q_ptr, dun_level, FALSE, TRUE, TRUE, FALSE);
+ apply_magic(q_ptr, dun_level, AM_GOOD | AM_GREAT);
break;
}
+ /* Apply special magic, but first clear object */
case 's': case 'S':
{
object_prep(q_ptr, o_ptr->k_idx);
- apply_magic(q_ptr, dun_level, TRUE, TRUE, TRUE, FALSE);
+ apply_magic(q_ptr, dun_level, AM_OKAY | AM_GOOD | AM_GREAT | AM_SPECIAL);
- /* Failed to create normal artifact; make a random one */
- if (!artifact_p(q_ptr)) create_artifact(q_ptr, FALSE);
+ /* Failed to create artifact; make a random one */
+ if (!artifact_p(q_ptr) && !q_ptr->art_name) create_artifact(q_ptr, FALSE);
break;
}
}
char ch;
cptr quality;
- bool good, great;
+ u32b mode;
object_type forge;
object_type *q_ptr;
if (ch == 'n' || ch == 'N')
{
- good = FALSE;
- great = FALSE;
+ mode = AM_OKAY;
quality = "normal";
}
else if (ch == 'g' || ch == 'G')
{
- good = TRUE;
- great = FALSE;
+ mode = AM_OKAY | AM_GOOD;
quality = "good";
}
else if (ch == 'e' || ch == 'E')
{
- good = TRUE;
- great = TRUE;
+ mode = AM_OKAY | AM_GOOD | AM_GREAT;
quality = "excellent";
}
else
{
- good = FALSE;
- great = FALSE;
break;
}
object_wipe(q_ptr);
/* Create an object */
- make_object(q_ptr, good, great);
+ make_object(q_ptr, mode);
/* XXX XXX XXX Mega-Hack -- allow multiple artifacts */
object_prep(q_ptr, k_idx);
/* Apply magic */
- apply_magic(q_ptr, dun_level, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, dun_level, 0L);
/* Drop the object from heaven */
(void)drop_near(q_ptr, -1, py, px);
object_wipe(q_ptr);
/* Make a great object */
- make_object(q_ptr, TRUE, TRUE);
+ make_object(q_ptr, AM_OKAY | AM_GOOD | AM_GREAT);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
- bool good = (r_ptr->flags1 & RF1_DROP_GOOD) ? TRUE : FALSE;
- bool great = (r_ptr->flags1 & RF1_DROP_GREAT) ? TRUE : FALSE;
+ u32b mo_mode = AM_OKAY;
bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
/* Prepare to make a prize */
object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
- apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, object_level, 0L);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
/* Prepare to make an object */
object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
- apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, object_level, 0L);
q_ptr->pval = m_ptr->r_idx;
/* Prepare to make a Blade of Chaos */
object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
- apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, object_level, 0L);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
get_obj_num_prep();
/* Make a book */
- make_object(q_ptr, FALSE, FALSE);
+ make_object(q_ptr, AM_OKAY);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
q_ptr->name1 = ART_GROND;
/* Mega-Hack -- Actually create "Grond" */
- apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
+ apply_magic(q_ptr, -1, AM_OKAY | AM_GOOD | AM_GREAT);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
q_ptr->name1 = ART_CHAOS;
/* Mega-Hack -- Actually create "Chaos" */
- apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
+ apply_magic(q_ptr, -1, AM_OKAY | AM_GOOD | AM_GREAT);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
/* Prepare to make a Can of Toys */
object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
- apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, object_level, 0L);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
get_obj_num_prep();
/* Make a cloak */
- make_object(q_ptr, FALSE, FALSE);
+ make_object(q_ptr, AM_OKAY);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
get_obj_num_prep();
/* Make a poleweapon */
- make_object(q_ptr, FALSE, FALSE);
+ make_object(q_ptr, AM_OKAY);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
get_obj_num_prep();
/* Make a hard armor */
- make_object(q_ptr, FALSE, FALSE);
+ make_object(q_ptr, AM_OKAY);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
get_obj_num_prep();
/* Make a sword */
- make_object(q_ptr, FALSE, FALSE);
+ make_object(q_ptr, AM_OKAY);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
/* Prepare to make a reward */
object_prep(q_ptr, k_idx);
- apply_magic(q_ptr, object_level, FALSE, TRUE, FALSE, FALSE);
+ apply_magic(q_ptr, object_level, AM_GOOD);
/* Drop it in the dungeon */
(void)drop_near(q_ptr, -1, y, x);
/* Average dungeon and monster levels */
object_level = (dun_level + r_ptr->level) / 2;
+ if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
+ if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
+
/* Drop some objects */
for (j = 0; j < number; j++)
{
else
{
/* Make an object */
- if (!make_object(q_ptr, good, great)) continue;
+ if (!make_object(q_ptr, mo_mode)) continue;
/* XXX XXX XXX */
dump_item++;