OSDN Git Service

Modify torch_lost_fuel bug. No more create minus charge torches.
[hengband/hengband.git] / src / spells3.c
index 0d918e2..b5dd46c 100644 (file)
@@ -267,6 +267,9 @@ bool cave_player_teleportable_bold(int y, int x, u32b mode)
 
        if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
 
+       /* don't teleport on a trap. */
+       if (have_flag(f_ptr->flags, FF_HIT_TRAP)) return FALSE;
+
        if (!(mode & TELEPORT_PASSIVE))
        {
                if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
@@ -285,10 +288,6 @@ bool cave_player_teleportable_bold(int y, int x, u32b mode)
                        if (!p_ptr->levitation) return FALSE;
                }
 
-               if (have_flag(f_ptr->flags, FF_HIT_TRAP))
-               {
-                       if (!is_known_trap(c_ptr) || !trap_can_be_ignored(c_ptr->feat)) return FALSE;
-               }
        }
 
        return TRUE;
@@ -569,7 +568,7 @@ void teleport_away_followable(int m_idx)
 
        teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
 
-       if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && los(py, px, oldfy, oldfx))
+       if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(py, px, oldfy, oldfx))
        {
                bool follow = FALSE;
 
@@ -799,7 +798,7 @@ void teleport_level(int m_idx)
                        char m2_name[80];
 
                        monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
-                       do_cmd_write_nikki(NIKKI_NAMED_PET, 8, m2_name);
+                       do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
                }
 
                delete_monster_idx(m_idx);
@@ -1642,7 +1641,7 @@ static bool vanish_dungeon(void)
                                (void)set_monster_csleep(c_ptr->m_idx, 0);
 
                                /* Notice the "waking up" */
