OSDN Git Service

コード整理。process_world()があまりに巨大で管理しずらいので、
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 29 Nov 2003 00:23:09 +0000 (00:23 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 29 Nov 2003 00:23:09 +0000 (00:23 +0000)
時刻に依存しない部分は全て小関数に分けた。

src/dungeon.c
src/xtra1.c
src/z-config.h

index d5f7c10..35f6822 100644 (file)
@@ -1446,6 +1446,11 @@ msg_print("
 #else
                msg_print("Your light has gone out!");
 #endif
+
+               /* Recalculate torch radius */
+               p_ptr->update |= (PU_TORCH);
+
+               /* Some ego light lose its effects without fuel */
                p_ptr->update |= (PU_BONUS);
        }
 
@@ -1882,511 +1887,212 @@ static object_type *choose_cursed_obj_name(u32b flag)
 
 
 /*
- * Handle certain things once every 10 game turns
+ * Handle timed damage and regeneration every 10 game turns
  */
-static void process_world(void)
+static void process_world_aux_hp_and_sp(void)
 {
-       int x, y, i, j;
-       int regen_amount;
+       feature_type *f_ptr = &f_info[cave[py][px].feat];
        bool cave_no_regen = FALSE;
        int upkeep_factor = 0;
-       cave_type *c_ptr;
-       feature_type *f_ptr;
-       object_type *o_ptr;
-       int temp;
-       object_kind *k_ptr;
-       const int dec_count = (easy_band ? 2 : 1);
-
-       int day, hour, min, prev_min;
 
-       s32b len = TURNS_PER_TICK * TOWN_DAWN;
-       s32b tick = turn % len + len / 4;
+       /* Default regeneration */
+       int regen_amount = PY_REGEN_NORMAL;
 
-       int quest_num = quest_number(dun_level);
 
-       extract_day_hour_min(&day, &hour, &min);
-       prev_min = (1440 * (tick - TURNS_PER_TICK) / len) % 60;
+       /*** Damage over Time ***/
 
-       if ((turn - old_turn == (150 - dun_level) * TURNS_PER_TICK)
-           && dun_level &&
-           !(quest_num && (is_fixed_quest_idx(quest_num) &&
-           !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
-             !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) &&
-           !p_ptr->inside_battle)
+       /* Take damage from poison */
+       if (p_ptr->poisoned && !IS_INVULN())
        {
-               /* Announce feeling */
-               do_cmd_feeling();
-
-               /* Update the level indicator */
-               p_ptr->redraw |= (PR_DEPTH);
+               /* Take damage */
+#ifdef JP
+               take_hit(DAMAGE_NOESCAPE, 1, "ÆÇ", -1);
+#else
+               take_hit(DAMAGE_NOESCAPE, 1, "poison", -1);
+#endif
 
-               /* Disturb */
-               if (disturb_minor) disturb(0, 0);
        }
 
-       if (p_ptr->inside_battle && !p_ptr->leaving)
+       /* Take damage from cuts */
+       if (p_ptr->cut && !IS_INVULN())
        {
-               int i2, j2;
-               int win_m_idx = 0;
-               int number_mon = 0;
+               int dam;
 
-               /* Count all hostile monsters */
-               for (i2 = 0; i2 < cur_wid; ++i2)
-                       for (j2 = 0; j2 < cur_hgt; j2++)
-                       {
-                               c_ptr = &cave[j2][i2];
+               /* Mortal wound or Deep Gash */
+               if (p_ptr->cut > 1000)
+               {
+                       dam = 200;
+               }
 
-                               if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
-                               {
-                                       number_mon++;
-                                       win_m_idx = c_ptr->m_idx;
-                               }
-                       }
+               else if (p_ptr->cut > 200)
+               {
+                       dam = 80;
+               }
 
-               if (number_mon == 0)
+               /* Severe cut */
+               else if (p_ptr->cut > 100)
                {
-#ifdef JP
-                       msg_print("ÁêÂǤÁ¤Ë½ª¤ï¤ê¤Þ¤·¤¿¡£");
-#else
-                       msg_print("They have kill each other at the same time.");
-#endif
-                       msg_print(NULL);
-                       p_ptr->energy_need = 0;
-                       battle_monsters();
+                       dam = 32;
                }
-               else if ((number_mon-1) == 0)
+
+               else if (p_ptr->cut > 50)
                {
-                       char m_name[80];
-                       monster_type *wm_ptr;
+                       dam = 16;
+               }
 
-                       wm_ptr = &m_list[win_m_idx];
+               else if (p_ptr->cut > 25)
+               {
+                       dam = 7;
+               }
 
-                       monster_desc(m_name, wm_ptr, 0);
+               else if (p_ptr->cut > 10)
+               {
+                       dam = 3;
+               }
+
+               /* Other cuts */
+               else
+               {
+                       dam = 1;
+               }
+
+               /* Take damage */
 #ifdef JP
-                       msg_format("%s¤¬¾¡Íø¤·¤¿¡ª", m_name);
+               take_hit(DAMAGE_NOESCAPE, dam, "Ã×Ì¿½ý", -1);
 #else
-                       msg_format("%s is winner!", m_name);
+               take_hit(DAMAGE_NOESCAPE, dam, "a fatal wound", -1);
 #endif
-                       msg_print(NULL);
 
-                       if (win_m_idx == (sel_monster+1))
+       }
+
+
+       /* (Vampires) Take damage from sunlight */
+       if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
+       {
+               if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
+               {
+                       if ((cave[py][px].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
                        {
+                               /* Take damage */
 #ifdef JP
-                               msg_print("¤ª¤á¤Ç¤È¤¦¤´¤¶¤¤¤Þ¤¹¡£");
-#else
-                               msg_print("Congratulations.");
-#endif
-#ifdef JP
-                               msg_format("%d¡ð¤ò¼õ¤±¼è¤Ã¤¿¡£", battle_odds);
+msg_print("Æü¸÷¤¬¤¢¤Ê¤¿¤Î¥¢¥ó¥Ç¥Ã¥É¤ÎÆùÂΤò¾Æ¤­¾Ç¤¬¤·¤¿¡ª");
+take_hit(DAMAGE_NOESCAPE, 1, "Æü¸÷", -1);
 #else
-                               msg_format("You received %d gold.", battle_odds);
+                               msg_print("The sun's rays scorch your undead flesh!");
+                               take_hit(DAMAGE_NOESCAPE, 1, "sunlight", -1);
 #endif
-                               p_ptr->au += battle_odds;
+
+                               cave_no_regen = TRUE;
                        }
-                       else
-                       {
+               }
+
+               if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
+                   !p_ptr->resist_lite)
+               {
+                       object_type * o_ptr = &inventory[INVEN_LITE];
+                       char o_name [MAX_NLEN];
+                       char ouch [MAX_NLEN+40];
+
+                       /* Get an object description */
+                       object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
+
 #ifdef JP
-                               msg_print("»ÄÇ°¤Ç¤·¤¿¡£");
+msg_format("%s¤¬¤¢¤Ê¤¿¤Î¥¢¥ó¥Ç¥Ã¥É¤ÎÆùÂΤò¾Æ¤­¾Ç¤¬¤·¤¿¡ª", o_name);
 #else
-                               msg_print("You lost gold.");
+                       msg_format("The %s scorches your undead flesh!", o_name);
 #endif
-                       }
-                       msg_print(NULL);
-                       p_ptr->energy_need = 0;
-                       battle_monsters();
-               }
-               else if(turn - old_turn == 150*TURNS_PER_TICK)
-               {
+
+
+                       cave_no_regen = TRUE;
+
+                       /* Get an object description */
+                       object_desc(o_name, o_ptr, OD_NAME_ONLY);
+
 #ifdef JP
-                       msg_print("¿½¤·Ê¬¤±¤¢¤ê¤Þ¤»¤ó¤¬¡¢¤³¤Î¾¡Éé¤Ï°ú¤­Ê¬¤±¤È¤µ¤»¤Æ¤¤¤¿¤À¤­¤Þ¤¹¡£");
+sprintf(ouch, "%s¤òÁõÈ÷¤·¤¿¥À¥á¡¼¥¸", o_name);
 #else
-                       msg_format("This battle have ended in a draw.");
+                       sprintf(ouch, "wielding %s", o_name);
 #endif
-                       p_ptr->au += kakekin;
-                       msg_print(NULL);
-                       p_ptr->energy_need = 0;
-                       battle_monsters();
+
+                       if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
                }
        }
 
-       /* Every 10 game turns */
-       if (turn % TURNS_PER_TICK) return;
+       if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
+       {
+               int damage = 0;
 
-       /*** Check the Time and Load ***/
+               if (have_flag(f_ptr->flags, FF_DEEP))
+               {
+                       damage = 6000 + randint0(4000);
+               }
+               else if (!p_ptr->ffall)
+               {
+                       damage = 3000 + randint0(2000);
+               }
 
-       if (!(turn % (50*TURNS_PER_TICK)))
-       {
-               /* Check time and load */
-               if ((0 != check_time()) || (0 != check_load()))
+               if (damage)
                {
-                       /* Warning */
-                       if (closing_flag <= 2)
-                       {
-                               /* Disturb */
-                               disturb(0, 0);
+                       if (prace_is_(RACE_ENT)) damage += damage / 3;
+                       if (p_ptr->resist_fire) damage = damage / 3;
+                       if (IS_OPPOSE_FIRE()) damage = damage / 3;
 
-                               /* Count warnings */
-                               closing_flag++;
+                       if (p_ptr->ffall) damage = damage / 5;
 
-                               /* Message */
+                       damage = damage / 100 + (randint0(100) < (damage % 100));
+
+                       if (p_ptr->ffall)
+                       {
 #ifdef JP
-msg_print("¥¢¥ó¥°¥Ð¥ó¥É¤Ø¤ÎÌ礬ÊĤ¸¤«¤«¤Ã¤Æ¤¤¤Þ¤¹...");
-msg_print("¥²¡¼¥à¤ò½ªÎ»¤¹¤ë¤«¥»¡¼¥Ö¤¹¤ë¤«¤·¤Æ²¼¤µ¤¤¡£");
+                               msg_print("Ç®¤Ç²Ð½ý¤·¤¿¡ª");
+                               take_hit(DAMAGE_NOESCAPE, damage, format("%s¤Î¾å¤ËÉâÍ·¤·¤¿¥À¥á¡¼¥¸", f_name + f_info[get_feat_mimic(&cave[py][px])].name), -1);
 #else
-                               msg_print("The gates to ANGBAND are closing...");
-                               msg_print("Please finish up and/or save your game.");
+                               msg_print("The heat burns you!");
+                               take_hit(DAMAGE_NOESCAPE, damage, format("flying over %s", f_name + f_info[get_feat_mimic(&cave[py][px])].name), -1);
 #endif
-
                        }
-
-                       /* Slam the gate */
                        else
                        {
-                               /* Message */
+                               cptr name = f_name + f_info[get_feat_mimic(&cave[py][px])].name;
 #ifdef JP
-msg_print("º£¡¢¥¢¥ó¥°¥Ð¥ó¥É¤Ø¤ÎÌ礬ÊĤ¶¤µ¤ì¤Þ¤·¤¿¡£");
+                               msg_format("%s¤Ç²Ð½ý¤·¤¿¡ª", name);
 #else
-                               msg_print("The gates to ANGBAND are now closed.");
+                               msg_format("The %s burns you!", name);
 #endif
-
-
-                               /* Stop playing */
-                               p_ptr->playing = FALSE;
-
-                               /* Leaving */
-                               p_ptr->leaving = TRUE;
+                               take_hit(DAMAGE_NOESCAPE, damage, name, -1);
                        }
-               }
-       }
 
-       /*** Attempt timed autosave ***/
-       if (autosave_t && autosave_freq && !p_ptr->inside_battle)
-       {
-               if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
-                       do_cmd_save_game(TRUE);
+                       cave_no_regen = TRUE;
+               }
        }
 
-       if (mon_fight)
+       if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
+           !p_ptr->ffall && !p_ptr->can_swim)
        {
+               if (p_ptr->total_weight > (((u32b)adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2))
+               {
+                       /* Take damage */
 #ifdef JP
-               msg_print("²¿¤«¤¬Ê¹¤³¤¨¤¿¡£");
+                       msg_print("Å®¤ì¤Æ¤¤¤ë¡ª");
+                       take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), "Å®¤ì", -1);
 #else
-               msg_print("You hear noise.");
+                       msg_print("You are drowning!");
+                       take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), "drowning", -1);
 #endif
-       }
 
-       /*** Handle the wilderness/town (sunshine) ***/
+                       cave_no_regen = TRUE;
+               }
+       }
 
