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 new location */
131 cave[ny][nx].m_idx = m_idx;
133 /* Update the old location */
134 cave[oy][ox].m_idx = 0;
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 new location */
234 cave[ny][nx].m_idx = m_idx;
236 /* Update the old location */
237 cave[oy][ox].m_idx = 0;
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 /* Fix the minimum distance */
362 for (cur_candidates = 0, min = dis; min >= 0; min--)
364 cur_candidates += candidates_at[min];
366 /* 50% of all candidates will have an equal chance to be choosen. */
367 if (cur_candidates >= total_candidates / 2) break;
370 /* Pick up a single location randomly */
371 pick = randint1(cur_candidates);
373 /* Search again the choosen location */
374 for (y = top; y <= bottom; y++)
376 for (x = left; x <= right; x++)
380 /* Skip illegal locations */
381 if (!cave_player_teleportable_bold(y, x, passive, FALSE)) continue;
383 /* Calculate distance */
384 d = distance(py, px, y, x);
386 /* Skip too far locations */
387 if (d > dis) continue;
389 /* Skip too close locations */
390 if (d < min) continue;
392 /* This grid was picked up? */
402 sound(SOUND_TELEPORT);
405 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
406 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
409 /* Save the old location */
413 /* Move the player */
414 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
416 /* Monsters with teleport ability may follow the player */
417 for (xx = -1; xx < 2; xx++)
419 for (yy = -1; yy < 2; yy++)
421 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
423 /* A monster except your mount may follow */
424 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
426 monster_type *m_ptr = &m_list[tmp_m_idx];
427 monster_race *r_ptr = &r_info[m_ptr->r_idx];
430 * The latter limitation is to avoid
431 * totally unkillable suckers...
433 if ((r_ptr->flags6 & RF6_TPORT) &&
434 !(r_ptr->flagsr & RFR_RES_TELE))
436 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level, FALSE);
445 * Teleport player to a grid near the given location
447 * This function is slightly obsessive about correctness.
448 * This function allows teleporting into vaults (!)
450 void teleport_player_to(int ny, int nx, bool no_tele, bool passive)
452 int y, x, dis = 0, ctr = 0;
454 if (p_ptr->anti_tele && no_tele)
457 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
459 msg_print("A mysterious force prevents you from teleporting!");
465 /* Find a usable location */
468 /* Pick a nearby legal location */
471 y = rand_spread(ny, dis);
472 x = rand_spread(nx, dis);
473 if (in_bounds(y, x)) break;
476 /* Accept any grid when wizard mode */
477 if (p_ptr->wizard && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
479 /* Accept teleportable floor grids */
480 if (cave_player_teleportable_bold(y, x, passive, !no_tele)) break;
482 /* Occasionally advance the distance */
483 if (++ctr > (4 * dis * dis + 4 * dis + 1))
491 sound(SOUND_TELEPORT);
493 /* Move the player */
494 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
500 * Teleport the player one level up or down (random when legal)
501 * Note: If m_idx <= 0, target is player.
503 void teleport_level(int m_idx)
509 if (m_idx <= 0) /* To player */
512 strcpy(m_name, "¤¢¤Ê¤¿");
514 strcpy(m_name, "you");
517 else /* To monster */
519 monster_type *m_ptr = &m_list[m_idx];
521 /* Get the monster name (or "it") */
522 monster_desc(m_name, m_ptr, 0);
524 see_m = is_seen(m_ptr);
527 /* No effect in some case */
528 if (TELE_LEVEL_IS_INEFF(m_idx))
531 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
533 if (see_m) msg_print("There is no effect.");
539 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
542 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
544 msg_print("A mysterious force prevents you from teleporting!");
549 /* Choose up or down */
550 if (randint0(100) < 50) go_up = TRUE;
553 if ((m_idx <= 0) && p_ptr->wizard)
555 if (get_check("Force to go up? ")) go_up = TRUE;
556 else if (get_check("Force to go down? ")) go_up = FALSE;
560 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
563 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
565 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
567 if (m_idx <= 0) /* To player */
571 dungeon_type = p_ptr->recall_dungeon;
576 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
578 if (autosave_l) do_cmd_save_game(TRUE);
582 dun_level = d_info[dungeon_type].mindepth;
583 prepare_change_floor_mode(CFM_RAND_PLACE);
587 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
591 p_ptr->leaving = TRUE;
596 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
599 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
601 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
605 if (m_idx <= 0) /* To player */
607 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
609 if (autosave_l) do_cmd_save_game(TRUE);
611 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
616 p_ptr->inside_quest = 0;
617 p_ptr->leaving = TRUE;
623 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
625 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
629 if (m_idx <= 0) /* To player */
631 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
633 if (autosave_l) do_cmd_save_game(TRUE);
635 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
638 p_ptr->leaving = TRUE;
644 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
646 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
649 if (m_idx <= 0) /* To player */
651 /* Never reach this code on the surface */
652 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
654 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
656 if (autosave_l) do_cmd_save_game(TRUE);
658 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
661 p_ptr->leaving = TRUE;
665 /* Monster level teleportation is simple deleting now */
668 monster_type *m_ptr = &m_list[m_idx];
670 /* Check for quest completion */
671 check_quest_completion(m_ptr);
673 delete_monster_idx(m_idx);
677 sound(SOUND_TPLEVEL);
682 int choose_dungeon(cptr note, int y, int x)
688 /* Hack -- No need to choose dungeon in some case */
689 if (lite_town || vanilla_town || ironman_downward)
691 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
695 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
697 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
704 /* Allocate the "dun" array */
705 C_MAKE(dun, max_d_idx, s16b);
708 for(i = 1; i < max_d_idx; i++)
713 if (!d_info[i].maxdepth) continue;
714 if (!max_dlv[i]) continue;
715 if (d_info[i].final_guardian)
717 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
719 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
722 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
724 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
726 prt(buf, y + num, x);
733 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
735 prt(" No dungeon is available.", y, x);
740 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
742 prt(format("Which dungeon do you %s?: ", note), 0, 0);
747 if ((i == ESCAPE) || !num)
749 /* Free the "dun" array */
750 C_KILL(dun, max_d_idx, s16b);
755 if (i >= 'a' && i <('a'+num))
757 select_dungeon = dun[i-'a'];
764 /* Free the "dun" array */
765 C_KILL(dun, max_d_idx, s16b);
767 return select_dungeon;
772 * Recall the player to town or dungeon
774 bool recall_player(int turns)
777 * TODO: Recall the player to the last
778 * visited town when in the wilderness
782 if (p_ptr->inside_arena || ironman_downward)
785 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
787 msg_print("Nothing happens.");
793 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
796 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
798 if (get_check("Reset recall depth? "))
801 max_dlv[dungeon_type] = dun_level;
804 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
806 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
811 if (!p_ptr->word_recall)
817 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
819 select_dungeon = choose_dungeon("recall", 2, 14);
821 if (!select_dungeon) return FALSE;
822 p_ptr->recall_dungeon = select_dungeon;
824 p_ptr->word_recall = turns;
826 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
828 msg_print("The air about you becomes charged...");
831 p_ptr->redraw |= (PR_STATUS);
835 p_ptr->word_recall = 0;
837 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
839 msg_print("A tension leaves the air around you...");
842 p_ptr->redraw |= (PR_STATUS);
848 bool word_of_recall(void)
850 return(recall_player(randint0(21) + 15));
854 bool reset_recall(void)
856 int select_dungeon, dummy = 0;
861 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
863 select_dungeon = choose_dungeon("reset", 2, 14);
867 if (ironman_downward)
870 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
872 msg_print("Nothing happens.");
878 if (!select_dungeon) return FALSE;
881 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
883 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
888 sprintf(tmp_val, "%d", MAX(dun_level, 1));
890 /* Ask for a level */
891 if (get_string(ppp, tmp_val, 10))
893 /* Extract request */
894 dummy = atoi(tmp_val);
897 if (dummy < 1) dummy = 1;
900 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
901 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
903 max_dlv[select_dungeon] = dummy;
907 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
909 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
913 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
915 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
928 * Apply disenchantment to the player's stuff
930 * XXX XXX XXX This function is also called from the "melee" code
932 * Return "TRUE" if the player notices anything
934 bool apply_disenchant(int mode)
938 char o_name[MAX_NLEN];
939 int to_h, to_d, to_a, pval;
941 /* Pick a random slot */
944 case 1: t = INVEN_RARM; break;
945 case 2: t = INVEN_LARM; break;
946 case 3: t = INVEN_BOW; break;
947 case 4: t = INVEN_BODY; break;
948 case 5: t = INVEN_OUTER; break;
949 case 6: t = INVEN_HEAD; break;
950 case 7: t = INVEN_HANDS; break;
951 case 8: t = INVEN_FEET; break;
955 o_ptr = &inventory[t];
957 /* No item, nothing happens */
958 if (!o_ptr->k_idx) return (FALSE);
960 /* Disenchant equipments only -- No disenchant on monster ball */
961 if (!object_is_weapon_armour_ammo(o_ptr))
964 /* Nothing to disenchant */
965 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
967 /* Nothing to notice */
972 /* Describe the object */
973 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
976 /* Artifacts have 71% chance to resist */
977 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
981 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
983 msg_format("Your %s (%c) resist%s disenchantment!",
984 o_name, index_to_label(t),
985 ((o_ptr->number != 1) ? "" : "s"));
994 /* Memorize old value */
1000 /* Disenchant tohit */
1001 if (o_ptr->to_h > 0) o_ptr->to_h--;
1002 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1004 /* Disenchant todam */
1005 if (o_ptr->to_d > 0) o_ptr->to_d--;
1006 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1008 /* Disenchant toac */
1009 if (o_ptr->to_a > 0) o_ptr->to_a--;
1010 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1012 /* Disenchant pval (occasionally) */
1013 /* Unless called from wild_magic() */
1014 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1016 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1017 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1021 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1022 o_name, index_to_label(t) );
1024 msg_format("Your %s (%c) %s disenchanted!",
1025 o_name, index_to_label(t),
1026 ((o_ptr->number != 1) ? "were" : "was"));
1029 chg_virtue(V_HARMONY, 1);
1030 chg_virtue(V_ENCHANT, -2);
1032 /* Recalculate bonuses */
1033 p_ptr->update |= (PU_BONUS);
1036 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1046 void mutate_player(void)
1048 int max1, cur1, max2, cur2, ii, jj, i;
1050 /* Pick a pair of stats */
1052 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1054 max1 = p_ptr->stat_max[ii];
1055 cur1 = p_ptr->stat_cur[ii];
1056 max2 = p_ptr->stat_max[jj];
1057 cur2 = p_ptr->stat_cur[jj];
1059 p_ptr->stat_max[ii] = max2;
1060 p_ptr->stat_cur[ii] = cur2;
1061 p_ptr->stat_max[jj] = max1;
1062 p_ptr->stat_cur[jj] = cur1;
1066 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1067 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1070 p_ptr->update |= (PU_BONUS);
1077 void apply_nexus(monster_type *m_ptr)
1079 switch (randint1(7))
1081 case 1: case 2: case 3:
1083 teleport_player(200, TRUE);
1089 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, TRUE);
1095 if (randint0(100) < p_ptr->skill_sav)
1098 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1100 msg_print("You resist the effects!");
1106 /* Teleport Level */
1113 if (randint0(100) < p_ptr->skill_sav)
1116 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1118 msg_print("You resist the effects!");
1125 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1127 msg_print("Your body starts to scramble...");
1138 * Charge a lite (torch or latern)
1140 void phlogiston(void)
1143 object_type * o_ptr = &inventory[INVEN_LITE];
1146 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1148 max_flog = FUEL_LAMP;
1152 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1154 max_flog = FUEL_TORCH;
1157 /* No torch to refill */
1161 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1163 msg_print("You are not wielding anything which uses phlogiston.");
1169 if (o_ptr->xtra4 >= max_flog)
1172 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1174 msg_print("No more phlogiston can be put in this item.");
1181 o_ptr->xtra4 += (max_flog / 2);
1185 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1187 msg_print("You add phlogiston to your light item.");
1192 if (o_ptr->xtra4 >= max_flog)
1194 o_ptr->xtra4 = max_flog;
1196 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1198 msg_print("Your light item is full.");
1203 /* Recalculate torch */
1204 p_ptr->update |= (PU_TORCH);
1209 * Brand the current weapon
1211 void brand_weapon(int brand_type)
1218 /* Assume enchant weapon */
1219 item_tester_hook = object_allow_enchant_melee_weapon;
1220 item_tester_no_ryoute = TRUE;
1224 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1225 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1227 q = "Enchant which weapon? ";
1228 s = "You have nothing to enchant.";
1231 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1233 /* Get the item (in the pack) */
1236 o_ptr = &inventory[item];
1239 /* Get the item (on the floor) */
1242 o_ptr = &o_list[0 - item];
1246 /* you can never modify artifacts / ego-items */
1247 /* you can never modify cursed items */
1248 /* TY: You _can_ modify broken items (if you're silly enough) */
1249 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1250 !object_is_cursed(o_ptr) &&
1251 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1252 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1253 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1257 /* Let's get the name before it is changed... */
1258 char o_name[MAX_NLEN];
1259 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1264 if (o_ptr->tval == TV_SWORD)
1267 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1269 act = "becomes very sharp!";
1272 o_ptr->name2 = EGO_SHARPNESS;
1273 o_ptr->pval = m_bonus(5, dun_level) + 1;
1278 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1280 act = "seems very powerful.";
1283 o_ptr->name2 = EGO_EARTHQUAKES;
1284 o_ptr->pval = m_bonus(3, dun_level);
1289 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1291 act = "seems to be looking for humans!";
1294 o_ptr->name2 = EGO_SLAY_HUMAN;
1298 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1300 act = "covered with lightning!";
1303 o_ptr->name2 = EGO_BRAND_ELEC;
1307 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1309 act = "coated with acid!";
1312 o_ptr->name2 = EGO_BRAND_ACID;
1316 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1318 act = "seems to be looking for evil monsters!";
1321 o_ptr->name2 = EGO_SLAY_EVIL;
1325 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1327 act = "seems to be looking for demons!";
1330 o_ptr->name2 = EGO_SLAY_DEMON;
1334 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1336 act = "seems to be looking for undead!";
1339 o_ptr->name2 = EGO_SLAY_UNDEAD;
1343 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1345 act = "seems to be looking for animals!";
1348 o_ptr->name2 = EGO_SLAY_ANIMAL;
1352 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1354 act = "seems to be looking for dragons!";
1357 o_ptr->name2 = EGO_SLAY_DRAGON;
1361 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1363 act = "seems to be looking for troll!s";
1366 o_ptr->name2 = EGO_SLAY_TROLL;
1370 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1372 act = "seems to be looking for orcs!";
1375 o_ptr->name2 = EGO_SLAY_ORC;
1379 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1381 act = "seems to be looking for giants!";
1384 o_ptr->name2 = EGO_SLAY_GIANT;
1388 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1390 act = "seems very unstable now.";
1393 o_ptr->name2 = EGO_TRUMP;
1394 o_ptr->pval = randint1(2);
1398 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1400 act = "thirsts for blood!";
1403 o_ptr->name2 = EGO_VAMPIRIC;
1407 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1409 act = "is coated with poison.";
1412 o_ptr->name2 = EGO_BRAND_POIS;
1416 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1418 act = "is engulfed in raw Logrus!";
1421 o_ptr->name2 = EGO_CHAOTIC;
1425 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1427 act = "is covered in a fiery shield!";
1430 o_ptr->name2 = EGO_BRAND_FIRE;
1434 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1436 act = "glows deep, icy blue!";
1439 o_ptr->name2 = EGO_BRAND_COLD;
1444 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1446 msg_format("Your %s %s", o_name, act);
1450 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1452 o_ptr->discount = 99;
1453 chg_virtue(V_ENCHANT, 2);
1457 if (flush_failure) flush();
1460 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1462 msg_print("The Branding failed.");
1465 chg_virtue(V_ENCHANT, -2);
1472 * Vanish all walls in this floor
1474 static bool vanish_dungeon(void)
1478 feature_type *f_ptr;
1479 monster_type *m_ptr;
1482 /* Prevent vasishing of quest levels and town */
1483 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1488 /* Scan all normal grids */
1489 for (y = 1; y < cur_hgt - 1; y++)
1491 for (x = 1; x < cur_wid - 1; x++)
1493 c_ptr = &cave[y][x];
1495 /* Seeing true feature code (ignore mimic) */
1496 f_ptr = &f_info[c_ptr->feat];
1498 /* Lose room and vault */
1499 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1501 m_ptr = &m_list[c_ptr->m_idx];
1504 if (c_ptr->m_idx && m_ptr->csleep)
1506 /* Reset sleep counter */
1509 /* Notice the "waking up" */
1512 /* Acquire the monster name */
1513 monster_desc(m_name, m_ptr, 0);
1515 /* Dump a message */
1517 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1519 msg_format("%^s wakes up.", m_name);
1525 /* Redraw the health bar */
1526 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1527 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1531 /* Process all walls, doors and patterns */
1532 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1536 /* Special boundary walls -- Top and bottom */
1537 for (x = 0; x < cur_wid; x++)
1539 c_ptr = &cave[0][x];
1540 f_ptr = &f_info[c_ptr->mimic];
1542 /* Lose room and vault */
1543 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1545 /* Set boundary mimic if needed */
1546 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1548 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1550 /* Check for change to boring grid */
1551 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1554 c_ptr = &cave[cur_hgt - 1][x];
1555 f_ptr = &f_info[c_ptr->mimic];
1557 /* Lose room and vault */
1558 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1560 /* Set boundary mimic if needed */
1561 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1563 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1565 /* Check for change to boring grid */
1566 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1570 /* Special boundary walls -- Left and right */
1571 for (y = 1; y < (cur_hgt - 1); y++)
1573 c_ptr = &cave[y][0];
1574 f_ptr = &f_info[c_ptr->mimic];
1576 /* Lose room and vault */
1577 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1579 /* Set boundary mimic if needed */
1580 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1582 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1584 /* Check for change to boring grid */
1585 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1588 c_ptr = &cave[y][cur_wid - 1];
1589 f_ptr = &f_info[c_ptr->mimic];
1591 /* Lose room and vault */
1592 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1594 /* Set boundary mimic if needed */
1595 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1597 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1599 /* Check for change to boring grid */
1600 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1604 /* Mega-Hack -- Forget the view and lite */
1605 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1608 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1610 /* Update the monsters */
1611 p_ptr->update |= (PU_MONSTERS);
1614 p_ptr->redraw |= (PR_MAP);
1617 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1623 void call_the_(void)
1627 bool do_call = TRUE;
1629 for (i = 0; i < 9; i++)
1631 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1633 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1635 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1636 !permanent_wall(&f_info[c_ptr->feat]))
1646 for (i = 1; i < 10; i++)
1648 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1651 for (i = 1; i < 10; i++)
1653 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1656 for (i = 1; i < 10; i++)
1658 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1662 /* Prevent destruction of quest levels and town */
1663 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1666 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1668 msg_print("The ground trembles.");
1675 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1676 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1677 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1679 msg_format("You %s the %s too close to a wall!",
1680 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1681 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1682 msg_print("There is a loud explosion!");
1688 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1690 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1695 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1697 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1699 msg_print("The dungeon collapses...");
1704 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1706 msg_print("The dungeon trembles.");
1711 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1713 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1720 * Fetch an item (teleport it right underneath the caster)
1722 void fetch(int dir, int wgt, bool require_los)
1727 char o_name[MAX_NLEN];
1729 /* Check to see if an object is already there */
1730 if (cave[py][px].o_idx)
1733 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1735 msg_print("You can't fetch when you're already standing on something.");
1742 if (dir == 5 && target_okay())
1747 if (distance(py, px, ty, tx) > MAX_RANGE)
1750 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1752 msg_print("You can't fetch something that far away!");
1758 c_ptr = &cave[ty][tx];
1760 /* We need an item to fetch */
1764 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1766 msg_print("There is no object at this place.");
1772 /* No fetching from vault */
1773 if (c_ptr->info & CAVE_ICKY)
1776 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1778 msg_print("The item slips from your control.");
1784 /* We need to see the item */
1787 if (!player_has_los_bold(ty, tx))
1790 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1792 msg_print("You have no direct line of sight to that location.");
1797 else if (!projectable(py, px, ty, tx))
1800 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1802 msg_print("You have no direct line of sight to that location.");
1811 /* Use a direction */
1812 ty = py; /* Where to drop the item */
1819 c_ptr = &cave[ty][tx];
1821 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1822 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1824 while (!c_ptr->o_idx);
1827 o_ptr = &o_list[c_ptr->o_idx];
1829 if (o_ptr->weight > wgt)
1831 /* Too heavy to 'fetch' */
1833 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1835 msg_print("The object is too heavy.");
1842 c_ptr->o_idx = o_ptr->next_o_idx;
1843 cave[py][px].o_idx = i; /* 'move' it */
1844 o_ptr->next_o_idx = 0;
1845 o_ptr->iy = (byte)py;
1846 o_ptr->ix = (byte)px;
1848 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1850 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1852 msg_format("%^s flies through the air to your feet.", o_name);
1857 p_ptr->redraw |= PR_MAP;
1861 void alter_reality(void)
1863 /* Ironman option */
1864 if (p_ptr->inside_arena || ironman_downward)
1867 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1869 msg_print("Nothing happens.");
1874 if (!p_ptr->alter_reality)
1876 int turns = randint0(21) + 15;
1878 p_ptr->alter_reality = turns;
1880 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1882 msg_print("The view around you begins to change...");
1885 p_ptr->redraw |= (PR_STATUS);
1889 p_ptr->alter_reality = 0;
1891 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1893 msg_print("The view around you got back...");
1896 p_ptr->redraw |= (PR_STATUS);
1903 * Leave a "glyph of warding" which prevents monster movement
1905 bool warding_glyph(void)
1908 if (!cave_clean_bold(py, px))
1911 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1913 msg_print("The object resists the spell.");
1919 /* Create a glyph */
1920 cave[py][px].info |= CAVE_OBJECT;
1921 cave[py][px].mimic = FEAT_GLYPH;
1932 bool place_mirror(void)
1935 if (!cave_clean_bold(py, px))
1938 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1940 msg_print("The object resists the spell.");
1946 /* Create a mirror */
1947 cave[py][px].info |= CAVE_OBJECT;
1948 cave[py][px].mimic = FEAT_MIRROR;
1950 /* Turn on the light */
1951 cave[py][px].info |= CAVE_GLOW;
1959 update_local_illumination(py, px);
1966 * Leave an "explosive rune" which prevents monster movement
1968 bool explosive_rune(void)
1971 if (!cave_clean_bold(py, px))
1974 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1976 msg_print("The object resists the spell.");
1982 /* Create a glyph */
1983 cave[py][px].info |= CAVE_OBJECT;
1984 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1997 * Identify everything being carried.
1998 * Done by a potion of "self knowledge".
2000 void identify_pack(void)
2004 /* Simply identify and know every item */
2005 for (i = 0; i < INVEN_TOTAL; i++)
2007 object_type *o_ptr = &inventory[i];
2009 /* Skip non-objects */
2010 if (!o_ptr->k_idx) continue;
2013 identify_item(o_ptr);
2015 /* Auto-inscription */
2016 autopick_alter_item(i, FALSE);
2022 * Used by the "enchant" function (chance of failure)
2023 * (modified for Zangband, we need better stuff there...) -- TY
2025 static int enchant_table[16] =
2027 0, 10, 50, 100, 200,
2028 300, 400, 500, 650, 800,
2029 950, 987, 993, 995, 998,
2035 * Removes curses from items in inventory
2037 * Note that Items which are "Perma-Cursed" (The One Ring,
2038 * The Crown of Morgoth) can NEVER be uncursed.
2040 * Note that if "all" is FALSE, then Items which are
2041 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2042 * will not be uncursed.
2044 static int remove_curse_aux(int all)
2048 /* Attempt to uncurse items being worn */
2049 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2051 object_type *o_ptr = &inventory[i];
2053 /* Skip non-objects */
2054 if (!o_ptr->k_idx) continue;
2056 /* Uncursed already */
2057 if (!object_is_cursed(o_ptr)) continue;
2059 /* Heavily Cursed Items need a special spell */
2060 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2062 /* Perma-Cursed Items can NEVER be uncursed */
2063 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2066 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2071 o_ptr->curse_flags = 0L;
2073 /* Hack -- Assume felt */
2074 o_ptr->ident |= (IDENT_SENSE);
2077 o_ptr->feeling = FEEL_NONE;
2079 /* Recalculate the bonuses */
2080 p_ptr->update |= (PU_BONUS);
2083 p_ptr->window |= (PW_EQUIP);
2085 /* Count the uncursings */
2089 /* Return "something uncursed" */
2095 * Remove most curses
2097 bool remove_curse(void)
2099 return (remove_curse_aux(FALSE));
2105 bool remove_all_curse(void)
2107 return (remove_curse_aux(TRUE));
2112 * Turns an object into gold, gain some of its value in a shop
2121 char o_name[MAX_NLEN];
2122 char out_val[MAX_NLEN+40];
2126 /* Hack -- force destruction */
2127 if (command_arg > 0) force = TRUE;
2131 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2132 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2134 q = "Turn which item to gold? ";
2135 s = "You have nothing to turn to gold.";
2138 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2140 /* Get the item (in the pack) */
2143 o_ptr = &inventory[item];
2146 /* Get the item (on the floor) */
2149 o_ptr = &o_list[0 - item];
2153 /* See how many items */
2154 if (o_ptr->number > 1)
2156 /* Get a quantity */
2157 amt = get_quantity(NULL, o_ptr->number);
2159 /* Allow user abort */
2160 if (amt <= 0) return FALSE;
2164 /* Describe the object */
2165 old_number = o_ptr->number;
2166 o_ptr->number = amt;
2167 object_desc(o_name, o_ptr, 0);
2168 o_ptr->number = old_number;
2170 /* Verify unless quantity given */
2173 if (confirm_destroy || (object_value(o_ptr) > 0))
2175 /* Make a verification */
2177 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2179 sprintf(out_val, "Really turn %s to gold? ", o_name);
2182 if (!get_check(out_val)) return FALSE;
2186 /* Artifacts cannot be destroyed */
2187 if (!can_player_destroy_object(o_ptr))
2191 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2193 msg_format("You fail to turn %s to gold!", o_name);
2200 price = object_value_real(o_ptr);
2206 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2208 msg_format("You turn %s to fool's gold.", o_name);
2216 if (amt > 1) price *= amt;
2218 if (price > 30000) price = 30000;
2220 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2222 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2228 p_ptr->redraw |= (PR_GOLD);
2231 p_ptr->window |= (PW_PLAYER);
2235 /* Eliminate the item (from the pack) */
2238 inven_item_increase(item, -amt);
2239 inven_item_describe(item);
2240 inven_item_optimize(item);
2243 /* Eliminate the item (from the floor) */
2246 floor_item_increase(0 - item, -amt);
2247 floor_item_describe(0 - item);
2248 floor_item_optimize(0 - item);
2256 * Break the curse of an item
2258 static void break_curse(object_type *o_ptr)
2260 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2263 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2265 msg_print("The curse is broken!");
2268 o_ptr->curse_flags = 0L;
2270 o_ptr->ident |= (IDENT_SENSE);
2272 o_ptr->feeling = FEEL_NONE;
2278 * Enchants a plus onto an item. -RAK-
2280 * Revamped! Now takes item pointer, number of times to try enchanting,
2281 * and a flag of what to try enchanting. Artifacts resist enchantment
2282 * some of the time, and successful enchantment to at least +0 might
2283 * break a curse on the item. -CFT-
2285 * Note that an item can technically be enchanted all the way to +15 if
2286 * you wait a very, very, long time. Going from +9 to +10 only works
2287 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2289 * Note that this function can now be used on "piles" of items, and
2290 * the larger the pile, the lower the chance of success.
2292 bool enchant(object_type *o_ptr, int n, int eflag)
2294 int i, chance, prob;
2296 bool a = object_is_artifact(o_ptr);
2297 bool force = (eflag & ENCH_FORCE);
2300 /* Large piles resist enchantment */
2301 prob = o_ptr->number * 100;
2303 /* Missiles are easy to enchant */
2304 if ((o_ptr->tval == TV_BOLT) ||
2305 (o_ptr->tval == TV_ARROW) ||
2306 (o_ptr->tval == TV_SHOT))
2312 for (i = 0; i < n; i++)
2314 /* Hack -- Roll for pile resistance */
2315 if (!force && randint0(prob) >= 100) continue;
2317 /* Enchant to hit */
2318 if (eflag & ENCH_TOHIT)
2320 if (o_ptr->to_h < 0) chance = 0;
2321 else if (o_ptr->to_h > 15) chance = 1000;
2322 else chance = enchant_table[o_ptr->to_h];
2324 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2329 /* only when you get it above -1 -CFT */
2330 if (o_ptr->to_h >= 0)
2335 /* Enchant to damage */
2336 if (eflag & ENCH_TODAM)
2338 if (o_ptr->to_d < 0) chance = 0;
2339 else if (o_ptr->to_d > 15) chance = 1000;
2340 else chance = enchant_table[o_ptr->to_d];
2342 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2347 /* only when you get it above -1 -CFT */
2348 if (o_ptr->to_d >= 0)
2353 /* Enchant to armor class */
2354 if (eflag & ENCH_TOAC)
2356 if (o_ptr->to_a < 0) chance = 0;
2357 else if (o_ptr->to_a > 15) chance = 1000;
2358 else chance = enchant_table[o_ptr->to_a];
2360 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2365 /* only when you get it above -1 -CFT */
2366 if (o_ptr->to_a >= 0)
2373 if (!res) return (FALSE);
2375 /* Recalculate bonuses */
2376 p_ptr->update |= (PU_BONUS);
2378 /* Combine / Reorder the pack (later) */
2379 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2382 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2393 * Enchant an item (in the inventory or on the floor)
2394 * Note that "num_ac" requires armour, else weapon
2395 * Returns TRUE if attempted, FALSE if cancelled
2397 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2402 char o_name[MAX_NLEN];
2406 /* Assume enchant weapon */
2407 item_tester_hook = object_allow_enchant_weapon;
2408 item_tester_no_ryoute = TRUE;
2410 /* Enchant armor if requested */
2411 if (num_ac) item_tester_hook = object_is_armour;
2415 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2416 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2418 q = "Enchant which item? ";
2419 s = "You have nothing to enchant.";
2422 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2424 /* Get the item (in the pack) */
2427 o_ptr = &inventory[item];
2430 /* Get the item (on the floor) */
2433 o_ptr = &o_list[0 - item];
2438 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2442 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2445 msg_format("%s %s glow%s brightly!",
2446 ((item >= 0) ? "Your" : "The"), o_name,
2447 ((o_ptr->number > 1) ? "" : "s"));
2452 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2453 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2454 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2460 if (flush_failure) flush();
2464 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2466 msg_print("The enchantment failed.");
2469 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2472 chg_virtue(V_ENCHANT, 1);
2476 /* Something happened */
2482 * Check if an object is nameless weapon or armour
2484 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2486 /* Require weapon or armour */
2487 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2489 /* Require nameless object if the object is well known */
2490 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2497 bool artifact_scroll(void)
2502 char o_name[MAX_NLEN];
2506 item_tester_no_ryoute = TRUE;
2508 /* Enchant weapon/armour */
2509 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2513 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2514 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2516 q = "Enchant which item? ";
2517 s = "You have nothing to enchant.";
2520 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2522 /* Get the item (in the pack) */
2525 o_ptr = &inventory[item];
2528 /* Get the item (on the floor) */
2531 o_ptr = &o_list[0 - item];
2536 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2540 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2542 msg_format("%s %s radiate%s a blinding light!",
2543 ((item >= 0) ? "Your" : "The"), o_name,
2544 ((o_ptr->number > 1) ? "" : "s"));
2547 if (object_is_artifact(o_ptr))
2550 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2552 msg_format("The %s %s already %s!",
2553 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2554 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2560 else if (object_is_ego(o_ptr))
2563 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2565 msg_format("The %s %s already %s!",
2566 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2567 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2573 else if (o_ptr->xtra3)
2576 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2578 msg_format("The %s %s already %s!",
2579 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2580 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2586 if (o_ptr->number > 1)
2589 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2590 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2592 msg_print("Not enough enough energy to enchant more than one object!");
2593 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2598 inven_item_increase(item, 1-(o_ptr->number));
2602 floor_item_increase(0-item, 1-(o_ptr->number));
2605 okay = create_artifact(o_ptr, TRUE);
2612 if (flush_failure) flush();
2616 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2618 msg_print("The enchantment failed.");
2621 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2624 chg_virtue(V_ENCHANT, 1);
2628 /* Something happened */
2634 * Identify an object
2636 bool identify_item(object_type *o_ptr)
2638 bool old_known = FALSE;
2639 char o_name[MAX_NLEN];
2642 object_desc(o_name, o_ptr, 0);
2644 if (o_ptr->ident & IDENT_KNOWN)
2647 if (!(o_ptr->ident & (IDENT_MENTAL)))
2649 if (object_is_artifact(o_ptr) || one_in_(5))
2650 chg_virtue(V_KNOWLEDGE, 1);
2653 /* Identify it fully */
2654 object_aware(o_ptr);
2655 object_known(o_ptr);
2657 /* Recalculate bonuses */
2658 p_ptr->update |= (PU_BONUS);
2660 /* Combine / Reorder the pack (later) */
2661 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2664 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2666 strcpy(record_o_name, o_name);
2670 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2672 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2673 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2674 if(record_rand_art && !old_known && o_ptr->art_name)
2675 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2681 static bool item_tester_hook_identify(object_type *o_ptr)
2683 return (bool)!object_is_known(o_ptr);
2686 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2688 if (object_is_known(o_ptr))
2690 return object_is_weapon_armour_ammo(o_ptr);
2694 * Identify an object in the inventory (or on the floor)
2695 * This routine does *not* automatically combine objects.
2696 * Returns TRUE if something was identified, else FALSE.
2698 bool ident_spell(bool only_equip)
2702 char o_name[MAX_NLEN];
2706 item_tester_no_ryoute = TRUE;
2709 item_tester_hook = item_tester_hook_identify_weapon_armour;
2711 item_tester_hook = item_tester_hook_identify;
2713 if (!can_get_item())
2717 item_tester_hook = object_is_weapon_armour_ammo;
2721 item_tester_hook = NULL;
2727 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2728 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2730 q = "Identify which item? ";
2731 s = "You have nothing to identify.";
2734 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2736 /* Get the item (in the pack) */
2739 o_ptr = &inventory[item];
2742 /* Get the item (on the floor) */
2745 o_ptr = &o_list[0 - item];
2749 old_known = identify_item(o_ptr);
2752 object_desc(o_name, o_ptr, 0);
2755 if (item >= INVEN_RARM)
2758 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2760 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2766 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2768 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2774 msg_format("¾²¾å: %s¡£", o_name);
2776 msg_format("On the ground: %s.", o_name);
2780 /* Auto-inscription/destroy */
2781 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2783 /* Something happened */
2789 * Mundanify an object in the inventory (or on the floor)
2790 * This routine does *not* automatically combine objects.
2791 * Returns TRUE if something was mundanified, else FALSE.
2793 bool mundane_spell(bool only_equip)
2799 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2800 item_tester_no_ryoute = TRUE;
2804 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2805 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2807 q = "Use which item? ";
2808 s = "You have nothing you can use.";
2811 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2813 /* Get the item (in the pack) */
2816 o_ptr = &inventory[item];
2819 /* Get the item (on the floor) */
2822 o_ptr = &o_list[0 - item];
2827 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2829 msg_print("There is a bright flash of light!");
2832 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2833 byte ix = o_ptr->ix; /* X-position on map, or zero */
2834 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2835 byte marked = o_ptr->marked; /* Object is marked */
2836 s16b weight = o_ptr->number * o_ptr->weight;
2837 u16b inscription = o_ptr->inscription;
2840 object_prep(o_ptr, o_ptr->k_idx);
2844 o_ptr->next_o_idx = next_o_idx;
2845 o_ptr->marked = marked;
2846 o_ptr->inscription = inscription;
2847 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2851 /* Something happened */
2857 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2859 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2862 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2864 if (!item_tester_hook_identify_fully(o_ptr))
2866 return object_is_weapon_armour_ammo(o_ptr);
2870 * Fully "identify" an object in the inventory -BEN-
2871 * This routine returns TRUE if an item was identified.
2873 bool identify_fully(bool only_equip)
2877 char o_name[MAX_NLEN];
2881 item_tester_no_ryoute = TRUE;
2883 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2885 item_tester_hook = item_tester_hook_identify_fully;
2887 if (!can_get_item())
2890 item_tester_hook = object_is_weapon_armour_ammo;
2892 item_tester_hook = NULL;
2897 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2898 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2900 q = "Identify which item? ";
2901 s = "You have nothing to identify.";
2904 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2906 /* Get the item (in the pack) */
2909 o_ptr = &inventory[item];
2912 /* Get the item (on the floor) */
2915 o_ptr = &o_list[0 - item];
2919 old_known = identify_item(o_ptr);
2921 /* Mark the item as fully known */
2922 o_ptr->ident |= (IDENT_MENTAL);
2928 object_desc(o_name, o_ptr, 0);
2931 if (item >= INVEN_RARM)
2934 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2936 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2944 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2946 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2952 msg_format("¾²¾å: %s¡£", o_name);
2954 msg_format("On the ground: %s.", o_name);
2958 /* Describe it fully */
2959 (void)screen_object(o_ptr, TRUE);
2961 /* Auto-inscription/destroy */
2962 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2972 * Hook for "get_item()". Determine if something is rechargable.
2974 bool item_tester_hook_recharge(object_type *o_ptr)
2976 /* Recharge staffs */
2977 if (o_ptr->tval == TV_STAFF) return (TRUE);
2979 /* Recharge wands */
2980 if (o_ptr->tval == TV_WAND) return (TRUE);
2982 /* Hack -- Recharge rods */
2983 if (o_ptr->tval == TV_ROD) return (TRUE);
2991 * Recharge a wand/staff/rod from the pack or on the floor.
2992 * This function has been rewritten in Oangband and ZAngband.
2994 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2995 * Chaos -- Arcane Binding --> recharge(90)
2997 * Scroll of recharging --> recharge(130)
2998 * Artifact activation/Thingol --> recharge(130)
3000 * It is harder to recharge high level, and highly charged wands,
3001 * staffs, and rods. The more wands in a stack, the more easily and
3002 * strongly they recharge. Staffs, however, each get fewer charges if
3005 * XXX XXX XXX Beware of "sliding index errors".
3007 bool recharge(int power)
3010 int recharge_strength, recharge_amount;
3019 char o_name[MAX_NLEN];
3021 /* Only accept legal items */
3022 item_tester_hook = item_tester_hook_recharge;
3026 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3027 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3029 q = "Recharge which item? ";
3030 s = "You have nothing to recharge.";
3033 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3035 /* Get the item (in the pack) */
3038 o_ptr = &inventory[item];
3041 /* Get the item (on the floor) */
3044 o_ptr = &o_list[0 - item];
3047 /* Get the object kind. */
3048 k_ptr = &k_info[o_ptr->k_idx];
3050 /* Extract the object "level" */
3051 lev = k_info[o_ptr->k_idx].level;
3054 /* Recharge a rod */
3055 if (o_ptr->tval == TV_ROD)
3057 /* Extract a recharge strength by comparing object level to power. */
3058 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3062 if (one_in_(recharge_strength))
3064 /* Activate the failure code. */
3071 /* Recharge amount */
3072 recharge_amount = (power * damroll(3, 2));
3074 /* Recharge by that amount */
3075 if (o_ptr->timeout > recharge_amount)
3076 o_ptr->timeout -= recharge_amount;
3083 /* Recharge wand/staff */
3086 /* Extract a recharge strength by comparing object level to power.
3087 * Divide up a stack of wands' charges to calculate charge penalty.
3089 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3090 recharge_strength = (100 + power - lev -
3091 (8 * o_ptr->pval / o_ptr->number)) / 15;
3093 /* All staffs, unstacked wands. */
3094 else recharge_strength = (100 + power - lev -
3095 (8 * o_ptr->pval)) / 15;
3098 if (recharge_strength < 0) recharge_strength = 0;
3101 if (one_in_(recharge_strength))
3103 /* Activate the failure code. */
3107 /* If the spell didn't backfire, recharge the wand or staff. */
3110 /* Recharge based on the standard number of charges. */
3111 recharge_amount = randint1(1 + k_ptr->pval / 2);
3113 /* Multiple wands in a stack increase recharging somewhat. */
3114 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3117 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3118 if (recharge_amount < 1) recharge_amount = 1;
3119 if (recharge_amount > 12) recharge_amount = 12;
3122 /* But each staff in a stack gets fewer additional charges,
3123 * although always at least one.
3125 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3127 recharge_amount /= o_ptr->number;
3128 if (recharge_amount < 1) recharge_amount = 1;
3131 /* Recharge the wand or staff. */
3132 o_ptr->pval += recharge_amount;
3135 /* Hack -- we no longer "know" the item */
3136 o_ptr->ident &= ~(IDENT_KNOWN);
3138 /* Hack -- we no longer think the item is empty */
3139 o_ptr->ident &= ~(IDENT_EMPTY);
3144 /* Inflict the penalties for failing a recharge. */
3147 /* Artifacts are never destroyed. */
3148 if (object_is_fixed_artifact(o_ptr))
3150 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3152 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3154 msg_format("The recharging backfires - %s is completely drained!", o_name);
3158 /* Artifact rods. */
3159 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3160 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3162 /* Artifact wands and staffs. */
3163 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3168 /* Get the object description */
3169 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3171 /*** Determine Seriousness of Failure ***/
3173 /* Mages recharge objects more safely. */
3174 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)
3176 /* 10% chance to blow up one rod, otherwise draining. */
3177 if (o_ptr->tval == TV_ROD)
3179 if (one_in_(10)) fail_type = 2;
3182 /* 75% chance to blow up one wand, otherwise draining. */
3183 else if (o_ptr->tval == TV_WAND)
3185 if (!one_in_(3)) fail_type = 2;
3188 /* 50% chance to blow up one staff, otherwise no effect. */
3189 else if (o_ptr->tval == TV_STAFF)
3191 if (one_in_(2)) fail_type = 2;
3196 /* All other classes get no special favors. */
3199 /* 33% chance to blow up one rod, otherwise draining. */
3200 if (o_ptr->tval == TV_ROD)
3202 if (one_in_(3)) fail_type = 2;
3205 /* 20% chance of the entire stack, else destroy one wand. */
3206 else if (o_ptr->tval == TV_WAND)
3208 if (one_in_(5)) fail_type = 3;
3211 /* Blow up one staff. */
3212 else if (o_ptr->tval == TV_STAFF)
3218 /*** Apply draining and destruction. ***/
3220 /* Drain object or stack of objects. */
3223 if (o_ptr->tval == TV_ROD)
3226 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3228 msg_print("The recharge backfires, draining the rod further!");
3231 if (o_ptr->timeout < 10000)
3232 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3234 else if (o_ptr->tval == TV_WAND)
3237 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3239 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3244 /* Staffs aren't drained. */
3247 /* Destroy an object or one in a stack of objects. */
3250 if (o_ptr->number > 1)
3252 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3254 msg_format("Wild magic consumes one of your %s!", o_name);
3259 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3261 msg_format("Wild magic consumes your %s!", o_name);
3265 /* Reduce rod stack maximum timeout, drain wands. */
3266 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3267 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3269 /* Reduce and describe inventory */
3272 inven_item_increase(item, -1);
3273 inven_item_describe(item);
3274 inven_item_optimize(item);
3277 /* Reduce and describe floor item */
3280 floor_item_increase(0 - item, -1);
3281 floor_item_describe(0 - item);
3282 floor_item_optimize(0 - item);
3286 /* Destroy all members of a stack of objects. */
3289 if (o_ptr->number > 1)
3291 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3293 msg_format("Wild magic consumes all your %s!", o_name);
3298 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3300 msg_format("Wild magic consumes your %s!", o_name);
3305 /* Reduce and describe inventory */
3308 inven_item_increase(item, -999);
3309 inven_item_describe(item);
3310 inven_item_optimize(item);
3313 /* Reduce and describe floor item */
3316 floor_item_increase(0 - item, -999);
3317 floor_item_describe(0 - item);
3318 floor_item_optimize(0 - item);
3324 /* Combine / Reorder the pack (later) */
3325 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3328 p_ptr->window |= (PW_INVEN);
3330 /* Something was done */
3338 bool bless_weapon(void)
3342 u32b flgs[TR_FLAG_SIZE];
3343 char o_name[MAX_NLEN];
3346 item_tester_no_ryoute = TRUE;
3348 /* Bless only weapons */
3349 item_tester_hook = object_is_weapon;
3353 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3354 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3356 q = "Bless which weapon? ";
3357 s = "You have weapon to bless.";
3360 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3363 /* Get the item (in the pack) */
3366 o_ptr = &inventory[item];
3369 /* Get the item (on the floor) */
3372 o_ptr = &o_list[0 - item];
3377 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3379 /* Extract the flags */
3380 object_flags(o_ptr, flgs);
3382 if (object_is_cursed(o_ptr))
3384 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3385 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3388 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3391 msg_format("The black aura on %s %s disrupts the blessing!",
3392 ((item >= 0) ? "your" : "the"), o_name);
3399 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3402 msg_format("A malignant aura leaves %s %s.",
3403 ((item >= 0) ? "your" : "the"), o_name);
3408 o_ptr->curse_flags = 0L;
3410 /* Hack -- Assume felt */
3411 o_ptr->ident |= (IDENT_SENSE);
3414 o_ptr->feeling = FEEL_NONE;
3416 /* Recalculate the bonuses */
3417 p_ptr->update |= (PU_BONUS);
3420 p_ptr->window |= (PW_EQUIP);
3424 * Next, we try to bless it. Artifacts have a 1/3 chance of
3425 * being blessed, otherwise, the operation simply disenchants
3426 * them, godly power negating the magic. Ok, the explanation
3427 * is silly, but otherwise priests would always bless every
3428 * artifact weapon they find. Ego weapons and normal weapons
3429 * can be blessed automatically.
3431 if (have_flag(flgs, TR_BLESSED))
3434 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3437 msg_format("%s %s %s blessed already.",
3438 ((item >= 0) ? "Your" : "The"), o_name,
3439 ((o_ptr->number > 1) ? "were" : "was"));
3445 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3449 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3452 msg_format("%s %s shine%s!",
3453 ((item >= 0) ? "Your" : "The"), o_name,
3454 ((o_ptr->number > 1) ? "" : "s"));
3457 add_flag(o_ptr->art_flags, TR_BLESSED);
3458 o_ptr->discount = 99;
3462 bool dis_happened = FALSE;
3465 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3467 msg_print("The weapon resists your blessing!");
3471 /* Disenchant tohit */
3472 if (o_ptr->to_h > 0)
3475 dis_happened = TRUE;
3478 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3480 /* Disenchant todam */
3481 if (o_ptr->to_d > 0)
3484 dis_happened = TRUE;
3487 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3489 /* Disenchant toac */
3490 if (o_ptr->to_a > 0)
3493 dis_happened = TRUE;
3496 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3501 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3503 msg_print("There is a static feeling in the air...");
3507 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3510 msg_format("%s %s %s disenchanted!",
3511 ((item >= 0) ? "Your" : "The"), o_name,
3512 ((o_ptr->number > 1) ? "were" : "was"));
3518 /* Recalculate bonuses */
3519 p_ptr->update |= (PU_BONUS);
3522 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3533 bool pulish_shield(void)
3537 u32b flgs[TR_FLAG_SIZE];
3538 char o_name[MAX_NLEN];
3541 item_tester_no_ryoute = TRUE;
3542 /* Assume enchant weapon */
3543 item_tester_tval = TV_SHIELD;
3547 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3548 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3550 q = "Pulish which weapon? ";
3551 s = "You have weapon to pulish.";
3554 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3557 /* Get the item (in the pack) */
3560 o_ptr = &inventory[item];
3563 /* Get the item (on the floor) */
3566 o_ptr = &o_list[0 - item];
3571 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3573 /* Extract the flags */
3574 object_flags(o_ptr, flgs);
3576 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3577 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3580 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3582 msg_format("%s %s shine%s!",
3583 ((item >= 0) ? "Your" : "The"), o_name,
3584 ((o_ptr->number > 1) ? "" : "s"));
3586 o_ptr->name2 = EGO_REFLECTION;
3587 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3589 o_ptr->discount = 99;
3590 chg_virtue(V_ENCHANT, 2);
3596 if (flush_failure) flush();
3599 msg_print("¼ºÇÔ¤·¤¿¡£");
3601 msg_print("Failed.");
3604 chg_virtue(V_ENCHANT, -2);
3613 * Potions "smash open" and cause an area effect when
3614 * (1) they are shattered while in the player's inventory,
3615 * due to cold (etc) attacks;
3616 * (2) they are thrown at a monster, or obstacle;
3617 * (3) they are shattered by a "cold ball" or other such spell
3618 * while lying on the floor.
3621 * who --- who caused the potion to shatter (0=player)
3622 * potions that smash on the floor are assumed to
3623 * be caused by no-one (who = 1), as are those that
3624 * shatter inside the player inventory.
3625 * (Not anymore -- I changed this; TY)
3626 * y, x --- coordinates of the potion (or player if
3627 * the potion was in her inventory);
3628 * o_ptr --- pointer to the potion object.
3630 bool potion_smash_effect(int who, int y, int x, int k_idx)
3637 object_kind *k_ptr = &k_info[k_idx];
3639 switch (k_ptr->sval)
3641 case SV_POTION_SALT_WATER:
3642 case SV_POTION_SLIME_MOLD:
3643 case SV_POTION_LOSE_MEMORIES:
3644 case SV_POTION_DEC_STR:
3645 case SV_POTION_DEC_INT:
3646 case SV_POTION_DEC_WIS:
3647 case SV_POTION_DEC_DEX:
3648 case SV_POTION_DEC_CON:
3649 case SV_POTION_DEC_CHR:
3650 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3651 case SV_POTION_APPLE_JUICE:
3654 case SV_POTION_INFRAVISION:
3655 case SV_POTION_DETECT_INVIS:
3656 case SV_POTION_SLOW_POISON:
3657 case SV_POTION_CURE_POISON:
3658 case SV_POTION_BOLDNESS:
3659 case SV_POTION_RESIST_HEAT:
3660 case SV_POTION_RESIST_COLD:
3661 case SV_POTION_HEROISM:
3662 case SV_POTION_BESERK_STRENGTH:
3663 case SV_POTION_RES_STR:
3664 case SV_POTION_RES_INT:
3665 case SV_POTION_RES_WIS:
3666 case SV_POTION_RES_DEX:
3667 case SV_POTION_RES_CON:
3668 case SV_POTION_RES_CHR:
3669 case SV_POTION_INC_STR:
3670 case SV_POTION_INC_INT:
3671 case SV_POTION_INC_WIS:
3672 case SV_POTION_INC_DEX:
3673 case SV_POTION_INC_CON:
3674 case SV_POTION_INC_CHR:
3675 case SV_POTION_AUGMENTATION:
3676 case SV_POTION_ENLIGHTENMENT:
3677 case SV_POTION_STAR_ENLIGHTENMENT:
3678 case SV_POTION_SELF_KNOWLEDGE:
3679 case SV_POTION_EXPERIENCE:
3680 case SV_POTION_RESISTANCE:
3681 case SV_POTION_INVULNERABILITY:
3682 case SV_POTION_NEW_LIFE:
3683 /* All of the above potions have no effect when shattered */
3685 case SV_POTION_SLOWNESS:
3690 case SV_POTION_POISON:
3695 case SV_POTION_BLINDNESS:
3699 case SV_POTION_CONFUSION: /* Booze */
3703 case SV_POTION_SLEEP:
3707 case SV_POTION_RUINATION:
3708 case SV_POTION_DETONATIONS:
3710 dam = damroll(25, 25);
3713 case SV_POTION_DEATH:
3714 dt = GF_DEATH_RAY; /* !! */
3715 dam = k_ptr->level * 10;
3719 case SV_POTION_SPEED:
3722 case SV_POTION_CURE_LIGHT:
3724 dam = damroll(2, 3);
3726 case SV_POTION_CURE_SERIOUS:
3728 dam = damroll(4, 3);
3730 case SV_POTION_CURE_CRITICAL:
3731 case SV_POTION_CURING:
3733 dam = damroll(6, 3);
3735 case SV_POTION_HEALING:
3737 dam = damroll(10, 10);
3739 case SV_POTION_RESTORE_EXP:
3744 case SV_POTION_LIFE:
3746 dam = damroll(50, 50);
3749 case SV_POTION_STAR_HEALING:
3751 dam = damroll(50, 50);
3754 case SV_POTION_RESTORE_MANA: /* MANA */
3756 dam = damroll(10, 10);
3763 (void)project(who, radius, y, x, dam, dt,
3764 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3766 /* XXX those potions that explode need to become "known" */
3772 * Hack -- Display all known spells in a window
3774 * XXX XXX XXX Need to analyze size of the window.
3776 * XXX XXX XXX Need more color coding.
3778 void display_spell_list(void)
3791 /* They have too many spells to list */
3792 if (p_ptr->pclass == CLASS_SORCERER) return;
3793 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3795 /* mind.c type classes */
3796 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3797 (p_ptr->pclass == CLASS_BERSERKER) ||
3798 (p_ptr->pclass == CLASS_NINJA) ||
3799 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3800 (p_ptr->pclass == CLASS_FORCETRAINER))
3806 int plev = p_ptr->lev;
3812 bool use_hp = FALSE;
3814 /* Display a list of spells */
3817 put_str("̾Á°", y, x + 5);
3818 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3820 put_str("Name", y, x + 5);
3821 put_str("Lv Mana Fail Info", y, x + 35);
3824 switch(p_ptr->pclass)
3826 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3827 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3828 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3829 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3830 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3831 default: use_mind = 0;break;
3834 /* Dump the spells */
3835 for (i = 0; i < MAX_MIND_POWERS; i++)
3837 byte a = TERM_WHITE;
3839 /* Access the available spell */
3840 spell = mind_powers[use_mind].info[i];
3841 if (spell.min_lev > plev) break;
3843 /* Get the failure rate */
3844 chance = spell.fail;
3846 /* Reduce failure rate by "effective" level adjustment */
3847 chance -= 3 * (p_ptr->lev - spell.min_lev);
3849 /* Reduce failure rate by INT/WIS adjustment */
3850 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3854 /* Not enough mana to cast */
3855 if (spell.mana_cost > p_ptr->csp)
3857 chance += 5 * (spell.mana_cost - p_ptr->csp);
3863 /* Not enough hp to cast */
3864 if (spell.mana_cost > p_ptr->chp)
3871 /* Extract the minimum failure rate */
3872 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3874 /* Minimum failure rate */
3875 if (chance < minfail) chance = minfail;
3877 /* Stunning makes spells harder */
3878 if (p_ptr->stun > 50) chance += 25;
3879 else if (p_ptr->stun) chance += 15;
3881 /* Always a 5 percent chance of working */
3882 if (chance > 95) chance = 95;
3885 mindcraft_info(comment, use_mind, i);
3887 /* Dump the spell */
3888 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3890 spell.min_lev, spell.mana_cost, chance, comment);
3892 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3897 /* Cannot read spellbooks */
3898 if (REALM_NONE == p_ptr->realm1) return;
3900 /* Normal spellcaster with books */
3903 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3907 /* Reset vertical */
3910 /* Vertical location */
3911 y = (j < 3) ? 0 : (m[j - 3] + 2);
3913 /* Horizontal location */
3917 for (i = 0; i < 32; i++)
3919 byte a = TERM_WHITE;
3921 /* Access the spell */
3922 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3924 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3928 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3931 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3934 if (s_ptr->slevel >= 99)
3938 strcpy(name, "(ȽÆÉÉÔǽ)");
3940 strcpy(name, "(illegible)");
3950 ((p_ptr->spell_forgotten1 & (1L << i))) :
3951 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3958 else if (!((j < 1) ?
3959 (p_ptr->spell_learned1 & (1L << i)) :
3960 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3967 else if (!((j < 1) ?
3968 (p_ptr->spell_worked1 & (1L << i)) :
3969 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3975 /* Dump the spell --(-- */
3976 sprintf(out_val, "%c/%c) %-20.20s",
3977 I2A(n / 8), I2A(n % 8), name);
3982 /* Dump onto the window */
3983 Term_putstr(x, m[j], -1, a, out_val);
3993 * Returns experience of a spell
3995 s16b experience_of_spell(int spell, int use_realm)
3997 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3998 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3999 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4000 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4006 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4008 int mod_need_mana(int need_mana, int spell, int realm)
4010 #define MANA_CONST 2400
4012 #define DEC_MANA_DIV 3
4015 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4018 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4019 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4021 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4022 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4023 need_mana /= MANA_CONST * MANA_DIV;
4024 if (need_mana < 1) need_mana = 1;
4027 /* Non-realm magic */
4030 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4042 * Modify spell fail rate
4043 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4045 int mod_spell_chance_1(int chance)
4047 chance += p_ptr->to_m_chance;
4049 if (p_ptr->heavy_spell) chance += 20;
4051 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4052 else if (p_ptr->easy_spell) chance -= 3;
4053 else if (p_ptr->dec_mana) chance -= 2;
4060 * Modify spell fail rate (as "suffix" process)
4061 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4062 * Note: variable "chance" cannot be negative.
4064 int mod_spell_chance_2(int chance)
4066 if (p_ptr->dec_mana) chance--;
4068 if (p_ptr->heavy_spell) chance += 5;
4070 return MAX(chance, 0);
4075 * Returns spell chance of failure for spell -RAK-
4077 s16b spell_chance(int spell, int use_realm)
4079 int chance, minfail;
4082 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4085 /* Paranoia -- must be literate */
4086 if (!mp_ptr->spell_book) return (100);
4088 if (use_realm == REALM_HISSATSU) return 0;
4090 /* Access the spell */
4091 if (!is_magic(use_realm))
4093 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4097 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4100 /* Extract the base spell failure rate */
4101 chance = s_ptr->sfail;
4103 /* Reduce failure rate by "effective" level adjustment */
4104 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4106 /* Reduce failure rate by INT/WIS adjustment */
4107 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4110 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4112 /* Extract mana consumption rate */
4113 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4115 /* Not enough mana to cast */
4116 if (need_mana > p_ptr->csp)
4118 chance += 5 * (need_mana - p_ptr->csp);
4121 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4123 /* Extract the minimum failure rate */
4124 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4127 * Non mage/priest characters never get too good
4128 * (added high mage, mindcrafter)
4130 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4132 if (minfail < 5) minfail = 5;
4135 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4136 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4137 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4139 chance = mod_spell_chance_1(chance);
4141 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4142 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4143 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4145 /* Minimum failure rate */
4146 if (chance < minfail) chance = minfail;
4148 /* Stunning makes spells harder */
4149 if (p_ptr->stun > 50) chance += 25;
4150 else if (p_ptr->stun) chance += 15;
4152 /* Always a 5 percent chance of working */
4153 if (chance > 95) chance = 95;
4155 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4156 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4158 s16b exp = experience_of_spell(spell, use_realm);
4159 if (exp >= SPELL_EXP_EXPERT) chance--;
4160 if (exp >= SPELL_EXP_MASTER) chance--;
4163 /* Return the chance */
4164 return mod_spell_chance_2(chance);
4170 * Determine if a spell is "okay" for the player to cast or study
4171 * The spell must be legible, not forgotten, and also, to cast,
4172 * it must be known, and to study, it must not be known.
4174 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4178 /* Access the spell */
4179 if (!is_magic(use_realm))
4181 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4185 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4188 /* Spell is illegal */
4189 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4191 /* Spell is forgotten */
4192 if ((use_realm == p_ptr->realm2) ?
4193 (p_ptr->spell_forgotten2 & (1L << spell)) :
4194 (p_ptr->spell_forgotten1 & (1L << spell)))
4200 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4201 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4203 /* Spell is learned */
4204 if ((use_realm == p_ptr->realm2) ?
4205 (p_ptr->spell_learned2 & (1L << spell)) :
4206 (p_ptr->spell_learned1 & (1L << spell)))
4209 return (!study_pray);
4212 /* Okay to study, not to cast */
4218 * Print a list of spells (for browsing or casting or viewing)
4220 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4222 int i, spell, exp_level, increment = 64;
4234 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4236 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4238 msg_print("Warning! print_spells called with null realm");
4242 /* Title the list */
4244 if (use_realm == REALM_HISSATSU)
4246 strcpy(buf," Lv MP");
4248 strcpy(buf," Lv SP");
4252 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4254 strcpy(buf,"Profic Lv SP Fail Effect");
4258 put_str("̾Á°", y, x + 5);
4259 put_str(buf, y, x + 29);
4261 put_str("Name", y, x + 5);
4262 put_str(buf, y, x + 29);
4265 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4266 else if (use_realm == p_ptr->realm1) increment = 0;
4267 else if (use_realm == p_ptr->realm2) increment = 32;
4269 /* Dump the spells */
4270 for (i = 0; i < num; i++)
4272 /* Access the spell */
4275 /* Access the spell */
4276 if (!is_magic(use_realm))
4278 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4282 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4285 if (use_realm == REALM_HISSATSU)
4286 need_mana = s_ptr->smana;
4289 s16b exp = experience_of_spell(spell, use_realm);
4291 /* Extract mana consumption rate */
4292 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4294 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4295 else exp_level = spell_exp_level(exp);
4298 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4299 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4300 else if (s_ptr->slevel >= 99) max = TRUE;
4301 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4303 strncpy(ryakuji, exp_level_str[exp_level], 4);
4308 if (use_menu && target_spell)
4310 if (i == (target_spell-1))
4312 strcpy(out_val, " ¡Õ ");
4314 strcpy(out_val, " > ");
4317 strcpy(out_val, " ");
4319 else sprintf(out_val, " %c) ", I2A(i));
4320 /* Skip illegible spells */
4321 if (s_ptr->slevel >= 99)
4324 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4326 strcat(out_val, format("%-30s", "(illegible)"));
4329 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4333 /* XXX XXX Could label spells above the players level */
4335 /* Get extra info */
4336 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4341 /* Assume spell is known and tried */
4342 line_attr = TERM_WHITE;
4344 /* Analyze the spell */
4345 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4347 if (s_ptr->slevel > p_ptr->max_plv)
4352 comment = "unknown";
4355 line_attr = TERM_L_BLUE;
4357 else if (s_ptr->slevel > p_ptr->lev)
4362 comment = "forgotten";
4365 line_attr = TERM_YELLOW;
4368 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4373 comment = "unknown";
4376 line_attr = TERM_L_BLUE;
4378 else if ((use_realm == p_ptr->realm1) ?
4379 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4380 ((p_ptr->spell_forgotten2 & (1L << spell))))
4385 comment = "forgotten";
4388 line_attr = TERM_YELLOW;
4390 else if (!((use_realm == p_ptr->realm1) ?
4391 (p_ptr->spell_learned1 & (1L << spell)) :
4392 (p_ptr->spell_learned2 & (1L << spell))))
4397 comment = "unknown";
4400 line_attr = TERM_L_BLUE;
4402 else if (!((use_realm == p_ptr->realm1) ?
4403 (p_ptr->spell_worked1 & (1L << spell)) :
4404 (p_ptr->spell_worked2 & (1L << spell))))
4409 comment = "untried";
4412 line_attr = TERM_L_GREEN;
4415 /* Dump the spell --(-- */
4416 if (use_realm == REALM_HISSATSU)
4418 strcat(out_val, format("%-25s %2d %4d",
4419 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4420 s_ptr->slevel, need_mana));
4424 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4425 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4426 (max ? '!' : ' '), ryakuji,
4427 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4429 c_prt(line_attr, out_val, y + i + 1, x);
4432 /* Clear the bottom line */
4433 prt("", y + i + 1, x);
4438 * Note that amulets, rods, and high-level spell books are immune
4439 * to "inventory damage" of any kind. Also sling ammo and shovels.
4444 * Does a given class of objects (usually) hate acid?
4445 * Note that acid can either melt or corrode something.
4447 bool hates_acid(object_type *o_ptr)
4449 /* Analyze the type */
4450 switch (o_ptr->tval)
4452 /* Wearable items */
4472 /* Staffs/Scrolls are wood/paper */
4485 /* Junk is useless */
4499 * Does a given object (usually) hate electricity?
4501 bool hates_elec(object_type *o_ptr)
4503 switch (o_ptr->tval)
4517 * Does a given object (usually) hate fire?
4518 * Hafted/Polearm weapons have wooden shafts.
4519 * Arrows/Bows are mostly wooden.
4521 bool hates_fire(object_type *o_ptr)
4523 /* Analyze the type */
4524 switch (o_ptr->tval)
4542 case TV_SORCERY_BOOK:
4543 case TV_NATURE_BOOK:
4547 case TV_ARCANE_BOOK:
4549 case TV_DAEMON_BOOK:
4550 case TV_CRUSADE_BOOK:
4552 case TV_HISSATSU_BOOK:
4563 /* Staffs/Scrolls burn */
4576 * Does a given object (usually) hate cold?
4578 bool hates_cold(object_type *o_ptr)
4580 switch (o_ptr->tval)
4597 int set_acid_destroy(object_type *o_ptr)
4599 u32b flgs[TR_FLAG_SIZE];
4600 if (!hates_acid(o_ptr)) return (FALSE);
4601 object_flags(o_ptr, flgs);
4602 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4610 int set_elec_destroy(object_type *o_ptr)
4612 u32b flgs[TR_FLAG_SIZE];
4613 if (!hates_elec(o_ptr)) return (FALSE);
4614 object_flags(o_ptr, flgs);
4615 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4623 int set_fire_destroy(object_type *o_ptr)
4625 u32b flgs[TR_FLAG_SIZE];
4626 if (!hates_fire(o_ptr)) return (FALSE);
4627 object_flags(o_ptr, flgs);
4628 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4636 int set_cold_destroy(object_type *o_ptr)
4638 u32b flgs[TR_FLAG_SIZE];
4639 if (!hates_cold(o_ptr)) return (FALSE);
4640 object_flags(o_ptr, flgs);
4641 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4647 * Destroys a type of item on a given percent chance
4648 * Note that missiles are no longer necessarily all destroyed
4649 * Destruction taken from "melee.c" code for "stealing".
4650 * New-style wands and rods handled correctly. -LM-
4651 * Returns number of items destroyed.
4653 int inven_damage(inven_func typ, int perc)
4657 char o_name[MAX_NLEN];
4659 /* Multishadow effects is determined by turn */
4660 if( p_ptr->multishadow && (turn & 1) )return 0;
4662 if (p_ptr->inside_arena) return 0;
4664 /* Count the casualties */
4667 /* Scan through the slots backwards */
4668 for (i = 0; i < INVEN_PACK; i++)
4670 o_ptr = &inventory[i];
4672 /* Skip non-objects */
4673 if (!o_ptr->k_idx) continue;
4675 /* Hack -- for now, skip artifacts */
4676 if (object_is_artifact(o_ptr)) continue;
4678 /* Give this item slot a shot at death */
4681 /* Count the casualties */
4682 for (amt = j = 0; j < o_ptr->number; ++j)
4684 if (randint0(100) < perc) amt++;
4687 /* Some casualities */
4690 /* Get a description */
4691 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4695 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4697 msg_format("%sour %s (%c) %s destroyed!",
4701 o_name, index_to_label(i),
4702 ((o_ptr->number > 1) ?
4703 ((amt == o_ptr->number) ? "Á´Éô" :
4704 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4706 ((o_ptr->number > 1) ?
4707 ((amt == o_ptr->number) ? "All of y" :
4708 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4709 o_name, index_to_label(i),
4710 ((amt > 1) ? "were" : "was"));
4714 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4715 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4718 /* Potions smash open */
4719 if (object_is_potion(o_ptr))
4721 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4724 /* Reduce the charges of rods/wands */
4725 reduce_charges(o_ptr, amt);
4727 /* Destroy "amt" items */
4728 inven_item_increase(i, -amt);
4729 inven_item_optimize(i);
4731 /* Count the casualties */
4737 /* Return the casualty count */
4743 * Acid has hit the player, attempt to affect some armor.
4745 * Note that the "base armor" of an object never changes.
4747 * If any armor is damaged (or resists), the player takes less damage.
4749 static int minus_ac(void)
4751 object_type *o_ptr = NULL;
4752 u32b flgs[TR_FLAG_SIZE];
4753 char o_name[MAX_NLEN];
4756 /* Pick a (possibly empty) inventory slot */
4757 switch (randint1(7))
4759 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4760 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4761 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4762 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4763 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4764 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4765 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4768 /* Nothing to damage */
4769 if (!o_ptr->k_idx) return (FALSE);
4771 if (!object_is_armour(o_ptr)) return (FALSE);
4773 /* No damage left to be done */
4774 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4778 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4780 /* Extract the flags */
4781 object_flags(o_ptr, flgs);
4783 /* Object resists */
4784 if (have_flag(flgs, TR_IGNORE_ACID))
4787 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
4789 msg_format("Your %s is unaffected!", o_name);
4798 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
4800 msg_format("Your %s is damaged!", o_name);
4804 /* Damage the item */
4807 /* Calculate bonuses */
4808 p_ptr->update |= (PU_BONUS);
4811 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4815 /* Item was damaged */
4821 * Hurt the player with Acid
4823 int acid_dam(int dam, cptr kb_str, int monspell)
4826 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4827 bool double_resist = IS_OPPOSE_ACID();
4829 /* Total Immunity */
4830 if (p_ptr->immune_acid || (dam <= 0))
4832 learn_spell(monspell);
4836 /* Vulnerability (Ouch!) */
4837 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4838 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4840 /* Resist the damage */
4841 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4842 if (double_resist) dam = (dam + 2) / 3;
4844 if ((!(double_resist || p_ptr->resist_acid)) &&
4845 one_in_(HURT_CHANCE))
4846 (void)do_dec_stat(A_CHR);
4848 /* If any armor gets hit, defend the player */
4849 if (minus_ac()) dam = (dam + 1) / 2;
4852 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4854 /* Inventory damage */
4855 if (!(double_resist && p_ptr->resist_acid))
4856 inven_damage(set_acid_destroy, inv);
4862 * Hurt the player with electricity
4864 int elec_dam(int dam, cptr kb_str, int monspell)
4867 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4868 bool double_resist = IS_OPPOSE_ELEC();
4870 /* Total immunity */
4871 if (p_ptr->immune_elec || (dam <= 0))
4873 learn_spell(monspell);
4877 /* Vulnerability (Ouch!) */
4878 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4879 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4880 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4882 /* Resist the damage */
4883 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4884 if (double_resist) dam = (dam + 2) / 3;
4886 if ((!(double_resist || p_ptr->resist_elec)) &&
4887 one_in_(HURT_CHANCE))
4888 (void)do_dec_stat(A_DEX);
4891 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4893 /* Inventory damage */
4894 if (!(double_resist && p_ptr->resist_elec))
4895 inven_damage(set_elec_destroy, inv);
4902 * Hurt the player with Fire
4904 int fire_dam(int dam, cptr kb_str, int monspell)
4907 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4908 bool double_resist = IS_OPPOSE_FIRE();
4910 /* Totally immune */
4911 if (p_ptr->immune_fire || (dam <= 0))
4913 learn_spell(monspell);
4917 /* Vulnerability (Ouch!) */
4918 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4919 if (prace_is_(RACE_ENT)) dam += dam / 3;
4920 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4922 /* Resist the damage */
4923 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4924 if (double_resist) dam = (dam + 2) / 3;
4926 if ((!(double_resist || p_ptr->resist_fire)) &&
4927 one_in_(HURT_CHANCE))
4928 (void)do_dec_stat(A_STR);
4931 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4933 /* Inventory damage */
4934 if (!(double_resist && p_ptr->resist_fire))
4935 inven_damage(set_fire_destroy, inv);
4942 * Hurt the player with Cold
4944 int cold_dam(int dam, cptr kb_str, int monspell)
4947 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4948 bool double_resist = IS_OPPOSE_COLD();
4950 /* Total immunity */
4951 if (p_ptr->immune_cold || (dam <= 0))
4953 learn_spell(monspell);
4957 /* Vulnerability (Ouch!) */
4958 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4959 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4961 /* Resist the damage */
4962 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4963 if (double_resist) dam = (dam + 2) / 3;
4965 if ((!(double_resist || p_ptr->resist_cold)) &&
4966 one_in_(HURT_CHANCE))
4967 (void)do_dec_stat(A_STR);
4970 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4972 /* Inventory damage */
4973 if (!(double_resist && p_ptr->resist_cold))
4974 inven_damage(set_cold_destroy, inv);
4980 bool rustproof(void)
4984 char o_name[MAX_NLEN];
4987 item_tester_no_ryoute = TRUE;
4988 /* Select a piece of armour */
4989 item_tester_hook = object_is_armour;
4993 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
4994 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4996 q = "Rustproof which piece of armour? ";
4997 s = "You have nothing to rustproof.";
5000 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5002 /* Get the item (in the pack) */
5005 o_ptr = &inventory[item];
5008 /* Get the item (on the floor) */
5011 o_ptr = &o_list[0 - item];
5016 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5018 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5020 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
5023 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5025 msg_format("%s %s look%s as good as new!",
5026 ((item >= 0) ? "Your" : "The"), o_name,
5027 ((o_ptr->number > 1) ? "" : "s"));
5034 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5036 msg_format("%s %s %s now protected against corrosion.",
5037 ((item >= 0) ? "Your" : "The"), o_name,
5038 ((o_ptr->number > 1) ? "are" : "is"));
5049 * Curse the players armor
5051 bool curse_armor(void)
5056 char o_name[MAX_NLEN];
5059 /* Curse the body armor */
5060 o_ptr = &inventory[INVEN_BODY];
5062 /* Nothing to curse */
5063 if (!o_ptr->k_idx) return (FALSE);
5067 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5069 /* Attempt a saving throw for artifacts */
5070 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
5074 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5075 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5077 msg_format("A %s tries to %s, but your %s resists the effects!",
5078 "terrible black aura", "surround your armor", o_name);
5083 /* not artifact or failed save... */
5088 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5090 msg_format("A terrible black aura blasts your %s!", o_name);
5093 chg_virtue(V_ENCHANT, -5);
5095 /* Blast the armor */
5097 o_ptr->name2 = EGO_BLASTED;
5098 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5105 for (i = 0; i < TR_FLAG_SIZE; i++)
5106 o_ptr->art_flags[i] = 0;
5109 o_ptr->curse_flags = TRC_CURSED;
5112 o_ptr->ident |= (IDENT_BROKEN);
5114 /* Recalculate bonuses */
5115 p_ptr->update |= (PU_BONUS);
5117 /* Recalculate mana */
5118 p_ptr->update |= (PU_MANA);
5121 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5129 * Curse the players weapon
5131 bool curse_weapon(bool force, int slot)
5137 char o_name[MAX_NLEN];
5140 /* Curse the weapon */
5141 o_ptr = &inventory[slot];
5143 /* Nothing to curse */
5144 if (!o_ptr->k_idx) return (FALSE);
5148 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5150 /* Attempt a saving throw */
5151 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5155 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5156 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5158 msg_format("A %s tries to %s, but your %s resists the effects!",
5159 "terrible black aura", "surround your weapon", o_name);
5164 /* not artifact or failed save... */
5169 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5171 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5174 chg_virtue(V_ENCHANT, -5);
5176 /* Shatter the weapon */
5178 o_ptr->name2 = EGO_SHATTERED;
5179 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5180 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5186 for (i = 0; i < TR_FLAG_SIZE; i++)
5187 o_ptr->art_flags[i] = 0;
5191 o_ptr->curse_flags = TRC_CURSED;
5194 o_ptr->ident |= (IDENT_BROKEN);
5196 /* Recalculate bonuses */
5197 p_ptr->update |= (PU_BONUS);
5199 /* Recalculate mana */
5200 p_ptr->update |= (PU_MANA);
5203 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5212 * Enchant some bolts
5214 bool brand_bolts(void)
5218 /* Use the first acceptable bolts */
5219 for (i = 0; i < INVEN_PACK; i++)
5221 object_type *o_ptr = &inventory[i];
5223 /* Skip non-bolts */
5224 if (o_ptr->tval != TV_BOLT) continue;
5226 /* Skip artifacts and ego-items */
5227 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5230 /* Skip cursed/broken items */
5231 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5234 if (randint0(100) < 75) continue;
5238 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5240 msg_print("Your bolts are covered in a fiery aura!");
5245 o_ptr->name2 = EGO_FLAME;
5248 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5255 if (flush_failure) flush();
5259 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5261 msg_print("The fiery enchantment failed.");
5271 * Helper function -- return a "nearby" race for polymorphing
5273 * Note that this function is one of the more "dangerous" ones...
5275 static s16b poly_r_idx(int r_idx)
5277 monster_race *r_ptr = &r_info[r_idx];
5279 int i, r, lev1, lev2;
5281 /* Hack -- Uniques/Questors never polymorph */
5282 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5283 (r_ptr->flags1 & RF1_QUESTOR))
5286 /* Allowable range of "levels" for resulting monster */
5287 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5288 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5290 /* Pick a (possibly new) non-unique race */
5291 for (i = 0; i < 1000; i++)
5293 /* Pick a new race, using a level calculation */
5294 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5296 /* Handle failure */
5302 /* Ignore unique monsters */
5303 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5305 /* Ignore monsters with incompatible levels */
5306 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5308 /* Use that index */
5320 bool polymorph_monster(int y, int x)
5322 cave_type *c_ptr = &cave[y][x];
5323 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5324 bool polymorphed = FALSE;
5326 int old_r_idx = m_ptr->r_idx;
5327 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5328 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5329 monster_type back_m;
5331 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5333 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5335 /* Memorize the monster before polymorphing */
5338 /* Pick a "new" monster race */
5339 new_r_idx = poly_r_idx(old_r_idx);
5341 /* Handle polymorph */
5342 if (new_r_idx != old_r_idx)
5346 /* Get the monsters attitude */
5347 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5348 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5349 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5351 /* "Kill" the "old" monster */
5352 delete_monster_idx(c_ptr->m_idx);
5354 /* Create a new monster (no groups) */
5355 if (place_monster_aux(0, y, x, new_r_idx, mode))
5362 /* Placing the new monster failed */
5363 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5364 m_list[hack_m_idx_ii] = back_m;
5367 if (targeted) target_who = hack_m_idx_ii;
5368 if (health_tracked) health_track(hack_m_idx_ii);
5378 static bool dimension_door_aux(int x, int y)
5380 int plev = p_ptr->lev;
5382 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5384 if (!cave_player_teleportable_bold(y, x, FALSE, FALSE) ||
5385 (distance(y, x, py, px) > plev / 2 + 10) ||
5386 (!randint0(plev / 10 + 10)))
5388 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5389 teleport_player((plev + 2) * 2, TRUE);
5396 teleport_player_to(y, x, TRUE, FALSE);
5407 bool dimension_door(void)
5411 /* Rerutn FALSE if cancelled */
5412 if (!tgt_pt(&x, &y)) return FALSE;
5414 if (dimension_door_aux(x, y)) return TRUE;
5417 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5419 msg_print("You fail to exit the astral plane correctly!");
5427 * Mirror Master's Dimension Door
5429 bool mirror_tunnel(void)
5433 /* Rerutn FALSE if cancelled */
5434 if (!tgt_pt(&x, &y)) return FALSE;
5436 if (dimension_door_aux(x, y)) return TRUE;
5439 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5441 msg_print("You fail to pass the mirror plane correctly!");
5448 bool eat_magic(int power)
5450 object_type * o_ptr;
5453 int recharge_strength = 0;
5459 char o_name[MAX_NLEN];
5461 item_tester_hook = item_tester_hook_recharge;
5465 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5466 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5468 q = "Drain which item? ";
5469 s = "You have nothing to drain.";
5472 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5476 o_ptr = &inventory[item];
5480 o_ptr = &o_list[0 - item];
5483 k_ptr = &k_info[o_ptr->k_idx];
5484 lev = k_info[o_ptr->k_idx].level;
5486 if (o_ptr->tval == TV_ROD)
5488 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5491 if (one_in_(recharge_strength))
5493 /* Activate the failure code. */
5498 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5501 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5503 msg_print("You can't absorb energy from a discharged rod.");
5510 o_ptr->timeout += k_ptr->pval;
5516 /* All staffs, wands. */
5517 recharge_strength = (100 + power - lev) / 15;
5520 if (recharge_strength < 0) recharge_strength = 0;
5523 if (one_in_(recharge_strength))
5525 /* Activate the failure code. */
5530 if (o_ptr->pval > 0)
5532 p_ptr->csp += lev / 2;
5535 /* XXX Hack -- unstack if necessary */
5536 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5541 /* Get local object */
5544 /* Obtain a local object */
5545 object_copy(q_ptr, o_ptr);
5547 /* Modify quantity */
5550 /* Restore the charges */
5553 /* Unstack the used item */
5555 p_ptr->total_weight -= q_ptr->weight;
5556 item = inven_carry(q_ptr);
5560 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5562 msg_print("You unstack your staff.");
5570 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5572 msg_print("There's no energy there to absorb!");
5576 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5580 /* Inflict the penalties for failing a recharge. */
5583 /* Artifacts are never destroyed. */
5584 if (object_is_fixed_artifact(o_ptr))
5586 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5588 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5590 msg_format("The recharging backfires - %s is completely drained!", o_name);
5594 /* Artifact rods. */
5595 if (o_ptr->tval == TV_ROD)
5596 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5598 /* Artifact wands and staffs. */
5599 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5604 /* Get the object description */
5605 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5607 /*** Determine Seriousness of Failure ***/
5609 /* Mages recharge objects more safely. */
5610 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)
5612 /* 10% chance to blow up one rod, otherwise draining. */
5613 if (o_ptr->tval == TV_ROD)
5615 if (one_in_(10)) fail_type = 2;
5618 /* 75% chance to blow up one wand, otherwise draining. */
5619 else if (o_ptr->tval == TV_WAND)
5621 if (!one_in_(3)) fail_type = 2;
5624 /* 50% chance to blow up one staff, otherwise no effect. */
5625 else if (o_ptr->tval == TV_STAFF)
5627 if (one_in_(2)) fail_type = 2;
5632 /* All other classes get no special favors. */
5635 /* 33% chance to blow up one rod, otherwise draining. */
5636 if (o_ptr->tval == TV_ROD)
5638 if (one_in_(3)) fail_type = 2;
5641 /* 20% chance of the entire stack, else destroy one wand. */
5642 else if (o_ptr->tval == TV_WAND)
5644 if (one_in_(5)) fail_type = 3;
5647 /* Blow up one staff. */
5648 else if (o_ptr->tval == TV_STAFF)
5654 /*** Apply draining and destruction. ***/
5656 /* Drain object or stack of objects. */
5659 if (o_ptr->tval == TV_ROD)
5662 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5664 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5667 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5669 else if (o_ptr->tval == TV_WAND)
5672 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5674 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5679 /* Staffs aren't drained. */
5682 /* Destroy an object or one in a stack of objects. */
5685 if (o_ptr->number > 1)
5688 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5690 msg_format("Wild magic consumes one of your %s!", o_name);
5693 /* Reduce rod stack maximum timeout, drain wands. */
5694 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5695 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5700 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5702 msg_format("Wild magic consumes your %s!", o_name);
5705 /* Reduce and describe inventory */
5708 inven_item_increase(item, -1);
5709 inven_item_describe(item);
5710 inven_item_optimize(item);
5713 /* Reduce and describe floor item */
5716 floor_item_increase(0 - item, -1);
5717 floor_item_describe(0 - item);
5718 floor_item_optimize(0 - item);
5722 /* Destroy all members of a stack of objects. */
5725 if (o_ptr->number > 1)
5727 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5729 msg_format("Wild magic consumes all your %s!", o_name);
5734 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5736 msg_format("Wild magic consumes your %s!", o_name);
5741 /* Reduce and describe inventory */
5744 inven_item_increase(item, -999);
5745 inven_item_describe(item);
5746 inven_item_optimize(item);
5749 /* Reduce and describe floor item */
5752 floor_item_increase(0 - item, -999);
5753 floor_item_describe(0 - item);
5754 floor_item_optimize(0 - item);
5760 if (p_ptr->csp > p_ptr->msp)
5762 p_ptr->csp = p_ptr->msp;
5765 /* Redraw mana and hp */
5766 p_ptr->redraw |= (PR_MANA);
5768 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5769 p_ptr->window |= (PW_INVEN);
5775 bool summon_kin_player(int level, int y, int x, u32b mode)
5777 bool pet = (bool)(mode & PM_FORCE_PET);
5778 if (!pet) mode |= PM_NO_PET;
5780 switch (p_ptr->mimic_form)
5783 switch (p_ptr->prace)
5787 case RACE_BARBARIAN:
5790 summon_kin_type = 'p';
5800 case RACE_MIND_FLAYER:
5803 summon_kin_type = 'h';
5806 summon_kin_type = 'o';
5808 case RACE_HALF_TROLL:
5809 summon_kin_type = 'T';
5811 case RACE_HALF_OGRE:
5812 summon_kin_type = 'O';
5814 case RACE_HALF_GIANT:
5815 case RACE_HALF_TITAN:
5817 summon_kin_type = 'P';
5820 summon_kin_type = 'y';
5823 summon_kin_type = 'K';
5826 summon_kin_type = 'k';
5829 if (one_in_(13)) summon_kin_type = 'U';
5830 else summon_kin_type = 'u';
5832 case RACE_DRACONIAN:
5833 summon_kin_type = 'd';
5837 summon_kin_type = 'g';
5840 if (one_in_(13)) summon_kin_type = 'L';
5841 else summon_kin_type = 's';
5844 summon_kin_type = 'z';
5847 summon_kin_type = 'V';
5850 summon_kin_type = 'G';
5853 summon_kin_type = 'I';
5856 summon_kin_type = '#';
5859 summon_kin_type = 'A';
5862 summon_kin_type = 'U';
5865 summon_kin_type = 'p';
5870 if (one_in_(13)) summon_kin_type = 'U';
5871 else summon_kin_type = 'u';
5873 case MIMIC_DEMON_LORD:
5874 summon_kin_type = 'U';
5877 summon_kin_type = 'V';
5880 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);