OSDN Git Service

Add artifact, 'Toragoroshi-Nanacho-Nenbutsu'.
[hengband/hengband.git] / src / xtra2.c
index a39394d..77d92ea 100644 (file)
@@ -379,7 +379,9 @@ static bool kind_is_hafted(int k_idx)
 
 void complete_quest(int quest_num)
 {
-       switch (quest[quest_num].type)
+       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);
@@ -389,10 +391,12 @@ void complete_quest(int quest_num)
                break;
        }
 
-       quest[quest_num].status = QUEST_STATUS_COMPLETED;
-       quest[quest_num].complev = (byte)p_ptr->lev;
+       q_ptr->status = QUEST_STATUS_COMPLETED;
+       q_ptr->complev = (byte)p_ptr->lev;
+       update_playtime();
+       q_ptr->comptime = playtime;
 
-       if (!(quest[quest_num].flags & QUEST_FLAG_SILENT))
+       if (!(q_ptr->flags & QUEST_FLAG_SILENT))
        {
                msg_print(_("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª", "You just completed your quest!"));
                msg_print(NULL);
@@ -425,7 +429,7 @@ static int count_all_hostile_monsters(void)
  */
 void check_quest_completion(monster_type *m_ptr)
 {
-       int i, j, y, x, ny, nx;
+       int y, x;
 
        int quest_num;
 
@@ -440,42 +444,46 @@ void check_quest_completion(monster_type *m_ptr)
        x = m_ptr->fx;
 
        /* Inside a quest */
-       quest_num = p_ptr->inside_quest;
+       quest_num = p_ptr->inside_quest;                
 
        /* Search for an active quest on this dungeon level */
        if (!quest_num)
        {
+               int i;
+
                for (i = max_quests - 1; i > 0; i--)
                {
+                       quest_type* const q_ptr = &quest[i];
+                       
                        /* Quest is not active */
-                       if (quest[i].status != QUEST_STATUS_TAKEN)
+                       if (q_ptr->status != QUEST_STATUS_TAKEN)
                                continue;
 
                        /* Quest is not a dungeon quest */
-                       if (quest[i].flags & QUEST_FLAG_PRESET)
+                       if (q_ptr->flags & QUEST_FLAG_PRESET)
                                continue;
 
                        /* Quest is not on this level */
-                       if ((quest[i].level != dun_level) &&
-                           (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
+                       if ((q_ptr->level != dun_level) &&
+                           (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
                                continue;
 
                        /* Not a "kill monster" quest */
-                       if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
-                           (quest[i].type == QUEST_TYPE_FIND_EXIT))
+                       if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
+                           (q_ptr->type == QUEST_TYPE_FIND_EXIT))
                                continue;
 
                        /* Interesting quest */
-                       if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
-                           (quest[i].type == QUEST_TYPE_TOWER) ||
-                           (quest[i].type == QUEST_TYPE_KILL_ALL))
+                       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 (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
-                            (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
-                            (quest[i].type == QUEST_TYPE_RANDOM)) &&
-                            (quest[i].r_idx == m_ptr->r_idx))
+                       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;
                }
 
@@ -486,19 +494,19 @@ void check_quest_completion(monster_type *m_ptr)
        if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
        {
                /* Current quest */
-               i = quest_num;
+               quest_type* const q_ptr = &quest[quest_num];
 
-               switch (quest[i].type)
+               switch (q_ptr->type)
                {
                        case QUEST_TYPE_KILL_NUMBER:
                        {
-                               quest[i].cur_num++;
+                               q_ptr->cur_num++;
 
-                               if (quest[i].cur_num >= quest[i].num_mon)
+                               if (q_ptr->cur_num >= q_ptr->num_mon)
                                {
-                                       complete_quest(i);
+                                       complete_quest(quest_num);
 
-                                       quest[i].cur_num = 0;
+                                       q_ptr->cur_num = 0;
                                }
                                break;
                        }
@@ -508,13 +516,13 @@ void check_quest_completion(monster_type *m_ptr)
 
                                if (count_all_hostile_monsters() == 1)
                                {
-                                       if (quest[i].flags & QUEST_FLAG_SILENT)
+                                       if (q_ptr->flags & QUEST_FLAG_SILENT)
                                        {
-                                               quest[i].status = QUEST_STATUS_FINISHED;
+                                               q_ptr->status = QUEST_STATUS_FINISHED;
                                        }
                                        else
                                        {
-                                               complete_quest(i);
+                                               complete_quest(quest_num);
                                        }
                                }
                                break;
@@ -523,42 +531,42 @@ void check_quest_completion(monster_type *m_ptr)
                        case QUEST_TYPE_RANDOM:
                        {
                                /* Only count valid monsters */
-                               if (quest[i].r_idx != m_ptr->r_idx)
+                               if (q_ptr->r_idx != m_ptr->r_idx)
                                        break;
 
-                               quest[i].cur_num++;
+                               q_ptr->cur_num++;
 
-                               if (quest[i].cur_num >= quest[i].max_num)
+                               if (q_ptr->cur_num >= q_ptr->max_num)
                                {
-                                       complete_quest(i);
+                                       complete_quest(quest_num);
 
-                                       if (!(quest[i].flags & QUEST_FLAG_PRESET))
+                                       if (!(q_ptr->flags & QUEST_FLAG_PRESET))
                                        {
                                                create_stairs = TRUE;
                                                p_ptr->inside_quest = 0;
                                        }
 
                                        /* Finish the two main quests without rewarding */
-                                       if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
+                                       if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
                                        {
-                                               quest[i].status = QUEST_STATUS_FINISHED;
+                                               q_ptr->status = QUEST_STATUS_FINISHED;
                                        }
 
-                                       if (quest[i].type == QUEST_TYPE_RANDOM)
+                                       if (q_ptr->type == QUEST_TYPE_RANDOM)
                                        {
                                                reward = TRUE;
-                                               quest[i].status = QUEST_STATUS_FINISHED;
+                                               q_ptr->status = QUEST_STATUS_FINISHED;
                                        }
                                }
                                break;
                        }
                        case QUEST_TYPE_KILL_ANY_LEVEL:
                        {
-                               quest[i].cur_num++;
-                               if (quest[i].cur_num >= quest[i].max_num)
+                               q_ptr->cur_num++;
+                               if (q_ptr->cur_num >= q_ptr->max_num)
                                {
-                                       complete_quest(i);
-                                       quest[i].cur_num = 0;
+                                       complete_quest(quest_num);
+                                       q_ptr->cur_num = 0;
                                }
                                break;
                        }
@@ -568,7 +576,7 @@ void check_quest_completion(monster_type *m_ptr)
 
                                if (count_all_hostile_monsters() == 1)
                                {
-                                       quest[i].status = QUEST_STATUS_STAGE_COMPLETED;
+                                       q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
 
                                        if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
                                           (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
@@ -586,6 +594,8 @@ void check_quest_completion(monster_type *m_ptr)
        /* Create a magical staircase */
        if (create_stairs)
        {
+               int ny, nx;
+
                /* Stagger around */
                while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
                {
@@ -616,7 +626,9 @@ msg_print("
         */
        if (reward)
        {
-               for (j = 0; j < (dun_level / 15)+1; j++)
+               int i;
+
+               for (i = 0; i < (dun_level / 15)+1; i++)
                {
                        /* Get local object */
                        q_ptr = &forge;
@@ -1321,8 +1333,16 @@ msg_print("
                        break;
 
                case MON_SURTUR:
-                       a_idx = ART_TWILIGHT;
-                       chance = 66;
+                       if (!one_in_(3))
+                       {
+                               a_idx = ART_TWILIGHT;
+                               chance = 100;
+                       }
+                       else
+                       {
+                               a_idx = ART_ORB_OF_FATE;
+                               chance = 100;
+                       }
                        break;
 
                case MON_SARUMAN:
@@ -1409,6 +1429,12 @@ msg_print("
                        a_idx = ART_ROBIN_HOOD;
                        chance = 5;
                        break;
+
+               case MON_KOGAN:
+                       a_idx = ART_NANACHO;
+                       chance = 80;
+                       break;
+
                }
 
                if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
@@ -1762,16 +1788,14 @@ bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
        int                     dealt_damage;
 
        (void)COPY(&exp_mon, m_ptr, monster_type);
-       if (!(r_ptr->flags7 & RF7_KILL_EXP))
-       {
-               expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
-
-               get_exp_from_mon(expdam, &exp_mon);
+       
+       expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
 
-               /* Genocided by chaos patron */
-               if (!m_ptr->r_idx) m_idx = 0;
-       }
+       get_exp_from_mon(expdam, &exp_mon);
 
+       /* Genocided by chaos patron */
+       if (!m_ptr->r_idx) m_idx = 0;
+       
        /* Redraw (later) if needed */
        if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
        if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
@@ -2153,19 +2177,7 @@ msg_format("%s
                        delete_monster_idx(m_idx);
                }
 
-               /* Prevent bug of chaos patron's reward */
-               if (r_ptr->flags7 & RF7_KILL_EXP)
-               {
-                       get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
-               }
-               else
-               {
-                       u32b destroy_exp = exp_mon.max_maxhp + 1;
-                       /* Add remained exp*/
-                       if(dealt_damage < m_ptr->maxhp)
-                               destroy_exp += m_ptr->maxhp - dealt_damage;
-                       get_exp_from_mon(destroy_exp, &exp_mon);
-               }
+               get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
 
                /* Not afraid */
                (*fear) = FALSE;