/* Percentile dice */
k = randint0(100);
-
+
+ /* Snipers with high-concentration reduce instant miss percentage.*/
+ k += p_ptr->concent;
+
/* Hack -- Instant miss or hit */
if (k < 10) return (k < 5);
* Critical hits (from objects thrown by player)
* Factor in item weight, total plusses, and player level.
*/
-s16b critical_shot(int weight, int plus, int dam)
+s16b critical_shot(int weight, int plus_ammo, int plus_bow, int dam)
{
int i, k;
-
+ object_type *j_ptr = &inventory[INVEN_BOW];
+
/* Extract "shot" power */
- i = ((p_ptr->to_h_b + plus) * 4) + (p_ptr->lev * 2);
+ i = p_ptr->to_h_b + plus_ammo;
+
+ if (p_ptr->tval_ammo == TV_BOLT)
+ i = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
+ else
+ i = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
+
/* Snipers can shot more critically with crossbows */
if (p_ptr->concent) i += ((i * p_ptr->concent) / 5);
if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->tval_ammo == TV_BOLT)) i *= 2;
-
+
+ /* Good bow makes more critical */
+ i += MAX(0, plus_bow - 15) * 4 * (p_ptr->concent ? p_ptr->concent + 5 : 5);
+
/* Critical hit */
- if (randint1(5000) <= i)
+ if (randint1(6000) <= i)
{
k = weight * randint1(500);
+static int mult_slaying(int mult, const u32b* flgs, const monster_type* m_ptr)
+{
+ static const struct slay_table_t {
+ int slay_flag;
+ u32b affect_race_flag;
+ int slay_mult;
+ size_t flag_offset;
+ size_t r_flag_offset;
+ } slay_table[] = {
+#define OFFSET(X) offsetof(monster_race, X)
+ {TR_SLAY_ANIMAL, RF3_ANIMAL, 25, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_KILL_ANIMAL, RF3_ANIMAL, 40, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_SLAY_EVIL, RF3_EVIL, 20, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_KILL_EVIL, RF3_EVIL, 35, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_SLAY_GOOD, RF3_GOOD, 20, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_KILL_GOOD, RF3_GOOD, 35, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_SLAY_HUMAN, RF2_HUMAN, 25, OFFSET(flags2), OFFSET(r_flags2)},
+ {TR_KILL_HUMAN, RF2_HUMAN, 40, OFFSET(flags2), OFFSET(r_flags2)},
+ {TR_SLAY_UNDEAD, RF3_UNDEAD, 30, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_KILL_UNDEAD, RF3_UNDEAD, 50, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_SLAY_DEMON, RF3_DEMON, 30, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_KILL_DEMON, RF3_DEMON, 50, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_SLAY_ORC, RF3_ORC, 30, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_KILL_ORC, RF3_ORC, 50, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_SLAY_TROLL, RF3_TROLL, 30, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_KILL_TROLL, RF3_TROLL, 50, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_SLAY_GIANT, RF3_GIANT, 30, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_KILL_GIANT, RF3_GIANT, 50, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_SLAY_DRAGON, RF3_DRAGON, 30, OFFSET(flags3), OFFSET(r_flags3)},
+ {TR_KILL_DRAGON, RF3_DRAGON, 50, OFFSET(flags3), OFFSET(r_flags3)},
+#undef OFFSET
+ };
+ int i;
+ monster_race* r_ptr = &r_info[m_ptr->r_idx];
+
+ for (i = 0; i < sizeof(slay_table) / sizeof(slay_table[0]); ++ i)
+ {
+ const struct slay_table_t* p = &slay_table[i];
+
+ if ((have_flag(flgs, p->slay_flag)) &&
+ (atoffset(u32b, r_ptr, p->flag_offset) & p->affect_race_flag))
+ {
+ if (is_original_ap_and_seen(m_ptr))
+ {
+ atoffset(u32b, r_ptr, p->r_flag_offset) |= p->affect_race_flag;
+ }
+
+ mult = MAX(mult, p->slay_mult);
+ }
+ }
+
+ return mult;
+}
+
+static int mult_brand(int mult, const u32b* flgs, const monster_type* m_ptr)
+{
+ static const struct brand_table_t {
+ int brand_flag;
+ u32b resist_mask;
+ u32b hurt_flag;
+ } brand_table[] = {
+ {TR_BRAND_ACID, RFR_EFF_IM_ACID_MASK, 0U },
+ {TR_BRAND_ELEC, RFR_EFF_IM_ELEC_MASK, 0U },
+ {TR_BRAND_FIRE, RFR_EFF_IM_FIRE_MASK, RF3_HURT_FIRE},
+ {TR_BRAND_COLD, RFR_EFF_IM_COLD_MASK, RF3_HURT_COLD},
+ {TR_BRAND_POIS, RFR_EFF_IM_POIS_MASK, 0U },
+ };
+ int i;
+ monster_race* r_ptr = &r_info[m_ptr->r_idx];
+
+ for (i = 0; i < sizeof(brand_table) / sizeof(brand_table[0]); ++ i)
+ {
+ const struct brand_table_t* p = &brand_table[i];
+
+ if (have_flag(flgs, p->brand_flag))
+ {
+ /* Notice immunity */
+ if (r_ptr->flagsr & p->resist_mask)
+ {
+ if (is_original_ap_and_seen(m_ptr))
+ {
+ r_ptr->r_flagsr |= (r_ptr->flagsr & p->resist_mask);
+ }
+ }
+
+ /* Otherwise, take the damage */
+ else if (r_ptr->flags3 & p->hurt_flag)
+ {
+ if (is_original_ap_and_seen(m_ptr))
+ {
+ r_ptr->r_flags3 |= p->hurt_flag;
+ }
+
+ mult = MAX(mult, 50);
+ }
+ else
+ {
+ mult = MAX(mult, 25);
+ }
+ }
+ }
+
+ return mult;
+}
/*
* Extract the "total damage" from a given object hitting a given monster.
*
{
int mult = 10;
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
u32b flgs[TR_FLAG_SIZE];
/* Extract the flags */
object_flags(o_ptr, flgs);
+ torch_flags(o_ptr, flgs); /* torches has secret flags */
if (!thrown)
{
if (p_ptr->special_attack & (ATTACK_POIS)) add_flag(flgs, TR_BRAND_POIS);
}
+ /* Hex - Slay Good (Runesword) */
+ if (hex_spelling(HEX_RUNESWORD)) add_flag(flgs, TR_SLAY_GOOD);
+
/* Some "weapons" and "ammo" do extra damage */
switch (o_ptr->tval)
{
case TV_POLEARM:
case TV_SWORD:
case TV_DIGGING:
+ case TV_LITE:
{
- /* Slay Animal */
- if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
- (r_ptr->flags3 & RF3_ANIMAL))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_ANIMAL;
- }
-
- if (mult < 25) mult = 25;
- }
-
- /* Execute Animal */
- if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
- (r_ptr->flags3 & RF3_ANIMAL))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_ANIMAL;
- }
-
- if (mult < 40) mult = 40;
- }
-
- /* Slay Evil */
- if ((have_flag(flgs, TR_SLAY_EVIL)) &&
- (r_ptr->flags3 & RF3_EVIL))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_EVIL;
- }
-
- if (mult < 20) mult = 20;
- }
-
- /* Execute Evil */
- if ((have_flag(flgs, TR_KILL_EVIL)) &&
- (r_ptr->flags3 & RF3_EVIL))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_EVIL;
- }
-
- if (mult < 35) mult = 35;
- }
-
- /* Slay Human */
- if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
- (r_ptr->flags2 & RF2_HUMAN))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags2 |= RF2_HUMAN;
- }
-
- if (mult < 25) mult = 25;
- }
-
- /* Execute Human */
- if ((have_flag(flgs, TR_KILL_HUMAN)) &&
- (r_ptr->flags2 & RF2_HUMAN))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags2 |= RF2_HUMAN;
- }
-
- if (mult < 40) mult = 40;
- }
-
- /* Slay Undead */
- if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
- (r_ptr->flags3 & RF3_UNDEAD))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_UNDEAD;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Execute Undead */
- if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
- (r_ptr->flags3 & RF3_UNDEAD))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_UNDEAD;
- }
-
- if (mult < 50) mult = 50;
- }
-
- /* Slay Demon */
- if ((have_flag(flgs, TR_SLAY_DEMON)) &&
- (r_ptr->flags3 & RF3_DEMON))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_DEMON;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Execute Demon */
- if ((have_flag(flgs, TR_KILL_DEMON)) &&
- (r_ptr->flags3 & RF3_DEMON))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_DEMON;
- }
-
- if (mult < 50) mult = 50;
- }
-
- /* Slay Orc */
- if ((have_flag(flgs, TR_SLAY_ORC)) &&
- (r_ptr->flags3 & RF3_ORC))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_ORC;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Execute Orc */
- if ((have_flag(flgs, TR_KILL_ORC)) &&
- (r_ptr->flags3 & RF3_ORC))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_ORC;
- }
-
- if (mult < 50) mult = 50;
- }
-
- /* Slay Troll */
- if ((have_flag(flgs, TR_SLAY_TROLL)) &&
- (r_ptr->flags3 & RF3_TROLL))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_TROLL;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Execute Troll */
- if ((have_flag(flgs, TR_KILL_TROLL)) &&
- (r_ptr->flags3 & RF3_TROLL))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_TROLL;
- }
-
- if (mult < 50) mult = 50;
- }
-
- /* Slay Giant */
- if ((have_flag(flgs, TR_SLAY_GIANT)) &&
- (r_ptr->flags3 & RF3_GIANT))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_GIANT;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Execute Giant */
- if ((have_flag(flgs, TR_KILL_GIANT)) &&
- (r_ptr->flags3 & RF3_GIANT))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_GIANT;
- }
-
- if (mult < 50) mult = 50;
- }
-
- /* Slay Dragon */
- if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
- (r_ptr->flags3 & RF3_DRAGON))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_DRAGON;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Execute Dragon */
- if ((have_flag(flgs, TR_KILL_DRAGON)) &&
- (r_ptr->flags3 & RF3_DRAGON))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_DRAGON;
- }
-
- if (mult < 50) mult = 50;
-
- if ((o_ptr->name1 == ART_NOTHUNG) && (m_ptr->r_idx == MON_FAFNER))
- mult *= 3;
- }
-
- /* Hex - Slay Good (Runesword) */
- if (hex_spelling(HEX_RUNESWORD) &&
- (r_ptr->flags3 & RF3_GOOD))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_GOOD;
- }
-
- if (mult < 20) mult = 20;
- }
-
- /* Brand (Acid) */
- if (have_flag(flgs, TR_BRAND_ACID))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
- }
- }
+ /* Slaying */
+ mult = mult_slaying(mult, flgs, m_ptr);
- /* Otherwise, take the damage */
- else
- {
- if (mult < 25) mult = 25;
- }
- }
-
- /* Brand (Elec) */
- if (have_flag(flgs, TR_BRAND_ELEC))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
- }
- }
-
- /* Otherwise, take the damage */
- else
- {
- if (mult < 25) mult = 25;
- }
- }
-
- /* Brand (Fire) */
- if (have_flag(flgs, TR_BRAND_FIRE))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
- }
- }
-
- /* Otherwise, take the damage */
- else
- {
- if (r_ptr->flags3 & RF3_HURT_FIRE)
- {
- if (mult < 50) mult = 50;
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_HURT_FIRE;
- }
- }
- else if (mult < 25) mult = 25;
- }
- }
-
- /* Brand (Cold) */
- if (have_flag(flgs, TR_BRAND_COLD))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
- }
- }
- /* Otherwise, take the damage */
- else
- {
- if (r_ptr->flags3 & RF3_HURT_COLD)
- {
- if (mult < 50) mult = 50;
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_HURT_COLD;
- }
- }
- else if (mult < 25) mult = 25;
- }
- }
-
- /* Brand (Poison) */
- if (have_flag(flgs, TR_BRAND_POIS))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
- }
- }
-
- /* Otherwise, take the damage */
- else
- {
- if (mult < 25) mult = 25;
- }
- }
+ /* Elemental Brand */
+ mult = mult_brand(mult, flgs, m_ptr);
/* Hissatsu */
if (p_ptr->pclass == CLASS_SAMURAI)
mult = mult_hissatsu(mult, flgs, m_ptr, mode);
}
+ /* Force Weapon */
if ((p_ptr->pclass != CLASS_SAMURAI) && (have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
{
p_ptr->csp -= (1+(o_ptr->dd * o_ptr->ds / 5));
p_ptr->redraw |= (PR_MANA);
mult = mult * 3 / 2 + 20;
}
+
+ /* Hack -- The Nothung cause special damage to Fafner */
+ if ((o_ptr->name1 == ART_NOTHUNG) && (m_ptr->r_idx == MON_FAFNER))
+ mult = 150;
break;
}
}
/*
* Search for hidden things
*/
-void search(void)
+static void discover_hidden_things(int y, int x)
{
- int y, x, chance;
-
s16b this_o_idx, next_o_idx = 0;
cave_type *c_ptr;
+ /* Access the grid */
+ c_ptr = &cave[y][x];
- /* Start with base search ability */
- chance = p_ptr->skill_srh;
+ /* Invisible trap */
+ if (c_ptr->mimic && is_trap(c_ptr->feat))
+ {
+ /* Pick a trap */
+ disclose_grid(y, x);
- /* Penalize various conditions */
- if (p_ptr->blind || no_lite()) chance = chance / 10;
- if (p_ptr->confused || p_ptr->image) chance = chance / 10;
+ /* Message */
+ msg_print(_("¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡£", "You have found a trap."));
- /* Search the nearby grids, which are always in bounds */
- for (y = (py - 1); y <= (py + 1); y++)
+ /* Disturb */
+ disturb(0, 1);
+ }
+
+ /* Secret door */
+ if (is_hidden_door(c_ptr))
{
- for (x = (px - 1); x <= (px + 1); x++)
- {
- /* Sometimes, notice things */
- if (randint0(100) < chance)
- {
- /* Access the grid */
- c_ptr = &cave[y][x];
+ /* Message */
+ msg_print(_("±£¤·¥É¥¢¤òȯ¸«¤·¤¿¡£", "You have found a secret door."));
- /* Invisible trap */
- if (c_ptr->mimic && is_trap(c_ptr->feat))
- {
- /* Pick a trap */
- disclose_grid(y, x);
+ /* Disclose */
+ disclose_grid(y, x);
- /* Message */
-#ifdef JP
- msg_print("¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡£");
-#else
- msg_print("You have found a trap.");
-#endif
+ /* Disturb */
+ disturb(0, 0);
+ }
- /* Disturb */
- disturb(0, 1);
- }
+ /* Scan all objects in the grid */
+ for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+ {
+ object_type *o_ptr;
- /* Secret door */
- if (is_hidden_door(c_ptr))
- {
- /* Message */
-#ifdef JP
- msg_print("±£¤·¥É¥¢¤òȯ¸«¤·¤¿¡£");
-#else
- msg_print("You have found a secret door.");
-#endif
+ /* Acquire object */
+ o_ptr = &o_list[this_o_idx];
- /* Disclose */
- disclose_grid(y, x);
+ /* Acquire next object */
+ next_o_idx = o_ptr->next_o_idx;
- /* Disturb */
- disturb(0, 0);
- }
+ /* Skip non-chests */
+ if (o_ptr->tval != TV_CHEST) continue;
- /* Scan all objects in the grid */
- for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
- {
- object_type *o_ptr;
+ /* Skip non-trapped chests */
+ if (!chest_traps[o_ptr->pval]) continue;
- /* Acquire object */
- o_ptr = &o_list[this_o_idx];
+ /* Identify once */
+ if (!object_is_known(o_ptr))
+ {
+ /* Message */
+ msg_print(_("È¢¤Ë»Å³Ý¤±¤é¤ì¤¿¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡ª", "You have discovered a trap on the chest!"));
- /* Acquire next object */
- next_o_idx = o_ptr->next_o_idx;
+ /* Know the trap */
+ object_known(o_ptr);
- /* Skip non-chests */
- if (o_ptr->tval != TV_CHEST) continue;
+ /* Notice it */
+ disturb(0, 0);
+ }
+ }
+}
- /* Skip non-trapped chests */
- if (!chest_traps[o_ptr->pval]) continue;
+void search(void)
+{
+ int i, chance;
- /* Identify once */
- if (!object_is_known(o_ptr))
- {
- /* Message */
-#ifdef JP
- msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤¿¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡ª");
-#else
- msg_print("You have discovered a trap on the chest!");
-#endif
+ /* Start with base search ability */
+ chance = p_ptr->skill_srh;
- /* Know the trap */
- object_known(o_ptr);
+ /* Penalize various conditions */
+ if (p_ptr->blind || no_lite()) chance = chance / 10;
+ if (p_ptr->confused || p_ptr->image) chance = chance / 10;
- /* Notice it */
- disturb(0, 0);
- }
- }
- }
+ /* Search the nearby grids, which are always in bounds */
+ for (i = 0; i < 9; ++ i)
+ {
+ /* Sometimes, notice things */
+ if (randint0(100) < chance)
+ {
+ discover_hidden_things(py + ddy_ddd[i], px + ddx_ddd[i]);
}
}
}
*/
void py_pickup_aux(int o_idx)
{
- int slot, i;
+ int slot;
#ifdef JP
/*
record_turn = turn;
- /* Check if completed a quest */
- for (i = 0; i < max_quests; i++)
- {
- if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
- (quest[i].status == QUEST_STATUS_TAKEN) &&
- (quest[i].k_idx == o_ptr->name1))
- {
- if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
- quest[i].status = QUEST_STATUS_COMPLETED;
- quest[i].complev = (byte)p_ptr->lev;
-#ifdef JP
- msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
-#else
- msg_print("You completed your quest!");
-#endif
-
- msg_print(NULL);
- }
- }
+ check_find_art_quest_completion(o_ptr);
}
/* Paranoia -- No power */
if (power <= 0) return (FALSE);
- /* Total armor */
- ac = p_ptr->ac + p_ptr->to_a;
+ /* Total armor */
+ ac = p_ptr->ac + p_ptr->to_a;
+
+ /* Power competes against Armor */
+ if (randint1(power) > ((ac * 3) / 4)) return (TRUE);
+
+ /* Assume miss */
+ return (FALSE);
+}
+
+
+
+static void hit_trap_pit(int trap_feat_type)
+{
+ int dam;
+ cptr trap_name = "";
+ cptr spike_name = "";
+
+ switch (trap_feat_type)
+ {
+ case TRAP_PIT:
+ trap_name = _("Íî¤È¤··ê", "a pit trap");
+ break;
+ case TRAP_SPIKED_PIT:
+ trap_name = _("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Íî¤È¤··ê", "a spiked pit");
+ spike_name = _("¥¹¥Ñ¥¤¥¯", "spikes");
+ break;
+ case TRAP_POISON_PIT:
+ trap_name = _("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Íî¤È¤··ê", "a spiked pit");
+ spike_name = _("ÆǤòÅɤé¤ì¤¿¥¹¥Ñ¥¤¥¯", "poisonous spikes");
+ break;
+ default:
+ return;
+ }
+
+ if (p_ptr->levitation)
+ {
+ msg_format(_("%s¤òÈô¤Ó±Û¤¨¤¿¡£", "You fly over %s."), trap_name);
+ return;
+ }
+
+ msg_format(_("%s¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª", "You have fallen into %s!"), trap_name);
+
+ /* Base damage */
+ dam = damroll(2, 6);
+
+ /* Extra spike damage */
+ if ((trap_feat_type == TRAP_SPIKED_PIT || trap_feat_type == TRAP_POISON_PIT) &&
+ one_in_(2))
+ {
+ msg_format(_("%s¤¬»É¤µ¤Ã¤¿¡ª", "You are impaled on %s!"), spike_name);
+
+ dam = dam * 2;
+ (void)set_cut(p_ptr->cut + randint1(dam));
+
+ if (trap_feat_type == TRAP_POISON_PIT) {
+ if (p_ptr->resist_pois || IS_OPPOSE_POIS())
+ {
+ msg_print(_("¤·¤«¤·ÆǤαƶÁ¤Ï¤Ê¤«¤Ã¤¿¡ª", "The poison does not affect you!"));
+ }
+ else
+ {
+ dam = dam * 2;
+ (void)set_poisoned(p_ptr->poisoned + randint1(dam));
+ }
+ }
+ }
+
+ /* Take the damage */
+ take_hit(DAMAGE_NOESCAPE, dam, trap_name, -1);
+}
+
+static bool hit_trap_dart(void)
+{
+ bool hit = FALSE;
+
+ if (check_hit(125))
+ {
+ msg_print(_("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤Æ»É¤µ¤Ã¤¿¡ª", "A small dart hits you!"));
+
+ take_hit(DAMAGE_ATTACK, damroll(1, 4), _("¥À¡¼¥Ä¤Îæ«", "a dart trap"), -1);
+
+ if (!CHECK_MULTISHADOW()) hit = TRUE;
+ }
+ else
+ {
+ msg_print(_("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£", "A small dart barely misses you."));
+ }
- /* Power competes against Armor */
- if (randint1(power) > ((ac * 3) / 4)) return (TRUE);
+ return hit;
+}
- /* Assume miss */
- return (FALSE);
+static void hit_trap_lose_stat(int stat)
+{
+ if (hit_trap_dart())
+ {
+ do_dec_stat(stat);
+ }
+}
+
+static void hit_trap_slow(void)
+{
+ if (hit_trap_dart())
+ {
+ set_slow(p_ptr->slow + randint0(20) + 20, FALSE);
+ }
}
+static void hit_trap_set_abnormal_status(cptr trap_message, bool resist, bool (*set_status)(int turn), int turn)
+{
+ msg_print(trap_message);
+ if (!resist)
+ {
+ set_status(turn);
+ }
+}
/*
* Handle player hitting a real trap
}
case TRAP_PIT:
- {
- if (p_ptr->levitation)
- {
-#ifdef JP
- msg_print("Íî¤È¤··ê¤òÈô¤Ó±Û¤¨¤¿¡£");
-#else
- msg_print("You fly over a pit trap.");
-#endif
-
- }
- else
- {
-#ifdef JP
- msg_print("Íî¤È¤··ê¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª");
-#else
- msg_print("You have fallen into a pit!");
-#endif
-
- dam = damroll(2, 6);
-#ifdef JP
- name = "Íî¤È¤··ê";
-#else
- name = "a pit trap";
-#endif
-
- take_hit(DAMAGE_NOESCAPE, dam, name, -1);
- }
- break;
- }
-
case TRAP_SPIKED_PIT:
- {
- if (p_ptr->levitation)
- {
-#ifdef JP
- msg_print("¥È¥²¤Î¤¢¤ëÍî¤È¤··ê¤òÈô¤Ó±Û¤¨¤¿¡£");
-#else
- msg_print("You fly over a spiked pit.");
-#endif
-
- }
- else
- {
-#ifdef JP
- msg_print("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Íî¤È¤··ê¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª");
-#else
- msg_print("You fall into a spiked pit!");
-#endif
-
-
- /* Base damage */
-#ifdef JP
- name = "Íî¤È¤··ê";
-#else
- name = "a pit trap";
-#endif
-
- dam = damroll(2, 6);
-
- /* Extra spike damage */
- if (randint0(100) < 50)
- {
-#ifdef JP
- msg_print("¥¹¥Ñ¥¤¥¯¤¬»É¤µ¤Ã¤¿¡ª");
-#else
- msg_print("You are impaled!");
-#endif
-
-
-#ifdef JP
- name = "¥È¥²¤Î¤¢¤ëÍî¤È¤··ê";
-#else
- name = "a spiked pit";
-#endif
-
- dam = dam * 2;
- (void)set_cut(p_ptr->cut + randint1(dam));
- }
-
- /* Take the damage */
- take_hit(DAMAGE_NOESCAPE, dam, name, -1);
- }
- break;
- }
-
case TRAP_POISON_PIT:
{
- if (p_ptr->levitation)
- {
-#ifdef JP
- msg_print("¥È¥²¤Î¤¢¤ëÍî¤È¤··ê¤òÈô¤Ó±Û¤¨¤¿¡£");
-#else
- msg_print("You fly over a spiked pit.");
-#endif
-
- }
- else
- {
-#ifdef JP
- msg_print("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Íî¤È¤··ê¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª");
-#else
- msg_print("You fall into a spiked pit!");
-#endif
-
-
- /* Base damage */
- dam = damroll(2, 6);
-
-#ifdef JP
- name = "Íî¤È¤··ê";
-#else
- name = "a pit trap";
-#endif
-
-
- /* Extra spike damage */
- if (randint0(100) < 50)
- {
-#ifdef JP
- msg_print("ÆǤòÅɤé¤ì¤¿¥¹¥Ñ¥¤¥¯¤¬»É¤µ¤Ã¤¿¡ª");
-#else
- msg_print("You are impaled on poisonous spikes!");
-#endif
-
-
-#ifdef JP
- name = "¥È¥²¤Î¤¢¤ëÍî¤È¤··ê";
-#else
- name = "a spiked pit";
-#endif
-
-
- dam = dam * 2;
- (void)set_cut(p_ptr->cut + randint1(dam));
-
- if (p_ptr->resist_pois || IS_OPPOSE_POIS())
- {
-#ifdef JP
- msg_print("¤·¤«¤·ÆǤαƶÁ¤Ï¤Ê¤«¤Ã¤¿¡ª");
-#else
- msg_print("The poison does not affect you!");
-#endif
-
- }
-
- else
- {
- dam = dam * 2;
- (void)set_poisoned(p_ptr->poisoned + randint1(dam));
- }
- }
-
- /* Take the damage */
- take_hit(DAMAGE_NOESCAPE, dam, name, -1);
- }
-
+ hit_trap_pit(trap_feat_type);
break;
}
dam = damroll(4, 6);
#ifdef JP
- (void)fire_dam(dam, "±ê¤Î¥È¥é¥Ã¥×", -1);
+ (void)fire_dam(dam, "±ê¤Î¥È¥é¥Ã¥×", -1, FALSE);
#else
- (void)fire_dam(dam, "a fire trap", -1);
+ (void)fire_dam(dam, "a fire trap", -1, FALSE);
#endif
break;
dam = damroll(4, 6);
#ifdef JP
- (void)acid_dam(dam, "»À¤Î¥È¥é¥Ã¥×", -1);
+ (void)acid_dam(dam, "»À¤Î¥È¥é¥Ã¥×", -1, FALSE);
#else
- (void)acid_dam(dam, "an acid trap", -1);
+ (void)acid_dam(dam, "an acid trap", -1, FALSE);
#endif
break;
case TRAP_SLOW:
{
- if (check_hit(125))
- {
-#ifdef JP
- msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤Æ»É¤µ¤Ã¤¿¡ª");
-#else
- msg_print("A small dart hits you!");
-#endif
-
- dam = damroll(1, 4);
-#ifdef JP
- take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
-#else
- take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
-#endif
-
- if (!CHECK_MULTISHADOW()) (void)set_slow(p_ptr->slow + randint0(20) + 20, FALSE);
- }
- else
- {
-#ifdef JP
- msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
-#else
- msg_print("A small dart barely misses you.");
-#endif
-
- }
+ hit_trap_slow();
break;
}
case TRAP_LOSE_STR:
{
- if (check_hit(125))
- {
-#ifdef JP
- msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤Æ»É¤µ¤Ã¤¿¡ª");
-#else
- msg_print("A small dart hits you!");
-#endif
-
- dam = damroll(1, 4);
-#ifdef JP
- take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
-#else
- take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
-#endif
-
- if (!CHECK_MULTISHADOW()) (void)do_dec_stat(A_STR);
- }
- else
- {
-#ifdef JP
- msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
-#else
- msg_print("A small dart barely misses you.");
-#endif
-
- }
+ hit_trap_lose_stat(A_STR);
break;
}
case TRAP_LOSE_DEX:
{
- if (check_hit(125))
- {
-#ifdef JP
- msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤Æ»É¤µ¤Ã¤¿¡ª");
-#else
- msg_print("A small dart hits you!");
-#endif
-
- dam = damroll(1, 4);
-#ifdef JP
- take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
-#else
- take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
-#endif
-
- if (!CHECK_MULTISHADOW()) (void)do_dec_stat(A_DEX);
- }
- else
- {
-#ifdef JP
- msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
-#else
- msg_print("A small dart barely misses you.");
-#endif
-
- }
+ hit_trap_lose_stat(A_DEX);
break;
}
case TRAP_LOSE_CON:
{
- if (check_hit(125))
- {
-#ifdef JP
- msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤Æ»É¤µ¤Ã¤¿¡ª");
-#else
- msg_print("A small dart hits you!");
-#endif
-
- dam = damroll(1, 4);
-#ifdef JP
- take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
-#else
- take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
-#endif
-
- if (!CHECK_MULTISHADOW()) (void)do_dec_stat(A_CON);
- }
- else
- {
-#ifdef JP
- msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
-#else
- msg_print("A small dart barely misses you.");
-#endif
-
- }
+ hit_trap_lose_stat(A_CON);
break;
}
case TRAP_BLIND:
{
-#ifdef JP
- msg_print("¹õ¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
-#else
- msg_print("A black gas surrounds you!");
-#endif
-
- if (!p_ptr->resist_blind)
- {
- (void)set_blind(p_ptr->blind + randint0(50) + 25);
- }
+ hit_trap_set_abnormal_status(
+ _("¹õ¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª", "A black gas surrounds you!"),
+ p_ptr->resist_blind,
+ set_blind, p_ptr->blind + randint0(50) + 25);
break;
}
case TRAP_CONFUSE:
{
-#ifdef JP
- msg_print("¤¤é¤á¤¯¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
-#else
- msg_print("A gas of scintillating colors surrounds you!");
-#endif
-
- if (!p_ptr->resist_conf)
- {
- (void)set_confused(p_ptr->confused + randint0(20) + 10);
- }
+ hit_trap_set_abnormal_status(
+ _("¤¤é¤á¤¯¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª", "A gas of scintillating colors surrounds you!"),
+ p_ptr->resist_conf,
+ set_confused, p_ptr->confused + randint0(20) + 10);
break;
}
case TRAP_POISON:
{
-#ifdef JP
- msg_print("»É·ãŪ¤ÊÎп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
-#else
- msg_print("A pungent green gas surrounds you!");
-#endif
-
- if (!p_ptr->resist_pois && !IS_OPPOSE_POIS())
- {
- (void)set_poisoned(p_ptr->poisoned + randint0(20) + 10);
- }
+ hit_trap_set_abnormal_status(
+ _("»É·ãŪ¤ÊÎп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª", "A pungent green gas surrounds you!"),
+ p_ptr->resist_pois || IS_OPPOSE_POIS(),
+ set_poisoned, p_ptr->poisoned + randint0(20) + 10);
break;
}
}
-static void touch_zap_player(monster_type *m_ptr)
+static void touch_zap_player_aux(monster_type *m_ptr, bool immune, int flags_offset, int r_flags_offset, u32b aura_flag,
+ int (*dam_func)(int dam, cptr kb_str, int monspell, bool aura), cptr message)
{
- int aura_damage = 0;
monster_race *r_ptr = &r_info[m_ptr->r_idx];
- if (r_ptr->flags2 & RF2_AURA_FIRE)
+ if ((atoffset(u32b, r_ptr, flags_offset) & aura_flag) && !immune)
{
- if (!p_ptr->immune_fire)
- {
- char aura_dam[80];
-
- aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
-
- /* Hack -- Get the "died from" name */
- monster_desc(aura_dam, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
+ char mon_name[80];
+ int aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
-#ifdef JP
- msg_print("ÆÍÁ³¤È¤Æ¤âÇ®¤¯¤Ê¤Ã¤¿¡ª");
-#else
- msg_print("You are suddenly very hot!");
-#endif
+ /* Hack -- Get the "died from" name */
+ monster_desc(mon_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
- if (prace_is_(RACE_ENT)) aura_damage += aura_damage / 3;
- if (IS_OPPOSE_FIRE()) aura_damage = (aura_damage + 2) / 3;
- if (p_ptr->resist_fire) aura_damage = (aura_damage + 2) / 3;
+ msg_print(message);
- take_hit(DAMAGE_NOESCAPE, aura_damage, aura_dam, -1);
- if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= RF2_AURA_FIRE;
- handle_stuff();
- }
- }
+ dam_func(aura_damage, mon_name, -1, TRUE);
- if (r_ptr->flags3 & RF3_AURA_COLD)
- {
- if (!p_ptr->immune_cold)
+ if (is_original_ap_and_seen(m_ptr))
{
- char aura_dam[80];
-
- aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
-
- /* Hack -- Get the "died from" name */
- monster_desc(aura_dam, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
-
-#ifdef JP
- msg_print("ÆÍÁ³¤È¤Æ¤â´¨¤¯¤Ê¤Ã¤¿¡ª");
-#else
- msg_print("You are suddenly very cold!");
-#endif
-
- if (IS_OPPOSE_COLD()) aura_damage = (aura_damage + 2) / 3;
- if (p_ptr->resist_cold) aura_damage = (aura_damage + 2) / 3;
-
- take_hit(DAMAGE_NOESCAPE, aura_damage, aura_dam, -1);
- if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= RF3_AURA_COLD;
- handle_stuff();
+ atoffset(u32b, r_ptr, r_flags_offset) |= aura_flag;
}
- }
-
- if (r_ptr->flags2 & RF2_AURA_ELEC)
- {
- if (!p_ptr->immune_elec)
- {
- char aura_dam[80];
-
- aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
-
- /* Hack -- Get the "died from" name */
- monster_desc(aura_dam, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
- if (prace_is_(RACE_ANDROID)) aura_damage += aura_damage / 3;
- if (IS_OPPOSE_ELEC()) aura_damage = (aura_damage + 2) / 3;
- if (p_ptr->resist_elec) aura_damage = (aura_damage + 2) / 3;
-
-#ifdef JP
- msg_print("ÅÅ·â¤ò¤¯¤é¤Ã¤¿¡ª");
-#else
- msg_print("You get zapped!");
-#endif
-
- take_hit(DAMAGE_NOESCAPE, aura_damage, aura_dam, -1);
- if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= RF2_AURA_ELEC;
- handle_stuff();
- }
+ handle_stuff();
}
}
+static void touch_zap_player(monster_type *m_ptr)
+{
+ touch_zap_player_aux(m_ptr, p_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE,
+ fire_dam, _("ÆÍÁ³¤È¤Æ¤âÇ®¤¯¤Ê¤Ã¤¿¡ª", "You are suddenly very hot!"));
+ touch_zap_player_aux(m_ptr, p_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD,
+ cold_dam, _("ÆÍÁ³¤È¤Æ¤â´¨¤¯¤Ê¤Ã¤¿¡ª", "You are suddenly very cold!"));
+ touch_zap_player_aux(m_ptr, p_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC,
+ elec_dam, _("ÅÅ·â¤ò¤¯¤é¤Ã¤¿¡ª", "You get zapped!"));
+}
+
static void natural_attack(s16b m_idx, int attack, bool *fear, bool *mdeath)
{
{
if (quest[p_ptr->inside_quest].type == QUEST_TYPE_FIND_EXIT)
{
- if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, p_ptr->inside_quest, NULL);
- quest[p_ptr->inside_quest].status = QUEST_STATUS_COMPLETED;
- quest[p_ptr->inside_quest].complev = (byte)p_ptr->lev;
-#ifdef JP
- msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
-#else
- msg_print("You accomplished your quest!");
-#endif
-
- msg_print(NULL);
+ complete_quest(p_ptr->inside_quest);
}
leave_quest_check();
#else
msg_print("No route is found!");
#endif
+ travel.y = travel.x = 0;
}
disturb(0, 1);
return;
move_player(travel.dir, always_pickup, FALSE);
if ((py == travel.y) && (px == travel.x))
+ {
travel.run = 0;
+ travel.y = travel.x = 0;
+ }
else if (travel.run > 0)
travel.run--;