OSDN Git Service

[Refactor] #37353 cnv_stat() と modify_stat_value() を player-status.c/h へ移動。
[hengband/hengband.git] / src / quest.c
index 88de5af..64a68bc 100644 (file)
@@ -1,4 +1,5 @@
 #include "angband.h"
+#include "floor.h"
 #include "floor-events.h"
 #include "quest.h"
 #include "monsterrace-hook.h"
@@ -77,7 +78,7 @@ void complete_quest(QUEST_IDX quest_num)
        q_ptr->status = QUEST_STATUS_COMPLETED;
        q_ptr->complev = p_ptr->lev;
        update_playtime();
-       q_ptr->comptime = playtime;
+       q_ptr->comptime = current_world_ptr->play_time;
 
        if (!(q_ptr->flags & QUEST_FLAG_SILENT))
        {
@@ -130,7 +131,7 @@ void check_quest_completion(monster_type *m_ptr)
                                continue;
 
                        /* Quest is not on this level */
-                       if ((q_ptr->level != dun_level) &&
+                       if ((q_ptr->level != current_floor_ptr->dun_level) &&
                                (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
                                continue;
 
@@ -263,7 +264,7 @@ void check_quest_completion(monster_type *m_ptr)
                POSITION ny, nx;
 
                /* Stagger around */
-               while (cave_perma_bold(y, x) || grid_array[y][x].o_idx || (grid_array[y][x].info & CAVE_OBJECT))
+               while (cave_perma_bold(y, x) || current_floor_ptr->grid_array[y][x].o_idx || (current_floor_ptr->grid_array[y][x].info & CAVE_OBJECT))
                {
                        /* Pick a location */
                        scatter(&ny, &nx, y, x, 1, 0);
@@ -289,7 +290,7 @@ void check_quest_completion(monster_type *m_ptr)
        {
                int i;
 
-               for (i = 0; i < (dun_level / 15) + 1; i++)
+               for (i = 0; i < (current_floor_ptr->dun_level / 15) + 1; i++)
                {
                        o_ptr = &forge;
                        object_wipe(o_ptr);
@@ -354,7 +355,7 @@ void quest_discovery(QUEST_IDX q_idx)
                        quest[q_idx].status = QUEST_STATUS_FINISHED;
                        q_ptr->complev = 0;
                        update_playtime();
-                       q_ptr->comptime = playtime;
+                       q_ptr->comptime = current_world_ptr->play_time;
                }
                else
                {
@@ -426,3 +427,78 @@ QUEST_IDX random_quest_number(DEPTH level)
 
        return 0;
 }
+
+/*!
+ * @brief クエスト階層から離脱する際の処理
+ * @return なし
+ */
+void leave_quest_check(void)
+{
+       /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
+       leaving_quest = p_ptr->inside_quest;
+
+       /* Leaving an 'only once' quest marks it as failed */
+       if (leaving_quest)
+       {
+               quest_type* const q_ptr = &quest[leaving_quest];
+
+               if (((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
+                       (q_ptr->status == QUEST_STATUS_TAKEN))
+               {
+                       q_ptr->status = QUEST_STATUS_FAILED;
+                       q_ptr->complev = p_ptr->lev;
+                       update_playtime();
+                       q_ptr->comptime = current_world_ptr->play_time;
+
+                       /* Additional settings */
+                       switch (q_ptr->type)
+                       {
+                       case QUEST_TYPE_TOWER:
+                               quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
+                               quest[QUEST_TOWER1].complev = p_ptr->lev;
+                               break;
+                       case QUEST_TYPE_FIND_ARTIFACT:
+                               a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
+                               break;
+                       case QUEST_TYPE_RANDOM:
+                               r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
+
+                               /* Floor of random quest will be blocked */
+                               prepare_change_floor_mode(CFM_NO_RETURN);
+                               break;
+                       }
+
+                       /* Record finishing a quest */
+                       if (q_ptr->type == QUEST_TYPE_RANDOM)
+                       {
+                               if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
+                       }
+                       else
+                       {
+                               if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
+                       }
+               }
+       }
+}
+
+/*!
+ * @brief 「塔」クエストの各階層から離脱する際の処理
+ * @return なし
+ */
+void leave_tower_check(void)
+{
+       leaving_quest = p_ptr->inside_quest;
+       /* Check for Tower Quest */
+       if (leaving_quest &&
+               (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
+               (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
+       {
+               if (quest[leaving_quest].type == QUEST_TYPE_TOWER)
+               {
+                       quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
+                       quest[QUEST_TOWER1].complev = p_ptr->lev;
+                       update_playtime();
+                       quest[QUEST_TOWER1].comptime = current_world_ptr->play_time;
+               }
+       }
+}