4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spell code (part 3) */
15 /* Maximum number of tries for teleporting */
18 /* 1/x chance of reducing stats (for elemental attacks) */
19 #define HURT_CHANCE 16
22 static bool cave_monster_teleportable_bold(int m_idx, int y, int x, bool passive)
24 monster_type *m_ptr = &m_list[m_idx];
25 cave_type *c_ptr = &cave[y][x];
26 feature_type *f_ptr = &f_info[c_ptr->feat];
28 /* Require "teleportable" space */
29 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
31 if (c_ptr->m_idx && (c_ptr->m_idx != m_idx)) return FALSE;
32 if (player_bold(y, x)) return FALSE;
34 /* Hack -- no teleport onto glyph of warding */
35 if (is_glyph_grid(c_ptr)) return FALSE;
36 if (is_explosive_rune_grid(c_ptr)) return FALSE;
40 if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
48 * Teleport a monster, normally up to "dis" grids away.
50 * Attempt to move the monster at least "dis/2" grids away.
52 * But allow variation to prevent infinite loops.
54 bool teleport_away(int m_idx, int dis, bool dec_valour, bool passive)
56 int oy, ox, d, i, min;
62 monster_type *m_ptr = &m_list[m_idx];
65 if (!m_ptr->r_idx) return (FALSE);
67 /* Save the old location */
71 /* Minimum distance */
75 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
76 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
78 chg_virtue(V_VALOUR, -1);
86 /* Verify max distance */
87 if (dis > 200) dis = 200;
89 /* Try several locations */
90 for (i = 0; i < 500; i++)
92 /* Pick a (possibly illegal) location */
95 ny = rand_spread(oy, dis);
96 nx = rand_spread(ox, dis);
97 d = distance(oy, ox, ny, nx);
98 if ((d >= min) && (d <= dis)) break;
101 /* Ignore illegal locations */
102 if (!in_bounds(ny, nx)) continue;
104 if (!cave_monster_teleportable_bold(m_idx, ny, nx, passive)) continue;
106 /* No teleporting into vaults and such */
107 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
108 if (cave[ny][nx].info & CAVE_ICKY) continue;
110 /* This grid looks good */
117 /* Increase the maximum distance */
120 /* Decrease the minimum distance */
123 /* Stop after MAX_TRIES tries */
124 if (tries > MAX_TRIES) return (FALSE);
128 sound(SOUND_TPOTHER);
130 /* Update the old location */
131 cave[oy][ox].m_idx = 0;
133 /* Update the new location */
134 cave[ny][nx].m_idx = m_idx;
136 /* Move the monster */
140 /* Forget the counter target */
143 /* Update the monster (new location) */
144 update_mon(m_idx, TRUE);
146 /* Redraw the old grid */
149 /* Redraw the new grid */
152 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
153 p_ptr->update |= (PU_MON_LITE);
161 * Teleport monster next to a grid near the given location
163 void teleport_monster_to(int m_idx, int ty, int tx, int power, bool passive)
165 int ny, nx, oy, ox, d, i, min;
169 monster_type *m_ptr = &m_list[m_idx];
172 if (!m_ptr->r_idx) return;
175 if (randint1(100) > power) return;
181 /* Save the old location */
185 /* Minimum distance */
188 /* Look until done */
189 while (look && --attempts)
191 /* Verify max distance */
192 if (dis > 200) dis = 200;
194 /* Try several locations */
195 for (i = 0; i < 500; i++)
197 /* Pick a (possibly illegal) location */
200 ny = rand_spread(ty, dis);
201 nx = rand_spread(tx, dis);
202 d = distance(ty, tx, ny, nx);
203 if ((d >= min) && (d <= dis)) break;
206 /* Ignore illegal locations */
207 if (!in_bounds(ny, nx)) continue;
209 if (!cave_monster_teleportable_bold(m_idx, ny, nx, passive)) continue;
211 /* No teleporting into vaults and such */
212 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
214 /* This grid looks good */
221 /* Increase the maximum distance */
224 /* Decrease the minimum distance */
228 if (attempts < 1) return;
231 sound(SOUND_TPOTHER);
233 /* Update the old location */
234 cave[oy][ox].m_idx = 0;
236 /* Update the new location */
237 cave[ny][nx].m_idx = m_idx;
239 /* Move the monster */
243 /* Update the monster (new location) */
244 update_mon(m_idx, TRUE);
246 /* Redraw the old grid */
249 /* Redraw the new grid */
252 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
253 p_ptr->update |= (PU_MON_LITE);
257 bool cave_player_teleportable_bold(int y, int x, bool passive, bool nonmagical)
259 cave_type *c_ptr = &cave[y][x];
260 feature_type *f_ptr = &f_info[c_ptr->feat];
262 /* Require "teleportable" space */
263 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
265 /* No magical teleporting into vaults and such */
266 if (!nonmagical && (c_ptr->info & CAVE_ICKY)) return FALSE;
268 if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
272 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
274 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
276 if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
279 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
281 /* Always forbid deep lava */
282 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
284 /* Forbid shallow lava when the player don't have levitation */
285 if (!p_ptr->levitation) return FALSE;
288 if (have_flag(f_ptr->flags, FF_HIT_TRAP))
290 if (!is_known_trap(c_ptr) || !trap_can_be_ignored(c_ptr->feat)) return FALSE;
299 * Teleport the player to a location up to "dis" grids away.
301 * If no such spaces are readily available, the distance may increase.
302 * Try very hard to move the player at least a quarter that distance.
304 * There was a nasty tendency for a long time; which was causing the
305 * player to "bounce" between two or three different spots because
306 * these are the only spots that are "far enough" way to satisfy the
309 * But this tendency is now removed; in the new algorithm, a list of
310 * candidates is selected first, which includes at least 50% of all
311 * floor grids within the distance, and any single grid in this list
312 * of candidates has equal possibility to be choosen as a destination.
315 #define MAX_TELEPORT_DISTANCE 200
317 void teleport_player(int dis, bool passive)
319 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
320 int total_candidates, cur_candidates;
321 int y = 0, x = 0, min, pick, i;
324 int left = MAX(1, px - dis);
325 int right = MIN(cur_wid - 2, px + dis);
326 int top = MAX(1, py - dis);
327 int bottom = MIN(cur_hgt - 2, py + dis);
329 /* Initialize counters */
330 total_candidates = 0;
331 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
332 candidates_at[i] = 0;
334 /* Limit the distance */
335 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
337 /* Search valid locations */
338 for (y = top; y <= bottom; y++)
340 for (x = left; x <= right; x++)
344 /* Skip illegal locations */
345 if (!cave_player_teleportable_bold(y, x, passive, FALSE)) continue;
347 /* Calculate distance */
348 d = distance(py, px, y, x);
350 /* Skip too far locations */
351 if (d > dis) continue;
353 /* Count the total number of candidates */
356 /* Count the number of candidates in this circumference */
361 /* No valid location! */
362 if (0 == total_candidates) return;
364 /* Fix the minimum distance */
365 for (cur_candidates = 0, min = dis; min >= 0; min--)
367 cur_candidates += candidates_at[min];
369 /* 50% of all candidates will have an equal chance to be choosen. */
370 if (cur_candidates >= total_candidates / 2) break;
373 /* Pick up a single location randomly */
374 pick = randint1(cur_candidates);
376 /* Search again the choosen location */
377 for (y = top; y <= bottom; y++)
379 for (x = left; x <= right; x++)
383 /* Skip illegal locations */
384 if (!cave_player_teleportable_bold(y, x, passive, FALSE)) continue;
386 /* Calculate distance */
387 d = distance(py, px, y, x);
389 /* Skip too far locations */
390 if (d > dis) continue;
392 /* Skip too close locations */
393 if (d < min) continue;
395 /* This grid was picked up? */
405 sound(SOUND_TELEPORT);
408 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
409 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
412 /* Save the old location */
416 /* Move the player */
417 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
419 /* Monsters with teleport ability may follow the player */
420 for (xx = -1; xx < 2; xx++)
422 for (yy = -1; yy < 2; yy++)
424 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
426 /* A monster except your mount may follow */
427 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
429 monster_type *m_ptr = &m_list[tmp_m_idx];
430 monster_race *r_ptr = &r_info[m_ptr->r_idx];
433 * The latter limitation is to avoid
434 * totally unkillable suckers...
436 if ((r_ptr->flags6 & RF6_TPORT) &&
437 !(r_ptr->flagsr & RFR_RES_TELE))
439 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level, FALSE);
448 * Teleport player to a grid near the given location
450 * This function is slightly obsessive about correctness.
451 * This function allows teleporting into vaults (!)
453 void teleport_player_to(int ny, int nx, bool no_tele, bool passive)
455 int y, x, dis = 0, ctr = 0;
457 if (p_ptr->anti_tele && no_tele)
460 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
462 msg_print("A mysterious force prevents you from teleporting!");
468 /* Find a usable location */
471 /* Pick a nearby legal location */
474 y = rand_spread(ny, dis);
475 x = rand_spread(nx, dis);
476 if (in_bounds(y, x)) break;
479 /* Accept any grid when wizard mode */
480 if (p_ptr->wizard && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
482 /* Accept teleportable floor grids */
483 if (cave_player_teleportable_bold(y, x, passive, !no_tele)) break;
485 /* Occasionally advance the distance */
486 if (++ctr > (4 * dis * dis + 4 * dis + 1))
494 sound(SOUND_TELEPORT);
496 /* Move the player */
497 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
501 void teleport_away_followable(int m_idx)
503 monster_type *m_ptr = &m_list[m_idx];
504 int oldfy = m_ptr->fy;
505 int oldfx = m_ptr->fx;
506 bool old_ml = m_ptr->ml;
507 int old_cdis = m_ptr->cdis;
509 teleport_away(m_idx, MAX_SIGHT * 2 + 5, FALSE, FALSE);
511 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && los(py, px, oldfy, oldfx))
515 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
518 u32b flgs[TR_FLAG_SIZE];
522 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
524 o_ptr = &inventory[i];
525 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
527 object_flags(o_ptr, flgs);
528 if (have_flag(flgs, TR_TELEPORT))
540 if (get_check_strict("¤Ä¤¤¤Æ¤¤¤¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
542 if (get_check_strict("Do you follow it? ", CHECK_OKAY_CANCEL))
547 teleport_player(200, TRUE);
551 msg_print("Failed!");
554 else teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, FALSE);
555 p_ptr->energy_need += ENERGY_NEED();
563 * Teleport the player one level up or down (random when legal)
564 * Note: If m_idx <= 0, target is player.
566 void teleport_level(int m_idx)
572 if (m_idx <= 0) /* To player */
575 strcpy(m_name, "¤¢¤Ê¤¿");
577 strcpy(m_name, "you");
580 else /* To monster */
582 monster_type *m_ptr = &m_list[m_idx];
584 /* Get the monster name (or "it") */
585 monster_desc(m_name, m_ptr, 0);
587 see_m = is_seen(m_ptr);
590 /* No effect in some case */
591 if (TELE_LEVEL_IS_INEFF(m_idx))
594 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
596 if (see_m) msg_print("There is no effect.");
602 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
605 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
607 msg_print("A mysterious force prevents you from teleporting!");
612 /* Choose up or down */
613 if (randint0(100) < 50) go_up = TRUE;
616 if ((m_idx <= 0) && p_ptr->wizard)
618 if (get_check("Force to go up? ")) go_up = TRUE;
619 else if (get_check("Force to go down? ")) go_up = FALSE;
623 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
626 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
628 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
630 if (m_idx <= 0) /* To player */
634 dungeon_type = p_ptr->recall_dungeon;
639 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
641 if (autosave_l) do_cmd_save_game(TRUE);
645 dun_level = d_info[dungeon_type].mindepth;
646 prepare_change_floor_mode(CFM_RAND_PLACE);
650 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
654 p_ptr->leaving = TRUE;
659 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
662 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
664 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
668 if (m_idx <= 0) /* To player */
670 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
672 if (autosave_l) do_cmd_save_game(TRUE);
674 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
679 p_ptr->inside_quest = 0;
680 p_ptr->leaving = TRUE;
686 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
688 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
692 if (m_idx <= 0) /* To player */
694 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
696 if (autosave_l) do_cmd_save_game(TRUE);
698 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
701 p_ptr->leaving = TRUE;
707 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
709 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
712 if (m_idx <= 0) /* To player */
714 /* Never reach this code on the surface */
715 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
717 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
719 if (autosave_l) do_cmd_save_game(TRUE);
721 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
724 p_ptr->leaving = TRUE;
728 /* Monster level teleportation is simple deleting now */
731 monster_type *m_ptr = &m_list[m_idx];
733 /* Check for quest completion */
734 check_quest_completion(m_ptr);
736 delete_monster_idx(m_idx);
740 sound(SOUND_TPLEVEL);
745 int choose_dungeon(cptr note, int y, int x)
751 /* Hack -- No need to choose dungeon in some case */
752 if (lite_town || vanilla_town || ironman_downward)
754 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
758 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
760 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
767 /* Allocate the "dun" array */
768 C_MAKE(dun, max_d_idx, s16b);
771 for(i = 1; i < max_d_idx; i++)
776 if (!d_info[i].maxdepth) continue;
777 if (!max_dlv[i]) continue;
778 if (d_info[i].final_guardian)
780 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
782 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
785 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
787 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
789 prt(buf, y + num, x);
796 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
798 prt(" No dungeon is available.", y, x);
803 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
805 prt(format("Which dungeon do you %s?: ", note), 0, 0);
810 if ((i == ESCAPE) || !num)
812 /* Free the "dun" array */
813 C_KILL(dun, max_d_idx, s16b);
818 if (i >= 'a' && i <('a'+num))
820 select_dungeon = dun[i-'a'];
827 /* Free the "dun" array */
828 C_KILL(dun, max_d_idx, s16b);
830 return select_dungeon;
835 * Recall the player to town or dungeon
837 bool recall_player(int turns)
840 * TODO: Recall the player to the last
841 * visited town when in the wilderness
845 if (p_ptr->inside_arena || ironman_downward)
848 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
850 msg_print("Nothing happens.");
856 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
859 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
861 if (get_check("Reset recall depth? "))
864 max_dlv[dungeon_type] = dun_level;
867 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
869 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
874 if (!p_ptr->word_recall)
880 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
882 select_dungeon = choose_dungeon("recall", 2, 14);
884 if (!select_dungeon) return FALSE;
885 p_ptr->recall_dungeon = select_dungeon;
887 p_ptr->word_recall = turns;
889 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
891 msg_print("The air about you becomes charged...");
894 p_ptr->redraw |= (PR_STATUS);
898 p_ptr->word_recall = 0;
900 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
902 msg_print("A tension leaves the air around you...");
905 p_ptr->redraw |= (PR_STATUS);
911 bool word_of_recall(void)
913 return(recall_player(randint0(21) + 15));
917 bool reset_recall(void)
919 int select_dungeon, dummy = 0;
924 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
926 select_dungeon = choose_dungeon("reset", 2, 14);
930 if (ironman_downward)
933 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
935 msg_print("Nothing happens.");
941 if (!select_dungeon) return FALSE;
944 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
946 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
951 sprintf(tmp_val, "%d", MAX(dun_level, 1));
953 /* Ask for a level */
954 if (get_string(ppp, tmp_val, 10))
956 /* Extract request */
957 dummy = atoi(tmp_val);
960 if (dummy < 1) dummy = 1;
963 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
964 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
966 max_dlv[select_dungeon] = dummy;
970 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
972 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
976 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
978 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
991 * Apply disenchantment to the player's stuff
993 * XXX XXX XXX This function is also called from the "melee" code
995 * Return "TRUE" if the player notices anything
997 bool apply_disenchant(int mode)
1001 char o_name[MAX_NLEN];
1002 int to_h, to_d, to_a, pval;
1004 /* Pick a random slot */
1005 switch (randint1(8))
1007 case 1: t = INVEN_RARM; break;
1008 case 2: t = INVEN_LARM; break;
1009 case 3: t = INVEN_BOW; break;
1010 case 4: t = INVEN_BODY; break;
1011 case 5: t = INVEN_OUTER; break;
1012 case 6: t = INVEN_HEAD; break;
1013 case 7: t = INVEN_HANDS; break;
1014 case 8: t = INVEN_FEET; break;
1018 o_ptr = &inventory[t];
1020 /* No item, nothing happens */
1021 if (!o_ptr->k_idx) return (FALSE);
1023 /* Disenchant equipments only -- No disenchant on monster ball */
1024 if (!object_is_weapon_armour_ammo(o_ptr))
1027 /* Nothing to disenchant */
1028 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1030 /* Nothing to notice */
1035 /* Describe the object */
1036 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1039 /* Artifacts have 71% chance to resist */
1040 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1044 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
1046 msg_format("Your %s (%c) resist%s disenchantment!",
1047 o_name, index_to_label(t),
1048 ((o_ptr->number != 1) ? "" : "s"));
1057 /* Memorize old value */
1063 /* Disenchant tohit */
1064 if (o_ptr->to_h > 0) o_ptr->to_h--;
1065 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1067 /* Disenchant todam */
1068 if (o_ptr->to_d > 0) o_ptr->to_d--;
1069 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1071 /* Disenchant toac */
1072 if (o_ptr->to_a > 0) o_ptr->to_a--;
1073 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1075 /* Disenchant pval (occasionally) */
1076 /* Unless called from wild_magic() */
1077 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1079 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1080 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1084 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1085 o_name, index_to_label(t) );
1087 msg_format("Your %s (%c) %s disenchanted!",
1088 o_name, index_to_label(t),
1089 ((o_ptr->number != 1) ? "were" : "was"));
1092 chg_virtue(V_HARMONY, 1);
1093 chg_virtue(V_ENCHANT, -2);
1095 /* Recalculate bonuses */
1096 p_ptr->update |= (PU_BONUS);
1099 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1109 void mutate_player(void)
1111 int max1, cur1, max2, cur2, ii, jj, i;
1113 /* Pick a pair of stats */
1115 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1117 max1 = p_ptr->stat_max[ii];
1118 cur1 = p_ptr->stat_cur[ii];
1119 max2 = p_ptr->stat_max[jj];
1120 cur2 = p_ptr->stat_cur[jj];
1122 p_ptr->stat_max[ii] = max2;
1123 p_ptr->stat_cur[ii] = cur2;
1124 p_ptr->stat_max[jj] = max1;
1125 p_ptr->stat_cur[jj] = cur1;
1129 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1130 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1133 p_ptr->update |= (PU_BONUS);
1140 void apply_nexus(monster_type *m_ptr)
1142 switch (randint1(7))
1144 case 1: case 2: case 3:
1146 teleport_player(200, TRUE);
1152 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, TRUE);
1158 if (randint0(100) < p_ptr->skill_sav)
1161 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1163 msg_print("You resist the effects!");
1169 /* Teleport Level */
1176 if (randint0(100) < p_ptr->skill_sav)
1179 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1181 msg_print("You resist the effects!");
1188 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1190 msg_print("Your body starts to scramble...");
1201 * Charge a lite (torch or latern)
1203 void phlogiston(void)
1206 object_type * o_ptr = &inventory[INVEN_LITE];
1209 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1211 max_flog = FUEL_LAMP;
1215 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1217 max_flog = FUEL_TORCH;
1220 /* No torch to refill */
1224 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1226 msg_print("You are not wielding anything which uses phlogiston.");
1232 if (o_ptr->xtra4 >= max_flog)
1235 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1237 msg_print("No more phlogiston can be put in this item.");
1244 o_ptr->xtra4 += (max_flog / 2);
1248 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1250 msg_print("You add phlogiston to your light item.");
1255 if (o_ptr->xtra4 >= max_flog)
1257 o_ptr->xtra4 = max_flog;
1259 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1261 msg_print("Your light item is full.");
1266 /* Recalculate torch */
1267 p_ptr->update |= (PU_TORCH);
1272 * Brand the current weapon
1274 void brand_weapon(int brand_type)
1281 /* Assume enchant weapon */
1282 item_tester_hook = object_allow_enchant_melee_weapon;
1283 item_tester_no_ryoute = TRUE;
1287 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1288 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1290 q = "Enchant which weapon? ";
1291 s = "You have nothing to enchant.";
1294 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1296 /* Get the item (in the pack) */
1299 o_ptr = &inventory[item];
1302 /* Get the item (on the floor) */
1305 o_ptr = &o_list[0 - item];
1309 /* you can never modify artifacts / ego-items */
1310 /* you can never modify cursed items */
1311 /* TY: You _can_ modify broken items (if you're silly enough) */
1312 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1313 !object_is_cursed(o_ptr) &&
1314 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1315 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1316 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1320 /* Let's get the name before it is changed... */
1321 char o_name[MAX_NLEN];
1322 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1327 if (o_ptr->tval == TV_SWORD)
1330 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1332 act = "becomes very sharp!";
1335 o_ptr->name2 = EGO_SHARPNESS;
1336 o_ptr->pval = m_bonus(5, dun_level) + 1;
1341 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1343 act = "seems very powerful.";
1346 o_ptr->name2 = EGO_EARTHQUAKES;
1347 o_ptr->pval = m_bonus(3, dun_level);
1352 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1354 act = "seems to be looking for humans!";
1357 o_ptr->name2 = EGO_SLAY_HUMAN;
1361 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1363 act = "covered with lightning!";
1366 o_ptr->name2 = EGO_BRAND_ELEC;
1370 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1372 act = "coated with acid!";
1375 o_ptr->name2 = EGO_BRAND_ACID;
1379 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1381 act = "seems to be looking for evil monsters!";
1384 o_ptr->name2 = EGO_SLAY_EVIL;
1388 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1390 act = "seems to be looking for demons!";
1393 o_ptr->name2 = EGO_SLAY_DEMON;
1397 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1399 act = "seems to be looking for undead!";
1402 o_ptr->name2 = EGO_SLAY_UNDEAD;
1406 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1408 act = "seems to be looking for animals!";
1411 o_ptr->name2 = EGO_SLAY_ANIMAL;
1415 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1417 act = "seems to be looking for dragons!";
1420 o_ptr->name2 = EGO_SLAY_DRAGON;
1424 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1426 act = "seems to be looking for troll!s";
1429 o_ptr->name2 = EGO_SLAY_TROLL;
1433 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1435 act = "seems to be looking for orcs!";
1438 o_ptr->name2 = EGO_SLAY_ORC;
1442 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1444 act = "seems to be looking for giants!";
1447 o_ptr->name2 = EGO_SLAY_GIANT;
1451 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1453 act = "seems very unstable now.";
1456 o_ptr->name2 = EGO_TRUMP;
1457 o_ptr->pval = randint1(2);
1461 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1463 act = "thirsts for blood!";
1466 o_ptr->name2 = EGO_VAMPIRIC;
1470 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1472 act = "is coated with poison.";
1475 o_ptr->name2 = EGO_BRAND_POIS;
1479 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1481 act = "is engulfed in raw Logrus!";
1484 o_ptr->name2 = EGO_CHAOTIC;
1488 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1490 act = "is covered in a fiery shield!";
1493 o_ptr->name2 = EGO_BRAND_FIRE;
1497 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1499 act = "glows deep, icy blue!";
1502 o_ptr->name2 = EGO_BRAND_COLD;
1507 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1509 msg_format("Your %s %s", o_name, act);
1513 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1515 o_ptr->discount = 99;
1516 chg_virtue(V_ENCHANT, 2);
1520 if (flush_failure) flush();
1523 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1525 msg_print("The Branding failed.");
1528 chg_virtue(V_ENCHANT, -2);
1535 * Vanish all walls in this floor
1537 static bool vanish_dungeon(void)
1541 feature_type *f_ptr;
1542 monster_type *m_ptr;
1545 /* Prevent vasishing of quest levels and town */
1546 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1551 /* Scan all normal grids */
1552 for (y = 1; y < cur_hgt - 1; y++)
1554 for (x = 1; x < cur_wid - 1; x++)
1556 c_ptr = &cave[y][x];
1558 /* Seeing true feature code (ignore mimic) */
1559 f_ptr = &f_info[c_ptr->feat];
1561 /* Lose room and vault */
1562 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1564 m_ptr = &m_list[c_ptr->m_idx];
1567 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1569 /* Reset sleep counter */
1570 (void)set_monster_csleep(c_ptr->m_idx, 0);
1572 /* Notice the "waking up" */
1575 /* Acquire the monster name */
1576 monster_desc(m_name, m_ptr, 0);
1578 /* Dump a message */
1580 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1582 msg_format("%^s wakes up.", m_name);
1587 /* Process all walls, doors and patterns */
1588 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1592 /* Special boundary walls -- Top and bottom */
1593 for (x = 0; x < cur_wid; x++)
1595 c_ptr = &cave[0][x];
1596 f_ptr = &f_info[c_ptr->mimic];
1598 /* Lose room and vault */
1599 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1601 /* Set boundary mimic if needed */
1602 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1604 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1606 /* Check for change to boring grid */
1607 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1610 c_ptr = &cave[cur_hgt - 1][x];
1611 f_ptr = &f_info[c_ptr->mimic];
1613 /* Lose room and vault */
1614 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1616 /* Set boundary mimic if needed */
1617 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1619 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1621 /* Check for change to boring grid */
1622 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1626 /* Special boundary walls -- Left and right */
1627 for (y = 1; y < (cur_hgt - 1); y++)
1629 c_ptr = &cave[y][0];
1630 f_ptr = &f_info[c_ptr->mimic];
1632 /* Lose room and vault */
1633 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1635 /* Set boundary mimic if needed */
1636 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1638 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1640 /* Check for change to boring grid */
1641 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1644 c_ptr = &cave[y][cur_wid - 1];
1645 f_ptr = &f_info[c_ptr->mimic];
1647 /* Lose room and vault */
1648 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1650 /* Set boundary mimic if needed */
1651 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1653 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1655 /* Check for change to boring grid */
1656 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1660 /* Mega-Hack -- Forget the view and lite */
1661 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1664 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1666 /* Update the monsters */
1667 p_ptr->update |= (PU_MONSTERS);
1670 p_ptr->redraw |= (PR_MAP);
1673 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1679 void call_the_(void)
1683 bool do_call = TRUE;
1685 for (i = 0; i < 9; i++)
1687 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1689 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1691 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1692 !permanent_wall(&f_info[c_ptr->feat]))
1702 for (i = 1; i < 10; i++)
1704 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1707 for (i = 1; i < 10; i++)
1709 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1712 for (i = 1; i < 10; i++)
1714 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1718 /* Prevent destruction of quest levels and town */
1719 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1722 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1724 msg_print("The ground trembles.");
1731 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1732 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1733 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1735 msg_format("You %s the %s too close to a wall!",
1736 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1737 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1738 msg_print("There is a loud explosion!");
1744 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1746 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1751 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1753 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1755 msg_print("The dungeon collapses...");
1760 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1762 msg_print("The dungeon trembles.");
1767 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1769 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1776 * Fetch an item (teleport it right underneath the caster)
1778 void fetch(int dir, int wgt, bool require_los)
1783 char o_name[MAX_NLEN];
1785 /* Check to see if an object is already there */
1786 if (cave[py][px].o_idx)
1789 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1791 msg_print("You can't fetch when you're already standing on something.");
1798 if (dir == 5 && target_okay())
1803 if (distance(py, px, ty, tx) > MAX_RANGE)
1806 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1808 msg_print("You can't fetch something that far away!");
1814 c_ptr = &cave[ty][tx];
1816 /* We need an item to fetch */
1820 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1822 msg_print("There is no object at this place.");
1828 /* No fetching from vault */
1829 if (c_ptr->info & CAVE_ICKY)
1832 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1834 msg_print("The item slips from your control.");
1840 /* We need to see the item */
1843 if (!player_has_los_bold(ty, tx))
1846 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1848 msg_print("You have no direct line of sight to that location.");
1853 else if (!projectable(py, px, ty, tx))
1856 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1858 msg_print("You have no direct line of sight to that location.");
1867 /* Use a direction */
1868 ty = py; /* Where to drop the item */
1875 c_ptr = &cave[ty][tx];
1877 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1878 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1880 while (!c_ptr->o_idx);
1883 o_ptr = &o_list[c_ptr->o_idx];
1885 if (o_ptr->weight > wgt)
1887 /* Too heavy to 'fetch' */
1889 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1891 msg_print("The object is too heavy.");
1898 c_ptr->o_idx = o_ptr->next_o_idx;
1899 cave[py][px].o_idx = i; /* 'move' it */
1900 o_ptr->next_o_idx = 0;
1901 o_ptr->iy = (byte)py;
1902 o_ptr->ix = (byte)px;
1904 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1906 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1908 msg_format("%^s flies through the air to your feet.", o_name);
1913 p_ptr->redraw |= PR_MAP;
1917 void alter_reality(void)
1919 /* Ironman option */
1920 if (p_ptr->inside_arena || ironman_downward)
1923 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1925 msg_print("Nothing happens.");
1930 if (!p_ptr->alter_reality)
1932 int turns = randint0(21) + 15;
1934 p_ptr->alter_reality = turns;
1936 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1938 msg_print("The view around you begins to change...");
1941 p_ptr->redraw |= (PR_STATUS);
1945 p_ptr->alter_reality = 0;
1947 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1949 msg_print("The view around you got back...");
1952 p_ptr->redraw |= (PR_STATUS);
1959 * Leave a "glyph of warding" which prevents monster movement
1961 bool warding_glyph(void)
1964 if (!cave_clean_bold(py, px))
1967 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1969 msg_print("The object resists the spell.");
1975 /* Create a glyph */
1976 cave[py][px].info |= CAVE_OBJECT;
1977 cave[py][px].mimic = FEAT_GLYPH;
1988 bool place_mirror(void)
1991 if (!cave_clean_bold(py, px))
1994 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1996 msg_print("The object resists the spell.");
2002 /* Create a mirror */
2003 cave[py][px].info |= CAVE_OBJECT;
2004 cave[py][px].mimic = FEAT_MIRROR;
2006 /* Turn on the light */
2007 cave[py][px].info |= CAVE_GLOW;
2015 update_local_illumination(py, px);
2022 * Leave an "explosive rune" which prevents monster movement
2024 bool explosive_rune(void)
2027 if (!cave_clean_bold(py, px))
2030 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2032 msg_print("The object resists the spell.");
2038 /* Create a glyph */
2039 cave[py][px].info |= CAVE_OBJECT;
2040 cave[py][px].mimic = FEAT_MINOR_GLYPH;
2053 * Identify everything being carried.
2054 * Done by a potion of "self knowledge".
2056 void identify_pack(void)
2060 /* Simply identify and know every item */
2061 for (i = 0; i < INVEN_TOTAL; i++)
2063 object_type *o_ptr = &inventory[i];
2065 /* Skip non-objects */
2066 if (!o_ptr->k_idx) continue;
2069 identify_item(o_ptr);
2071 /* Auto-inscription */
2072 autopick_alter_item(i, FALSE);
2078 * Used by the "enchant" function (chance of failure)
2079 * (modified for Zangband, we need better stuff there...) -- TY
2081 static int enchant_table[16] =
2083 0, 10, 50, 100, 200,
2084 300, 400, 500, 650, 800,
2085 950, 987, 993, 995, 998,
2091 * Removes curses from items in inventory
2093 * Note that Items which are "Perma-Cursed" (The One Ring,
2094 * The Crown of Morgoth) can NEVER be uncursed.
2096 * Note that if "all" is FALSE, then Items which are
2097 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2098 * will not be uncursed.
2100 static int remove_curse_aux(int all)
2104 /* Attempt to uncurse items being worn */
2105 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2107 object_type *o_ptr = &inventory[i];
2109 /* Skip non-objects */
2110 if (!o_ptr->k_idx) continue;
2112 /* Uncursed already */
2113 if (!object_is_cursed(o_ptr)) continue;
2115 /* Heavily Cursed Items need a special spell */
2116 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2118 /* Perma-Cursed Items can NEVER be uncursed */
2119 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2122 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2127 o_ptr->curse_flags = 0L;
2129 /* Hack -- Assume felt */
2130 o_ptr->ident |= (IDENT_SENSE);
2133 o_ptr->feeling = FEEL_NONE;
2135 /* Recalculate the bonuses */
2136 p_ptr->update |= (PU_BONUS);
2139 p_ptr->window |= (PW_EQUIP);
2141 /* Count the uncursings */
2145 /* Return "something uncursed" */
2151 * Remove most curses
2153 bool remove_curse(void)
2155 return (remove_curse_aux(FALSE));
2161 bool remove_all_curse(void)
2163 return (remove_curse_aux(TRUE));
2168 * Turns an object into gold, gain some of its value in a shop
2177 char o_name[MAX_NLEN];
2178 char out_val[MAX_NLEN+40];
2182 /* Hack -- force destruction */
2183 if (command_arg > 0) force = TRUE;
2187 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2188 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2190 q = "Turn which item to gold? ";
2191 s = "You have nothing to turn to gold.";
2194 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2196 /* Get the item (in the pack) */
2199 o_ptr = &inventory[item];
2202 /* Get the item (on the floor) */
2205 o_ptr = &o_list[0 - item];
2209 /* See how many items */
2210 if (o_ptr->number > 1)
2212 /* Get a quantity */
2213 amt = get_quantity(NULL, o_ptr->number);
2215 /* Allow user abort */
2216 if (amt <= 0) return FALSE;
2220 /* Describe the object */
2221 old_number = o_ptr->number;
2222 o_ptr->number = amt;
2223 object_desc(o_name, o_ptr, 0);
2224 o_ptr->number = old_number;
2226 /* Verify unless quantity given */
2229 if (confirm_destroy || (object_value(o_ptr) > 0))
2231 /* Make a verification */
2233 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2235 sprintf(out_val, "Really turn %s to gold? ", o_name);
2238 if (!get_check(out_val)) return FALSE;
2242 /* Artifacts cannot be destroyed */
2243 if (!can_player_destroy_object(o_ptr))
2247 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2249 msg_format("You fail to turn %s to gold!", o_name);
2256 price = object_value_real(o_ptr);
2262 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2264 msg_format("You turn %s to fool's gold.", o_name);
2272 if (amt > 1) price *= amt;
2274 if (price > 30000) price = 30000;
2276 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2278 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2284 p_ptr->redraw |= (PR_GOLD);
2287 p_ptr->window |= (PW_PLAYER);
2291 /* Eliminate the item (from the pack) */
2294 inven_item_increase(item, -amt);
2295 inven_item_describe(item);
2296 inven_item_optimize(item);
2299 /* Eliminate the item (from the floor) */
2302 floor_item_increase(0 - item, -amt);
2303 floor_item_describe(0 - item);
2304 floor_item_optimize(0 - item);
2312 * Break the curse of an item
2314 static void break_curse(object_type *o_ptr)
2316 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2319 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2321 msg_print("The curse is broken!");
2324 o_ptr->curse_flags = 0L;
2326 o_ptr->ident |= (IDENT_SENSE);
2328 o_ptr->feeling = FEEL_NONE;
2334 * Enchants a plus onto an item. -RAK-
2336 * Revamped! Now takes item pointer, number of times to try enchanting,
2337 * and a flag of what to try enchanting. Artifacts resist enchantment
2338 * some of the time, and successful enchantment to at least +0 might
2339 * break a curse on the item. -CFT-
2341 * Note that an item can technically be enchanted all the way to +15 if
2342 * you wait a very, very, long time. Going from +9 to +10 only works
2343 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2345 * Note that this function can now be used on "piles" of items, and
2346 * the larger the pile, the lower the chance of success.
2348 bool enchant(object_type *o_ptr, int n, int eflag)
2350 int i, chance, prob;
2352 bool a = object_is_artifact(o_ptr);
2353 bool force = (eflag & ENCH_FORCE);
2356 /* Large piles resist enchantment */
2357 prob = o_ptr->number * 100;
2359 /* Missiles are easy to enchant */
2360 if ((o_ptr->tval == TV_BOLT) ||
2361 (o_ptr->tval == TV_ARROW) ||
2362 (o_ptr->tval == TV_SHOT))
2368 for (i = 0; i < n; i++)
2370 /* Hack -- Roll for pile resistance */
2371 if (!force && randint0(prob) >= 100) continue;
2373 /* Enchant to hit */
2374 if (eflag & ENCH_TOHIT)
2376 if (o_ptr->to_h < 0) chance = 0;
2377 else if (o_ptr->to_h > 15) chance = 1000;
2378 else chance = enchant_table[o_ptr->to_h];
2380 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2385 /* only when you get it above -1 -CFT */
2386 if (o_ptr->to_h >= 0)
2391 /* Enchant to damage */
2392 if (eflag & ENCH_TODAM)
2394 if (o_ptr->to_d < 0) chance = 0;
2395 else if (o_ptr->to_d > 15) chance = 1000;
2396 else chance = enchant_table[o_ptr->to_d];
2398 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2403 /* only when you get it above -1 -CFT */
2404 if (o_ptr->to_d >= 0)
2409 /* Enchant to armor class */
2410 if (eflag & ENCH_TOAC)
2412 if (o_ptr->to_a < 0) chance = 0;
2413 else if (o_ptr->to_a > 15) chance = 1000;
2414 else chance = enchant_table[o_ptr->to_a];
2416 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2421 /* only when you get it above -1 -CFT */
2422 if (o_ptr->to_a >= 0)
2429 if (!res) return (FALSE);
2431 /* Recalculate bonuses */
2432 p_ptr->update |= (PU_BONUS);
2434 /* Combine / Reorder the pack (later) */
2435 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2438 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2449 * Enchant an item (in the inventory or on the floor)
2450 * Note that "num_ac" requires armour, else weapon
2451 * Returns TRUE if attempted, FALSE if cancelled
2453 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2458 char o_name[MAX_NLEN];
2462 /* Assume enchant weapon */
2463 item_tester_hook = object_allow_enchant_weapon;
2464 item_tester_no_ryoute = TRUE;
2466 /* Enchant armor if requested */
2467 if (num_ac) item_tester_hook = object_is_armour;
2471 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2472 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2474 q = "Enchant which item? ";
2475 s = "You have nothing to enchant.";
2478 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2480 /* Get the item (in the pack) */
2483 o_ptr = &inventory[item];
2486 /* Get the item (on the floor) */
2489 o_ptr = &o_list[0 - item];
2494 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2498 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2501 msg_format("%s %s glow%s brightly!",
2502 ((item >= 0) ? "Your" : "The"), o_name,
2503 ((o_ptr->number > 1) ? "" : "s"));
2508 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2509 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2510 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2516 if (flush_failure) flush();
2520 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2522 msg_print("The enchantment failed.");
2525 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2528 chg_virtue(V_ENCHANT, 1);
2532 /* Something happened */
2538 * Check if an object is nameless weapon or armour
2540 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2542 /* Require weapon or armour */
2543 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2545 /* Require nameless object if the object is well known */
2546 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2553 bool artifact_scroll(void)
2558 char o_name[MAX_NLEN];
2562 item_tester_no_ryoute = TRUE;
2564 /* Enchant weapon/armour */
2565 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2569 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2570 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2572 q = "Enchant which item? ";
2573 s = "You have nothing to enchant.";
2576 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2578 /* Get the item (in the pack) */
2581 o_ptr = &inventory[item];
2584 /* Get the item (on the floor) */
2587 o_ptr = &o_list[0 - item];
2592 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2596 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2598 msg_format("%s %s radiate%s a blinding light!",
2599 ((item >= 0) ? "Your" : "The"), o_name,
2600 ((o_ptr->number > 1) ? "" : "s"));
2603 if (object_is_artifact(o_ptr))
2606 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2608 msg_format("The %s %s already %s!",
2609 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2610 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2616 else if (object_is_ego(o_ptr))
2619 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2621 msg_format("The %s %s already %s!",
2622 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2623 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2629 else if (o_ptr->xtra3)
2632 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2634 msg_format("The %s %s already %s!",
2635 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2636 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2642 if (o_ptr->number > 1)
2645 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2646 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2648 msg_print("Not enough enough energy to enchant more than one object!");
2649 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2654 inven_item_increase(item, 1-(o_ptr->number));
2658 floor_item_increase(0-item, 1-(o_ptr->number));
2661 okay = create_artifact(o_ptr, TRUE);
2668 if (flush_failure) flush();
2672 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2674 msg_print("The enchantment failed.");
2677 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2680 chg_virtue(V_ENCHANT, 1);
2684 /* Something happened */
2690 * Identify an object
2692 bool identify_item(object_type *o_ptr)
2694 bool old_known = FALSE;
2695 char o_name[MAX_NLEN];
2698 object_desc(o_name, o_ptr, 0);
2700 if (o_ptr->ident & IDENT_KNOWN)
2703 if (!(o_ptr->ident & (IDENT_MENTAL)))
2705 if (object_is_artifact(o_ptr) || one_in_(5))
2706 chg_virtue(V_KNOWLEDGE, 1);
2709 /* Identify it fully */
2710 object_aware(o_ptr);
2711 object_known(o_ptr);
2713 /* Recalculate bonuses */
2714 p_ptr->update |= (PU_BONUS);
2716 /* Combine / Reorder the pack (later) */
2717 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2720 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2722 strcpy(record_o_name, o_name);
2726 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2728 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2729 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2730 if(record_rand_art && !old_known && o_ptr->art_name)
2731 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2737 static bool item_tester_hook_identify(object_type *o_ptr)
2739 return (bool)!object_is_known(o_ptr);
2742 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2744 if (object_is_known(o_ptr))
2746 return object_is_weapon_armour_ammo(o_ptr);
2750 * Identify an object in the inventory (or on the floor)
2751 * This routine does *not* automatically combine objects.
2752 * Returns TRUE if something was identified, else FALSE.
2754 bool ident_spell(bool only_equip)
2758 char o_name[MAX_NLEN];
2762 item_tester_no_ryoute = TRUE;
2765 item_tester_hook = item_tester_hook_identify_weapon_armour;
2767 item_tester_hook = item_tester_hook_identify;
2769 if (!can_get_item())
2773 item_tester_hook = object_is_weapon_armour_ammo;
2777 item_tester_hook = NULL;
2783 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2784 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2786 q = "Identify which item? ";
2787 s = "You have nothing to identify.";
2790 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2792 /* Get the item (in the pack) */
2795 o_ptr = &inventory[item];
2798 /* Get the item (on the floor) */
2801 o_ptr = &o_list[0 - item];
2805 old_known = identify_item(o_ptr);
2808 object_desc(o_name, o_ptr, 0);
2811 if (item >= INVEN_RARM)
2814 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2816 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2822 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2824 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2830 msg_format("¾²¾å: %s¡£", o_name);
2832 msg_format("On the ground: %s.", o_name);
2836 /* Auto-inscription/destroy */
2837 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2839 /* Something happened */
2845 * Mundanify an object in the inventory (or on the floor)
2846 * This routine does *not* automatically combine objects.
2847 * Returns TRUE if something was mundanified, else FALSE.
2849 bool mundane_spell(bool only_equip)
2855 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2856 item_tester_no_ryoute = TRUE;
2860 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2861 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2863 q = "Use which item? ";
2864 s = "You have nothing you can use.";
2867 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2869 /* Get the item (in the pack) */
2872 o_ptr = &inventory[item];
2875 /* Get the item (on the floor) */
2878 o_ptr = &o_list[0 - item];
2883 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2885 msg_print("There is a bright flash of light!");
2888 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2889 byte ix = o_ptr->ix; /* X-position on map, or zero */
2890 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2891 byte marked = o_ptr->marked; /* Object is marked */
2892 s16b weight = o_ptr->number * o_ptr->weight;
2893 u16b inscription = o_ptr->inscription;
2896 object_prep(o_ptr, o_ptr->k_idx);
2900 o_ptr->next_o_idx = next_o_idx;
2901 o_ptr->marked = marked;
2902 o_ptr->inscription = inscription;
2903 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2907 /* Something happened */
2913 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2915 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2918 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2920 if (!item_tester_hook_identify_fully(o_ptr))
2922 return object_is_weapon_armour_ammo(o_ptr);
2926 * Fully "identify" an object in the inventory -BEN-
2927 * This routine returns TRUE if an item was identified.
2929 bool identify_fully(bool only_equip)
2933 char o_name[MAX_NLEN];
2937 item_tester_no_ryoute = TRUE;
2939 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2941 item_tester_hook = item_tester_hook_identify_fully;
2943 if (!can_get_item())
2946 item_tester_hook = object_is_weapon_armour_ammo;
2948 item_tester_hook = NULL;
2953 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2954 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2956 q = "Identify which item? ";
2957 s = "You have nothing to identify.";
2960 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2962 /* Get the item (in the pack) */
2965 o_ptr = &inventory[item];
2968 /* Get the item (on the floor) */
2971 o_ptr = &o_list[0 - item];
2975 old_known = identify_item(o_ptr);
2977 /* Mark the item as fully known */
2978 o_ptr->ident |= (IDENT_MENTAL);
2984 object_desc(o_name, o_ptr, 0);
2987 if (item >= INVEN_RARM)
2990 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2992 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3000 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3002 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3008 msg_format("¾²¾å: %s¡£", o_name);
3010 msg_format("On the ground: %s.", o_name);
3014 /* Describe it fully */
3015 (void)screen_object(o_ptr, TRUE);
3017 /* Auto-inscription/destroy */
3018 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3028 * Hook for "get_item()". Determine if something is rechargable.
3030 bool item_tester_hook_recharge(object_type *o_ptr)
3032 /* Recharge staffs */
3033 if (o_ptr->tval == TV_STAFF) return (TRUE);
3035 /* Recharge wands */
3036 if (o_ptr->tval == TV_WAND) return (TRUE);
3038 /* Hack -- Recharge rods */
3039 if (o_ptr->tval == TV_ROD) return (TRUE);
3047 * Recharge a wand/staff/rod from the pack or on the floor.
3048 * This function has been rewritten in Oangband and ZAngband.
3050 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3051 * Chaos -- Arcane Binding --> recharge(90)
3053 * Scroll of recharging --> recharge(130)
3054 * Artifact activation/Thingol --> recharge(130)
3056 * It is harder to recharge high level, and highly charged wands,
3057 * staffs, and rods. The more wands in a stack, the more easily and
3058 * strongly they recharge. Staffs, however, each get fewer charges if
3061 * XXX XXX XXX Beware of "sliding index errors".
3063 bool recharge(int power)
3066 int recharge_strength, recharge_amount;
3075 char o_name[MAX_NLEN];
3077 /* Only accept legal items */
3078 item_tester_hook = item_tester_hook_recharge;
3082 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3083 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3085 q = "Recharge which item? ";
3086 s = "You have nothing to recharge.";
3089 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3091 /* Get the item (in the pack) */
3094 o_ptr = &inventory[item];
3097 /* Get the item (on the floor) */
3100 o_ptr = &o_list[0 - item];
3103 /* Get the object kind. */
3104 k_ptr = &k_info[o_ptr->k_idx];
3106 /* Extract the object "level" */
3107 lev = k_info[o_ptr->k_idx].level;
3110 /* Recharge a rod */
3111 if (o_ptr->tval == TV_ROD)
3113 /* Extract a recharge strength by comparing object level to power. */
3114 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3118 if (one_in_(recharge_strength))
3120 /* Activate the failure code. */
3127 /* Recharge amount */
3128 recharge_amount = (power * damroll(3, 2));
3130 /* Recharge by that amount */
3131 if (o_ptr->timeout > recharge_amount)
3132 o_ptr->timeout -= recharge_amount;
3139 /* Recharge wand/staff */
3142 /* Extract a recharge strength by comparing object level to power.
3143 * Divide up a stack of wands' charges to calculate charge penalty.
3145 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3146 recharge_strength = (100 + power - lev -
3147 (8 * o_ptr->pval / o_ptr->number)) / 15;
3149 /* All staffs, unstacked wands. */
3150 else recharge_strength = (100 + power - lev -
3151 (8 * o_ptr->pval)) / 15;
3154 if (recharge_strength < 0) recharge_strength = 0;
3157 if (one_in_(recharge_strength))
3159 /* Activate the failure code. */
3163 /* If the spell didn't backfire, recharge the wand or staff. */
3166 /* Recharge based on the standard number of charges. */
3167 recharge_amount = randint1(1 + k_ptr->pval / 2);
3169 /* Multiple wands in a stack increase recharging somewhat. */
3170 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3173 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3174 if (recharge_amount < 1) recharge_amount = 1;
3175 if (recharge_amount > 12) recharge_amount = 12;
3178 /* But each staff in a stack gets fewer additional charges,
3179 * although always at least one.
3181 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3183 recharge_amount /= o_ptr->number;
3184 if (recharge_amount < 1) recharge_amount = 1;
3187 /* Recharge the wand or staff. */
3188 o_ptr->pval += recharge_amount;
3191 /* Hack -- we no longer "know" the item */
3192 o_ptr->ident &= ~(IDENT_KNOWN);
3194 /* Hack -- we no longer think the item is empty */
3195 o_ptr->ident &= ~(IDENT_EMPTY);
3200 /* Inflict the penalties for failing a recharge. */
3203 /* Artifacts are never destroyed. */
3204 if (object_is_fixed_artifact(o_ptr))
3206 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3208 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3210 msg_format("The recharging backfires - %s is completely drained!", o_name);
3214 /* Artifact rods. */
3215 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3216 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3218 /* Artifact wands and staffs. */
3219 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3224 /* Get the object description */
3225 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3227 /*** Determine Seriousness of Failure ***/
3229 /* Mages recharge objects more safely. */
3230 if (p_ptr->pclass == CLASS_MAGE || p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
3232 /* 10% chance to blow up one rod, otherwise draining. */
3233 if (o_ptr->tval == TV_ROD)
3235 if (one_in_(10)) fail_type = 2;
3238 /* 75% chance to blow up one wand, otherwise draining. */
3239 else if (o_ptr->tval == TV_WAND)
3241 if (!one_in_(3)) fail_type = 2;
3244 /* 50% chance to blow up one staff, otherwise no effect. */
3245 else if (o_ptr->tval == TV_STAFF)
3247 if (one_in_(2)) fail_type = 2;
3252 /* All other classes get no special favors. */
3255 /* 33% chance to blow up one rod, otherwise draining. */
3256 if (o_ptr->tval == TV_ROD)
3258 if (one_in_(3)) fail_type = 2;
3261 /* 20% chance of the entire stack, else destroy one wand. */
3262 else if (o_ptr->tval == TV_WAND)
3264 if (one_in_(5)) fail_type = 3;
3267 /* Blow up one staff. */
3268 else if (o_ptr->tval == TV_STAFF)
3274 /*** Apply draining and destruction. ***/
3276 /* Drain object or stack of objects. */
3279 if (o_ptr->tval == TV_ROD)
3282 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3284 msg_print("The recharge backfires, draining the rod further!");
3287 if (o_ptr->timeout < 10000)
3288 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3290 else if (o_ptr->tval == TV_WAND)
3293 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3295 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3300 /* Staffs aren't drained. */
3303 /* Destroy an object or one in a stack of objects. */
3306 if (o_ptr->number > 1)
3308 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3310 msg_format("Wild magic consumes one of your %s!", o_name);
3315 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3317 msg_format("Wild magic consumes your %s!", o_name);
3321 /* Reduce rod stack maximum timeout, drain wands. */
3322 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3323 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3325 /* Reduce and describe inventory */
3328 inven_item_increase(item, -1);
3329 inven_item_describe(item);
3330 inven_item_optimize(item);
3333 /* Reduce and describe floor item */
3336 floor_item_increase(0 - item, -1);
3337 floor_item_describe(0 - item);
3338 floor_item_optimize(0 - item);
3342 /* Destroy all members of a stack of objects. */
3345 if (o_ptr->number > 1)
3347 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3349 msg_format("Wild magic consumes all your %s!", o_name);
3354 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3356 msg_format("Wild magic consumes your %s!", o_name);
3361 /* Reduce and describe inventory */
3364 inven_item_increase(item, -999);
3365 inven_item_describe(item);
3366 inven_item_optimize(item);
3369 /* Reduce and describe floor item */
3372 floor_item_increase(0 - item, -999);
3373 floor_item_describe(0 - item);
3374 floor_item_optimize(0 - item);
3380 /* Combine / Reorder the pack (later) */
3381 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3384 p_ptr->window |= (PW_INVEN);
3386 /* Something was done */
3394 bool bless_weapon(void)
3398 u32b flgs[TR_FLAG_SIZE];
3399 char o_name[MAX_NLEN];
3402 item_tester_no_ryoute = TRUE;
3404 /* Bless only weapons */
3405 item_tester_hook = object_is_weapon;
3409 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3410 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3412 q = "Bless which weapon? ";
3413 s = "You have weapon to bless.";
3416 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3419 /* Get the item (in the pack) */
3422 o_ptr = &inventory[item];
3425 /* Get the item (on the floor) */
3428 o_ptr = &o_list[0 - item];
3433 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3435 /* Extract the flags */
3436 object_flags(o_ptr, flgs);
3438 if (object_is_cursed(o_ptr))
3440 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3441 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3444 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3447 msg_format("The black aura on %s %s disrupts the blessing!",
3448 ((item >= 0) ? "your" : "the"), o_name);
3455 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3458 msg_format("A malignant aura leaves %s %s.",
3459 ((item >= 0) ? "your" : "the"), o_name);
3464 o_ptr->curse_flags = 0L;
3466 /* Hack -- Assume felt */
3467 o_ptr->ident |= (IDENT_SENSE);
3470 o_ptr->feeling = FEEL_NONE;
3472 /* Recalculate the bonuses */
3473 p_ptr->update |= (PU_BONUS);
3476 p_ptr->window |= (PW_EQUIP);
3480 * Next, we try to bless it. Artifacts have a 1/3 chance of
3481 * being blessed, otherwise, the operation simply disenchants
3482 * them, godly power negating the magic. Ok, the explanation
3483 * is silly, but otherwise priests would always bless every
3484 * artifact weapon they find. Ego weapons and normal weapons
3485 * can be blessed automatically.
3487 if (have_flag(flgs, TR_BLESSED))
3490 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3493 msg_format("%s %s %s blessed already.",
3494 ((item >= 0) ? "Your" : "The"), o_name,
3495 ((o_ptr->number > 1) ? "were" : "was"));
3501 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3505 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3508 msg_format("%s %s shine%s!",
3509 ((item >= 0) ? "Your" : "The"), o_name,
3510 ((o_ptr->number > 1) ? "" : "s"));
3513 add_flag(o_ptr->art_flags, TR_BLESSED);
3514 o_ptr->discount = 99;
3518 bool dis_happened = FALSE;
3521 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3523 msg_print("The weapon resists your blessing!");
3527 /* Disenchant tohit */
3528 if (o_ptr->to_h > 0)
3531 dis_happened = TRUE;
3534 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3536 /* Disenchant todam */
3537 if (o_ptr->to_d > 0)
3540 dis_happened = TRUE;
3543 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3545 /* Disenchant toac */
3546 if (o_ptr->to_a > 0)
3549 dis_happened = TRUE;
3552 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3557 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3559 msg_print("There is a static feeling in the air...");
3563 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3566 msg_format("%s %s %s disenchanted!",
3567 ((item >= 0) ? "Your" : "The"), o_name,
3568 ((o_ptr->number > 1) ? "were" : "was"));
3574 /* Recalculate bonuses */
3575 p_ptr->update |= (PU_BONUS);
3578 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3589 bool pulish_shield(void)
3593 u32b flgs[TR_FLAG_SIZE];
3594 char o_name[MAX_NLEN];
3597 item_tester_no_ryoute = TRUE;
3598 /* Assume enchant weapon */
3599 item_tester_tval = TV_SHIELD;
3603 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3604 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3606 q = "Pulish which weapon? ";
3607 s = "You have weapon to pulish.";
3610 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3613 /* Get the item (in the pack) */
3616 o_ptr = &inventory[item];
3619 /* Get the item (on the floor) */
3622 o_ptr = &o_list[0 - item];
3627 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3629 /* Extract the flags */
3630 object_flags(o_ptr, flgs);
3632 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3633 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3636 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3638 msg_format("%s %s shine%s!",
3639 ((item >= 0) ? "Your" : "The"), o_name,
3640 ((o_ptr->number > 1) ? "" : "s"));
3642 o_ptr->name2 = EGO_REFLECTION;
3643 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3645 o_ptr->discount = 99;
3646 chg_virtue(V_ENCHANT, 2);
3652 if (flush_failure) flush();
3655 msg_print("¼ºÇÔ¤·¤¿¡£");
3657 msg_print("Failed.");
3660 chg_virtue(V_ENCHANT, -2);
3669 * Potions "smash open" and cause an area effect when
3670 * (1) they are shattered while in the player's inventory,
3671 * due to cold (etc) attacks;
3672 * (2) they are thrown at a monster, or obstacle;
3673 * (3) they are shattered by a "cold ball" or other such spell
3674 * while lying on the floor.
3677 * who --- who caused the potion to shatter (0=player)
3678 * potions that smash on the floor are assumed to
3679 * be caused by no-one (who = 1), as are those that
3680 * shatter inside the player inventory.
3681 * (Not anymore -- I changed this; TY)
3682 * y, x --- coordinates of the potion (or player if
3683 * the potion was in her inventory);
3684 * o_ptr --- pointer to the potion object.
3686 bool potion_smash_effect(int who, int y, int x, int k_idx)
3693 object_kind *k_ptr = &k_info[k_idx];
3695 switch (k_ptr->sval)
3697 case SV_POTION_SALT_WATER:
3698 case SV_POTION_SLIME_MOLD:
3699 case SV_POTION_LOSE_MEMORIES:
3700 case SV_POTION_DEC_STR:
3701 case SV_POTION_DEC_INT:
3702 case SV_POTION_DEC_WIS:
3703 case SV_POTION_DEC_DEX:
3704 case SV_POTION_DEC_CON:
3705 case SV_POTION_DEC_CHR:
3706 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3707 case SV_POTION_APPLE_JUICE:
3710 case SV_POTION_INFRAVISION:
3711 case SV_POTION_DETECT_INVIS:
3712 case SV_POTION_SLOW_POISON:
3713 case SV_POTION_CURE_POISON:
3714 case SV_POTION_BOLDNESS:
3715 case SV_POTION_RESIST_HEAT:
3716 case SV_POTION_RESIST_COLD:
3717 case SV_POTION_HEROISM:
3718 case SV_POTION_BESERK_STRENGTH:
3719 case SV_POTION_RES_STR:
3720 case SV_POTION_RES_INT:
3721 case SV_POTION_RES_WIS:
3722 case SV_POTION_RES_DEX:
3723 case SV_POTION_RES_CON:
3724 case SV_POTION_RES_CHR:
3725 case SV_POTION_INC_STR:
3726 case SV_POTION_INC_INT:
3727 case SV_POTION_INC_WIS:
3728 case SV_POTION_INC_DEX:
3729 case SV_POTION_INC_CON:
3730 case SV_POTION_INC_CHR:
3731 case SV_POTION_AUGMENTATION:
3732 case SV_POTION_ENLIGHTENMENT:
3733 case SV_POTION_STAR_ENLIGHTENMENT:
3734 case SV_POTION_SELF_KNOWLEDGE:
3735 case SV_POTION_EXPERIENCE:
3736 case SV_POTION_RESISTANCE:
3737 case SV_POTION_INVULNERABILITY:
3738 case SV_POTION_NEW_LIFE:
3739 /* All of the above potions have no effect when shattered */
3741 case SV_POTION_SLOWNESS:
3746 case SV_POTION_POISON:
3751 case SV_POTION_BLINDNESS:
3755 case SV_POTION_CONFUSION: /* Booze */
3759 case SV_POTION_SLEEP:
3763 case SV_POTION_RUINATION:
3764 case SV_POTION_DETONATIONS:
3766 dam = damroll(25, 25);
3769 case SV_POTION_DEATH:
3770 dt = GF_DEATH_RAY; /* !! */
3771 dam = k_ptr->level * 10;
3775 case SV_POTION_SPEED:
3778 case SV_POTION_CURE_LIGHT:
3780 dam = damroll(2, 3);
3782 case SV_POTION_CURE_SERIOUS:
3784 dam = damroll(4, 3);
3786 case SV_POTION_CURE_CRITICAL:
3787 case SV_POTION_CURING:
3789 dam = damroll(6, 3);
3791 case SV_POTION_HEALING:
3793 dam = damroll(10, 10);
3795 case SV_POTION_RESTORE_EXP:
3800 case SV_POTION_LIFE:
3802 dam = damroll(50, 50);
3805 case SV_POTION_STAR_HEALING:
3807 dam = damroll(50, 50);
3810 case SV_POTION_RESTORE_MANA: /* MANA */
3812 dam = damroll(10, 10);
3819 (void)project(who, radius, y, x, dam, dt,
3820 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3822 /* XXX those potions that explode need to become "known" */
3828 * Hack -- Display all known spells in a window
3830 * XXX XXX XXX Need to analyze size of the window.
3832 * XXX XXX XXX Need more color coding.
3834 void display_spell_list(void)
3847 /* They have too many spells to list */
3848 if (p_ptr->pclass == CLASS_SORCERER) return;
3849 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3851 /* mind.c type classes */
3852 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3853 (p_ptr->pclass == CLASS_BERSERKER) ||
3854 (p_ptr->pclass == CLASS_NINJA) ||
3855 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3856 (p_ptr->pclass == CLASS_FORCETRAINER))
3862 int plev = p_ptr->lev;
3868 bool use_hp = FALSE;
3870 /* Display a list of spells */
3873 put_str("̾Á°", y, x + 5);
3874 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3876 put_str("Name", y, x + 5);
3877 put_str("Lv Mana Fail Info", y, x + 35);
3880 switch(p_ptr->pclass)
3882 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3883 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3884 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3885 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3886 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3887 default: use_mind = 0;break;
3890 /* Dump the spells */
3891 for (i = 0; i < MAX_MIND_POWERS; i++)
3893 byte a = TERM_WHITE;
3895 /* Access the available spell */
3896 spell = mind_powers[use_mind].info[i];
3897 if (spell.min_lev > plev) break;
3899 /* Get the failure rate */
3900 chance = spell.fail;
3902 /* Reduce failure rate by "effective" level adjustment */
3903 chance -= 3 * (p_ptr->lev - spell.min_lev);
3905 /* Reduce failure rate by INT/WIS adjustment */
3906 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3910 /* Not enough mana to cast */
3911 if (spell.mana_cost > p_ptr->csp)
3913 chance += 5 * (spell.mana_cost - p_ptr->csp);
3919 /* Not enough hp to cast */
3920 if (spell.mana_cost > p_ptr->chp)
3927 /* Extract the minimum failure rate */
3928 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3930 /* Minimum failure rate */
3931 if (chance < minfail) chance = minfail;
3933 /* Stunning makes spells harder */
3934 if (p_ptr->stun > 50) chance += 25;
3935 else if (p_ptr->stun) chance += 15;
3937 /* Always a 5 percent chance of working */
3938 if (chance > 95) chance = 95;
3941 mindcraft_info(comment, use_mind, i);
3943 /* Dump the spell */
3944 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3946 spell.min_lev, spell.mana_cost, chance, comment);
3948 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3953 /* Cannot read spellbooks */
3954 if (REALM_NONE == p_ptr->realm1) return;
3956 /* Normal spellcaster with books */
3959 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3963 /* Reset vertical */
3966 /* Vertical location */
3967 y = (j < 3) ? 0 : (m[j - 3] + 2);
3969 /* Horizontal location */
3973 for (i = 0; i < 32; i++)
3975 byte a = TERM_WHITE;
3977 /* Access the spell */
3978 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3980 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3984 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3987 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3990 if (s_ptr->slevel >= 99)
3994 strcpy(name, "(ȽÆÉÉÔǽ)");
3996 strcpy(name, "(illegible)");
4006 ((p_ptr->spell_forgotten1 & (1L << i))) :
4007 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4014 else if (!((j < 1) ?
4015 (p_ptr->spell_learned1 & (1L << i)) :
4016 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4023 else if (!((j < 1) ?
4024 (p_ptr->spell_worked1 & (1L << i)) :
4025 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4031 /* Dump the spell --(-- */
4032 sprintf(out_val, "%c/%c) %-20.20s",
4033 I2A(n / 8), I2A(n % 8), name);
4038 /* Dump onto the window */
4039 Term_putstr(x, m[j], -1, a, out_val);
4049 * Returns experience of a spell
4051 s16b experience_of_spell(int spell, int use_realm)
4053 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4054 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4055 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4056 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4062 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4064 int mod_need_mana(int need_mana, int spell, int realm)
4066 #define MANA_CONST 2400
4068 #define DEC_MANA_DIV 3
4071 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4074 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4075 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4077 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4078 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4079 need_mana /= MANA_CONST * MANA_DIV;
4080 if (need_mana < 1) need_mana = 1;
4083 /* Non-realm magic */
4086 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4098 * Modify spell fail rate
4099 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4101 int mod_spell_chance_1(int chance)
4103 chance += p_ptr->to_m_chance;
4105 if (p_ptr->heavy_spell) chance += 20;
4107 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4108 else if (p_ptr->easy_spell) chance -= 3;
4109 else if (p_ptr->dec_mana) chance -= 2;
4116 * Modify spell fail rate (as "suffix" process)
4117 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4118 * Note: variable "chance" cannot be negative.
4120 int mod_spell_chance_2(int chance)
4122 if (p_ptr->dec_mana) chance--;
4124 if (p_ptr->heavy_spell) chance += 5;
4126 return MAX(chance, 0);
4131 * Returns spell chance of failure for spell -RAK-
4133 s16b spell_chance(int spell, int use_realm)
4135 int chance, minfail;
4138 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4141 /* Paranoia -- must be literate */
4142 if (!mp_ptr->spell_book) return (100);
4144 if (use_realm == REALM_HISSATSU) return 0;
4146 /* Access the spell */
4147 if (!is_magic(use_realm))
4149 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4153 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4156 /* Extract the base spell failure rate */
4157 chance = s_ptr->sfail;
4159 /* Reduce failure rate by "effective" level adjustment */
4160 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4162 /* Reduce failure rate by INT/WIS adjustment */
4163 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4166 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4168 /* Extract mana consumption rate */
4169 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4171 /* Not enough mana to cast */
4172 if (need_mana > p_ptr->csp)
4174 chance += 5 * (need_mana - p_ptr->csp);
4177 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4179 /* Extract the minimum failure rate */
4180 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4183 * Non mage/priest characters never get too good
4184 * (added high mage, mindcrafter)
4186 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4188 if (minfail < 5) minfail = 5;
4191 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4192 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4193 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4195 chance = mod_spell_chance_1(chance);
4197 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4198 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4199 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4201 /* Minimum failure rate */
4202 if (chance < minfail) chance = minfail;
4204 /* Stunning makes spells harder */
4205 if (p_ptr->stun > 50) chance += 25;
4206 else if (p_ptr->stun) chance += 15;
4208 /* Always a 5 percent chance of working */
4209 if (chance > 95) chance = 95;
4211 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4212 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4214 s16b exp = experience_of_spell(spell, use_realm);
4215 if (exp >= SPELL_EXP_EXPERT) chance--;
4216 if (exp >= SPELL_EXP_MASTER) chance--;
4219 /* Return the chance */
4220 return mod_spell_chance_2(chance);
4226 * Determine if a spell is "okay" for the player to cast or study
4227 * The spell must be legible, not forgotten, and also, to cast,
4228 * it must be known, and to study, it must not be known.
4230 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4234 /* Access the spell */
4235 if (!is_magic(use_realm))
4237 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4241 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4244 /* Spell is illegal */
4245 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4247 /* Spell is forgotten */
4248 if ((use_realm == p_ptr->realm2) ?
4249 (p_ptr->spell_forgotten2 & (1L << spell)) :
4250 (p_ptr->spell_forgotten1 & (1L << spell)))
4256 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4257 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4259 /* Spell is learned */
4260 if ((use_realm == p_ptr->realm2) ?
4261 (p_ptr->spell_learned2 & (1L << spell)) :
4262 (p_ptr->spell_learned1 & (1L << spell)))
4265 return (!study_pray);
4268 /* Okay to study, not to cast */
4274 * Print a list of spells (for browsing or casting or viewing)
4276 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4278 int i, spell, exp_level, increment = 64;
4290 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4292 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4294 msg_print("Warning! print_spells called with null realm");
4298 /* Title the list */
4300 if (use_realm == REALM_HISSATSU)
4302 strcpy(buf," Lv MP");
4304 strcpy(buf," Lv SP");
4308 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4310 strcpy(buf,"Profic Lv SP Fail Effect");
4314 put_str("̾Á°", y, x + 5);
4315 put_str(buf, y, x + 29);
4317 put_str("Name", y, x + 5);
4318 put_str(buf, y, x + 29);
4321 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4322 else if (use_realm == p_ptr->realm1) increment = 0;
4323 else if (use_realm == p_ptr->realm2) increment = 32;
4325 /* Dump the spells */
4326 for (i = 0; i < num; i++)
4328 /* Access the spell */
4331 /* Access the spell */
4332 if (!is_magic(use_realm))
4334 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4338 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4341 if (use_realm == REALM_HISSATSU)
4342 need_mana = s_ptr->smana;
4345 s16b exp = experience_of_spell(spell, use_realm);
4347 /* Extract mana consumption rate */
4348 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4350 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4351 else exp_level = spell_exp_level(exp);
4354 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4355 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4356 else if (s_ptr->slevel >= 99) max = TRUE;
4357 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4359 strncpy(ryakuji, exp_level_str[exp_level], 4);
4364 if (use_menu && target_spell)
4366 if (i == (target_spell-1))
4368 strcpy(out_val, " ¡Õ ");
4370 strcpy(out_val, " > ");
4373 strcpy(out_val, " ");
4375 else sprintf(out_val, " %c) ", I2A(i));
4376 /* Skip illegible spells */
4377 if (s_ptr->slevel >= 99)
4380 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4382 strcat(out_val, format("%-30s", "(illegible)"));
4385 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4389 /* XXX XXX Could label spells above the players level */
4391 /* Get extra info */
4392 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4397 /* Assume spell is known and tried */
4398 line_attr = TERM_WHITE;
4400 /* Analyze the spell */
4401 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4403 if (s_ptr->slevel > p_ptr->max_plv)
4408 comment = "unknown";
4411 line_attr = TERM_L_BLUE;
4413 else if (s_ptr->slevel > p_ptr->lev)
4418 comment = "forgotten";
4421 line_attr = TERM_YELLOW;
4424 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4429 comment = "unknown";
4432 line_attr = TERM_L_BLUE;
4434 else if ((use_realm == p_ptr->realm1) ?
4435 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4436 ((p_ptr->spell_forgotten2 & (1L << spell))))
4441 comment = "forgotten";
4444 line_attr = TERM_YELLOW;
4446 else if (!((use_realm == p_ptr->realm1) ?
4447 (p_ptr->spell_learned1 & (1L << spell)) :
4448 (p_ptr->spell_learned2 & (1L << spell))))
4453 comment = "unknown";
4456 line_attr = TERM_L_BLUE;
4458 else if (!((use_realm == p_ptr->realm1) ?
4459 (p_ptr->spell_worked1 & (1L << spell)) :
4460 (p_ptr->spell_worked2 & (1L << spell))))
4465 comment = "untried";
4468 line_attr = TERM_L_GREEN;
4471 /* Dump the spell --(-- */
4472 if (use_realm == REALM_HISSATSU)
4474 strcat(out_val, format("%-25s %2d %4d",
4475 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4476 s_ptr->slevel, need_mana));
4480 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4481 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4482 (max ? '!' : ' '), ryakuji,
4483 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4485 c_prt(line_attr, out_val, y + i + 1, x);
4488 /* Clear the bottom line */
4489 prt("", y + i + 1, x);
4494 * Note that amulets, rods, and high-level spell books are immune
4495 * to "inventory damage" of any kind. Also sling ammo and shovels.
4500 * Does a given class of objects (usually) hate acid?
4501 * Note that acid can either melt or corrode something.
4503 bool hates_acid(object_type *o_ptr)
4505 /* Analyze the type */
4506 switch (o_ptr->tval)
4508 /* Wearable items */
4528 /* Staffs/Scrolls are wood/paper */
4541 /* Junk is useless */
4555 * Does a given object (usually) hate electricity?
4557 bool hates_elec(object_type *o_ptr)
4559 switch (o_ptr->tval)
4573 * Does a given object (usually) hate fire?
4574 * Hafted/Polearm weapons have wooden shafts.
4575 * Arrows/Bows are mostly wooden.
4577 bool hates_fire(object_type *o_ptr)
4579 /* Analyze the type */
4580 switch (o_ptr->tval)
4598 case TV_SORCERY_BOOK:
4599 case TV_NATURE_BOOK:
4603 case TV_ARCANE_BOOK:
4605 case TV_DAEMON_BOOK:
4606 case TV_CRUSADE_BOOK:
4608 case TV_HISSATSU_BOOK:
4619 /* Staffs/Scrolls burn */
4632 * Does a given object (usually) hate cold?
4634 bool hates_cold(object_type *o_ptr)
4636 switch (o_ptr->tval)
4653 int set_acid_destroy(object_type *o_ptr)
4655 u32b flgs[TR_FLAG_SIZE];
4656 if (!hates_acid(o_ptr)) return (FALSE);
4657 object_flags(o_ptr, flgs);
4658 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4666 int set_elec_destroy(object_type *o_ptr)
4668 u32b flgs[TR_FLAG_SIZE];
4669 if (!hates_elec(o_ptr)) return (FALSE);
4670 object_flags(o_ptr, flgs);
4671 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4679 int set_fire_destroy(object_type *o_ptr)
4681 u32b flgs[TR_FLAG_SIZE];
4682 if (!hates_fire(o_ptr)) return (FALSE);
4683 object_flags(o_ptr, flgs);
4684 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4692 int set_cold_destroy(object_type *o_ptr)
4694 u32b flgs[TR_FLAG_SIZE];
4695 if (!hates_cold(o_ptr)) return (FALSE);
4696 object_flags(o_ptr, flgs);
4697 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4703 * Destroys a type of item on a given percent chance
4704 * Note that missiles are no longer necessarily all destroyed
4705 * Destruction taken from "melee.c" code for "stealing".
4706 * New-style wands and rods handled correctly. -LM-
4707 * Returns number of items destroyed.
4709 int inven_damage(inven_func typ, int perc)
4713 char o_name[MAX_NLEN];
4715 /* Multishadow effects is determined by turn */
4716 if( p_ptr->multishadow && (turn & 1) )return 0;
4718 if (p_ptr->inside_arena) return 0;
4720 /* Count the casualties */
4723 /* Scan through the slots backwards */
4724 for (i = 0; i < INVEN_PACK; i++)
4726 o_ptr = &inventory[i];
4728 /* Skip non-objects */
4729 if (!o_ptr->k_idx) continue;
4731 /* Hack -- for now, skip artifacts */
4732 if (object_is_artifact(o_ptr)) continue;
4734 /* Give this item slot a shot at death */
4737 /* Count the casualties */
4738 for (amt = j = 0; j < o_ptr->number; ++j)
4740 if (randint0(100) < perc) amt++;
4743 /* Some casualities */
4746 /* Get a description */
4747 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4751 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4753 msg_format("%sour %s (%c) %s destroyed!",
4757 o_name, index_to_label(i),
4758 ((o_ptr->number > 1) ?
4759 ((amt == o_ptr->number) ? "Á´Éô" :
4760 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4762 ((o_ptr->number > 1) ?
4763 ((amt == o_ptr->number) ? "All of y" :
4764 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4765 o_name, index_to_label(i),
4766 ((amt > 1) ? "were" : "was"));
4770 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4771 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4774 /* Potions smash open */
4775 if (object_is_potion(o_ptr))
4777 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4780 /* Reduce the charges of rods/wands */
4781 reduce_charges(o_ptr, amt);
4783 /* Destroy "amt" items */
4784 inven_item_increase(i, -amt);
4785 inven_item_optimize(i);
4787 /* Count the casualties */
4793 /* Return the casualty count */
4799 * Acid has hit the player, attempt to affect some armor.
4801 * Note that the "base armor" of an object never changes.
4803 * If any armor is damaged (or resists), the player takes less damage.
4805 static int minus_ac(void)
4807 object_type *o_ptr = NULL;
4808 u32b flgs[TR_FLAG_SIZE];
4809 char o_name[MAX_NLEN];
4812 /* Pick a (possibly empty) inventory slot */
4813 switch (randint1(7))
4815 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4816 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4817 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4818 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4819 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4820 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4821 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4824 /* Nothing to damage */
4825 if (!o_ptr->k_idx) return (FALSE);
4827 if (!object_is_armour(o_ptr)) return (FALSE);
4829 /* No damage left to be done */
4830 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4834 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4836 /* Extract the flags */
4837 object_flags(o_ptr, flgs);
4839 /* Object resists */
4840 if (have_flag(flgs, TR_IGNORE_ACID))
4843 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
4845 msg_format("Your %s is unaffected!", o_name);
4854 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
4856 msg_format("Your %s is damaged!", o_name);
4860 /* Damage the item */
4863 /* Calculate bonuses */
4864 p_ptr->update |= (PU_BONUS);
4867 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4871 /* Item was damaged */
4877 * Hurt the player with Acid
4879 int acid_dam(int dam, cptr kb_str, int monspell)
4882 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4883 bool double_resist = IS_OPPOSE_ACID();
4885 /* Total Immunity */
4886 if (p_ptr->immune_acid || (dam <= 0))
4888 learn_spell(monspell);
4892 /* Vulnerability (Ouch!) */
4893 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4894 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4896 /* Resist the damage */
4897 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4898 if (double_resist) dam = (dam + 2) / 3;
4900 if ((!(double_resist || p_ptr->resist_acid)) &&
4901 one_in_(HURT_CHANCE))
4902 (void)do_dec_stat(A_CHR);
4904 /* If any armor gets hit, defend the player */
4905 if (minus_ac()) dam = (dam + 1) / 2;
4908 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4910 /* Inventory damage */
4911 if (!(double_resist && p_ptr->resist_acid))
4912 inven_damage(set_acid_destroy, inv);
4918 * Hurt the player with electricity
4920 int elec_dam(int dam, cptr kb_str, int monspell)
4923 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4924 bool double_resist = IS_OPPOSE_ELEC();
4926 /* Total immunity */
4927 if (p_ptr->immune_elec || (dam <= 0))
4929 learn_spell(monspell);
4933 /* Vulnerability (Ouch!) */
4934 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4935 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4936 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4938 /* Resist the damage */
4939 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4940 if (double_resist) dam = (dam + 2) / 3;
4942 if ((!(double_resist || p_ptr->resist_elec)) &&
4943 one_in_(HURT_CHANCE))
4944 (void)do_dec_stat(A_DEX);
4947 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4949 /* Inventory damage */
4950 if (!(double_resist && p_ptr->resist_elec))
4951 inven_damage(set_elec_destroy, inv);
4958 * Hurt the player with Fire
4960 int fire_dam(int dam, cptr kb_str, int monspell)
4963 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4964 bool double_resist = IS_OPPOSE_FIRE();
4966 /* Totally immune */
4967 if (p_ptr->immune_fire || (dam <= 0))
4969 learn_spell(monspell);
4973 /* Vulnerability (Ouch!) */
4974 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4975 if (prace_is_(RACE_ENT)) dam += dam / 3;
4976 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4978 /* Resist the damage */
4979 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4980 if (double_resist) dam = (dam + 2) / 3;
4982 if ((!(double_resist || p_ptr->resist_fire)) &&
4983 one_in_(HURT_CHANCE))
4984 (void)do_dec_stat(A_STR);
4987 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4989 /* Inventory damage */
4990 if (!(double_resist && p_ptr->resist_fire))
4991 inven_damage(set_fire_destroy, inv);
4998 * Hurt the player with Cold
5000 int cold_dam(int dam, cptr kb_str, int monspell)
5003 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5004 bool double_resist = IS_OPPOSE_COLD();
5006 /* Total immunity */
5007 if (p_ptr->immune_cold || (dam <= 0))
5009 learn_spell(monspell);
5013 /* Vulnerability (Ouch!) */
5014 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5015 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5017 /* Resist the damage */
5018 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5019 if (double_resist) dam = (dam + 2) / 3;
5021 if ((!(double_resist || p_ptr->resist_cold)) &&
5022 one_in_(HURT_CHANCE))
5023 (void)do_dec_stat(A_STR);
5026 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5028 /* Inventory damage */
5029 if (!(double_resist && p_ptr->resist_cold))
5030 inven_damage(set_cold_destroy, inv);
5036 bool rustproof(void)
5040 char o_name[MAX_NLEN];
5043 item_tester_no_ryoute = TRUE;
5044 /* Select a piece of armour */
5045 item_tester_hook = object_is_armour;
5049 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5050 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5052 q = "Rustproof which piece of armour? ";
5053 s = "You have nothing to rustproof.";
5056 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5058 /* Get the item (in the pack) */
5061 o_ptr = &inventory[item];
5064 /* Get the item (on the floor) */
5067 o_ptr = &o_list[0 - item];
5072 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5074 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5076 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
5079 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5081 msg_format("%s %s look%s as good as new!",
5082 ((item >= 0) ? "Your" : "The"), o_name,
5083 ((o_ptr->number > 1) ? "" : "s"));
5090 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5092 msg_format("%s %s %s now protected against corrosion.",
5093 ((item >= 0) ? "Your" : "The"), o_name,
5094 ((o_ptr->number > 1) ? "are" : "is"));
5105 * Curse the players armor
5107 bool curse_armor(void)
5112 char o_name[MAX_NLEN];
5115 /* Curse the body armor */
5116 o_ptr = &inventory[INVEN_BODY];
5118 /* Nothing to curse */
5119 if (!o_ptr->k_idx) return (FALSE);
5123 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5125 /* Attempt a saving throw for artifacts */
5126 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
5130 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5131 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5133 msg_format("A %s tries to %s, but your %s resists the effects!",
5134 "terrible black aura", "surround your armor", o_name);
5139 /* not artifact or failed save... */
5144 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5146 msg_format("A terrible black aura blasts your %s!", o_name);
5149 chg_virtue(V_ENCHANT, -5);
5151 /* Blast the armor */
5153 o_ptr->name2 = EGO_BLASTED;
5154 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5161 for (i = 0; i < TR_FLAG_SIZE; i++)
5162 o_ptr->art_flags[i] = 0;
5165 o_ptr->curse_flags = TRC_CURSED;
5168 o_ptr->ident |= (IDENT_BROKEN);
5170 /* Recalculate bonuses */
5171 p_ptr->update |= (PU_BONUS);
5173 /* Recalculate mana */
5174 p_ptr->update |= (PU_MANA);
5177 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5185 * Curse the players weapon
5187 bool curse_weapon(bool force, int slot)
5193 char o_name[MAX_NLEN];
5196 /* Curse the weapon */
5197 o_ptr = &inventory[slot];
5199 /* Nothing to curse */
5200 if (!o_ptr->k_idx) return (FALSE);
5204 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5206 /* Attempt a saving throw */
5207 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5211 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5212 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5214 msg_format("A %s tries to %s, but your %s resists the effects!",
5215 "terrible black aura", "surround your weapon", o_name);
5220 /* not artifact or failed save... */
5225 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5227 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5230 chg_virtue(V_ENCHANT, -5);
5232 /* Shatter the weapon */
5234 o_ptr->name2 = EGO_SHATTERED;
5235 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5236 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5242 for (i = 0; i < TR_FLAG_SIZE; i++)
5243 o_ptr->art_flags[i] = 0;
5247 o_ptr->curse_flags = TRC_CURSED;
5250 o_ptr->ident |= (IDENT_BROKEN);
5252 /* Recalculate bonuses */
5253 p_ptr->update |= (PU_BONUS);
5255 /* Recalculate mana */
5256 p_ptr->update |= (PU_MANA);
5259 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5268 * Enchant some bolts
5270 bool brand_bolts(void)
5274 /* Use the first acceptable bolts */
5275 for (i = 0; i < INVEN_PACK; i++)
5277 object_type *o_ptr = &inventory[i];
5279 /* Skip non-bolts */
5280 if (o_ptr->tval != TV_BOLT) continue;
5282 /* Skip artifacts and ego-items */
5283 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5286 /* Skip cursed/broken items */
5287 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5290 if (randint0(100) < 75) continue;
5294 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5296 msg_print("Your bolts are covered in a fiery aura!");
5301 o_ptr->name2 = EGO_FLAME;
5304 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5311 if (flush_failure) flush();
5315 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5317 msg_print("The fiery enchantment failed.");
5327 * Helper function -- return a "nearby" race for polymorphing
5329 * Note that this function is one of the more "dangerous" ones...
5331 static s16b poly_r_idx(int r_idx)
5333 monster_race *r_ptr = &r_info[r_idx];
5335 int i, r, lev1, lev2;
5337 /* Hack -- Uniques/Questors never polymorph */
5338 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5339 (r_ptr->flags1 & RF1_QUESTOR))
5342 /* Allowable range of "levels" for resulting monster */
5343 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5344 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5346 /* Pick a (possibly new) non-unique race */
5347 for (i = 0; i < 1000; i++)
5349 /* Pick a new race, using a level calculation */
5350 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5352 /* Handle failure */
5358 /* Ignore unique monsters */
5359 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5361 /* Ignore monsters with incompatible levels */
5362 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5364 /* Use that index */
5376 bool polymorph_monster(int y, int x)
5378 cave_type *c_ptr = &cave[y][x];
5379 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5380 bool polymorphed = FALSE;
5382 int old_r_idx = m_ptr->r_idx;
5383 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5384 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5385 monster_type back_m;
5387 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5389 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5391 /* Memorize the monster before polymorphing */
5394 /* Pick a "new" monster race */
5395 new_r_idx = poly_r_idx(old_r_idx);
5397 /* Handle polymorph */
5398 if (new_r_idx != old_r_idx)
5402 /* Get the monsters attitude */
5403 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5404 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5405 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5407 /* "Kill" the "old" monster */
5408 delete_monster_idx(c_ptr->m_idx);
5410 /* Create a new monster (no groups) */
5411 if (place_monster_aux(0, y, x, new_r_idx, mode))
5418 /* Placing the new monster failed */
5419 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5421 m_list[hack_m_idx_ii] = back_m;
5423 /* Re-initialize monster process */
5428 if (targeted) target_who = hack_m_idx_ii;
5429 if (health_tracked) health_track(hack_m_idx_ii);
5439 static bool dimension_door_aux(int x, int y)
5441 int plev = p_ptr->lev;
5443 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5445 if (!cave_player_teleportable_bold(y, x, FALSE, FALSE) ||
5446 (distance(y, x, py, px) > plev / 2 + 10) ||
5447 (!randint0(plev / 10 + 10)))
5449 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5450 teleport_player((plev + 2) * 2, TRUE);
5457 teleport_player_to(y, x, TRUE, FALSE);
5468 bool dimension_door(void)
5472 /* Rerutn FALSE if cancelled */
5473 if (!tgt_pt(&x, &y)) return FALSE;
5475 if (dimension_door_aux(x, y)) return TRUE;
5478 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5480 msg_print("You fail to exit the astral plane correctly!");
5488 * Mirror Master's Dimension Door
5490 bool mirror_tunnel(void)
5494 /* Rerutn FALSE if cancelled */
5495 if (!tgt_pt(&x, &y)) return FALSE;
5497 if (dimension_door_aux(x, y)) return TRUE;
5500 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5502 msg_print("You fail to pass the mirror plane correctly!");
5509 bool eat_magic(int power)
5511 object_type * o_ptr;
5514 int recharge_strength = 0;
5520 char o_name[MAX_NLEN];
5522 item_tester_hook = item_tester_hook_recharge;
5526 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5527 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5529 q = "Drain which item? ";
5530 s = "You have nothing to drain.";
5533 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5537 o_ptr = &inventory[item];
5541 o_ptr = &o_list[0 - item];
5544 k_ptr = &k_info[o_ptr->k_idx];
5545 lev = k_info[o_ptr->k_idx].level;
5547 if (o_ptr->tval == TV_ROD)
5549 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5552 if (one_in_(recharge_strength))
5554 /* Activate the failure code. */
5559 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5562 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5564 msg_print("You can't absorb energy from a discharged rod.");
5571 o_ptr->timeout += k_ptr->pval;
5577 /* All staffs, wands. */
5578 recharge_strength = (100 + power - lev) / 15;
5581 if (recharge_strength < 0) recharge_strength = 0;
5584 if (one_in_(recharge_strength))
5586 /* Activate the failure code. */
5591 if (o_ptr->pval > 0)
5593 p_ptr->csp += lev / 2;
5596 /* XXX Hack -- unstack if necessary */
5597 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5602 /* Get local object */
5605 /* Obtain a local object */
5606 object_copy(q_ptr, o_ptr);
5608 /* Modify quantity */
5611 /* Restore the charges */
5614 /* Unstack the used item */
5616 p_ptr->total_weight -= q_ptr->weight;
5617 item = inven_carry(q_ptr);
5621 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5623 msg_print("You unstack your staff.");
5631 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5633 msg_print("There's no energy there to absorb!");
5637 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5641 /* Inflict the penalties for failing a recharge. */
5644 /* Artifacts are never destroyed. */
5645 if (object_is_fixed_artifact(o_ptr))
5647 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5649 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5651 msg_format("The recharging backfires - %s is completely drained!", o_name);
5655 /* Artifact rods. */
5656 if (o_ptr->tval == TV_ROD)
5657 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5659 /* Artifact wands and staffs. */
5660 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5665 /* Get the object description */
5666 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5668 /*** Determine Seriousness of Failure ***/
5670 /* Mages recharge objects more safely. */
5671 if (p_ptr->pclass == CLASS_MAGE || p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
5673 /* 10% chance to blow up one rod, otherwise draining. */
5674 if (o_ptr->tval == TV_ROD)
5676 if (one_in_(10)) fail_type = 2;
5679 /* 75% chance to blow up one wand, otherwise draining. */
5680 else if (o_ptr->tval == TV_WAND)
5682 if (!one_in_(3)) fail_type = 2;
5685 /* 50% chance to blow up one staff, otherwise no effect. */
5686 else if (o_ptr->tval == TV_STAFF)
5688 if (one_in_(2)) fail_type = 2;
5693 /* All other classes get no special favors. */
5696 /* 33% chance to blow up one rod, otherwise draining. */
5697 if (o_ptr->tval == TV_ROD)
5699 if (one_in_(3)) fail_type = 2;
5702 /* 20% chance of the entire stack, else destroy one wand. */
5703 else if (o_ptr->tval == TV_WAND)
5705 if (one_in_(5)) fail_type = 3;
5708 /* Blow up one staff. */
5709 else if (o_ptr->tval == TV_STAFF)
5715 /*** Apply draining and destruction. ***/
5717 /* Drain object or stack of objects. */
5720 if (o_ptr->tval == TV_ROD)
5723 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5725 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5728 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5730 else if (o_ptr->tval == TV_WAND)
5733 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5735 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5740 /* Staffs aren't drained. */
5743 /* Destroy an object or one in a stack of objects. */
5746 if (o_ptr->number > 1)
5749 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5751 msg_format("Wild magic consumes one of your %s!", o_name);
5754 /* Reduce rod stack maximum timeout, drain wands. */
5755 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5756 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5761 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5763 msg_format("Wild magic consumes your %s!", o_name);
5766 /* Reduce and describe inventory */
5769 inven_item_increase(item, -1);
5770 inven_item_describe(item);
5771 inven_item_optimize(item);
5774 /* Reduce and describe floor item */
5777 floor_item_increase(0 - item, -1);
5778 floor_item_describe(0 - item);
5779 floor_item_optimize(0 - item);
5783 /* Destroy all members of a stack of objects. */
5786 if (o_ptr->number > 1)
5788 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5790 msg_format("Wild magic consumes all your %s!", o_name);
5795 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5797 msg_format("Wild magic consumes your %s!", o_name);
5802 /* Reduce and describe inventory */
5805 inven_item_increase(item, -999);
5806 inven_item_describe(item);
5807 inven_item_optimize(item);
5810 /* Reduce and describe floor item */
5813 floor_item_increase(0 - item, -999);
5814 floor_item_describe(0 - item);
5815 floor_item_optimize(0 - item);
5821 if (p_ptr->csp > p_ptr->msp)
5823 p_ptr->csp = p_ptr->msp;
5826 /* Redraw mana and hp */
5827 p_ptr->redraw |= (PR_MANA);
5829 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5830 p_ptr->window |= (PW_INVEN);
5836 bool summon_kin_player(int level, int y, int x, u32b mode)
5838 bool pet = (bool)(mode & PM_FORCE_PET);
5839 if (!pet) mode |= PM_NO_PET;
5841 switch (p_ptr->mimic_form)
5844 switch (p_ptr->prace)
5848 case RACE_BARBARIAN:
5851 summon_kin_type = 'p';
5861 case RACE_MIND_FLAYER:
5864 summon_kin_type = 'h';
5867 summon_kin_type = 'o';
5869 case RACE_HALF_TROLL:
5870 summon_kin_type = 'T';
5872 case RACE_HALF_OGRE:
5873 summon_kin_type = 'O';
5875 case RACE_HALF_GIANT:
5876 case RACE_HALF_TITAN:
5878 summon_kin_type = 'P';
5881 summon_kin_type = 'y';
5884 summon_kin_type = 'K';
5887 summon_kin_type = 'k';
5890 if (one_in_(13)) summon_kin_type = 'U';
5891 else summon_kin_type = 'u';
5893 case RACE_DRACONIAN:
5894 summon_kin_type = 'd';
5898 summon_kin_type = 'g';
5901 if (one_in_(13)) summon_kin_type = 'L';
5902 else summon_kin_type = 's';
5905 summon_kin_type = 'z';
5908 summon_kin_type = 'V';
5911 summon_kin_type = 'G';
5914 summon_kin_type = 'I';
5917 summon_kin_type = '#';
5920 summon_kin_type = 'A';
5923 summon_kin_type = 'U';
5926 summon_kin_type = 'p';
5931 if (one_in_(13)) summon_kin_type = 'U';
5932 else summon_kin_type = 'u';
5934 case MIMIC_DEMON_LORD:
5935 summon_kin_type = 'U';
5938 summon_kin_type = 'V';
5941 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);