X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fxtra2.c;h=76d95ebec19c5a6878e0a0ff054c75f496d90896;hb=4c1a6c7f571b1ba707fbc5f5dd0d35b6e3b275b4;hp=7d375ed0ac73b261e32ad4832bb0311c49b01f1e;hpb=ed678a3221697fa4c8486806a9b16bb5cb1e2ece;p=hengband%2Fhengband.git diff --git a/src/xtra2.c b/src/xtra2.c index 7d375ed0a..76d95ebec 100644 --- a/src/xtra2.c +++ b/src/xtra2.c @@ -424,6 +424,7 @@ void check_quest_completion(monster_type *m_ptr) /* Interesting quest */ if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) || + (quest[i].type == QUEST_TYPE_TOWER) || (quest[i].type == QUEST_TYPE_KILL_ALL)) break; @@ -579,6 +580,42 @@ msg_print(" } break; } + case QUEST_TYPE_TOWER: + { + int number_mon = 0; + + if (!is_hostile(m_ptr)) break; + + /* Count all hostile monsters */ + for (i2 = 0; i2 < cur_wid; ++i2) + for (j2 = 0; j2 < cur_hgt; j2++) + if (cave[j2][i2].m_idx > 0) + if (is_hostile(&m_list[cave[j2][i2].m_idx])) + number_mon++; + + if ((number_mon - 1) == 0) + { + if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL); + + quest[i].status = QUEST_STATUS_STAGE_COMPLETED; + /* completed */ + if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) && + (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) && + (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED)) + { + quest[QUEST_TOWER1].status = QUEST_STATUS_COMPLETED; + quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;; + +#ifdef JP +msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª"); +#else + msg_print("You just completed your quest!"); +#endif + msg_print(NULL); + } + } + break; + } } } @@ -604,7 +641,7 @@ msg_print(" /* Create stairs down */ - cave_set_feat(y, x, FEAT_MORE); + cave_set_feat(y, x, feat_down_stair); /* Remember to update everything */ p_ptr->update |= (PU_FLOW); @@ -698,7 +735,7 @@ void monster_death(int m_idx, bool drop_item) monster_race *r_ptr = &r_info[m_ptr->r_idx]; - bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE)); + bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE)); u32b mo_mode = 0L; @@ -823,8 +860,7 @@ msg_print(" /* Drop a dead corpse? */ if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) && - ((r_ptr->flags9 & RF9_DROP_CORPSE) || - (r_ptr->flags9 & RF9_DROP_SKELETON)) && + (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) && !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr)))) { /* Assume skeleton */ @@ -836,7 +872,7 @@ msg_print(" */ if (!(r_ptr->flags9 & RF9_DROP_SKELETON)) corpse = TRUE; - else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE)) + else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE)) corpse = TRUE; /* Else, a corpse is more likely unless we did a "lot" of damage */ @@ -999,6 +1035,7 @@ msg_print(" if (p_ptr->pseikaku == SEIKAKU_NAMAKE) { int a_idx = 0; + artifact_type *a_ptr = NULL; if (!drop_chosen_item) break; @@ -1016,15 +1053,20 @@ msg_print(" a_idx = ART_NAMAKE_ARMOR; break; } + + a_ptr = &a_info[a_idx]; } - while (a_info[a_idx].cur_num); + while (a_ptr->cur_num); - if (a_info[a_idx].cur_num == 0) + /* Create the artifact */ + if (create_named_art(a_idx, y, x)) { - /* Create the artifact */ - create_named_art(a_idx, y, x); - a_info[a_idx].cur_num = 1; + a_ptr->cur_num = 1; + + /* Hack -- Memorize location of artifact in saved floors */ + if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id; } + else if (!preserve_mode) a_ptr->cur_num = 1; } break; @@ -1079,7 +1121,7 @@ msg_print(" case MON_A_GOLD: case MON_A_SILVER: if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) || - ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_pkills % 5 == 0)))) + ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0)))) { /* Get local object */ q_ptr = &forge; @@ -1178,7 +1220,7 @@ msg_print(" /* Activate restriction */ get_obj_num_hook = kind_is_hafted; - /* Make a poleweapon */ + /* Make a hafted weapon */ make_object(q_ptr, mo_mode); /* Drop it in the dungeon */ @@ -1383,15 +1425,28 @@ 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)) { - if (a_info[a_idx].cur_num == 0) + artifact_type *a_ptr = &a_info[a_idx]; + + if (!a_ptr->cur_num) { /* Create the artifact */ - create_named_art(a_idx, y, x); - a_info[a_idx].cur_num = 1; + if (create_named_art(a_idx, y, x)) + { + a_ptr->cur_num = 1; + + /* Hack -- Memorize location of artifact in saved floors */ + if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id; + } + else if (!preserve_mode) a_ptr->cur_num = 1; } } @@ -1403,11 +1458,19 @@ msg_print(" if (d_info[dungeon_type].final_artifact) { int a_idx = d_info[dungeon_type].final_artifact; - if (!a_info[a_idx].cur_num) + artifact_type *a_ptr = &a_info[a_idx]; + + if (!a_ptr->cur_num) { /* Create the artifact */ - create_named_art(a_idx, y, x); - a_info[a_idx].cur_num = 1; + if (create_named_art(a_idx, y, x)) + { + a_ptr->cur_num = 1; + + /* Hack -- Memorize location of artifact in saved floors */ + if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id; + } + else if (!preserve_mode) a_ptr->cur_num = 1; /* Prevent rewarding both artifact and "default" object */ if (!d_info[dungeon_type].final_object) k_idx = 0; @@ -1449,6 +1512,9 @@ msg_print(" if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena) number = 0; /* Pets drop no stuff */ if (!drop_item && (r_ptr->d_char != '$')) number = 0; + + if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024)) + number = 0; /* Limit of Multiply monster drop */ /* Hack -- handle creeping coins */ coin_type = force_coin; @@ -1628,9 +1694,9 @@ static void get_exp_from_mon(int dam, monster_type *m_ptr) /* Use (average maxhp * 2) as a denominator */ if (!(r_ptr->flags1 & RF1_FORCE_MAXHP)) - s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (r_ptr->hside + 1)); + s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1)); else - s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * r_ptr->hside * 2); + s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2); /* Special penalty in the wilderness */ if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) @@ -1642,7 +1708,7 @@ static void get_exp_from_mon(int dam, monster_type *m_ptr) /* Special penalty for mutiply-monster */ if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN)) { - int monnum_penarty = r_ptr->r_pkills / 400; + int monnum_penarty = r_ptr->r_akills / 400; if (monnum_penarty > 8) monnum_penarty = 8; while (monnum_penarty--) @@ -1708,6 +1774,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 */ @@ -1723,6 +1792,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; @@ -1758,15 +1830,18 @@ bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note) { r_info[MON_BANORLUPART].max_num = 0; r_info[MON_BANORLUPART].r_pkills++; + r_info[MON_BANORLUPART].r_akills++; if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++; } else if (m_ptr->r_idx == MON_BANORLUPART) { r_info[MON_BANOR].max_num = 0; r_info[MON_BANOR].r_pkills++; + r_info[MON_BANOR].r_akills++; if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++; r_info[MON_LUPART].max_num = 0; r_info[MON_LUPART].r_pkills++; + r_info[MON_LUPART].r_akills++; if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++; } } @@ -1775,8 +1850,11 @@ bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note) else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--; } + /* Count all monsters killed */ + if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++; + /* Recall even invisible uniques or winners */ - if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE)) + if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE)) { /* Count kills this life */ if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++; @@ -1910,7 +1988,7 @@ msg_format("%^s chg_virtue(V_HONOUR, 1); } } - if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10)) + if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10)) { chg_virtue(V_VALOUR, -1); } @@ -1994,9 +2072,9 @@ msg_format("%s /* Special note at death */ if (explode) #ifdef JP -msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name); + msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name); #else - msg_format("%s explodes into tiny shreds.", m_name); + msg_format("%^s explodes into tiny shreds.", m_name); #endif else { @@ -2303,6 +2381,24 @@ bool change_panel(int dy, int dx) return (FALSE); } +bool change_panel_xy(int y, int x) +{ + int dy = 0, dx = 0; + int wid, hgt; + + /* Get size */ + get_screen_size(&wid, &hgt); + + if (y < panel_row_min) dy = -1; + if (y > panel_row_max) dy = 1; + if (x < panel_col_min) dx = -1; + if (x > panel_col_max) dx = 1; + + if (!dy && !dx) return (FALSE); + + return change_panel(dy, dx); +} + /* * Given an row (y) and col (x), this routine detects when a move @@ -2940,14 +3036,32 @@ static bool target_set_accept(int y, int x) static void target_set_prepare(int mode) { int y, x; + int min_hgt, max_hgt, min_wid, max_wid; + + if (mode & TARGET_KILL) + { + /* Inner range */ + min_hgt = MAX((py - MAX_RANGE), 0); + max_hgt = MIN((py + MAX_RANGE), cur_hgt - 1); + min_wid = MAX((px - MAX_RANGE), 0); + max_wid = MIN((px + MAX_RANGE), cur_wid - 1); + } + else /* not targetting */ + { + /* Inner panel */ + min_hgt = panel_row_min; + max_hgt = panel_row_max; + min_wid = panel_col_min; + max_wid = panel_col_max; + } /* Reset "temp" array */ temp_n = 0; /* Scan the current panel */ - for (y = panel_row_min; y <= panel_row_max; y++) + for (y = min_hgt; y <= max_hgt; y++) { - for (x = panel_col_min; x <= panel_col_max; x++) + for (x = min_wid; x <= max_wid; x++) { cave_type *c_ptr; @@ -2997,6 +3111,9 @@ static void target_set_prepare(int mode) temp_x[1] = tmp; } } +void target_set_prepare_look(){ + target_set_prepare(TARGET_LOOK); +} /* @@ -3050,10 +3167,12 @@ 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); } +bool show_gold_on_floor = FALSE; + /* * Examine a grid, return a keypress. * @@ -3405,7 +3524,9 @@ static int target_set_aux(int y, int x, int mode, cptr info) screen_save(); /* Display */ + show_gold_on_floor = TRUE; (void)show_floor(0, y, x, &min_width); + show_gold_on_floor = FALSE; /* Prompt */ #ifdef JP @@ -3530,7 +3651,7 @@ static int target_set_aux(int y, int x, int mode, cptr info) if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x)) { /* Forget feature */ - feat = FEAT_NONE; + feat = feat_none; } f_ptr = &f_info[feat]; @@ -3540,10 +3661,38 @@ 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_NAME_ONLY; + + 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->power].name; + name = building[f_ptr->subtype].name; } else if (have_flag(f_ptr->flags, FF_ENTRANCE)) { @@ -3557,7 +3706,7 @@ static int target_set_aux(int y, int x, int mode, cptr info) { name = town[c_ptr->special].name; } - else if (p_ptr->wild_mode && (feat == FEAT_FLOOR)) + else if (p_ptr->wild_mode && (feat == feat_floor)) { #ifdef JP name = "Æ»"; @@ -3586,6 +3735,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)) { @@ -3703,8 +3853,7 @@ bool target_set(int mode) cave_type *c_ptr; int wid, hgt; - - + /* Get size */ get_screen_size(&wid, &hgt); @@ -3731,6 +3880,9 @@ bool target_set(int mode) y = temp_y[m]; x = temp_x[m]; + /* Set forcus */ + change_panel_xy(y, x); + if (!(mode & TARGET_LOOK)) prt_path(y, x); /* Access */ @@ -3757,9 +3909,12 @@ strcpy(info, "q #endif } - + /* Describe and Prompt */ - while (!(query = target_set_aux(y, x, mode, info))); + while (TRUE){ + query = target_set_aux(y, x, mode, info); + if(query)break; + } /* Cancel tracking */ /* health_track(0); */ @@ -4355,6 +4510,7 @@ msg_print(" bool get_rep_dir(int *dp, bool under) { int dir; + cptr prompt; /* Initialize */ (*dp) = 0; @@ -4372,24 +4528,36 @@ bool get_rep_dir(int *dp, bool under) #endif /* ALLOW_REPEAT -- TNB */ + if (under) + { + prompt = _("Êý¸þ ('.'­¸µ, ESC¤ÇÃæÃÇ)? ", "Direction ('.' at feet, Escape to cancel)? "); + } + else + { + prompt = _("Êý¸þ (ESC¤ÇÃæÃÇ)? ", "Direction (Escape to cancel)? "); + } + /* Get a direction */ while (!dir) { char ch; /* Get a command (or Cancel) */ -#ifdef JP -if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break; -#else - if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break; -#endif - + if (!get_com(prompt, &ch, TRUE)) break; - /* Look up the direction */ - dir = get_keymap_dir(ch); + /* Look down */ + if ((under) && ((ch == '5') || (ch == '-') || (ch == '.'))) + { + dir = 5; + } + else + { + /* Look up the direction */ + dir = get_keymap_dir(ch); - /* Oops */ - if (!dir) bell(); + /* Oops */ + if (!dir) bell(); + } } /* Prevent weirdness */ @@ -4576,7 +4744,6 @@ msg_print(" return (TRUE); } - void gain_level_reward(int chosen_reward) { object_type *q_ptr; @@ -5554,12 +5721,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; @@ -5570,8 +5810,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 @@ -5599,6 +5845,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); @@ -6001,3 +6312,174 @@ int spell_exp_level(int spell_exp) else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT; else return EXP_LEVEL_MASTER; } + + +/* + * Display a rumor and apply its effects + */ + +int rumor_num(char *zz, int max_idx) +{ + if (strcmp(zz, "*") == 0) return randint1(max_idx - 1); + return atoi(zz); +} + +cptr rumor_bind_name(char *base, cptr fullname) +{ + char *s, *v; + + s = strstr(base, "{Name}"); + if (s) + { + s[0] = '\0'; + v = format("%s%s%s", base, fullname, (s + 6)); + } + else + { + v = base; + } + + return v; +} + +void display_rumor(bool ex) +{ + bool err; + int section = 0; + char Rumor[1024]; + + if (ex) + { + if (randint0(3) == 0) section = 1; + } + +#ifdef JP + err = get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10); + if (err) strcpy(Rumor, "±³¤Î±½¤â¤¢¤ë¡£"); +#else + err = get_rnd_line("rumors.txt", section, Rumor); + if (err) strcpy(Rumor, "Some rumors are wrong."); +#endif + + err = TRUE; + + if (strncmp(Rumor, "R:", 2) == 0) + { + char *zz[4]; + cptr rumor_msg = NULL; + cptr rumor_eff = NULL; + char fullname[1024] = ""; + + if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3) + { + if (strcmp(zz[0], "ARTIFACT") == 0) + { + int a_idx, k_idx; + object_type forge; + object_type *q_ptr = &forge; + artifact_type *a_ptr; + + while (1) + { + a_idx = rumor_num(zz[1], max_a_idx); + + a_ptr = &a_info[a_idx]; + if (a_ptr->name) break; + } + + k_idx = lookup_kind(a_ptr->tval, a_ptr->sval); + object_prep(q_ptr, k_idx); + q_ptr->name1 = a_idx; + q_ptr->ident = IDENT_STORE; + object_desc(fullname, q_ptr, OD_NAME_ONLY); + } + else if (strcmp(zz[0], "MONSTER") == 0) + { + int r_idx; + monster_race *r_ptr; + + while(1) + { + r_idx = rumor_num(zz[1], max_r_idx); + r_ptr = &r_info[r_idx]; + if (r_ptr->name) break; + } + + strcpy(fullname, r_name + r_ptr->name); + + /* Remember this monster */ + if (!r_ptr->r_sights) + { + r_ptr->r_sights++; + } + } + else if (strcmp(zz[0], "DUNGEON") == 0) + { + int d_idx; + dungeon_info_type *d_ptr; + + while (1) + { + d_idx = rumor_num(zz[1], max_d_idx); + d_ptr = &d_info[d_idx]; + if (d_ptr->name) break; + } + + strcpy(fullname, d_name + d_ptr->name); + + if (!max_dlv[d_idx]) + { + max_dlv[d_idx] = d_ptr->mindepth; +#ifdef JP + rumor_eff = format("%s¤Ëµ¢´Ô¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£", fullname); +#else + rumor_eff = format("You can recall to %s.", fullname); +#endif + } + } + else if (strcmp(zz[0], "TOWN") == 0) + { + int t_idx; + s32b visit; + + while(1) + { + t_idx = rumor_num(zz[1], NO_TOWN); + if (town[t_idx].name) break; + } + + strcpy(fullname, town[t_idx].name); + + visit = (1L << (t_idx - 1)); + if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit)) + { + p_ptr->visit |= visit; +#ifdef JP + rumor_eff = format("%s¤Ë¹Ô¤Ã¤¿¤³¤È¤¬¤¢¤ëµ¤¤¬¤¹¤ë¡£", fullname); +#else + rumor_eff = format("You feel you have been to %s.", fullname); +#endif + } + } + + rumor_msg = rumor_bind_name(zz[2], fullname); + msg_print(rumor_msg); + if (rumor_eff) + { + msg_print(NULL); + msg_print(rumor_eff); + } + err = FALSE; + } + /* error */ +#ifdef JP + if (err) msg_print("¤³¤Î¾ðÊó¤Ï´Ö°ã¤Ã¤Æ¤¤¤ë¡£"); +#else + if (err) msg_print("This information is wrong."); +#endif + } + else + { + msg_format("%s", Rumor); + } +}