-       /* While in town/wilderness */
-       if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena && !p_ptr->wild_mode)
+       if (p_ptr->riding)
        {
-               /* Hack -- Daybreak/Nighfall in town */
-               if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
+               int damage;
+               if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
                {
-                       bool dawn;
-
-                       /* Check for dawn */
-                       dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
-
-                       /* Day breaks */
-                       if (dawn)
-                       {
-                               /* Message */
-#ifdef JP
-                               msg_print("Ì뤬ÌÀ¤±¤¿¡£");
-#else
-                               msg_print("The sun has risen.");
-#endif
-
-                               /* Hack -- Scan the town */
-                               for (y = 0; y < cur_hgt; y++)
-                               {
-                                       for (x = 0; x < cur_wid; x++)
-                                       {
-                                               /* Get the cave grid */
-                                               c_ptr = &cave[y][x];
-
-                                               /* Assume lit */
-                                               c_ptr->info |= (CAVE_GLOW);
-
-                                               /* Hack -- Memorize lit grids if allowed */
-                                               if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
-
-                                               /* Hack -- Notice spot */
-                                               note_spot(y, x);
-                                       }
-                               }
-                       }
-
-                       /* Night falls */
-                       else
-                       {
-                               /* Message */
-#ifdef JP
-                               msg_print("Æü¤¬ÄÀ¤ó¤À¡£");
-#else
-                               msg_print("The sun has fallen.");
-#endif
-
-                               /* Hack -- Scan the town */
-                               for (y = 0; y < cur_hgt; y++)
-                               {
-                                       for (x = 0; x < cur_wid; x++)
-                                       {
-                                               /* Get the cave grid */
-                                               c_ptr = &cave[y][x];
-
-                                               /* Feature code (applying "mimic" field) */
-                                               f_ptr = &f_info[get_feat_mimic(c_ptr)];
-
-                                               if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
-                                                   !have_flag(f_ptr->flags, FF_ENTRANCE))
-                                               {
-                                                       /* Assume dark */
-                                                       c_ptr->info &= ~(CAVE_GLOW);
-
-                                                       if (!have_flag(f_ptr->flags, FF_REMEMBER))
-                                                       {
-                                                               /* Forget the normal floor grid */
-                                                               c_ptr->info &= ~(CAVE_MARK);
-
-                                                               /* Hack -- Notice spot */
-                                                               note_spot(y, x);
-                                                       }
-                                               }
-                                       }
-
-                                       /* Glow deep lava and building entrances */
-                                       glow_deep_lava_and_bldg();
-                               }
-                       }
-
-                       /* Update the monsters */
-                       p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
-
-                       /* Redraw map */
-                       p_ptr->redraw |= (PR_MAP);
-
-                       /* Window stuff */
-                       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-               }
-       }
-
-       /* While in the dungeon (vanilla_town or lite_town mode only) */
-       else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
-       {
-               /*** Shuffle the Storekeepers ***/
-
-               /* Chance is only once a day (while in dungeon) */
-               if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
-               {
-                       /* Sometimes, shuffle the shop-keepers */
-                       if (one_in_(STORE_SHUFFLE))
-                       {
-                               int n;
-
-                               /* Pick a random shop (except home and museum) */
-                               do
-                               {
-                                       n = randint0(MAX_STORES);
-                               }
-                               while ((n == STORE_HOME) || (n == STORE_MUSEUM));
-
-                               /* Check every feature */
-                               for (i = 1; i < max_f_idx; i++)
-                               {
-                                       /* Access the index */
-                                       f_ptr = &f_info[i];
-
-                                       /* Skip empty index */
-                                       if (!f_ptr->name) continue;
-
-                                       /* Skip non-store features */
-                                       if (!have_flag(f_ptr->flags, FF_STORE)) continue;
-
-                                       /* Verify store type */
-                                       if (f_ptr->power == n)
-                                       {
-                                               /* Message */
-#ifdef JP
-                                               if (cheat_xtra) msg_format("%s¤ÎŹ¼ç¤ò¥·¥ã¥Ã¥Õ¥ë¤·¤Þ¤¹¡£", f_name + f_ptr->name);
-#else
-                                               if (cheat_xtra) msg_format("Shuffle a Shopkeeper of %s.", f_name + f_ptr->name);
-#endif
-
-                                               /* Shuffle it */
-                                               store_shuffle(n);
-
-                                               break;
-                                       }
-                               }
-                       }
-               }
-       }
-
-
-       /*** Process the monsters ***/
-
-       /* Check for creature generation. */
-       if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
-           !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
-       {
-               /* Make a new monster */
-               (void)alloc_monster(MAX_SIGHT + 5, 0);
-       }
-
-       /* Hack -- Check for creature regeneration */
-       if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
-       if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
-
-       /* Hack -- Process the counters of all monsters */
-       process_monsters_counters();
-
-
-       /*** Damage over Time ***/
-
-       /* Take damage from poison */
-       if (p_ptr->poisoned && !IS_INVULN())
-       {
-               /* Take damage */
-#ifdef JP
-               take_hit(DAMAGE_NOESCAPE, 1, "ÆÇ", -1);
-#else
-               take_hit(DAMAGE_NOESCAPE, 1, "poison", -1);
-#endif
-
-       }
-
-
-       /* (Vampires) Take damage from sunlight */
-       if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
-       {
-               if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
-               {
-                       if ((cave[py][px].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
-                       {
-                               /* Take damage */
-#ifdef JP
-msg_print("Æü¸÷¤¬¤¢¤Ê¤¿¤Î¥¢¥ó¥Ç¥Ã¥É¤ÎÆùÂΤò¾Æ¤­¾Ç¤¬¤·¤¿¡ª");
-take_hit(DAMAGE_NOESCAPE, 1, "Æü¸÷", -1);
-#else
-                               msg_print("The sun's rays scorch your undead flesh!");
-                               take_hit(DAMAGE_NOESCAPE, 1, "sunlight", -1);
-#endif
-
-                               cave_no_regen = TRUE;
-                       }
-               }
-
-               if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
-                   !p_ptr->resist_lite)
-               {
-                       object_type * o_ptr = &inventory[INVEN_LITE];
-                       char o_name [MAX_NLEN];
-                       char ouch [MAX_NLEN+40];
-
-                       /* Get an object description */
-                       object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-
-#ifdef JP
-msg_format("%s¤¬¤¢¤Ê¤¿¤Î¥¢¥ó¥Ç¥Ã¥É¤ÎÆùÂΤò¾Æ¤­¾Ç¤¬¤·¤¿¡ª", o_name);
-#else
-                       msg_format("The %s scorches your undead flesh!", o_name);
-#endif
-
-
-                       cave_no_regen = TRUE;
-
-                       /* Get an object description */
-                       object_desc(o_name, o_ptr, OD_NAME_ONLY);
-
-#ifdef JP
-sprintf(ouch, "%s¤òÁõÈ÷¤·¤¿¥À¥á¡¼¥¸", o_name);
-#else
-                       sprintf(ouch, "wielding %s", o_name);
-#endif
-
-                       if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
-               }
-       }
-
-       f_ptr = &f_info[cave[py][px].feat];
-
-       if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
-       {
-               int damage = 0;
-
-               if (have_flag(f_ptr->flags, FF_DEEP))
-               {
-                       damage = 6000 + randint0(4000);
-               }
-               else if (!p_ptr->ffall)
-               {
-                       damage = 3000 + randint0(2000);
-               }
-
-               if (damage)
-               {
-                       if (prace_is_(RACE_ENT)) damage += damage / 3;
-                       if (p_ptr->resist_fire) damage = damage / 3;
-                       if (IS_OPPOSE_FIRE()) damage = damage / 3;
-
-                       if (p_ptr->ffall) damage = damage / 5;
-
-                       damage = damage / 100 + (randint0(100) < (damage % 100));
-
-                       if (p_ptr->ffall)
-                       {
-#ifdef JP
-                               msg_print("Ç®¤Ç²Ð½ý¤·¤¿¡ª");
-                               take_hit(DAMAGE_NOESCAPE, damage, format("%s¤Î¾å¤ËÉâÍ·¤·¤¿¥À¥á¡¼¥¸", f_name + f_info[get_feat_mimic(&cave[py][px])].name), -1);
-#else
-                               msg_print("The heat burns you!");
-                               take_hit(DAMAGE_NOESCAPE, damage, format("flying over %s", f_name + f_info[get_feat_mimic(&cave[py][px])].name), -1);
-#endif
-                       }
-                       else
-                       {
-                               cptr name = f_name + f_info[get_feat_mimic(&cave[py][px])].name;
-#ifdef JP
-                               msg_format("%s¤Ç²Ð½ý¤·¤¿¡ª", name);
-#else
-                               msg_format("The %s burns you!", name);
-#endif
-                               take_hit(DAMAGE_NOESCAPE, damage, name, -1);
-                       }
-
-                       cave_no_regen = TRUE;
-               }
-       }
-
-       if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
-           !p_ptr->ffall && !p_ptr->can_swim)
-       {
-               if (p_ptr->total_weight > (((u32b)adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2))
-               {
-                       /* Take damage */
-#ifdef JP
-                       msg_print("Å®¤ì¤Æ¤¤¤ë¡ª");
-                       take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), "Å®¤ì", -1);
-#else
-                       msg_print("You are drowning!");
-                       take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), "drowning", -1);
-#endif
-
-                       cave_no_regen = TRUE;
-               }
-       }
-
-       if (p_ptr->riding)
-       {
-               int damage;
-               if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
-               {
-                       damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
-                       if (prace_is_(RACE_ENT)) damage += damage / 3;
-                       if (p_ptr->resist_fire) damage = damage / 3;
-                       if (IS_OPPOSE_FIRE()) damage = damage / 3;
+                       damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
+                       if (prace_is_(RACE_ENT)) damage += damage / 3;
+                       if (p_ptr->resist_fire) damage = damage / 3;
+                       if (IS_OPPOSE_FIRE()) damage = damage / 3;
 #ifdef JP
 msg_print("Ç®¤¤¡ª");
 take_hit(DAMAGE_NOESCAPE, damage, "±ê¤Î¥ª¡¼¥é", -1);
@@ -2447,214 +2153,26 @@ take_hit(DAMAGE_NOESCAPE, damage, "
                                dam_desc = "Ì©ÅÙ";
 #else
                                msg_print("Your molecules feel disrupted!");
-                               dam_desc = "density";
-#endif
-                       }
-                       else
-                       {
-#ifdef JP
-                               msg_print("Êø¤ì¤¿´ä¤Ë²¡¤·ÄÙ¤µ¤ì¤¿¡ª");
-                               dam_desc = "¹Å¤¤´ä";
-#else
-                               msg_print("You are being crushed!");
-                               dam_desc = "solid rock";
-#endif
-                       }
-
-                       take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
-               }
-       }
-
-       if (!hour && !min)
-       {
-               if (min != prev_min)
-               {
-                       do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
-                       determine_today_mon(FALSE);
-               }
-       }
-
-       /* Nightmare mode activates the TY_CURSE at midnight */
-       if (ironman_nightmare)
-       {
-               /* Require exact minute */
-               if (min != prev_min)
-               {
-                       /* Every 15 minutes after 11:00 pm */
-                       if ((hour == 23) && !(min % 15))
-                       {
-                               /* Disturbing */
-                               disturb(0, 0);
-
-                               switch (min / 15)
-                               {
-                                       case 0:
-                                       {
-#ifdef JP
-msg_print("±ó¤¯¤ÇÉÔµ¤Ì£¤Ê¾â¤Î²»¤¬ÌĤä¿¡£");
-#else
-                                               msg_print("You hear a distant bell toll ominously.");
-#endif
-
-                                               break;
-                                       }
-                                       case 1:
-                                       {
-#ifdef JP
-msg_print("±ó¤¯¤Ç¾â¤¬Æó²óÌĤä¿¡£");
-#else
-                                               msg_print("A distant bell sounds twice.");
-#endif
-
-                                               break;
-                                       }
-                                       case 2:
-       {
-#ifdef JP
-msg_print("±ó¤¯¤Ç¾â¤¬»°²óÌĤä¿¡£");
-#else
-                                               msg_print("A distant bell sounds three times.");
-#endif
-
-                                               break;
-                                       }
-                                       case 3:
-                                       {
-#ifdef JP
-msg_print("±ó¤¯¤Ç¾â¤¬»Í²óÌĤä¿¡£");
-#else
-                                               msg_print("A distant bell tolls four times.");
-#endif
-
-                                               break;
-                                       }
-                               }
-                       }
-
-                       /* TY_CURSE activates at mignight! */
-                       if (!hour && !min)
-                       {
-                               int count = 0;
-
-                               disturb(1, 0);
-#ifdef JP
-msg_print("±ó¤¯¤Ç¾â¤¬²¿²ó¤âÌĤꡢ»à¤ó¤À¤è¤¦¤ÊÀŤ±¤µ¤ÎÃæ¤Ø¾Ã¤¨¤Æ¤¤¤Ã¤¿¡£");
-#else
-                               msg_print("A distant bell tolls many times, fading into an deathly silence.");
-#endif
-
-               activate_ty_curse(FALSE, &count);
-       }
-               }
-       }
-
-       /* Take damage from cuts */
-       if (p_ptr->cut && !IS_INVULN())
-       {
-               /* Mortal wound or Deep Gash */
-               if (p_ptr->cut > 1000)
-               {
-                       i = 200;
-               }
-
-               else if (p_ptr->cut > 200)
-               {
-                       i = 80;
-               }
-
-               /* Severe cut */
-               else if (p_ptr->cut > 100)
-               {
-                       i = 32;
-               }
-
-               else if (p_ptr->cut > 50)
-               {
-                       i = 16;
-               }
-
-               else if (p_ptr->cut > 25)
-               {
-                       i = 7;
-               }
-
-               else if (p_ptr->cut > 10)
-               {
-                       i = 3;
-               }
-
-               /* Other cuts */
-               else
-               {
-                       i = 1;
-               }
-
-               /* Take damage */
-#ifdef JP
-take_hit(DAMAGE_NOESCAPE, i, "Ã×Ì¿½ý", -1);
-#else
-               take_hit(DAMAGE_NOESCAPE, i, "a fatal wound", -1);
-#endif
-
-       }
-
-
-       /*** Check the Food, and Regenerate ***/
-
-       if (!p_ptr->inside_battle)
-       {
-               /* Digest normally */
-               if (p_ptr->food < PY_FOOD_MAX)
-               {
-                       /* Every 50 game turns */
-                       if (!(turn % (TURNS_PER_TICK*5)))
-                       {
-                               /* Basic digestion rate based on speed */
-                               i = SPEED_TO_ENERGY(p_ptr->pspeed);
-
-                               /* Regeneration takes more food */
-                               if (p_ptr->regenerate) i += 20;
-                               if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK)) i+= 20;
-                               if (p_ptr->cursed & TRC_FAST_DIGEST) i += 30;
-
-                               /* Slow digestion takes less food */
-                               if (p_ptr->slow_digest) i -= 5;
-
-                               /* Minimal digestion */
-                               if (i < 1) i = 1;
-                               /* Maximal digestion */
-                               if (i > 100) i = 100;
-
-                               /* Digest some food */
-                               (void)set_food(p_ptr->food - i);
-                       }
-               }
-
-               /* Digest quickly when gorged */
-               else
-               {
-                       /* Digest a lot of food */
-                       (void)set_food(p_ptr->food - 100);
-               }
-       }
-
-       /* Starve to death (slowly) */
-       if (p_ptr->food < PY_FOOD_STARVE)
-       {
-               /* Calculate damage */
-               i = (PY_FOOD_STARVE - p_ptr->food) / 10;
-
-               /* Take damage */
+                               dam_desc = "density";
+#endif
+                       }
+                       else
+                       {
 #ifdef JP
-               if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, i, "¶õÊ¢", -1);
+                               msg_print("Êø¤ì¤¿´ä¤Ë²¡¤·ÄÙ¤µ¤ì¤¿¡ª");
+                               dam_desc = "¹Å¤¤´ä";
 #else
-               if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, i, "starvation", -1);
+                               msg_print("You are being crushed!");
+                               dam_desc = "solid rock";
 #endif
+                       }
 
+                       take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
+               }
        }
 
-       /* Default regeneration */
-       regen_amount = PY_REGEN_NORMAL;
+
+       /*** handle regeneration ***/
 
        /* Getting Weak */
        if (p_ptr->food < PY_FOOD_WEAK)
