OSDN Git Service

add type casting for fprintf
[hengband/hengband.git] / src / xtra2.c
index b3bbce7..246306b 100644 (file)
@@ -1388,6 +1388,11 @@ msg_print("
                        a_idx = ART_FUNDIN;
                        chance = 5;
                        break;
+
+               case MON_ROBIN_HOOD:
+                       a_idx = ART_ROBIN_HOOD;
+                       chance = 5;
+                       break;
                }
 
                if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
@@ -1729,6 +1734,9 @@ bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
                if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
 
                get_exp_from_mon(expdam, &exp_mon);
+
+               /* Genocided by chaos patron */
+               if (!m_ptr->r_idx) m_idx = 0;
        }
 
        /* Redraw (later) if needed */
@@ -1744,6 +1752,9 @@ bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
                set_superstealth(FALSE);
        }
 
+       /* Genocided by chaos patron */
+       if (!m_idx) return TRUE;
+
        /* Hurt it */
        m_ptr->hp -= dam;
 
@@ -3077,7 +3088,7 @@ static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
        num = MIN(999, exp_adv_frac);
 
        /* Display the number */
-       sprintf(buf,"%03ld", num);
+       sprintf(buf,"%03ld", (long int)num);
 }
 
 
@@ -3571,8 +3582,36 @@ static int target_set_aux(int y, int x, int mode, cptr info)
        {
                cptr name;
 
+               /* Hack -- special handling for quest entrances */
+               if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
+               {
+                       /* Set the quest number temporary */
+                       int old_quest = p_ptr->inside_quest;
+                       int j;
+
+                       /* Clear the text */
+                       for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
+                       quest_text_line = 0;
+
+                       p_ptr->inside_quest = c_ptr->special;
+
+                       /* Get the quest text */
+                       init_flags = INIT_SHOW_TEXT;
+
+                       process_dungeon_file("q_info.txt", 0, 0, 0, 0);
+
+#ifdef JP
+                       name = format("¥¯¥¨¥¹¥È¡Ö%s¡×(%d³¬ÁêÅö)", quest[c_ptr->special].name, quest[c_ptr->special].level);
+#else
+                       name = format("the entrance to the quest '%s'(level %d)", quest[c_ptr->special].name, quest[c_ptr->special].level);
+#endif
+
+                       /* Reset the old quest number */
+                       p_ptr->inside_quest = old_quest;
+               }
+
                /* Hack -- special handling for building doors */
-               if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
+               else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
                {
                        name = building[f_ptr->subtype].name;
                }
@@ -3617,6 +3656,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
 
                /* Hack -- special introduction for store & building doors -KMW- */
                if (have_flag(f_ptr->flags, FF_STORE) ||
+                   have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
                    (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
                    have_flag(f_ptr->flags, FF_ENTRANCE))
                {
@@ -5585,12 +5625,85 @@ msg_format("
 
 
 /*
+ * XAngband: determine if a given location is "interesting"
+ * based on target_set_accept function.
+ */
+static bool tgt_pt_accept(int y, int x)
+{
+       cave_type *c_ptr;
+
+       /* Bounds */
+       if (!(in_bounds(y, x))) return (FALSE);
+
+       /* Player grid is always interesting */
+       if ((y == py) && (x == px)) return (TRUE);
+
+       /* Handle hallucination */
+       if (p_ptr->image) return (FALSE);
+
+       /* Examine the grid */
+       c_ptr = &cave[y][x];
+
+       /* Interesting memorized features */
+       if (c_ptr->info & (CAVE_MARK))
+       {
+               /* Notice stairs */
+               if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
+               if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
+
+               /* Notice quest features */
+               if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
+               if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
+       }
+
+       /* Nope */
+       return (FALSE);
+}
+
+
+/*
+ * XAngband: Prepare the "temp" array for "tget_pt"
+ * based on target_set_prepare funciton.
+ */
+static void tgt_pt_prepare(void)
+{
+       int y, x;
+
+       /* Reset "temp" array */
+       temp_n = 0;
+
+       if (!expand_list) return;
+
+       /* Scan the current panel */
+       for (y = 1; y < cur_hgt; y++)
+       {
+               for (x = 1; x < cur_wid; x++)
+               {
+                       /* Require "interesting" contents */
+                       if (!tgt_pt_accept(y, x)) continue;
+
+                       /* Save the location */
+                       temp_x[temp_n] = x;
+                       temp_y[temp_n] = y;
+                       temp_n++;
+               }
+       }
+
+       /* Target the nearest monster for shooting */
+       ang_sort_comp = ang_sort_comp_distance;
+       ang_sort_swap = ang_sort_swap_distance;
+
+       /* Sort the positions */
+       ang_sort(temp_x, temp_y, temp_n);
+}
+
+/*
  * old -- from PsiAngband.
  */
 bool tgt_pt(int *x_ptr, int *y_ptr)
 {
        char ch = 0;
-       int d, x, y;
+       int d, x, y, n;
        bool success = FALSE;
 
        int wid, hgt;
@@ -5601,8 +5714,14 @@ bool tgt_pt(int *x_ptr, int *y_ptr)
        x = px;
        y = py;
 
+       if (expand_list) 
+       {
+               tgt_pt_prepare();
+               n = 0;
+       }
+
 #ifdef JP
-msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥­¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
+       msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥­¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
 #else
        msg_print("Select a point and press space.");
 #endif
@@ -5630,6 +5749,71 @@ msg_print("
                        else success = TRUE;
 
                        break;
+
+               /* XAngband: Move cursor to stairs */
+               case '>':
+               case '<':
+                       if (expand_list && temp_n)
+                       {
+                               int dx, dy;
+                               int cx = (panel_col_min + panel_col_max) / 2;
+                               int cy = (panel_row_min + panel_row_max) / 2;
+
+                               n++;
+
+                               while(n < temp_n)       /* Skip stairs which have defferent distance */
+                               {
+                                       cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
+
+                                       if (ch == '>')
+                                       {
+                                               if (cave_have_flag_grid(c_ptr, FF_LESS) ||
+                                                       cave_have_flag_grid(c_ptr, FF_QUEST_ENTER))
+                                                       n++;
+                                               else
+                                                       break;
+                                       }
+                                       else /* if (ch == '<') */
+                                       {
+                                               if (cave_have_flag_grid(c_ptr, FF_MORE) ||
+                                                       cave_have_flag_grid(c_ptr, FF_QUEST_EXIT))
+                                                       n++;
+                                               else
+                                                       break;
+                                       }
+                               }
+
+                               if (n == temp_n)        /* Loop out taget list */
+                               {
+                                       n = 0;
+                                       y = py;
+                                       x = px;
+                                       verify_panel(); /* Move cursor to player */
+
+                                       /* Update stuff */
+                                       p_ptr->update |= (PU_MONSTERS);
+
+                                       /* Redraw map */
+                                       p_ptr->redraw |= (PR_MAP);
+
+                                       /* Window stuff */
+                                       p_ptr->window |= (PW_OVERHEAD);
+
+                                       /* Handle stuff */
+                                       handle_stuff();
+                               }
+                               else    /* move cursor to next stair and change panel */
+                               {
+                                       y = temp_y[n];
+                                       x = temp_x[n];
+
+                                       dy = 2 * (y - cy) / hgt;
+                                       dx = 2 * (x - cx) / wid;
+                                       if (dy || dx) change_panel(dy, dx);
+                               }
+                       }
+                       break;
+
                default:
                        /* Look up the direction */
                        d = get_keymap_dir(ch);