if (dec_valour &&
(((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
- (4+randint(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
+ (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
{
chg_virtue(V_VALOUR, -1);
}
if (!m_ptr->r_idx) return;
/* "Skill" test */
- if (randint(100) > power) return;
+ if (randint1(100) > power) return;
/* Initialize */
ny = m_ptr->fy;
if (!dun_level) dungeon_type = 0;
- leaving_quest = p_ptr->inside_quest;
-
- if (leaving_quest &&
- ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
- (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
- {
- quest[leaving_quest].status = QUEST_STATUS_FAILED;
- quest[leaving_quest].complev = (byte)p_ptr->lev;
- if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
- {
- r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
- if (record_rand_quest)
- do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
- }
- else if (record_fix_quest)
- do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
- }
+ leave_quest_check();
/* Leaving */
p_ptr->inside_quest = 0;
p_ptr->leaving = TRUE;
}
- else if (rand_int(100) < 50)
+ else if (randint0(100) < 50)
{
#ifdef JP
msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
bool word_of_recall(void)
{
- return(recall_player(rand_int(21) + 15));
+ return(recall_player(randint0(21) + 15));
}
*
* XXX XXX XXX This function is also called from the "melee" code
*
- * The "mode" is currently unused.
- *
* Return "TRUE" if the player notices anything
*/
bool apply_disenchant(int mode)
int t = 0;
object_type *o_ptr;
char o_name[MAX_NLEN];
-
-
- /* Unused */
- mode = mode;
-
+ int to_h, to_d, to_a, pval;
/* Pick a random slot */
- switch (randint(8))
+ switch (randint1(8))
{
case 1: t = INVEN_RARM; break;
case 2: t = INVEN_LARM; break;
/* Nothing to disenchant */
- if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0))
+ if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
{
/* Nothing to notice */
return (FALSE);
/* Artifacts have 71% chance to resist */
- if ((artifact_p(o_ptr) || o_ptr->art_name) && (rand_int(100) < 71))
+ if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
{
/* Message */
#ifdef JP
}
+ /* Memorize old value */
+ to_h = o_ptr->to_h;
+ to_d = o_ptr->to_d;
+ to_a = o_ptr->to_a;
+ pval = o_ptr->pval;
+
/* Disenchant tohit */
if (o_ptr->to_h > 0) o_ptr->to_h--;
- if ((o_ptr->to_h > 5) && (rand_int(100) < 20)) o_ptr->to_h--;
+ if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
/* Disenchant todam */
if (o_ptr->to_d > 0) o_ptr->to_d--;
- if ((o_ptr->to_d > 5) && (rand_int(100) < 20)) o_ptr->to_d--;
+ if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
/* Disenchant toac */
if (o_ptr->to_a > 0) o_ptr->to_a--;
- if ((o_ptr->to_a > 5) && (rand_int(100) < 20)) o_ptr->to_a--;
+ if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
- /* Message */
+ /* Disenchant pval (occasionally) */
+ /* Unless called from wild_magic() */
+ if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
+
+ if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
+ (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
+ {
+ /* Message */
#ifdef JP
-msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
- o_name, index_to_label(t) );
+ msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
+ o_name, index_to_label(t) );
#else
- msg_format("Your %s (%c) %s disenchanted!",
- o_name, index_to_label(t),
- ((o_ptr->number != 1) ? "were" : "was"));
+ msg_format("Your %s (%c) %s disenchanted!",
+ o_name, index_to_label(t),
+ ((o_ptr->number != 1) ? "were" : "was"));
#endif
- chg_virtue(V_HARMONY, 1);
- chg_virtue(V_ENCHANT, -2);
+ chg_virtue(V_HARMONY, 1);
+ chg_virtue(V_ENCHANT, -2);
- /* Recalculate bonuses */
- p_ptr->update |= (PU_BONUS);
+ /* Recalculate bonuses */
+ p_ptr->update |= (PU_BONUS);
- /* Window stuff */
- p_ptr->window |= (PW_EQUIP | PW_PLAYER);
+ /* Window stuff */
+ p_ptr->window |= (PW_EQUIP | PW_PLAYER);
- calc_android_exp();
+ calc_android_exp();
+ }
/* Notice */
return (TRUE);
int max1, cur1, max2, cur2, ii, jj, i;
/* Pick a pair of stats */
- ii = rand_int(6);
- for (jj = ii; jj == ii; jj = rand_int(6)) /* loop */;
+ ii = randint0(6);
+ for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
max1 = p_ptr->stat_max[ii];
cur1 = p_ptr->stat_cur[ii];
*/
void apply_nexus(monster_type *m_ptr)
{
- switch (randint(7))
+ switch (randint1(7))
{
case 1: case 2: case 3:
{
case 6:
{
- if (rand_int(100) < p_ptr->skill_sav)
+ if (randint0(100) < p_ptr->skill_sav)
{
#ifdef JP
msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
case 7:
{
- if (rand_int(100) < p_ptr->skill_sav)
+ if (randint0(100) < p_ptr->skill_sav)
{
#ifdef JP
msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
switch (brand_type)
{
- case 16:
+ case 17:
if (o_ptr->tval == TV_SWORD)
{
#ifdef JP
o_ptr->pval = m_bonus(3, dun_level);
}
break;
+ case 16:
+#ifdef JP
+act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
+#else
+ act = "seems looking for human!";
+#endif
+
+ o_ptr->name2 = EGO_SLAY_HUMAN;
+ break;
case 15:
#ifdef JP
act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
#endif
o_ptr->name2 = EGO_TRUMP;
- o_ptr->pval = randint(2);
+ o_ptr->pval = randint1(2);
break;
case 4:
#ifdef JP
#endif
- enchant(o_ptr, rand_int(3) + 4, ENCH_TOHIT | ENCH_TODAM);
+ enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
o_ptr->discount = 99;
chg_virtue(V_ENCHANT, 2);
#endif
- if (destroy_area(py, px, 15 + p_ptr->lev + rand_int(11), TRUE))
+ if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), TRUE))
#ifdef JP
msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
#else
#ifdef JP
-take_hit(DAMAGE_NOESCAPE, 100 + randint(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
+take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
#else
- take_hit(DAMAGE_NOESCAPE, 100 + randint(150), "a suicidal Call the Void", -1);
+ take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
#endif
}
/* Attempt to uncurse items being worn */
for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
{
- u32b f1, f2, f3;
-
object_type *o_ptr = &inventory[i];
/* Skip non-objects */
/* Uncursed already */
if (!cursed_p(o_ptr)) continue;
- /* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3);
-
/* Heavily Cursed Items need a special spell */
- if (!all && (f3 & TR3_HEAVY_CURSE)) continue;
+ if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
/* Perma-Cursed Items can NEVER be uncursed */
- if (f3 & TR3_PERMA_CURSE) continue;
+ if (o_ptr->curse_flags & TRC_PERMA_CURSE)
+ {
+ /* Uncurse it */
+ o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
+ continue;
+ }
/* Uncurse it */
- o_ptr->ident &= ~(IDENT_CURSED);
+ o_ptr->curse_flags = 0L;
/* Hack -- Assume felt */
o_ptr->ident |= (IDENT_SENSE);
- if (o_ptr->art_flags3 & TR3_CURSED)
- o_ptr->art_flags3 &= ~(TR3_CURSED);
-
- if (o_ptr->art_flags3 & TR3_HEAVY_CURSE)
- o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
-
/* Take note */
o_ptr->feeling = FEEL_NONE;
}
/* Artifacts cannot be destroyed */
- if (artifact_p(o_ptr) || o_ptr->art_name)
+ if (!can_player_destroy_object(o_ptr))
{
- byte feel = FEEL_SPECIAL;
-
/* Message */
#ifdef JP
-msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
+ msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
#else
msg_format("You fail to turn %s to gold!", o_name);
#endif
-
- /* Hack -- Handle icky artifacts */
- if (cursed_p(o_ptr) || broken_p(o_ptr)) feel = FEEL_TERRIBLE;
-
- /* Hack -- inscribe the artifact */
- o_ptr->feeling = feel;
-
- /* We have "felt" it (again) */
- o_ptr->ident |= (IDENT_SENSE);
-
- /* Combine the pack */
- p_ptr->notice |= (PN_COMBINE);
-
- /* Window stuff */
- p_ptr->window |= (PW_INVEN | PW_EQUIP);
-
/* Done */
return FALSE;
}
/* Quest level */
cave_set_feat(py, px, FEAT_LESS);
}
- else if (rand_int(100) < 50)
+ else if (randint0(100) < 50)
{
cave_set_feat(py, px, FEAT_MORE);
}
*/
static void break_curse(object_type *o_ptr)
{
- u32b f1, f2, f3;
-
- /* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3);
-
- if (cursed_p(o_ptr) && !(f3 & TR3_PERMA_CURSE) && !(f3 & TR3_HEAVY_CURSE) && (rand_int(100) < 25))
+ if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
{
#ifdef JP
msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
msg_print("The curse is broken!");
#endif
+ o_ptr->curse_flags = 0L;
- o_ptr->ident &= ~(IDENT_CURSED);
o_ptr->ident |= (IDENT_SENSE);
- if (o_ptr->art_flags3 & TR3_CURSED)
- o_ptr->art_flags3 &= ~(TR3_CURSED);
-
o_ptr->feeling = FEEL_NONE;
}
}
for (i = 0; i < n; i++)
{
/* Hack -- Roll for pile resistance */
- if (!force && rand_int(prob) >= 100) continue;
+ if (!force && randint0(prob) >= 100) continue;
/* Enchant to hit */
if (eflag & ENCH_TOHIT)
else if (o_ptr->to_h > 15) chance = 1000;
else chance = enchant_table[o_ptr->to_h];
- if (force || ((randint(1000) > chance) && (!a || (rand_int(100) < 50))))
+ if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
{
o_ptr->to_h++;
res = TRUE;
else if (o_ptr->to_d > 15) chance = 1000;
else chance = enchant_table[o_ptr->to_d];
- if (force || ((randint(1000) > chance) && (!a || (rand_int(100) < 50))))
+ if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
{
o_ptr->to_d++;
res = TRUE;
else if (o_ptr->to_a > 15) chance = 1000;
else chance = enchant_table[o_ptr->to_a];
- if (force || ((randint(1000) > chance) && (!a || (rand_int(100) < 50))))
+ if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
{
o_ptr->to_a++;
res = TRUE;
msg_print("The enchantment failed.");
#endif
- if (randint(3)==1) chg_virtue(V_ENCHANT, -1);
+ if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
}
else
chg_virtue(V_ENCHANT, 1);
msg_print("The enchantment failed.");
#endif
- if (randint(3)==1) chg_virtue(V_ENCHANT, -1);
+ if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
}
else
chg_virtue(V_ENCHANT, 1);
/*
* Identify an object
*/
-void identify_item(object_type *o_ptr)
+bool identify_item(object_type *o_ptr)
{
- bool motoart = TRUE;
+ bool old_known = FALSE;
char o_name[MAX_NLEN];
/* Description */
object_desc(o_name, o_ptr, TRUE, 3);
- if ((artifact_p(o_ptr) || o_ptr->art_name) && !(o_ptr->ident & IDENT_KNOWN))
- motoart = FALSE;
+ if (o_ptr->ident & IDENT_KNOWN)
+ old_known = TRUE;
if (!(o_ptr->ident & (IDENT_MENTAL)))
{
/* Description */
object_desc(o_name, o_ptr, TRUE, 0);
- if(record_fix_art && !motoart && artifact_p(o_ptr))
+ if(record_fix_art && !old_known && artifact_p(o_ptr))
do_cmd_write_nikki(NIKKI_ART, 0, o_name);
- if(record_rand_art && !motoart && o_ptr->art_name)
+ if(record_rand_art && !old_known && o_ptr->art_name)
do_cmd_write_nikki(NIKKI_ART, 0, o_name);
+
+ return old_known;
}
object_type *o_ptr;
char o_name[MAX_NLEN];
cptr q, s;
+ bool old_known;
+ int idx;
item_tester_no_ryoute = TRUE;
}
/* Identify it */
- identify_item(o_ptr);
+ old_known = identify_item(o_ptr);
/* Description */
object_desc(o_name, o_ptr, TRUE, 3);
if (item >= INVEN_RARM)
{
#ifdef JP
-msg_format("%^s: %s(%c)¡£",
+ msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
#else
- msg_format("%^s: %s (%c).",
+ msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
#endif
-
- describe_use(item), o_name, index_to_label(item));
}
else if (item >= 0)
{
#ifdef JP
-msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£",
+ msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
#else
- msg_format("In your pack: %s (%c).",
+ msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
#endif
-
- o_name, index_to_label(item));
}
else
{
#ifdef JP
-msg_format("¾²¾å: %s¡£",
+ msg_format("¾²¾å: %s¡£", o_name);
#else
- msg_format("On the ground: %s.",
+ msg_format("On the ground: %s.", o_name);
#endif
-
- o_name);
}
+ /* Auto-inscription/destroy */
+ idx = is_autopick(o_ptr);
+ auto_inscribe_item(item, idx);
+ if (!old_known) auto_destroy_item(item, idx);
+
/* Something happened */
return (TRUE);
}
object_type *o_ptr;
char o_name[MAX_NLEN];
cptr q, s;
+ bool old_known;
+ int idx;
item_tester_no_ryoute = TRUE;
if (only_equip)
}
/* Identify it */
- identify_item(o_ptr);
+ old_known = identify_item(o_ptr);
/* Mark the item as fully known */
o_ptr->ident |= (IDENT_MENTAL);
if (item >= INVEN_RARM)
{
#ifdef JP
-msg_format("%^s: %s(%c)¡£",
+ msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
#else
- msg_format("%^s: %s (%c).",
+ msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
#endif
- describe_use(item), o_name, index_to_label(item));
+
}
else if (item >= 0)
{
#ifdef JP
-msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£",
+ msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
#else
- msg_format("In your pack: %s (%c).",
+ msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
#endif
-
- o_name, index_to_label(item));
}
else
{
#ifdef JP
-msg_format("¾²¾å: %s¡£",
+ msg_format("¾²¾å: %s¡£", o_name);
#else
- msg_format("On the ground: %s.",
+ msg_format("On the ground: %s.", o_name);
#endif
-
- o_name);
}
/* Describe it fully */
(void)identify_fully_aux(o_ptr);
+ /* Auto-inscription/destroy */
+ idx = is_autopick(o_ptr);
+ auto_inscribe_item(item, idx);
+ if (!old_known) auto_destroy_item(item, idx);
+
/* Success */
return (TRUE);
}
/* Back-fire */
- if (rand_int(recharge_strength) == 0)
+ if (one_in_(recharge_strength))
{
/* Activate the failure code. */
fail = TRUE;
if (recharge_strength < 0) recharge_strength = 0;
/* Back-fire */
- if (rand_int(recharge_strength) == 0)
+ if (one_in_(recharge_strength))
{
/* Activate the failure code. */
fail = TRUE;
else
{
/* Recharge based on the standard number of charges. */
- recharge_amount = randint(1 + k_ptr->pval / 2);
+ recharge_amount = randint1(1 + k_ptr->pval / 2);
/* Multiple wands in a stack increase recharging somewhat. */
if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
{
recharge_amount +=
- (randint(recharge_amount * (o_ptr->number - 1))) / 2;
+ (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
if (recharge_amount < 1) recharge_amount = 1;
if (recharge_amount > 12) recharge_amount = 12;
}
/* 10% chance to blow up one rod, otherwise draining. */
if (o_ptr->tval == TV_ROD)
{
- if (randint(10) == 1) fail_type = 2;
+ if (one_in_(10)) fail_type = 2;
else fail_type = 1;
}
/* 75% chance to blow up one wand, otherwise draining. */
else if (o_ptr->tval == TV_WAND)
{
- if (randint(3) != 1) fail_type = 2;
+ if (!one_in_(3)) fail_type = 2;
else fail_type = 1;
}
/* 50% chance to blow up one staff, otherwise no effect. */
else if (o_ptr->tval == TV_STAFF)
{
- if (randint(2) == 1) fail_type = 2;
+ if (one_in_(2)) fail_type = 2;
else fail_type = 0;
}
}
/* 33% chance to blow up one rod, otherwise draining. */
if (o_ptr->tval == TV_ROD)
{
- if (randint(3) == 1) fail_type = 2;
+ if (one_in_(3)) fail_type = 2;
else fail_type = 1;
}
/* 20% chance of the entire stack, else destroy one wand. */
else if (o_ptr->tval == TV_WAND)
{
- if (randint(5) == 1) fail_type = 3;
+ if (one_in_(5)) fail_type = 3;
else fail_type = 2;
}
/* Blow up one staff. */
if (o_ptr->tval == TV_ROD)
{
#ifdef JP
-msg_print("ËâÎϤòµÛ¤¤¼è¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£¥í¥Ã¥É¤ÎËâÎϤÏÁ´¤Æȯ»¶¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
+msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
#else
- msg_print("You failed to absorb magic power. All magic power of your rod had gone!");
+ msg_print("The recharge backfires, draining the rod further!");
#endif
if (o_ptr->timeout < 10000)
/* Extract the flags */
object_flags(o_ptr, &f1, &f2, &f3);
- if (o_ptr->ident & IDENT_CURSED)
+ if (cursed_p(o_ptr))
{
- if (((f3 & TR3_HEAVY_CURSE) && (randint(100) < 33)) ||
- (f3 & TR3_PERMA_CURSE))
+ if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
+ (o_ptr->curse_flags & TRC_PERMA_CURSE))
{
#ifdef JP
msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
/* Uncurse it */
- o_ptr->ident &= ~(IDENT_CURSED);
+ o_ptr->curse_flags = 0L;
/* Hack -- Assume felt */
o_ptr->ident |= (IDENT_SENSE);
return TRUE;
}
- if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || (randint(3) == 1))
+ if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
{
/* Describe */
#ifdef JP
dis_happened = TRUE;
}
- if ((o_ptr->to_h > 5) && (rand_int(100) < 33)) o_ptr->to_h--;
+ if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
/* Disenchant todam */
if (o_ptr->to_d > 0)
dis_happened = TRUE;
}
- if ((o_ptr->to_d > 5) && (rand_int(100) < 33)) o_ptr->to_d--;
+ if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
/* Disenchant toac */
if (o_ptr->to_a > 0)
dis_happened = TRUE;
}
- if ((o_ptr->to_a > 5) && (rand_int(100) < 33)) o_ptr->to_a--;
+ if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
if (dis_happened)
{
((o_ptr->number > 1) ? "" : "s"));
#endif
o_ptr->name2 = EGO_REFLECTION;
- enchant(o_ptr, rand_int(3) + 4, ENCH_TOAC);
+ enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
o_ptr->discount = 99;
chg_virtue(V_ENCHANT, 2);
chance += 5 * (shouhimana - p_ptr->csp);
}
- if (p_ptr->pseikaku == SEIKAKU_NAMAKE) chance += 10;
- if (p_ptr->pseikaku == SEIKAKU_KIREMONO) chance -= 3;
- if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) chance++;
+ chance += p_ptr->to_m_chance;
if (((realm + 1) != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
/* Extract the minimum failure rate */
else if (p_ptr->dec_mana) chance-=2;
if ((realm+1 == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
- if ((realm+1 == REALM_LIFE) && (p_ptr->align < -20)) chance += penalty;
+ if (((realm+1 == REALM_LIFE) || (realm+1 == REALM_HAJA)) && (p_ptr->align < -20)) chance += penalty;
if (((realm+1 == REALM_DEATH) || (realm+1 == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
/* Minimum failure rate */
#ifdef JP
case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
#else
- case 28: sprintf(p, " dam %d each", plev * 2); break;
+ case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
#endif
}
break;
}
break;
+ case 9: /* Haja */
+ switch (spell)
+ {
+ case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
+ case 6: sprintf(p, " %s%d", s_range, plev*3); break;
+#ifdef JP
+ case 7: sprintf(p, " %s³Æ%dd3", s_dam, 3+((plev-1)/8)); break;
+#else
+ case 7: sprintf(p, " %s%dd3 each", s_dam, 3+((plev-1)/8)); break;
+#endif
+ case 10: sprintf(p, " %sd%d", s_dam, plev); break;
+ case 11: sprintf(p, " %s3d6+%d", s_dam, orb); break;
+ case 12: sprintf(p, " %s24+d24", s_dur); break;
+ case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
+ case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
+#ifdef JP
+ case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
+#else
+ case 15: sprintf(p, " d %d/h 100", 6 * plev); break;
+#endif
+ case 18: sprintf(p, " %s18+d18", s_dur); break;
+ case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
+ case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
+ case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
+ case 28: sprintf(p, " %s10+d10", s_dur); break;
+#ifdef JP
+ case 29: sprintf(p, " %s³Æ%d", s_dam, plev*4); break;
+#else
+ case 29: sprintf(p, " %s%d each", s_dam, plev*4); break;
+#endif
+#ifdef JP
+ case 30: sprintf(p, " ²ó100/»%d+250", plev * 4); break;
+#else
+ case 30: sprintf(p, " h100/d%d+250", plev * 4); break;
+#endif
+ }
+ break;
+
case 15: /* Music */
switch (spell)
{
case TV_ARCANE_BOOK:
case TV_ENCHANT_BOOK:
case TV_DAEMON_BOOK:
+ case TV_HAJA_BOOK:
case TV_MUSIC_BOOK:
case TV_HISSATSU_BOOK:
{
/* Count the casualties */
for (amt = j = 0; j < o_ptr->number; ++j)
{
- if (rand_int(100) < perc) amt++;
+ if (randint0(100) < perc) amt++;
}
/* Some casualities */
/* Pick a (possibly empty) inventory slot */
- switch (randint(7))
+ switch (randint1(7))
{
case 1: o_ptr = &inventory[INVEN_RARM]; break;
case 2: o_ptr = &inventory[INVEN_LARM]; break;
if (double_resist) dam = (dam + 2) / 3;
if ((!(double_resist || p_ptr->resist_acid)) &&
- randint(HURT_CHANCE) == 1)
+ one_in_(HURT_CHANCE))
(void)do_dec_stat(A_CHR);
/* If any armor gets hit, defend the player */
if (double_resist) dam = (dam + 2) / 3;
if ((!(double_resist || p_ptr->resist_elec)) &&
- randint(HURT_CHANCE) == 1)
+ one_in_(HURT_CHANCE))
(void)do_dec_stat(A_DEX);
/* Take damage */
if (double_resist) dam = (dam + 2) / 3;
if ((!(double_resist || p_ptr->resist_fire)) &&
- randint(HURT_CHANCE) == 1)
+ one_in_(HURT_CHANCE))
(void)do_dec_stat(A_STR);
/* Take damage */
if (double_resist) dam = (dam + 2) / 3;
if ((!(double_resist || p_ptr->resist_cold)) &&
- randint(HURT_CHANCE) == 1)
+ one_in_(HURT_CHANCE))
(void)do_dec_stat(A_STR);
/* Take damage */
o_ptr->art_flags3 |= TR3_IGNORE_ACID;
- if ((o_ptr->to_a < 0) && !(o_ptr->ident & IDENT_CURSED))
+ if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
{
#ifdef JP
msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
object_desc(o_name, o_ptr, FALSE, 3);
/* Attempt a saving throw for artifacts */
- if ((o_ptr->art_name || artifact_p(o_ptr)) && (rand_int(100) < 50))
+ if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
{
/* Cool */
#ifdef JP
/* Blast the armor */
o_ptr->name1 = 0;
o_ptr->name2 = EGO_BLASTED;
- o_ptr->to_a = 0 - randint(5) - randint(5);
+ o_ptr->to_a = 0 - randint1(5) - randint1(5);
o_ptr->to_h = 0;
o_ptr->to_d = 0;
o_ptr->ac = 0;
o_ptr->art_flags3 = 0;
/* Curse it */
- o_ptr->ident |= (IDENT_CURSED);
+ o_ptr->curse_flags = TRC_CURSED;
/* Break it */
o_ptr->ident |= (IDENT_BROKEN);
object_desc(o_name, o_ptr, FALSE, 3);
/* Attempt a saving throw */
- if ((artifact_p(o_ptr) || o_ptr->art_name) && (rand_int(100) < 50) && !force)
+ if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
{
/* Cool */
#ifdef JP
/* Shatter the weapon */
o_ptr->name1 = 0;
o_ptr->name2 = EGO_SHATTERED;
- o_ptr->to_h = 0 - randint(5) - randint(5);
- o_ptr->to_d = 0 - randint(5) - randint(5);
+ o_ptr->to_h = 0 - randint1(5) - randint1(5);
+ o_ptr->to_d = 0 - randint1(5) - randint1(5);
o_ptr->to_a = 0;
o_ptr->ac = 0;
o_ptr->dd = 0;
/* Curse it */
- o_ptr->ident |= (IDENT_CURSED);
+ o_ptr->curse_flags = TRC_CURSED;
/* Break it */
o_ptr->ident |= (IDENT_BROKEN);
if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
/* Randomize */
- if (rand_int(100) < 75) continue;
+ if (randint0(100) < 75) continue;
/* Message */
#ifdef JP
o_ptr->name2 = EGO_FLAME;
/* Enchant */
- enchant(o_ptr, rand_int(3) + 4, ENCH_TOHIT | ENCH_TODAM);
+ enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
/* Notice */
return (TRUE);
return (r_idx);
/* Allowable range of "levels" for resulting monster */
- lev1 = r_ptr->level - ((randint(20) / randint(9)) + 1);
- lev2 = r_ptr->level + ((randint(20) / randint(9)) + 1);
+ lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
+ lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
/* Pick a (possibly new) non-unique race */
for (i = 0; i < 1000; i++)
{
cave_type *c_ptr = &cave[y][x];
monster_type *m_ptr = &m_list[c_ptr->m_idx];
- bool friendly, pet;
bool polymorphed = FALSE;
int new_r_idx;
int old_r_idx = m_ptr->r_idx;
+ bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
+ bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
+ monster_type back_m;
if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG_KAGE)) return (FALSE);
- /* Get the monsters attitude */
- friendly = is_friendly(m_ptr);
- pet = is_pet(m_ptr);
+ /* Memorize the monster before polymorphing */
+ back_m = *m_ptr;
/* Pick a "new" monster race */
new_r_idx = poly_r_idx(old_r_idx);
/* Handle polymorph */
if (new_r_idx != old_r_idx)
{
+ u32b mode = 0L;
+
+ /* Get the monsters attitude */
+ if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
+ if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
+ if (m_ptr->mflag2 & MFLAG_NOPET) mode |= PM_NO_PET;
+
/* "Kill" the "old" monster */
delete_monster_idx(c_ptr->m_idx);
/* Create a new monster (no groups) */
- if (place_monster_aux(y, x, new_r_idx, FALSE, FALSE, friendly, pet, FALSE, (bool)(m_ptr->mflag2 & MFLAG_NOPET)))
+ if (place_monster_aux(0, y, x, new_r_idx, mode))
{
/* Success */
polymorphed = TRUE;
monster_terrain_sensitive = FALSE;
/* Placing the new monster failed */
- place_monster_aux(y, x, old_r_idx, FALSE, FALSE, friendly, pet, TRUE, (bool)(m_ptr->mflag2 & MFLAG_NOPET));
+ place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE));
+ m_list[hack_m_idx_ii] = back_m;
monster_terrain_sensitive = TRUE;
}
+
+ if (targeted) target_who = hack_m_idx_ii;
+ if (health_tracked) health_track(hack_m_idx_ii);
}
return polymorphed;
if (!tgt_pt(&x, &y)) return FALSE;
- p_ptr->energy -= 60 - plev;
+ p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
(distance(y, x, py, px) > plev / 2 + 10) ||
- (!rand_int(plev / 10 + 10)))
+ (!randint0(plev / 10 + 10)))
{
- if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
+ if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
#ifdef JP
-msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
+ msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
#else
- msg_print("You fail to exit the astral plane correctly!");
+ msg_print("You fail to exit the astral plane correctly!");
#endif
- }
- else {
+ }
+ else
+ {
#ifdef JP
-msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
+ msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
#else
- msg_print("You fail to exit the astral plane correctly!");
+ msg_print("You fail to exit the astral plane correctly!");
#endif
- }
- p_ptr->energy -= 60 - plev;
+ }
+ p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
teleport_player((plev+2)*2);
}
- else teleport_player_to(y, x, TRUE);
+ else
+ teleport_player_to(y, x, TRUE);
return (TRUE);
}
recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
/* Back-fire */
- if (rand_int(recharge_strength) == 0)
+ if (one_in_(recharge_strength))
{
/* Activate the failure code. */
fail = TRUE;
if (recharge_strength < 0) recharge_strength = 0;
/* Back-fire */
- if (rand_int(recharge_strength) == 0)
+ if (one_in_(recharge_strength))
{
/* Activate the failure code. */
fail = TRUE;
/* 10% chance to blow up one rod, otherwise draining. */
if (o_ptr->tval == TV_ROD)
{
- if (randint(10) == 1) fail_type = 2;
+ if (one_in_(10)) fail_type = 2;
else fail_type = 1;
}
/* 75% chance to blow up one wand, otherwise draining. */
else if (o_ptr->tval == TV_WAND)
{
- if (randint(3) != 1) fail_type = 2;
+ if (!one_in_(3)) fail_type = 2;
else fail_type = 1;
}
/* 50% chance to blow up one staff, otherwise no effect. */
else if (o_ptr->tval == TV_STAFF)
{
- if (randint(2) == 1) fail_type = 2;
+ if (one_in_(2)) fail_type = 2;
else fail_type = 0;
}
}
/* 33% chance to blow up one rod, otherwise draining. */
if (o_ptr->tval == TV_ROD)
{
- if (randint(3) == 1) fail_type = 2;
+ if (one_in_(3)) fail_type = 2;
else fail_type = 1;
}
/* 20% chance of the entire stack, else destroy one wand. */
else if (o_ptr->tval == TV_WAND)
{
- if (randint(5) == 1) fail_type = 3;
+ if (one_in_(5)) fail_type = 3;
else fail_type = 2;
}
/* Blow up one staff. */
if (o_ptr->tval == TV_ROD)
{
#ifdef JP
-msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
+msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
#else
- msg_print("The recharge backfires, draining the rod further!");
+ msg_format("You save your rod from destruction, but all charges are lost.", o_name);
#endif
o_ptr->timeout = k_ptr->pval * o_ptr->number;
}
-bool summon_kin_player(bool pet, int level, int y, int x, bool group)
+//bool summon_kin_player(bool pet, int level, int y, int x, bool group)
+bool summon_kin_player(int level, int y, int x, u32b mode)
{
+ bool pet = (bool)(mode & PM_FORCE_PET);
+ if (!pet) mode |= PM_NO_PET;
+
switch (p_ptr->mimic_form)
{
case MIMIC_NONE:
summon_kin_type = 'V';
break;
}
- return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, group, FALSE, pet, FALSE, (bool)(!pet));
+ return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
}