@@ -2672,29 +2190,8 @@ take_hit(DAMAGE_NOESCAPE, i, "
                {
                        regen_amount = PY_REGEN_WEAK;
                }
-
-               /* Getting Faint */
-               if ((p_ptr->food < PY_FOOD_FAINT) && !p_ptr->inside_battle)
-               {
-                       /* Faint occasionally */
-                       if (!p_ptr->paralyzed && (randint0(100) < 10))
-                       {
-                               /* Message */
-#ifdef JP
-msg_print("¤¢¤Þ¤ê¤Ë¤â¶õÊ¢¤Çµ¤À䤷¤Æ¤·¤Þ¤Ã¤¿¡£");
-#else
-                               msg_print("You faint from the lack of food.");
-#endif
-
-                               disturb(1, 0);
-
-                               /* Hack -- faint (bypass free action) */
-                               (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
-                       }
-               }
        }
 
-
        /* Are we walking the pattern? */
        if (pattern_effect())
        {
@@ -2727,32 +2224,31 @@ msg_print("
        upkeep_factor = calculate_upkeep();
 
        /* Regenerate the mana */
-/*     if (p_ptr->csp < p_ptr->msp) */
+       if (upkeep_factor)
        {
-               if (upkeep_factor)
-               {
-                       s32b upkeep_regen = ((100 - upkeep_factor) * regen_amount);
-                       if ((p_ptr->action == ACTION_LEARN) || (p_ptr->action == ACTION_HAYAGAKE)) upkeep_regen -= regen_amount;
-                       regenmana(upkeep_regen/100);
+               s32b upkeep_regen = ((100 - upkeep_factor) * regen_amount);
+               if ((p_ptr->action == ACTION_LEARN) || (p_ptr->action == ACTION_HAYAGAKE)) upkeep_regen -= regen_amount;
+               regenmana(upkeep_regen/100);
 
-#ifdef TRACK_FRIENDS
-                       if (p_ptr->wizard)
-                       {
+#if 0
+               /* Debug message */
+               if (p_ptr->wizard)
+               {
 #ifdef JP
-msg_format("£Í£Ð²óÉü: %d/%d", upkeep_regen, regen_amount);
+                       msg_format("£Í£Ð²óÉü: %d/%d", upkeep_regen, regen_amount);
 #else
-                               msg_format("Regen: %d/%d", upkeep_regen, regen_amount);
+                       msg_format("Regen: %d/%d", upkeep_regen, regen_amount);
 #endif
 
-                       }
-#endif /* TRACK_FRIENDS */
-
-               }
-               else if (p_ptr->action != ACTION_LEARN)
-               {
-                       regenmana(regen_amount);
                }
+#endif /* 0 */
+
+       }
+       else if (p_ptr->action != ACTION_LEARN)
+       {
+               regenmana(regen_amount);
        }
+
        if (p_ptr->pclass == CLASS_MAGIC_EATER)
        {
                regenmagic(regen_amount);
@@ -2793,7 +2289,7 @@ msg_print("
        /* Regenerate Hit Points if needed */
        if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
        {
-               f_ptr = &f_info[cave[py][px].feat];
+               feature_type *f_ptr = &f_info[cave[py][px].feat];
 
                if (have_flag(f_ptr->flags, FF_PATTERN) && (f_ptr->power <= PATTERN_TILE_4))
                {
@@ -2804,8 +2300,16 @@ msg_print("
                        regenhp(regen_amount);
                }
        }
+}
 
 
+/*
+ * Handle timeout every 10 game turns
+ */
+static void process_world_aux_timeout(void)
+{
+       const int dec_count = (easy_band ? 2 : 1);
+
        /*** Timeout Various Things ***/
 
        /* Mimic */
@@ -2999,1308 +2503,1871 @@ msg_print("
                (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
        }
 
-       /* Heroism */
-       if (p_ptr->hero)
+       /* Heroism */
+       if (p_ptr->hero)
+       {
+               (void)set_hero(p_ptr->hero - 1, TRUE);
+       }
+
+       /* Super Heroism */
+       if (p_ptr->shero)
+       {
+               (void)set_shero(p_ptr->shero - 1, TRUE);
+       }
+
+       /* Blessed */
+       if (p_ptr->blessed)
+       {
+               (void)set_blessed(p_ptr->blessed - 1, TRUE);
+       }
+
+       /* Shield */
+       if (p_ptr->shield)
+       {
+               (void)set_shield(p_ptr->shield - 1, TRUE);
+       }
+
+       /* Tsubureru */
+       if (p_ptr->tsubureru)
+       {
+               (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
+       }
+
+       /* Magicdef */
+       if (p_ptr->magicdef)
+       {
+               (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
+       }
+
+       /* Tsuyoshi */
+       if (p_ptr->tsuyoshi)
+       {
+               (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
+       }
+
+       /* Oppose Acid */
+       if (p_ptr->oppose_acid)
+       {
+               (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
+       }
+
+       /* Oppose Lightning */
+       if (p_ptr->oppose_elec)
+       {
+               (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
+       }
+
+       /* Oppose Fire */
+       if (p_ptr->oppose_fire)
+       {
+               (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
+       }
+
+       /* Oppose Cold */
+       if (p_ptr->oppose_cold)
+       {
+               (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
+       }
+
+       /* Oppose Poison */
+       if (p_ptr->oppose_pois)
+       {
+               (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
+       }
+
+       if (p_ptr->ult_res)
+       {
+               (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
+       }
+
+       /*** Poison and Stun and Cut ***/
+
+       /* Poison */
+       if (p_ptr->poisoned)
+       {
+               int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
+
+               /* Apply some healing */
+               (void)set_poisoned(p_ptr->poisoned - adjust);
+       }
+
+       /* Stun */
+       if (p_ptr->stun)
+       {
+               int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
+
+               /* Apply some healing */
+               (void)set_stun(p_ptr->stun - adjust);
+       }
+
+       /* Cut */
+       if (p_ptr->cut)
+       {
+               int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
+
+               /* Hack -- Truly "mortal" wound */
+               if (p_ptr->cut > 1000) adjust = 0;
+
+               /* Apply some healing */
+               (void)set_cut(p_ptr->cut - adjust);
+       }
+}
+
+
+/*
+ * Handle burning fuel every 10 game turns
+ */
+static void process_world_aux_light(void)
+{
+       /* Check for light being wielded */
+       object_type *o_ptr = &inventory[INVEN_LITE];
+
+       /* Burn some fuel in the current lite */
+       if (o_ptr->tval == TV_LITE)
+       {
+               /* Hack -- Use some fuel (except on artifacts) */
+               if (!(artifact_p(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
+               {
+                       /* Decrease life-span */
+                       if (o_ptr->name2 == EGO_LITE_LONG)
+                       {
+                               if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
+                       }
+                       else o_ptr->xtra4--;
+
+                       /* Notice interesting fuel steps */
+                       notice_lite_change(o_ptr);
+               }
+       }
+}
+
+
+/*
+ * Handle mutation effects once every 10 game turns
+ */
+static void process_world_aux_mutation(void)
+{
+       /* No mutation with effects */
+       if (!p_ptr->muta2) return;
+
+       /* No effect on monster arena */
+       if (p_ptr->inside_battle) return;
+
+       /* No effect on the global map */
+       if (p_ptr->wild_mode) return;
+
+
+       if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
+       {
+               disturb(0, 0);
+#ifdef JP
+               msg_print("¥¦¥¬¥¡¥¡¥¢¡ª");
+               msg_print("·ãÅܤÎȯºî¤Ë½±¤ï¤ì¤¿¡ª");
+#else
+               msg_print("RAAAAGHH!");
+               msg_print("You feel a fit of rage coming over you!");
+#endif
+
+               (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
+       }
+
+       if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
+       {
+               if (!p_ptr->resist_fear)
+               {
+                       disturb(0, 0);
+#ifdef JP
+                       msg_print("¤È¤Æ¤â°Å¤¤... ¤È¤Æ¤â¶²¤¤¡ª");
+#else
+                       msg_print("It's so dark... so scary!");
+#endif
+
+                       set_afraid(p_ptr->afraid + 13 + randint1(26));
+               }
+       }
+
+       if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
+       {
+               if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
+                   !p_ptr->anti_tele)
+               {
+                       disturb(0, 0);
+
+                       /* Teleport player */
+#ifdef JP
+                       msg_print("¤¢¤Ê¤¿¤Î°ÌÃÖ¤ÏÆÍÁ³¤Ò¤¸¤ç¤¦¤ËÉÔ³ÎÄê¤Ë¤Ê¤Ã¤¿...");
+#else
+                       msg_print("Your position suddenly seems very uncertain...");
+#endif
+
+                       msg_print(NULL);
+                       teleport_player(40);
+               }
+       }
+
+       if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
+       {
+               if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
+               {
+                       disturb(0, 0);
+                       p_ptr->redraw |= PR_EXTRA;
+#ifdef JP
+                       msg_print("¤¤¤Ò¤­¤¬¤â¡¼¤í¡¼¤È¤Ò¤Æ¤­¤¿¤­¤¬¤Õ¤ë...¥Ò¥Ã¥¯¡ª");
+#else
+                       msg_print("You feel a SSSCHtupor cOmINg over yOu... *HIC*!");
+#endif
+
+               }
+
+               if (!p_ptr->resist_conf)
+               {
+                       (void)set_confused(p_ptr->confused + randint0(20) + 15);
+               }
+
+               if (!p_ptr->resist_chaos)
+               {
+                       if (one_in_(20))
+                       {
+                               msg_print(NULL);
+                               if (one_in_(3)) lose_all_info();
+                               else wiz_dark();
+                               teleport_player(100);
+                               wiz_dark();
+#ifdef JP
+                               msg_print("¤¢¤Ê¤¿¤Ï¸«ÃΤé¤Ì¾ì½ê¤ÇÌܤ¬Àä᤿...Ƭ¤¬Äˤ¤¡£");
+                               msg_print("²¿¤â³Ð¤¨¤Æ¤¤¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ËÍ褿¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
+#else
+                               msg_print("You wake up somewhere with a sore head...");
+                               msg_print("You can't remember a thing, or how you got here!");
+#endif
+
+                       }
+                       else
+                       {
+                               if (one_in_(3))
+                               {
+#ifdef JP
+                                       msg_print("¤­¡Á¤ì¤¤¤Ê¤Á¤ç¤ª¤Á¤ç¤é¤È¤ó¤ì¤¤¤ë¡Á");
+#else
+                                       msg_print("Thishcischs GooDSChtuff!");
+#endif
+
+                                       (void)set_image(p_ptr->image + randint0(150) + 150);
+                               }
+                       }
+               }
+       }
+
+       if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
        {
-               (void)set_hero(p_ptr->hero - 1, TRUE);
+               if (!p_ptr->resist_chaos)
+               {
+                       disturb(0, 0);
+                       p_ptr->redraw |= PR_EXTRA;
+                       (void)set_image(p_ptr->image + randint0(50) + 20);
+               }
        }
 
-       /* Super Heroism */
-       if (p_ptr->shero)
+       if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
        {
-               (void)set_shero(p_ptr->shero - 1, TRUE);
-       }
+               disturb(0, 0);
 
-       /* Blessed */
-       if (p_ptr->blessed)
-       {
-               (void)set_blessed(p_ptr->blessed - 1, TRUE);
-       }
+#ifdef JP
+               msg_print("¥Ö¥¥¡¼¡¼¥Ã¡ª¤ª¤Ã¤È¡£");
+#else
+               msg_print("BRRAAAP! Oops.");
+#endif
 
-       /* Shield */
-       if (p_ptr->shield)
-       {
-               (void)set_shield(p_ptr->shield - 1, TRUE);
+               msg_print(NULL);
+               fire_ball(GF_POIS, 0, p_ptr->lev, 3);
        }
 
-       /* Tsubureru */
-       if (p_ptr->tsubureru)
+       if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
+           !p_ptr->anti_magic && one_in_(9000))
        {
-               (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
-       }
+               int dire = 0;
+               disturb(0, 0);
+#ifdef JP
+               msg_print("ËâË¡¤Î¥¨¥Í¥ë¥®¡¼¤¬ÆÍÁ³¤¢¤Ê¤¿¤ÎÃæ¤Ëή¤ì¹þ¤ó¤Ç¤­¤¿¡ª¥¨¥Í¥ë¥®¡¼¤ò²òÊü¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡ª");
+#else
+               msg_print("Magical energy flows through you! You must release it!");
+#endif
 
-       /* Magicdef */
-       if (p_ptr->magicdef)
-       {
-               (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
+               flush();
+               msg_print(NULL);
+               (void)get_hack_dir(&dire);
+               fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
        }
 
-       /* Tsuyoshi */
-       if (p_ptr->tsuyoshi)
+       if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
+           !p_ptr->anti_magic && (randint1(6666) == 666))
        {
-               (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
-       }
+               bool pet = one_in_(6);
+               u32b mode = PM_ALLOW_GROUP;
 
-       /* Oppose Acid */
-       if (p_ptr->oppose_acid)
-       {
-               (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
-       }
+               if (pet) mode |= PM_FORCE_PET;
+               else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
 
-       /* Oppose Lightning */
-       if (p_ptr->oppose_elec)
-       {
-               (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
-       }
+               if (summon_specific((pet ? -1 : 0), py, px,
+                                   dun_level, SUMMON_DEMON, mode))
+               {
+#ifdef JP
+                       msg_print("¤¢¤Ê¤¿¤Ï¥Ç¡¼¥â¥ó¤ò°ú¤­´ó¤»¤¿¡ª");
+#else
+                       msg_print("You have attracted a demon!");
+#endif
 
-       /* Oppose Fire */
-       if (p_ptr->oppose_fire)
-       {
-               (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
+                       disturb(0, 0);
+               }
        }
 
-       /* Oppose Cold */
-       if (p_ptr->oppose_cold)
+       if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
        {
-               (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
-       }
+               disturb(0, 0);
+               if (one_in_(2))
+               {
+#ifdef JP
+                       msg_print("ÀºÎÏŪ¤Ç¤Ê¤¯¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
+#else
+                       msg_print("You feel less energetic.");
+#endif
 
-       /* Oppose Poison */
-       if (p_ptr->oppose_pois)
+                       if (p_ptr->fast > 0)
+                       {
+                               set_fast(0, TRUE);
+                       }
+                       else
+                       {
+                               set_slow(randint1(30) + 10, FALSE);
+                       }
+               }
+               else
+               {
+#ifdef JP
+                       msg_print("ÀºÎÏŪ¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
+#else
+                       msg_print("You feel more energetic.");
+#endif
+
+                       if (p_ptr->slow > 0)
+                       {
+                               set_slow(0, TRUE);
+                       }
+                       else
+                       {
+                               set_fast(randint1(30) + 10, FALSE);
+                       }
+               }
+               msg_print(NULL);
+       }
+       if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
        {
-               (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
+               disturb(0, 0);
+#ifdef JP
+               msg_print("ÆÍÁ³¤Û¤È¤ó¤É¸ÉÆȤˤʤ俵¤¤¬¤¹¤ë¡£");
+#else
+               msg_print("You suddenly feel almost lonely.");
+#endif
+
+               banish_monsters(100);
+               if (!dun_level && p_ptr->town_num)
+               {
+                       int n;
+
+                       /* Pick a random shop (except home) */
+                       do
+                       {
+                               n = randint0(MAX_STORES);
+                       }
+                       while ((n == STORE_HOME) || (n == STORE_MUSEUM));
+
+#ifdef JP
+                       msg_print("Ź¤Î¼ç¿Í¤¬µÖ¤Ë¸þ¤«¤Ã¤ÆÁö¤Ã¤Æ¤¤¤ë¡ª");
+#else
+                       msg_print("You see one of the shopkeepers running for the hills!");
+#endif
+
+                       store_shuffle(n);
+               }
+               msg_print(NULL);
        }
 
-       if (p_ptr->ult_res)
+       if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
        {
-               (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
-       }
+               object_type *o_ptr;
 
-       /*** Poison and Stun and Cut ***/
+#ifdef JP
+               msg_print("±Æ¤Ë¤Ä¤Ä¤Þ¤ì¤¿¡£");
+#else
+               msg_print("A shadow passes over you.");
+#endif
 
-       /* Poison */
-       if (p_ptr->poisoned)
-       {
-               int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
+               msg_print(NULL);
 
-               /* Apply some healing */
-               (void)set_poisoned(p_ptr->poisoned - adjust);
+               /* Absorb light from the current possition */
+               if ((cave[py][px].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
+               {
+                       hp_player(10);
+               }
+
+               o_ptr = &inventory[INVEN_LITE];
+
+               /* Absorb some fuel in the current lite */
+               if (o_ptr->tval == TV_LITE)
+               {
+                       /* Use some fuel (except on artifacts) */
+                       if (!artifact_p(o_ptr) && (o_ptr->xtra4 > 0))
+                       {
+                               /* Heal the player a bit */
+                               hp_player(o_ptr->xtra4 / 20);
+
+                               /* Decrease life-span of lite */
+                               o_ptr->xtra4 /= 2;
+
+#ifdef JP
+                               msg_print("¸÷¸»¤«¤é¥¨¥Í¥ë¥®¡¼¤òµÛ¼ý¤·¤¿¡ª");
+#else
+                               msg_print("You absorb energy from your light!");
+#endif
+
+
+                               /* Notice interesting fuel steps */
+                               notice_lite_change(o_ptr);
+                       }
+               }
+
+               /*
+                * Unlite the area (radius 10) around player and
+                * do 50 points damage to every affected monster
+                */
+               unlite_area(50, 10);
        }
 
-       /* Stun */
-       if (p_ptr->stun)
+       if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
+           !p_ptr->anti_magic && one_in_(7000))
        {
-               int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
+               bool pet = one_in_(3);
+               u32b mode = PM_ALLOW_GROUP;
 
-               /* Apply some healing */
-               (void)set_stun(p_ptr->stun - adjust);
+               if (pet) mode |= PM_FORCE_PET;
+               else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
+
+               if (summon_specific((pet ? -1 : 0), py, px, dun_level, SUMMON_ANIMAL, mode))
+               {
+#ifdef JP
+                       msg_print("ưʪ¤ò°ú¤­´ó¤»¤¿¡ª");
+#else
+                       msg_print("You have attracted an animal!");
+#endif
+
+                       disturb(0, 0);
+               }
        }
 
-       /* Cut */
-       if (p_ptr->cut)
+       if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
+           !p_ptr->anti_magic && one_in_(8000))
        {
-               int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
-
-               /* Hack -- Truly "mortal" wound */
-               if (p_ptr->cut > 1000) adjust = 0;
+               disturb(0, 0);
+#ifdef JP
+               msg_print("¼þ¤ê¤Î¶õ´Ö¤¬ÏĤó¤Ç¤¤¤ëµ¤¤¬¤¹¤ë¡ª");
+#else
+               msg_print("You feel the world warping around you!");
+#endif
 
-               /* Apply some healing */
-               (void)set_cut(p_ptr->cut - adjust);
+               msg_print(NULL);
+               fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
        }
+       if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
+       {
+               if (!lose_mutation(0))
+#ifdef JP
+                       msg_print("´ñ̯¤Ê¤¯¤é¤¤ÉáÄ̤ˤʤ俵¤¤¬¤¹¤ë¡£");
+#else
+               msg_print("You feel oddly normal.");
+#endif
 
+       }
+       if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
+       {
+               disturb(0, 0);
+#ifdef JP
+               msg_print("Èóʪ¼Á²½¤·¤¿¡ª");
+#else
+               msg_print("You feel insubstantial!");
+#endif
 
+               msg_print(NULL);
+               set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
+       }
+       if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
+       {
+               do_poly_wounds();
+       }
+       if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
+       {
+               int which_stat = randint0(6);
+               int sustained = FALSE;
 
-       /*** Process Light ***/
+               switch (which_stat)
+               {
+               case A_STR:
+                       if (p_ptr->sustain_str) sustained = TRUE;
+                       break;
+               case A_INT:
+                       if (p_ptr->sustain_int) sustained = TRUE;
+                       break;
+               case A_WIS:
+                       if (p_ptr->sustain_wis) sustained = TRUE;
+                       break;
+               case A_DEX:
+                       if (p_ptr->sustain_dex) sustained = TRUE;
+                       break;
+               case A_CON:
+                       if (p_ptr->sustain_con) sustained = TRUE;
+                       break;
+               case A_CHR:
+                       if (p_ptr->sustain_chr) sustained = TRUE;
+                       break;
+               default:
+#ifdef JP
+                       msg_print("ÉÔÀµ¤Ê¾õÂÖ¡ª");
+#else
+                       msg_print("Invalid stat chosen!");
+#endif
 
-       /* Check for light being wielded */
-       o_ptr = &inventory[INVEN_LITE];
+                       sustained = TRUE;
+               }
 
-       /* Burn some fuel in the current lite */
-       if (o_ptr->tval == TV_LITE)
-       {
-               /* Hack -- Use some fuel (except on artifacts) */
-               if (!(artifact_p(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
+               if (!sustained)
                {
-                       /* Decrease life-span */
-                       if (o_ptr->name2 == EGO_LITE_LONG)
-                       {
-                               if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
-                       }
-                       else o_ptr->xtra4--;
+                       disturb(0, 0);
+#ifdef JP
+                       msg_print("¼«Ê¬¤¬¿ê¼å¤·¤Æ¤¤¤¯¤Î¤¬Ê¬¤«¤ë¡ª");
+#else
+                       msg_print("You can feel yourself wasting away!");
+#endif
 
-                       /* Notice interesting fuel steps */
-                       notice_lite_change(o_ptr);
+                       msg_print(NULL);
+                       (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
                }
        }
+       if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
+           !p_ptr->anti_magic && one_in_(3000))
+       {
+               bool pet = one_in_(5);
+               u32b mode = PM_ALLOW_GROUP;
 
-       /* Calculate torch radius */
-       p_ptr->update |= (PU_TORCH);
+               if (pet) mode |= PM_FORCE_PET;
+               else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
 
+               if (summon_specific((pet ? -1 : 0), py, px, dun_level, SUMMON_DRAGON, mode))
+               {
+#ifdef JP
+                       msg_print("¥É¥é¥´¥ó¤ò°ú¤­´ó¤»¤¿¡ª");
+#else
+                       msg_print("You have attracted a dragon!");
+#endif
 
-       /*** Process mutation effects ***/
-       if (p_ptr->muta2 && !p_ptr->inside_battle && !p_ptr->wild_mode)
+                       disturb(0, 0);
+               }
+       }
+       if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
+           one_in_(3000))
        {
-               if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
+               if (p_ptr->tim_esp > 0)
                {
-                       disturb(0, 0);
 #ifdef JP
-msg_print("¥¦¥¬¥¡¥¡¥¢¡ª");
-msg_print("·ãÅܤÎȯºî¤Ë½±¤ï¤ì¤¿¡ª");
+                       msg_print("Àº¿À¤Ë¤â¤ä¤¬¤«¤«¤Ã¤¿¡ª");
 #else
-                       msg_print("RAAAAGHH!");
-                       msg_print("You feel a fit of rage coming over you!");
+                       msg_print("Your mind feels cloudy!");
 #endif
 
-                       (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
+                       set_tim_esp(0, TRUE);
                }
-
-               if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
+               else
                {
-                       if (!p_ptr->resist_fear)
-                       {
-                               disturb(0, 0);
 #ifdef JP
-msg_print("¤È¤Æ¤â°Å¤¤... ¤È¤Æ¤â¶²¤¤¡ª");
+                       msg_print("Àº¿À¤¬¹­¤¬¤Ã¤¿¡ª");
 #else
-                               msg_print("It's so dark... so scary!");
+                       msg_print("Your mind expands!");
 #endif
 
-                               set_afraid(p_ptr->afraid + 13 + randint1(26));
-                       }
+                       set_tim_esp(p_ptr->lev, FALSE);
                }
+       }
+       if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
+           one_in_(9000))
+       {
+               disturb(0, 0);
+#ifdef JP
+               msg_print("°ß¤¬áÛÚ»¤·¡¢¿©»ö¤ò¼º¤Ã¤¿¡ª");
+#else
+               msg_print("Your stomach roils, and you lose your lunch!");
+#endif
+
+               msg_print(NULL);
+               set_food(PY_FOOD_WEAK);
+       }
+
+       if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
+           !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
+       {
+               alter_reality();
+       }
+
+       if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
+       {
+               int danger_amount = 0;
+               int monster;
 
-               if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
+               for (monster = 0; monster < m_max; monster++)
                {
-                       if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
-                           !p_ptr->anti_tele)
+                       monster_type    *m_ptr = &m_list[monster];
+                       monster_race    *r_ptr = &r_info[m_ptr->r_idx];
+
+                       /* Paranoia -- Skip dead monsters */
+                       if (!m_ptr->r_idx) continue;
+
+                       if (r_ptr->level >= p_ptr->lev)
                        {
-                               disturb(0, 0);
+                               danger_amount += r_ptr->level - p_ptr->lev + 1;
+                       }
+               }
+
+               if (danger_amount > 100)
+#ifdef JP
+                       msg_print("Èó¾ï¤Ë¶²¤í¤·¤¤µ¤¤¬¤¹¤ë¡ª");
+#else
+               msg_print("You feel utterly terrified!");
+#endif
 
-                               /* Teleport player */
+               else if (danger_amount > 50)
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤Î°ÌÃÖ¤ÏÆÍÁ³¤Ò¤¸¤ç¤¦¤ËÉÔ³ÎÄê¤Ë¤Ê¤Ã¤¿...");
+                       msg_print("¶²¤í¤·¤¤µ¤¤¬¤¹¤ë¡ª");
 #else
-                               msg_print("Your position suddenly seems very uncertain...");
+               msg_print("You feel terrified!");
 #endif
 
-                               msg_print(NULL);
-                               teleport_player(40);
-                       }
-               }
-
-               if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
-               {
-                       if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
-                       {
-                               disturb(0, 0);
-                               p_ptr->redraw |= PR_EXTRA;
+               else if (danger_amount > 20)
 #ifdef JP
-msg_print("¤¤¤Ò¤­¤¬¤â¡¼¤í¡¼¤È¤Ò¤Æ¤­¤¿¤­¤¬¤Õ¤ë...¥Ò¥Ã¥¯¡ª");
+                       msg_print("Èó¾ï¤Ë¿´Çۤʵ¤¤¬¤¹¤ë¡ª");
 #else
-                               msg_print("You feel a SSSCHtupor cOmINg over yOu... *HIC*!");
+               msg_print("You feel very worried!");
 #endif
 
-                       }
+               else if (danger_amount > 10)
+#ifdef JP
+                       msg_print("¿´Çۤʵ¤¤¬¤¹¤ë¡ª");
+#else
+               msg_print("You feel paranoid!");
+#endif
 
-                       if (!p_ptr->resist_conf)
-                       {
-                               (void)set_confused(p_ptr->confused + randint0(20) + 15);
-                       }
+               else if (danger_amount > 5)
+#ifdef JP
+                       msg_print("¤Û¤È¤ó¤É°ÂÁ´¤Êµ¤¤¬¤¹¤ë¡£");
+#else
+               msg_print("You feel almost safe.");
+#endif
 
-                       if (!p_ptr->resist_chaos)
-                       {
-                               if (one_in_(20))
-                               {
-                                       msg_print(NULL);
-                                       if (one_in_(3)) lose_all_info();
-                                       else wiz_dark();
-                                       teleport_player(100);
-                                       wiz_dark();
+               else
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤Ï¸«ÃΤé¤Ì¾ì½ê¤ÇÌܤ¬Àä᤿...Ƭ¤¬Äˤ¤¡£");
-msg_print("²¿¤â³Ð¤¨¤Æ¤¤¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ËÍ褿¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
+                       msg_print("¼ä¤·¤¤µ¤¤¬¤¹¤ë¡£");
 #else
-                                       msg_print("You wake up somewhere with a sore head...");
-                                       msg_print("You can't remember a thing, or how you got here!");
+               msg_print("You feel lonely.");
 #endif
 
-                               }
-                               else
-                               {
-                                       if (one_in_(3))
-                                       {
+       }
+       if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
+           one_in_(5000))
+       {
+               disturb(0, 0);
 #ifdef JP
-msg_print("¤­¡Á¤ì¤¤¤Ê¤Á¤ç¤ª¤Á¤ç¤é¤È¤ó¤ì¤¤¤ë¡Á");
+               msg_print("̵Ũ¤Êµ¤¤¬¤¹¤ë¡ª");
 #else
-                                               msg_print("Thishcischs GooDSChtuff!");
+               msg_print("You feel invincible!");
 #endif
 
-                                               (void)set_image(p_ptr->image + randint0(150) + 150);
-                                       }
-                               }
-                       }
-               }
+               msg_print(NULL);
+               (void)set_invuln(randint1(8) + 8, FALSE);
+       }
+       if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
+       {
+               int wounds = p_ptr->mhp - p_ptr->chp;
 
-               if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
+               if (wounds > 0)
                {
-                       if (!p_ptr->resist_chaos)
+                       int healing = p_ptr->csp;
+
+                       if (healing > wounds)
                        {
-                               disturb(0, 0);
-                               p_ptr->redraw |= PR_EXTRA;
-                               (void)set_image(p_ptr->image + randint0(50) + 20);
+                               healing = wounds;
                        }
+
+                       hp_player(healing);
+                       p_ptr->csp -= healing;
+
+                       /* Redraw mana */
+                       p_ptr->redraw |= (PR_MANA);
                }
+       }
+       if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
+           one_in_(4000))
+       {
+               int wounds = p_ptr->msp - p_ptr->csp;
 
-               if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
+               if (wounds > 0)
                {
-                       disturb(0, 0);
+                       int healing = p_ptr->chp;
+
+                       if (healing > wounds)
+                       {
+                               healing = wounds;
+                       }
+
+                       p_ptr->csp += healing;
 
+                       /* Redraw mana */
+                       p_ptr->redraw |= (PR_MANA);
 #ifdef JP
-msg_print("¥Ö¥¥¡¼¡¼¥Ã¡ª¤ª¤Ã¤È¡£");
+                       take_hit(DAMAGE_LOSELIFE, healing, "Ƭ¤Ë¾º¤Ã¤¿·ì", -1);
 #else
-                       msg_print("BRRAAAP! Oops.");
+                       take_hit(DAMAGE_LOSELIFE, healing, "blood rushing to the head", -1);
 #endif
 
-                       msg_print(NULL);
-                       fire_ball(GF_POIS, 0, p_ptr->lev, 3);
                }
+       }
+       if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
+       {
+               object_type *o_ptr;
 
-               if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
-                   !p_ptr->anti_magic && one_in_(9000))
-               {
-                       int dire = 0;
-                       disturb(0, 0);
+               disturb(0, 0);
 #ifdef JP
-msg_print("ËâË¡¤Î¥¨¥Í¥ë¥®¡¼¤¬ÆÍÁ³¤¢¤Ê¤¿¤ÎÃæ¤Ëή¤ì¹þ¤ó¤Ç¤­¤¿¡ª¥¨¥Í¥ë¥®¡¼¤ò²òÊü¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡ª");
+               msg_print("­¤¬¤â¤Ä¤ì¤Æž¤ó¤À¡ª");
+               take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), "žÅÝ", -1);
 #else
-                       msg_print("Magical energy flows through you! You must release it!");
+               msg_print("You trip over your own feet!");
+               take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), "tripping", -1);
 #endif
 
-                       flush();
-                       msg_print(NULL);
-                       (void)get_hack_dir(&dire);
-                       fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
-               }
 
-               if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
-                   !p_ptr->anti_magic && (randint1(6666) == 666))
+               msg_print(NULL);
+               if (buki_motteruka(INVEN_RARM))
                {
-                       bool pet = one_in_(6);
-                       u32b mode = PM_ALLOW_GROUP;
-
-                       if (pet) mode |= PM_FORCE_PET;
-                       else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
-
-                       if (summon_specific((pet ? -1 : 0), py, px,
-                                   dun_level, SUMMON_DEMON, mode))
+                       int slot = INVEN_RARM;
+                       o_ptr = &inventory[INVEN_RARM];
+                       if (buki_motteruka(INVEN_LARM) && one_in_(2))
+                       {
+                               o_ptr = &inventory[INVEN_LARM];
+                               slot = INVEN_LARM;
+                       }
+                       if (!cursed_p(o_ptr))
                        {
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤Ï¥Ç¡¼¥â¥ó¤ò°ú¤­´ó¤»¤¿¡ª");
+                               msg_print("Éð´ï¤òÍ¤Æ¤·¤Þ¤Ã¤¿¡ª");
 #else
-                               msg_print("You have attracted a demon!");
+                               msg_print("You drop your weapon!");
 #endif
 
-                               disturb(0, 0);
+                               inven_drop(slot, 1);
                        }
                }
+       }
+}
+
 
-               if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
+/*
+ * Handle curse effects once every 10 game turns
+ */
+static void process_world_aux_curse(void)
+{
+       if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
+       {
+               /*
+                * Hack: Uncursed teleporting items (e.g. Trump Weapons)
+                * can actually be useful!
+                */
+               if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
                {
-                       disturb(0, 0);
-                       if (one_in_(2))
+                       char o_name[MAX_NLEN];
+                       object_type *o_ptr;
+                       int i;
+
+                       /* Scan the equipment with random teleport ability */
+                       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
                        {
+                               u32b flgs[TR_FLAG_SIZE];
+                               o_ptr = &inventory[i];
+                               
+                               /* Skip non-objects */
+                               if (!o_ptr->k_idx) continue;
+                               
+                               /* Extract the item flags */
+                               object_flags(o_ptr, flgs);
+                               
+                               if (have_flag(flgs, TR_TELEPORT)) break;
+                       }
+
+                       object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
+
 #ifdef JP
-msg_print("ÀºÎÏŪ¤Ç¤Ê¤¯¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
+                       msg_format("%s¤¬¥Æ¥ì¥Ý¡¼¥È¤ÎǽÎϤòȯư¤µ¤»¤è¤¦¤È¤·¤Æ¤¤¤ë¡£", o_name);
 #else
-                               msg_print("You feel less energetic.");
+                       msg_format("Your %s is activating teleportation.", o_name);
 #endif
 
-                               if (p_ptr->fast > 0)
-                               {
-                                       set_fast(0, TRUE);
-                               }
-                               else
-                               {
-                                       set_slow(randint1(30) + 10, FALSE);
-                               }
+#ifdef JP
+                       if (get_check_strict("¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
+#else
+                       if (get_check_strict("Teleport? ", CHECK_OKAY_CANCEL))
+#endif
+                       {
+                               disturb(0, 0);
+                               teleport_player(50);
                        }
                        else
                        {
 #ifdef JP
-msg_print("ÀºÎÏŪ¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
+                               msg_format("%s¤Ë{.}(¥Ô¥ê¥ª¥É)¤ÈÌäò¹ï¤à¤Èȯư¤òÍÞÀ©¤Ç¤­¤Þ¤¹¡£", o_name);
 #else
-                               msg_print("You feel more energetic.");
+                               msg_format("You can inscribe {.} on your %s to disable random teleportation. ", o_name);
 #endif
-
-                               if (p_ptr->slow > 0)
-                               {
-                                       set_slow(0, TRUE);
-                               }
-                               else
-                               {
-                                       set_fast(randint1(30) + 10, FALSE);
-                               }
+                               disturb(1, 0);
                        }
-                       msg_print(NULL);
                }
-               if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
+               /* Make a chainsword noise */
+               if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
                {
-                       disturb(0, 0);
+                       char noise[1024];
 #ifdef JP
-msg_print("ÆÍÁ³¤Û¤È¤ó¤É¸ÉÆȤˤʤ俵¤¤¬¤¹¤ë¡£");
+                       if (!get_rnd_line("chainswd_j.txt", 0, noise))
 #else
-                       msg_print("You suddenly feel almost lonely.");
+                       if (!get_rnd_line("chainswd.txt", 0, noise))
 #endif
+                               msg_print(noise);
+                       disturb(FALSE, FALSE);
+               }
+               /* TY Curse */
+               if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
+               {
+                       int count = 0;
+                       (void)activate_ty_curse(FALSE, &count);
+               }
+               /* Handle experience draining */
+               if (p_ptr->prace != RACE_ANDROID && 
+                       ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
+               {
+                       p_ptr->exp -= (p_ptr->lev+1)/2;
+                       if (p_ptr->exp < 0) p_ptr->exp = 0;
+                       p_ptr->max_exp -= (p_ptr->lev+1)/2;
+                       if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
+                       check_experience();
+               }
+               /* Add light curse (Later) */
+               if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
+               {
+                       u32b new_curse;
+                       object_type *o_ptr;
+
+                       o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
 
-                       banish_monsters(100);
-                       if (!dun_level && p_ptr->town_num)
+                       new_curse = get_curse(0, o_ptr);
+                       if (!(o_ptr->curse_flags & new_curse))
                        {
-                               int n;
+                               char o_name[MAX_NLEN];
 
-                               /* Pick a random shop (except home) */
-                               do
-                               {
-                                       n = randint0(MAX_STORES);
-                               }
-                               while ((n == STORE_HOME) || (n == STORE_MUSEUM));
+                               object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
+                               o_ptr->curse_flags |= new_curse;
 #ifdef JP
-                               msg_print("Ź¤Î¼ç¿Í¤¬µÖ¤Ë¸þ¤«¤Ã¤ÆÁö¤Ã¤Æ¤¤¤ë¡ª");
+                               msg_format("°­°Õ¤ËËþ¤Á¤¿¹õ¤¤¥ª¡¼¥é¤¬%s¤ò¤È¤ê¤Þ¤¤¤¿...", o_name);
 #else
-                               msg_print("You see one of the shopkeepers running for the hills!");
+                               msg_format("There is a malignant black aura surrounding your %s...", o_name);
 #endif
 
-                               store_shuffle(n);
+                               o_ptr->feeling = FEEL_NONE;
+
+                               p_ptr->update |= (PU_BONUS);
                        }
-                       msg_print(NULL);
                }
-
-               if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
+               /* Add heavy curse (Later) */
+               if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
                {
+                       u32b new_curse;
                        object_type *o_ptr;
 
-#ifdef JP
-msg_print("±Æ¤Ë¤Ä¤Ä¤Þ¤ì¤¿¡£");
-#else
-                       msg_print("A shadow passes over you.");
-#endif
-
-                       msg_print(NULL);
-
-                       /* Absorb light from the current possition */
-                       if ((cave[py][px].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
-                       {
-                               hp_player(10);
-                       }
-
-                       o_ptr = &inventory[INVEN_LITE];
+                       o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
 
-                       /* Absorb some fuel in the current lite */
-                       if (o_ptr->tval == TV_LITE)
+                       new_curse = get_curse(1, o_ptr);
+                       if (!(o_ptr->curse_flags & new_curse))
                        {
-                               /* Use some fuel (except on artifacts) */
-                               if (!artifact_p(o_ptr) && (o_ptr->xtra4 > 0))
-                               {
-                                       /* Heal the player a bit */
-                                       hp_player(o_ptr->xtra4 / 20);
+                               char o_name[MAX_NLEN];
 
-                                       /* Decrease life-span of lite */
-                                       o_ptr->xtra4 /= 2;
+                               object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
+                               o_ptr->curse_flags |= new_curse;
 #ifdef JP
-msg_print("¸÷¸»¤«¤é¥¨¥Í¥ë¥®¡¼¤òµÛ¼ý¤·¤¿¡ª");
+                               msg_format("°­°Õ¤ËËþ¤Á¤¿¹õ¤¤¥ª¡¼¥é¤¬%s¤ò¤È¤ê¤Þ¤¤¤¿...", o_name);
 #else
-                                       msg_print("You absorb energy from your light!");
+                               msg_format("There is a malignant black aura surrounding your %s...", o_name);
 #endif
 
+                               o_ptr->feeling = FEEL_NONE;
 
-                                       /* Notice interesting fuel steps */
-                                       notice_lite_change(o_ptr);
-                               }
+                               p_ptr->update |= (PU_BONUS);
                        }
-
-                       /*
-                        * Unlite the area (radius 10) around player and
-                        * do 50 points damage to every affected monster
-                        */
-                       unlite_area(50, 10);
                }
-
-               if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
-                  !p_ptr->anti_magic && one_in_(7000))
+               /* Call animal */
+               if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
                {
-                       bool pet = one_in_(3);
-                       u32b mode = PM_ALLOW_GROUP;
-
-                       if (pet) mode |= PM_FORCE_PET;
-                       else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
-
-                       if (summon_specific((pet ? -1 : 0), py, px, dun_level, SUMMON_ANIMAL, mode))
+                       if (summon_specific(0, py, px, dun_level, SUMMON_ANIMAL,
+                           (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                        {
+                               char o_name[MAX_NLEN];
+
+                               object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
-msg_print("ưʪ¤ò°ú¤­´ó¤»¤¿¡ª");
+                               msg_format("%s¤¬Æ°Êª¤ò°ú¤­´ó¤»¤¿¡ª", o_name);
 #else
-                               msg_print("You have attracted an animal!");
+                               msg_format("Your %s have attracted an animal!", o_name);
 #endif
 
                                disturb(0, 0);
                        }
                }
-
-               if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
-                   !p_ptr->anti_magic && one_in_(8000))
-               {
-                       disturb(0, 0);
-#ifdef JP
-msg_print("¼þ¤ê¤Î¶õ´Ö¤¬ÏĤó¤Ç¤¤¤ëµ¤¤¬¤¹¤ë¡ª");
-#else
-                       msg_print("You feel the world warping around you!");
-#endif
-
-                       msg_print(NULL);
-                       fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
-               }
-               if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
+               /* Call demon */
+               if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
                {
-                       if (!lose_mutation(0))
-#ifdef JP
-msg_print("´ñ̯¤Ê¤¯¤é¤¤ÉáÄ̤ˤʤ俵¤¤¬¤¹¤ë¡£");
-#else
-                               msg_print("You feel oddly normal.");
-#endif
+                       if (summon_specific(0, py, px, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
+                       {
+                               char o_name[MAX_NLEN];
 
-               }
-               if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
-               {
-                       disturb(0, 0);
+                               object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
-msg_print("Èóʪ¼Á²½¤·¤¿¡ª");
+                               msg_format("%s¤¬°­Ëâ¤ò°ú¤­´ó¤»¤¿¡ª", o_name);
 #else
-                       msg_print("You feel insubstantial!");
+                               msg_format("Your %s have attracted a demon!", o_name);
 #endif
 
-                       msg_print(NULL);
-                       set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
-               }
-               if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
-               {
-                       do_poly_wounds();
+                               disturb(0, 0);
+                       }
                }
-               if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
+               /* Call dragon */
+               if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
                {
-                       int which_stat = randint0(6);
-                       int sustained = FALSE;
-
-                       switch (which_stat)
+                       if (summon_specific(0, py, px, dun_level, SUMMON_DRAGON,
+                           (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                        {
-                       case A_STR:
-                               if (p_ptr->sustain_str) sustained = TRUE;
-                               break;
-                       case A_INT:
-                               if (p_ptr->sustain_int) sustained = TRUE;
-                               break;
-                       case A_WIS:
-                               if (p_ptr->sustain_wis) sustained = TRUE;
-                               break;
-                       case A_DEX:
-                               if (p_ptr->sustain_dex) sustained = TRUE;
-                               break;
-                       case A_CON:
-                               if (p_ptr->sustain_con) sustained = TRUE;
-                               break;
-                       case A_CHR:
-                               if (p_ptr->sustain_chr) sustained = TRUE;
-                               break;
-                       default:
+                               char o_name[MAX_NLEN];
+
+                               object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
-msg_print("ÉÔÀµ¤Ê¾õÂÖ¡ª");
+                               msg_format("%s¤¬¥É¥é¥´¥ó¤ò°ú¤­´ó¤»¤¿¡ª", o_name);
 #else
-                               msg_print("Invalid stat chosen!");
+                               msg_format("Your %s have attracted an animal!", o_name);
 #endif
 
-                               sustained = TRUE;
+                               disturb(0, 0);
                        }
-
-                       if (!sustained)
+               }
+               if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
+               {
+                       if (!p_ptr->resist_fear)
                        {
                                disturb(0, 0);
 #ifdef JP
-msg_print("¼«Ê¬¤¬¿ê¼å¤·¤Æ¤¤¤¯¤Î¤¬Ê¬¤«¤ë¡ª");
+                               msg_print("¤È¤Æ¤â°Å¤¤... ¤È¤Æ¤â¶²¤¤¡ª");
 #else
-                               msg_print("You can feel yourself wasting away!");
+                               msg_print("It's so dark... so scary!");
 #endif
 
-                               msg_print(NULL);
-                               (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
+                               set_afraid(p_ptr->afraid + 13 + randint1(26));
                        }
                }
-               if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
-                  !p_ptr->anti_magic && one_in_(3000))
+               /* Teleport player */
+               if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
                {
-                       bool pet = one_in_(5);
-                       u32b mode = PM_ALLOW_GROUP;
+                       disturb(0, 0);
 
-                       if (pet) mode |= PM_FORCE_PET;
-                       else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
+                       /* Teleport player */
+                       teleport_player(40);
+               }
+               /* Handle HP draining */
+               if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
+               {
+                       char o_name[MAX_NLEN];
 
-                       if (summon_specific((pet ? -1 : 0), py, px, dun_level, SUMMON_DRAGON, mode))
-                       {
+                       object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
-msg_print("¥É¥é¥´¥ó¤ò°ú¤­´ó¤»¤¿¡ª");
+                       msg_format("%s¤Ï¤¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¼ý¤·¤¿¡ª", o_name);
 #else
-                               msg_print("You have attracted a dragon!");
+                       msg_format("Your %s drains HP from you!", o_name);
 #endif
-
-                               disturb(0, 0);
-                       }
+                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
                }
-               if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
-                       one_in_(3000))
+               /* Handle mana draining */
+               if ((p_ptr->cursed & TRC_DRAIN_MANA) && one_in_(666))
                {
-                       if (p_ptr->tim_esp > 0)
-                       {
-#ifdef JP
-msg_print("Àº¿À¤Ë¤â¤ä¤¬¤«¤«¤Ã¤¿¡ª");
-#else
-                               msg_print("Your mind feels cloudy!");
-#endif
+                       char o_name[MAX_NLEN];
 
-                               set_tim_esp(0, TRUE);
-                       }
-                       else
-                       {
+                       object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
-msg_print("Àº¿À¤¬¹­¤¬¤Ã¤¿¡ª");
+                       msg_format("%s¤Ï¤¢¤Ê¤¿¤ÎËâÎϤòµÛ¼ý¤·¤¿¡ª", o_name);
 #else
-                               msg_print("Your mind expands!");
+                       msg_format("Your %s drains mana from you!", o_name);
 #endif
-
-                               set_tim_esp(p_ptr->lev, FALSE);
+                       p_ptr->csp -= MIN(p_ptr->lev, 50);
+                       if (p_ptr->csp < 0)
+                       {
+                               p_ptr->csp = 0;
+                               p_ptr->csp_frac = 0;
                        }
+                       p_ptr->redraw |= PR_MANA;
                }
-               if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
-                       one_in_(9000))
+       }
+
+       /* Rarely, take damage from the Jewel of Judgement */
+       if (one_in_(999) && !p_ptr->anti_magic)
+       {
+               object_type *o_ptr = &inventory[INVEN_LITE];
+
+               if (o_ptr->name1 == ART_JUDGE)
                {
-                       disturb(0, 0);
 #ifdef JP
-msg_print("°ß¤¬áÛÚ»¤·¡¢¿©»ö¤ò¼º¤Ã¤¿¡ª");
+                       if (object_known_p(o_ptr))
+                               msg_print("¡Ø¿³È½¤ÎÊõÀС٤Ϥ¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¼ý¤·¤¿¡ª");
+                       else
+                               msg_print("¤Ê¤Ë¤«¤¬¤¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¼ý¤·¤¿¡ª");
+                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "¿³È½¤ÎÊõÀÐ", -1);
 #else
-                       msg_print("Your stomach roils, and you lose your lunch!");
+                       if (object_known_p(o_ptr))
+                               msg_print("The Jewel of Judgement drains life from you!");
+                       else
+                               msg_print("Something drains life from you!");
+                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
 #endif
-
-                       msg_print(NULL);
-                       set_food(PY_FOOD_WEAK);
                }
+       }
+}
+
+
+/*
+ * Handle recharging objects once every 10 game turns
+ */
+static void process_world_aux_recharge(void)
+{
+       int i;
+       bool changed;
+
+       /* Process equipment */
+       for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
+       {
+               /* Get the object */
+               object_type *o_ptr = &inventory[i];
+
+               /* Skip non-objects */
+               if (!o_ptr->k_idx) continue;
 
-               if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
-                  !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
+               /* Recharge activatable objects */
+               if (o_ptr->timeout > 0)
                {
-                       alter_reality();
+                       /* Recharge */
+                       o_ptr->timeout--;
+
+                       /* Notice changes */
+                       if (!o_ptr->timeout)
+                       {
+                               recharged_notice(o_ptr);
+                               changed = TRUE;
+                       }
                }
+       }
+
+       /* Notice changes */
+       if (changed)
+       {
+               /* Window stuff */
+               p_ptr->window |= (PW_EQUIP);
+               wild_regen = 20;
+       }
+
+       /*
+        * Recharge rods.  Rods now use timeout to control charging status,
+        * and each charging rod in a stack decreases the stack's timeout by
+        * one per turn. -LM-
+        */
+       for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
+       {
+               object_type *o_ptr = &inventory[i];
+               object_kind *k_ptr = &k_info[o_ptr->k_idx];
+
+               /* Skip non-objects */
+               if (!o_ptr->k_idx) continue;
 
-               if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
+               /* Examine all charging rods or stacks of charging rods. */
+               if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
                {
-                       int danger_amount = 0;
-                       int monster;
+                       /* Determine how many rods are charging. */
+                       int temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
+                       if (temp > o_ptr->number) temp = o_ptr->number;
 
-                       for (monster = 0; monster < m_max; monster++)
-                       {
-                               monster_type    *m_ptr = &m_list[monster];
-                               monster_race    *r_ptr = &r_info[m_ptr->r_idx];
+                       /* Decrease timeout by that number. */
+                       o_ptr->timeout -= temp;
 
-                               /* Paranoia -- Skip dead monsters */
-                               if (!m_ptr->r_idx) continue;
+                       /* Boundary control. */
+                       if (o_ptr->timeout < 0) o_ptr->timeout = 0;
 
-                               if (r_ptr->level >= p_ptr->lev)
-                               {
-                                       danger_amount += r_ptr->level - p_ptr->lev + 1;
-                               }
+                       /* Notice changes, provide message if object is inscribed. */
+                       if (!(o_ptr->timeout))
+                       {
+                               recharged_notice(o_ptr);
+                               changed = TRUE;
                        }
+               }
+       }
 
-                       if (danger_amount > 100)
-#ifdef JP
-msg_print("Èó¾ï¤Ë¶²¤í¤·¤¤µ¤¤¬¤¹¤ë¡ª");
-#else
-                               msg_print("You feel utterly terrified!");
-#endif
+       /* Notice changes */
+       if (changed)
+       {
+               /* Combine pack */
+               p_ptr->notice |= (PN_COMBINE);
 
-                       else if (danger_amount > 50)
-#ifdef JP
-msg_print("¶²¤í¤·¤¤µ¤¤¬¤¹¤ë¡ª");
-#else
-                               msg_print("You feel terrified!");
-#endif
+               /* Window stuff */
+               p_ptr->window |= (PW_INVEN);
+               wild_regen = 20;
+       }
 
-                       else if (danger_amount > 20)
-#ifdef JP
-msg_print("Èó¾ï¤Ë¿´Çۤʵ¤¤¬¤¹¤ë¡ª");
-#else
-                               msg_print("You feel very worried!");
-#endif
+       /* Process objects on floor */
+       for (i = 1; i < o_max; i++)
+       {
+               /* Access object */
+               object_type *o_ptr = &o_list[i];
 
-                       else if (danger_amount > 10)
-#ifdef JP
-msg_print("¿´Çۤʵ¤¤¬¤¹¤ë¡ª");
-#else
-                               msg_print("You feel paranoid!");
-#endif
+               /* Skip dead objects */
+               if (!o_ptr->k_idx) continue;
+
+               /* Recharge rods on the ground.  No messages. */
+               if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
+               {
+                       /* Charge it */
+                       o_ptr->timeout -= o_ptr->number;
+
+                       /* Boundary control. */
+                       if (o_ptr->timeout < 0) o_ptr->timeout = 0;
+               }
+       }
+}
+
+
+/*
+ * Handle involuntary movement once every 10 game turns
+ */
+static void process_world_aux_movement(void)
+{
+       /* Delayed Word-of-Recall */
+       if (p_ptr->word_recall)
+       {
+               /*
+                * HACK: Autosave BEFORE resetting the recall counter (rr9)
+                * The player is yanked up/down as soon as
+                * he loads the autosaved game.
+                */
+               if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
+                       do_cmd_save_game(TRUE);
+
+               /* Count down towards recall */
+               p_ptr->word_recall--;
+
+               p_ptr->redraw |= (PR_STATUS);
 
-                       else if (danger_amount > 5)
+               /* Activate the recall */
+               if (!p_ptr->word_recall)
+               {
+                       /* Disturbing! */
+                       disturb(0, 0);
+
+                       /* Determine the level */
+                       if (dun_level || p_ptr->inside_quest)
+                       {
 #ifdef JP
-msg_print("¤Û¤È¤ó¤É°ÂÁ´¤Êµ¤¤¬¤¹¤ë¡£");
+msg_print("¾å¤Ë°ú¤ÃÄ¥¤ê¤¢¤²¤é¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª");
 #else
-                               msg_print("You feel almost safe.");
+                               msg_print("You feel yourself yanked upwards!");
 #endif
 
+                               p_ptr->recall_dungeon = dungeon_type;
+                               if (record_stair)
+                                       do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
+
+                               dun_level = 0;
+                               dungeon_type = 0;
+
+                               leave_quest_check();
+
+                               p_ptr->inside_quest = 0;
+
+                               p_ptr->leaving = TRUE;
+                       }
                        else
+                       {
 #ifdef JP
-msg_print("¼ä¤·¤¤µ¤¤¬¤¹¤ë¡£");
+msg_print("²¼¤Ë°ú¤­¤º¤ê¹ß¤í¤µ¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª");
 #else
-                               msg_print("You feel lonely.");
+                               msg_print("You feel yourself yanked downwards!");
 #endif
 
-               }
-               if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
-                       one_in_(5000))
-               {
-                       disturb(0, 0);
-#ifdef JP
-msg_print("̵Ũ¤Êµ¤¤¬¤¹¤ë¡ª");
-#else
-                       msg_print("You feel invincible!");
-#endif
+                               dungeon_type = p_ptr->recall_dungeon;
 
-                       msg_print(NULL);
-                       (void)set_invuln(randint1(8) + 8, FALSE);
-               }
-               if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
-               {
-                       int wounds = p_ptr->mhp - p_ptr->chp;
+                               if (record_stair)
+                                       do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
+
+                               /* New depth */
+                               dun_level = max_dlv[dungeon_type];
+                               if (dun_level < 1) dun_level = 1;
+
+                               /* Nightmare mode makes recall more dangerous */
+                               if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
+                               {
+                                       if (dun_level < 50)
+                                       {
+                                               dun_level *= 2;
+                                       }
+                                       else if (dun_level < 99)
+                                       {
+                                               dun_level = (dun_level + 99) / 2;
+                                       }
+                                       else if (dun_level > 100)
+                                       {
+                                               dun_level = d_info[dungeon_type].maxdepth - 1;
+                                       }
+                               }
+
+                               if (p_ptr->wild_mode)
+                               {
+                                       p_ptr->wilderness_y = py;
+                                       p_ptr->wilderness_x = px;
+                               }
+                               else
+                               {
+                                       /* Save player position */
+                                       p_ptr->oldpx = px;
+                                       p_ptr->oldpy = py;
+                               }
+                               p_ptr->wild_mode = FALSE;
 
-                       if (wounds > 0)
-                       {
-                               int healing = p_ptr->csp;
+                               /*
+                                * Clear all saved floors
+                                * and create a first saved floor
+                                */
+                               prepare_change_floor_mode(CFM_FIRST_FLOOR);
 
-                               if (healing > wounds)
-                               {
-                                       healing = wounds;
-                               }
+                               /* Leaving */
+                               p_ptr->leaving = TRUE;
 
-                               hp_player(healing);
-                               p_ptr->csp -= healing;
+                               if (dungeon_type == DUNGEON_ANGBAND)
+                               {
+                                       int i;
 
-                               /* Redraw mana */
-                               p_ptr->redraw |= (PR_MANA);
+                                       for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
+                                       {
+                                               if ((quest[i].type == QUEST_TYPE_RANDOM) &&
+                                                   (quest[i].status == QUEST_STATUS_TAKEN) &&
+                                                   (quest[i].level < dun_level))
+                                               {
+                                                       quest[i].status = QUEST_STATUS_FAILED;
+                                                       quest[i].complev = (byte)p_ptr->lev;
+                                                       r_info[quest[i].r_idx].flags1 &= ~(RF1_QUESTOR);
+                                               }
+                                       }
+                               }
                        }
+
+                       /* Sound */
+                       sound(SOUND_TPLEVEL);
                }
-               if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
-                       one_in_(4000))
-               {
-                       int wounds = p_ptr->msp - p_ptr->csp;
+       }
 
-                       if (wounds > 0)
-                       {
-                               int healing = p_ptr->chp;
 
-                               if (healing > wounds)
-                               {
-                                       healing = wounds;
-                               }
+       /* Delayed Alter reality */
+       if (p_ptr->alter_reality)
+       {
+               if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
+                       do_cmd_save_game(TRUE);
 
-                               p_ptr->csp += healing;
+               /* Count down towards alter */
+               p_ptr->alter_reality--;
 
-                               /* Redraw mana */
-                               p_ptr->redraw |= (PR_MANA);
-#ifdef JP
-take_hit(DAMAGE_LOSELIFE, healing, "Ƭ¤Ë¾º¤Ã¤¿·ì", -1);
-#else
-                               take_hit(DAMAGE_LOSELIFE, healing, "blood rushing to the head", -1);
-#endif
+               p_ptr->redraw |= (PR_STATUS);
 
-                       }
-               }
-               if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
+               /* Activate the alter reality */
+               if (!p_ptr->alter_reality)
                {
-                       object_type *o_ptr;
-
+                       /* Disturbing! */
                        disturb(0, 0);
+
+                       /* Determine the level */
+                       if (!quest_number(dun_level) && dun_level)
+                       {
 #ifdef JP
-msg_print("­¤¬¤â¤Ä¤ì¤Æž¤ó¤À¡ª");
-take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), "žÅÝ", -1);
+                               msg_print("À¤³¦¤¬ÊѤï¤Ã¤¿¡ª");
 #else
-                       msg_print("You trip over your own feet!");
-                       take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), "tripping", -1);
+                               msg_print("The world changes!");
 #endif
 
-
-                       msg_print(NULL);
-                       if (buki_motteruka(INVEN_RARM))
+                               /* Leaving */
+                               p_ptr->leaving = TRUE;
+                       }
+                       else
                        {
-                               int slot = INVEN_RARM;
-                               o_ptr = &inventory[INVEN_RARM];
-                               if (buki_motteruka(INVEN_LARM) && one_in_(2))
-                               {
-                                       o_ptr = &inventory[INVEN_LARM];
-                                       slot = INVEN_LARM;
-                               }
-                               if (!cursed_p(o_ptr))
-                               {
 #ifdef JP
-msg_print("Éð´ï¤òÍ¤Æ¤·¤Þ¤Ã¤¿¡ª");
+                               msg_print("À¤³¦¤¬¾¯¤·¤Î´ÖÊѲ½¤·¤¿¤è¤¦¤À¡£");
 #else
-                                       msg_print("You drop your weapon!");
+                               msg_print("The world seems to change for a moment!");
 #endif
-
-                                       inven_drop(slot, 1);
-                               }
                        }
+
+                       /* Sound */
+                       sound(SOUND_TPLEVEL);
                }
        }
+}
+
+
+/*
+ * Handle certain things once every 10 game turns
+ */
+static void process_world(void)
+{
+       int day, hour, min, prev_min;
 
+       const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
+       s32b turn_in_today = (turn + A_DAY / 4) % A_DAY;
+       
+       extract_day_hour_min(&day, &hour, &min);
+       prev_min = (1440 * (turn_in_today - TURNS_PER_TICK) / A_DAY) % 60;
 
-       /*** Process Inventory ***/
 
-       if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
+       if ((turn - old_turn == (150 - dun_level) * TURNS_PER_TICK)
+           && dun_level && !p_ptr->inside_battle)
        {
-               /*
-                * Hack: Uncursed teleporting items (e.g. Trump Weapons)
-                * can actually be useful!
-                */
-               if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
+               int quest_num = quest_number(dun_level);
+
+               /* Get dungeon level feeling */
+               if (!(quest_num &&
+                     (is_fixed_quest_idx(quest_num) &&
+                      !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
+                        !(quest[quest_num].flags & QUEST_FLAG_PRESET)))))
                {
-                       char o_name[MAX_NLEN];
-                       object_type *o_ptr;
-                       int i;
+                       /* Announce feeling */
+                       do_cmd_feeling();
 
-                       /* Scan the equipment with random teleport ability */
-                       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
-                       {
-                               u32b flgs[TR_FLAG_SIZE];
-                               o_ptr = &inventory[i];
-                               
-                               /* Skip non-objects */
-                               if (!o_ptr->k_idx) continue;
-                               
-                               /* Extract the item flags */
-                               object_flags(o_ptr, flgs);
-                               
-                               if (have_flag(flgs, TR_TELEPORT)) break;
-                       }
+                       /* Update the level indicator */
+                       p_ptr->redraw |= (PR_DEPTH);
 
-                       object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
+                       /* Disturb */
+                       if (disturb_minor) disturb(0, 0);
+               }
+       }
 
-#ifdef JP
-                       msg_format("%s¤¬¥Æ¥ì¥Ý¡¼¥È¤ÎǽÎϤòȯư¤µ¤»¤è¤¦¤È¤·¤Æ¤¤¤ë¡£", o_name);
-#else
-                       msg_format("Your %s is activating teleportation.", o_name);
-#endif
+       /*** Check monster arena ***/
+       if (p_ptr->inside_battle && !p_ptr->leaving)
+       {
+               int i2, j2;
+               int win_m_idx = 0;
+               int number_mon = 0;
 
-#ifdef JP
-                       if (get_check_strict("¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
-#else
-                       if (get_check_strict("Teleport? ", CHECK_OKAY_CANCEL))
-#endif
-                       {
-                               disturb(0, 0);
-                               teleport_player(50);
-                       }
-                       else
+               /* Count all hostile monsters */
+               for (i2 = 0; i2 < cur_wid; ++i2)
+                       for (j2 = 0; j2 < cur_hgt; j2++)
                        {
-#ifdef JP
-                               msg_format("%s¤Ë{.}(¥Ô¥ê¥ª¥É)¤ÈÌäò¹ï¤à¤Èȯư¤òÍÞÀ©¤Ç¤­¤Þ¤¹¡£", o_name);
-#else
-                               msg_format("You can inscribe {.} on your %s to disable random teleportation. ", o_name);
-#endif
-                               disturb(1, 0);
+                               cave_type *c_ptr = &cave[j2][i2];
+
+                               if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
+                               {
+                                       number_mon++;
+                                       win_m_idx = c_ptr->m_idx;
+                               }
                        }
-               }
-               /* Make a chainsword noise */
-               if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
+
+               if (number_mon == 0)
                {
-                       char noise[1024];
 #ifdef JP
-                       if (!get_rnd_line("chainswd_j.txt", 0, noise))
+                       msg_print("ÁêÂǤÁ¤Ë½ª¤ï¤ê¤Þ¤·¤¿¡£");
 #else
-                       if (!get_rnd_line("chainswd.txt", 0, noise))
+                       msg_print("They have kill each other at the same time.");
 #endif
-                               msg_print(noise);
-                       disturb(FALSE, FALSE);
-               }
-               /* TY Curse */
-               if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
-               {
-                       int count = 0;
-                       (void)activate_ty_curse(FALSE, &count);
-               }
-               /* Handle experience draining */
-               if (p_ptr->prace != RACE_ANDROID && 
-                       ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
-               {
-                       p_ptr->exp -= (p_ptr->lev+1)/2;
-                       if (p_ptr->exp < 0) p_ptr->exp = 0;
-                       p_ptr->max_exp -= (p_ptr->lev+1)/2;
-                       if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
-                       check_experience();
+                       msg_print(NULL);
+                       p_ptr->energy_need = 0;
+                       battle_monsters();
                }
-               /* Add light curse (Later) */
-               if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
+               else if ((number_mon-1) == 0)
                {
-                       u32b new_curse;
-                       object_type *o_ptr;
-
-                       o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
-
-                       new_curse = get_curse(0, o_ptr);
-                       if (!(o_ptr->curse_flags & new_curse))
-                       {
-                               char o_name[MAX_NLEN];
+                       char m_name[80];
+                       monster_type *wm_ptr;
 
-                               object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
+                       wm_ptr = &m_list[win_m_idx];
 
-                               o_ptr->curse_flags |= new_curse;
+                       monster_desc(m_name, wm_ptr, 0);
 #ifdef JP
-                               msg_format("°­°Õ¤ËËþ¤Á¤¿¹õ¤¤¥ª¡¼¥é¤¬%s¤ò¤È¤ê¤Þ¤¤¤¿...", o_name);
+                       msg_format("%s¤¬¾¡Íø¤·¤¿¡ª", m_name);
 #else
-                               msg_format("There is a malignant black aura surrounding your %s...", o_name);
+                       msg_format("%s is winner!", m_name);
 #endif
+                       msg_print(NULL);
 
-                               o_ptr->feeling = FEEL_NONE;
-
-                               p_ptr->update |= (PU_BONUS);
-                       }
-               }
-               /* Add heavy curse (Later) */
-               if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
-               {
-                       u32b new_curse;
-                       object_type *o_ptr;
-
-                       o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
-
-                       new_curse = get_curse(1, o_ptr);
-                       if (!(o_ptr->curse_flags & new_curse))
+                       if (win_m_idx == (sel_monster+1))
                        {
-                               char o_name[MAX_NLEN];
-
-                               object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-
-                               o_ptr->curse_flags |= new_curse;
 #ifdef JP
-                               msg_format("°­°Õ¤ËËþ¤Á¤¿¹õ¤¤¥ª¡¼¥é¤¬%s¤ò¤È¤ê¤Þ¤¤¤¿...", o_name);
+                               msg_print("¤ª¤á¤Ç¤È¤¦¤´¤¶¤¤¤Þ¤¹¡£");
 #else
-                               msg_format("There is a malignant black aura surrounding your %s...", o_name);
+                               msg_print("Congratulations.");
 #endif
-
-                               o_ptr->feeling = FEEL_NONE;
-
-                               p_ptr->update |= (PU_BONUS);
+#ifdef JP
+                               msg_format("%d¡ð¤ò¼õ¤±¼è¤Ã¤¿¡£", battle_odds);
+#else
+                               msg_format("You received %d gold.", battle_odds);
+#endif
+                               p_ptr->au += battle_odds;
                        }
-               }
-               /* Call animal */
-               if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
-               {
-                       if (summon_specific(0, py, px, dun_level, SUMMON_ANIMAL,
-                           (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
+                       else
                        {
-                               char o_name[MAX_NLEN];
-
-                               object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
-                               msg_format("%s¤¬Æ°Êª¤ò°ú¤­´ó¤»¤¿¡ª", o_name);
+                               msg_print("»ÄÇ°¤Ç¤·¤¿¡£");
 #else
-                               msg_format("Your %s have attracted an animal!", o_name);
+                               msg_print("You lost gold.");
 #endif
-
-                               disturb(0, 0);
                        }
+                       msg_print(NULL);
+                       p_ptr->energy_need = 0;
+                       battle_monsters();
                }
-               /* Call demon */
-               if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
+               else if(turn - old_turn == 150*TURNS_PER_TICK)
                {
-                       if (summon_specific(0, py, px, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
-                       {
-                               char o_name[MAX_NLEN];
-
-                               object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
-                               msg_format("%s¤¬°­Ëâ¤ò°ú¤­´ó¤»¤¿¡ª", o_name);
+                       msg_print("¿½¤·Ê¬¤±¤¢¤ê¤Þ¤»¤ó¤¬¡¢¤³¤Î¾¡Éé¤Ï°ú¤­Ê¬¤±¤È¤µ¤»¤Æ¤¤¤¿¤À¤­¤Þ¤¹¡£");
 #else
-                               msg_format("Your %s have attracted a demon!", o_name);
+                       msg_format("This battle have ended in a draw.");
 #endif
-
-                               disturb(0, 0);
-                       }
+                       p_ptr->au += kakekin;
+                       msg_print(NULL);
+                       p_ptr->energy_need = 0;
+                       battle_monsters();
                }
-               /* Call dragon */
-               if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
+       }
+
+       /* Every 10 game turns */
+       if (turn % TURNS_PER_TICK) return;
+
+       /*** Check the Time and Load ***/
+
+       if (!(turn % (50*TURNS_PER_TICK)))
+       {
+               /* Check time and load */
+               if ((0 != check_time()) || (0 != check_load()))
                {
-                       if (summon_specific(0, py, px, dun_level, SUMMON_DRAGON,
-                           (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
+                       /* Warning */
+                       if (closing_flag <= 2)
                        {
-                               char o_name[MAX_NLEN];
+                               /* Disturb */
+                               disturb(0, 0);
 
-                               object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
+                               /* Count warnings */
+                               closing_flag++;
+
+                               /* Message */
 #ifdef JP
-                               msg_format("%s¤¬¥É¥é¥´¥ó¤ò°ú¤­´ó¤»¤¿¡ª", o_name);
+msg_print("¥¢¥ó¥°¥Ð¥ó¥É¤Ø¤ÎÌ礬ÊĤ¸¤«¤«¤Ã¤Æ¤¤¤Þ¤¹...");
+msg_print("¥²¡¼¥à¤ò½ªÎ»¤¹¤ë¤«¥»¡¼¥Ö¤¹¤ë¤«¤·¤Æ²¼¤µ¤¤¡£");
 #else
-                               msg_format("Your %s have attracted an animal!", o_name);
+                               msg_print("The gates to ANGBAND are closing...");
+                               msg_print("Please finish up and/or save your game.");
 #endif
 
-                               disturb(0, 0);
                        }
-               }
-               if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
-               {
-                       if (!p_ptr->resist_fear)
+
+                       /* Slam the gate */
+                       else
                        {
-                               disturb(0, 0);
+                               /* Message */
 #ifdef JP
-                               msg_print("¤È¤Æ¤â°Å¤¤... ¤È¤Æ¤â¶²¤¤¡ª");
+msg_print("º£¡¢¥¢¥ó¥°¥Ð¥ó¥É¤Ø¤ÎÌ礬ÊĤ¶¤µ¤ì¤Þ¤·¤¿¡£");
 #else
-                               msg_print("It's so dark... so scary!");
+                               msg_print("The gates to ANGBAND are now closed.");
 #endif
 
-                               set_afraid(p_ptr->afraid + 13 + randint1(26));
+
+                               /* Stop playing */
+                               p_ptr->playing = FALSE;
+
+                               /* Leaving */
+                               p_ptr->leaving = TRUE;
                        }
                }
-               /* Teleport player */
-               if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
-               {
-                       disturb(0, 0);
+       }
 
-                       /* Teleport player */
-                       teleport_player(40);
-               }
-               /* Handle HP draining */
-               if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
-               {
-                       char o_name[MAX_NLEN];
+       /*** Attempt timed autosave ***/
+       if (autosave_t && autosave_freq && !p_ptr->inside_battle)
+       {
+               if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
+                       do_cmd_save_game(TRUE);
+       }
 
-                       object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
+       if (mon_fight)
+       {
 #ifdef JP
-                       msg_format("%s¤Ï¤¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¼ý¤·¤¿¡ª", o_name);
+               msg_print("²¿¤«¤¬Ê¹¤³¤¨¤¿¡£");
 #else
-                       msg_format("Your %s drains HP from you!", o_name);
+               msg_print("You hear noise.");
 #endif
-                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
-               }
-               /* Handle mana draining */
-               if ((p_ptr->cursed & TRC_DRAIN_MANA) && one_in_(666))
+       }
+
+       /*** Handle the wilderness/town (sunshine) ***/
+
+       /* While in town/wilderness */
+       if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena && !p_ptr->wild_mode)
+       {
+               /* Hack -- Daybreak/Nighfall in town */
+               if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
                {
-                       char o_name[MAX_NLEN];
+                       bool dawn;
 
-                       object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
+                       /* Check for dawn */
+                       dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
+
+                       /* Day breaks */
+                       if (dawn)
+                       {
+                               int y, x;
+
+                               /* Message */
 #ifdef JP
-                       msg_format("%s¤Ï¤¢¤Ê¤¿¤ÎËâÎϤòµÛ¼ý¤·¤¿¡ª", o_name);
+                               msg_print("Ì뤬ÌÀ¤±¤¿¡£");
 #else
-                       msg_format("Your %s drains mana from you!", o_name);
+                               msg_print("The sun has risen.");
 #endif
-                       p_ptr->csp -= MIN(p_ptr->lev, 50);
-                       if (p_ptr->csp < 0)
-                       {
-                               p_ptr->csp = 0;
-                               p_ptr->csp_frac = 0;
+
+                               /* Hack -- Scan the town */
+                               for (y = 0; y < cur_hgt; y++)
+                               {
+                                       for (x = 0; x < cur_wid; x++)
+                                       {
+                                               /* Get the cave grid */
+                                               cave_type *c_ptr = &cave[y][x];
+
+                                               /* Assume lit */
+                                               c_ptr->info |= (CAVE_GLOW);
+
+                                               /* Hack -- Memorize lit grids if allowed */
+                                               if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
+
+                                               /* Hack -- Notice spot */
+                                               note_spot(y, x);
+                                       }
+                               }
                        }
-                       p_ptr->redraw |= PR_MANA;
-               }
-       }
 
-       /* Rarely, take damage from the Jewel of Judgement */
-       if (one_in_(999) && !p_ptr->anti_magic)
-       {
-               object_type *o_ptr = &inventory[INVEN_LITE];
+                       /* Night falls */
+                       else
+                       {
+                               int y, x;
 
-               if (o_ptr->name1 == ART_JUDGE)
-               {
+                               /* Message */
 #ifdef JP
-                       if (object_known_p(o_ptr))
-                               msg_print("¡Ø¿³È½¤ÎÊõÀС٤Ϥ¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¼ý¤·¤¿¡ª");
-                       else
-                               msg_print("¤Ê¤Ë¤«¤¬¤¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¼ý¤·¤¿¡ª");
-                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "¿³È½¤ÎÊõÀÐ", -1);
+                               msg_print("Æü¤¬ÄÀ¤ó¤À¡£");
 #else
-                       if (object_known_p(o_ptr))
-                               msg_print("The Jewel of Judgement drains life from you!");
-                       else
-                               msg_print("Something drains life from you!");
-                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
+                               msg_print("The sun has fallen.");
 #endif
-               }
-       }
 
+                               /* Hack -- Scan the town */
+                               for (y = 0; y < cur_hgt; y++)
+                               {
+                                       for (x = 0; x < cur_wid; x++)
+                                       {
+                                               /* Get the cave grid */
+                                               cave_type *c_ptr = &cave[y][x];
 
-       /* Process equipment */
-       for (j = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
-       {
-               /* Get the object */
-               o_ptr = &inventory[i];
+                                               /* Feature code (applying "mimic" field) */
+                                               feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
 
-               /* Skip non-objects */
-               if (!o_ptr->k_idx) continue;
+                                               if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
+                                                   !have_flag(f_ptr->flags, FF_ENTRANCE))
+                                               {
+                                                       /* Assume dark */
+                                                       c_ptr->info &= ~(CAVE_GLOW);
 
-               /* Recharge activatable objects */
-               if (o_ptr->timeout > 0)
-               {
-                       /* Recharge */
-                       o_ptr->timeout--;
+                                                       if (!have_flag(f_ptr->flags, FF_REMEMBER))
+                                                       {
+                                                               /* Forget the normal floor grid */
+                                                               c_ptr->info &= ~(CAVE_MARK);
 
-                       /* Notice changes */
-                       if (!o_ptr->timeout)
-                       {
-                               recharged_notice(o_ptr);
-                               j++;
+                                                               /* Hack -- Notice spot */
+                                                               note_spot(y, x);
+                                                       }
+                                               }
+                                       }
+
+                                       /* Glow deep lava and building entrances */
+                                       glow_deep_lava_and_bldg();
+                               }
                        }
+
+                       /* Update the monsters */
+                       p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
+
+                       /* Redraw map */
+                       p_ptr->redraw |= (PR_MAP);
+
+                       /* Window stuff */
+                       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                }
        }
 
-       /* Notice changes */
-       if (j)
+       /* While in the dungeon (vanilla_town or lite_town mode only) */
+       else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
        {
-               /* Window stuff */
-               p_ptr->window |= (PW_EQUIP);
-               wild_regen = 20;
-       }
+               /*** Shuffle the Storekeepers ***/
 
-       /*
-        * Recharge rods.  Rods now use timeout to control charging status,
-        * and each charging rod in a stack decreases the stack's timeout by
-        * one per turn. -LM-
-        */
-       for (j = 0, i = 0; i < INVEN_PACK; i++)
-       {
-               o_ptr = &inventory[i];
-               k_ptr = &k_info[o_ptr->k_idx];
+               /* Chance is only once a day (while in dungeon) */
+               if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
+               {
+                       /* Sometimes, shuffle the shop-keepers */
+                       if (one_in_(STORE_SHUFFLE))
+                       {
+                               int n, i;
+
+                               /* Pick a random shop (except home and museum) */
+                               do
+                               {
+                                       n = randint0(MAX_STORES);
+                               }
+                               while ((n == STORE_HOME) || (n == STORE_MUSEUM));
+
+                               /* Check every feature */
+                               for (i = 1; i < max_f_idx; i++)
+                               {
+                                       /* Access the index */
+                                       feature_type *f_ptr = &f_info[i];
 
-               /* Skip non-objects */
-               if (!o_ptr->k_idx) continue;
+                                       /* Skip empty index */
+                                       if (!f_ptr->name) continue;
 
-               /* Examine all charging rods or stacks of charging rods. */
-               if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
-               {
-                       /* Determine how many rods are charging. */
-                       temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
-                       if (temp > o_ptr->number) temp = o_ptr->number;
+                                       /* Skip non-store features */
+                                       if (!have_flag(f_ptr->flags, FF_STORE)) continue;
 
-                       /* Decrease timeout by that number. */
-                       o_ptr->timeout -= temp;
+                                       /* Verify store type */
+                                       if (f_ptr->power == n)
+                                       {
+                                               /* Message */
+#ifdef JP
+                                               if (cheat_xtra) msg_format("%s¤ÎŹ¼ç¤ò¥·¥ã¥Ã¥Õ¥ë¤·¤Þ¤¹¡£", f_name + f_ptr->name);
+#else
+                                               if (cheat_xtra) msg_format("Shuffle a Shopkeeper of %s.", f_name + f_ptr->name);
+#endif
 
-                       /* Boundary control. */
-                       if (o_ptr->timeout < 0) o_ptr->timeout = 0;
+                                               /* Shuffle it */
+                                               store_shuffle(n);
 
-                       /* Notice changes, provide message if object is inscribed. */
-                       if (!(o_ptr->timeout))
-                       {
-                               recharged_notice(o_ptr);
-                               j++;
+                                               break;
+                                       }
+                               }
                        }
                }
        }
 
-       /* Notice changes */
-       if (j)
-       {
-               /* Combine pack */
-               p_ptr->notice |= (PN_COMBINE);
 
-               /* Window stuff */
-               p_ptr->window |= (PW_INVEN);
-               wild_regen = 20;
+       /*** Process the monsters ***/
+
+       /* Check for creature generation. */
+       if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
+           !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
+       {
+               /* Make a new monster */
+               (void)alloc_monster(MAX_SIGHT + 5, 0);
        }
 
-       /* Feel the inventory */
-       sense_inventory1();
-       sense_inventory2();
+       /* Hack -- Check for creature regeneration */
+       if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
+       if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
 
+       /* Hack -- Process the counters of all monsters */
+       process_monsters_counters();
 
-       /*** Process Objects ***/
 
-       /* Process objects */
-       for (i = 1; i < o_max; i++)
+       /* Date changes */
+       if (!hour && !min)
        {
-               /* Access object */
-               o_ptr = &o_list[i];
-
-               /* Skip dead objects */
-               if (!o_ptr->k_idx) continue;
-
-               /* Recharge rods on the ground.  No messages. */
-               if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
+               if (min != prev_min)
                {
-                       /* Charge it */
-                       o_ptr->timeout -= o_ptr->number;
-
-                       /* Boundary control. */
-                       if (o_ptr->timeout < 0) o_ptr->timeout = 0;
+                       do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
+                       determine_today_mon(FALSE);
                }
        }
 
-
-       /*** Involuntary Movement ***/
-
-       /* Delayed Word-of-Recall */
-       if (p_ptr->word_recall)
+       /*
+        * Nightmare mode activates the TY_CURSE at midnight
+        *
+        * Require exact minute -- Don't activate multiple times in a minute
+        */
+       if (ironman_nightmare && (min != prev_min))
        {
-               /*
-                * HACK: Autosave BEFORE resetting the recall counter (rr9)
-                * The player is yanked up/down as soon as
-                * he loads the autosaved game.
-                */
-               if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
-                       do_cmd_save_game(TRUE);
-
-               /* Count down towards recall */
-               p_ptr->word_recall--;
-
-               p_ptr->redraw |= (PR_STATUS);
-
-               /* Activate the recall */
-               if (!p_ptr->word_recall)
+               /* Every 15 minutes after 11:00 pm */
+               if ((hour == 23) && !(min % 15))
                {
-                       /* Disturbing! */
+                       /* Disturbing */
                        disturb(0, 0);
 
-                       /* Determine the level */
-                       if (dun_level || p_ptr->inside_quest)
+                       switch (min / 15)
                        {
+                       case 0:
 #ifdef JP
-msg_print("¾å¤Ë°ú¤ÃÄ¥¤ê¤¢¤²¤é¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª");
+                               msg_print("±ó¤¯¤ÇÉÔµ¤Ì£¤Ê¾â¤Î²»¤¬ÌĤä¿¡£");
 #else
-                               msg_print("You feel yourself yanked upwards!");
+                               msg_print("You hear a distant bell toll ominously.");
 #endif
+                               break;
 
-                               p_ptr->recall_dungeon = dungeon_type;
-                               if (record_stair)
-                                       do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
+                       case 1:
+#ifdef JP
+                               msg_print("±ó¤¯¤Ç¾â¤¬Æó²óÌĤä¿¡£");
+#else
+                               msg_print("A distant bell sounds twice.");
+#endif
+                               break;
 
-                               dun_level = 0;
-                               dungeon_type = 0;
+                       case 2:
+#ifdef JP
+                               msg_print("±ó¤¯¤Ç¾â¤¬»°²óÌĤä¿¡£");
+#else
+                               msg_print("A distant bell sounds three times.");
+#endif
+                               break;
 
-                               leave_quest_check();
+                       case 3:
+#ifdef JP
+                               msg_print("±ó¤¯¤Ç¾â¤¬»Í²óÌĤä¿¡£");
+#else
+                               msg_print("A distant bell tolls four times.");
+#endif
+                               break;
+                       }
+               }
 
-                               p_ptr->inside_quest = 0;
+               /* TY_CURSE activates at mignight! */
+               if (!hour && !min)
+               {
+                       int count = 0;
 
-                               p_ptr->leaving = TRUE;
-                       }
-                       else
-                       {
+                       disturb(1, 0);
 #ifdef JP
-msg_print("²¼¤Ë°ú¤­¤º¤ê¹ß¤í¤µ¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª");
+                       msg_print("±ó¤¯¤Ç¾â¤¬²¿²ó¤âÌĤꡢ»à¤ó¤À¤è¤¦¤ÊÀŤ±¤µ¤ÎÃæ¤Ø¾Ã¤¨¤Æ¤¤¤Ã¤¿¡£");
 #else
-                               msg_print("You feel yourself yanked downwards!");
+                       msg_print("A distant bell tolls many times, fading into an deathly silence.");
 #endif
 
-                               dungeon_type = p_ptr->recall_dungeon;
+                       activate_ty_curse(FALSE, &count);
+               }
+       }
 
-                               if (record_stair)
-                                       do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
 
-                               /* New depth */
-                               dun_level = max_dlv[dungeon_type];
-                               if (dun_level < 1) dun_level = 1;
+       /*** Check the Food, and Regenerate ***/
 
-                               /* Nightmare mode makes recall more dangerous */
-                               if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
-                               {
-                                       if (dun_level < 50)
-                                       {
-                                               dun_level *= 2;
-                                       }
-                                       else if (dun_level < 99)
-                                       {
-                                               dun_level = (dun_level + 99) / 2;
-                                       }
-                                       else if (dun_level > 100)
-                                       {
-                                               dun_level = d_info[dungeon_type].maxdepth - 1;
-                                       }
-                               }
+       if (!p_ptr->inside_battle)
+       {
+               /* Digest quickly when gorged */
+               if (p_ptr->food >= PY_FOOD_MAX)
+               {
+                       /* Digest a lot of food */
+                       (void)set_food(p_ptr->food - 100);
+               }
 
-                               if (p_ptr->wild_mode)
-                               {
-                                       p_ptr->wilderness_y = py;
-                                       p_ptr->wilderness_x = px;
-                               }
-                               else
-                               {
-                                       /* Save player position */
-                                       p_ptr->oldpx = px;
-                                       p_ptr->oldpy = py;
-                               }
-                               p_ptr->wild_mode = FALSE;
+               /* Digest normally -- Every 50 game turns */
+               else if (!(turn % (TURNS_PER_TICK*5)))
+               {
+                       /* Basic digestion rate based on speed */
+                       int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
 
-                               /*
-                                * Clear all saved floors
-                                * and create a first saved floor
-                                */
-                               prepare_change_floor_mode(CFM_FIRST_FLOOR);
+                       /* Regeneration takes more food */
+                       if (p_ptr->regenerate)
+                               digestion += 20;
+                       if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
+                               digestion += 20;
+                       if (p_ptr->cursed & TRC_FAST_DIGEST)
+                               digestion += 30;
 
-                               /* Leaving */
-                               p_ptr->leaving = TRUE;
+                       /* Slow digestion takes less food */
+                       if (p_ptr->slow_digest)
+                               digestion -= 5;
 
-                               if (dungeon_type == DUNGEON_ANGBAND)
-                               {
-                                       for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
-                                       {
-                                               if ((quest[i].type == QUEST_TYPE_RANDOM) &&
-                                                   (quest[i].status == QUEST_STATUS_TAKEN) &&
-                                                   (quest[i].level < dun_level))
-                                               {
-                                                       quest[i].status = QUEST_STATUS_FAILED;
-                                                       quest[i].complev = (byte)p_ptr->lev;
-                                                       r_info[quest[i].r_idx].flags1 &= ~(RF1_QUESTOR);
-                                               }
-                                       }
-                               }
-                       }
+                       /* Minimal digestion */
+                       if (digestion < 1) digestion = 1;
+                       /* Maximal digestion */
+                       if (digestion > 100) digestion = 100;
 
-                       /* Sound */
-                       sound(SOUND_TPLEVEL);
+                       /* Digest some food */
+                       (void)set_food(p_ptr->food - digestion);
                }
-       }
-
-
-       /* Delayed Alter reality */
-       if (p_ptr->alter_reality)
-       {
-               if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
-                       do_cmd_save_game(TRUE);
-
-               /* Count down towards alter */
-               p_ptr->alter_reality--;
 
-               p_ptr->redraw |= (PR_STATUS);
 
-               /* Activate the alter reality */
-               if (!p_ptr->alter_reality)
+               /* Getting Faint */
+               if ((p_ptr->food < PY_FOOD_FAINT))
                {
-                       /* Disturbing! */
-                       disturb(0, 0);
-
-                       /* Determine the level */
-                       if (!quest_number(dun_level) && dun_level)
+                       /* Faint occasionally */
+                       if (!p_ptr->paralyzed && (randint0(100) < 10))
                        {
+                               /* Message */
 #ifdef JP
-                               msg_print("À¤³¦¤¬ÊѤï¤Ã¤¿¡ª");
+                               msg_print("¤¢¤Þ¤ê¤Ë¤â¶õÊ¢¤Çµ¤À䤷¤Æ¤·¤Þ¤Ã¤¿¡£");
 #else
-                               msg_print("The world changes!");
+                               msg_print("You faint from the lack of food.");
 #endif
 
-                               /* Leaving */
-                               p_ptr->leaving = TRUE;
+                               disturb(1, 0);
+
+                               /* Hack -- faint (bypass free action) */
+                               (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
                        }
-                       else
+
+                       /* Starve to death (slowly) */
+                       if (p_ptr->food < PY_FOOD_STARVE)
                        {
+                               /* Calculate damage */
+                               int dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
+
+                               /* Take damage */
 #ifdef JP
-                               msg_print("À¤³¦¤¬¾¯¤·¤Î´ÖÊѲ½¤·¤¿¤è¤¦¤À¡£");
+                               if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, "¶õÊ¢", -1);
 #else
-                               msg_print("The world seems to change for a moment!");
+                               if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, "starvation", -1);
 #endif
                        }
-
-                       /* Sound */
-                       sound(SOUND_TPLEVEL);
                }
        }
+
+
+
+       /* Process timed damage and regeneration */
+       process_world_aux_hp_and_sp();
+
+       /* Process timeout */
+       process_world_aux_timeout();
+
+       /* Process light */
+       process_world_aux_light();
+
+       /* Process mutation effects */
+       process_world_aux_mutation();
+
+       /* Process curse effects */
+       process_world_aux_curse();
+
+       /* Process recharging */
+       process_world_aux_recharge();
+
+       /* Feel the inventory */
+       sense_inventory1();
+       sense_inventory2();
+
+       /* Involuntary Movement */
+       process_world_aux_movement();
 }
 
 
index f2c74f2..fbac4bd 100644 (file)
@@ -129,8 +129,8 @@ bool is_daytime(void)
  */
 void extract_day_hour_min(int *day, int *hour, int *min)
 {
-       s32b len = TURNS_PER_TICK * TOWN_DAWN;
-       s32b tick = turn % len + len / 4;
+       const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
+       s32b turn_in_today = (turn + A_DAY / 4) % A_DAY;
 
        switch (p_ptr->start_race)
        {
@@ -138,14 +138,14 @@ void extract_day_hour_min(int *day, int *hour, int *min)
        case RACE_SKELETON:
        case RACE_ZOMBIE:
        case RACE_SPECTRE:
-               *day = (turn - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4)) / len + 1;
+               *day = (turn - A_DAY * 3 / 4) / A_DAY + 1;
                break;
        default:
-               *day = (turn + (TURNS_PER_TICK * TOWN_DAWN / 4)) / len + 1;
+               *day = (turn + A_DAY / 4) / A_DAY + 1;
                break;
        }
-       *hour = (24 * tick / len) % 24;
-       *min = (1440 * tick / len) % 60;
+       *hour = (24 * turn_in_today / A_DAY) % 24;
+       *min = (1440 * turn_in_today / A_DAY) % 60;
 }
 
 /*
index 137998f..89ec30f 100644 (file)
 /* Allow hordes of 'similar' monsters */
 # define MONSTER_HORDES
 
-/* Wizard mode testing options: */
-
-/* Testing upkeep */
-/* # define TRACK_FRIENDS */
-
 /*
  * OPTION: Repeat last command -- TNB
  */