4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spell code (part 3) */
15 /* Maximum number of tries for teleporting */
18 /* 1/x chance of reducing stats (for elemental attacks) */
19 #define HURT_CHANCE 16
22 static bool cave_monster_teleportable_bold(int m_idx, int y, int x, bool passive)
24 monster_type *m_ptr = &m_list[m_idx];
25 cave_type *c_ptr = &cave[y][x];
26 feature_type *f_ptr = &f_info[c_ptr->feat];
28 /* Require "teleportable" space */
29 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
31 if (c_ptr->m_idx && (c_ptr->m_idx != m_idx)) return FALSE;
32 if (player_bold(y, x)) return FALSE;
34 /* Hack -- no teleport onto glyph of warding */
35 if (is_glyph_grid(c_ptr)) return FALSE;
36 if (is_explosive_rune_grid(c_ptr)) return FALSE;
40 if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
48 * Teleport a monster, normally up to "dis" grids away.
50 * Attempt to move the monster at least "dis/2" grids away.
52 * But allow variation to prevent infinite loops.
54 bool teleport_away(int m_idx, int dis, bool dec_valour, bool passive)
56 int oy, ox, d, i, min;
62 monster_type *m_ptr = &m_list[m_idx];
65 if (!m_ptr->r_idx) return (FALSE);
67 /* Save the old location */
71 /* Minimum distance */
75 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
76 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
78 chg_virtue(V_VALOUR, -1);
86 /* Verify max distance */
87 if (dis > 200) dis = 200;
89 /* Try several locations */
90 for (i = 0; i < 500; i++)
92 /* Pick a (possibly illegal) location */
95 ny = rand_spread(oy, dis);
96 nx = rand_spread(ox, dis);
97 d = distance(oy, ox, ny, nx);
98 if ((d >= min) && (d <= dis)) break;
101 /* Ignore illegal locations */
102 if (!in_bounds(ny, nx)) continue;
104 if (!cave_monster_teleportable_bold(m_idx, ny, nx, passive)) continue;
106 /* No teleporting into vaults and such */
107 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
108 if (cave[ny][nx].info & CAVE_ICKY) continue;
110 /* This grid looks good */
117 /* Increase the maximum distance */
120 /* Decrease the minimum distance */
123 /* Stop after MAX_TRIES tries */
124 if (tries > MAX_TRIES) return (FALSE);
128 sound(SOUND_TPOTHER);
130 /* Update the old location */
131 cave[oy][ox].m_idx = 0;
133 /* Update the new location */
134 cave[ny][nx].m_idx = m_idx;
136 /* Move the monster */
140 /* Forget the counter target */
143 /* Update the monster (new location) */
144 update_mon(m_idx, TRUE);
146 /* Redraw the old grid */
149 /* Redraw the new grid */
152 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
153 p_ptr->update |= (PU_MON_LITE);
161 * Teleport monster next to a grid near the given location
163 void teleport_monster_to(int m_idx, int ty, int tx, int power, bool passive)
165 int ny, nx, oy, ox, d, i, min;
169 monster_type *m_ptr = &m_list[m_idx];
172 if (!m_ptr->r_idx) return;
175 if (randint1(100) > power) return;
181 /* Save the old location */
185 /* Minimum distance */
188 /* Look until done */
189 while (look && --attempts)
191 /* Verify max distance */
192 if (dis > 200) dis = 200;
194 /* Try several locations */
195 for (i = 0; i < 500; i++)
197 /* Pick a (possibly illegal) location */
200 ny = rand_spread(ty, dis);
201 nx = rand_spread(tx, dis);
202 d = distance(ty, tx, ny, nx);
203 if ((d >= min) && (d <= dis)) break;
206 /* Ignore illegal locations */
207 if (!in_bounds(ny, nx)) continue;
209 if (!cave_monster_teleportable_bold(m_idx, ny, nx, passive)) continue;
211 /* No teleporting into vaults and such */
212 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
214 /* This grid looks good */
221 /* Increase the maximum distance */
224 /* Decrease the minimum distance */
228 if (attempts < 1) return;
231 sound(SOUND_TPOTHER);
233 /* Update the old location */
234 cave[oy][ox].m_idx = 0;
236 /* Update the new location */
237 cave[ny][nx].m_idx = m_idx;
239 /* Move the monster */
243 /* Update the monster (new location) */
244 update_mon(m_idx, TRUE);
246 /* Redraw the old grid */
249 /* Redraw the new grid */
252 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
253 p_ptr->update |= (PU_MON_LITE);
257 bool cave_player_teleportable_bold(int y, int x, bool passive, bool nonmagical)
259 cave_type *c_ptr = &cave[y][x];
260 feature_type *f_ptr = &f_info[c_ptr->feat];
262 /* Require "teleportable" space */
263 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
265 /* No magical teleporting into vaults and such */
266 if (!nonmagical && (c_ptr->info & CAVE_ICKY)) return FALSE;
268 if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
272 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
274 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
276 if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
279 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
281 /* Always forbid deep lava */
282 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
284 /* Forbid shallow lava when the player don't have levitation */
285 if (!p_ptr->levitation) return FALSE;
288 if (have_flag(f_ptr->flags, FF_HIT_TRAP))
290 if (!is_known_trap(c_ptr) || !trap_can_be_ignored(c_ptr->feat)) return FALSE;
299 * Teleport the player to a location up to "dis" grids away.
301 * If no such spaces are readily available, the distance may increase.
302 * Try very hard to move the player at least a quarter that distance.
304 * There was a nasty tendency for a long time; which was causing the
305 * player to "bounce" between two or three different spots because
306 * these are the only spots that are "far enough" way to satisfy the
309 * But this tendency is now removed; in the new algorithm, a list of
310 * candidates is selected first, which includes at least 50% of all
311 * floor grids within the distance, and any single grid in this list
312 * of candidates has equal possibility to be choosen as a destination.
315 #define MAX_TELEPORT_DISTANCE 200
317 void teleport_player(int dis, bool passive)
319 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
320 int total_candidates, cur_candidates;
321 int y = 0, x = 0, min, pick, i;
324 int left = MAX(1, px - dis);
325 int right = MIN(cur_wid - 2, px + dis);
326 int top = MAX(1, py - dis);
327 int bottom = MIN(cur_hgt - 2, py + dis);
329 /* Initialize counters */
330 total_candidates = 0;
331 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
332 candidates_at[i] = 0;
334 /* Limit the distance */
335 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
337 /* Search valid locations */
338 for (y = top; y <= bottom; y++)
340 for (x = left; x <= right; x++)
344 /* Skip illegal locations */
345 if (!cave_player_teleportable_bold(y, x, passive, FALSE)) continue;
347 /* Calculate distance */
348 d = distance(py, px, y, x);
350 /* Skip too far locations */
351 if (d > dis) continue;
353 /* Count the total number of candidates */
356 /* Count the number of candidates in this circumference */
361 /* No valid location! */
362 if (0 == total_candidates) return;
364 /* Fix the minimum distance */
365 for (cur_candidates = 0, min = dis; min >= 0; min--)
367 cur_candidates += candidates_at[min];
369 /* 50% of all candidates will have an equal chance to be choosen. */
370 if (cur_candidates >= total_candidates / 2) break;
373 /* Pick up a single location randomly */
374 pick = randint1(cur_candidates);
376 /* Search again the choosen location */
377 for (y = top; y <= bottom; y++)
379 for (x = left; x <= right; x++)
383 /* Skip illegal locations */
384 if (!cave_player_teleportable_bold(y, x, passive, FALSE)) continue;
386 /* Calculate distance */
387 d = distance(py, px, y, x);
389 /* Skip too far locations */
390 if (d > dis) continue;
392 /* Skip too close locations */
393 if (d < min) continue;
395 /* This grid was picked up? */
405 sound(SOUND_TELEPORT);
408 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
409 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
412 /* Save the old location */
416 /* Move the player */
417 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
419 /* Monsters with teleport ability may follow the player */
420 for (xx = -1; xx < 2; xx++)
422 for (yy = -1; yy < 2; yy++)
424 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
426 /* A monster except your mount may follow */
427 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
429 monster_type *m_ptr = &m_list[tmp_m_idx];
430 monster_race *r_ptr = &r_info[m_ptr->r_idx];
433 * The latter limitation is to avoid
434 * totally unkillable suckers...
436 if ((r_ptr->flags6 & RF6_TPORT) &&
437 !(r_ptr->flagsr & RFR_RES_TELE))
439 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level, FALSE);
448 * Teleport player to a grid near the given location
450 * This function is slightly obsessive about correctness.
451 * This function allows teleporting into vaults (!)
453 void teleport_player_to(int ny, int nx, bool no_tele, bool passive)
455 int y, x, dis = 0, ctr = 0;
457 if (p_ptr->anti_tele && no_tele)
460 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
462 msg_print("A mysterious force prevents you from teleporting!");
468 /* Find a usable location */
471 /* Pick a nearby legal location */
474 y = rand_spread(ny, dis);
475 x = rand_spread(nx, dis);
476 if (in_bounds(y, x)) break;
479 /* Accept any grid when wizard mode */
480 if (p_ptr->wizard && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
482 /* Accept teleportable floor grids */
483 if (cave_player_teleportable_bold(y, x, passive, !no_tele)) break;
485 /* Occasionally advance the distance */
486 if (++ctr > (4 * dis * dis + 4 * dis + 1))
494 sound(SOUND_TELEPORT);
496 /* Move the player */
497 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
503 * Teleport the player one level up or down (random when legal)
504 * Note: If m_idx <= 0, target is player.
506 void teleport_level(int m_idx)
512 if (m_idx <= 0) /* To player */
515 strcpy(m_name, "¤¢¤Ê¤¿");
517 strcpy(m_name, "you");
520 else /* To monster */
522 monster_type *m_ptr = &m_list[m_idx];
524 /* Get the monster name (or "it") */
525 monster_desc(m_name, m_ptr, 0);
527 see_m = is_seen(m_ptr);
530 /* No effect in some case */
531 if (TELE_LEVEL_IS_INEFF(m_idx))
534 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
536 if (see_m) msg_print("There is no effect.");
542 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
545 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
547 msg_print("A mysterious force prevents you from teleporting!");
552 /* Choose up or down */
553 if (randint0(100) < 50) go_up = TRUE;
556 if ((m_idx <= 0) && p_ptr->wizard)
558 if (get_check("Force to go up? ")) go_up = TRUE;
559 else if (get_check("Force to go down? ")) go_up = FALSE;
563 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
566 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
568 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
570 if (m_idx <= 0) /* To player */
574 dungeon_type = p_ptr->recall_dungeon;
579 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
581 if (autosave_l) do_cmd_save_game(TRUE);
585 dun_level = d_info[dungeon_type].mindepth;
586 prepare_change_floor_mode(CFM_RAND_PLACE);
590 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
594 p_ptr->leaving = TRUE;
599 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
602 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
604 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
608 if (m_idx <= 0) /* To player */
610 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
612 if (autosave_l) do_cmd_save_game(TRUE);
614 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
619 p_ptr->inside_quest = 0;
620 p_ptr->leaving = TRUE;
626 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
628 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
632 if (m_idx <= 0) /* To player */
634 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
636 if (autosave_l) do_cmd_save_game(TRUE);
638 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
641 p_ptr->leaving = TRUE;
647 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
649 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
652 if (m_idx <= 0) /* To player */
654 /* Never reach this code on the surface */
655 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
657 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
659 if (autosave_l) do_cmd_save_game(TRUE);
661 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
664 p_ptr->leaving = TRUE;
668 /* Monster level teleportation is simple deleting now */
671 monster_type *m_ptr = &m_list[m_idx];
673 /* Check for quest completion */
674 check_quest_completion(m_ptr);
676 delete_monster_idx(m_idx);
680 sound(SOUND_TPLEVEL);
685 int choose_dungeon(cptr note, int y, int x)
691 /* Hack -- No need to choose dungeon in some case */
692 if (lite_town || vanilla_town || ironman_downward)
694 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
698 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
700 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
707 /* Allocate the "dun" array */
708 C_MAKE(dun, max_d_idx, s16b);
711 for(i = 1; i < max_d_idx; i++)
716 if (!d_info[i].maxdepth) continue;
717 if (!max_dlv[i]) continue;
718 if (d_info[i].final_guardian)
720 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
722 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
725 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
727 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
729 prt(buf, y + num, x);
736 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
738 prt(" No dungeon is available.", y, x);
743 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
745 prt(format("Which dungeon do you %s?: ", note), 0, 0);
750 if ((i == ESCAPE) || !num)
752 /* Free the "dun" array */
753 C_KILL(dun, max_d_idx, s16b);
758 if (i >= 'a' && i <('a'+num))
760 select_dungeon = dun[i-'a'];
767 /* Free the "dun" array */
768 C_KILL(dun, max_d_idx, s16b);
770 return select_dungeon;
775 * Recall the player to town or dungeon
777 bool recall_player(int turns)
780 * TODO: Recall the player to the last
781 * visited town when in the wilderness
785 if (p_ptr->inside_arena || ironman_downward)
788 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
790 msg_print("Nothing happens.");
796 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
799 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
801 if (get_check("Reset recall depth? "))
804 max_dlv[dungeon_type] = dun_level;
807 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
809 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
814 if (!p_ptr->word_recall)
820 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
822 select_dungeon = choose_dungeon("recall", 2, 14);
824 if (!select_dungeon) return FALSE;
825 p_ptr->recall_dungeon = select_dungeon;
827 p_ptr->word_recall = turns;
829 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
831 msg_print("The air about you becomes charged...");
834 p_ptr->redraw |= (PR_STATUS);
838 p_ptr->word_recall = 0;
840 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
842 msg_print("A tension leaves the air around you...");
845 p_ptr->redraw |= (PR_STATUS);
851 bool word_of_recall(void)
853 return(recall_player(randint0(21) + 15));
857 bool reset_recall(void)
859 int select_dungeon, dummy = 0;
864 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
866 select_dungeon = choose_dungeon("reset", 2, 14);
870 if (ironman_downward)
873 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
875 msg_print("Nothing happens.");
881 if (!select_dungeon) return FALSE;
884 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
886 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
891 sprintf(tmp_val, "%d", MAX(dun_level, 1));
893 /* Ask for a level */
894 if (get_string(ppp, tmp_val, 10))
896 /* Extract request */
897 dummy = atoi(tmp_val);
900 if (dummy < 1) dummy = 1;
903 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
904 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
906 max_dlv[select_dungeon] = dummy;
910 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
912 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
916 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
918 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
931 * Apply disenchantment to the player's stuff
933 * XXX XXX XXX This function is also called from the "melee" code
935 * Return "TRUE" if the player notices anything
937 bool apply_disenchant(int mode)
941 char o_name[MAX_NLEN];
942 int to_h, to_d, to_a, pval;
944 /* Pick a random slot */
947 case 1: t = INVEN_RARM; break;
948 case 2: t = INVEN_LARM; break;
949 case 3: t = INVEN_BOW; break;
950 case 4: t = INVEN_BODY; break;
951 case 5: t = INVEN_OUTER; break;
952 case 6: t = INVEN_HEAD; break;
953 case 7: t = INVEN_HANDS; break;
954 case 8: t = INVEN_FEET; break;
958 o_ptr = &inventory[t];
960 /* No item, nothing happens */
961 if (!o_ptr->k_idx) return (FALSE);
963 /* Disenchant equipments only -- No disenchant on monster ball */
964 if (!object_is_weapon_armour_ammo(o_ptr))
967 /* Nothing to disenchant */
968 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
970 /* Nothing to notice */
975 /* Describe the object */
976 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
979 /* Artifacts have 71% chance to resist */
980 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
984 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
986 msg_format("Your %s (%c) resist%s disenchantment!",
987 o_name, index_to_label(t),
988 ((o_ptr->number != 1) ? "" : "s"));
997 /* Memorize old value */
1003 /* Disenchant tohit */
1004 if (o_ptr->to_h > 0) o_ptr->to_h--;
1005 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1007 /* Disenchant todam */
1008 if (o_ptr->to_d > 0) o_ptr->to_d--;
1009 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1011 /* Disenchant toac */
1012 if (o_ptr->to_a > 0) o_ptr->to_a--;
1013 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1015 /* Disenchant pval (occasionally) */
1016 /* Unless called from wild_magic() */
1017 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1019 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1020 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1024 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1025 o_name, index_to_label(t) );
1027 msg_format("Your %s (%c) %s disenchanted!",
1028 o_name, index_to_label(t),
1029 ((o_ptr->number != 1) ? "were" : "was"));
1032 chg_virtue(V_HARMONY, 1);
1033 chg_virtue(V_ENCHANT, -2);
1035 /* Recalculate bonuses */
1036 p_ptr->update |= (PU_BONUS);
1039 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1049 void mutate_player(void)
1051 int max1, cur1, max2, cur2, ii, jj, i;
1053 /* Pick a pair of stats */
1055 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1057 max1 = p_ptr->stat_max[ii];
1058 cur1 = p_ptr->stat_cur[ii];
1059 max2 = p_ptr->stat_max[jj];
1060 cur2 = p_ptr->stat_cur[jj];
1062 p_ptr->stat_max[ii] = max2;
1063 p_ptr->stat_cur[ii] = cur2;
1064 p_ptr->stat_max[jj] = max1;
1065 p_ptr->stat_cur[jj] = cur1;
1069 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1070 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1073 p_ptr->update |= (PU_BONUS);
1080 void apply_nexus(monster_type *m_ptr)
1082 switch (randint1(7))
1084 case 1: case 2: case 3:
1086 teleport_player(200, TRUE);
1092 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, TRUE);
1098 if (randint0(100) < p_ptr->skill_sav)
1101 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1103 msg_print("You resist the effects!");
1109 /* Teleport Level */
1116 if (randint0(100) < p_ptr->skill_sav)
1119 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1121 msg_print("You resist the effects!");
1128 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1130 msg_print("Your body starts to scramble...");
1141 * Charge a lite (torch or latern)
1143 void phlogiston(void)
1146 object_type * o_ptr = &inventory[INVEN_LITE];
1149 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1151 max_flog = FUEL_LAMP;
1155 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1157 max_flog = FUEL_TORCH;
1160 /* No torch to refill */
1164 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1166 msg_print("You are not wielding anything which uses phlogiston.");
1172 if (o_ptr->xtra4 >= max_flog)
1175 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1177 msg_print("No more phlogiston can be put in this item.");
1184 o_ptr->xtra4 += (max_flog / 2);
1188 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1190 msg_print("You add phlogiston to your light item.");
1195 if (o_ptr->xtra4 >= max_flog)
1197 o_ptr->xtra4 = max_flog;
1199 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1201 msg_print("Your light item is full.");
1206 /* Recalculate torch */
1207 p_ptr->update |= (PU_TORCH);
1212 * Brand the current weapon
1214 void brand_weapon(int brand_type)
1221 /* Assume enchant weapon */
1222 item_tester_hook = object_allow_enchant_melee_weapon;
1223 item_tester_no_ryoute = TRUE;
1227 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1228 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1230 q = "Enchant which weapon? ";
1231 s = "You have nothing to enchant.";
1234 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1236 /* Get the item (in the pack) */
1239 o_ptr = &inventory[item];
1242 /* Get the item (on the floor) */
1245 o_ptr = &o_list[0 - item];
1249 /* you can never modify artifacts / ego-items */
1250 /* you can never modify cursed items */
1251 /* TY: You _can_ modify broken items (if you're silly enough) */
1252 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1253 !object_is_cursed(o_ptr) &&
1254 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1255 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1256 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1260 /* Let's get the name before it is changed... */
1261 char o_name[MAX_NLEN];
1262 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1267 if (o_ptr->tval == TV_SWORD)
1270 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1272 act = "becomes very sharp!";
1275 o_ptr->name2 = EGO_SHARPNESS;
1276 o_ptr->pval = m_bonus(5, dun_level) + 1;
1281 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1283 act = "seems very powerful.";
1286 o_ptr->name2 = EGO_EARTHQUAKES;
1287 o_ptr->pval = m_bonus(3, dun_level);
1292 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1294 act = "seems to be looking for humans!";
1297 o_ptr->name2 = EGO_SLAY_HUMAN;
1301 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1303 act = "covered with lightning!";
1306 o_ptr->name2 = EGO_BRAND_ELEC;
1310 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1312 act = "coated with acid!";
1315 o_ptr->name2 = EGO_BRAND_ACID;
1319 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1321 act = "seems to be looking for evil monsters!";
1324 o_ptr->name2 = EGO_SLAY_EVIL;
1328 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1330 act = "seems to be looking for demons!";
1333 o_ptr->name2 = EGO_SLAY_DEMON;
1337 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1339 act = "seems to be looking for undead!";
1342 o_ptr->name2 = EGO_SLAY_UNDEAD;
1346 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1348 act = "seems to be looking for animals!";
1351 o_ptr->name2 = EGO_SLAY_ANIMAL;
1355 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1357 act = "seems to be looking for dragons!";
1360 o_ptr->name2 = EGO_SLAY_DRAGON;
1364 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1366 act = "seems to be looking for troll!s";
1369 o_ptr->name2 = EGO_SLAY_TROLL;
1373 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1375 act = "seems to be looking for orcs!";
1378 o_ptr->name2 = EGO_SLAY_ORC;
1382 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1384 act = "seems to be looking for giants!";
1387 o_ptr->name2 = EGO_SLAY_GIANT;
1391 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1393 act = "seems very unstable now.";
1396 o_ptr->name2 = EGO_TRUMP;
1397 o_ptr->pval = randint1(2);
1401 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1403 act = "thirsts for blood!";
1406 o_ptr->name2 = EGO_VAMPIRIC;
1410 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1412 act = "is coated with poison.";
1415 o_ptr->name2 = EGO_BRAND_POIS;
1419 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1421 act = "is engulfed in raw Logrus!";
1424 o_ptr->name2 = EGO_CHAOTIC;
1428 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1430 act = "is covered in a fiery shield!";
1433 o_ptr->name2 = EGO_BRAND_FIRE;
1437 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1439 act = "glows deep, icy blue!";
1442 o_ptr->name2 = EGO_BRAND_COLD;
1447 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1449 msg_format("Your %s %s", o_name, act);
1453 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1455 o_ptr->discount = 99;
1456 chg_virtue(V_ENCHANT, 2);
1460 if (flush_failure) flush();
1463 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1465 msg_print("The Branding failed.");
1468 chg_virtue(V_ENCHANT, -2);
1475 * Vanish all walls in this floor
1477 static bool vanish_dungeon(void)
1481 feature_type *f_ptr;
1482 monster_type *m_ptr;
1485 /* Prevent vasishing of quest levels and town */
1486 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1491 /* Scan all normal grids */
1492 for (y = 1; y < cur_hgt - 1; y++)
1494 for (x = 1; x < cur_wid - 1; x++)
1496 c_ptr = &cave[y][x];
1498 /* Seeing true feature code (ignore mimic) */
1499 f_ptr = &f_info[c_ptr->feat];
1501 /* Lose room and vault */
1502 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1504 m_ptr = &m_list[c_ptr->m_idx];
1507 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1509 /* Reset sleep counter */
1510 (void)set_monster_csleep(c_ptr->m_idx, 0);
1512 /* Notice the "waking up" */
1515 /* Acquire the monster name */
1516 monster_desc(m_name, m_ptr, 0);
1518 /* Dump a message */
1520 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1522 msg_format("%^s wakes up.", m_name);
1527 /* Process all walls, doors and patterns */
1528 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1532 /* Special boundary walls -- Top and bottom */
1533 for (x = 0; x < cur_wid; x++)
1535 c_ptr = &cave[0][x];
1536 f_ptr = &f_info[c_ptr->mimic];
1538 /* Lose room and vault */
1539 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1541 /* Set boundary mimic if needed */
1542 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1544 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1546 /* Check for change to boring grid */
1547 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1550 c_ptr = &cave[cur_hgt - 1][x];
1551 f_ptr = &f_info[c_ptr->mimic];
1553 /* Lose room and vault */
1554 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1556 /* Set boundary mimic if needed */
1557 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1559 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1561 /* Check for change to boring grid */
1562 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1566 /* Special boundary walls -- Left and right */
1567 for (y = 1; y < (cur_hgt - 1); y++)
1569 c_ptr = &cave[y][0];
1570 f_ptr = &f_info[c_ptr->mimic];
1572 /* Lose room and vault */
1573 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1575 /* Set boundary mimic if needed */
1576 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1578 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1580 /* Check for change to boring grid */
1581 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1584 c_ptr = &cave[y][cur_wid - 1];
1585 f_ptr = &f_info[c_ptr->mimic];
1587 /* Lose room and vault */
1588 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1590 /* Set boundary mimic if needed */
1591 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1593 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1595 /* Check for change to boring grid */
1596 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1600 /* Mega-Hack -- Forget the view and lite */
1601 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1604 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1606 /* Update the monsters */
1607 p_ptr->update |= (PU_MONSTERS);
1610 p_ptr->redraw |= (PR_MAP);
1613 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1619 void call_the_(void)
1623 bool do_call = TRUE;
1625 for (i = 0; i < 9; i++)
1627 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1629 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1631 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1632 !permanent_wall(&f_info[c_ptr->feat]))
1642 for (i = 1; i < 10; i++)
1644 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1647 for (i = 1; i < 10; i++)
1649 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1652 for (i = 1; i < 10; i++)
1654 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1658 /* Prevent destruction of quest levels and town */
1659 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1662 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1664 msg_print("The ground trembles.");
1671 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1672 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1673 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1675 msg_format("You %s the %s too close to a wall!",
1676 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1677 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1678 msg_print("There is a loud explosion!");
1684 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1686 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1691 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1693 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1695 msg_print("The dungeon collapses...");
1700 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1702 msg_print("The dungeon trembles.");
1707 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1709 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1716 * Fetch an item (teleport it right underneath the caster)
1718 void fetch(int dir, int wgt, bool require_los)
1723 char o_name[MAX_NLEN];
1725 /* Check to see if an object is already there */
1726 if (cave[py][px].o_idx)
1729 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1731 msg_print("You can't fetch when you're already standing on something.");
1738 if (dir == 5 && target_okay())
1743 if (distance(py, px, ty, tx) > MAX_RANGE)
1746 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1748 msg_print("You can't fetch something that far away!");
1754 c_ptr = &cave[ty][tx];
1756 /* We need an item to fetch */
1760 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1762 msg_print("There is no object at this place.");
1768 /* No fetching from vault */
1769 if (c_ptr->info & CAVE_ICKY)
1772 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1774 msg_print("The item slips from your control.");
1780 /* We need to see the item */
1783 if (!player_has_los_bold(ty, tx))
1786 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1788 msg_print("You have no direct line of sight to that location.");
1793 else if (!projectable(py, px, ty, tx))
1796 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1798 msg_print("You have no direct line of sight to that location.");
1807 /* Use a direction */
1808 ty = py; /* Where to drop the item */
1815 c_ptr = &cave[ty][tx];
1817 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1818 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1820 while (!c_ptr->o_idx);
1823 o_ptr = &o_list[c_ptr->o_idx];
1825 if (o_ptr->weight > wgt)
1827 /* Too heavy to 'fetch' */
1829 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1831 msg_print("The object is too heavy.");
1838 c_ptr->o_idx = o_ptr->next_o_idx;
1839 cave[py][px].o_idx = i; /* 'move' it */
1840 o_ptr->next_o_idx = 0;
1841 o_ptr->iy = (byte)py;
1842 o_ptr->ix = (byte)px;
1844 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1846 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1848 msg_format("%^s flies through the air to your feet.", o_name);
1853 p_ptr->redraw |= PR_MAP;
1857 void alter_reality(void)
1859 /* Ironman option */
1860 if (p_ptr->inside_arena || ironman_downward)
1863 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1865 msg_print("Nothing happens.");
1870 if (!p_ptr->alter_reality)
1872 int turns = randint0(21) + 15;
1874 p_ptr->alter_reality = turns;
1876 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1878 msg_print("The view around you begins to change...");
1881 p_ptr->redraw |= (PR_STATUS);
1885 p_ptr->alter_reality = 0;
1887 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1889 msg_print("The view around you got back...");
1892 p_ptr->redraw |= (PR_STATUS);
1899 * Leave a "glyph of warding" which prevents monster movement
1901 bool warding_glyph(void)
1904 if (!cave_clean_bold(py, px))
1907 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1909 msg_print("The object resists the spell.");
1915 /* Create a glyph */
1916 cave[py][px].info |= CAVE_OBJECT;
1917 cave[py][px].mimic = FEAT_GLYPH;
1928 bool place_mirror(void)
1931 if (!cave_clean_bold(py, px))
1934 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1936 msg_print("The object resists the spell.");
1942 /* Create a mirror */
1943 cave[py][px].info |= CAVE_OBJECT;
1944 cave[py][px].mimic = FEAT_MIRROR;
1946 /* Turn on the light */
1947 cave[py][px].info |= CAVE_GLOW;
1955 update_local_illumination(py, px);
1962 * Leave an "explosive rune" which prevents monster movement
1964 bool explosive_rune(void)
1967 if (!cave_clean_bold(py, px))
1970 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1972 msg_print("The object resists the spell.");
1978 /* Create a glyph */
1979 cave[py][px].info |= CAVE_OBJECT;
1980 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1993 * Identify everything being carried.
1994 * Done by a potion of "self knowledge".
1996 void identify_pack(void)
2000 /* Simply identify and know every item */
2001 for (i = 0; i < INVEN_TOTAL; i++)
2003 object_type *o_ptr = &inventory[i];
2005 /* Skip non-objects */
2006 if (!o_ptr->k_idx) continue;
2009 identify_item(o_ptr);
2011 /* Auto-inscription */
2012 autopick_alter_item(i, FALSE);
2018 * Used by the "enchant" function (chance of failure)
2019 * (modified for Zangband, we need better stuff there...) -- TY
2021 static int enchant_table[16] =
2023 0, 10, 50, 100, 200,
2024 300, 400, 500, 650, 800,
2025 950, 987, 993, 995, 998,
2031 * Removes curses from items in inventory
2033 * Note that Items which are "Perma-Cursed" (The One Ring,
2034 * The Crown of Morgoth) can NEVER be uncursed.
2036 * Note that if "all" is FALSE, then Items which are
2037 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2038 * will not be uncursed.
2040 static int remove_curse_aux(int all)
2044 /* Attempt to uncurse items being worn */
2045 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2047 object_type *o_ptr = &inventory[i];
2049 /* Skip non-objects */
2050 if (!o_ptr->k_idx) continue;
2052 /* Uncursed already */
2053 if (!object_is_cursed(o_ptr)) continue;
2055 /* Heavily Cursed Items need a special spell */
2056 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2058 /* Perma-Cursed Items can NEVER be uncursed */
2059 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2062 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2067 o_ptr->curse_flags = 0L;
2069 /* Hack -- Assume felt */
2070 o_ptr->ident |= (IDENT_SENSE);
2073 o_ptr->feeling = FEEL_NONE;
2075 /* Recalculate the bonuses */
2076 p_ptr->update |= (PU_BONUS);
2079 p_ptr->window |= (PW_EQUIP);
2081 /* Count the uncursings */
2085 /* Return "something uncursed" */
2091 * Remove most curses
2093 bool remove_curse(void)
2095 return (remove_curse_aux(FALSE));
2101 bool remove_all_curse(void)
2103 return (remove_curse_aux(TRUE));
2108 * Turns an object into gold, gain some of its value in a shop
2117 char o_name[MAX_NLEN];
2118 char out_val[MAX_NLEN+40];
2122 /* Hack -- force destruction */
2123 if (command_arg > 0) force = TRUE;
2127 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2128 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2130 q = "Turn which item to gold? ";
2131 s = "You have nothing to turn to gold.";
2134 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2136 /* Get the item (in the pack) */
2139 o_ptr = &inventory[item];
2142 /* Get the item (on the floor) */
2145 o_ptr = &o_list[0 - item];
2149 /* See how many items */
2150 if (o_ptr->number > 1)
2152 /* Get a quantity */
2153 amt = get_quantity(NULL, o_ptr->number);
2155 /* Allow user abort */
2156 if (amt <= 0) return FALSE;
2160 /* Describe the object */
2161 old_number = o_ptr->number;
2162 o_ptr->number = amt;
2163 object_desc(o_name, o_ptr, 0);
2164 o_ptr->number = old_number;
2166 /* Verify unless quantity given */
2169 if (confirm_destroy || (object_value(o_ptr) > 0))
2171 /* Make a verification */
2173 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2175 sprintf(out_val, "Really turn %s to gold? ", o_name);
2178 if (!get_check(out_val)) return FALSE;
2182 /* Artifacts cannot be destroyed */
2183 if (!can_player_destroy_object(o_ptr))
2187 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2189 msg_format("You fail to turn %s to gold!", o_name);
2196 price = object_value_real(o_ptr);
2202 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2204 msg_format("You turn %s to fool's gold.", o_name);
2212 if (amt > 1) price *= amt;
2214 if (price > 30000) price = 30000;
2216 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2218 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2224 p_ptr->redraw |= (PR_GOLD);
2227 p_ptr->window |= (PW_PLAYER);
2231 /* Eliminate the item (from the pack) */
2234 inven_item_increase(item, -amt);
2235 inven_item_describe(item);
2236 inven_item_optimize(item);
2239 /* Eliminate the item (from the floor) */
2242 floor_item_increase(0 - item, -amt);
2243 floor_item_describe(0 - item);
2244 floor_item_optimize(0 - item);
2252 * Break the curse of an item
2254 static void break_curse(object_type *o_ptr)
2256 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2259 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2261 msg_print("The curse is broken!");
2264 o_ptr->curse_flags = 0L;
2266 o_ptr->ident |= (IDENT_SENSE);
2268 o_ptr->feeling = FEEL_NONE;
2274 * Enchants a plus onto an item. -RAK-
2276 * Revamped! Now takes item pointer, number of times to try enchanting,
2277 * and a flag of what to try enchanting. Artifacts resist enchantment
2278 * some of the time, and successful enchantment to at least +0 might
2279 * break a curse on the item. -CFT-
2281 * Note that an item can technically be enchanted all the way to +15 if
2282 * you wait a very, very, long time. Going from +9 to +10 only works
2283 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2285 * Note that this function can now be used on "piles" of items, and
2286 * the larger the pile, the lower the chance of success.
2288 bool enchant(object_type *o_ptr, int n, int eflag)
2290 int i, chance, prob;
2292 bool a = object_is_artifact(o_ptr);
2293 bool force = (eflag & ENCH_FORCE);
2296 /* Large piles resist enchantment */
2297 prob = o_ptr->number * 100;
2299 /* Missiles are easy to enchant */
2300 if ((o_ptr->tval == TV_BOLT) ||
2301 (o_ptr->tval == TV_ARROW) ||
2302 (o_ptr->tval == TV_SHOT))
2308 for (i = 0; i < n; i++)
2310 /* Hack -- Roll for pile resistance */
2311 if (!force && randint0(prob) >= 100) continue;
2313 /* Enchant to hit */
2314 if (eflag & ENCH_TOHIT)
2316 if (o_ptr->to_h < 0) chance = 0;
2317 else if (o_ptr->to_h > 15) chance = 1000;
2318 else chance = enchant_table[o_ptr->to_h];
2320 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2325 /* only when you get it above -1 -CFT */
2326 if (o_ptr->to_h >= 0)
2331 /* Enchant to damage */
2332 if (eflag & ENCH_TODAM)
2334 if (o_ptr->to_d < 0) chance = 0;
2335 else if (o_ptr->to_d > 15) chance = 1000;
2336 else chance = enchant_table[o_ptr->to_d];
2338 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2343 /* only when you get it above -1 -CFT */
2344 if (o_ptr->to_d >= 0)
2349 /* Enchant to armor class */
2350 if (eflag & ENCH_TOAC)
2352 if (o_ptr->to_a < 0) chance = 0;
2353 else if (o_ptr->to_a > 15) chance = 1000;
2354 else chance = enchant_table[o_ptr->to_a];
2356 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2361 /* only when you get it above -1 -CFT */
2362 if (o_ptr->to_a >= 0)
2369 if (!res) return (FALSE);
2371 /* Recalculate bonuses */
2372 p_ptr->update |= (PU_BONUS);
2374 /* Combine / Reorder the pack (later) */
2375 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2378 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2389 * Enchant an item (in the inventory or on the floor)
2390 * Note that "num_ac" requires armour, else weapon
2391 * Returns TRUE if attempted, FALSE if cancelled
2393 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2398 char o_name[MAX_NLEN];
2402 /* Assume enchant weapon */
2403 item_tester_hook = object_allow_enchant_weapon;
2404 item_tester_no_ryoute = TRUE;
2406 /* Enchant armor if requested */
2407 if (num_ac) item_tester_hook = object_is_armour;
2411 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2412 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2414 q = "Enchant which item? ";
2415 s = "You have nothing to enchant.";
2418 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2420 /* Get the item (in the pack) */
2423 o_ptr = &inventory[item];
2426 /* Get the item (on the floor) */
2429 o_ptr = &o_list[0 - item];
2434 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2438 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2441 msg_format("%s %s glow%s brightly!",
2442 ((item >= 0) ? "Your" : "The"), o_name,
2443 ((o_ptr->number > 1) ? "" : "s"));
2448 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2449 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2450 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2456 if (flush_failure) flush();
2460 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2462 msg_print("The enchantment failed.");
2465 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2468 chg_virtue(V_ENCHANT, 1);
2472 /* Something happened */
2478 * Check if an object is nameless weapon or armour
2480 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2482 /* Require weapon or armour */
2483 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2485 /* Require nameless object if the object is well known */
2486 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2493 bool artifact_scroll(void)
2498 char o_name[MAX_NLEN];
2502 item_tester_no_ryoute = TRUE;
2504 /* Enchant weapon/armour */
2505 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2509 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2510 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2512 q = "Enchant which item? ";
2513 s = "You have nothing to enchant.";
2516 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2518 /* Get the item (in the pack) */
2521 o_ptr = &inventory[item];
2524 /* Get the item (on the floor) */
2527 o_ptr = &o_list[0 - item];
2532 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2536 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2538 msg_format("%s %s radiate%s a blinding light!",
2539 ((item >= 0) ? "Your" : "The"), o_name,
2540 ((o_ptr->number > 1) ? "" : "s"));
2543 if (object_is_artifact(o_ptr))
2546 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2548 msg_format("The %s %s already %s!",
2549 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2550 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2556 else if (object_is_ego(o_ptr))
2559 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2561 msg_format("The %s %s already %s!",
2562 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2563 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2569 else if (o_ptr->xtra3)
2572 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2574 msg_format("The %s %s already %s!",
2575 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2576 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2582 if (o_ptr->number > 1)
2585 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2586 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2588 msg_print("Not enough enough energy to enchant more than one object!");
2589 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2594 inven_item_increase(item, 1-(o_ptr->number));
2598 floor_item_increase(0-item, 1-(o_ptr->number));
2601 okay = create_artifact(o_ptr, TRUE);
2608 if (flush_failure) flush();
2612 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2614 msg_print("The enchantment failed.");
2617 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2620 chg_virtue(V_ENCHANT, 1);
2624 /* Something happened */
2630 * Identify an object
2632 bool identify_item(object_type *o_ptr)
2634 bool old_known = FALSE;
2635 char o_name[MAX_NLEN];
2638 object_desc(o_name, o_ptr, 0);
2640 if (o_ptr->ident & IDENT_KNOWN)
2643 if (!(o_ptr->ident & (IDENT_MENTAL)))
2645 if (object_is_artifact(o_ptr) || one_in_(5))
2646 chg_virtue(V_KNOWLEDGE, 1);
2649 /* Identify it fully */
2650 object_aware(o_ptr);
2651 object_known(o_ptr);
2653 /* Recalculate bonuses */
2654 p_ptr->update |= (PU_BONUS);
2656 /* Combine / Reorder the pack (later) */
2657 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2660 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2662 strcpy(record_o_name, o_name);
2666 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2668 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2669 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2670 if(record_rand_art && !old_known && o_ptr->art_name)
2671 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2677 static bool item_tester_hook_identify(object_type *o_ptr)
2679 return (bool)!object_is_known(o_ptr);
2682 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2684 if (object_is_known(o_ptr))
2686 return object_is_weapon_armour_ammo(o_ptr);
2690 * Identify an object in the inventory (or on the floor)
2691 * This routine does *not* automatically combine objects.
2692 * Returns TRUE if something was identified, else FALSE.
2694 bool ident_spell(bool only_equip)
2698 char o_name[MAX_NLEN];
2702 item_tester_no_ryoute = TRUE;
2705 item_tester_hook = item_tester_hook_identify_weapon_armour;
2707 item_tester_hook = item_tester_hook_identify;
2709 if (!can_get_item())
2713 item_tester_hook = object_is_weapon_armour_ammo;
2717 item_tester_hook = NULL;
2723 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2724 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2726 q = "Identify which item? ";
2727 s = "You have nothing to identify.";
2730 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2732 /* Get the item (in the pack) */
2735 o_ptr = &inventory[item];
2738 /* Get the item (on the floor) */
2741 o_ptr = &o_list[0 - item];
2745 old_known = identify_item(o_ptr);
2748 object_desc(o_name, o_ptr, 0);
2751 if (item >= INVEN_RARM)
2754 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2756 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2762 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2764 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2770 msg_format("¾²¾å: %s¡£", o_name);
2772 msg_format("On the ground: %s.", o_name);
2776 /* Auto-inscription/destroy */
2777 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2779 /* Something happened */
2785 * Mundanify an object in the inventory (or on the floor)
2786 * This routine does *not* automatically combine objects.
2787 * Returns TRUE if something was mundanified, else FALSE.
2789 bool mundane_spell(bool only_equip)
2795 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2796 item_tester_no_ryoute = TRUE;
2800 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2801 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2803 q = "Use which item? ";
2804 s = "You have nothing you can use.";
2807 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2809 /* Get the item (in the pack) */
2812 o_ptr = &inventory[item];
2815 /* Get the item (on the floor) */
2818 o_ptr = &o_list[0 - item];
2823 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2825 msg_print("There is a bright flash of light!");
2828 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2829 byte ix = o_ptr->ix; /* X-position on map, or zero */
2830 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2831 byte marked = o_ptr->marked; /* Object is marked */
2832 s16b weight = o_ptr->number * o_ptr->weight;
2833 u16b inscription = o_ptr->inscription;
2836 object_prep(o_ptr, o_ptr->k_idx);
2840 o_ptr->next_o_idx = next_o_idx;
2841 o_ptr->marked = marked;
2842 o_ptr->inscription = inscription;
2843 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2847 /* Something happened */
2853 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2855 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2858 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2860 if (!item_tester_hook_identify_fully(o_ptr))
2862 return object_is_weapon_armour_ammo(o_ptr);
2866 * Fully "identify" an object in the inventory -BEN-
2867 * This routine returns TRUE if an item was identified.
2869 bool identify_fully(bool only_equip)
2873 char o_name[MAX_NLEN];
2877 item_tester_no_ryoute = TRUE;
2879 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2881 item_tester_hook = item_tester_hook_identify_fully;
2883 if (!can_get_item())
2886 item_tester_hook = object_is_weapon_armour_ammo;
2888 item_tester_hook = NULL;
2893 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2894 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2896 q = "Identify which item? ";
2897 s = "You have nothing to identify.";
2900 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2902 /* Get the item (in the pack) */
2905 o_ptr = &inventory[item];
2908 /* Get the item (on the floor) */
2911 o_ptr = &o_list[0 - item];
2915 old_known = identify_item(o_ptr);
2917 /* Mark the item as fully known */
2918 o_ptr->ident |= (IDENT_MENTAL);
2924 object_desc(o_name, o_ptr, 0);
2927 if (item >= INVEN_RARM)
2930 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2932 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2940 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2942 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2948 msg_format("¾²¾å: %s¡£", o_name);
2950 msg_format("On the ground: %s.", o_name);
2954 /* Describe it fully */
2955 (void)screen_object(o_ptr, TRUE);
2957 /* Auto-inscription/destroy */
2958 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2968 * Hook for "get_item()". Determine if something is rechargable.
2970 bool item_tester_hook_recharge(object_type *o_ptr)
2972 /* Recharge staffs */
2973 if (o_ptr->tval == TV_STAFF) return (TRUE);
2975 /* Recharge wands */
2976 if (o_ptr->tval == TV_WAND) return (TRUE);
2978 /* Hack -- Recharge rods */
2979 if (o_ptr->tval == TV_ROD) return (TRUE);
2987 * Recharge a wand/staff/rod from the pack or on the floor.
2988 * This function has been rewritten in Oangband and ZAngband.
2990 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2991 * Chaos -- Arcane Binding --> recharge(90)
2993 * Scroll of recharging --> recharge(130)
2994 * Artifact activation/Thingol --> recharge(130)
2996 * It is harder to recharge high level, and highly charged wands,
2997 * staffs, and rods. The more wands in a stack, the more easily and
2998 * strongly they recharge. Staffs, however, each get fewer charges if
3001 * XXX XXX XXX Beware of "sliding index errors".
3003 bool recharge(int power)
3006 int recharge_strength, recharge_amount;
3015 char o_name[MAX_NLEN];
3017 /* Only accept legal items */
3018 item_tester_hook = item_tester_hook_recharge;
3022 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3023 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3025 q = "Recharge which item? ";
3026 s = "You have nothing to recharge.";
3029 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3031 /* Get the item (in the pack) */
3034 o_ptr = &inventory[item];
3037 /* Get the item (on the floor) */
3040 o_ptr = &o_list[0 - item];
3043 /* Get the object kind. */
3044 k_ptr = &k_info[o_ptr->k_idx];
3046 /* Extract the object "level" */
3047 lev = k_info[o_ptr->k_idx].level;
3050 /* Recharge a rod */
3051 if (o_ptr->tval == TV_ROD)
3053 /* Extract a recharge strength by comparing object level to power. */
3054 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3058 if (one_in_(recharge_strength))
3060 /* Activate the failure code. */
3067 /* Recharge amount */
3068 recharge_amount = (power * damroll(3, 2));
3070 /* Recharge by that amount */
3071 if (o_ptr->timeout > recharge_amount)
3072 o_ptr->timeout -= recharge_amount;
3079 /* Recharge wand/staff */
3082 /* Extract a recharge strength by comparing object level to power.
3083 * Divide up a stack of wands' charges to calculate charge penalty.
3085 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3086 recharge_strength = (100 + power - lev -
3087 (8 * o_ptr->pval / o_ptr->number)) / 15;
3089 /* All staffs, unstacked wands. */
3090 else recharge_strength = (100 + power - lev -
3091 (8 * o_ptr->pval)) / 15;
3094 if (recharge_strength < 0) recharge_strength = 0;
3097 if (one_in_(recharge_strength))
3099 /* Activate the failure code. */
3103 /* If the spell didn't backfire, recharge the wand or staff. */
3106 /* Recharge based on the standard number of charges. */
3107 recharge_amount = randint1(1 + k_ptr->pval / 2);
3109 /* Multiple wands in a stack increase recharging somewhat. */
3110 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3113 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3114 if (recharge_amount < 1) recharge_amount = 1;
3115 if (recharge_amount > 12) recharge_amount = 12;
3118 /* But each staff in a stack gets fewer additional charges,
3119 * although always at least one.
3121 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3123 recharge_amount /= o_ptr->number;
3124 if (recharge_amount < 1) recharge_amount = 1;
3127 /* Recharge the wand or staff. */
3128 o_ptr->pval += recharge_amount;
3131 /* Hack -- we no longer "know" the item */
3132 o_ptr->ident &= ~(IDENT_KNOWN);
3134 /* Hack -- we no longer think the item is empty */
3135 o_ptr->ident &= ~(IDENT_EMPTY);
3140 /* Inflict the penalties for failing a recharge. */
3143 /* Artifacts are never destroyed. */
3144 if (object_is_fixed_artifact(o_ptr))
3146 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3148 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3150 msg_format("The recharging backfires - %s is completely drained!", o_name);
3154 /* Artifact rods. */
3155 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3156 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3158 /* Artifact wands and staffs. */
3159 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3164 /* Get the object description */
3165 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3167 /*** Determine Seriousness of Failure ***/
3169 /* Mages recharge objects more safely. */
3170 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)
3172 /* 10% chance to blow up one rod, otherwise draining. */
3173 if (o_ptr->tval == TV_ROD)
3175 if (one_in_(10)) fail_type = 2;
3178 /* 75% chance to blow up one wand, otherwise draining. */
3179 else if (o_ptr->tval == TV_WAND)
3181 if (!one_in_(3)) fail_type = 2;
3184 /* 50% chance to blow up one staff, otherwise no effect. */
3185 else if (o_ptr->tval == TV_STAFF)
3187 if (one_in_(2)) fail_type = 2;
3192 /* All other classes get no special favors. */
3195 /* 33% chance to blow up one rod, otherwise draining. */
3196 if (o_ptr->tval == TV_ROD)
3198 if (one_in_(3)) fail_type = 2;
3201 /* 20% chance of the entire stack, else destroy one wand. */
3202 else if (o_ptr->tval == TV_WAND)
3204 if (one_in_(5)) fail_type = 3;
3207 /* Blow up one staff. */
3208 else if (o_ptr->tval == TV_STAFF)
3214 /*** Apply draining and destruction. ***/
3216 /* Drain object or stack of objects. */
3219 if (o_ptr->tval == TV_ROD)
3222 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3224 msg_print("The recharge backfires, draining the rod further!");
3227 if (o_ptr->timeout < 10000)
3228 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3230 else if (o_ptr->tval == TV_WAND)
3233 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3235 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3240 /* Staffs aren't drained. */
3243 /* Destroy an object or one in a stack of objects. */
3246 if (o_ptr->number > 1)
3248 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3250 msg_format("Wild magic consumes one of your %s!", o_name);
3255 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3257 msg_format("Wild magic consumes your %s!", o_name);
3261 /* Reduce rod stack maximum timeout, drain wands. */
3262 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3263 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3265 /* Reduce and describe inventory */
3268 inven_item_increase(item, -1);
3269 inven_item_describe(item);
3270 inven_item_optimize(item);
3273 /* Reduce and describe floor item */
3276 floor_item_increase(0 - item, -1);
3277 floor_item_describe(0 - item);
3278 floor_item_optimize(0 - item);
3282 /* Destroy all members of a stack of objects. */
3285 if (o_ptr->number > 1)
3287 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3289 msg_format("Wild magic consumes all your %s!", o_name);
3294 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3296 msg_format("Wild magic consumes your %s!", o_name);
3301 /* Reduce and describe inventory */
3304 inven_item_increase(item, -999);
3305 inven_item_describe(item);
3306 inven_item_optimize(item);
3309 /* Reduce and describe floor item */
3312 floor_item_increase(0 - item, -999);
3313 floor_item_describe(0 - item);
3314 floor_item_optimize(0 - item);
3320 /* Combine / Reorder the pack (later) */
3321 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3324 p_ptr->window |= (PW_INVEN);
3326 /* Something was done */
3334 bool bless_weapon(void)
3338 u32b flgs[TR_FLAG_SIZE];
3339 char o_name[MAX_NLEN];
3342 item_tester_no_ryoute = TRUE;
3344 /* Bless only weapons */
3345 item_tester_hook = object_is_weapon;
3349 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3350 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3352 q = "Bless which weapon? ";
3353 s = "You have weapon to bless.";
3356 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3359 /* Get the item (in the pack) */
3362 o_ptr = &inventory[item];
3365 /* Get the item (on the floor) */
3368 o_ptr = &o_list[0 - item];
3373 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3375 /* Extract the flags */
3376 object_flags(o_ptr, flgs);
3378 if (object_is_cursed(o_ptr))
3380 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3381 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3384 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3387 msg_format("The black aura on %s %s disrupts the blessing!",
3388 ((item >= 0) ? "your" : "the"), o_name);
3395 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3398 msg_format("A malignant aura leaves %s %s.",
3399 ((item >= 0) ? "your" : "the"), o_name);
3404 o_ptr->curse_flags = 0L;
3406 /* Hack -- Assume felt */
3407 o_ptr->ident |= (IDENT_SENSE);
3410 o_ptr->feeling = FEEL_NONE;
3412 /* Recalculate the bonuses */
3413 p_ptr->update |= (PU_BONUS);
3416 p_ptr->window |= (PW_EQUIP);
3420 * Next, we try to bless it. Artifacts have a 1/3 chance of
3421 * being blessed, otherwise, the operation simply disenchants
3422 * them, godly power negating the magic. Ok, the explanation
3423 * is silly, but otherwise priests would always bless every
3424 * artifact weapon they find. Ego weapons and normal weapons
3425 * can be blessed automatically.
3427 if (have_flag(flgs, TR_BLESSED))
3430 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3433 msg_format("%s %s %s blessed already.",
3434 ((item >= 0) ? "Your" : "The"), o_name,
3435 ((o_ptr->number > 1) ? "were" : "was"));
3441 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3445 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3448 msg_format("%s %s shine%s!",
3449 ((item >= 0) ? "Your" : "The"), o_name,
3450 ((o_ptr->number > 1) ? "" : "s"));
3453 add_flag(o_ptr->art_flags, TR_BLESSED);
3454 o_ptr->discount = 99;
3458 bool dis_happened = FALSE;
3461 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3463 msg_print("The weapon resists your blessing!");
3467 /* Disenchant tohit */
3468 if (o_ptr->to_h > 0)
3471 dis_happened = TRUE;
3474 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3476 /* Disenchant todam */
3477 if (o_ptr->to_d > 0)
3480 dis_happened = TRUE;
3483 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3485 /* Disenchant toac */
3486 if (o_ptr->to_a > 0)
3489 dis_happened = TRUE;
3492 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3497 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3499 msg_print("There is a static feeling in the air...");
3503 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3506 msg_format("%s %s %s disenchanted!",
3507 ((item >= 0) ? "Your" : "The"), o_name,
3508 ((o_ptr->number > 1) ? "were" : "was"));
3514 /* Recalculate bonuses */
3515 p_ptr->update |= (PU_BONUS);
3518 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3529 bool pulish_shield(void)
3533 u32b flgs[TR_FLAG_SIZE];
3534 char o_name[MAX_NLEN];
3537 item_tester_no_ryoute = TRUE;
3538 /* Assume enchant weapon */
3539 item_tester_tval = TV_SHIELD;
3543 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3544 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3546 q = "Pulish which weapon? ";
3547 s = "You have weapon to pulish.";
3550 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3553 /* Get the item (in the pack) */
3556 o_ptr = &inventory[item];
3559 /* Get the item (on the floor) */
3562 o_ptr = &o_list[0 - item];
3567 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3569 /* Extract the flags */
3570 object_flags(o_ptr, flgs);
3572 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3573 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3576 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3578 msg_format("%s %s shine%s!",
3579 ((item >= 0) ? "Your" : "The"), o_name,
3580 ((o_ptr->number > 1) ? "" : "s"));
3582 o_ptr->name2 = EGO_REFLECTION;
3583 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3585 o_ptr->discount = 99;
3586 chg_virtue(V_ENCHANT, 2);
3592 if (flush_failure) flush();
3595 msg_print("¼ºÇÔ¤·¤¿¡£");
3597 msg_print("Failed.");
3600 chg_virtue(V_ENCHANT, -2);
3609 * Potions "smash open" and cause an area effect when
3610 * (1) they are shattered while in the player's inventory,
3611 * due to cold (etc) attacks;
3612 * (2) they are thrown at a monster, or obstacle;
3613 * (3) they are shattered by a "cold ball" or other such spell
3614 * while lying on the floor.
3617 * who --- who caused the potion to shatter (0=player)
3618 * potions that smash on the floor are assumed to
3619 * be caused by no-one (who = 1), as are those that
3620 * shatter inside the player inventory.
3621 * (Not anymore -- I changed this; TY)
3622 * y, x --- coordinates of the potion (or player if
3623 * the potion was in her inventory);
3624 * o_ptr --- pointer to the potion object.
3626 bool potion_smash_effect(int who, int y, int x, int k_idx)
3633 object_kind *k_ptr = &k_info[k_idx];
3635 switch (k_ptr->sval)
3637 case SV_POTION_SALT_WATER:
3638 case SV_POTION_SLIME_MOLD:
3639 case SV_POTION_LOSE_MEMORIES:
3640 case SV_POTION_DEC_STR:
3641 case SV_POTION_DEC_INT:
3642 case SV_POTION_DEC_WIS:
3643 case SV_POTION_DEC_DEX:
3644 case SV_POTION_DEC_CON:
3645 case SV_POTION_DEC_CHR:
3646 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3647 case SV_POTION_APPLE_JUICE:
3650 case SV_POTION_INFRAVISION:
3651 case SV_POTION_DETECT_INVIS:
3652 case SV_POTION_SLOW_POISON:
3653 case SV_POTION_CURE_POISON:
3654 case SV_POTION_BOLDNESS:
3655 case SV_POTION_RESIST_HEAT:
3656 case SV_POTION_RESIST_COLD:
3657 case SV_POTION_HEROISM:
3658 case SV_POTION_BESERK_STRENGTH:
3659 case SV_POTION_RES_STR:
3660 case SV_POTION_RES_INT:
3661 case SV_POTION_RES_WIS:
3662 case SV_POTION_RES_DEX:
3663 case SV_POTION_RES_CON:
3664 case SV_POTION_RES_CHR:
3665 case SV_POTION_INC_STR:
3666 case SV_POTION_INC_INT:
3667 case SV_POTION_INC_WIS:
3668 case SV_POTION_INC_DEX:
3669 case SV_POTION_INC_CON:
3670 case SV_POTION_INC_CHR:
3671 case SV_POTION_AUGMENTATION:
3672 case SV_POTION_ENLIGHTENMENT:
3673 case SV_POTION_STAR_ENLIGHTENMENT:
3674 case SV_POTION_SELF_KNOWLEDGE:
3675 case SV_POTION_EXPERIENCE:
3676 case SV_POTION_RESISTANCE:
3677 case SV_POTION_INVULNERABILITY:
3678 case SV_POTION_NEW_LIFE:
3679 /* All of the above potions have no effect when shattered */
3681 case SV_POTION_SLOWNESS:
3686 case SV_POTION_POISON:
3691 case SV_POTION_BLINDNESS:
3695 case SV_POTION_CONFUSION: /* Booze */
3699 case SV_POTION_SLEEP:
3703 case SV_POTION_RUINATION:
3704 case SV_POTION_DETONATIONS:
3706 dam = damroll(25, 25);
3709 case SV_POTION_DEATH:
3710 dt = GF_DEATH_RAY; /* !! */
3711 dam = k_ptr->level * 10;
3715 case SV_POTION_SPEED:
3718 case SV_POTION_CURE_LIGHT:
3720 dam = damroll(2, 3);
3722 case SV_POTION_CURE_SERIOUS:
3724 dam = damroll(4, 3);
3726 case SV_POTION_CURE_CRITICAL:
3727 case SV_POTION_CURING:
3729 dam = damroll(6, 3);
3731 case SV_POTION_HEALING:
3733 dam = damroll(10, 10);
3735 case SV_POTION_RESTORE_EXP:
3740 case SV_POTION_LIFE:
3742 dam = damroll(50, 50);
3745 case SV_POTION_STAR_HEALING:
3747 dam = damroll(50, 50);
3750 case SV_POTION_RESTORE_MANA: /* MANA */
3752 dam = damroll(10, 10);
3759 (void)project(who, radius, y, x, dam, dt,
3760 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3762 /* XXX those potions that explode need to become "known" */
3768 * Hack -- Display all known spells in a window
3770 * XXX XXX XXX Need to analyze size of the window.
3772 * XXX XXX XXX Need more color coding.
3774 void display_spell_list(void)
3787 /* They have too many spells to list */
3788 if (p_ptr->pclass == CLASS_SORCERER) return;
3789 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3791 /* mind.c type classes */
3792 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3793 (p_ptr->pclass == CLASS_BERSERKER) ||
3794 (p_ptr->pclass == CLASS_NINJA) ||
3795 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3796 (p_ptr->pclass == CLASS_FORCETRAINER))
3802 int plev = p_ptr->lev;
3808 bool use_hp = FALSE;
3810 /* Display a list of spells */
3813 put_str("̾Á°", y, x + 5);
3814 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3816 put_str("Name", y, x + 5);
3817 put_str("Lv Mana Fail Info", y, x + 35);
3820 switch(p_ptr->pclass)
3822 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3823 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3824 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3825 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3826 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3827 default: use_mind = 0;break;
3830 /* Dump the spells */
3831 for (i = 0; i < MAX_MIND_POWERS; i++)
3833 byte a = TERM_WHITE;
3835 /* Access the available spell */
3836 spell = mind_powers[use_mind].info[i];
3837 if (spell.min_lev > plev) break;
3839 /* Get the failure rate */
3840 chance = spell.fail;
3842 /* Reduce failure rate by "effective" level adjustment */
3843 chance -= 3 * (p_ptr->lev - spell.min_lev);
3845 /* Reduce failure rate by INT/WIS adjustment */
3846 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3850 /* Not enough mana to cast */
3851 if (spell.mana_cost > p_ptr->csp)
3853 chance += 5 * (spell.mana_cost - p_ptr->csp);
3859 /* Not enough hp to cast */
3860 if (spell.mana_cost > p_ptr->chp)
3867 /* Extract the minimum failure rate */
3868 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3870 /* Minimum failure rate */
3871 if (chance < minfail) chance = minfail;
3873 /* Stunning makes spells harder */
3874 if (p_ptr->stun > 50) chance += 25;
3875 else if (p_ptr->stun) chance += 15;
3877 /* Always a 5 percent chance of working */
3878 if (chance > 95) chance = 95;
3881 mindcraft_info(comment, use_mind, i);
3883 /* Dump the spell */
3884 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3886 spell.min_lev, spell.mana_cost, chance, comment);
3888 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3893 /* Cannot read spellbooks */
3894 if (REALM_NONE == p_ptr->realm1) return;
3896 /* Normal spellcaster with books */
3899 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3903 /* Reset vertical */
3906 /* Vertical location */
3907 y = (j < 3) ? 0 : (m[j - 3] + 2);
3909 /* Horizontal location */
3913 for (i = 0; i < 32; i++)
3915 byte a = TERM_WHITE;
3917 /* Access the spell */
3918 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3920 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3924 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3927 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3930 if (s_ptr->slevel >= 99)
3934 strcpy(name, "(ȽÆÉÉÔǽ)");
3936 strcpy(name, "(illegible)");
3946 ((p_ptr->spell_forgotten1 & (1L << i))) :
3947 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3954 else if (!((j < 1) ?
3955 (p_ptr->spell_learned1 & (1L << i)) :
3956 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3963 else if (!((j < 1) ?
3964 (p_ptr->spell_worked1 & (1L << i)) :
3965 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3971 /* Dump the spell --(-- */
3972 sprintf(out_val, "%c/%c) %-20.20s",
3973 I2A(n / 8), I2A(n % 8), name);
3978 /* Dump onto the window */
3979 Term_putstr(x, m[j], -1, a, out_val);
3989 * Returns experience of a spell
3991 s16b experience_of_spell(int spell, int use_realm)
3993 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3994 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3995 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3996 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4002 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4004 int mod_need_mana(int need_mana, int spell, int realm)
4006 #define MANA_CONST 2400
4008 #define DEC_MANA_DIV 3
4011 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4014 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4015 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4017 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4018 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4019 need_mana /= MANA_CONST * MANA_DIV;
4020 if (need_mana < 1) need_mana = 1;
4023 /* Non-realm magic */
4026 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4038 * Modify spell fail rate
4039 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4041 int mod_spell_chance_1(int chance)
4043 chance += p_ptr->to_m_chance;
4045 if (p_ptr->heavy_spell) chance += 20;
4047 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4048 else if (p_ptr->easy_spell) chance -= 3;
4049 else if (p_ptr->dec_mana) chance -= 2;
4056 * Modify spell fail rate (as "suffix" process)
4057 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4058 * Note: variable "chance" cannot be negative.
4060 int mod_spell_chance_2(int chance)
4062 if (p_ptr->dec_mana) chance--;
4064 if (p_ptr->heavy_spell) chance += 5;
4066 return MAX(chance, 0);
4071 * Returns spell chance of failure for spell -RAK-
4073 s16b spell_chance(int spell, int use_realm)
4075 int chance, minfail;
4078 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4081 /* Paranoia -- must be literate */
4082 if (!mp_ptr->spell_book) return (100);
4084 if (use_realm == REALM_HISSATSU) return 0;
4086 /* Access the spell */
4087 if (!is_magic(use_realm))
4089 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4093 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4096 /* Extract the base spell failure rate */
4097 chance = s_ptr->sfail;
4099 /* Reduce failure rate by "effective" level adjustment */
4100 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4102 /* Reduce failure rate by INT/WIS adjustment */
4103 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4106 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4108 /* Extract mana consumption rate */
4109 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4111 /* Not enough mana to cast */
4112 if (need_mana > p_ptr->csp)
4114 chance += 5 * (need_mana - p_ptr->csp);
4117 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4119 /* Extract the minimum failure rate */
4120 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4123 * Non mage/priest characters never get too good
4124 * (added high mage, mindcrafter)
4126 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4128 if (minfail < 5) minfail = 5;
4131 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4132 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4133 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4135 chance = mod_spell_chance_1(chance);
4137 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4138 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4139 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4141 /* Minimum failure rate */
4142 if (chance < minfail) chance = minfail;
4144 /* Stunning makes spells harder */
4145 if (p_ptr->stun > 50) chance += 25;
4146 else if (p_ptr->stun) chance += 15;
4148 /* Always a 5 percent chance of working */
4149 if (chance > 95) chance = 95;
4151 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4152 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4154 s16b exp = experience_of_spell(spell, use_realm);
4155 if (exp >= SPELL_EXP_EXPERT) chance--;
4156 if (exp >= SPELL_EXP_MASTER) chance--;
4159 /* Return the chance */
4160 return mod_spell_chance_2(chance);
4166 * Determine if a spell is "okay" for the player to cast or study
4167 * The spell must be legible, not forgotten, and also, to cast,
4168 * it must be known, and to study, it must not be known.
4170 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4174 /* Access the spell */
4175 if (!is_magic(use_realm))
4177 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4181 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4184 /* Spell is illegal */
4185 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4187 /* Spell is forgotten */
4188 if ((use_realm == p_ptr->realm2) ?
4189 (p_ptr->spell_forgotten2 & (1L << spell)) :
4190 (p_ptr->spell_forgotten1 & (1L << spell)))
4196 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4197 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4199 /* Spell is learned */
4200 if ((use_realm == p_ptr->realm2) ?
4201 (p_ptr->spell_learned2 & (1L << spell)) :
4202 (p_ptr->spell_learned1 & (1L << spell)))
4205 return (!study_pray);
4208 /* Okay to study, not to cast */
4214 * Print a list of spells (for browsing or casting or viewing)
4216 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4218 int i, spell, exp_level, increment = 64;
4230 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4232 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4234 msg_print("Warning! print_spells called with null realm");
4238 /* Title the list */
4240 if (use_realm == REALM_HISSATSU)
4242 strcpy(buf," Lv MP");
4244 strcpy(buf," Lv SP");
4248 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4250 strcpy(buf,"Profic Lv SP Fail Effect");
4254 put_str("̾Á°", y, x + 5);
4255 put_str(buf, y, x + 29);
4257 put_str("Name", y, x + 5);
4258 put_str(buf, y, x + 29);
4261 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4262 else if (use_realm == p_ptr->realm1) increment = 0;
4263 else if (use_realm == p_ptr->realm2) increment = 32;
4265 /* Dump the spells */
4266 for (i = 0; i < num; i++)
4268 /* Access the spell */
4271 /* Access the spell */
4272 if (!is_magic(use_realm))
4274 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4278 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4281 if (use_realm == REALM_HISSATSU)
4282 need_mana = s_ptr->smana;
4285 s16b exp = experience_of_spell(spell, use_realm);
4287 /* Extract mana consumption rate */
4288 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4290 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4291 else exp_level = spell_exp_level(exp);
4294 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4295 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4296 else if (s_ptr->slevel >= 99) max = TRUE;
4297 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4299 strncpy(ryakuji, exp_level_str[exp_level], 4);
4304 if (use_menu && target_spell)
4306 if (i == (target_spell-1))
4308 strcpy(out_val, " ¡Õ ");
4310 strcpy(out_val, " > ");
4313 strcpy(out_val, " ");
4315 else sprintf(out_val, " %c) ", I2A(i));
4316 /* Skip illegible spells */
4317 if (s_ptr->slevel >= 99)
4320 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4322 strcat(out_val, format("%-30s", "(illegible)"));
4325 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4329 /* XXX XXX Could label spells above the players level */
4331 /* Get extra info */
4332 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4337 /* Assume spell is known and tried */
4338 line_attr = TERM_WHITE;
4340 /* Analyze the spell */
4341 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4343 if (s_ptr->slevel > p_ptr->max_plv)
4348 comment = "unknown";
4351 line_attr = TERM_L_BLUE;
4353 else if (s_ptr->slevel > p_ptr->lev)
4358 comment = "forgotten";
4361 line_attr = TERM_YELLOW;
4364 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4369 comment = "unknown";
4372 line_attr = TERM_L_BLUE;
4374 else if ((use_realm == p_ptr->realm1) ?
4375 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4376 ((p_ptr->spell_forgotten2 & (1L << spell))))
4381 comment = "forgotten";
4384 line_attr = TERM_YELLOW;
4386 else if (!((use_realm == p_ptr->realm1) ?
4387 (p_ptr->spell_learned1 & (1L << spell)) :
4388 (p_ptr->spell_learned2 & (1L << spell))))
4393 comment = "unknown";
4396 line_attr = TERM_L_BLUE;
4398 else if (!((use_realm == p_ptr->realm1) ?
4399 (p_ptr->spell_worked1 & (1L << spell)) :
4400 (p_ptr->spell_worked2 & (1L << spell))))
4405 comment = "untried";
4408 line_attr = TERM_L_GREEN;
4411 /* Dump the spell --(-- */
4412 if (use_realm == REALM_HISSATSU)
4414 strcat(out_val, format("%-25s %2d %4d",
4415 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4416 s_ptr->slevel, need_mana));
4420 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4421 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4422 (max ? '!' : ' '), ryakuji,
4423 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4425 c_prt(line_attr, out_val, y + i + 1, x);
4428 /* Clear the bottom line */
4429 prt("", y + i + 1, x);
4434 * Note that amulets, rods, and high-level spell books are immune
4435 * to "inventory damage" of any kind. Also sling ammo and shovels.
4440 * Does a given class of objects (usually) hate acid?
4441 * Note that acid can either melt or corrode something.
4443 bool hates_acid(object_type *o_ptr)
4445 /* Analyze the type */
4446 switch (o_ptr->tval)
4448 /* Wearable items */
4468 /* Staffs/Scrolls are wood/paper */
4481 /* Junk is useless */
4495 * Does a given object (usually) hate electricity?
4497 bool hates_elec(object_type *o_ptr)
4499 switch (o_ptr->tval)
4513 * Does a given object (usually) hate fire?
4514 * Hafted/Polearm weapons have wooden shafts.
4515 * Arrows/Bows are mostly wooden.
4517 bool hates_fire(object_type *o_ptr)
4519 /* Analyze the type */
4520 switch (o_ptr->tval)
4538 case TV_SORCERY_BOOK:
4539 case TV_NATURE_BOOK:
4543 case TV_ARCANE_BOOK:
4545 case TV_DAEMON_BOOK:
4546 case TV_CRUSADE_BOOK:
4548 case TV_HISSATSU_BOOK:
4559 /* Staffs/Scrolls burn */
4572 * Does a given object (usually) hate cold?
4574 bool hates_cold(object_type *o_ptr)
4576 switch (o_ptr->tval)
4593 int set_acid_destroy(object_type *o_ptr)
4595 u32b flgs[TR_FLAG_SIZE];
4596 if (!hates_acid(o_ptr)) return (FALSE);
4597 object_flags(o_ptr, flgs);
4598 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4606 int set_elec_destroy(object_type *o_ptr)
4608 u32b flgs[TR_FLAG_SIZE];
4609 if (!hates_elec(o_ptr)) return (FALSE);
4610 object_flags(o_ptr, flgs);
4611 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4619 int set_fire_destroy(object_type *o_ptr)
4621 u32b flgs[TR_FLAG_SIZE];
4622 if (!hates_fire(o_ptr)) return (FALSE);
4623 object_flags(o_ptr, flgs);
4624 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4632 int set_cold_destroy(object_type *o_ptr)
4634 u32b flgs[TR_FLAG_SIZE];
4635 if (!hates_cold(o_ptr)) return (FALSE);
4636 object_flags(o_ptr, flgs);
4637 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4643 * Destroys a type of item on a given percent chance
4644 * Note that missiles are no longer necessarily all destroyed
4645 * Destruction taken from "melee.c" code for "stealing".
4646 * New-style wands and rods handled correctly. -LM-
4647 * Returns number of items destroyed.
4649 int inven_damage(inven_func typ, int perc)
4653 char o_name[MAX_NLEN];
4655 /* Multishadow effects is determined by turn */
4656 if( p_ptr->multishadow && (turn & 1) )return 0;
4658 if (p_ptr->inside_arena) return 0;
4660 /* Count the casualties */
4663 /* Scan through the slots backwards */
4664 for (i = 0; i < INVEN_PACK; i++)
4666 o_ptr = &inventory[i];
4668 /* Skip non-objects */
4669 if (!o_ptr->k_idx) continue;
4671 /* Hack -- for now, skip artifacts */
4672 if (object_is_artifact(o_ptr)) continue;
4674 /* Give this item slot a shot at death */
4677 /* Count the casualties */
4678 for (amt = j = 0; j < o_ptr->number; ++j)
4680 if (randint0(100) < perc) amt++;
4683 /* Some casualities */
4686 /* Get a description */
4687 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4691 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4693 msg_format("%sour %s (%c) %s destroyed!",
4697 o_name, index_to_label(i),
4698 ((o_ptr->number > 1) ?
4699 ((amt == o_ptr->number) ? "Á´Éô" :
4700 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4702 ((o_ptr->number > 1) ?
4703 ((amt == o_ptr->number) ? "All of y" :
4704 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4705 o_name, index_to_label(i),
4706 ((amt > 1) ? "were" : "was"));
4710 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4711 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4714 /* Potions smash open */
4715 if (object_is_potion(o_ptr))
4717 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4720 /* Reduce the charges of rods/wands */
4721 reduce_charges(o_ptr, amt);
4723 /* Destroy "amt" items */
4724 inven_item_increase(i, -amt);
4725 inven_item_optimize(i);
4727 /* Count the casualties */
4733 /* Return the casualty count */
4739 * Acid has hit the player, attempt to affect some armor.
4741 * Note that the "base armor" of an object never changes.
4743 * If any armor is damaged (or resists), the player takes less damage.
4745 static int minus_ac(void)
4747 object_type *o_ptr = NULL;
4748 u32b flgs[TR_FLAG_SIZE];
4749 char o_name[MAX_NLEN];
4752 /* Pick a (possibly empty) inventory slot */
4753 switch (randint1(7))
4755 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4756 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4757 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4758 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4759 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4760 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4761 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4764 /* Nothing to damage */
4765 if (!o_ptr->k_idx) return (FALSE);
4767 if (!object_is_armour(o_ptr)) return (FALSE);
4769 /* No damage left to be done */
4770 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4774 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4776 /* Extract the flags */
4777 object_flags(o_ptr, flgs);
4779 /* Object resists */
4780 if (have_flag(flgs, TR_IGNORE_ACID))
4783 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
4785 msg_format("Your %s is unaffected!", o_name);
4794 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
4796 msg_format("Your %s is damaged!", o_name);
4800 /* Damage the item */
4803 /* Calculate bonuses */
4804 p_ptr->update |= (PU_BONUS);
4807 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4811 /* Item was damaged */
4817 * Hurt the player with Acid
4819 int acid_dam(int dam, cptr kb_str, int monspell)
4822 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4823 bool double_resist = IS_OPPOSE_ACID();
4825 /* Total Immunity */
4826 if (p_ptr->immune_acid || (dam <= 0))
4828 learn_spell(monspell);
4832 /* Vulnerability (Ouch!) */
4833 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4834 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4836 /* Resist the damage */
4837 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4838 if (double_resist) dam = (dam + 2) / 3;
4840 if ((!(double_resist || p_ptr->resist_acid)) &&
4841 one_in_(HURT_CHANCE))
4842 (void)do_dec_stat(A_CHR);
4844 /* If any armor gets hit, defend the player */
4845 if (minus_ac()) dam = (dam + 1) / 2;
4848 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4850 /* Inventory damage */
4851 if (!(double_resist && p_ptr->resist_acid))
4852 inven_damage(set_acid_destroy, inv);
4858 * Hurt the player with electricity
4860 int elec_dam(int dam, cptr kb_str, int monspell)
4863 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4864 bool double_resist = IS_OPPOSE_ELEC();
4866 /* Total immunity */
4867 if (p_ptr->immune_elec || (dam <= 0))
4869 learn_spell(monspell);
4873 /* Vulnerability (Ouch!) */
4874 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4875 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4876 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4878 /* Resist the damage */
4879 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4880 if (double_resist) dam = (dam + 2) / 3;
4882 if ((!(double_resist || p_ptr->resist_elec)) &&
4883 one_in_(HURT_CHANCE))
4884 (void)do_dec_stat(A_DEX);
4887 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4889 /* Inventory damage */
4890 if (!(double_resist && p_ptr->resist_elec))
4891 inven_damage(set_elec_destroy, inv);
4898 * Hurt the player with Fire
4900 int fire_dam(int dam, cptr kb_str, int monspell)
4903 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4904 bool double_resist = IS_OPPOSE_FIRE();
4906 /* Totally immune */
4907 if (p_ptr->immune_fire || (dam <= 0))
4909 learn_spell(monspell);
4913 /* Vulnerability (Ouch!) */
4914 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4915 if (prace_is_(RACE_ENT)) dam += dam / 3;
4916 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4918 /* Resist the damage */
4919 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4920 if (double_resist) dam = (dam + 2) / 3;
4922 if ((!(double_resist || p_ptr->resist_fire)) &&
4923 one_in_(HURT_CHANCE))
4924 (void)do_dec_stat(A_STR);
4927 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4929 /* Inventory damage */
4930 if (!(double_resist && p_ptr->resist_fire))
4931 inven_damage(set_fire_destroy, inv);
4938 * Hurt the player with Cold
4940 int cold_dam(int dam, cptr kb_str, int monspell)
4943 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4944 bool double_resist = IS_OPPOSE_COLD();
4946 /* Total immunity */
4947 if (p_ptr->immune_cold || (dam <= 0))
4949 learn_spell(monspell);
4953 /* Vulnerability (Ouch!) */
4954 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4955 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4957 /* Resist the damage */
4958 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4959 if (double_resist) dam = (dam + 2) / 3;
4961 if ((!(double_resist || p_ptr->resist_cold)) &&
4962 one_in_(HURT_CHANCE))
4963 (void)do_dec_stat(A_STR);
4966 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
4968 /* Inventory damage */
4969 if (!(double_resist && p_ptr->resist_cold))
4970 inven_damage(set_cold_destroy, inv);
4976 bool rustproof(void)
4980 char o_name[MAX_NLEN];
4983 item_tester_no_ryoute = TRUE;
4984 /* Select a piece of armour */
4985 item_tester_hook = object_is_armour;
4989 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
4990 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4992 q = "Rustproof which piece of armour? ";
4993 s = "You have nothing to rustproof.";
4996 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4998 /* Get the item (in the pack) */
5001 o_ptr = &inventory[item];
5004 /* Get the item (on the floor) */
5007 o_ptr = &o_list[0 - item];
5012 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5014 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5016 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
5019 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5021 msg_format("%s %s look%s as good as new!",
5022 ((item >= 0) ? "Your" : "The"), o_name,
5023 ((o_ptr->number > 1) ? "" : "s"));
5030 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5032 msg_format("%s %s %s now protected against corrosion.",
5033 ((item >= 0) ? "Your" : "The"), o_name,
5034 ((o_ptr->number > 1) ? "are" : "is"));
5045 * Curse the players armor
5047 bool curse_armor(void)
5052 char o_name[MAX_NLEN];
5055 /* Curse the body armor */
5056 o_ptr = &inventory[INVEN_BODY];
5058 /* Nothing to curse */
5059 if (!o_ptr->k_idx) return (FALSE);
5063 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5065 /* Attempt a saving throw for artifacts */
5066 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
5070 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5071 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5073 msg_format("A %s tries to %s, but your %s resists the effects!",
5074 "terrible black aura", "surround your armor", o_name);
5079 /* not artifact or failed save... */
5084 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5086 msg_format("A terrible black aura blasts your %s!", o_name);
5089 chg_virtue(V_ENCHANT, -5);
5091 /* Blast the armor */
5093 o_ptr->name2 = EGO_BLASTED;
5094 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5101 for (i = 0; i < TR_FLAG_SIZE; i++)
5102 o_ptr->art_flags[i] = 0;
5105 o_ptr->curse_flags = TRC_CURSED;
5108 o_ptr->ident |= (IDENT_BROKEN);
5110 /* Recalculate bonuses */
5111 p_ptr->update |= (PU_BONUS);
5113 /* Recalculate mana */
5114 p_ptr->update |= (PU_MANA);
5117 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5125 * Curse the players weapon
5127 bool curse_weapon(bool force, int slot)
5133 char o_name[MAX_NLEN];
5136 /* Curse the weapon */
5137 o_ptr = &inventory[slot];
5139 /* Nothing to curse */
5140 if (!o_ptr->k_idx) return (FALSE);
5144 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5146 /* Attempt a saving throw */
5147 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5151 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5152 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5154 msg_format("A %s tries to %s, but your %s resists the effects!",
5155 "terrible black aura", "surround your weapon", o_name);
5160 /* not artifact or failed save... */
5165 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5167 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5170 chg_virtue(V_ENCHANT, -5);
5172 /* Shatter the weapon */
5174 o_ptr->name2 = EGO_SHATTERED;
5175 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5176 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5182 for (i = 0; i < TR_FLAG_SIZE; i++)
5183 o_ptr->art_flags[i] = 0;
5187 o_ptr->curse_flags = TRC_CURSED;
5190 o_ptr->ident |= (IDENT_BROKEN);
5192 /* Recalculate bonuses */
5193 p_ptr->update |= (PU_BONUS);
5195 /* Recalculate mana */
5196 p_ptr->update |= (PU_MANA);
5199 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5208 * Enchant some bolts
5210 bool brand_bolts(void)
5214 /* Use the first acceptable bolts */
5215 for (i = 0; i < INVEN_PACK; i++)
5217 object_type *o_ptr = &inventory[i];
5219 /* Skip non-bolts */
5220 if (o_ptr->tval != TV_BOLT) continue;
5222 /* Skip artifacts and ego-items */
5223 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5226 /* Skip cursed/broken items */
5227 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5230 if (randint0(100) < 75) continue;
5234 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5236 msg_print("Your bolts are covered in a fiery aura!");
5241 o_ptr->name2 = EGO_FLAME;
5244 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5251 if (flush_failure) flush();
5255 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5257 msg_print("The fiery enchantment failed.");
5267 * Helper function -- return a "nearby" race for polymorphing
5269 * Note that this function is one of the more "dangerous" ones...
5271 static s16b poly_r_idx(int r_idx)
5273 monster_race *r_ptr = &r_info[r_idx];
5275 int i, r, lev1, lev2;
5277 /* Hack -- Uniques/Questors never polymorph */
5278 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5279 (r_ptr->flags1 & RF1_QUESTOR))
5282 /* Allowable range of "levels" for resulting monster */
5283 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5284 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5286 /* Pick a (possibly new) non-unique race */
5287 for (i = 0; i < 1000; i++)
5289 /* Pick a new race, using a level calculation */
5290 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5292 /* Handle failure */
5298 /* Ignore unique monsters */
5299 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5301 /* Ignore monsters with incompatible levels */
5302 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5304 /* Use that index */
5316 bool polymorph_monster(int y, int x)
5318 cave_type *c_ptr = &cave[y][x];
5319 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5320 bool polymorphed = FALSE;
5322 int old_r_idx = m_ptr->r_idx;
5323 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5324 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5325 monster_type back_m;
5327 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5329 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5331 /* Memorize the monster before polymorphing */
5334 /* Pick a "new" monster race */
5335 new_r_idx = poly_r_idx(old_r_idx);
5337 /* Handle polymorph */
5338 if (new_r_idx != old_r_idx)
5342 /* Get the monsters attitude */
5343 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5344 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5345 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5347 /* "Kill" the "old" monster */
5348 delete_monster_idx(c_ptr->m_idx);
5350 /* Create a new monster (no groups) */
5351 if (place_monster_aux(0, y, x, new_r_idx, mode))
5358 /* Placing the new monster failed */
5359 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5363 for (cmi = 0; cmi < MAX_MTIMED; cmi++)
5365 back_m.mtimed[cmi] = 0;
5366 back_m.mproc_idx[cmi] = 0;
5368 m_list[hack_m_idx_ii] = back_m;
5370 if (MON_CSLEEP(&back_m)) (void)set_monster_csleep(hack_m_idx_ii, MON_CSLEEP(&back_m));
5371 if (MON_FAST(&back_m)) (void)set_monster_fast(hack_m_idx_ii, MON_FAST(&back_m));
5372 if (MON_SLOW(&back_m)) (void)set_monster_slow(hack_m_idx_ii, MON_SLOW(&back_m));
5373 if (MON_STUNNED(&back_m)) (void)set_monster_stunned(hack_m_idx_ii, MON_STUNNED(&back_m));
5374 if (MON_CONFUSED(&back_m)) (void)set_monster_confused(hack_m_idx_ii, MON_CONFUSED(&back_m));
5375 if (MON_MONFEAR(&back_m)) (void)set_monster_monfear(hack_m_idx_ii, MON_MONFEAR(&back_m));
5376 if (MON_INVULNER(&back_m)) (void)set_monster_invulner(hack_m_idx_ii, MON_INVULNER(&back_m), FALSE);
5380 if (targeted) target_who = hack_m_idx_ii;
5381 if (health_tracked) health_track(hack_m_idx_ii);
5391 static bool dimension_door_aux(int x, int y)
5393 int plev = p_ptr->lev;
5395 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5397 if (!cave_player_teleportable_bold(y, x, FALSE, FALSE) ||
5398 (distance(y, x, py, px) > plev / 2 + 10) ||
5399 (!randint0(plev / 10 + 10)))
5401 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5402 teleport_player((plev + 2) * 2, TRUE);
5409 teleport_player_to(y, x, TRUE, FALSE);
5420 bool dimension_door(void)
5424 /* Rerutn FALSE if cancelled */
5425 if (!tgt_pt(&x, &y)) return FALSE;
5427 if (dimension_door_aux(x, y)) return TRUE;
5430 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5432 msg_print("You fail to exit the astral plane correctly!");
5440 * Mirror Master's Dimension Door
5442 bool mirror_tunnel(void)
5446 /* Rerutn FALSE if cancelled */
5447 if (!tgt_pt(&x, &y)) return FALSE;
5449 if (dimension_door_aux(x, y)) return TRUE;
5452 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5454 msg_print("You fail to pass the mirror plane correctly!");
5461 bool eat_magic(int power)
5463 object_type * o_ptr;
5466 int recharge_strength = 0;
5472 char o_name[MAX_NLEN];
5474 item_tester_hook = item_tester_hook_recharge;
5478 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5479 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5481 q = "Drain which item? ";
5482 s = "You have nothing to drain.";
5485 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5489 o_ptr = &inventory[item];
5493 o_ptr = &o_list[0 - item];
5496 k_ptr = &k_info[o_ptr->k_idx];
5497 lev = k_info[o_ptr->k_idx].level;
5499 if (o_ptr->tval == TV_ROD)
5501 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5504 if (one_in_(recharge_strength))
5506 /* Activate the failure code. */
5511 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5514 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5516 msg_print("You can't absorb energy from a discharged rod.");
5523 o_ptr->timeout += k_ptr->pval;
5529 /* All staffs, wands. */
5530 recharge_strength = (100 + power - lev) / 15;
5533 if (recharge_strength < 0) recharge_strength = 0;
5536 if (one_in_(recharge_strength))
5538 /* Activate the failure code. */
5543 if (o_ptr->pval > 0)
5545 p_ptr->csp += lev / 2;
5548 /* XXX Hack -- unstack if necessary */
5549 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5554 /* Get local object */
5557 /* Obtain a local object */
5558 object_copy(q_ptr, o_ptr);
5560 /* Modify quantity */
5563 /* Restore the charges */
5566 /* Unstack the used item */
5568 p_ptr->total_weight -= q_ptr->weight;
5569 item = inven_carry(q_ptr);
5573 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5575 msg_print("You unstack your staff.");
5583 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5585 msg_print("There's no energy there to absorb!");
5589 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5593 /* Inflict the penalties for failing a recharge. */
5596 /* Artifacts are never destroyed. */
5597 if (object_is_fixed_artifact(o_ptr))
5599 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5601 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5603 msg_format("The recharging backfires - %s is completely drained!", o_name);
5607 /* Artifact rods. */
5608 if (o_ptr->tval == TV_ROD)
5609 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5611 /* Artifact wands and staffs. */
5612 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5617 /* Get the object description */
5618 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5620 /*** Determine Seriousness of Failure ***/
5622 /* Mages recharge objects more safely. */
5623 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)
5625 /* 10% chance to blow up one rod, otherwise draining. */
5626 if (o_ptr->tval == TV_ROD)
5628 if (one_in_(10)) fail_type = 2;
5631 /* 75% chance to blow up one wand, otherwise draining. */
5632 else if (o_ptr->tval == TV_WAND)
5634 if (!one_in_(3)) fail_type = 2;
5637 /* 50% chance to blow up one staff, otherwise no effect. */
5638 else if (o_ptr->tval == TV_STAFF)
5640 if (one_in_(2)) fail_type = 2;
5645 /* All other classes get no special favors. */
5648 /* 33% chance to blow up one rod, otherwise draining. */
5649 if (o_ptr->tval == TV_ROD)
5651 if (one_in_(3)) fail_type = 2;
5654 /* 20% chance of the entire stack, else destroy one wand. */
5655 else if (o_ptr->tval == TV_WAND)
5657 if (one_in_(5)) fail_type = 3;
5660 /* Blow up one staff. */
5661 else if (o_ptr->tval == TV_STAFF)
5667 /*** Apply draining and destruction. ***/
5669 /* Drain object or stack of objects. */
5672 if (o_ptr->tval == TV_ROD)
5675 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5677 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5680 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5682 else if (o_ptr->tval == TV_WAND)
5685 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5687 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5692 /* Staffs aren't drained. */
5695 /* Destroy an object or one in a stack of objects. */
5698 if (o_ptr->number > 1)
5701 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5703 msg_format("Wild magic consumes one of your %s!", o_name);
5706 /* Reduce rod stack maximum timeout, drain wands. */
5707 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5708 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5713 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5715 msg_format("Wild magic consumes your %s!", o_name);
5718 /* Reduce and describe inventory */
5721 inven_item_increase(item, -1);
5722 inven_item_describe(item);
5723 inven_item_optimize(item);
5726 /* Reduce and describe floor item */
5729 floor_item_increase(0 - item, -1);
5730 floor_item_describe(0 - item);
5731 floor_item_optimize(0 - item);
5735 /* Destroy all members of a stack of objects. */
5738 if (o_ptr->number > 1)
5740 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5742 msg_format("Wild magic consumes all your %s!", o_name);
5747 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5749 msg_format("Wild magic consumes your %s!", o_name);
5754 /* Reduce and describe inventory */
5757 inven_item_increase(item, -999);
5758 inven_item_describe(item);
5759 inven_item_optimize(item);
5762 /* Reduce and describe floor item */
5765 floor_item_increase(0 - item, -999);
5766 floor_item_describe(0 - item);
5767 floor_item_optimize(0 - item);
5773 if (p_ptr->csp > p_ptr->msp)
5775 p_ptr->csp = p_ptr->msp;
5778 /* Redraw mana and hp */
5779 p_ptr->redraw |= (PR_MANA);
5781 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5782 p_ptr->window |= (PW_INVEN);
5788 bool summon_kin_player(int level, int y, int x, u32b mode)
5790 bool pet = (bool)(mode & PM_FORCE_PET);
5791 if (!pet) mode |= PM_NO_PET;
5793 switch (p_ptr->mimic_form)
5796 switch (p_ptr->prace)
5800 case RACE_BARBARIAN:
5803 summon_kin_type = 'p';
5813 case RACE_MIND_FLAYER:
5816 summon_kin_type = 'h';
5819 summon_kin_type = 'o';
5821 case RACE_HALF_TROLL:
5822 summon_kin_type = 'T';
5824 case RACE_HALF_OGRE:
5825 summon_kin_type = 'O';
5827 case RACE_HALF_GIANT:
5828 case RACE_HALF_TITAN:
5830 summon_kin_type = 'P';
5833 summon_kin_type = 'y';
5836 summon_kin_type = 'K';
5839 summon_kin_type = 'k';
5842 if (one_in_(13)) summon_kin_type = 'U';
5843 else summon_kin_type = 'u';
5845 case RACE_DRACONIAN:
5846 summon_kin_type = 'd';
5850 summon_kin_type = 'g';
5853 if (one_in_(13)) summon_kin_type = 'L';
5854 else summon_kin_type = 's';
5857 summon_kin_type = 'z';
5860 summon_kin_type = 'V';
5863 summon_kin_type = 'G';
5866 summon_kin_type = 'I';
5869 summon_kin_type = '#';
5872 summon_kin_type = 'A';
5875 summon_kin_type = 'U';
5878 summon_kin_type = 'p';
5883 if (one_in_(13)) summon_kin_type = 'U';
5884 else summon_kin_type = 'u';
5886 case MIMIC_DEMON_LORD:
5887 summon_kin_type = 'U';
5890 summon_kin_type = 'V';
5893 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);