OSDN Git Service

Thrown torches given pretty larger dice, fire brand, kill undead when them has fuel
[hengbandforosx/hengbandosx.git] / src / cmd1.c
index f2e0076..dfdd5ec 100644 (file)
@@ -88,14 +88,18 @@ s16b critical_shot(int weight, int plus, int dam)
        int i, k;
 
        /* Extract "shot" power */
-       i = (weight + ((p_ptr->to_h_b + plus) * 4) + (p_ptr->lev * 2));
+       i = ((p_ptr->to_h_b + plus) * 4) + (p_ptr->lev * 2);
+
+       /* 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;
 
        /* Critical hit */
        if (randint1(5000) <= i)
        {
-               k = weight + randint1(500);
+               k = weight * randint1(500);
 
-               if (k < 500)
+               if (k < 900)
                {
 #ifdef JP
                        msg_print("¼ê¤´¤¿¤¨¤¬¤¢¤Ã¤¿¡ª");
@@ -103,9 +107,9 @@ s16b critical_shot(int weight, int plus, int dam)
                        msg_print("It was a good hit!");
 #endif
 
-                       dam = 2 * dam + 5;
+                       dam += (dam / 2);
                }
-               else if (k < 1000)
+               else if (k < 1350)
                {
 #ifdef JP
                        msg_print("¤«¤Ê¤ê¤Î¼ê¤´¤¿¤¨¤¬¤¢¤Ã¤¿¡ª");
@@ -113,7 +117,7 @@ s16b critical_shot(int weight, int plus, int dam)
                        msg_print("It was a great hit!");
 #endif
 
-                       dam = 2 * dam + 10;
+                       dam *= 2;
                }
                else
                {
@@ -123,7 +127,7 @@ s16b critical_shot(int weight, int plus, int dam)
                        msg_print("It was a superb hit!");
 #endif
 
-                       dam = 3 * dam + 15;
+                       dam *= 3;
                }
        }
 
@@ -226,6 +230,17 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
 
        /* Extract the flags */
        object_flags(o_ptr, flgs);
+       torch_flags(o_ptr, flgs); /* torches has secret flags */
+
+       if (!thrown)
+       {
+               /* Magical Swords */
+               if (p_ptr->special_attack & (ATTACK_ACID)) add_flag(flgs, TR_BRAND_ACID);
+               if (p_ptr->special_attack & (ATTACK_COLD)) add_flag(flgs, TR_BRAND_COLD);
+               if (p_ptr->special_attack & (ATTACK_ELEC)) add_flag(flgs, TR_BRAND_ELEC);
+               if (p_ptr->special_attack & (ATTACK_FIRE)) add_flag(flgs, TR_BRAND_FIRE);
+               if (p_ptr->special_attack & (ATTACK_POIS)) add_flag(flgs, TR_BRAND_POIS);
+       }
 
        /* Some "weapons" and "ammo" do extra damage */
        switch (o_ptr->tval)
@@ -237,6 +252,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                case TV_POLEARM:
                case TV_SWORD:
                case TV_DIGGING:
+               case TV_LITE:
                {
                        /* Slay Animal */
                        if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
@@ -457,8 +473,20 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                                        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) || ((p_ptr->special_attack & (ATTACK_ACID)) && !thrown))
+                       if (have_flag(flgs, TR_BRAND_ACID))
                        {
                                /* Notice immunity */
                                if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
@@ -477,7 +505,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                        }
 
                        /* Brand (Elec) */
-                       if (have_flag(flgs, TR_BRAND_ELEC) || ((p_ptr->special_attack & (ATTACK_ELEC)) && !thrown) || (mode == HISSATSU_ELEC))
+                       if (have_flag(flgs, TR_BRAND_ELEC))
                        {
                                /* Notice immunity */
                                if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
@@ -489,15 +517,6 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                                }
 
                                /* Otherwise, take the damage */
