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;
1338 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1344 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1346 act = "seems very powerful.";
1349 o_ptr->name2 = EGO_EARTHQUAKES;
1350 o_ptr->pval = m_bonus(3, dun_level);
1355 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1357 act = "seems to be looking for humans!";
1360 o_ptr->name2 = EGO_SLAY_HUMAN;
1364 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1366 act = "covered with lightning!";
1369 o_ptr->name2 = EGO_BRAND_ELEC;
1373 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1375 act = "coated with acid!";
1378 o_ptr->name2 = EGO_BRAND_ACID;
1382 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1384 act = "seems to be looking for evil monsters!";
1387 o_ptr->name2 = EGO_SLAY_EVIL;
1391 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1393 act = "seems to be looking for demons!";
1396 o_ptr->name2 = EGO_SLAY_DEMON;
1400 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1402 act = "seems to be looking for undead!";
1405 o_ptr->name2 = EGO_SLAY_UNDEAD;
1409 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1411 act = "seems to be looking for animals!";
1414 o_ptr->name2 = EGO_SLAY_ANIMAL;
1418 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1420 act = "seems to be looking for dragons!";
1423 o_ptr->name2 = EGO_SLAY_DRAGON;
1427 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1429 act = "seems to be looking for troll!s";
1432 o_ptr->name2 = EGO_SLAY_TROLL;
1436 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1438 act = "seems to be looking for orcs!";
1441 o_ptr->name2 = EGO_SLAY_ORC;
1445 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1447 act = "seems to be looking for giants!";
1450 o_ptr->name2 = EGO_SLAY_GIANT;
1454 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1456 act = "seems very unstable now.";
1459 o_ptr->name2 = EGO_TRUMP;
1460 o_ptr->pval = randint1(2);
1464 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1466 act = "thirsts for blood!";
1469 o_ptr->name2 = EGO_VAMPIRIC;
1473 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1475 act = "is coated with poison.";
1478 o_ptr->name2 = EGO_BRAND_POIS;
1482 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1484 act = "is engulfed in raw Logrus!";
1487 o_ptr->name2 = EGO_CHAOTIC;
1491 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1493 act = "is covered in a fiery shield!";
1496 o_ptr->name2 = EGO_BRAND_FIRE;
1500 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1502 act = "glows deep, icy blue!";
1505 o_ptr->name2 = EGO_BRAND_COLD;
1510 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1512 msg_format("Your %s %s", o_name, act);
1516 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1518 o_ptr->discount = 99;
1519 chg_virtue(V_ENCHANT, 2);
1523 if (flush_failure) flush();
1526 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1528 msg_print("The Branding failed.");
1531 chg_virtue(V_ENCHANT, -2);
1538 * Vanish all walls in this floor
1540 static bool vanish_dungeon(void)
1544 feature_type *f_ptr;
1545 monster_type *m_ptr;
1548 /* Prevent vasishing of quest levels and town */
1549 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1554 /* Scan all normal grids */
1555 for (y = 1; y < cur_hgt - 1; y++)
1557 for (x = 1; x < cur_wid - 1; x++)
1559 c_ptr = &cave[y][x];
1561 /* Seeing true feature code (ignore mimic) */
1562 f_ptr = &f_info[c_ptr->feat];
1564 /* Lose room and vault */
1565 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1567 m_ptr = &m_list[c_ptr->m_idx];
1570 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1572 /* Reset sleep counter */
1573 (void)set_monster_csleep(c_ptr->m_idx, 0);
1575 /* Notice the "waking up" */
1578 /* Acquire the monster name */
1579 monster_desc(m_name, m_ptr, 0);
1581 /* Dump a message */
1583 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1585 msg_format("%^s wakes up.", m_name);
1590 /* Process all walls, doors and patterns */
1591 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1595 /* Special boundary walls -- Top and bottom */
1596 for (x = 0; x < cur_wid; x++)
1598 c_ptr = &cave[0][x];
1599 f_ptr = &f_info[c_ptr->mimic];
1601 /* Lose room and vault */
1602 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1604 /* Set boundary mimic if needed */
1605 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1607 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1609 /* Check for change to boring grid */
1610 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1613 c_ptr = &cave[cur_hgt - 1][x];
1614 f_ptr = &f_info[c_ptr->mimic];
1616 /* Lose room and vault */
1617 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1619 /* Set boundary mimic if needed */
1620 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1622 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1624 /* Check for change to boring grid */
1625 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1629 /* Special boundary walls -- Left and right */
1630 for (y = 1; y < (cur_hgt - 1); y++)
1632 c_ptr = &cave[y][0];
1633 f_ptr = &f_info[c_ptr->mimic];
1635 /* Lose room and vault */
1636 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1638 /* Set boundary mimic if needed */
1639 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1641 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1643 /* Check for change to boring grid */
1644 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1647 c_ptr = &cave[y][cur_wid - 1];
1648 f_ptr = &f_info[c_ptr->mimic];
1650 /* Lose room and vault */
1651 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1653 /* Set boundary mimic if needed */
1654 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1656 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1658 /* Check for change to boring grid */
1659 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1663 /* Mega-Hack -- Forget the view and lite */
1664 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1667 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1669 /* Update the monsters */
1670 p_ptr->update |= (PU_MONSTERS);
1673 p_ptr->redraw |= (PR_MAP);
1676 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1682 void call_the_(void)
1686 bool do_call = TRUE;
1688 for (i = 0; i < 9; i++)
1690 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1692 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1694 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1695 !permanent_wall(&f_info[c_ptr->feat]))
1705 for (i = 1; i < 10; i++)
1707 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1710 for (i = 1; i < 10; i++)
1712 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1715 for (i = 1; i < 10; i++)
1717 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1721 /* Prevent destruction of quest levels and town */
1722 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1725 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1727 msg_print("The ground trembles.");
1734 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1735 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1736 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1738 msg_format("You %s the %s too close to a wall!",
1739 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1740 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1741 msg_print("There is a loud explosion!");
1747 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1749 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1754 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1756 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1758 msg_print("The dungeon collapses...");
1763 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1765 msg_print("The dungeon trembles.");
1770 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1772 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1779 * Fetch an item (teleport it right underneath the caster)
1781 void fetch(int dir, int wgt, bool require_los)
1786 char o_name[MAX_NLEN];
1788 /* Check to see if an object is already there */
1789 if (cave[py][px].o_idx)
1792 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1794 msg_print("You can't fetch when you're already standing on something.");
1801 if (dir == 5 && target_okay())
1806 if (distance(py, px, ty, tx) > MAX_RANGE)
1809 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1811 msg_print("You can't fetch something that far away!");
1817 c_ptr = &cave[ty][tx];
1819 /* We need an item to fetch */
1823 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1825 msg_print("There is no object at this place.");
1831 /* No fetching from vault */
1832 if (c_ptr->info & CAVE_ICKY)
1835 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1837 msg_print("The item slips from your control.");
1843 /* We need to see the item */
1846 if (!player_has_los_bold(ty, tx))
1849 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1851 msg_print("You have no direct line of sight to that location.");
1856 else if (!projectable(py, px, ty, tx))
1859 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1861 msg_print("You have no direct line of sight to that location.");
1870 /* Use a direction */
1871 ty = py; /* Where to drop the item */
1878 c_ptr = &cave[ty][tx];
1880 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1881 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1883 while (!c_ptr->o_idx);
1886 o_ptr = &o_list[c_ptr->o_idx];
1888 if (o_ptr->weight > wgt)
1890 /* Too heavy to 'fetch' */
1892 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1894 msg_print("The object is too heavy.");
1901 c_ptr->o_idx = o_ptr->next_o_idx;
1902 cave[py][px].o_idx = i; /* 'move' it */
1903 o_ptr->next_o_idx = 0;
1904 o_ptr->iy = (byte)py;
1905 o_ptr->ix = (byte)px;
1907 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1909 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1911 msg_format("%^s flies through the air to your feet.", o_name);
1916 p_ptr->redraw |= PR_MAP;
1920 void alter_reality(void)
1922 /* Ironman option */
1923 if (p_ptr->inside_arena || ironman_downward)
1926 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1928 msg_print("Nothing happens.");
1933 if (!p_ptr->alter_reality)
1935 int turns = randint0(21) + 15;
1937 p_ptr->alter_reality = turns;
1939 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1941 msg_print("The view around you begins to change...");
1944 p_ptr->redraw |= (PR_STATUS);
1948 p_ptr->alter_reality = 0;
1950 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1952 msg_print("The view around you got back...");
1955 p_ptr->redraw |= (PR_STATUS);
1962 * Leave a "glyph of warding" which prevents monster movement
1964 bool warding_glyph(void)
1967 if (!cave_clean_bold(py, px))
1970 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1972 msg_print("The object resists the spell.");
1978 /* Create a glyph */
1979 cave[py][px].info |= CAVE_OBJECT;
1980 cave[py][px].mimic = FEAT_GLYPH;
1991 bool place_mirror(void)
1994 if (!cave_clean_bold(py, px))
1997 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1999 msg_print("The object resists the spell.");
2005 /* Create a mirror */
2006 cave[py][px].info |= CAVE_OBJECT;
2007 cave[py][px].mimic = FEAT_MIRROR;
2009 /* Turn on the light */
2010 cave[py][px].info |= CAVE_GLOW;
2018 update_local_illumination(py, px);
2025 * Leave an "explosive rune" which prevents monster movement
2027 bool explosive_rune(void)
2030 if (!cave_clean_bold(py, px))
2033 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2035 msg_print("The object resists the spell.");
2041 /* Create a glyph */
2042 cave[py][px].info |= CAVE_OBJECT;
2043 cave[py][px].mimic = FEAT_MINOR_GLYPH;
2056 * Identify everything being carried.
2057 * Done by a potion of "self knowledge".
2059 void identify_pack(void)
2063 /* Simply identify and know every item */
2064 for (i = 0; i < INVEN_TOTAL; i++)
2066 object_type *o_ptr = &inventory[i];
2068 /* Skip non-objects */
2069 if (!o_ptr->k_idx) continue;
2072 identify_item(o_ptr);
2074 /* Auto-inscription */
2075 autopick_alter_item(i, FALSE);
2081 * Used by the "enchant" function (chance of failure)
2082 * (modified for Zangband, we need better stuff there...) -- TY
2084 static int enchant_table[16] =
2086 0, 10, 50, 100, 200,
2087 300, 400, 500, 650, 800,
2088 950, 987, 993, 995, 998,
2094 * Removes curses from items in inventory
2096 * Note that Items which are "Perma-Cursed" (The One Ring,
2097 * The Crown of Morgoth) can NEVER be uncursed.
2099 * Note that if "all" is FALSE, then Items which are
2100 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2101 * will not be uncursed.
2103 static int remove_curse_aux(int all)
2107 /* Attempt to uncurse items being worn */
2108 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2110 object_type *o_ptr = &inventory[i];
2112 /* Skip non-objects */
2113 if (!o_ptr->k_idx) continue;
2115 /* Uncursed already */
2116 if (!object_is_cursed(o_ptr)) continue;
2118 /* Heavily Cursed Items need a special spell */
2119 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2121 /* Perma-Cursed Items can NEVER be uncursed */
2122 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2125 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2130 o_ptr->curse_flags = 0L;
2132 /* Hack -- Assume felt */
2133 o_ptr->ident |= (IDENT_SENSE);
2136 o_ptr->feeling = FEEL_NONE;
2138 /* Recalculate the bonuses */
2139 p_ptr->update |= (PU_BONUS);
2142 p_ptr->window |= (PW_EQUIP);
2144 /* Count the uncursings */
2148 /* Return "something uncursed" */
2154 * Remove most curses
2156 bool remove_curse(void)
2158 return (remove_curse_aux(FALSE));
2164 bool remove_all_curse(void)
2166 return (remove_curse_aux(TRUE));
2171 * Turns an object into gold, gain some of its value in a shop
2180 char o_name[MAX_NLEN];
2181 char out_val[MAX_NLEN+40];
2185 /* Hack -- force destruction */
2186 if (command_arg > 0) force = TRUE;
2190 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2191 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2193 q = "Turn which item to gold? ";
2194 s = "You have nothing to turn to gold.";
2197 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2199 /* Get the item (in the pack) */
2202 o_ptr = &inventory[item];
2205 /* Get the item (on the floor) */
2208 o_ptr = &o_list[0 - item];
2212 /* See how many items */
2213 if (o_ptr->number > 1)
2215 /* Get a quantity */
2216 amt = get_quantity(NULL, o_ptr->number);
2218 /* Allow user abort */
2219 if (amt <= 0) return FALSE;
2223 /* Describe the object */
2224 old_number = o_ptr->number;
2225 o_ptr->number = amt;
2226 object_desc(o_name, o_ptr, 0);
2227 o_ptr->number = old_number;
2229 /* Verify unless quantity given */
2232 if (confirm_destroy || (object_value(o_ptr) > 0))
2234 /* Make a verification */
2236 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2238 sprintf(out_val, "Really turn %s to gold? ", o_name);
2241 if (!get_check(out_val)) return FALSE;
2245 /* Artifacts cannot be destroyed */
2246 if (!can_player_destroy_object(o_ptr))
2250 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2252 msg_format("You fail to turn %s to gold!", o_name);
2259 price = object_value_real(o_ptr);
2265 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2267 msg_format("You turn %s to fool's gold.", o_name);
2275 if (amt > 1) price *= amt;
2277 if (price > 30000) price = 30000;
2279 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2281 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2287 p_ptr->redraw |= (PR_GOLD);
2290 p_ptr->window |= (PW_PLAYER);
2294 /* Eliminate the item (from the pack) */
2297 inven_item_increase(item, -amt);
2298 inven_item_describe(item);
2299 inven_item_optimize(item);
2302 /* Eliminate the item (from the floor) */
2305 floor_item_increase(0 - item, -amt);
2306 floor_item_describe(0 - item);
2307 floor_item_optimize(0 - item);
2315 * Break the curse of an item
2317 static void break_curse(object_type *o_ptr)
2319 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2322 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2324 msg_print("The curse is broken!");
2327 o_ptr->curse_flags = 0L;
2329 o_ptr->ident |= (IDENT_SENSE);
2331 o_ptr->feeling = FEEL_NONE;
2337 * Enchants a plus onto an item. -RAK-
2339 * Revamped! Now takes item pointer, number of times to try enchanting,
2340 * and a flag of what to try enchanting. Artifacts resist enchantment
2341 * some of the time, and successful enchantment to at least +0 might
2342 * break a curse on the item. -CFT-
2344 * Note that an item can technically be enchanted all the way to +15 if
2345 * you wait a very, very, long time. Going from +9 to +10 only works
2346 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2348 * Note that this function can now be used on "piles" of items, and
2349 * the larger the pile, the lower the chance of success.
2351 bool enchant(object_type *o_ptr, int n, int eflag)
2353 int i, chance, prob;
2355 bool a = object_is_artifact(o_ptr);
2356 bool force = (eflag & ENCH_FORCE);
2359 /* Large piles resist enchantment */
2360 prob = o_ptr->number * 100;
2362 /* Missiles are easy to enchant */
2363 if ((o_ptr->tval == TV_BOLT) ||
2364 (o_ptr->tval == TV_ARROW) ||
2365 (o_ptr->tval == TV_SHOT))
2371 for (i = 0; i < n; i++)
2373 /* Hack -- Roll for pile resistance */
2374 if (!force && randint0(prob) >= 100) continue;
2376 /* Enchant to hit */
2377 if (eflag & ENCH_TOHIT)
2379 if (o_ptr->to_h < 0) chance = 0;
2380 else if (o_ptr->to_h > 15) chance = 1000;
2381 else chance = enchant_table[o_ptr->to_h];
2383 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2388 /* only when you get it above -1 -CFT */
2389 if (o_ptr->to_h >= 0)
2394 /* Enchant to damage */
2395 if (eflag & ENCH_TODAM)
2397 if (o_ptr->to_d < 0) chance = 0;
2398 else if (o_ptr->to_d > 15) chance = 1000;
2399 else chance = enchant_table[o_ptr->to_d];
2401 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2406 /* only when you get it above -1 -CFT */
2407 if (o_ptr->to_d >= 0)
2412 /* Enchant to armor class */
2413 if (eflag & ENCH_TOAC)
2415 if (o_ptr->to_a < 0) chance = 0;
2416 else if (o_ptr->to_a > 15) chance = 1000;
2417 else chance = enchant_table[o_ptr->to_a];
2419 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2424 /* only when you get it above -1 -CFT */
2425 if (o_ptr->to_a >= 0)
2432 if (!res) return (FALSE);
2434 /* Recalculate bonuses */
2435 p_ptr->update |= (PU_BONUS);
2437 /* Combine / Reorder the pack (later) */
2438 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2441 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2452 * Enchant an item (in the inventory or on the floor)
2453 * Note that "num_ac" requires armour, else weapon
2454 * Returns TRUE if attempted, FALSE if cancelled
2456 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2461 char o_name[MAX_NLEN];
2465 /* Assume enchant weapon */
2466 item_tester_hook = object_allow_enchant_weapon;
2467 item_tester_no_ryoute = TRUE;
2469 /* Enchant armor if requested */
2470 if (num_ac) item_tester_hook = object_is_armour;
2474 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2475 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2477 q = "Enchant which item? ";
2478 s = "You have nothing to enchant.";
2481 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2483 /* Get the item (in the pack) */
2486 o_ptr = &inventory[item];
2489 /* Get the item (on the floor) */
2492 o_ptr = &o_list[0 - item];
2497 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2501 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2504 msg_format("%s %s glow%s brightly!",
2505 ((item >= 0) ? "Your" : "The"), o_name,
2506 ((o_ptr->number > 1) ? "" : "s"));
2511 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2512 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2513 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2519 if (flush_failure) flush();
2523 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2525 msg_print("The enchantment failed.");
2528 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2531 chg_virtue(V_ENCHANT, 1);
2535 /* Something happened */
2541 * Check if an object is nameless weapon or armour
2543 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2545 /* Require weapon or armour */
2546 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2548 /* Require nameless object if the object is well known */
2549 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2556 bool artifact_scroll(void)
2561 char o_name[MAX_NLEN];
2565 item_tester_no_ryoute = TRUE;
2567 /* Enchant weapon/armour */
2568 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2572 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2573 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2575 q = "Enchant which item? ";
2576 s = "You have nothing to enchant.";
2579 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2581 /* Get the item (in the pack) */
2584 o_ptr = &inventory[item];
2587 /* Get the item (on the floor) */
2590 o_ptr = &o_list[0 - item];
2595 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2599 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2601 msg_format("%s %s radiate%s a blinding light!",
2602 ((item >= 0) ? "Your" : "The"), o_name,
2603 ((o_ptr->number > 1) ? "" : "s"));
2606 if (object_is_artifact(o_ptr))
2609 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2611 msg_format("The %s %s already %s!",
2612 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2613 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2619 else if (object_is_ego(o_ptr))
2622 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2624 msg_format("The %s %s already %s!",
2625 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2626 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2632 else if (o_ptr->xtra3)
2635 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2637 msg_format("The %s %s already %s!",
2638 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2639 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2645 if (o_ptr->number > 1)
2648 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2649 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2651 msg_print("Not enough enough energy to enchant more than one object!");
2652 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2657 inven_item_increase(item, 1-(o_ptr->number));
2661 floor_item_increase(0-item, 1-(o_ptr->number));
2664 okay = create_artifact(o_ptr, TRUE);
2671 if (flush_failure) flush();
2675 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2677 msg_print("The enchantment failed.");
2680 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2683 chg_virtue(V_ENCHANT, 1);
2687 /* Something happened */
2693 * Identify an object
2695 bool identify_item(object_type *o_ptr)
2697 bool old_known = FALSE;
2698 char o_name[MAX_NLEN];
2701 object_desc(o_name, o_ptr, 0);
2703 if (o_ptr->ident & IDENT_KNOWN)
2706 if (!(o_ptr->ident & (IDENT_MENTAL)))
2708 if (object_is_artifact(o_ptr) || one_in_(5))
2709 chg_virtue(V_KNOWLEDGE, 1);
2712 /* Identify it fully */
2713 object_aware(o_ptr);
2714 object_known(o_ptr);
2716 /* Recalculate bonuses */
2717 p_ptr->update |= (PU_BONUS);
2719 /* Combine / Reorder the pack (later) */
2720 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2723 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2725 strcpy(record_o_name, o_name);
2729 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2731 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2732 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2733 if(record_rand_art && !old_known && o_ptr->art_name)
2734 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2740 static bool item_tester_hook_identify(object_type *o_ptr)
2742 return (bool)!object_is_known(o_ptr);
2745 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2747 if (object_is_known(o_ptr))
2749 return object_is_weapon_armour_ammo(o_ptr);
2753 * Identify an object in the inventory (or on the floor)
2754 * This routine does *not* automatically combine objects.
2755 * Returns TRUE if something was identified, else FALSE.
2757 bool ident_spell(bool only_equip)
2761 char o_name[MAX_NLEN];
2765 item_tester_no_ryoute = TRUE;
2768 item_tester_hook = item_tester_hook_identify_weapon_armour;
2770 item_tester_hook = item_tester_hook_identify;
2772 if (!can_get_item())
2776 item_tester_hook = object_is_weapon_armour_ammo;
2780 item_tester_hook = NULL;
2786 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2787 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2789 q = "Identify which item? ";
2790 s = "You have nothing to identify.";
2793 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2795 /* Get the item (in the pack) */
2798 o_ptr = &inventory[item];
2801 /* Get the item (on the floor) */
2804 o_ptr = &o_list[0 - item];
2808 old_known = identify_item(o_ptr);
2811 object_desc(o_name, o_ptr, 0);
2814 if (item >= INVEN_RARM)
2817 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2819 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2825 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2827 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2833 msg_format("¾²¾å: %s¡£", o_name);
2835 msg_format("On the ground: %s.", o_name);
2839 /* Auto-inscription/destroy */
2840 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2842 /* Something happened */
2848 * Mundanify an object in the inventory (or on the floor)
2849 * This routine does *not* automatically combine objects.
2850 * Returns TRUE if something was mundanified, else FALSE.
2852 bool mundane_spell(bool only_equip)
2858 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2859 item_tester_no_ryoute = TRUE;
2863 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2864 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2866 q = "Use which item? ";
2867 s = "You have nothing you can use.";
2870 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2872 /* Get the item (in the pack) */
2875 o_ptr = &inventory[item];
2878 /* Get the item (on the floor) */
2881 o_ptr = &o_list[0 - item];
2886 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2888 msg_print("There is a bright flash of light!");
2891 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2892 byte ix = o_ptr->ix; /* X-position on map, or zero */
2893 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2894 byte marked = o_ptr->marked; /* Object is marked */
2895 s16b weight = o_ptr->number * o_ptr->weight;
2896 u16b inscription = o_ptr->inscription;
2899 object_prep(o_ptr, o_ptr->k_idx);
2903 o_ptr->next_o_idx = next_o_idx;
2904 o_ptr->marked = marked;
2905 o_ptr->inscription = inscription;
2906 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2910 /* Something happened */
2916 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2918 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2921 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2923 if (!item_tester_hook_identify_fully(o_ptr))
2925 return object_is_weapon_armour_ammo(o_ptr);
2929 * Fully "identify" an object in the inventory -BEN-
2930 * This routine returns TRUE if an item was identified.
2932 bool identify_fully(bool only_equip)
2936 char o_name[MAX_NLEN];
2940 item_tester_no_ryoute = TRUE;
2942 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2944 item_tester_hook = item_tester_hook_identify_fully;
2946 if (!can_get_item())
2949 item_tester_hook = object_is_weapon_armour_ammo;
2951 item_tester_hook = NULL;
2956 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2957 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2959 q = "Identify which item? ";
2960 s = "You have nothing to identify.";
2963 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2965 /* Get the item (in the pack) */
2968 o_ptr = &inventory[item];
2971 /* Get the item (on the floor) */
2974 o_ptr = &o_list[0 - item];
2978 old_known = identify_item(o_ptr);
2980 /* Mark the item as fully known */
2981 o_ptr->ident |= (IDENT_MENTAL);
2987 object_desc(o_name, o_ptr, 0);
2990 if (item >= INVEN_RARM)
2993 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2995 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3003 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3005 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3011 msg_format("¾²¾å: %s¡£", o_name);
3013 msg_format("On the ground: %s.", o_name);
3017 /* Describe it fully */
3018 (void)screen_object(o_ptr, TRUE);
3020 /* Auto-inscription/destroy */
3021 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3031 * Hook for "get_item()". Determine if something is rechargable.
3033 bool item_tester_hook_recharge(object_type *o_ptr)
3035 /* Recharge staffs */
3036 if (o_ptr->tval == TV_STAFF) return (TRUE);
3038 /* Recharge wands */
3039 if (o_ptr->tval == TV_WAND) return (TRUE);
3041 /* Hack -- Recharge rods */
3042 if (o_ptr->tval == TV_ROD) return (TRUE);
3050 * Recharge a wand/staff/rod from the pack or on the floor.
3051 * This function has been rewritten in Oangband and ZAngband.
3053 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3054 * Chaos -- Arcane Binding --> recharge(90)
3056 * Scroll of recharging --> recharge(130)
3057 * Artifact activation/Thingol --> recharge(130)
3059 * It is harder to recharge high level, and highly charged wands,
3060 * staffs, and rods. The more wands in a stack, the more easily and
3061 * strongly they recharge. Staffs, however, each get fewer charges if
3064 * XXX XXX XXX Beware of "sliding index errors".
3066 bool recharge(int power)
3069 int recharge_strength, recharge_amount;
3078 char o_name[MAX_NLEN];
3080 /* Only accept legal items */
3081 item_tester_hook = item_tester_hook_recharge;
3085 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3086 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3088 q = "Recharge which item? ";
3089 s = "You have nothing to recharge.";
3092 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3094 /* Get the item (in the pack) */
3097 o_ptr = &inventory[item];
3100 /* Get the item (on the floor) */
3103 o_ptr = &o_list[0 - item];
3106 /* Get the object kind. */
3107 k_ptr = &k_info[o_ptr->k_idx];
3109 /* Extract the object "level" */
3110 lev = k_info[o_ptr->k_idx].level;
3113 /* Recharge a rod */
3114 if (o_ptr->tval == TV_ROD)
3116 /* Extract a recharge strength by comparing object level to power. */
3117 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3121 if (one_in_(recharge_strength))
3123 /* Activate the failure code. */
3130 /* Recharge amount */
3131 recharge_amount = (power * damroll(3, 2));
3133 /* Recharge by that amount */
3134 if (o_ptr->timeout > recharge_amount)
3135 o_ptr->timeout -= recharge_amount;
3142 /* Recharge wand/staff */
3145 /* Extract a recharge strength by comparing object level to power.
3146 * Divide up a stack of wands' charges to calculate charge penalty.
3148 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3149 recharge_strength = (100 + power - lev -
3150 (8 * o_ptr->pval / o_ptr->number)) / 15;
3152 /* All staffs, unstacked wands. */
3153 else recharge_strength = (100 + power - lev -
3154 (8 * o_ptr->pval)) / 15;
3157 if (recharge_strength < 0) recharge_strength = 0;
3160 if (one_in_(recharge_strength))
3162 /* Activate the failure code. */
3166 /* If the spell didn't backfire, recharge the wand or staff. */
3169 /* Recharge based on the standard number of charges. */
3170 recharge_amount = randint1(1 + k_ptr->pval / 2);
3172 /* Multiple wands in a stack increase recharging somewhat. */
3173 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3176 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3177 if (recharge_amount < 1) recharge_amount = 1;
3178 if (recharge_amount > 12) recharge_amount = 12;
3181 /* But each staff in a stack gets fewer additional charges,
3182 * although always at least one.
3184 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3186 recharge_amount /= o_ptr->number;
3187 if (recharge_amount < 1) recharge_amount = 1;
3190 /* Recharge the wand or staff. */
3191 o_ptr->pval += recharge_amount;
3194 /* Hack -- we no longer "know" the item */
3195 o_ptr->ident &= ~(IDENT_KNOWN);
3197 /* Hack -- we no longer think the item is empty */
3198 o_ptr->ident &= ~(IDENT_EMPTY);
3203 /* Inflict the penalties for failing a recharge. */
3206 /* Artifacts are never destroyed. */
3207 if (object_is_fixed_artifact(o_ptr))
3209 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3211 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3213 msg_format("The recharging backfires - %s is completely drained!", o_name);
3217 /* Artifact rods. */
3218 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3219 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3221 /* Artifact wands and staffs. */
3222 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3227 /* Get the object description */
3228 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3230 /*** Determine Seriousness of Failure ***/
3232 /* Mages recharge objects more safely. */
3233 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)
3235 /* 10% chance to blow up one rod, otherwise draining. */
3236 if (o_ptr->tval == TV_ROD)
3238 if (one_in_(10)) fail_type = 2;
3241 /* 75% chance to blow up one wand, otherwise draining. */
3242 else if (o_ptr->tval == TV_WAND)
3244 if (!one_in_(3)) fail_type = 2;
3247 /* 50% chance to blow up one staff, otherwise no effect. */
3248 else if (o_ptr->tval == TV_STAFF)
3250 if (one_in_(2)) fail_type = 2;
3255 /* All other classes get no special favors. */
3258 /* 33% chance to blow up one rod, otherwise draining. */
3259 if (o_ptr->tval == TV_ROD)
3261 if (one_in_(3)) fail_type = 2;
3264 /* 20% chance of the entire stack, else destroy one wand. */
3265 else if (o_ptr->tval == TV_WAND)
3267 if (one_in_(5)) fail_type = 3;
3270 /* Blow up one staff. */
3271 else if (o_ptr->tval == TV_STAFF)
3277 /*** Apply draining and destruction. ***/
3279 /* Drain object or stack of objects. */
3282 if (o_ptr->tval == TV_ROD)
3285 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3287 msg_print("The recharge backfires, draining the rod further!");
3290 if (o_ptr->timeout < 10000)
3291 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3293 else if (o_ptr->tval == TV_WAND)
3296 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3298 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3303 /* Staffs aren't drained. */
3306 /* Destroy an object or one in a stack of objects. */
3309 if (o_ptr->number > 1)
3311 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3313 msg_format("Wild magic consumes one of your %s!", o_name);
3318 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3320 msg_format("Wild magic consumes your %s!", o_name);
3324 /* Reduce rod stack maximum timeout, drain wands. */
3325 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3326 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3328 /* Reduce and describe inventory */
3331 inven_item_increase(item, -1);
3332 inven_item_describe(item);
3333 inven_item_optimize(item);
3336 /* Reduce and describe floor item */
3339 floor_item_increase(0 - item, -1);
3340 floor_item_describe(0 - item);
3341 floor_item_optimize(0 - item);
3345 /* Destroy all members of a stack of objects. */
3348 if (o_ptr->number > 1)
3350 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3352 msg_format("Wild magic consumes all your %s!", o_name);
3357 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3359 msg_format("Wild magic consumes your %s!", o_name);
3364 /* Reduce and describe inventory */
3367 inven_item_increase(item, -999);
3368 inven_item_describe(item);
3369 inven_item_optimize(item);
3372 /* Reduce and describe floor item */
3375 floor_item_increase(0 - item, -999);
3376 floor_item_describe(0 - item);
3377 floor_item_optimize(0 - item);
3383 /* Combine / Reorder the pack (later) */
3384 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3387 p_ptr->window |= (PW_INVEN);
3389 /* Something was done */
3397 bool bless_weapon(void)
3401 u32b flgs[TR_FLAG_SIZE];
3402 char o_name[MAX_NLEN];
3405 item_tester_no_ryoute = TRUE;
3407 /* Bless only weapons */
3408 item_tester_hook = object_is_weapon;
3412 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3413 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3415 q = "Bless which weapon? ";
3416 s = "You have weapon to bless.";
3419 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3422 /* Get the item (in the pack) */
3425 o_ptr = &inventory[item];
3428 /* Get the item (on the floor) */
3431 o_ptr = &o_list[0 - item];
3436 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3438 /* Extract the flags */
3439 object_flags(o_ptr, flgs);
3441 if (object_is_cursed(o_ptr))
3443 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3444 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3447 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3450 msg_format("The black aura on %s %s disrupts the blessing!",
3451 ((item >= 0) ? "your" : "the"), o_name);
3458 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3461 msg_format("A malignant aura leaves %s %s.",
3462 ((item >= 0) ? "your" : "the"), o_name);
3467 o_ptr->curse_flags = 0L;
3469 /* Hack -- Assume felt */
3470 o_ptr->ident |= (IDENT_SENSE);
3473 o_ptr->feeling = FEEL_NONE;
3475 /* Recalculate the bonuses */
3476 p_ptr->update |= (PU_BONUS);
3479 p_ptr->window |= (PW_EQUIP);
3483 * Next, we try to bless it. Artifacts have a 1/3 chance of
3484 * being blessed, otherwise, the operation simply disenchants
3485 * them, godly power negating the magic. Ok, the explanation
3486 * is silly, but otherwise priests would always bless every
3487 * artifact weapon they find. Ego weapons and normal weapons
3488 * can be blessed automatically.
3490 if (have_flag(flgs, TR_BLESSED))
3493 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3496 msg_format("%s %s %s blessed already.",
3497 ((item >= 0) ? "Your" : "The"), o_name,
3498 ((o_ptr->number > 1) ? "were" : "was"));
3504 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3508 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3511 msg_format("%s %s shine%s!",
3512 ((item >= 0) ? "Your" : "The"), o_name,
3513 ((o_ptr->number > 1) ? "" : "s"));
3516 add_flag(o_ptr->art_flags, TR_BLESSED);
3517 o_ptr->discount = 99;
3521 bool dis_happened = FALSE;
3524 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3526 msg_print("The weapon resists your blessing!");
3530 /* Disenchant tohit */
3531 if (o_ptr->to_h > 0)
3534 dis_happened = TRUE;
3537 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3539 /* Disenchant todam */
3540 if (o_ptr->to_d > 0)
3543 dis_happened = TRUE;
3546 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3548 /* Disenchant toac */
3549 if (o_ptr->to_a > 0)
3552 dis_happened = TRUE;
3555 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3560 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3562 msg_print("There is a static feeling in the air...");
3566 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3569 msg_format("%s %s %s disenchanted!",
3570 ((item >= 0) ? "Your" : "The"), o_name,
3571 ((o_ptr->number > 1) ? "were" : "was"));
3577 /* Recalculate bonuses */
3578 p_ptr->update |= (PU_BONUS);
3581 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3592 bool pulish_shield(void)
3596 u32b flgs[TR_FLAG_SIZE];
3597 char o_name[MAX_NLEN];
3600 item_tester_no_ryoute = TRUE;
3601 /* Assume enchant weapon */
3602 item_tester_tval = TV_SHIELD;
3606 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3607 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3609 q = "Pulish which weapon? ";
3610 s = "You have weapon to pulish.";
3613 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3616 /* Get the item (in the pack) */
3619 o_ptr = &inventory[item];
3622 /* Get the item (on the floor) */
3625 o_ptr = &o_list[0 - item];
3630 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3632 /* Extract the flags */
3633 object_flags(o_ptr, flgs);
3635 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3636 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3639 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3641 msg_format("%s %s shine%s!",
3642 ((item >= 0) ? "Your" : "The"), o_name,
3643 ((o_ptr->number > 1) ? "" : "s"));
3645 o_ptr->name2 = EGO_REFLECTION;
3646 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3648 o_ptr->discount = 99;
3649 chg_virtue(V_ENCHANT, 2);
3655 if (flush_failure) flush();
3658 msg_print("¼ºÇÔ¤·¤¿¡£");
3660 msg_print("Failed.");
3663 chg_virtue(V_ENCHANT, -2);
3672 * Potions "smash open" and cause an area effect when
3673 * (1) they are shattered while in the player's inventory,
3674 * due to cold (etc) attacks;
3675 * (2) they are thrown at a monster, or obstacle;
3676 * (3) they are shattered by a "cold ball" or other such spell
3677 * while lying on the floor.
3680 * who --- who caused the potion to shatter (0=player)
3681 * potions that smash on the floor are assumed to
3682 * be caused by no-one (who = 1), as are those that
3683 * shatter inside the player inventory.
3684 * (Not anymore -- I changed this; TY)
3685 * y, x --- coordinates of the potion (or player if
3686 * the potion was in her inventory);
3687 * o_ptr --- pointer to the potion object.
3689 bool potion_smash_effect(int who, int y, int x, int k_idx)
3696 object_kind *k_ptr = &k_info[k_idx];
3698 switch (k_ptr->sval)
3700 case SV_POTION_SALT_WATER:
3701 case SV_POTION_SLIME_MOLD:
3702 case SV_POTION_LOSE_MEMORIES:
3703 case SV_POTION_DEC_STR:
3704 case SV_POTION_DEC_INT:
3705 case SV_POTION_DEC_WIS:
3706 case SV_POTION_DEC_DEX:
3707 case SV_POTION_DEC_CON:
3708 case SV_POTION_DEC_CHR:
3709 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3710 case SV_POTION_APPLE_JUICE:
3713 case SV_POTION_INFRAVISION:
3714 case SV_POTION_DETECT_INVIS:
3715 case SV_POTION_SLOW_POISON:
3716 case SV_POTION_CURE_POISON:
3717 case SV_POTION_BOLDNESS:
3718 case SV_POTION_RESIST_HEAT:
3719 case SV_POTION_RESIST_COLD:
3720 case SV_POTION_HEROISM:
3721 case SV_POTION_BESERK_STRENGTH:
3722 case SV_POTION_RES_STR:
3723 case SV_POTION_RES_INT:
3724 case SV_POTION_RES_WIS:
3725 case SV_POTION_RES_DEX:
3726 case SV_POTION_RES_CON:
3727 case SV_POTION_RES_CHR:
3728 case SV_POTION_INC_STR:
3729 case SV_POTION_INC_INT:
3730 case SV_POTION_INC_WIS:
3731 case SV_POTION_INC_DEX:
3732 case SV_POTION_INC_CON:
3733 case SV_POTION_INC_CHR:
3734 case SV_POTION_AUGMENTATION:
3735 case SV_POTION_ENLIGHTENMENT:
3736 case SV_POTION_STAR_ENLIGHTENMENT:
3737 case SV_POTION_SELF_KNOWLEDGE:
3738 case SV_POTION_EXPERIENCE:
3739 case SV_POTION_RESISTANCE:
3740 case SV_POTION_INVULNERABILITY:
3741 case SV_POTION_NEW_LIFE:
3742 /* All of the above potions have no effect when shattered */
3744 case SV_POTION_SLOWNESS:
3749 case SV_POTION_POISON:
3754 case SV_POTION_BLINDNESS:
3758 case SV_POTION_CONFUSION: /* Booze */
3762 case SV_POTION_SLEEP:
3766 case SV_POTION_RUINATION:
3767 case SV_POTION_DETONATIONS:
3769 dam = damroll(25, 25);
3772 case SV_POTION_DEATH:
3773 dt = GF_DEATH_RAY; /* !! */
3774 dam = k_ptr->level * 10;
3778 case SV_POTION_SPEED:
3781 case SV_POTION_CURE_LIGHT:
3783 dam = damroll(2, 3);
3785 case SV_POTION_CURE_SERIOUS:
3787 dam = damroll(4, 3);
3789 case SV_POTION_CURE_CRITICAL:
3790 case SV_POTION_CURING:
3792 dam = damroll(6, 3);
3794 case SV_POTION_HEALING:
3796 dam = damroll(10, 10);
3798 case SV_POTION_RESTORE_EXP:
3803 case SV_POTION_LIFE:
3805 dam = damroll(50, 50);
3808 case SV_POTION_STAR_HEALING:
3810 dam = damroll(50, 50);
3813 case SV_POTION_RESTORE_MANA: /* MANA */
3815 dam = damroll(10, 10);
3822 (void)project(who, radius, y, x, dam, dt,
3823 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3825 /* XXX those potions that explode need to become "known" */
3831 * Hack -- Display all known spells in a window
3833 * XXX XXX XXX Need to analyze size of the window.
3835 * XXX XXX XXX Need more color coding.
3837 void display_spell_list(void)
3850 /* They have too many spells to list */
3851 if (p_ptr->pclass == CLASS_SORCERER) return;
3852 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3854 /* mind.c type classes */
3855 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3856 (p_ptr->pclass == CLASS_BERSERKER) ||
3857 (p_ptr->pclass == CLASS_NINJA) ||
3858 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3859 (p_ptr->pclass == CLASS_FORCETRAINER))
3865 int plev = p_ptr->lev;
3871 bool use_hp = FALSE;
3873 /* Display a list of spells */
3876 put_str("̾Á°", y, x + 5);
3877 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3879 put_str("Name", y, x + 5);
3880 put_str("Lv Mana Fail Info", y, x + 35);
3883 switch(p_ptr->pclass)
3885 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3886 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3887 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3888 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3889 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3890 default: use_mind = 0;break;
3893 /* Dump the spells */
3894 for (i = 0; i < MAX_MIND_POWERS; i++)
3896 byte a = TERM_WHITE;
3898 /* Access the available spell */
3899 spell = mind_powers[use_mind].info[i];
3900 if (spell.min_lev > plev) break;
3902 /* Get the failure rate */
3903 chance = spell.fail;
3905 /* Reduce failure rate by "effective" level adjustment */
3906 chance -= 3 * (p_ptr->lev - spell.min_lev);
3908 /* Reduce failure rate by INT/WIS adjustment */
3909 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3913 /* Not enough mana to cast */
3914 if (spell.mana_cost > p_ptr->csp)
3916 chance += 5 * (spell.mana_cost - p_ptr->csp);
3922 /* Not enough hp to cast */
3923 if (spell.mana_cost > p_ptr->chp)
3930 /* Extract the minimum failure rate */
3931 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3933 /* Minimum failure rate */
3934 if (chance < minfail) chance = minfail;
3936 /* Stunning makes spells harder */
3937 if (p_ptr->stun > 50) chance += 25;
3938 else if (p_ptr->stun) chance += 15;
3940 /* Always a 5 percent chance of working */
3941 if (chance > 95) chance = 95;
3944 mindcraft_info(comment, use_mind, i);
3946 /* Dump the spell */
3947 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3949 spell.min_lev, spell.mana_cost, chance, comment);
3951 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3956 /* Cannot read spellbooks */
3957 if (REALM_NONE == p_ptr->realm1) return;
3959 /* Normal spellcaster with books */
3962 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3966 /* Reset vertical */
3969 /* Vertical location */
3970 y = (j < 3) ? 0 : (m[j - 3] + 2);
3972 /* Horizontal location */
3976 for (i = 0; i < 32; i++)
3978 byte a = TERM_WHITE;
3980 /* Access the spell */
3981 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3983 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3987 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3990 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3993 if (s_ptr->slevel >= 99)
3997 strcpy(name, "(ȽÆÉÉÔǽ)");
3999 strcpy(name, "(illegible)");
4009 ((p_ptr->spell_forgotten1 & (1L << i))) :
4010 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4017 else if (!((j < 1) ?
4018 (p_ptr->spell_learned1 & (1L << i)) :
4019 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4026 else if (!((j < 1) ?
4027 (p_ptr->spell_worked1 & (1L << i)) :
4028 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4034 /* Dump the spell --(-- */
4035 sprintf(out_val, "%c/%c) %-20.20s",
4036 I2A(n / 8), I2A(n % 8), name);
4041 /* Dump onto the window */
4042 Term_putstr(x, m[j], -1, a, out_val);
4052 * Returns experience of a spell
4054 s16b experience_of_spell(int spell, int use_realm)
4056 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4057 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4058 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4059 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4065 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4067 int mod_need_mana(int need_mana, int spell, int realm)
4069 #define MANA_CONST 2400
4071 #define DEC_MANA_DIV 3
4074 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4077 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4078 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4080 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4081 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4082 need_mana /= MANA_CONST * MANA_DIV;
4083 if (need_mana < 1) need_mana = 1;
4086 /* Non-realm magic */
4089 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4101 * Modify spell fail rate
4102 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4104 int mod_spell_chance_1(int chance)
4106 chance += p_ptr->to_m_chance;
4108 if (p_ptr->heavy_spell) chance += 20;
4110 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4111 else if (p_ptr->easy_spell) chance -= 3;
4112 else if (p_ptr->dec_mana) chance -= 2;
4119 * Modify spell fail rate (as "suffix" process)
4120 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4121 * Note: variable "chance" cannot be negative.
4123 int mod_spell_chance_2(int chance)
4125 if (p_ptr->dec_mana) chance--;
4127 if (p_ptr->heavy_spell) chance += 5;
4129 return MAX(chance, 0);
4134 * Returns spell chance of failure for spell -RAK-
4136 s16b spell_chance(int spell, int use_realm)
4138 int chance, minfail;
4141 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4144 /* Paranoia -- must be literate */
4145 if (!mp_ptr->spell_book) return (100);
4147 if (use_realm == REALM_HISSATSU) return 0;
4149 /* Access the spell */
4150 if (!is_magic(use_realm))
4152 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4156 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4159 /* Extract the base spell failure rate */
4160 chance = s_ptr->sfail;
4162 /* Reduce failure rate by "effective" level adjustment */
4163 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4165 /* Reduce failure rate by INT/WIS adjustment */
4166 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4169 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4171 /* Extract mana consumption rate */
4172 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4174 /* Not enough mana to cast */
4175 if (need_mana > p_ptr->csp)
4177 chance += 5 * (need_mana - p_ptr->csp);
4180 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4182 /* Extract the minimum failure rate */
4183 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4186 * Non mage/priest characters never get too good
4187 * (added high mage, mindcrafter)
4189 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4191 if (minfail < 5) minfail = 5;
4194 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4195 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4196 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4198 chance = mod_spell_chance_1(chance);
4200 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4201 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4202 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4204 /* Minimum failure rate */
4205 if (chance < minfail) chance = minfail;
4207 /* Stunning makes spells harder */
4208 if (p_ptr->stun > 50) chance += 25;
4209 else if (p_ptr->stun) chance += 15;
4211 /* Always a 5 percent chance of working */
4212 if (chance > 95) chance = 95;
4214 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4215 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4217 s16b exp = experience_of_spell(spell, use_realm);
4218 if (exp >= SPELL_EXP_EXPERT) chance--;
4219 if (exp >= SPELL_EXP_MASTER) chance--;
4222 /* Return the chance */
4223 return mod_spell_chance_2(chance);
4229 * Determine if a spell is "okay" for the player to cast or study
4230 * The spell must be legible, not forgotten, and also, to cast,
4231 * it must be known, and to study, it must not be known.
4233 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4237 /* Access the spell */
4238 if (!is_magic(use_realm))
4240 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4244 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4247 /* Spell is illegal */
4248 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4250 /* Spell is forgotten */
4251 if ((use_realm == p_ptr->realm2) ?
4252 (p_ptr->spell_forgotten2 & (1L << spell)) :
4253 (p_ptr->spell_forgotten1 & (1L << spell)))
4259 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4260 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4262 /* Spell is learned */
4263 if ((use_realm == p_ptr->realm2) ?
4264 (p_ptr->spell_learned2 & (1L << spell)) :
4265 (p_ptr->spell_learned1 & (1L << spell)))
4268 return (!study_pray);
4271 /* Okay to study, not to cast */
4277 * Print a list of spells (for browsing or casting or viewing)
4279 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4281 int i, spell, exp_level, increment = 64;
4293 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4295 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4297 msg_print("Warning! print_spells called with null realm");
4301 /* Title the list */
4303 if (use_realm == REALM_HISSATSU)
4305 strcpy(buf," Lv MP");
4307 strcpy(buf," Lv SP");
4311 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4313 strcpy(buf,"Profic Lv SP Fail Effect");
4317 put_str("̾Á°", y, x + 5);
4318 put_str(buf, y, x + 29);
4320 put_str("Name", y, x + 5);
4321 put_str(buf, y, x + 29);
4324 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4325 else if (use_realm == p_ptr->realm1) increment = 0;
4326 else if (use_realm == p_ptr->realm2) increment = 32;
4328 /* Dump the spells */
4329 for (i = 0; i < num; i++)
4331 /* Access the spell */
4334 /* Access the spell */
4335 if (!is_magic(use_realm))
4337 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4341 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4344 if (use_realm == REALM_HISSATSU)
4345 need_mana = s_ptr->smana;
4348 s16b exp = experience_of_spell(spell, use_realm);
4350 /* Extract mana consumption rate */
4351 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4353 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4354 else exp_level = spell_exp_level(exp);
4357 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4358 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4359 else if (s_ptr->slevel >= 99) max = TRUE;
4360 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4362 strncpy(ryakuji, exp_level_str[exp_level], 4);
4367 if (use_menu && target_spell)
4369 if (i == (target_spell-1))
4371 strcpy(out_val, " ¡Õ ");
4373 strcpy(out_val, " > ");
4376 strcpy(out_val, " ");
4378 else sprintf(out_val, " %c) ", I2A(i));
4379 /* Skip illegible spells */
4380 if (s_ptr->slevel >= 99)
4383 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4385 strcat(out_val, format("%-30s", "(illegible)"));
4388 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4392 /* XXX XXX Could label spells above the players level */
4394 /* Get extra info */
4395 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4400 /* Assume spell is known and tried */
4401 line_attr = TERM_WHITE;
4403 /* Analyze the spell */
4404 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4406 if (s_ptr->slevel > p_ptr->max_plv)
4411 comment = "unknown";
4414 line_attr = TERM_L_BLUE;
4416 else if (s_ptr->slevel > p_ptr->lev)
4421 comment = "forgotten";
4424 line_attr = TERM_YELLOW;
4427 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4432 comment = "unknown";
4435 line_attr = TERM_L_BLUE;
4437 else if ((use_realm == p_ptr->realm1) ?
4438 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4439 ((p_ptr->spell_forgotten2 & (1L << spell))))
4444 comment = "forgotten";
4447 line_attr = TERM_YELLOW;
4449 else if (!((use_realm == p_ptr->realm1) ?
4450 (p_ptr->spell_learned1 & (1L << spell)) :
4451 (p_ptr->spell_learned2 & (1L << spell))))
4456 comment = "unknown";
4459 line_attr = TERM_L_BLUE;
4461 else if (!((use_realm == p_ptr->realm1) ?
4462 (p_ptr->spell_worked1 & (1L << spell)) :
4463 (p_ptr->spell_worked2 & (1L << spell))))
4468 comment = "untried";
4471 line_attr = TERM_L_GREEN;
4474 /* Dump the spell --(-- */
4475 if (use_realm == REALM_HISSATSU)
4477 strcat(out_val, format("%-25s %2d %4d",
4478 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4479 s_ptr->slevel, need_mana));
4483 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4484 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4485 (max ? '!' : ' '), ryakuji,
4486 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4488 c_prt(line_attr, out_val, y + i + 1, x);
4491 /* Clear the bottom line */
4492 prt("", y + i + 1, x);
4497 * Note that amulets, rods, and high-level spell books are immune
4498 * to "inventory damage" of any kind. Also sling ammo and shovels.
4503 * Does a given class of objects (usually) hate acid?
4504 * Note that acid can either melt or corrode something.
4506 bool hates_acid(object_type *o_ptr)
4508 /* Analyze the type */
4509 switch (o_ptr->tval)
4511 /* Wearable items */
4531 /* Staffs/Scrolls are wood/paper */
4544 /* Junk is useless */
4558 * Does a given object (usually) hate electricity?
4560 bool hates_elec(object_type *o_ptr)
4562 switch (o_ptr->tval)
4576 * Does a given object (usually) hate fire?
4577 * Hafted/Polearm weapons have wooden shafts.
4578 * Arrows/Bows are mostly wooden.
4580 bool hates_fire(object_type *o_ptr)
4582 /* Analyze the type */
4583 switch (o_ptr->tval)
4601 case TV_SORCERY_BOOK:
4602 case TV_NATURE_BOOK:
4606 case TV_ARCANE_BOOK:
4608 case TV_DAEMON_BOOK:
4609 case TV_CRUSADE_BOOK:
4611 case TV_HISSATSU_BOOK:
4622 /* Staffs/Scrolls burn */
4635 * Does a given object (usually) hate cold?
4637 bool hates_cold(object_type *o_ptr)
4639 switch (o_ptr->tval)
4656 int set_acid_destroy(object_type *o_ptr)
4658 u32b flgs[TR_FLAG_SIZE];
4659 if (!hates_acid(o_ptr)) return (FALSE);
4660 object_flags(o_ptr, flgs);
4661 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4669 int set_elec_destroy(object_type *o_ptr)
4671 u32b flgs[TR_FLAG_SIZE];
4672 if (!hates_elec(o_ptr)) return (FALSE);
4673 object_flags(o_ptr, flgs);
4674 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4682 int set_fire_destroy(object_type *o_ptr)
4684 u32b flgs[TR_FLAG_SIZE];
4685 if (!hates_fire(o_ptr)) return (FALSE);
4686 object_flags(o_ptr, flgs);
4687 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4695 int set_cold_destroy(object_type *o_ptr)
4697 u32b flgs[TR_FLAG_SIZE];
4698 if (!hates_cold(o_ptr)) return (FALSE);
4699 object_flags(o_ptr, flgs);
4700 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4706 * Destroys a type of item on a given percent chance
4707 * Note that missiles are no longer necessarily all destroyed
4708 * Destruction taken from "melee.c" code for "stealing".
4709 * New-style wands and rods handled correctly. -LM-
4710 * Returns number of items destroyed.
4712 int inven_damage(inven_func typ, int perc)
4716 char o_name[MAX_NLEN];
4718 /* Multishadow effects is determined by turn */
4719 if( p_ptr->multishadow && (turn & 1) )return 0;
4721 if (p_ptr->inside_arena) return 0;
4723 /* Count the casualties */
4726 /* Scan through the slots backwards */
4727 for (i = 0; i < INVEN_PACK; i++)
4729 o_ptr = &inventory[i];
4731 /* Skip non-objects */
4732 if (!o_ptr->k_idx) continue;
4734 /* Hack -- for now, skip artifacts */
4735 if (object_is_artifact(o_ptr)) continue;
4737 /* Give this item slot a shot at death */
4740 /* Count the casualties */
4741 for (amt = j = 0; j < o_ptr->number; ++j)
4743 if (randint0(100) < perc) amt++;
4746 /* Some casualities */
4749 /* Get a description */
4750 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4754 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4756 msg_format("%sour %s (%c) %s destroyed!",
4760 o_name, index_to_label(i),
4761 ((o_ptr->number > 1) ?
4762 ((amt == o_ptr->number) ? "Á´Éô" :
4763 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4765 ((o_ptr->number > 1) ?
4766 ((amt == o_ptr->number) ? "All of y" :
4767 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4768 o_name, index_to_label(i),
4769 ((amt > 1) ? "were" : "was"));
4773 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4774 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4777 /* Potions smash open */
4778 if (object_is_potion(o_ptr))
4780 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4783 /* Reduce the charges of rods/wands */
4784 reduce_charges(o_ptr, amt);
4786 /* Destroy "amt" items */
4787 inven_item_increase(i, -amt);
4788 inven_item_optimize(i);
4790 /* Count the casualties */
4796 /* Return the casualty count */
4802 * Acid has hit the player, attempt to affect some armor.
4804 * Note that the "base armor" of an object never changes.
4806 * If any armor is damaged (or resists), the player takes less damage.
4808 static int minus_ac(void)
4810 object_type *o_ptr = NULL;
4811 u32b flgs[TR_FLAG_SIZE];
4812 char o_name[MAX_NLEN];
4815 /* Pick a (possibly empty) inventory slot */
4816 switch (randint1(7))
4818 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4819 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4820 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4821 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4822 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4823 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4824 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4827 /* Nothing to damage */
4828 if (!o_ptr->k_idx) return (FALSE);
4830 if (!object_is_armour(o_ptr)) return (FALSE);
4832 /* No damage left to be done */
4833 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4837 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4839 /* Extract the flags */
4840 object_flags(o_ptr, flgs);
4842 /* Object resists */
4843 if (have_flag(flgs, TR_IGNORE_ACID))
4846 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
4848 msg_format("Your %s is unaffected!", o_name);
4857 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
4859 msg_format("Your %s is damaged!", o_name);
4863 /* Damage the item */
4866 /* Calculate bonuses */
4867 p_ptr->update |= (PU_BONUS);
4870 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4874 /* Item was damaged */
4880 * Hurt the player with Acid
4882 int acid_dam(int dam, cptr kb_str, int monspell)
4885 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4886 bool double_resist = IS_OPPOSE_ACID();
4888 /* Total Immunity */
4889 if (p_ptr->immune_acid || (dam <= 0))
4891 learn_spell(monspell);
4895 /* Vulnerability (Ouch!) */
4896 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4897 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4899 /* Resist the damage */
4900 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4901 if (double_resist) dam = (dam + 2) / 3;
4903 if ((!(double_resist || p_ptr->resist_acid)) &&
4904 one_in_(HURT_CHANCE))
4905 (void)do_dec_stat(A_CHR);
4907 /* If any armor gets hit, defend the player */
4908 if (minus_ac()) dam = (dam + 1) / 2;
4911 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4913 /* Inventory damage */
4914 if (!(double_resist && p_ptr->resist_acid))
4915 inven_damage(set_acid_destroy, inv);
4921 * Hurt the player with electricity
4923 int elec_dam(int dam, cptr kb_str, int monspell)
4926 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4927 bool double_resist = IS_OPPOSE_ELEC();
4929 /* Total immunity */
4930 if (p_ptr->immune_elec || (dam <= 0))
4932 learn_spell(monspell);
4936 /* Vulnerability (Ouch!) */
4937 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4938 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4939 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4941 /* Resist the damage */
4942 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4943 if (double_resist) dam = (dam + 2) / 3;
4945 if ((!(double_resist || p_ptr->resist_elec)) &&
4946 one_in_(HURT_CHANCE))
4947 (void)do_dec_stat(A_DEX);
4950 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4952 /* Inventory damage */
4953 if (!(double_resist && p_ptr->resist_elec))
4954 inven_damage(set_elec_destroy, inv);
4961 * Hurt the player with Fire
4963 int fire_dam(int dam, cptr kb_str, int monspell)
4966 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4967 bool double_resist = IS_OPPOSE_FIRE();
4969 /* Totally immune */
4970 if (p_ptr->immune_fire || (dam <= 0))
4972 learn_spell(monspell);
4976 /* Vulnerability (Ouch!) */
4977 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4978 if (prace_is_(RACE_ENT)) dam += dam / 3;
4979 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4981 /* Resist the damage */
4982 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4983 if (double_resist) dam = (dam + 2) / 3;
4985 if ((!(double_resist || p_ptr->resist_fire)) &&
4986 one_in_(HURT_CHANCE))
4987 (void)do_dec_stat(A_STR);
4990 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4992 /* Inventory damage */
4993 if (!(double_resist && p_ptr->resist_fire))
4994 inven_damage(set_fire_destroy, inv);
5001 * Hurt the player with Cold
5003 int cold_dam(int dam, cptr kb_str, int monspell)
5006 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5007 bool double_resist = IS_OPPOSE_COLD();
5009 /* Total immunity */
5010 if (p_ptr->immune_cold || (dam <= 0))
5012 learn_spell(monspell);
5016 /* Vulnerability (Ouch!) */
5017 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5018 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5020 /* Resist the damage */
5021 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5022 if (double_resist) dam = (dam + 2) / 3;
5024 if ((!(double_resist || p_ptr->resist_cold)) &&
5025 one_in_(HURT_CHANCE))
5026 (void)do_dec_stat(A_STR);
5029 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5031 /* Inventory damage */
5032 if (!(double_resist && p_ptr->resist_cold))
5033 inven_damage(set_cold_destroy, inv);
5039 bool rustproof(void)
5043 char o_name[MAX_NLEN];
5046 item_tester_no_ryoute = TRUE;
5047 /* Select a piece of armour */
5048 item_tester_hook = object_is_armour;
5052 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5053 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5055 q = "Rustproof which piece of armour? ";
5056 s = "You have nothing to rustproof.";
5059 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5061 /* Get the item (in the pack) */
5064 o_ptr = &inventory[item];
5067 /* Get the item (on the floor) */
5070 o_ptr = &o_list[0 - item];
5075 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5077 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5079 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
5082 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5084 msg_format("%s %s look%s as good as new!",
5085 ((item >= 0) ? "Your" : "The"), o_name,
5086 ((o_ptr->number > 1) ? "" : "s"));
5093 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5095 msg_format("%s %s %s now protected against corrosion.",
5096 ((item >= 0) ? "Your" : "The"), o_name,
5097 ((o_ptr->number > 1) ? "are" : "is"));
5108 * Curse the players armor
5110 bool curse_armor(void)
5115 char o_name[MAX_NLEN];
5118 /* Curse the body armor */
5119 o_ptr = &inventory[INVEN_BODY];
5121 /* Nothing to curse */
5122 if (!o_ptr->k_idx) return (FALSE);
5126 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5128 /* Attempt a saving throw for artifacts */
5129 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
5133 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5134 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5136 msg_format("A %s tries to %s, but your %s resists the effects!",
5137 "terrible black aura", "surround your armor", o_name);
5142 /* not artifact or failed save... */
5147 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5149 msg_format("A terrible black aura blasts your %s!", o_name);
5152 chg_virtue(V_ENCHANT, -5);
5154 /* Blast the armor */
5156 o_ptr->name2 = EGO_BLASTED;
5157 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5164 for (i = 0; i < TR_FLAG_SIZE; i++)
5165 o_ptr->art_flags[i] = 0;
5168 o_ptr->curse_flags = TRC_CURSED;
5171 o_ptr->ident |= (IDENT_BROKEN);
5173 /* Recalculate bonuses */
5174 p_ptr->update |= (PU_BONUS);
5176 /* Recalculate mana */
5177 p_ptr->update |= (PU_MANA);
5180 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5188 * Curse the players weapon
5190 bool curse_weapon(bool force, int slot)
5196 char o_name[MAX_NLEN];
5199 /* Curse the weapon */
5200 o_ptr = &inventory[slot];
5202 /* Nothing to curse */
5203 if (!o_ptr->k_idx) return (FALSE);
5207 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5209 /* Attempt a saving throw */
5210 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5214 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5215 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5217 msg_format("A %s tries to %s, but your %s resists the effects!",
5218 "terrible black aura", "surround your weapon", o_name);
5223 /* not artifact or failed save... */
5228 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5230 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5233 chg_virtue(V_ENCHANT, -5);
5235 /* Shatter the weapon */
5237 o_ptr->name2 = EGO_SHATTERED;
5238 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5239 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5245 for (i = 0; i < TR_FLAG_SIZE; i++)
5246 o_ptr->art_flags[i] = 0;
5250 o_ptr->curse_flags = TRC_CURSED;
5253 o_ptr->ident |= (IDENT_BROKEN);
5255 /* Recalculate bonuses */
5256 p_ptr->update |= (PU_BONUS);
5258 /* Recalculate mana */
5259 p_ptr->update |= (PU_MANA);
5262 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5271 * Enchant some bolts
5273 bool brand_bolts(void)
5277 /* Use the first acceptable bolts */
5278 for (i = 0; i < INVEN_PACK; i++)
5280 object_type *o_ptr = &inventory[i];
5282 /* Skip non-bolts */
5283 if (o_ptr->tval != TV_BOLT) continue;
5285 /* Skip artifacts and ego-items */
5286 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5289 /* Skip cursed/broken items */
5290 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5293 if (randint0(100) < 75) continue;
5297 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5299 msg_print("Your bolts are covered in a fiery aura!");
5304 o_ptr->name2 = EGO_FLAME;
5307 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5314 if (flush_failure) flush();
5318 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5320 msg_print("The fiery enchantment failed.");
5330 * Helper function -- return a "nearby" race for polymorphing
5332 * Note that this function is one of the more "dangerous" ones...
5334 static s16b poly_r_idx(int r_idx)
5336 monster_race *r_ptr = &r_info[r_idx];
5338 int i, r, lev1, lev2;
5340 /* Hack -- Uniques/Questors never polymorph */
5341 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5342 (r_ptr->flags1 & RF1_QUESTOR))
5345 /* Allowable range of "levels" for resulting monster */
5346 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5347 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5349 /* Pick a (possibly new) non-unique race */
5350 for (i = 0; i < 1000; i++)
5352 /* Pick a new race, using a level calculation */
5353 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5355 /* Handle failure */
5361 /* Ignore unique monsters */
5362 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5364 /* Ignore monsters with incompatible levels */
5365 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5367 /* Use that index */
5379 bool polymorph_monster(int y, int x)
5381 cave_type *c_ptr = &cave[y][x];
5382 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5383 bool polymorphed = FALSE;
5385 int old_r_idx = m_ptr->r_idx;
5386 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5387 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5388 monster_type back_m;
5390 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5392 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5394 /* Memorize the monster before polymorphing */
5397 /* Pick a "new" monster race */
5398 new_r_idx = poly_r_idx(old_r_idx);
5400 /* Handle polymorph */
5401 if (new_r_idx != old_r_idx)
5405 /* Get the monsters attitude */
5406 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5407 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5408 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5410 /* "Kill" the "old" monster */
5411 delete_monster_idx(c_ptr->m_idx);
5413 /* Create a new monster (no groups) */
5414 if (place_monster_aux(0, y, x, new_r_idx, mode))
5421 /* Placing the new monster failed */
5422 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5424 m_list[hack_m_idx_ii] = back_m;
5426 /* Re-initialize monster process */
5431 if (targeted) target_who = hack_m_idx_ii;
5432 if (health_tracked) health_track(hack_m_idx_ii);
5442 static bool dimension_door_aux(int x, int y)
5444 int plev = p_ptr->lev;
5446 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5448 if (!cave_player_teleportable_bold(y, x, FALSE, FALSE) ||
5449 (distance(y, x, py, px) > plev / 2 + 10) ||
5450 (!randint0(plev / 10 + 10)))
5452 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5453 teleport_player((plev + 2) * 2, TRUE);
5460 teleport_player_to(y, x, TRUE, FALSE);
5471 bool dimension_door(void)
5475 /* Rerutn FALSE if cancelled */
5476 if (!tgt_pt(&x, &y)) return FALSE;
5478 if (dimension_door_aux(x, y)) return TRUE;
5481 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5483 msg_print("You fail to exit the astral plane correctly!");
5491 * Mirror Master's Dimension Door
5493 bool mirror_tunnel(void)
5497 /* Rerutn FALSE if cancelled */
5498 if (!tgt_pt(&x, &y)) return FALSE;
5500 if (dimension_door_aux(x, y)) return TRUE;
5503 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5505 msg_print("You fail to pass the mirror plane correctly!");
5512 bool eat_magic(int power)
5514 object_type * o_ptr;
5517 int recharge_strength = 0;
5523 char o_name[MAX_NLEN];
5525 item_tester_hook = item_tester_hook_recharge;
5529 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5530 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5532 q = "Drain which item? ";
5533 s = "You have nothing to drain.";
5536 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5540 o_ptr = &inventory[item];
5544 o_ptr = &o_list[0 - item];
5547 k_ptr = &k_info[o_ptr->k_idx];
5548 lev = k_info[o_ptr->k_idx].level;
5550 if (o_ptr->tval == TV_ROD)
5552 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5555 if (one_in_(recharge_strength))
5557 /* Activate the failure code. */
5562 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5565 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5567 msg_print("You can't absorb energy from a discharged rod.");
5574 o_ptr->timeout += k_ptr->pval;
5580 /* All staffs, wands. */
5581 recharge_strength = (100 + power - lev) / 15;
5584 if (recharge_strength < 0) recharge_strength = 0;
5587 if (one_in_(recharge_strength))
5589 /* Activate the failure code. */
5594 if (o_ptr->pval > 0)
5596 p_ptr->csp += lev / 2;
5599 /* XXX Hack -- unstack if necessary */
5600 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5605 /* Get local object */
5608 /* Obtain a local object */
5609 object_copy(q_ptr, o_ptr);
5611 /* Modify quantity */
5614 /* Restore the charges */
5617 /* Unstack the used item */
5619 p_ptr->total_weight -= q_ptr->weight;
5620 item = inven_carry(q_ptr);
5624 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5626 msg_print("You unstack your staff.");
5634 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5636 msg_print("There's no energy there to absorb!");
5640 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5644 /* Inflict the penalties for failing a recharge. */
5647 /* Artifacts are never destroyed. */
5648 if (object_is_fixed_artifact(o_ptr))
5650 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5652 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5654 msg_format("The recharging backfires - %s is completely drained!", o_name);
5658 /* Artifact rods. */
5659 if (o_ptr->tval == TV_ROD)
5660 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5662 /* Artifact wands and staffs. */
5663 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5668 /* Get the object description */
5669 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5671 /*** Determine Seriousness of Failure ***/
5673 /* Mages recharge objects more safely. */
5674 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)
5676 /* 10% chance to blow up one rod, otherwise draining. */
5677 if (o_ptr->tval == TV_ROD)
5679 if (one_in_(10)) fail_type = 2;
5682 /* 75% chance to blow up one wand, otherwise draining. */
5683 else if (o_ptr->tval == TV_WAND)
5685 if (!one_in_(3)) fail_type = 2;
5688 /* 50% chance to blow up one staff, otherwise no effect. */
5689 else if (o_ptr->tval == TV_STAFF)
5691 if (one_in_(2)) fail_type = 2;
5696 /* All other classes get no special favors. */
5699 /* 33% chance to blow up one rod, otherwise draining. */
5700 if (o_ptr->tval == TV_ROD)
5702 if (one_in_(3)) fail_type = 2;
5705 /* 20% chance of the entire stack, else destroy one wand. */
5706 else if (o_ptr->tval == TV_WAND)
5708 if (one_in_(5)) fail_type = 3;
5711 /* Blow up one staff. */
5712 else if (o_ptr->tval == TV_STAFF)
5718 /*** Apply draining and destruction. ***/
5720 /* Drain object or stack of objects. */
5723 if (o_ptr->tval == TV_ROD)
5726 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5728 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5731 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5733 else if (o_ptr->tval == TV_WAND)
5736 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5738 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5743 /* Staffs aren't drained. */
5746 /* Destroy an object or one in a stack of objects. */
5749 if (o_ptr->number > 1)
5752 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5754 msg_format("Wild magic consumes one of your %s!", o_name);
5757 /* Reduce rod stack maximum timeout, drain wands. */
5758 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5759 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5764 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5766 msg_format("Wild magic consumes your %s!", o_name);
5769 /* Reduce and describe inventory */
5772 inven_item_increase(item, -1);
5773 inven_item_describe(item);
5774 inven_item_optimize(item);
5777 /* Reduce and describe floor item */
5780 floor_item_increase(0 - item, -1);
5781 floor_item_describe(0 - item);
5782 floor_item_optimize(0 - item);
5786 /* Destroy all members of a stack of objects. */
5789 if (o_ptr->number > 1)
5791 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5793 msg_format("Wild magic consumes all your %s!", o_name);
5798 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5800 msg_format("Wild magic consumes your %s!", o_name);
5805 /* Reduce and describe inventory */
5808 inven_item_increase(item, -999);
5809 inven_item_describe(item);
5810 inven_item_optimize(item);
5813 /* Reduce and describe floor item */
5816 floor_item_increase(0 - item, -999);
5817 floor_item_describe(0 - item);
5818 floor_item_optimize(0 - item);
5824 if (p_ptr->csp > p_ptr->msp)
5826 p_ptr->csp = p_ptr->msp;
5829 /* Redraw mana and hp */
5830 p_ptr->redraw |= (PR_MANA);
5832 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5833 p_ptr->window |= (PW_INVEN);
5839 bool summon_kin_player(int level, int y, int x, u32b mode)
5841 bool pet = (bool)(mode & PM_FORCE_PET);
5842 if (!pet) mode |= PM_NO_PET;
5844 switch (p_ptr->mimic_form)
5847 switch (p_ptr->prace)
5851 case RACE_BARBARIAN:
5854 summon_kin_type = 'p';
5864 case RACE_MIND_FLAYER:
5867 summon_kin_type = 'h';
5870 summon_kin_type = 'o';
5872 case RACE_HALF_TROLL:
5873 summon_kin_type = 'T';
5875 case RACE_HALF_OGRE:
5876 summon_kin_type = 'O';
5878 case RACE_HALF_GIANT:
5879 case RACE_HALF_TITAN:
5881 summon_kin_type = 'P';
5884 summon_kin_type = 'y';
5887 summon_kin_type = 'K';
5890 summon_kin_type = 'k';
5893 if (one_in_(13)) summon_kin_type = 'U';
5894 else summon_kin_type = 'u';
5896 case RACE_DRACONIAN:
5897 summon_kin_type = 'd';
5901 summon_kin_type = 'g';
5904 if (one_in_(13)) summon_kin_type = 'L';
5905 else summon_kin_type = 's';
5908 summon_kin_type = 'z';
5911 summon_kin_type = 'V';
5914 summon_kin_type = 'G';
5917 summon_kin_type = 'I';
5920 summon_kin_type = '#';
5923 summon_kin_type = 'A';
5926 summon_kin_type = 'U';
5929 summon_kin_type = 'p';
5934 if (one_in_(13)) summon_kin_type = 'U';
5935 else summon_kin_type = 'u';
5937 case MIMIC_DEMON_LORD:
5938 summon_kin_type = 'U';
5941 summon_kin_type = 'V';
5944 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);