-                               if (is_seen(m_ptr))
+                               if (m_ptr->ml)
                                {
                                        /* Acquire the monster name */
                                        monster_desc(m_name, m_ptr, 0);
@@ -2782,6 +2781,9 @@ bool identify_item(object_type *o_ptr)
        object_aware(o_ptr);
        object_known(o_ptr);
 
+       /* Player touches it */
+       o_ptr->marked |= OM_TOUCHED;
+
        /* Recalculate bonuses */
        p_ptr->update |= (PU_BONUS);
 
@@ -2838,24 +2840,32 @@ bool ident_spell(bool only_equip)
        else
                item_tester_hook = item_tester_hook_identify;
 
-       if (!can_get_item())
+       if (can_get_item())
+       {
+#ifdef JP
+               q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
+#else
+               q = "Identify which item? ";
+#endif
+       }
+       else
        {
                if (only_equip)
-               {
                        item_tester_hook = object_is_weapon_armour_ammo;
-               }
                else
-               {
                        item_tester_hook = NULL;
-               }
+
+#ifdef JP
+               q = "¤¹¤Ù¤Æ´ÕÄêºÑ¤ß¤Ç¤¹¡£ ";
+#else
+               q = "All items are identified. ";
+#endif
        }
 
        /* Get an item */
 #ifdef JP
-q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
-s = "´ÕÄꤹ¤ë¤Ù¤­¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
+       s = "´ÕÄꤹ¤ë¤Ù¤­¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
 #else
-       q = "Identify which item? ";
        s = "You have nothing to identify.";
 #endif
 
@@ -3012,21 +3022,33 @@ bool identify_fully(bool only_equip)
        else
                item_tester_hook = item_tester_hook_identify_fully;
 
-       if (!can_get_item())
+       if (can_get_item())
+       {
+#ifdef JP
+               q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò*´ÕÄê*¤·¤Þ¤¹¤«? ";
+#else
+               q = "*Identify* which item? ";
+#endif
+       }
+       else
        {
                if (only_equip)
                        item_tester_hook = object_is_weapon_armour_ammo;
                else
                        item_tester_hook = NULL;
+
+#ifdef JP
+               q = "¤¹¤Ù¤Æ*´ÕÄê*ºÑ¤ß¤Ç¤¹¡£ ";
+#else
+               q = "All items are *identified*. ";
+#endif
        }
 
        /* Get an item */
 #ifdef JP
-q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
-s = "´ÕÄꤹ¤ë¤Ù¤­¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
+       s = "*´ÕÄê*¤¹¤ë¤Ù¤­¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
 #else
-       q = "Identify which item? ";
-       s = "You have nothing to identify.";
+       s = "You have nothing to *identify*.";
 #endif
 
        if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
@@ -3510,6 +3532,8 @@ s = "
        if (object_is_cursed(o_ptr))
        {
                if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
+                       have_flag(flgs, TR_ADD_L_CURSE) ||
+                       have_flag(flgs, TR_ADD_H_CURSE) ||
                    (o_ptr->curse_flags & TRC_PERMA_CURSE))
                {
 #ifdef JP
@@ -3908,7 +3932,7 @@ void display_spell_list(void)
        int             i, j;
        int             y, x;
        int             m[9];
-       magic_type      *s_ptr;
+       const magic_type *s_ptr;
        char            name[80];
        char            out_val[160];
 
@@ -3920,6 +3944,13 @@ void display_spell_list(void)
        if (p_ptr->pclass == CLASS_SORCERER) return;
        if (p_ptr->pclass == CLASS_RED_MAGE) return;
 
+       /* Snipers */
+       if (p_ptr->pclass == CLASS_SNIPER)
+       {
+               display_snipe_list();
+               return;
+       }
+
        /* mind.c type classes */
        if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
            (p_ptr->pclass == CLASS_BERSERKER) ||
@@ -4205,7 +4236,7 @@ int mod_spell_chance_2(int chance)
 s16b spell_chance(int spell, int use_realm)
 {
        int             chance, minfail;
-       magic_type      *s_ptr;
+       const magic_type *s_ptr;
        int             need_mana;
        int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
 
@@ -4266,9 +4297,19 @@ s16b spell_chance(int spell, int use_realm)
 
        chance = mod_spell_chance_1(chance);
 
-       if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
-       if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
-       if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
+       /* Goodness or evilness gives a penalty to failure rate */
+       switch (use_realm)
+       {
+       case REALM_NATURE:
+               if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
+               break;
+       case REALM_LIFE: case REALM_CRUSADE:
+               if (p_ptr->align < -20) chance += penalty;
+               break;
+       case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
+               if (p_ptr->align > 20) chance += penalty;
+               break;
+       }
 
        /* Minimum failure rate */
        if (chance < minfail) chance = minfail;
@@ -4301,7 +4342,7 @@ s16b spell_chance(int spell, int use_realm)
  */
 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
 {
-       magic_type *s_ptr;
+       const magic_type *s_ptr;
 
        /* Access the spell */
        if (!is_magic(use_realm))
@@ -4348,7 +4389,7 @@ bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
 {
        int             i, spell, exp_level, increment = 64;
-       magic_type      *s_ptr;
+       const magic_type *s_ptr;
        cptr            comment;
        char            info[80];
        char            out_val[160];
@@ -4678,6 +4719,7 @@ bool hates_fire(object_type *o_ptr)
                case TV_CRUSADE_BOOK:
                case TV_MUSIC_BOOK:
                case TV_HISSATSU_BOOK:
+               case TV_HEX_BOOK:
                {
                        return (TRUE);
                }
@@ -4784,8 +4826,7 @@ int inven_damage(inven_func typ, int perc)
        object_type *o_ptr;
        char        o_name[MAX_NLEN];
 
-       /* Multishadow effects is determined by turn */
-       if( p_ptr->multishadow && (turn & 1) )return 0;
+       if (CHECK_MULTISHADOW()) return 0;
 
        if (p_ptr->inside_arena) return 0;
 
@@ -4969,15 +5010,18 @@ int acid_dam(int dam, cptr kb_str, int monspell)
        if (p_ptr->resist_acid) dam = (dam + 2) / 3;
        if (double_resist) dam = (dam + 2) / 3;
 
-       if ((!(double_resist || p_ptr->resist_acid)) &&
-           one_in_(HURT_CHANCE))
-               (void)do_dec_stat(A_CHR);
+       if (!CHECK_MULTISHADOW())
+       {
+               if ((!(double_resist || p_ptr->resist_acid)) &&
+                   one_in_(HURT_CHANCE))
+                       (void)do_dec_stat(A_CHR);
 
-       /* If any armor gets hit, defend the player */
-       if (minus_ac()) dam = (dam + 1) / 2;
+               /* If any armor gets hit, defend the player */
+               if (minus_ac()) dam = (dam + 1) / 2;
+       }
 
        /* Take damage */
-       get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
        if (!(double_resist && p_ptr->resist_acid))
@@ -5012,11 +5056,11 @@ int elec_dam(int dam, cptr kb_str, int monspell)
        if (double_resist) dam = (dam + 2) / 3;
 
        if ((!(double_resist || p_ptr->resist_elec)) &&
-           one_in_(HURT_CHANCE))
+           one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
                (void)do_dec_stat(A_DEX);
 
        /* Take damage */
-       get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
        if (!(double_resist && p_ptr->resist_elec))
@@ -5052,11 +5096,11 @@ int fire_dam(int dam, cptr kb_str, int monspell)
        if (double_resist) dam = (dam + 2) / 3;
 
        if ((!(double_resist || p_ptr->resist_fire)) &&
-           one_in_(HURT_CHANCE))
+           one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
                (void)do_dec_stat(A_STR);
 
        /* Take damage */
-       get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
        if (!(double_resist && p_ptr->resist_fire))
@@ -5091,11 +5135,11 @@ int cold_dam(int dam, cptr kb_str, int monspell)
        if (double_resist) dam = (dam + 2) / 3;
 
        if ((!(double_resist || p_ptr->resist_cold)) &&
-           one_in_(HURT_CHANCE))
+           one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
                (void)do_dec_stat(A_STR);
 
        /* Take damage */
-       get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
        if (!(double_resist && p_ptr->resist_cold))
@@ -5256,22 +5300,14 @@ msg_format("
 /*
  * Curse the players weapon
  */
-bool curse_weapon(bool force, int slot)
+bool curse_weapon_object(bool force, object_type *o_ptr)
 {
        int i;
-
-       object_type *o_ptr;
-
        char o_name[MAX_NLEN];
 
-
-       /* Curse the weapon */
-       o_ptr = &inventory[slot];
-
        /* Nothing to curse */
        if (!o_ptr->k_idx) return (FALSE);
 
-
        /* Describe */
        object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
 
@@ -5280,13 +5316,12 @@ bool curse_weapon(bool force, int slot)
        {
                /* Cool */
 #ifdef JP
-msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
-"¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
+               msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
+                               "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
 #else
                msg_format("A %s tries to %s, but your %s resists the effects!",
-                          "terrible black aura", "surround your weapon", o_name);
+                               "terrible black aura", "surround your weapon", o_name);
 #endif
-
        }
 
        /* not artifact or failed save... */
@@ -5294,11 +5329,10 @@ msg_format("%s
        {
                /* Oops */
 #ifdef JP
-if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
+               if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
 #else
                if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
 #endif
-
                chg_virtue(V_ENCHANT, -5);
 
                /* Shatter the weapon */
@@ -5314,7 +5348,6 @@ if (!force) msg_format("
                for (i = 0; i < TR_FLAG_SIZE; i++)
                        o_ptr->art_flags[i] = 0;
 
-
                /* Curse it */
                o_ptr->curse_flags = TRC_CURSED;
 
@@ -5335,6 +5368,12 @@ if (!force) msg_format("
        return (TRUE);
 }
 
+bool curse_weapon(bool force, int slot)
+{
+       /* Curse the weapon */
+       return curse_weapon_object(force, &inventory[slot]);
+}
+
 
 /*
  * Enchant some bolts
@@ -5470,18 +5509,27 @@ bool polymorph_monster(int y, int x)
        if (new_r_idx != old_r_idx)
        {
                u32b mode = 0L;
+               bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
+               s16b this_o_idx, next_o_idx = 0;
 
                /* 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 & MFLAG2_NOPET) mode |= PM_NO_PET;
 
+               /* Mega-hack -- ignore held objects */
+               m_ptr->hold_o_idx = 0;
+
                /* "Kill" the "old" monster */
                delete_monster_idx(c_ptr->m_idx);
 
                /* Create a new monster (no groups) */
                if (place_monster_aux(0, y, x, new_r_idx, mode))
                {
+                       m_list[hack_m_idx_ii].nickname = back_m.nickname;
+                       m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
+                       m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
+
                        /* Success */
                        polymorphed = TRUE;
                }
@@ -5495,6 +5543,35 @@ bool polymorph_monster(int y, int x)
                                /* Re-initialize monster process */
                                mproc_init();
                        }
+                       else preserve_hold_objects = FALSE;
+               }
+
+               /* Mega-hack -- preserve held objects */
+               if (preserve_hold_objects)
+               {
+                       for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
+                       {
+                               /* Acquire object */
+                               object_type *o_ptr = &o_list[this_o_idx];
+
+                               /* Acquire next object */
+                               next_o_idx = o_ptr->next_o_idx;
+
+                               /* Held by new monster */
+                               o_ptr->held_m_idx = hack_m_idx_ii;
+                       }
+               }
+               else if (back_m.hold_o_idx) /* Failed (paranoia) */
+               {
+                       /* Delete objects */
+                       for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
+                       {
+                               /* Acquire next object */
+                               next_o_idx = o_list[this_o_idx].next_o_idx;
+
+                               /* Delete the object */
+                               delete_object_idx(this_o_idx);
+                       }
                }
 
                if (targeted) target_who = hack_m_idx_ii;
@@ -5931,7 +6008,7 @@ bool summon_kin_player(int level, int y, int x, u32b mode)
                        case RACE_NIBELUNG:
                        case RACE_DARK_ELF:
                        case RACE_MIND_FLAYER:
-                       case RACE_KUTA:
+                       case RACE_KUTAR:
                        case RACE_S_FAIRY:
                                summon_kin_type = 'h';
                                break;