-                               else if ((have_flag(flgs, TR_BRAND_ELEC) || ((p_ptr->special_attack & (ATTACK_ELEC)) && !thrown)) && (mode == HISSATSU_ELEC))
-                               {
-                                       if (mult < 70) mult = 70;
-                               }
-                               else if (mode == HISSATSU_ELEC)
-                               {
-                                       if (mult < 50) mult = 50;
-                               }
-
                                else
                                {
                                        if (mult < 25) mult = 25;
@@ -505,7 +524,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                        }
 
                        /* Brand (Fire) */
-                       if (have_flag(flgs, TR_BRAND_FIRE) || ((p_ptr->special_attack & (ATTACK_FIRE)) && !thrown) || (mode == HISSATSU_FIRE))
+                       if (have_flag(flgs, TR_BRAND_FIRE))
                        {
                                /* Notice immunity */
                                if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
@@ -517,18 +536,6 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                                }
 
                                /* Otherwise, take the damage */
-                               else if ((have_flag(flgs, TR_BRAND_FIRE) || ((p_ptr->special_attack & (ATTACK_FIRE)) && !thrown)) && (mode == HISSATSU_FIRE))
-                               {
-                                       if (r_ptr->flags3 & RF3_HURT_FIRE)
-                                       {
-                                               if (mult < 70) mult = 70;
-                                               if (is_original_ap_and_seen(m_ptr))
-                                               {
-                                                       r_ptr->r_flags3 |= RF3_HURT_FIRE;
-                                               }
-                                       }
-                                       else if (mult < 35) mult = 35;
-                               }
                                else
                                {
                                        if (r_ptr->flags3 & RF3_HURT_FIRE)
@@ -544,7 +551,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                        }
 
                        /* Brand (Cold) */
-                       if (have_flag(flgs, TR_BRAND_COLD) || ((p_ptr->special_attack & (ATTACK_COLD)) && !thrown) || (mode == HISSATSU_COLD))
+                       if (have_flag(flgs, TR_BRAND_COLD))
                        {
                                /* Notice immunity */
                                if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
@@ -555,18 +562,6 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                                        }
                                }
                                /* Otherwise, take the damage */
-                               else if ((have_flag(flgs, TR_BRAND_COLD) || ((p_ptr->special_attack & (ATTACK_COLD)) && !thrown)) && (mode == HISSATSU_COLD))
-                               {
-                                       if (r_ptr->flags3 & RF3_HURT_COLD)
-                                       {
-                                               if (mult < 70) mult = 70;
-                                               if (is_original_ap_and_seen(m_ptr))
-                                               {
-                                                       r_ptr->r_flags3 |= RF3_HURT_COLD;
-                                               }
-                                       }
-                                       else if (mult < 35) mult = 35;
-                               }
                                else
                                {
                                        if (r_ptr->flags3 & RF3_HURT_COLD)
@@ -582,7 +577,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                        }
 
                        /* Brand (Poison) */
-                       if (have_flag(flgs, TR_BRAND_POIS) || ((p_ptr->special_attack & (ATTACK_POIS)) && !thrown) || (mode == HISSATSU_POISON))
+                       if (have_flag(flgs, TR_BRAND_POIS))
                        {
                                /* Notice immunity */
                                if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
@@ -594,48 +589,18 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
                                }
 
                                /* Otherwise, take the damage */
-                               else if ((have_flag(flgs, TR_BRAND_POIS) || ((p_ptr->special_attack & (ATTACK_POIS)) && !thrown)) && (mode == HISSATSU_POISON))
-                               {
-                                       if (mult < 35) mult = 35;
-                               }
                                else
                                {
                                        if (mult < 25) mult = 25;
                                }
                        }
