#include "spells-summon.h"
#include "patron.h"
#include "mutation.h"
+#include "floor-events.h"
#define REWARD_CHANCE 10
/*!
- * @brief クエストを達成状態にする /
- * @param quest_num 達成状態にしたいクエストのID
- * @return なし
- */
-void complete_quest(QUEST_IDX quest_num)
-{
- quest_type* const q_ptr = &quest[quest_num];
-
- switch (q_ptr->type)
- {
- case QUEST_TYPE_RANDOM:
- if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
- break;
- default:
- if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
- break;
- }
-
- q_ptr->status = QUEST_STATUS_COMPLETED;
- q_ptr->complev = p_ptr->lev;
- update_playtime();
- q_ptr->comptime = playtime;
-
- if (!(q_ptr->flags & QUEST_FLAG_SILENT))
- {
- play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
- msg_print(_("クエストを達成した!", "You just completed your quest!"));
- msg_print(NULL);
- }
-}
-
-/*!
- * @brief 現在フロアに残っている敵モンスターの数を返す /
- * @return 現在の敵モンスターの数
- */
-static MONSTER_NUMBER count_all_hostile_monsters(void)
-{
- POSITION x, y;
- MONSTER_NUMBER number_mon = 0;
-
- for (x = 0; x < cur_wid; ++ x)
- {
- for (y = 0; y < cur_hgt; ++ y)
- {
- MONSTER_IDX m_idx = cave[y][x].m_idx;
-
- if (m_idx > 0 && is_hostile(&m_list[m_idx]))
- {
- ++number_mon;
- }
- }
- }
-
- return number_mon;
-}
-
-/*!
- * @brief 特定の敵を倒した際にクエスト達成処理 /
- * Check for "Quest" completion when a quest monster is killed or charmed.
- * @param m_ptr 撃破したモンスターの構造体参照ポインタ
- * @return なし
- */
-void check_quest_completion(monster_type *m_ptr)
-{
- POSITION y, x;
- QUEST_IDX quest_num;
-
- bool create_stairs = FALSE;
- bool reward = FALSE;
-
- object_type forge;
- object_type *o_ptr;
-
- y = m_ptr->fy;
- x = m_ptr->fx;
-
- /* Inside a quest */
- quest_num = p_ptr->inside_quest;
-
- /* Search for an active quest on this dungeon level */
- if (!quest_num)
- {
- QUEST_IDX i;
-
- for (i = max_q_idx - 1; i > 0; i--)
- {
- quest_type* const q_ptr = &quest[i];
-
- /* Quest is not active */
- if (q_ptr->status != QUEST_STATUS_TAKEN)
- continue;
-
- /* Quest is not a dungeon quest */
- if (q_ptr->flags & QUEST_FLAG_PRESET)
- continue;
-
- /* Quest is not on this level */
- if ((q_ptr->level != dun_level) &&
- (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
- continue;
-
- /* Not a "kill monster" quest */
- if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
- (q_ptr->type == QUEST_TYPE_FIND_EXIT))
- continue;
-
- /* Interesting quest */
- if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
- (q_ptr->type == QUEST_TYPE_TOWER) ||
- (q_ptr->type == QUEST_TYPE_KILL_ALL))
- break;
-
- /* Interesting quest */
- if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
- (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
- (q_ptr->type == QUEST_TYPE_RANDOM)) &&
- (q_ptr->r_idx == m_ptr->r_idx))
- break;
- }
-
- quest_num = i;
- }
-
- /* Handle the current quest */
- if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
- {
- /* Current quest */
- quest_type* const q_ptr = &quest[quest_num];
-
- switch (q_ptr->type)
- {
- case QUEST_TYPE_KILL_NUMBER:
- {
- q_ptr->cur_num++;
-
- if (q_ptr->cur_num >= q_ptr->num_mon)
- {
- complete_quest(quest_num);
-
- q_ptr->cur_num = 0;
- }
- break;
- }
- case QUEST_TYPE_KILL_ALL:
- {
- if (!is_hostile(m_ptr)) break;
-
- if (count_all_hostile_monsters() == 1)
- {
- if (q_ptr->flags & QUEST_FLAG_SILENT)
- {
- q_ptr->status = QUEST_STATUS_FINISHED;
- }
- else
- {
- complete_quest(quest_num);
- }
- }
- break;
- }
- case QUEST_TYPE_KILL_LEVEL:
- case QUEST_TYPE_RANDOM:
- {
- /* Only count valid monsters */
- if (q_ptr->r_idx != m_ptr->r_idx)
- break;
-
- q_ptr->cur_num++;
-
- if (q_ptr->cur_num >= q_ptr->max_num)
- {
- complete_quest(quest_num);
-
- if (!(q_ptr->flags & QUEST_FLAG_PRESET))
- {
- create_stairs = TRUE;
- p_ptr->inside_quest = 0;
- }
-
- /* Finish the two main quests without rewarding */
- if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
- {
- q_ptr->status = QUEST_STATUS_FINISHED;
- }
-
- if (q_ptr->type == QUEST_TYPE_RANDOM)
- {
- reward = TRUE;
- q_ptr->status = QUEST_STATUS_FINISHED;
- }
- }
- break;
- }
- case QUEST_TYPE_KILL_ANY_LEVEL:
- {
- q_ptr->cur_num++;
- if (q_ptr->cur_num >= q_ptr->max_num)
- {
- complete_quest(quest_num);
- q_ptr->cur_num = 0;
- }
- break;
- }
- case QUEST_TYPE_TOWER:
- {
- if (!is_hostile(m_ptr)) break;
-
- if (count_all_hostile_monsters() == 1)
- {
- q_ptr->status = QUEST_STATUS_STAGE_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))
- {
-
- complete_quest(QUEST_TOWER1);
- }
- }
- break;
- }
- }
- }
-
- /* Create a magical staircase */
- if (create_stairs)
- {
- POSITION ny, nx;
-
- /* Stagger around */
- while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
- {
- /* Pick a location */
- scatter(&ny, &nx, y, x, 1, 0);
-
- /* Stagger */
- y = ny; x = nx;
- }
-
- /* Explain the staircase */
- msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
-
- /* Create stairs down */
- cave_set_feat(y, x, feat_down_stair);
-
- /* Remember to update everything */
- p_ptr->update |= (PU_FLOW);
- }
-
- /*
- * Drop quest reward
- */
- if (reward)
- {
- int i;
-
- for (i = 0; i < (dun_level / 15)+1; i++)
- {
- o_ptr = &forge;
- object_wipe(o_ptr);
-
- /* Make a great object */
- make_object(o_ptr, AM_GOOD | AM_GREAT);
- (void)drop_near(o_ptr, -1, y, x);
- }
- }
-}
-
-/*!
- * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
- * Check for "Quest" completion when a quest monster is killed or charmed.
- * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
- * @return なし
- */
-void check_find_art_quest_completion(object_type *o_ptr)
-{
- QUEST_IDX i;
- /* Check if completed a quest */
- for (i = 0; i < max_q_idx; i++)
- {
- if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
- (quest[i].status == QUEST_STATUS_TAKEN) &&
- (quest[i].k_idx == o_ptr->name1))
- {
- complete_quest(i);
- }
- }
-}
-
-
-/*!
* @brief モンスターを撃破した際の述語メッセージを返す /
* Return monster death string
* @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
return _("を倒した。", " is destroyed.");
}
- /* Assume a default death */
return _("は死んだ。", " dies.");
}
-/*!
- * @brief モンスターに与えたダメージの修正処理 /
- * Modify the physical damage done to the monster.
- * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
- * @param dam ダメージ基本値
- * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
- * @return 修正を行った結果のダメージ量
- * @details
- * <pre>
- * (for example when it's invulnerable or shielded)
- * ToDo: Accept a damage-type to calculate the modified damage from
- * things like fire, frost, lightning, poison, ... attacks.
- * "type" is not yet used and should be 0.
- * </pre>
- */
-HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
-{
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
- if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
- {
- dam /= 100;
- if ((dam == 0) && one_in_(3)) dam = 1;
- }
-
- if (MON_INVULNER(m_ptr))
- {
- if (is_psy_spear)
- {
- if (!p_ptr->blind && is_seen(m_ptr))
- {
- msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
- }
- }
- else if (!one_in_(PENETRATE_INVULNERABILITY))
- {
- return (0);
- }
- }
- return (dam);
-}
-
-
-
/*!
* @brief 現在のコンソール表示の縦横を返す。 /
panel_col_prt = panel_col_min - 13;
}
-
-/*!
- * @brief コンソールのリサイズに合わせてマップを再描画する /
- * Map resizing whenever the main term changes size
- * @return なし
- */
-void resize_map(void)
-{
- /* Only if the dungeon exists */
- if (!character_dungeon) return;
-
- /* Mega-Hack -- no panel yet */
- panel_row_max = 0;
- panel_col_max = 0;
-
- /* Reset the panels */
- panel_row_min = cur_hgt;
- panel_col_min = cur_wid;
-
- verify_panel();
-
- p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
- p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
- p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
- p_ptr->update |= (PU_MONSTERS);
- p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
-
- handle_stuff();
- Term_redraw();
-
- /*
- * Waiting command;
- * Place the cursor on the player
- */
- if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
-
- Term_fresh();
-}
-
-/*!
- * @brief コンソールを再描画する /
- * Redraw a term when it is resized
- * @return なし
- */
-void redraw_window(void)
-{
- /* Only if the dungeon exists */
- if (!character_dungeon) return;
-
- p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
- p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
-
- handle_stuff();
- Term_redraw();
-}
-
-
-/*!
- * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
- * @param dy 変更先のフロアY座標
- * @param dx 変更先のフロアX座標
- * Handle a request to change the current panel
- * Return TRUE if the panel was changed.
- * Also used in do_cmd_locate
- * @return 実際に再描画が必要だった場合TRUEを返す
- */
-bool change_panel(POSITION dy, POSITION dx)
-{
- POSITION y, x;
- TERM_LEN wid, hgt;
-
- get_screen_size(&wid, &hgt);
-
- /* Apply the motion */
- y = panel_row_min + dy * hgt / 2;
- x = panel_col_min + dx * wid / 2;
-
- /* Verify the row */
- if (y > cur_hgt - hgt) y = cur_hgt - hgt;
- if (y < 0) y = 0;
-
- /* Verify the col */
- if (x > cur_wid - wid) x = cur_wid - wid;
- if (x < 0) x = 0;
-
- /* Handle "changes" */
- if ((y != panel_row_min) || (x != panel_col_min))
- {
- /* Save the new panel info */
- panel_row_min = y;
- panel_col_min = x;
-
- /* Recalculate the boundaries */
- panel_bounds_center();
-
- p_ptr->update |= (PU_MONSTERS);
- p_ptr->redraw |= (PR_MAP);
- handle_stuff();
-
- /* Success */
- return (TRUE);
- }
-
- /* No change */
- return (FALSE);
-}
-
/*!
* @brief フォーカスを当てるべきマップ描画の基準座標を指定する
* @param y 変更先のフロアY座標
}
else if (have_flag(f_ptr->flags, FF_TOWN))
{
- name = town[c_ptr->special].name;
+ name = town_info[c_ptr->special].name;
}
else if (p_ptr->wild_mode && (feat == feat_floor))
{
/* A "valid" direction was entered */
return (TRUE);
}
-
-
-/*!
- * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
- * @param sval 射撃武器のアイテム副分類ID
- * @return 消費する基本エネルギー
- */
-ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
-{
- ENERGY energy = 10000;
-
- /* Analyze the launcher */
- switch (sval)
- {
- /* Sling and ammo */
- case SV_SLING:
- {
- energy = 8000;
- break;
- }
-
- /* Short Bow and Arrow */
- case SV_SHORT_BOW:
- {
- energy = 10000;
- break;
- }
-
- /* Long Bow and Arrow */
- case SV_LONG_BOW:
- {
- energy = 10000;
- break;
- }
-
- /* Bow of irresponsiblity and Arrow */
- case SV_NAMAKE_BOW:
- {
- energy = 7777;
- break;
- }
-
- /* Light Crossbow and Bolt */
- case SV_LIGHT_XBOW:
- {
- energy = 12000;
- break;
- }
-
- /* Heavy Crossbow and Bolt */
- case SV_HEAVY_XBOW:
- {
- energy = 13333;
- break;
- }
- }
-
- return (energy);
-}
-
-
-/*
- * Return bow tmul
- */
-int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
-{
- int tmul = 0;
-
- /* Analyze the launcher */
- switch (sval)
- {
- /* Sling and ammo */
- case SV_SLING:
- {
- tmul = 2;
- break;
- }
-
- /* Short Bow and Arrow */
- case SV_SHORT_BOW:
- {
- tmul = 2;
- break;
- }
-
- /* Long Bow and Arrow */
- case SV_LONG_BOW:
- {
- tmul = 3;
- break;
- }
-
- /* Bow of irresponsiblity and Arrow */
- case SV_NAMAKE_BOW:
- {
- tmul = 3;
- break;
- }
-
- /* Light Crossbow and Bolt */
- case SV_LIGHT_XBOW:
- {
- tmul = 3;
- break;
- }
-
- /* Heavy Crossbow and Bolt */
- case SV_HEAVY_XBOW:
- {
- tmul = 4;
- break;
- }
- }
-
- return (tmul);
-}
-
-
-/*
- * Display a rumor and apply its effects
- */
-
-IDX rumor_num(char *zz, IDX max_idx)
-{
- if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
- return (IDX)atoi(zz);
-}
-
-concptr rumor_bind_name(char *base, concptr 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)
-{
- errr err;
- int section = 0;
- char Rumor[1024];
-
- if (ex)
- {
- if (randint0(3) == 0) section = 1;
- }
-
- err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
- get_rnd_line("rumors.txt", section, Rumor));
- if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
-
- err = TRUE;
-
- if (strncmp(Rumor, "R:", 2) == 0)
- {
- char *zz[4];
- concptr rumor_msg = NULL;
- concptr rumor_eff_format = NULL;
- char fullname[1024] = "";
-
- if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
- {
- if (strcmp(zz[0], "ARTIFACT") == 0)
- {
- IDX 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)
- {
- MONRACE_IDX 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)
- {
- DUNGEON_IDX 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;
- rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
- }
- }
- else if (strcmp(zz[0], "TOWN") == 0)
- {
- IDX 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;
- rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
- }
- }
-
- rumor_msg = rumor_bind_name(zz[2], fullname);
- msg_print(rumor_msg);
- if (rumor_eff_format)
- {
- msg_print(NULL);
- msg_format(rumor_eff_format, fullname);
- }
- err = FALSE;
- }
- /* error */
- if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
- }
- else
- {
- msg_format("%s", Rumor);
- }
-}