-                       if ((mode == HISSATSU_ZANMA) && !monster_living(r_ptr) && (r_ptr->flags3 & RF3_EVIL))
-                       {
-                               if (mult < 15) mult = 25;
-                               else if (mult < 50) mult = MIN(50, mult+20);
-                       }
-                       if (mode == HISSATSU_UNDEAD)
-                       {
-                               if (r_ptr->flags3 & RF3_UNDEAD)
-                               {
-                                       if (is_original_ap_and_seen(m_ptr))
-                                       {
-                                               r_ptr->r_flags3 |= RF3_UNDEAD;
-                                       }
-                                       if (mult == 10) mult = 70;
-                                       else if (mult < 140) mult = MIN(140, mult+60);
-                               }
-                               if (mult == 10) mult = 40;
-                               else if (mult < 60) mult = MIN(60, mult+30);
-                       }
-                       if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && monster_living(r_ptr))
+
+                       /* Hissatsu */
+                       if (p_ptr->pclass == CLASS_SAMURAI)
                        {
-                               int tmp = MIN(100, MAX(10, p_ptr->cut / 10));
-                               if (mult < tmp) mult = tmp;
-                       }
-                       if ((mode == HISSATSU_HAGAN) && (r_ptr->flags3 & RF3_HURT_ROCK))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_HURT_ROCK;
-                               }
-                               if (mult == 10) mult = 40;
-                               else if (mult < 60) mult = 60;
+                               mult = mult_hissatsu(mult, flgs, m_ptr, mode);
                        }
+
                        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));
@@ -696,7 +661,7 @@ void search(void)
 #endif
 
                                        /* Disturb */
-                                       disturb(0, 0);
+                                       disturb(0, 1);
                                }
 
                                /* Secret door */
@@ -1084,7 +1049,7 @@ static void hit_trap(bool break_trap)
 #endif
 
        /* Disturb the player */
-       disturb(0, 0);
+       disturb(0, 1);
 
        cave_alter_feat(y, x, FF_HIT_TRAP);
 
@@ -2192,7 +2157,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        }
 
                        /* Vampiric drain */
-                       if ((have_flag(flgs, TR_VAMPIRIC)) || (chaos_effect == 1) || (mode == HISSATSU_DRAIN))
+                       if ((have_flag(flgs, TR_VAMPIRIC)) || (chaos_effect == 1) || (mode == HISSATSU_DRAIN) || hex_spelling(HEX_VAMP_BLADE))
                        {
                                /* Only drain "living" monsters */
                                if (monster_living(r_ptr))
@@ -2201,7 +2166,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        can_drain = FALSE;
                        }
 
-                       if ((have_flag(flgs, TR_VORPAL)) && (randint1(vorpal_chance*3/2) == 1) && !zantetsu_mukou)
+                       if ((have_flag(flgs, TR_VORPAL) || hex_spelling(HEX_RUNESWORD)) && (randint1(vorpal_chance*3/2) == 1) && !zantetsu_mukou)
                                vorpal_cut = TRUE;
                        else vorpal_cut = FALSE;
 
@@ -2209,7 +2174,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        {
                                int special_effect = 0, stun_effect = 0, times = 0, max_times;
                                int min_level = 1;
-                               martial_arts *ma_ptr = &ma_blows[0], *old_ptr = &ma_blows[0];
+                               const martial_arts *ma_ptr = &ma_blows[0], *old_ptr = &ma_blows[0];
                                int resist_stun = 0;
                                int weight = 8;
 
@@ -2694,6 +2659,9 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        {
                                                drain_heal = damroll(2, drain_result / 6);
 
+                                               /* Hex */
+                                               if (hex_spelling(HEX_VAMP_BLADE)) drain_heal *= 2;
+
                                                if (cheat_xtra)
                                                {
 #ifdef JP
@@ -2743,7 +2711,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        drain_result = 0;
 
                        /* Confusion attack */
-                       if ((p_ptr->special_attack & ATTACK_CONFUSE) || (chaos_effect == 3) || (mode == HISSATSU_CONF))
+                       if ((p_ptr->special_attack & ATTACK_CONFUSE) || (chaos_effect == 3) || (mode == HISSATSU_CONF) || hex_spelling(HEX_CONFUSION))
                        {
                                /* Cancel glowing hands */
                                if (p_ptr->special_attack & ATTACK_CONFUSE)
@@ -3070,7 +3038,7 @@ bool py_attack(int y, int x, int mode)
        char            m_name[80];
 
        /* Disturb the player */
-       disturb(0, 0);
+       disturb(0, 1);
 
        energy_use = 100;
 
@@ -3592,7 +3560,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        if (have_flag(f_ptr->flags, FF_STORE))
        {
                /* Disturb */
-               disturb(0, 0);
+               disturb(0, 1);
 
                energy_use = 0;
                /* Hack -- Enter store */
@@ -3603,7 +3571,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        else if (have_flag(f_ptr->flags, FF_BLDG))
        {
                /* Disturb */
-               disturb(0, 0);
+               disturb(0, 1);
 
                energy_use = 0;
                /* Hack -- Enter building */
@@ -3614,7 +3582,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        else if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
        {
                /* Disturb */
-               disturb(0, 0);
+               disturb(0, 1);
 
                energy_use = 0;
                /* Hack -- Enter quest level */
@@ -3651,7 +3619,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        else if (have_flag(f_ptr->flags, FF_HIT_TRAP) && !(mpe_mode & MPE_STAYING))
        {
                /* Disturb */
-               disturb(0, 0);
+               disturb(0, 1);
 
                /* Hidden trap */
                if (c_ptr->mimic || have_flag(f_ptr->flags, FF_SECRET))
@@ -3692,7 +3660,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
 #endif
                        }
 
-                       if (disturb_trap_detect) disturb(0, 0);
+                       if (disturb_trap_detect) disturb(0, 1);
                }
        }
 
@@ -3953,7 +3921,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 #endif
                        energy_use = 0;
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
                else if (MON_MONFEAR(riding_m_ptr))
                {
@@ -3969,12 +3937,12 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        msg_format("%^s is too scared to control.", m_name);
 #endif
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
                else if (p_ptr->riding_ryoute)
                {
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
                else if (have_flag(f_ptr->flags, FF_CAN_FLY) && (riding_r_ptr->flags7 & RF7_CAN_FLY))
                {
@@ -3995,7 +3963,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 #endif
                        energy_use = 0;
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
                else if (!have_flag(f_ptr->flags, FF_WATER) && (riding_r_ptr->flags7 & RF7_AQUATIC))
                {
@@ -4006,7 +3974,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 #endif
                        energy_use = 0;
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
                else if (have_flag(f_ptr->flags, FF_LAVA) && !(riding_r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK))
                {
@@ -4017,7 +3985,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 #endif
                        energy_use = 0;
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
 
                if (oktomove && MON_STUNNED(riding_m_ptr) && one_in_(2))
@@ -4030,7 +3998,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        msg_format("You cannot control stunned %s!",m_name);
 #endif
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
        }
 
@@ -4085,9 +4053,6 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 
                oktomove = FALSE;
 
-               /* Disturb the player */
-               disturb(0, 0);
-
                /* Notice things in the dark */
                if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
                {
@@ -4157,6 +4122,9 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        }
                }
 
+               /* Disturb the player */
+               disturb(0, 1);
+
                /* Sound */
                if (!boundary_floor(c_ptr, f_ptr, mimic_f_ptr)) sound(SOUND_HITWALL);
        }
@@ -4170,7 +4138,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                }
 
                /* To avoid a loop with running */
-               disturb(0, 0);
+               disturb(0, 1);
 
                oktomove = FALSE;
        }
@@ -4990,3 +4958,143 @@ void run_step(int dir)
                disturb(0, 0);
        }
 }
+
+
+#ifdef TRAVEL
+/*
+ * Test for traveling
+ */
+static int travel_test(int prev_dir)
+{
+       int new_dir = 0;
+       int i, max;
+       const cave_type *c_ptr;
+       int cost;
+
+       /* Cannot travel when blind */
+       if (p_ptr->blind || no_lite())
+       {
+               msg_print(_("Ìܤ¬¸«¤¨¤Ê¤¤¡ª", "You cannot see!"));
+               return (0);
+       }
+
+       /* break run when leaving trap detected region */
+       if ((disturb_trap_detect || alert_trap_detect)
+           && p_ptr->dtrap && !(cave[py][px].info & CAVE_IN_DETECT))
+       {
+               /* No duplicate warning */
+               p_ptr->dtrap = FALSE;
+
+               /* You are just on the edge */
+               if (!(cave[py][px].info & CAVE_UNSAFE))
+               {
+                       if (alert_trap_detect)
+                       {
+#ifdef JP
+                               msg_print("* Ãí°Õ:¤³¤ÎÀè¤Ï¥È¥é¥Ã¥×¤Î´¶ÃÎÈϰϳ°¤Ç¤¹¡ª *");
+#else
+                               msg_print("*Leaving trap detect region!*");
+#endif
+                       }
+
+                       if (disturb_trap_detect)
+                       {
+                               /* Break Run */
+                               return (0);
+                       }
+               }
+       }
+
+       /* Range of newly adjacent grids */
+       max = (prev_dir & 0x01) + 1;
+
+       /* Look at every newly adjacent square. */
+       for (i = -max; i <= max; i++)
+       {
+               /* New direction */
+               int dir = cycle[chome[prev_dir] + i];
+
+               /* New location */
+               int row = py + ddy[dir];
+               int col = px + ddx[dir];
+
+               /* Access grid */
+               c_ptr = &cave[row][col];
+
+               /* Visible monsters abort running */
+               if (c_ptr->m_idx)
+               {
+                       monster_type *m_ptr = &m_list[c_ptr->m_idx];
+
+                       /* Visible monster */
+                       if (m_ptr->ml) return (0);
+               }
+
+       }
+
+       /* Travel cost of current grid */
+       cost = travel.cost[py][px];
+
+       /* Determine travel direction */
+       for (i = 0; i < 8; ++ i) {
+               int dir_cost = travel.cost[py+ddy_ddd[i]][px+ddx_ddd[i]];
+
+               if (dir_cost < cost)
+               {
+                       new_dir = ddd[i];
+                       cost = dir_cost;
+               }
+       }
+
+       if (!new_dir) return (0);
+
+       /* Access newly move grid */
+       c_ptr = &cave[py+ddy[new_dir]][px+ddx[new_dir]];
+
+       /* Close door abort traveling */
+       if (!easy_open && is_closed_door(c_ptr->feat)) return (0);
+
+       /* Visible and unignorable trap abort tarveling */
+       if (!c_ptr->mimic && !trap_can_be_ignored(c_ptr->feat)) return (0);
+
+       /* Move new grid */
+       return (new_dir);
+}
+
+
+/*
+ * Travel command
+ */
+void travel_step(void)
+{
+       /* Get travel direction */
+       travel.dir = travel_test(travel.dir);
+
+       /* disturb */
+       if (!travel.dir)
+       {
+               if (travel.run == 255)
+               {
+#ifdef JP
+                       msg_print("Æ»¶Ú¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡ª");
+#else
+                       msg_print("No route is found!");
+#endif
+               }
+               disturb(0, 1);
+               return;
+       }
+
+       energy_use = 100;
+
+       move_player(travel.dir, always_pickup, FALSE);
+
+       if ((py == travel.y) && (px == travel.x))
+               travel.run = 0;
+       else if (travel.run > 0)
+               travel.run--;
+
+       /* Travel Delay */
+       Term_xtra(TERM_XTRA_DELAY, delay_factor);
+}
+#endif