3 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Î¼ÂÁõ / Object code, part 2
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
8 * This software may be copied and distributed for educational, research,\n
9 * and not for profit purposes provided that this copyright and statement\n
10 * are included in all such copies. Other copyrights may also apply.\n
11 * 2014 Deskull rearranged comment for Doxygen.\n
19 * @brief ¾²¾å¡¢¥â¥ó¥¹¥¿¡¼½ê»ý¤Ç¥¹¥¿¥Ã¥¯¤µ¤ì¤¿¥¢¥¤¥Æ¥à¤òºï½ü¤·¥¹¥¿¥Ã¥¯¤òÊä´°¤¹¤ë / Excise a dungeon object from any stacks
20 * @param o_idx ºï½üÂоݤΥª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΥݥ¤¥ó¥¿
23 void excise_object_idx(int o_idx)
27 s16b this_o_idx, next_o_idx = 0;
33 j_ptr = &o_list[o_idx];
36 if (j_ptr->held_m_idx)
41 m_ptr = &m_list[j_ptr->held_m_idx];
43 /* Scan all objects in the grid */
44 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
49 o_ptr = &o_list[this_o_idx];
51 /* Acquire next object */
52 next_o_idx = o_ptr->next_o_idx;
55 if (this_o_idx == o_idx)
60 /* Remove from list */
61 m_ptr->hold_o_idx = next_o_idx;
70 k_ptr = &o_list[prev_o_idx];
72 /* Remove from list */
73 k_ptr->next_o_idx = next_o_idx;
76 /* Forget next pointer */
77 o_ptr->next_o_idx = 0;
84 prev_o_idx = this_o_idx;
99 /* Scan all objects in the grid */
100 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
105 o_ptr = &o_list[this_o_idx];
107 /* Acquire next object */
108 next_o_idx = o_ptr->next_o_idx;
111 if (this_o_idx == o_idx)
116 /* Remove from list */
117 c_ptr->o_idx = next_o_idx;
125 /* Previous object */
126 k_ptr = &o_list[prev_o_idx];
128 /* Remove from list */
129 k_ptr->next_o_idx = next_o_idx;
132 /* Forget next pointer */
133 o_ptr->next_o_idx = 0;
139 /* Save prev_o_idx */
140 prev_o_idx = this_o_idx;
146 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤òºï½ü¤¹¤ë /
147 * Delete a dungeon object
148 * @param o_idx ºï½üÂоݤΥª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΥݥ¤¥ó¥¿
151 * Handle "stacks" of objects correctly.
153 void delete_object_idx(int o_idx)
158 excise_object_idx(o_idx);
161 j_ptr = &o_list[o_idx];
164 if (!(j_ptr->held_m_idx))
176 /* Wipe the object */
185 * @brief ¥Õ¥í¥¢¤Ë¥Þ¥¹¤ËÍî¤Á¤Æ¤¤¤ë¥ª¥Ö¥¸¥§¥¯¥È¤òÁ´¤Æºï½ü¤¹¤ë / Deletes all objects at given location
186 * Delete a dungeon object
187 * @param y ºï½ü¤·¤¿¥Õ¥í¥¢¥Þ¥¹¤ÎYºÂɸ
188 * @param x ºï½ü¤·¤¿¥Õ¥í¥¢¥Þ¥¹¤ÎXºÂɸ
191 void delete_object(int y, int x)
195 s16b this_o_idx, next_o_idx = 0;
198 /* Refuse "illegal" locations */
199 if (!in_bounds(y, x)) return;
205 /* Scan all objects in the grid */
206 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
211 o_ptr = &o_list[this_o_idx];
213 /* Acquire next object */
214 next_o_idx = o_ptr->next_o_idx;
216 /* Wipe the object */
223 /* Objects are gone */
232 * @brief ¥°¥í¡¼¥Ð¥ë¥ª¥Ö¥¸¥§¥¯¥ÈÇÛÎó¤ËÂФ·»ØÄêÈϰϤΥª¥Ö¥¸¥§¥¯¥È¤òÀ°Íý¤·¤ÆID¤Î¼ã¤¤½ç¤Ë´ó¤»¤ë /
233 * Move an object from index i1 to index i2 in the object list
234 * @param i1 À°Íý¤·¤¿¤¤ÇÛÎó¤Î»ÏÅÀ
235 * @param i2 À°Íý¤·¤¿¤¤ÇÛÎó¤Î½ªÅÀ
238 static void compact_objects_aux(int i1, int i2)
248 if (i1 == i2) return;
252 for (i = 1; i < o_max; i++)
257 /* Skip "dead" objects */
258 if (!o_ptr->k_idx) continue;
260 /* Repair "next" pointers */
261 if (o_ptr->next_o_idx == i1)
264 o_ptr->next_o_idx = i2;
274 if (o_ptr->held_m_idx)
278 /* Acquire monster */
279 m_ptr = &m_list[o_ptr->held_m_idx];
282 if (m_ptr->hold_o_idx == i1)
285 m_ptr->hold_o_idx = i2;
294 /* Acquire location */
302 if (c_ptr->o_idx == i1)
311 o_list[i2] = o_list[i1];
319 * @brief ¥°¥í¡¼¥Ð¥ë¥ª¥Ö¥¸¥§¥¯¥ÈÇÛÎ󤫤éÍ¥ÀèÅÙ¤ÎÄ㤤¤â¤Î¤òºï½ü¤·¡¢¥Ç¡¼¥¿¤ò°µ½Ì¤¹¤ë¡£ /
320 * Compact and Reorder the object list.
321 * @size ºÇÄã¤Ç¤â¸º¤é¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¿ô¤Î¿å½à
324 * ¡Ê´í¸±¤Ê¤Î¤Ç»ÈÍѤˤÏÃí°Õ¤¹¤ë¤³¤È¡Ë
325 * This function can be very dangerous, use with caution!\n
327 * When actually "compacting" objects, we base the saving throw on a\n
328 * combination of object level, distance from player, and current\n
331 * After "compacting" (if needed), we "reorder" the objects into a more\n
332 * compact order, and we reset the allocation info, and the "live" array.\n
334 void compact_objects(int size)
336 int i, y, x, num, cnt;
337 int cur_lev, cur_dis, chance;
346 msg_print("¥¢¥¤¥Æ¥à¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
348 msg_print("Compacting objects...");
353 p_ptr->redraw |= (PR_MAP);
356 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
360 /* Compact at least 'size' objects */
361 for (num = 0, cnt = 1; num < size; cnt++)
363 /* Get more vicious each iteration */
366 /* Get closer each iteration */
367 cur_dis = 5 * (20 - cnt);
369 /* Examine the objects */
370 for (i = 1; i < o_max; i++)
374 /* Skip dead objects */
375 if (!o_ptr->k_idx) continue;
377 /* Hack -- High level objects start out "immune" */
378 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
381 if (o_ptr->held_m_idx)
385 /* Acquire monster */
386 m_ptr = &m_list[o_ptr->held_m_idx];
388 /* Get the location */
392 /* Monsters protect their objects */
393 if (randint0(100) < 90) continue;
399 /* Get the location */
404 /* Nearby objects start out "immune" */
405 if ((cur_dis > 0) && (distance(py, px, y, x) < cur_dis)) continue;
410 /* Hack -- only compact artifacts in emergencies */
411 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
412 (cnt < 1000)) chance = 100;
414 /* Apply the saving throw */
415 if (randint0(100) < chance) continue;
417 /* Delete the object */
418 delete_object_idx(i);
426 /* Excise dead objects (backwards!) */
427 for (i = o_max - 1; i >= 1; i--)
431 /* Skip real objects */
432 if (o_ptr->k_idx) continue;
434 /* Move last object into open hole */
435 compact_objects_aux(o_max - 1, i);
437 /* Compress "o_max" */
444 * @brief ¥°¥í¡¼¥Ð¥ë¥ª¥Ö¥¸¥§¥¯¥ÈÇÛÎó¤ò½é´ü²½¤¹¤ë /
445 * Delete all the items when player leaves the level
446 * @note we do NOT visually reflect these (irrelevant) changes
448 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
449 * and the "m_ptr->next_o_idx" field for every monster, since
450 * we know we are clearing every object. Technically, we only
451 * clear those fields for grids/monsters containing objects,
452 * and we clear it once for every such object.
455 void wipe_o_list(void)
459 /* Delete the existing objects */
460 for (i = 1; i < o_max; i++)
462 object_type *o_ptr = &o_list[i];
464 /* Skip dead objects */
465 if (!o_ptr->k_idx) continue;
467 /* Mega-Hack -- preserve artifacts */
468 if (!character_dungeon || preserve_mode)
470 /* Hack -- Preserve unknown artifacts */
471 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
473 /* Mega-Hack -- Preserve the artifact */
474 a_info[o_ptr->name1].cur_num = 0;
479 if (o_ptr->held_m_idx)
484 m_ptr = &m_list[o_ptr->held_m_idx];
486 /* Hack -- see above */
487 m_ptr->hold_o_idx = 0;
495 /* Access location */
502 /* Hack -- see above */
506 /* Wipe the object */
519 * @brief ¥°¥í¡¼¥Ð¥ë¥ª¥Ö¥¸¥§¥¯¥ÈÇÛÎ󤫤é¶õ¤¤ò¼èÆÀ¤¹¤ë /
520 * Acquires and returns the index of a "free" object.
521 * @return ³«¤¤¤Æ¤¤¤ë¥ª¥Ö¥¸¥§¥¯¥ÈÍ×ÁǤÎID
523 * This routine should almost never fail, but in case it does,
524 * we must be sure to handle "failure" of this routine.
531 /* Initial allocation */
532 if (o_max < max_o_idx)
537 /* Expand object array */
543 /* Use this object */
548 /* Recycle dead objects */
549 for (i = 1; i < o_max; i++)
556 /* Skip live objects */
557 if (o_ptr->k_idx) continue;
562 /* Use this object */
567 /* Warn the player (except during dungeon creation) */
569 if (character_dungeon) msg_print("¥¢¥¤¥Æ¥à¤¬Â¿¤¹¤®¤ë¡ª");
571 if (character_dungeon) msg_print("Too many objects!");
581 * @brief ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥Æ¡¼¥Ö¥ë¤ËÀ¸À®À©Ìó¤ò²Ã¤¨¤ë /
582 * Apply a "object restriction function" to the "object allocation table"
583 * @return ¾ï¤Ë0¤òÊÖ¤¹¡£
584 * @details À¸À®¤ÎÀ©Ìó¤Ï¥°¥í¡¼¥Ð¥ë¤Îget_obj_num_hook´Ø¿ô¥Ý¥¤¥ó¥¿¤Ç²Ã¤¨¤ë
586 static errr get_obj_num_prep(void)
591 alloc_entry *table = alloc_kind_table;
593 /* Scan the allocation table */
594 for (i = 0; i < alloc_kind_size; i++)
596 /* Accept objects which pass the restriction, if any */
597 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
599 /* Accept this object */
600 table[i].prob2 = table[i].prob1;
603 /* Do not use this object */
606 /* Decline this object */
617 * @brief ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¥Æ¡¼¥Ö¥ë¤«¤é¥¢¥¤¥Æ¥à¤ò¼èÆÀ¤¹¤ë /
618 * Choose an object kind that seems "appropriate" to the given level
620 * @return Áª¤Ð¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¥Ù¡¼¥¹ID
622 * This function uses the "prob2" field of the "object allocation table",\n
623 * and various local information, to calculate the "prob3" field of the\n
624 * same table, which is then used to choose an "appropriate" object, in\n
625 * a relatively efficient manner.\n
627 * It is (slightly) more likely to acquire an object of the given level\n
628 * than one of a lower level. This is done by choosing several objects\n
629 * appropriate to the given level and keeping the "hardest" one.\n
631 * Note that if no objects are "appropriate", then this function will\n
632 * fail, and return zero, but this should *almost* never happen.\n
634 s16b get_obj_num(int level)
640 alloc_entry *table = alloc_kind_table;
642 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
645 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
647 /* Occasional "boost" */
648 if (one_in_(GREAT_OBJ))
650 /* What a bizarre calculation */
651 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
658 /* Process probabilities */
659 for (i = 0; i < alloc_kind_size; i++)
661 /* Objects are sorted by depth */
662 if (table[i].level > level) break;
667 /* Access the index */
668 k_idx = table[i].index;
670 /* Access the actual kind */
671 k_ptr = &k_info[k_idx];
673 /* Hack -- prevent embedded chests */
674 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
677 table[i].prob3 = table[i].prob2;
680 total += table[i].prob3;
683 /* No legal objects */
684 if (total <= 0) return (0);
688 value = randint0(total);
690 /* Find the object */
691 for (i = 0; i < alloc_kind_size; i++)
693 /* Found the entry */
694 if (value < table[i].prob3) break;
697 value = value - table[i].prob3;
704 /* Try for a "better" object once (50%) or twice (10%) */
711 value = randint0(total);
713 /* Find the object */
714 for (i = 0; i < alloc_kind_size; i++)
716 /* Found the entry */
717 if (value < table[i].prob3) break;
720 value = value - table[i].prob3;
723 /* Keep the "best" one */
724 if (table[i].level < table[j].level) i = j;
727 /* Try for a "better" object twice (10%) */
734 value = randint0(total);
736 /* Find the object */
737 for (i = 0; i < alloc_kind_size; i++)
739 /* Found the entry */
740 if (value < table[i].prob3) break;
743 value = value - table[i].prob3;
746 /* Keep the "best" one */
747 if (table[i].level < table[j].level) i = j;
752 return (table[i].index);
757 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò´ÕÄêºÑ¤Ë¤¹¤ë /
758 * Known is true when the "attributes" of an object are "known".
759 * @param o_ptr ´ÕÄêºÑ¤Ë¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
761 * These include tohit, todam, toac, cost, and pval (charges).\n
763 * Note that "knowing" an object gives you everything that an "awareness"\n
764 * gives you, and much more. In fact, the player is always "aware" of any\n
765 * item of which he has full "knowledge".\n
767 * But having full knowledge of, say, one "wand of wonder", does not, by\n
768 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
769 * It happens that most "identify" routines (including "buying from a shop")\n
770 * will make the player "aware" of the object as well as fully "know" it.\n
772 * This routine also removes any inscriptions generated by "feelings".\n
774 void object_known(object_type *o_ptr)
776 /* Remove "default inscriptions" */
777 o_ptr->feeling = FEEL_NONE;
779 /* Clear the "Felt" info */
780 o_ptr->ident &= ~(IDENT_SENSE);
782 /* Clear the "Empty" info */
783 o_ptr->ident &= ~(IDENT_EMPTY);
785 /* Now we know about the item */
786 o_ptr->ident |= (IDENT_KNOWN);
790 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò¡ö´ÕÄê¡öºÑ¤Ë¤¹¤ë /
791 * The player is now aware of the effects of the given object.
792 * @param o_ptr ¡ö´ÕÄê¡öºÑ¤Ë¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
795 void object_aware(object_type *o_ptr)
797 bool mihanmei = !object_is_aware(o_ptr);
799 /* Fully aware of the effects */
800 k_info[o_ptr->k_idx].aware = TRUE;
802 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
803 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
807 char o_name[MAX_NLEN];
810 object_copy(q_ptr, o_ptr);
813 object_desc(o_name, q_ptr, OD_NAME_ONLY);
815 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
821 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò»î¹ÔºÑ¤Ë¤¹¤ë /
822 * Something has been "sampled"
823 * @param o_ptr »î¹ÔºÑ¤Ë¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
826 void object_tried(object_type *o_ptr)
828 /* Mark it as tried (even if "aware") */
829 k_info[o_ptr->k_idx].tried = TRUE;
834 * @brief ̤´ÕÄê¤Ê¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤Î´ðËܲÁ³Ê¤òÊÖ¤¹ /
835 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
836 * @param o_ptr ̤´ÕÄê²Á³Ê¤ò³Îǧ¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
837 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤Î̤´ÕÄê²Á³Ê
839 static s32b object_value_base(object_type *o_ptr)
841 /* Aware item -- use template cost */
842 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
844 /* Analyze the type */
849 case TV_FOOD: return (5L);
851 /* Un-aware Potions */
852 case TV_POTION: return (20L);
854 /* Un-aware Scrolls */
855 case TV_SCROLL: return (20L);
857 /* Un-aware Staffs */
858 case TV_STAFF: return (70L);
861 case TV_WAND: return (50L);
864 case TV_ROD: return (90L);
867 case TV_RING: return (45L);
869 /* Un-aware Amulets */
870 case TV_AMULET: return (45L);
872 /* Figurines, relative to monster level */
875 int level = r_info[o_ptr->pval].level;
876 if (level < 20) return level*50L;
877 else if (level < 30) return 1000+(level-20)*150L;
878 else if (level < 40) return 2500+(level-30)*350L;
879 else if (level < 50) return 6000+(level-40)*800L;
880 else return 14000+(level-50)*2000L;
884 if (!o_ptr->pval) return 1000L;
885 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
888 /* Paranoia -- Oops */
894 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Õ¥é¥°Îफ¤é²Á³Ê¤ò»»½Ð¤¹¤ë /
895 * Return the value of the flags the object has...
896 * @param o_ptr ¥Õ¥é¥°²Á³Ê¤ò³Îǧ¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
897 * @param plusses ¥Õ¥é¥°¤ËÍ¿¤¨¤ë²Á³Ê¤Î´ðËܽŤß
898 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Õ¥é¥°²Á³Ê
900 s32b flag_cost(object_type *o_ptr, int plusses)
903 u32b flgs[TR_FLAG_SIZE];
907 object_kind *k_ptr = &k_info[o_ptr->k_idx];
909 object_flags(o_ptr, flgs);
912 * Exclude fixed flags of the base item.
913 * pval bonuses of base item will be treated later.
915 for (i = 0; i < TR_FLAG_SIZE; i++)
916 flgs[i] &= ~(k_ptr->flags[i]);
918 /* Exclude fixed flags of the fixed artifact. */
919 if (object_is_fixed_artifact(o_ptr))
921 artifact_type *a_ptr = &a_info[o_ptr->name1];
923 for (i = 0; i < TR_FLAG_SIZE; i++)
924 flgs[i] &= ~(a_ptr->flags[i]);
927 /* Exclude fixed flags of the ego-item. */
928 else if (object_is_ego(o_ptr))
930 ego_item_type *e_ptr = &e_info[o_ptr->name2];
932 for (i = 0; i < TR_FLAG_SIZE; i++)
933 flgs[i] &= ~(e_ptr->flags[i]);
938 * Calucurate values of remaining flags
940 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
941 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
942 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
943 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
944 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
945 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
946 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
947 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
948 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
949 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
950 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
951 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
952 total += (10000 + (2500 * plusses));
953 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
954 total += (10000 + (2500 * plusses));
958 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
959 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
960 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
961 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
962 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
963 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
964 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
965 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
966 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
967 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
968 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
969 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
970 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
971 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
972 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
973 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
974 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
975 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
976 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
977 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
978 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
980 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
981 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
982 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
983 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
984 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
985 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
986 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
987 total += (tmp_cost * count);
989 if (have_flag(flgs, TR_SUST_STR)) total += 850;
990 if (have_flag(flgs, TR_SUST_INT)) total += 850;
991 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
992 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
993 if (have_flag(flgs, TR_SUST_CON)) total += 850;
994 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
995 if (have_flag(flgs, TR_RIDING)) total += 0;
996 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
997 if (have_flag(flgs, TR_THROW)) total += 5000;
998 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
999 if (have_flag(flgs, TR_HOLD_LIFE)) total += 8500;
1003 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
1004 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
1005 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
1006 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
1007 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
1008 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
1009 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1010 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1011 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1012 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1013 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1014 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1015 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1016 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1017 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1018 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1019 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1020 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1021 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1022 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1023 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1024 total += (tmp_cost * count);
1026 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1027 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1028 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1029 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1030 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1031 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1032 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1033 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1034 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1035 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1036 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1037 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1038 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1039 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1040 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1041 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1042 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1043 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1044 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1045 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1046 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1047 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1048 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1049 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1050 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1051 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1052 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1053 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1054 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1055 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1056 if (have_flag(flgs, TR_REGEN)) total += 2500;
1057 if (have_flag(flgs, TR_WARNING)) total += 2000;
1058 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1059 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1060 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1061 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1062 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1063 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1064 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1065 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1066 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1067 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1068 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1069 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1070 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1071 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1072 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1073 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1074 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1075 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1076 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1077 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1078 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1079 if (have_flag(flgs, TR_TELEPORT))
1081 if (object_is_cursed(o_ptr))
1086 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1087 if (have_flag(flgs, TR_BLESSED)) total += 750;
1088 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1089 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1090 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1091 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1092 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1094 /* Also, give some extra for activatable powers... */
1095 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1097 const activation_type* const act_ptr = find_activation_info(o_ptr);
1099 total += act_ptr->value;
1108 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Î¿¿¤Î²Á³Ê¤ò»»½Ð¤¹¤ë /
1109 * Return the value of the flags the object has...
1110 * @param o_ptr ËܲÁ³Ê¤ò³Îǧ¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1111 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤ÎËܲÁ³Ê
1113 * Return the "real" price of a "known" item, not including discounts\n
1115 * Wand and staffs get cost for each charge\n
1117 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1119 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1121 * Missiles are only worth 5 gold per bonus point, since they\n
1122 * usually appear in groups of 20, and we want the player to get\n
1123 * the same amount of cash for any "equivalent" item. Note that\n
1124 * missiles never have any of the "pval" flags, and in fact, they\n
1125 * only have a few of the available flags, primarily of the "slay"\n
1126 * and "brand" and "ignore" variety.\n
1128 * Armor with a negative armor bonus is worthless.\n
1129 * Weapons with negative hit+damage bonuses are worthless.\n
1131 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1133 s32b object_value_real(object_type *o_ptr)
1137 u32b flgs[TR_FLAG_SIZE];
1139 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1142 /* Hack -- "worthless" items */
1143 if (!k_info[o_ptr->k_idx].cost) return (0L);
1146 value = k_info[o_ptr->k_idx].cost;
1148 /* Extract some flags */
1149 object_flags(o_ptr, flgs);
1152 if (object_is_fixed_artifact(o_ptr))
1154 artifact_type *a_ptr = &a_info[o_ptr->name1];
1156 /* Hack -- "worthless" artifacts */
1157 if (!a_ptr->cost) return (0L);
1159 /* Hack -- Use the artifact cost instead */
1160 value = a_ptr->cost;
1161 value += flag_cost(o_ptr, o_ptr->pval);
1163 /* Don't add pval bonuses etc. */
1168 else if (object_is_ego(o_ptr))
1170 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1172 /* Hack -- "worthless" ego-items */
1173 if (!e_ptr->cost) return (0L);
1175 /* Hack -- Reward the ego-item with a bonus */
1176 value += e_ptr->cost;
1177 value += flag_cost(o_ptr, o_ptr->pval);
1185 for (i = 0; i < TR_FLAG_SIZE; i++)
1186 if (o_ptr->art_flags[i]) flag = TRUE;
1188 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1191 /* Analyze pval bonus for normal object */
1192 switch (o_ptr->tval)
1215 if (!o_ptr->pval) break;
1217 /* Hack -- Negative "pval" is always bad */
1218 if (o_ptr->pval < 0) return (0L);
1220 /* Give credit for stat bonuses */
1221 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1222 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1223 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1224 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1225 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1226 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1228 /* Give credit for stealth and searching */
1229 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1230 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1231 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1233 /* Give credit for infra-vision and tunneling */
1234 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1235 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1237 /* Give credit for extra attacks */
1238 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1240 /* Give credit for speed bonus */
1241 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1247 /* Analyze the item */
1248 switch (o_ptr->tval)
1253 /* Pay extra for charges, depending on standard number of
1254 * charges. Handle new-style wands correctly. -LM-
1256 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1263 /* Pay extra for charges, depending on standard number of
1266 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1276 /* Hack -- negative bonuses are bad */
1277 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1279 /* Give credit for bonuses */
1280 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1297 /* Hack -- negative armor bonus */
1298 if (o_ptr->to_a < 0) return (0L);
1300 /* Give credit for bonuses */
1301 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1314 /* Hack -- negative hit/damage bonuses */
1315 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1317 /* Factor in the bonuses */
1318 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1320 /* Hack -- Factor in extra damage dice and sides */
1321 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1322 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1333 /* Hack -- negative hit/damage bonuses */
1334 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1336 /* Factor in the bonuses */
1337 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1339 /* Hack -- Factor in extra damage dice and sides */
1340 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1341 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1347 /* Figurines, relative to monster level */
1350 int level = r_info[o_ptr->pval].level;
1351 if (level < 20) value = level*50L;
1352 else if (level < 30) value = 1000+(level-20)*150L;
1353 else if (level < 40) value = 2500+(level-30)*350L;
1354 else if (level < 50) value = 6000+(level-40)*800L;
1355 else value = 14000+(level-50)*2000L;
1361 if (!o_ptr->pval) value = 1000L;
1362 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1368 if (!o_ptr->pval) value = 0L;
1373 /* Worthless object */
1374 if (value < 0) return 0L;
1376 /* Return the value */
1382 * @brief ¥ª¥Ö¥¸¥§¥¯¥È²Á³Ê»»½Ð¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
1383 * Return the price of an item including plusses (and charges)
1384 * @param o_ptr ȽÌÀ¤·¤Æ¤¤¤ë¸½²Á³Ê¤ò³Îǧ¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1385 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤ÎȽÌÀ¤·¤Æ¤¤¤ë¸½²Á³Ê
1387 * This function returns the "value" of the given item (qty one)\n
1389 * Never notice "unknown" bonuses or properties, including "curses",\n
1390 * since that would give the player information he did not have.\n
1392 * Note that discounted items stay discounted forever, even if\n
1393 * the discount is "forgotten" by the player via memory loss.\n
1395 s32b object_value(object_type *o_ptr)
1400 /* Unknown items -- acquire a base value */
1401 if (object_is_known(o_ptr))
1403 /* Broken items -- worthless */
1404 if (object_is_broken(o_ptr)) return (0L);
1406 /* Cursed items -- worthless */
1407 if (object_is_cursed(o_ptr)) return (0L);
1409 /* Real value (see above) */
1410 value = object_value_real(o_ptr);
1413 /* Known items -- acquire the actual value */
1416 /* Hack -- Felt broken items */
1417 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1419 /* Hack -- Felt cursed items */
1420 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1422 /* Base value (see above) */
1423 value = object_value_base(o_ptr);
1427 /* Apply discount (if any) */
1428 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1431 /* Return the final value */
1438 * @brief Ç˲õ²Äǽ¤Ê¥¢¥¤¥Æ¥à¤«¤òÊÖ¤¹ /
1439 * Determines whether an object can be destroyed, and makes fake inscription.
1440 * @param o_ptr Ç˲õ²Äǽ¤«¤ò³Îǧ¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1441 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤¬Ç˲õ²Äǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
1443 bool can_player_destroy_object(object_type *o_ptr)
1445 /* Artifacts cannot be destroyed */
1446 if (!object_is_artifact(o_ptr)) return TRUE;
1448 /* If object is unidentified, makes fake inscription */
1449 if (!object_is_known(o_ptr))
1451 byte feel = FEEL_SPECIAL;
1453 /* Hack -- Handle icky artifacts */
1454 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1456 /* Hack -- inscribe the artifact */
1457 o_ptr->feeling = feel;
1459 /* We have "felt" it (again) */
1460 o_ptr->ident |= (IDENT_SENSE);
1462 /* Combine the pack */
1463 p_ptr->notice |= (PN_COMBINE);
1466 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1472 /* Identified artifact -- Nothing to do */
1478 * @brief ËâË¡ËÀ¤ä¥í¥Ã¥É¤Î¥¹¥í¥Ã¥Èʬ³ä»þ¤Ë»ÈÍѲó¿ô¤òʬÇÛ¤¹¤ë /
1479 * Distribute charges of rods or wands.
1480 * @param o_ptr ʬ³ä¸µ¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿ source item
1481 * @param q_ptr ʬ³äÀ襪¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿ target item, must be of the same type as o_ptr
1482 * @param amt ʬ³ä¤·¤¿¤¤²ó¿ôÎÌ number of items that are transfered
1485 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1486 * charges need to be allocated between the two stacks. If all the items\n
1487 * are being dropped, it makes for a neater message to leave the original\n
1488 * stack's pval alone. -LM-\n
1490 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1492 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1494 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1495 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1497 /* Hack -- Rods also need to have their timeouts distributed. The
1498 * dropped stack will accept all time remaining to charge up to its
1501 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1503 if (q_ptr->pval > o_ptr->timeout)
1504 q_ptr->timeout = o_ptr->timeout;
1506 q_ptr->timeout = q_ptr->pval;
1508 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1514 * @brief ËâË¡ËÀ¤ä¥í¥Ã¥É¤Î»ÈÍѲó¿ô¤ò¸º¤é¤¹ /
1515 * @param o_ptr ¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿ source item
1516 * @param amt ¸º¤é¤·¤¿¤¤²ó¿ôÎÌ number of items that are transfered
1519 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1520 * charges of the stack needs to be reduced, unless all the items are\n
1521 * being destroyed. -LM-\n
1523 void reduce_charges(object_type *o_ptr, int amt)
1525 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1526 (amt < o_ptr->number))
1528 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1533 * Determine if an item can "absorb" a second item
1535 * See "object_absorb()" for the actual "absorption" code.
1537 * If permitted, we allow staffs (if they are known to have equal charges
1538 * and both are either known or confirmed empty) and wands (if both are
1539 * either known or confirmed empty) and rods (in all cases) to combine.
1540 * Staffs will unstack (if necessary) when they are used, but wands and
1541 * rods will only unstack if one is dropped. -LM-
1543 * If permitted, we allow weapons/armor to stack, if fully "known".
1545 * Missiles will combine if both stacks have the same "known" status.
1546 * This is done to make unidentified stacks of missiles useful.
1548 * Food, potions, scrolls, and "easy know" items always stack.
1550 * Chests, and activatable items, never stack (for various reasons).
1554 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1556 #define MAX_STACK_SIZE 99
1560 * @brief ¥Ö¥¸¥§¥¯¥È¤ò¥¹¥í¥Ã¥È¤Ë½Å¤Í¹ç¤ï¤»²Äǽ¤ÊºÇÂç¿ô¤òÊÖ¤¹¡£
1561 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1562 * @param o_ptr ¸¡¾Ú¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿1
1563 * @param j_ptr ¸¡¾Ú¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿2
1564 * @return ½Å¤Í¹ç¤ï¤»²Äǽ¤Ê¥¢¥¤¥Æ¥à¿ô
1566 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1570 /* Default maximum number of stack */
1571 int max_num = MAX_STACK_SIZE;
1573 /* Require identical object types */
1574 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1577 /* Analyze the items */
1578 switch (o_ptr->tval)
1580 /* Chests and Statues*/
1591 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1592 if (o_ptr->pval != j_ptr->pval) return 0;
1596 /* Figurines and Corpses*/
1601 if (o_ptr->pval != j_ptr->pval) return 0;
1607 /* Food and Potions and Scrolls */
1619 /* Require either knowledge or known empty for both staffs. */
1620 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1621 !object_is_known(o_ptr)) ||
1622 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1623 !object_is_known(j_ptr))) return 0;
1625 /* Require identical charges, since staffs are bulky. */
1626 if (o_ptr->pval != j_ptr->pval) return 0;
1635 /* Require either knowledge or known empty for both wands. */
1636 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1637 !object_is_known(o_ptr)) ||
1638 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1639 !object_is_known(j_ptr))) return 0;
1641 /* Wand charges combine in O&ZAngband. */
1647 /* Staffs and Wands and Rods */
1650 /* Prevent overflaw of timeout */
1651 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1657 /* Weapons and Armor */
1673 /* Rings, Amulets, Lites */
1679 /* Require full knowledge of both items */
1680 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1690 /* Require identical knowledge of both items */
1691 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1692 if (o_ptr->feeling != j_ptr->feeling) return 0;
1694 /* Require identical "bonuses" */
1695 if (o_ptr->to_h != j_ptr->to_h) return 0;
1696 if (o_ptr->to_d != j_ptr->to_d) return 0;
1697 if (o_ptr->to_a != j_ptr->to_a) return 0;
1699 /* Require identical "pval" code */
1700 if (o_ptr->pval != j_ptr->pval) return 0;
1702 /* Artifacts never stack */
1703 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1705 /* Require identical "ego-item" names */
1706 if (o_ptr->name2 != j_ptr->name2) return 0;
1708 /* Require identical added essence */
1709 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1710 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1712 /* Hack -- Never stack "powerful" items */
1713 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1715 /* Hack -- Never stack recharging items */
1716 if (o_ptr->timeout || j_ptr->timeout) return 0;
1718 /* Require identical "values" */
1719 if (o_ptr->ac != j_ptr->ac) return 0;
1720 if (o_ptr->dd != j_ptr->dd) return 0;
1721 if (o_ptr->ds != j_ptr->ds) return 0;
1730 /* Require knowledge */
1731 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1739 /* Hack -- Identical art_flags! */
1740 for (i = 0; i < TR_FLAG_SIZE; i++)
1741 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1743 /* Hack -- Require identical "cursed" status */
1744 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1746 /* Hack -- Require identical "broken" status */
1747 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1750 /* Hack -- require semi-matching "inscriptions" */
1751 if (o_ptr->inscription && j_ptr->inscription &&
1752 (o_ptr->inscription != j_ptr->inscription))
1755 /* Hack -- normally require matching "inscriptions" */
1756 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1758 /* Hack -- normally require matching "discounts" */
1759 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1762 /* They match, so they must be similar */
1767 * @brief ¥Ö¥¸¥§¥¯¥È¤ò¥¹¥í¥Ã¥È¤Ë½Å¤Í¤ë¤³¤È¤¬¤Ç¤¤ë¤«¤É¤¦¤«¤òÊÖ¤¹¡£
1768 * Determine if an item can absorb a second item.
1769 * @param o_ptr ¸¡¾Ú¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿1
1770 * @param j_ptr ¸¡¾Ú¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿2
1771 * @return ½Å¤Í¹ç¤ï¤»²Äǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
1773 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1775 int total = o_ptr->number + j_ptr->number;
1778 /* Are these objects similar? */
1779 max_num = object_similar_part(o_ptr, j_ptr);
1781 /* Return if not similar */
1782 if (!max_num) return FALSE;
1784 /* Maximal "stacking" limit */
1785 if (total > max_num) return (0);
1788 /* They match, so they must be similar */
1794 * @brief ¥Ö¥¸¥§¥¯¥È¤ò¥¹¥í¥Ã¥È¤Ë½Å¤Í¹ç¤ï¤»¤ë¡£
1795 * Allow one item to "absorb" another, assuming they are similar
1796 * @param o_ptr ½Å¤Í¹ç¤ï¤»Àè¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1797 * @param j_ptr ½Å¤Í¹ç¤ï¤»¸µ¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1800 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1802 int max_num = object_similar_part(o_ptr, j_ptr);
1803 int total = o_ptr->number + j_ptr->number;
1804 int diff = (total > max_num) ? total - max_num : 0;
1806 /* Combine quantity, lose excess items */
1807 o_ptr->number = (total > max_num) ? max_num : total;
1809 /* Hack -- blend "known" status */
1810 if (object_is_known(j_ptr)) object_known(o_ptr);
1812 /* Hack -- clear "storebought" if only one has it */
1813 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1814 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1816 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1817 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1820 /* Hack -- blend "mental" status */
1821 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1823 /* Hack -- blend "inscriptions" */
1824 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1826 /* Hack -- blend "feelings" */
1827 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1829 /* Hack -- could average discounts XXX XXX XXX */
1830 /* Hack -- save largest discount XXX XXX XXX */
1831 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1833 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1834 if (o_ptr->tval == TV_ROD)
1836 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1837 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1840 /* Hack -- if wands are stacking, combine the charges. -LM- */
1841 if (o_ptr->tval == TV_WAND)
1843 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1849 * @brief tval¤Èsval¤ËÂбþ¤¹¤ë¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤ÎID¤òÊÖ¤¹¡£
1850 * Find the index of the object_kind with the given tval and sval
1851 * @param tval ¸¡º÷¤·¤¿¤¤¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤Îtval
1852 * @param sval ¸¡º÷¤·¤¿¤¤¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤Îsval
1855 s16b lookup_kind(int tval, int sval)
1862 for (k = 1; k < max_k_idx; k++)
1864 object_kind *k_ptr = &k_info[k];
1866 /* Require correct tval */
1867 if (k_ptr->tval != tval) continue;
1870 if (k_ptr->sval == sval) return (k);
1872 /* Ignore illegal items */
1873 if (sval != SV_ANY) continue;
1875 /* Apply the randomizer */
1876 if (!one_in_(++num)) continue;
1878 /* Use this value */
1882 /* Return this choice */
1891 msg_format("¥¢¥¤¥Æ¥à¤¬¤Ê¤¤ (%d,%d)", tval, sval);
1893 msg_format("No object (%d,%d)", tval, sval);
1904 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ò½é´ü²½¤¹¤ë
1905 * Wipe an object clean.
1906 * @param o_ptr ½é´ü²½¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1909 void object_wipe(object_type *o_ptr)
1911 /* Wipe the structure */
1912 (void)WIPE(o_ptr, object_type);
1917 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤òÊ£À½¤¹¤ë
1918 * Wipe an object clean.
1919 * @param o_ptr Ê£À½¸µ¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1920 * @param j_ptr Ê£À½Àè¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1923 void object_copy(object_type *o_ptr, object_type *j_ptr)
1925 /* Copy the structure */
1926 (void)COPY(o_ptr, j_ptr, object_type);
1931 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤ˥١¼¥¹¥¢¥¤¥Æ¥à¤òºîÀ®¤¹¤ë
1932 * Prepare an object based on an object kind.
1933 * @param o_ptr ÂåÆþ¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1934 * @param k_idx ¿·¤¿¤ËºîÀ®¤·¤¿¤¤¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¾ðÊó¤ÎID
1937 void object_prep(object_type *o_ptr, int k_idx)
1939 object_kind *k_ptr = &k_info[k_idx];
1941 /* Clear the record */
1944 /* Save the kind index */
1945 o_ptr->k_idx = k_idx;
1947 /* Efficiency -- tval/sval */
1948 o_ptr->tval = k_ptr->tval;
1949 o_ptr->sval = k_ptr->sval;
1951 /* Default "pval" */
1952 o_ptr->pval = k_ptr->pval;
1954 /* Default number */
1957 /* Default weight */
1958 o_ptr->weight = k_ptr->weight;
1961 o_ptr->to_h = k_ptr->to_h;
1962 o_ptr->to_d = k_ptr->to_d;
1963 o_ptr->to_a = k_ptr->to_a;
1966 o_ptr->ac = k_ptr->ac;
1967 o_ptr->dd = k_ptr->dd;
1968 o_ptr->ds = k_ptr->ds;
1970 /* Default activation */
1971 if (k_ptr->act_idx > 0) o_ptr->xtra2 = k_ptr->act_idx;
1973 /* Hack -- worthless items are always "broken" */
1974 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
1976 /* Hack -- cursed items are always "cursed" */
1977 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
1978 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
1979 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
1980 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
1981 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
1982 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
1987 * @brief ¾å¼Á°Ê¾å¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ËÍ¿¤¨¤ë¤¿¤á¤Î³Æ¼ï¥Ü¡¼¥Ê¥¹¤òÀµµ¬Íð¿ô¤â²Ã¤¨¤Æ»»½Ð¤¹¤ë¡£
1988 * Help determine an "enchantment bonus" for an object.
1989 * @param max ¥Ü¡¼¥Ê¥¹ÃͤθÂÅÙ
1990 * @param level ¥Ü¡¼¥Ê¥¹Ãͤ˲ÃÌ£¤¹¤ë´ð½àÀ¸À®³¬
1991 * @return »»½Ð¤µ¤ì¤¿¥Ü¡¼¥Ê¥¹ÃÍ
1993 * To avoid floating point but still provide a smooth distribution of bonuses,\n
1994 * we simply round the results of division in such a way as to "average" the\n
1995 * correct floating point value.\n
1997 * This function has been changed. It uses "randnor()" to choose values from\n
1998 * a normal distribution, whose mean moves from zero towards the max as the\n
1999 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
2000 * and whose values are forced to lie between zero and the max, inclusive.\n
2002 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2003 * rare to get the "full" enchantment on an object, even a deep levels.\n
2005 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2007 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2009 * N 0 1 2 3 4 5 6 7 8 9 10\n
2010 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2011 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2012 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2013 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2014 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2015 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2016 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2017 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2018 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2019 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2020 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2021 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2022 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2023 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2024 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2025 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2026 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2027 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2029 s16b m_bonus(int max, int level)
2031 int bonus, stand, extra, value;
2034 /* Paranoia -- enforce maximal "level" */
2035 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2038 /* The "bonus" moves towards the max */
2039 bonus = ((max * level) / MAX_DEPTH);
2041 /* Hack -- determine fraction of error */
2042 extra = ((max * level) % MAX_DEPTH);
2044 /* Hack -- simulate floating point computations */
2045 if (randint0(MAX_DEPTH) < extra) bonus++;
2048 /* The "stand" is equal to one quarter of the max */
2051 /* Hack -- determine fraction of error */
2054 /* Hack -- simulate floating point computations */
2055 if (randint0(4) < extra) stand++;
2058 /* Choose an "interesting" value */
2059 value = randnor(bonus, stand);
2061 /* Enforce the minimum value */
2062 if (value < 0) return (0);
2064 /* Enforce the maximum value */
2065 if (value > max) return (max);
2073 * @brief ¥Ç¥Ð¥Ã¥°»þ¤Ë¥¢¥¤¥Æ¥àÀ¸À®¾ðÊó¤ò¥á¥Ã¥»¡¼¥¸¤Ë½ÐÎϤ¹¤ë / Cheat -- describe a created object for the user
2074 * @param o_ptr ¥Ç¥Ð¥Ã¥°½ÐÎϤ¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2077 static void object_mention(object_type *o_ptr)
2079 char o_name[MAX_NLEN];
2082 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
2085 if (object_is_fixed_artifact(o_ptr))
2089 msg_format("ÅÁÀâ¤Î¥¢¥¤¥Æ¥à (%s)", o_name);
2091 msg_format("Artifact (%s)", o_name);
2096 /* Random Artifact */
2097 else if (o_ptr->art_name)
2100 msg_print("¥é¥ó¥À¥à¡¦¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È");
2102 msg_print("Random artifact");
2108 else if (object_is_ego(o_ptr))
2112 msg_format("̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à (%s)", o_name);
2114 msg_format("Ego-item (%s)", o_name);
2124 msg_format("¥¢¥¤¥Æ¥à (%s)", o_name);
2126 msg_format("Object (%s)", o_name);
2133 * @brief INSTA_ART·¿¤Î¸ÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÎÀ¸À®¤ò³ÎΨ¤Ë±þ¤¸¤Æ»î¹Ô¤¹¤ë¡£
2134 * Mega-Hack -- Attempt to create one of the "Special Objects"
2135 * @param o_ptr À¸À®¤Ë³ä¤êÅö¤Æ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2136 * @return À¸À®¤ËÀ®¸ù¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
2138 * We are only called from "make_object()", and we assume that\n
2139 * "apply_magic()" is called immediately after we return.\n
2141 * Note -- see "make_artifact()" and "apply_magic()"\n
2143 static bool make_artifact_special(object_type *o_ptr)
2149 /* No artifacts in the town */
2150 if (!dun_level) return (FALSE);
2153 if (get_obj_num_hook) return (FALSE);
2155 /* Check the artifact list (just the "specials") */
2156 for (i = 0; i < max_a_idx; i++)
2158 artifact_type *a_ptr = &a_info[i];
2160 /* Skip "empty" artifacts */
2161 if (!a_ptr->name) continue;
2163 /* Cannot make an artifact twice */
2164 if (a_ptr->cur_num) continue;
2166 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2167 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2169 /* XXX XXX Enforce minimum "depth" (loosely) */
2170 if (a_ptr->level > dun_level)
2172 /* Acquire the "out-of-depth factor" */
2173 int d = (a_ptr->level - dun_level) * 2;
2175 /* Roll for out-of-depth creation */
2176 if (!one_in_(d)) continue;
2179 /* Artifact "rarity roll" */
2180 if (!one_in_(a_ptr->rarity)) continue;
2182 /* Find the base object */
2183 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2185 /* XXX XXX Enforce minimum "object" level (loosely) */
2186 if (k_info[k_idx].level > object_level)
2188 /* Acquire the "out-of-depth factor" */
2189 int d = (k_info[k_idx].level - object_level) * 5;
2191 /* Roll for out-of-depth creation */
2192 if (!one_in_(d)) continue;
2195 /* Assign the template */
2196 object_prep(o_ptr, k_idx);
2198 /* Mega-Hack -- mark the item as an artifact */
2201 /* Hack: Some artifacts get random extra powers */
2202 random_artifact_resistance(o_ptr, a_ptr);
2214 * @brief ÈóINSTA_ART·¿¤Î¸ÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÎÀ¸À®¤ò³ÎΨ¤Ë±þ¤¸¤Æ»î¹Ô¤¹¤ë¡£
2215 * Mega-Hack -- Attempt to create one of the "Special Objects"
2216 * @param o_ptr À¸À®¤Ë³ä¤êÅö¤Æ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2217 * @return À¸À®¤ËÀ®¸ù¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
2219 * Attempt to change an object into an artifact\n
2220 * This routine should only be called by "apply_magic()"\n
2221 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2223 static bool make_artifact(object_type *o_ptr)
2228 /* No artifacts in the town */
2229 if (!dun_level) return (FALSE);
2231 /* Paranoia -- no "plural" artifacts */
2232 if (o_ptr->number != 1) return (FALSE);
2234 /* Check the artifact list (skip the "specials") */
2235 for (i = 0; i < max_a_idx; i++)
2237 artifact_type *a_ptr = &a_info[i];
2239 /* Skip "empty" items */
2240 if (!a_ptr->name) continue;
2242 /* Cannot make an artifact twice */
2243 if (a_ptr->cur_num) continue;
2245 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2247 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2249 /* Must have the correct fields */
2250 if (a_ptr->tval != o_ptr->tval) continue;
2251 if (a_ptr->sval != o_ptr->sval) continue;
2253 /* XXX XXX Enforce minimum "depth" (loosely) */
2254 if (a_ptr->level > dun_level)
2256 /* Acquire the "out-of-depth factor" */
2257 int d = (a_ptr->level - dun_level) * 2;
2259 /* Roll for out-of-depth creation */
2260 if (!one_in_(d)) continue;
2263 /* We must make the "rarity roll" */
2264 if (!one_in_(a_ptr->rarity)) continue;
2266 /* Hack -- mark the item as an artifact */
2269 /* Hack: Some artifacts get random extra powers */
2270 random_artifact_resistance(o_ptr, a_ptr);
2282 * @brief ¥¢¥¤¥Æ¥à¤Î¥¨¥´¤ò¥ì¥¢Å٤νŤߤ˹ç¤ï¤»¤Æ¥é¥ó¥À¥à¤ËÁªÂò¤¹¤ë
2283 * Choose random ego type
2284 * @param slot ¼èÆÀ¤·¤¿¤¤¥¨¥´¤ÎÁõÈ÷Éô°Ì
2285 * @param good TRUE¤Ê¤é¤ÐÄ̾ï¤Î¥¨¥´¡¢FALSE¤Ê¤é¤Ð¼ö¤¤¤Î¥¨¥´¤¬ÁªÂòÂоݤȤʤ롣
2286 * @return ÁªÂò¤µ¤ì¤¿¥¨¥´¾ðÊó¤ÎID¡¢Ëü°ìÁªÂò¤Ç¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ïmax_e_idx¤¬Ê֤롣
2288 static byte get_random_ego(byte slot, bool good)
2291 ego_item_type *e_ptr;
2295 for (i = 1; i < max_e_idx; i++)
2299 if (e_ptr->slot == slot
2300 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2303 total += (255 / e_ptr->rarity);
2307 value = randint1(total);
2309 for (i = 1; i < max_e_idx; i++)
2313 if (e_ptr->slot == slot
2314 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2317 value -= (255 / e_ptr->rarity);
2318 if (value <= 0L) break;
2326 * @brief Éð´ï·Ï¥ª¥Ö¥¸¥§¥¯¥È¤ËÀ¸À®¥é¥ó¥¯¤´¤È¤Î¶¯²½¤òÍ¿¤¨¤ë¥µ¥Ö¥ë¡¼¥Á¥ó
2327 * Apply magic to an item known to be a "weapon"
2328 * @param o_ptr ¶¯²½¤òÍ¿¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2329 * @param level À¸À®´ð½à³¬
2330 * @param power À¸À®¥é¥ó¥¯
2333 * Hack -- note special base damage dice boosting\n
2334 * Hack -- note special processing for weapon/digger\n
2336 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2338 int tohit1 = randint1(5) + m_bonus(5, level);
2339 int todam1 = randint1(5) + m_bonus(5, level);
2341 int tohit2 = m_bonus(10, level);
2342 int todam2 = m_bonus(10, level);
2344 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2346 tohit2 = (tohit2+1)/2;
2347 todam2 = (todam2+1)/2;
2354 o_ptr->to_h += tohit1;
2355 o_ptr->to_d += todam1;
2361 o_ptr->to_h += tohit2;
2362 o_ptr->to_d += todam2;
2370 o_ptr->to_h -= tohit1;
2371 o_ptr->to_d -= todam1;
2376 /* Penalize again */
2377 o_ptr->to_h -= tohit2;
2378 o_ptr->to_d -= todam2;
2381 /* Cursed (if "bad") */
2382 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2385 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2388 switch (o_ptr->tval)
2395 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2396 create_artifact(o_ptr, FALSE);
2398 /* Special Ego-item */
2399 o_ptr->name2 = EGO_DIGGING;
2403 else if (power < -1)
2405 /* Hack -- Horrible digging bonus */
2406 o_ptr->pval = 0 - (5 + randint1(5));
2412 /* Hack -- Reverse digging bonus */
2413 o_ptr->pval = 0 - (o_ptr->pval);
2427 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2429 create_artifact(o_ptr, FALSE);
2434 /* Roll for an ego-item */
2435 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2436 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2438 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2440 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2445 switch (o_ptr->name2)
2448 if (one_in_(4) && (level > 40))
2449 add_flag(o_ptr->art_flags, TR_BLOWS);
2453 add_flag(o_ptr->art_flags, TR_RES_POIS);
2455 add_flag(o_ptr->art_flags, TR_WARNING);
2457 case EGO_KILL_DRAGON:
2459 add_flag(o_ptr->art_flags, TR_RES_POIS);
2463 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2465 case EGO_SLAYING_WEAPON:
2466 if (one_in_(3)) /* double damage */
2474 while (one_in_(o_ptr->dd));
2480 while (one_in_(o_ptr->ds));
2485 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2487 if (o_ptr->tval == TV_SWORD && one_in_(3))
2489 add_flag(o_ptr->art_flags, TR_VORPAL);
2494 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2500 add_flag(o_ptr->art_flags, TR_HOLD_LIFE);
2502 add_flag(o_ptr->art_flags, TR_DEX);
2504 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2507 o_ptr->pval = m_bonus(5, level) + 1;
2509 case EGO_EARTHQUAKES:
2510 if (one_in_(3) && (level > 60))
2511 add_flag(o_ptr->art_flags, TR_BLOWS);
2513 o_ptr->pval = m_bonus(3, level);
2517 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2521 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2523 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2525 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2526 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2529 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2530 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2531 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2532 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2536 if (!o_ptr->art_name)
2538 /* Hack -- Super-charge the damage dice */
2539 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2541 /* Hack -- Lower the damage dice */
2542 if (o_ptr->dd > 9) o_ptr->dd = 9;
2547 else if (power < -1)
2549 /* Roll for ego-item */
2550 if (randint0(MAX_DEPTH) < level)
2554 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2555 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2561 switch (o_ptr->name2)
2564 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2565 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2567 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2568 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2569 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2570 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2571 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2572 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2586 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2588 create_artifact(o_ptr, FALSE);
2591 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2605 if (power > 2) /* power > 2 is debug only */
2607 create_artifact(o_ptr, FALSE);
2611 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2613 switch (o_ptr->name2)
2615 case EGO_SLAYING_BOLT:
2620 /* Hack -- super-charge the damage dice */
2621 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2623 /* Hack -- restrict the damage dice */
2624 if (o_ptr->dd > 9) o_ptr->dd = 9;
2628 else if (power < -1)
2630 /* Roll for ego-item */
2631 if (randint0(MAX_DEPTH) < level)
2633 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2643 * @brief ¥É¥é¥´¥óÁõÈ÷¤Ë¥é¥ó¥À¥à¤ÊÂÑÀ¤òÍ¿¤¨¤ë
2644 * @param o_ptr ¶¯²½¤òÍ¿¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2647 static void dragon_resist(object_type * o_ptr)
2652 one_dragon_ele_resistance(o_ptr);
2654 one_high_resistance(o_ptr);
2660 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥é¥ó¥À¥à¤Ê¶¯¤¤ESP¤òÍ¿¤¨¤ë
2661 * @param o_ptr ¶¯²½¤òÍ¿¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2664 static bool add_esp_strong(object_type *o_ptr)
2666 bool nonliv = FALSE;
2668 switch (randint1(3))
2670 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2671 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2672 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2679 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥é¥ó¥À¥à¤Ê¼å¤¤ESP¤òÍ¿¤¨¤ë
2680 * @param o_ptr ¶¯²½¤òÍ¿¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2683 static void add_esp_weak(object_type *o_ptr, bool extra)
2686 u32b weak_esp_list[] = {
2698 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2699 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2701 /* Add unduplicated weak esp flags randomly */
2702 for (i = 0; i < add_count; ++ i)
2704 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2706 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2707 weak_esp_list[choice] = weak_esp_list[i];
2713 * @brief Ëɶñ·Ï¥ª¥Ö¥¸¥§¥¯¥È¤ËÀ¸À®¥é¥ó¥¯¤´¤È¤Î¶¯²½¤òÍ¿¤¨¤ë¥µ¥Ö¥ë¡¼¥Á¥ó
2714 * Apply magic to an item known to be "armor"
2715 * @param o_ptr ¶¯²½¤òÍ¿¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
2716 * @param level À¸À®´ð½à³¬
2717 * @param power À¸À®¥é¥ó¥¯
2720 * Hack -- note special processing for crown/helm\n
2721 * Hack -- note special processing for robe of permanence\n
2723 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2725 int toac1 = randint1(5) + m_bonus(5, level);
2727 int toac2 = m_bonus(10, level);
2733 o_ptr->to_a += toac1;
2739 o_ptr->to_a += toac2;
2747 o_ptr->to_a -= toac1;
2752 /* Penalize again */
2753 o_ptr->to_a -= toac2;
2756 /* Cursed (if "bad") */
2757 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2762 switch (o_ptr->tval)
2766 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2767 create_artifact(o_ptr, FALSE);
2769 /* Mention the item */
2770 if (cheat_peek) object_mention(o_ptr);
2781 /* Hack -- Try for "Robes of the Magi" */
2782 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2783 (o_ptr->sval == SV_ROBE) &&
2784 (randint0(100) < 15))
2788 o_ptr->name2 = EGO_YOIYAMI;
2789 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2790 o_ptr->sval = SV_YOIYAMI_ROBE;
2796 o_ptr->name2 = EGO_PERMANENCE;
2801 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2803 create_artifact(o_ptr, FALSE);
2809 bool okay_flag = TRUE;
2811 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2813 switch (o_ptr->name2)
2816 if (o_ptr->tval != TV_HARD_ARMOR)
2822 if (o_ptr->tval != TV_SOFT_ARMOR)
2834 switch (o_ptr->name2)
2836 case EGO_RESISTANCE:
2838 add_flag(o_ptr->art_flags, TR_RES_POIS);
2841 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2842 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2846 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2848 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2850 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2851 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2853 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2854 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2855 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2856 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2857 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2858 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2859 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2860 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2863 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2864 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2865 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2866 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2867 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2868 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2881 if (o_ptr->sval == SV_DRAGON_SHIELD)
2883 /* Mention the item */
2884 if (cheat_peek) object_mention(o_ptr);
2885 dragon_resist(o_ptr);
2886 if (!one_in_(3)) break;
2892 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2894 create_artifact(o_ptr, FALSE);
2900 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2901 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2902 && o_ptr->name2 == EGO_S_DWARVEN)
2909 switch (o_ptr->name2)
2912 if (!one_in_(3)) one_high_resistance(o_ptr);
2913 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2915 case EGO_REFLECTION:
2916 if (o_ptr->sval == SV_MIRROR_SHIELD)
2921 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2922 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2931 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2933 /* Mention the item */
2934 if (cheat_peek) object_mention(o_ptr);
2935 dragon_resist(o_ptr);
2936 if (!one_in_(3)) break;
2940 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2942 create_artifact(o_ptr, FALSE);
2945 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2949 else if (power < -1)
2951 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2959 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2961 /* Mention the item */
2962 if (cheat_peek) object_mention(o_ptr);
2963 dragon_resist(o_ptr);
2964 if (!one_in_(3)) break;
2969 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2971 create_artifact(o_ptr, FALSE);
2974 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2976 switch (o_ptr->name2)
2978 case EGO_SLOW_DESCENT:
2981 one_high_resistance(o_ptr);
2987 else if (power < -1)
2989 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
3000 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3002 create_artifact(o_ptr, FALSE);
3007 bool ok_flag = TRUE;
3008 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3010 switch (o_ptr->name2)
3013 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
3014 else add_esp_weak(o_ptr, FALSE);
3018 case EGO_REGENERATION:
3019 case EGO_LORDLINESS:
3025 if (one_in_(2)) add_esp_strong(o_ptr);
3026 else add_esp_weak(o_ptr, FALSE);
3029 default:/* not existing crown (wisdom,lite, etc...) */
3033 break; /* while (1) */
3039 else if (power < -1)
3043 bool ok_flag = TRUE;
3044 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3046 switch (o_ptr->name2)
3048 case EGO_ANCIENT_CURSE:
3049 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3050 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3051 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3052 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3053 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3054 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3058 break; /* while (1) */
3067 if (o_ptr->sval == SV_DRAGON_HELM)
3069 /* Mention the item */
3070 if (cheat_peek) object_mention(o_ptr);
3071 dragon_resist(o_ptr);
3072 if (!one_in_(3)) break;
3078 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3080 create_artifact(o_ptr, FALSE);
3085 bool ok_flag = TRUE;
3086 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3088 switch (o_ptr->name2)
3090 case EGO_BRILLIANCE:
3092 case EGO_INFRAVISION:
3093 case EGO_H_PROTECTION:
3098 if (one_in_(2)) add_esp_strong(o_ptr);
3099 else add_esp_weak(o_ptr, FALSE);
3103 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3104 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3107 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3109 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3111 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3112 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3114 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3115 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3116 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3117 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3118 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3119 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3120 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3121 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3123 default:/* not existing helm (Magi, Might, etc...)*/
3127 break; /* while (1) */
3132 else if (power < -1)
3136 bool ok_flag = TRUE;
3137 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3139 switch (o_ptr->name2)
3141 case EGO_ANCIENT_CURSE:
3145 break; /* while (1) */
3156 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3158 create_artifact(o_ptr, FALSE);
3161 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3163 switch (o_ptr->name2)
3172 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3173 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3174 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3175 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3182 else if (power < -1)
3184 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3194 * @brief Áõ¾þÉÊ·Ï¥ª¥Ö¥¸¥§¥¯¥È¤ËÀ¸À®¥é¥ó¥¯¤´¤È¤Î¶¯²½¤òÍ¿¤¨¤ë¥µ¥Ö¥ë¡¼¥Á¥ó
3195 * Apply magic to an item known to be a "ring" or "amulet"
3196 * @param o_ptr ¶¯²½¤òÍ¿¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
3197 * @param level À¸À®´ð½à³¬
3198 * @param power À¸À®¥é¥ó¥¯
3201 * Hack -- note special "pval boost" code for ring of speed\n
3202 * Hack -- note that some items must be cursed (or blessed)\n
3204 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3206 /* Apply magic (good or bad) according to type */
3207 switch (o_ptr->tval)
3212 switch (o_ptr->sval)
3214 case SV_RING_ATTACKS:
3217 o_ptr->pval = m_bonus(2, level);
3218 if (one_in_(15)) o_ptr->pval++;
3219 if (o_ptr->pval < 1) o_ptr->pval = 1;
3225 o_ptr->ident |= (IDENT_BROKEN);
3228 o_ptr->curse_flags |= TRC_CURSED;
3231 o_ptr->pval = 0 - (o_ptr->pval);
3242 /* Strength, Constitution, Dexterity, Intelligence */
3248 o_ptr->pval = 1 + m_bonus(5, level);
3254 o_ptr->ident |= (IDENT_BROKEN);
3257 o_ptr->curse_flags |= TRC_CURSED;
3260 o_ptr->pval = 0 - (o_ptr->pval);
3266 /* Ring of Speed! */
3269 /* Base speed (1 to 10) */
3270 o_ptr->pval = randint1(5) + m_bonus(5, level);
3272 /* Super-charge the ring */
3273 while (randint0(100) < 50) o_ptr->pval++;
3279 o_ptr->ident |= (IDENT_BROKEN);
3282 o_ptr->curse_flags |= TRC_CURSED;
3285 o_ptr->pval = 0 - (o_ptr->pval);
3290 /* Mention the item */
3291 if (cheat_peek) object_mention(o_ptr);
3296 case SV_RING_LORDLY:
3300 one_lordly_high_resistance(o_ptr);
3304 /* Bonus to armor class */
3305 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
3309 case SV_RING_WARNING:
3311 if (one_in_(3)) one_low_esp(o_ptr);
3316 case SV_RING_SEARCHING:
3318 /* Bonus to searching */
3319 o_ptr->pval = 1 + m_bonus(5, level);
3325 o_ptr->ident |= (IDENT_BROKEN);
3328 o_ptr->curse_flags |= TRC_CURSED;
3331 o_ptr->pval = 0 - (o_ptr->pval);
3337 /* Flames, Acid, Ice */
3338 case SV_RING_FLAMES:
3343 /* Bonus to armor class */
3344 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3348 /* Weakness, Stupidity */
3349 case SV_RING_WEAKNESS:
3350 case SV_RING_STUPIDITY:
3353 o_ptr->ident |= (IDENT_BROKEN);
3356 o_ptr->curse_flags |= TRC_CURSED;
3359 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3360 if (power > 0) power = 0 - power;
3365 /* WOE, Stupidity */
3369 o_ptr->ident |= (IDENT_BROKEN);
3372 o_ptr->curse_flags |= TRC_CURSED;
3375 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3376 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3377 if (power > 0) power = 0 - power;
3382 /* Ring of damage */
3383 case SV_RING_DAMAGE:
3385 /* Bonus to damage */
3386 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3392 o_ptr->ident |= (IDENT_BROKEN);
3395 o_ptr->curse_flags |= TRC_CURSED;
3398 o_ptr->to_d = 0 - o_ptr->to_d;
3404 /* Ring of Accuracy */
3405 case SV_RING_ACCURACY:
3408 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3414 o_ptr->ident |= (IDENT_BROKEN);
3417 o_ptr->curse_flags |= TRC_CURSED;
3420 o_ptr->to_h = 0 - o_ptr->to_h;
3426 /* Ring of Protection */
3427 case SV_RING_PROTECTION:
3429 /* Bonus to armor class */
3430 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3436 o_ptr->ident |= (IDENT_BROKEN);
3439 o_ptr->curse_flags |= TRC_CURSED;
3442 o_ptr->to_a = 0 - o_ptr->to_a;
3448 /* Ring of Slaying */
3449 case SV_RING_SLAYING:
3451 /* Bonus to damage and to hit */
3452 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3453 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3459 o_ptr->ident |= (IDENT_BROKEN);
3462 o_ptr->curse_flags |= TRC_CURSED;
3464 /* Reverse bonuses */
3465 o_ptr->to_h = 0 - o_ptr->to_h;
3466 o_ptr->to_d = 0 - o_ptr->to_d;
3472 case SV_RING_MUSCLE:
3474 o_ptr->pval = 1 + m_bonus(3, level);
3475 if (one_in_(4)) o_ptr->pval++;
3481 o_ptr->ident |= (IDENT_BROKEN);
3484 o_ptr->curse_flags |= TRC_CURSED;
3486 /* Reverse bonuses */
3487 o_ptr->pval = 0 - o_ptr->pval;
3492 case SV_RING_AGGRAVATION:
3495 o_ptr->ident |= (IDENT_BROKEN);
3498 o_ptr->curse_flags |= TRC_CURSED;
3500 if (power > 0) power = 0 - power;
3504 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3505 || (power > 2)) /* power > 2 is debug only */
3507 o_ptr->pval = MIN(o_ptr->pval, 4);
3508 /* Randart amulet */
3509 create_artifact(o_ptr, FALSE);
3511 else if ((power == 2) && one_in_(2))
3513 while(!o_ptr->name2)
3515 int tmp = m_bonus(10, level);
3516 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3517 switch(randint1(28))
3520 o_ptr->name2 = EGO_RING_THROW;
3523 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3524 o_ptr->name2 = EGO_RING_REGEN;
3527 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3528 o_ptr->name2 = EGO_RING_LITE;
3531 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3532 o_ptr->name2 = EGO_RING_TELEPORT;
3535 if (o_ptr->to_h) break;
3536 o_ptr->name2 = EGO_RING_TO_H;
3539 if (o_ptr->to_d) break;
3540 o_ptr->name2 = EGO_RING_TO_D;
3543 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3544 o_ptr->name2 = EGO_RING_SLAY;
3547 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3548 o_ptr->name2 = EGO_RING_WIZARD;
3551 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3552 o_ptr->name2 = EGO_RING_HERO;
3555 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3556 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3557 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3558 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3561 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3562 if (!(have_flag(k_ptr->flags, TR_RES_FIRE)) && (have_flag(k_ptr->flags, TR_RES_COLD) || have_flag(k_ptr->flags, TR_RES_ELEC) || have_flag(k_ptr->flags, TR_RES_ACID))) break;
3563 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3564 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3565 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3568 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3569 if (!(have_flag(k_ptr->flags, TR_RES_COLD)) && (have_flag(k_ptr->flags, TR_RES_FIRE) || have_flag(k_ptr->flags, TR_RES_ELEC) || have_flag(k_ptr->flags, TR_RES_ACID))) break;
3570 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3571 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3572 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3575 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3576 if (!(have_flag(k_ptr->flags, TR_RES_ELEC)) && (have_flag(k_ptr->flags, TR_RES_COLD) || have_flag(k_ptr->flags, TR_RES_FIRE) || have_flag(k_ptr->flags, TR_RES_ACID))) break;
3577 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3578 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3581 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3582 if (!(have_flag(k_ptr->flags, TR_RES_ACID)) && (have_flag(k_ptr->flags, TR_RES_COLD) || have_flag(k_ptr->flags, TR_RES_ELEC) || have_flag(k_ptr->flags, TR_RES_FIRE))) break;
3583 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3584 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3586 case 21: case 22: case 23: case 24: case 25: case 26:
3587 switch (o_ptr->sval)
3590 if (!one_in_(3)) break;
3591 o_ptr->name2 = EGO_RING_D_SPEED;
3593 case SV_RING_DAMAGE:
3594 case SV_RING_ACCURACY:
3595 case SV_RING_SLAYING:
3596 if (one_in_(2)) break;
3597 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3600 o_ptr->name2 = EGO_RING_BERSERKER;
3601 o_ptr->to_h -= 2+randint1(4);
3602 o_ptr->to_d += 2+randint1(4);
3605 case SV_RING_PROTECTION:
3606 o_ptr->name2 = EGO_RING_SUPER_AC;
3607 o_ptr->to_a += 7 + m_bonus(5, level);
3609 case SV_RING_RES_FEAR:
3610 o_ptr->name2 = EGO_RING_HERO;
3613 if (one_in_(2)) break;
3614 o_ptr->name2 = EGO_RING_HUNTER;
3616 case SV_RING_SEARCHING:
3617 o_ptr->name2 = EGO_RING_STEALTH;
3619 case SV_RING_TELEPORTATION:
3620 o_ptr->name2 = EGO_RING_TELE_AWAY;
3622 case SV_RING_RES_BLINDNESS:
3624 o_ptr->name2 = EGO_RING_RES_LITE;
3626 o_ptr->name2 = EGO_RING_RES_DARK;
3628 case SV_RING_LORDLY:
3629 if (!one_in_(20)) break;
3630 one_lordly_high_resistance(o_ptr);
3631 one_lordly_high_resistance(o_ptr);
3632 o_ptr->name2 = EGO_RING_TRUE;
3634 case SV_RING_SUSTAIN:
3635 if (!one_in_(4)) break;
3636 o_ptr->name2 = EGO_RING_RES_TIME;
3638 case SV_RING_FLAMES:
3639 if (!one_in_(2)) break;
3640 o_ptr->name2 = EGO_RING_DRAGON_F;
3643 if (!one_in_(2)) break;
3644 o_ptr->name2 = EGO_RING_DRAGON_C;
3646 case SV_RING_WARNING:
3647 if (!one_in_(2)) break;
3648 o_ptr->name2 = EGO_RING_M_DETECT;
3657 o_ptr->curse_flags = 0L;
3659 else if ((power == -2) && one_in_(2))
3661 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3662 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3663 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3664 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3665 o_ptr->art_flags[0] = 0;
3666 o_ptr->art_flags[1] = 0;
3667 while(!o_ptr->name2)
3669 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3673 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3674 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3677 o_ptr->name2 = EGO_RING_NO_MELEE;
3680 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3681 o_ptr->name2 = EGO_RING_AGGRAVATE;
3684 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3685 o_ptr->name2 = EGO_RING_TY_CURSE;
3688 o_ptr->name2 = EGO_RING_ALBINO;
3693 o_ptr->ident |= (IDENT_BROKEN);
3696 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3704 switch (o_ptr->sval)
3706 /* Amulet of wisdom/charisma */
3707 case SV_AMULET_INTELLIGENCE:
3708 case SV_AMULET_WISDOM:
3709 case SV_AMULET_CHARISMA:
3711 o_ptr->pval = 1 + m_bonus(5, level);
3717 o_ptr->ident |= (IDENT_BROKEN);
3720 o_ptr->curse_flags |= (TRC_CURSED);
3722 /* Reverse bonuses */
3723 o_ptr->pval = 0 - o_ptr->pval;
3729 /* Amulet of brilliance */
3730 case SV_AMULET_BRILLIANCE:
3732 o_ptr->pval = 1 + m_bonus(3, level);
3733 if (one_in_(4)) o_ptr->pval++;
3739 o_ptr->ident |= (IDENT_BROKEN);
3742 o_ptr->curse_flags |= (TRC_CURSED);
3744 /* Reverse bonuses */
3745 o_ptr->pval = 0 - o_ptr->pval;
3751 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3755 o_ptr->curse_flags |= (TRC_CURSED);
3760 case SV_AMULET_RESISTANCE:
3762 if (one_in_(5)) one_high_resistance(o_ptr);
3763 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3767 /* Amulet of searching */
3768 case SV_AMULET_SEARCHING:
3770 o_ptr->pval = randint1(2) + m_bonus(4, level);
3776 o_ptr->ident |= (IDENT_BROKEN);
3779 o_ptr->curse_flags |= (TRC_CURSED);
3781 /* Reverse bonuses */
3782 o_ptr->pval = 0 - (o_ptr->pval);
3788 /* Amulet of the Magi -- never cursed */
3789 case SV_AMULET_THE_MAGI:
3791 o_ptr->pval = randint1(5) + m_bonus(5, level);
3792 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3794 /* gain one low ESP */
3795 add_esp_weak(o_ptr, FALSE);
3797 /* Mention the item */
3798 if (cheat_peek) object_mention(o_ptr);
3803 /* Amulet of Doom -- always cursed */
3804 case SV_AMULET_DOOM:
3807 o_ptr->ident |= (IDENT_BROKEN);
3810 o_ptr->curse_flags |= (TRC_CURSED);
3813 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3814 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3815 if (power > 0) power = 0 - power;
3820 case SV_AMULET_MAGIC_MASTERY:
3822 o_ptr->pval = 1 + m_bonus(4, level);
3828 o_ptr->ident |= (IDENT_BROKEN);
3831 o_ptr->curse_flags |= (TRC_CURSED);
3833 /* Reverse bonuses */
3834 o_ptr->pval = 0 - o_ptr->pval;
3840 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3841 || (power > 2)) /* power > 2 is debug only */
3843 o_ptr->pval = MIN(o_ptr->pval, 4);
3844 /* Randart amulet */
3845 create_artifact(o_ptr, FALSE);
3847 else if ((power == 2) && one_in_(2))
3849 while(!o_ptr->name2)
3851 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3852 switch(randint1(21))
3855 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3856 o_ptr->name2 = EGO_AMU_SLOW_D;
3859 if (o_ptr->pval) break;
3860 o_ptr->name2 = EGO_AMU_INFRA;
3863 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3864 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3867 if (have_flag(k_ptr->flags, TR_HOLD_LIFE)) break;
3868 o_ptr->name2 = EGO_AMU_HOLD_LIFE;
3871 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3872 o_ptr->name2 = EGO_AMU_LEVITATION;
3874 case 10: case 11: case 21:
3875 o_ptr->name2 = EGO_AMU_AC;
3878 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3879 if (m_bonus(10, level) > 8)
3880 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3882 o_ptr->name2 = EGO_AMU_RES_FIRE;
3885 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3886 if (m_bonus(10, level) > 8)
3887 o_ptr->name2 = EGO_AMU_RES_COLD_;
3889 o_ptr->name2 = EGO_AMU_RES_COLD;
3892 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3893 if (m_bonus(10, level) > 8)
3894 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3896 o_ptr->name2 = EGO_AMU_RES_ELEC;
3899 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3900 if (m_bonus(10, level) > 8)
3901 o_ptr->name2 = EGO_AMU_RES_ACID_;
3903 o_ptr->name2 = EGO_AMU_RES_ACID;
3905 case 16: case 17: case 18: case 19: case 20:
3906 switch (o_ptr->sval)
3908 case SV_AMULET_TELEPORT:
3909 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3910 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3911 else o_ptr->name2 = EGO_AMU_TELEPORT;
3913 case SV_AMULET_RESIST_ACID:
3914 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3916 case SV_AMULET_SEARCHING:
3917 o_ptr->name2 = EGO_AMU_STEALTH;
3919 case SV_AMULET_BRILLIANCE:
3920 if (!one_in_(3)) break;
3921 o_ptr->name2 = EGO_AMU_IDENT;
3923 case SV_AMULET_CHARISMA:
3924 if (!one_in_(3)) break;
3925 o_ptr->name2 = EGO_AMU_CHARM;
3927 case SV_AMULET_THE_MAGI:
3928 if (one_in_(2)) break;
3929 o_ptr->name2 = EGO_AMU_GREAT;
3931 case SV_AMULET_RESISTANCE:
3932 if (!one_in_(5)) break;
3933 o_ptr->name2 = EGO_AMU_DEFENDER;
3935 case SV_AMULET_TELEPATHY:
3936 if (!one_in_(3)) break;
3937 o_ptr->name2 = EGO_AMU_DETECTION;
3943 o_ptr->curse_flags = 0L;
3945 else if ((power == -2) && one_in_(2))
3947 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3948 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3949 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3950 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3951 o_ptr->art_flags[0] = 0;
3952 o_ptr->art_flags[1] = 0;
3953 while(!o_ptr->name2)
3955 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3959 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3960 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3963 o_ptr->name2 = EGO_AMU_FOOL;
3966 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3967 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3970 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3971 o_ptr->name2 = EGO_AMU_TY_CURSE;
3974 o_ptr->name2 = EGO_AMU_NAIVETY;
3979 o_ptr->ident |= (IDENT_BROKEN);
3982 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3990 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¿Í·Á¤Î¥Ù¡¼¥¹¤Ë¤Ç¤¤ë¤«¤òÊÖ¤¹
3991 * @param r_idx ¥Á¥§¥Ã¥¯¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²¤ÎID
3992 * @return ¿Í·Á¤Ë¤Ç¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹
3994 static bool item_monster_okay(int r_idx)
3996 monster_race *r_ptr = &r_info[r_idx];
3999 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
4000 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
4001 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
4002 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
4003 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
4004 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
4012 * @brief ¤½¤Î¾»¨Â¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ËÀ¸À®¥é¥ó¥¯¤´¤È¤Î¶¯²½¤òÍ¿¤¨¤ë¥µ¥Ö¥ë¡¼¥Á¥ó
4013 * Apply magic to an item known to be "boring"
4014 * @param o_ptr ¶¯²½¤òÍ¿¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
4015 * @param level À¸À®´ð½à³¬
4016 * @param power À¸À®¥é¥ó¥¯
4019 * Hack -- note the special code for various items
4021 static void a_m_aux_4(object_type *o_ptr, int level, int power)
4023 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4028 /* Apply magic (good or bad) according to type */
4029 switch (o_ptr->tval)
4038 o_ptr->ident |= (IDENT_BROKEN);
4041 o_ptr->curse_flags |= (TRC_CURSED);
4048 o_ptr->xtra4 = o_ptr->pval;
4054 /* Hack -- Torches -- random fuel */
4055 if (o_ptr->sval == SV_LITE_TORCH)
4057 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4061 /* Hack -- Lanterns -- random fuel */
4062 if (o_ptr->sval == SV_LITE_LANTERN)
4064 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4068 if (power > 2) /* power > 2 is debug only */
4070 create_artifact(o_ptr, FALSE);
4072 else if ((power == 2) || ((power == 1) && one_in_(3)))
4074 while (!o_ptr->name2)
4078 bool okay_flag = TRUE;
4080 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4082 switch (o_ptr->name2)
4085 if (o_ptr->sval == SV_LITE_FEANOR)
4093 else if (power == -2)
4095 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4097 switch (o_ptr->name2)
4099 case EGO_LITE_DARKNESS:
4102 if (o_ptr->sval == SV_LITE_TORCH)
4104 add_flag(o_ptr->art_flags, TR_LITE_M1);
4106 else if (o_ptr->sval == SV_LITE_LANTERN)
4108 add_flag(o_ptr->art_flags, TR_LITE_M2);
4110 else if (o_ptr->sval == SV_LITE_FEANOR)
4112 add_flag(o_ptr->art_flags, TR_LITE_M3);
4124 /* The wand or staff gets a number of initial charges equal
4125 * to between 1/2 (+1) and the full object kind's pval. -LM-
4127 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4133 /* Transfer the pval. -LM- */
4134 o_ptr->pval = k_ptr->pval;
4141 object_aware(o_ptr);
4142 object_known(o_ptr);
4151 monster_race *r_ptr;
4153 /* Pick a random non-unique monster race */
4156 i = randint1(max_r_idx - 1);
4158 if (!item_monster_okay(i)) continue;
4159 if (i == MON_TSUCHINOKO) continue;
4163 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4165 /* Ignore dead monsters */
4166 if (!r_ptr->rarity) continue;
4168 /* Ignore uncommon monsters */
4169 if (r_ptr->rarity > 100) continue;
4171 /* Prefer less out-of-depth monsters */
4172 if (randint0(check)) continue;
4179 /* Some figurines are cursed */
4180 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4185 msg_format("%s¤Î¿Í·Á, ¿¼¤µ +%d%s",
4187 msg_format("Figurine of %s, depth +%d%s",
4190 r_name + r_ptr->name, check - 1,
4191 !object_is_cursed(o_ptr) ? "" : " {cursed}");
4204 monster_race *r_ptr;
4206 if (o_ptr->sval == SV_SKELETON)
4208 match = RF9_DROP_SKELETON;
4210 else if (o_ptr->sval == SV_CORPSE)
4212 match = RF9_DROP_CORPSE;
4215 /* Hack -- Remove the monster restriction */
4216 get_mon_num_prep(item_monster_okay, NULL);
4218 /* Pick a random non-unique monster race */
4221 i = get_mon_num(dun_level);
4225 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4227 /* Ignore dead monsters */
4228 if (!r_ptr->rarity) continue;
4230 /* Ignore corpseless monsters */
4231 if (!(r_ptr->flags9 & match)) continue;
4233 /* Prefer less out-of-depth monsters */
4234 if (randint0(check)) continue;
4244 msg_format("%s¤Î»àÂÎ, ¿¼¤µ +%d",
4246 msg_format("Corpse of %s, depth +%d",
4249 r_name + r_ptr->name, check - 1);
4252 object_aware(o_ptr);
4253 object_known(o_ptr);
4261 monster_race *r_ptr;
4263 /* Pick a random monster race */
4266 i = randint1(max_r_idx - 1);
4270 /* Ignore dead monsters */
4271 if (!r_ptr->rarity) continue;
4281 msg_format("%s¤ÎÁü", r_name + r_ptr->name);
4283 msg_format("Statue of %s", r_name + r_ptr->name);
4287 object_aware(o_ptr);
4288 object_known(o_ptr);
4295 byte obj_level = k_info[o_ptr->k_idx].level;
4297 /* Hack -- skip ruined chests */
4298 if (obj_level <= 0) break;
4300 /* Hack -- pick a "difficulty" */
4301 o_ptr->pval = randint1(obj_level);
4302 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4304 o_ptr->xtra3 = dun_level + 5;
4306 /* Never exceed "difficulty" of 55 to 59 */
4307 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4315 * @brief À¸À®¤µ¤ì¤¿¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤ËËâˡŪ¤Ê¶¯²½¤òÍ¿¤¨¤ë¥á¥¤¥ó¥ë¡¼¥Á¥ó
4316 * Complete the "creation" of an object by applying "magic" to the item
4317 * @param o_ptr ¶¯²½¤òÍ¿¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
4318 * @param lev À¸À®´ð½à³¬
4319 * @param mode À¸À®¥ª¥×¥·¥ç¥ó
4322 * This includes not only rolling for random bonuses, but also putting the\n
4323 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4324 * staffs, giving fuel to lites, and placing traps on chests.\n
4326 * In particular, note that "Instant Artifacts", if "created" by an external\n
4327 * routine, must pass through this function to complete the actual creation.\n
4329 * The base "chance" of the item being "good" increases with the "level"\n
4330 * parameter, which is usually derived from the dungeon level, being equal\n
4331 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4332 * the object is guaranteed to be "good". If an object is "good", then\n
4333 * the chance that the object will be "great" (ego-item or artifact), also\n
4334 * increases with the "level", being equal to half the level, plus 5, up to\n
4335 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4336 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4338 * If the object is not "good", there is a chance it will be "cursed", and\n
4339 * if it is "cursed", there is a chance it will be "broken". These chances\n
4340 * are related to the "good" / "great" chances above.\n
4342 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4343 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4345 * If "okay" is true, and the object is going to be "great", then there is\n
4346 * a chance that an artifact will be created. This is true even if both the\n
4347 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4348 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4350 void apply_magic(object_type *o_ptr, int lev, u32b mode)
4352 int i, rolls, f1, f2, power;
4354 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4356 /* Maximum "level" for various things */
4357 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4359 /* Base chance of being "good" */
4362 /* Maximal chance of being "good" */
4363 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4365 /* Base chance of being "great" */
4368 /* Maximal chance of being "great" */
4369 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4370 f2 = d_info[dungeon_type].obj_great;
4372 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4377 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4386 /* Roll for "good" */
4387 if ((mode & AM_GOOD) || magik(f1))
4392 /* Roll for "great" */
4393 if ((mode & AM_GREAT) || magik(f2))
4397 /* Roll for "special" */
4398 if (mode & AM_SPECIAL) power = 3;
4402 /* Roll for "cursed" */
4405 /* Assume "cursed" */
4408 /* Roll for "broken" */
4409 if (magik(f2)) power = -2;
4413 if (mode & AM_CURSED)
4415 /* Assume 'cursed' */
4420 /* Everything else gets more badly cursed */
4427 /* Assume no rolls */
4430 /* Get one roll if excellent */
4431 if (power >= 2) rolls = 1;
4433 /* Hack -- Get four rolls if forced great or special */
4434 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4436 /* Hack -- Get no rolls if not allowed */
4437 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4439 /* Roll for artifacts if allowed */
4440 for (i = 0; i < rolls; i++)
4442 /* Roll for an artifact */
4443 if (make_artifact(o_ptr)) break;
4444 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4446 if (make_artifact(o_ptr)) break;
4451 /* Hack -- analyze artifacts */
4452 if (object_is_fixed_artifact(o_ptr))
4454 artifact_type *a_ptr = &a_info[o_ptr->name1];
4456 /* Hack -- Mark the artifact as "created" */
4459 /* Hack -- Memorize location of artifact in saved floors */
4460 if (character_dungeon)
4461 a_ptr->floor_id = p_ptr->floor_id;
4463 /* Extract the other fields */
4464 o_ptr->pval = a_ptr->pval;
4465 o_ptr->ac = a_ptr->ac;
4466 o_ptr->dd = a_ptr->dd;
4467 o_ptr->ds = a_ptr->ds;
4468 o_ptr->to_a = a_ptr->to_a;
4469 o_ptr->to_h = a_ptr->to_h;
4470 o_ptr->to_d = a_ptr->to_d;
4471 o_ptr->weight = a_ptr->weight;
4472 o_ptr->xtra2 = a_ptr->act_idx;
4474 if (o_ptr->name1 == ART_MILIM)
4476 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4482 /* Hack -- extract the "broken" flag */
4483 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4485 /* Hack -- extract the "cursed" flag */
4486 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4487 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4488 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4489 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4490 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4491 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4494 /* Cheat -- peek at the item */
4495 if (cheat_peek) object_mention(o_ptr);
4503 switch (o_ptr->tval)
4512 if (power) a_m_aux_1(o_ptr, lev, power);
4518 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4524 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4538 /* Elven Cloak and Black Clothes ... */
4539 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4540 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4541 o_ptr->pval = randint1(4);
4545 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4546 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4547 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4548 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4549 a_m_aux_2(o_ptr, lev, power);
4551 if (power) a_m_aux_2(o_ptr, lev, power);
4559 if (!power && (randint0(100) < 50)) power = -1;
4560 a_m_aux_3(o_ptr, lev, power);
4566 a_m_aux_4(o_ptr, lev, power);
4571 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4572 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4573 (p_ptr->pseikaku == SEIKAKU_SEXY))
4576 add_flag(o_ptr->art_flags, TR_STR);
4577 add_flag(o_ptr->art_flags, TR_INT);
4578 add_flag(o_ptr->art_flags, TR_WIS);
4579 add_flag(o_ptr->art_flags, TR_DEX);
4580 add_flag(o_ptr->art_flags, TR_CON);
4581 add_flag(o_ptr->art_flags, TR_CHR);
4584 /* Hack -- analyze ego-items */
4585 if (object_is_ego(o_ptr))
4587 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4589 /* Hack -- acquire "broken" flag */
4590 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4592 /* Hack -- acquire "cursed" flag */
4593 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4594 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4595 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4596 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4597 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4598 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4600 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4601 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4602 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4603 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4604 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4605 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4606 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4607 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4613 while (one_in_(o_ptr->dd));
4615 if (o_ptr->dd > 9) o_ptr->dd = 9;
4618 /* Hack -- apply activatin index if needed */
4619 if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
4621 /* Hack -- apply extra penalties if needed */
4622 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4624 /* Hack -- obtain bonuses */
4625 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4626 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4627 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4629 /* Hack -- obtain pval */
4630 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4633 /* Hack -- apply extra bonuses if needed */
4636 /* Hack -- obtain bonuses */
4637 if (e_ptr->max_to_h)
4639 if (e_ptr->max_to_h > 127)
4640 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4641 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4643 if (e_ptr->max_to_d)
4645 if (e_ptr->max_to_d > 127)
4646 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4647 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4649 if (e_ptr->max_to_a)
4651 if (e_ptr->max_to_a > 127)
4652 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4653 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4656 /* Accuracy ego must have high to_h */
4657 if(o_ptr->name2 == EGO_ACCURACY)
4659 while(o_ptr->to_h < o_ptr->to_d + 10)
4664 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4667 /* Accuracy ego must have high to_h */
4668 if(o_ptr->name2 == EGO_VELOCITY)
4670 while(o_ptr->to_d < o_ptr->to_h + 10)
4675 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4678 /* Protection ego must have high to_a */
4679 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4681 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4684 /* Hack -- obtain pval */
4685 if (e_ptr->max_pval)
4687 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4690 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4692 else if (o_ptr->name2 == EGO_DEMON)
4694 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4696 o_ptr->pval += randint1(2);
4700 o_ptr->pval += randint1(e_ptr->max_pval);
4703 else if (o_ptr->name2 == EGO_ATTACKS)
4705 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4706 if (o_ptr->pval > 3) o_ptr->pval = 3;
4707 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4708 o_ptr->pval += randint1(2);
4710 else if (o_ptr->name2 == EGO_BAT)
4712 o_ptr->pval = randint1(e_ptr->max_pval);
4713 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4715 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4717 o_ptr->pval = randint1(e_ptr->max_pval);
4721 o_ptr->pval += randint1(e_ptr->max_pval);
4726 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4728 o_ptr->pval = randint1(o_ptr->pval);
4730 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4734 /* Cheat -- describe the item */
4735 if (cheat_peek) object_mention(o_ptr);
4741 /* Examine real objects */
4744 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4746 /* Hack -- acquire "broken" flag */
4747 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4749 /* Hack -- acquire "cursed" flag */
4750 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4751 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4752 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4753 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4754 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4755 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4761 * @brief ¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤¬¾å¼Á¤È¤·¤Æ°·¤ï¤ì¤ë¤«¤É¤¦¤«¤òÊÖ¤¹¡£
4762 * Hack -- determine if a template is "good"
4763 * @param k_idx ȽÄꤷ¤¿¤¤¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤ÎID
4764 * @return ¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤¬¾å¼Á¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
4766 static bool kind_is_good(int k_idx)
4768 object_kind *k_ptr = &k_info[k_idx];
4770 /* Analyze the item type */
4771 switch (k_ptr->tval)
4773 /* Armor -- Good unless damaged */
4784 if (k_ptr->to_a < 0) return (FALSE);
4788 /* Weapons -- Good unless damaged */
4795 if (k_ptr->to_h < 0) return (FALSE);
4796 if (k_ptr->to_d < 0) return (FALSE);
4800 /* Ammo -- Arrows/Bolts are good */
4807 /* Books -- High level books are good (except Arcane books) */
4809 case TV_SORCERY_BOOK:
4810 case TV_NATURE_BOOK:
4815 case TV_DAEMON_BOOK:
4816 case TV_CRUSADE_BOOK:
4818 case TV_HISSATSU_BOOK:
4821 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4825 /* Rings -- Rings of Speed are good */
4828 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4829 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4833 /* Amulets -- Amulets of the Magi and Resistance are good */
4836 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4837 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4842 /* Assume not good */
4847 * @brief À¸À®³¬¤Ë±þ¤¸¤¿¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤ÎÀ¸À®¤ò¹Ô¤¦¡£
4848 * Attempt to make an object (normal or good/great)
4849 * @param j_ptr À¸À®·ë²Ì¤ò¼ý¤á¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
4850 * @param mode ¥ª¥×¥·¥ç¥ó¥Õ¥é¥°
4851 * @return À¸À®¤ËÀ®¸ù¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
4853 * This routine plays nasty games to generate the "special artifacts".\n
4854 * This routine uses "object_level" for the "generation level".\n
4855 * We assume that the given object has been "wiped".\n
4857 bool make_object(object_type *j_ptr, u32b mode)
4863 /* Chance of "special object" */
4864 prob = ((mode & AM_GOOD) ? 10 : 1000);
4866 /* Base level for the object */
4867 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4870 /* Generate a special object, or a normal object */
4871 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4876 if ((mode & AM_GOOD) && !get_obj_num_hook)
4878 /* Activate restriction (if already specified, use that) */
4879 get_obj_num_hook = kind_is_good;
4882 /* Restricted objects - prepare allocation table */
4883 if (get_obj_num_hook) get_obj_num_prep();
4885 /* Pick a random object */
4886 k_idx = get_obj_num(base);
4888 /* Restricted objects */
4889 if (get_obj_num_hook)
4891 /* Clear restriction */
4892 get_obj_num_hook = NULL;
4894 /* Reset allocation table to default */
4898 /* Handle failure */
4899 if (!k_idx) return (FALSE);
4901 /* Prepare the object */
4902 object_prep(j_ptr, k_idx);
4905 /* Apply magic (allow artifacts) */
4906 apply_magic(j_ptr, object_level, mode);
4908 /* Hack -- generate multiple spikes/missiles */
4909 switch (j_ptr->tval)
4917 j_ptr->number = (byte)damroll(6, 7);
4921 obj_level = k_info[j_ptr->k_idx].level;
4922 if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4924 /* Notice "okay" out-of-depth objects */
4925 if (!object_is_cursed(j_ptr) && !object_is_broken(j_ptr) &&
4926 (obj_level > dun_level))
4928 /* Cheat -- peek at items */
4929 if (cheat_peek) object_mention(j_ptr);
4938 * @brief ¥Õ¥í¥¢¤Î»ØÄê°ÌÃÖ¤ËÀ¸À®³¬¤Ë±þ¤¸¤¿¥Ù¡¼¥¹¥¢¥¤¥Æ¥à¤ÎÀ¸À®¤ò¹Ô¤¦¡£
4939 * Attempt to place an object (normal or good/great) at the given location.
4940 * @param y ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎYºÂɸ
4941 * @param x ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎXºÂɸ
4942 * @param mode ¥ª¥×¥·¥ç¥ó¥Õ¥é¥°
4943 * @return À¸À®¤ËÀ®¸ù¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
4945 * This routine plays nasty games to generate the "special artifacts".\n
4946 * This routine uses "object_level" for the "generation level".\n
4947 * This routine requires a clean floor grid destination.\n
4949 void place_object(int y, int x, u32b mode)
4954 cave_type *c_ptr = &cave[y][x];
4960 /* Paranoia -- check bounds */
4961 if (!in_bounds(y, x)) return;
4963 /* Require floor space */
4964 if (!cave_drop_bold(y, x)) return;
4966 /* Avoid stacking on other objects */
4967 if (c_ptr->o_idx) return;
4970 /* Get local object */
4973 /* Wipe the object */
4976 /* Make an object (if possible) */
4977 if (!make_object(q_ptr, mode)) return;
4980 /* Make an object */
4988 /* Acquire object */
4989 o_ptr = &o_list[o_idx];
4991 /* Structure Copy */
4992 object_copy(o_ptr, q_ptr);
4999 o_ptr->next_o_idx = c_ptr->o_idx;
5001 /* Place the object */
5002 c_ptr->o_idx = o_idx;
5012 /* Hack -- Preserve artifacts */
5013 if (object_is_fixed_artifact(q_ptr))
5015 a_info[q_ptr->name1].cur_num = 0;
5022 * @brief À¸À®³¬¤Ë±þ¤¸¤¿ºâÊõ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤ò¹Ô¤¦¡£
5023 * Make a treasure object
5024 * @param j_ptr À¸À®·ë²Ì¤ò¼ý¤á¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
5025 * @return À¸À®¤ËÀ®¸ù¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
5027 * The location must be a legal, clean, floor grid.
5029 bool make_gold(object_type *j_ptr)
5036 /* Hack -- Pick a Treasure variety */
5037 i = ((randint1(object_level + 2) + 2) / 2) - 1;
5039 /* Apply "extra" magic */
5040 if (one_in_(GREAT_OBJ))
5042 i += randint1(object_level + 1);
5045 /* Hack -- Creeping Coins only generate "themselves" */
5046 if (coin_type) i = coin_type;
5048 /* Do not create "illegal" Treasure Types */
5049 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
5051 /* Prepare a gold object */
5052 object_prep(j_ptr, OBJ_GOLD_LIST + i);
5054 /* Hack -- Base coin cost */
5055 base = k_info[OBJ_GOLD_LIST+i].cost;
5057 /* Determine how much the treasure is "worth" */
5058 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
5066 * @brief ¥Õ¥í¥¢¤Î»ØÄê°ÌÃÖ¤ËÀ¸À®³¬¤Ë±þ¤¸¤¿ºâÊõ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤ò¹Ô¤¦¡£
5067 * Places a treasure (Gold or Gems) at given location
5068 * @param y ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎYºÂɸ
5069 * @param x ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎXºÂɸ
5070 * @return À¸À®¤ËÀ®¸ù¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
5072 * The location must be a legal, clean, floor grid.
5074 void place_gold(int y, int x)
5079 cave_type *c_ptr = &cave[y][x];
5086 /* Paranoia -- check bounds */
5087 if (!in_bounds(y, x)) return;
5089 /* Require floor space */
5090 if (!cave_drop_bold(y, x)) return;
5092 /* Avoid stacking on other objects */
5093 if (c_ptr->o_idx) return;
5096 /* Get local object */
5099 /* Wipe the object */
5102 /* Make some gold */
5103 if (!make_gold(q_ptr)) return;
5106 /* Make an object */
5114 /* Acquire object */
5115 o_ptr = &o_list[o_idx];
5117 /* Copy the object */
5118 object_copy(o_ptr, q_ptr);
5125 o_ptr->next_o_idx = c_ptr->o_idx;
5127 /* Place the object */
5128 c_ptr->o_idx = o_idx;
5140 * @brief À¸À®ºÑ¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ò¥Õ¥í¥¢¤Î½êÄê¤Î°ÌÃÖ¤ËÍî¤È¤¹¡£
5141 * Let an object fall to the ground at or near a location.
5142 * @param j_ptr Íî¤È¤·¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
5143 * @param chance ¥É¥í¥Ã¥×¤ÎÀ®¸ùΨ(%)
5144 * @param y ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎYºÂɸ
5145 * @param x ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎXºÂɸ
5146 * @return À¸À®¤ËÀ®¸ù¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
5148 * The initial location is assumed to be "in_bounds()".\n
5150 * This function takes a parameter "chance". This is the percentage\n
5151 * chance that the item will "disappear" instead of drop. If the object\n
5152 * has been thrown, then this is the chance of disappearance on contact.\n
5154 * Hack -- this function uses "chance" to determine if it should produce\n
5155 * some form of "description" of the drop event (under the player).\n
5157 * We check several locations to see if we can find a location at which\n
5158 * the object can combine, stack, or be placed. Artifacts will try very\n
5159 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5161 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5172 s16b this_o_idx, next_o_idx = 0;
5176 char o_name[MAX_NLEN];
5182 /* Extract plural */
5183 bool plural = (j_ptr->number != 1);
5186 /* Describe object */
5187 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5190 /* Handle normal "breakage" */
5191 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5195 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5197 msg_format("The %s disappear%s.",
5198 o_name, (plural ? "" : "s"));
5204 if (p_ptr->wizard) msg_print("(ÇË»)");
5206 if (p_ptr->wizard) msg_print("(breakage)");
5225 /* Scan local grids */
5226 for (dy = -3; dy <= 3; dy++)
5228 /* Scan local grids */
5229 for (dx = -3; dx <= 3; dx++)
5233 /* Calculate actual distance */
5234 d = (dy * dy) + (dx * dx);
5236 /* Ignore distant grids */
5237 if (d > 10) continue;
5243 /* Skip illegal grids */
5244 if (!in_bounds(ty, tx)) continue;
5246 /* Require line of projection */
5247 if (!projectable(y, x, ty, tx)) continue;
5250 c_ptr = &cave[ty][tx];
5252 /* Require floor space */
5253 if (!cave_drop_bold(ty, tx)) continue;
5258 /* Scan objects in that grid */
5259 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5263 /* Acquire object */
5264 o_ptr = &o_list[this_o_idx];
5266 /* Acquire next object */
5267 next_o_idx = o_ptr->next_o_idx;
5269 /* Check for possible combination */
5270 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5276 /* Add new object */
5280 if (k > 99) continue;
5282 /* Calculate score */
5283 s = 1000 - (d + k * 5);
5285 /* Skip bad values */
5286 if (s < bs) continue;
5288 /* New best value */
5291 /* Apply the randomizer to equivalent values */
5292 if ((++bn >= 2) && !one_in_(bn)) continue;
5307 /* Handle lack of space */
5308 if (!flag && !object_is_artifact(j_ptr))
5312 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5314 msg_format("The %s disappear%s.",
5315 o_name, (plural ? "" : "s"));
5321 if (p_ptr->wizard) msg_print("(¾²¥¹¥Ú¡¼¥¹¤¬¤Ê¤¤)");
5323 if (p_ptr->wizard) msg_print("(no floor space)");
5333 for (i = 0; !flag && (i < 1000); i++)
5336 ty = rand_spread(by, 1);
5337 tx = rand_spread(bx, 1);
5339 /* Verify location */
5340 if (!in_bounds(ty, tx)) continue;
5342 /* Bounce to that location */
5346 /* Require floor space */
5347 if (!cave_drop_bold(by, bx)) continue;
5356 int candidates = 0, pick;
5358 for (ty = 1; ty < cur_hgt - 1; ty++)
5360 for (tx = 1; tx < cur_wid - 1; tx++)
5362 /* A valid space found */
5363 if (cave_drop_bold(ty, tx)) candidates++;
5367 /* No valid place! */
5372 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5374 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5379 if (p_ptr->wizard) msg_print("(¾²¥¹¥Ú¡¼¥¹¤¬¤Ê¤¤)");
5381 if (p_ptr->wizard) msg_print("(no floor space)");
5384 /* Mega-Hack -- preserve artifacts */
5387 /* Hack -- Preserve unknown artifacts */
5388 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5390 /* Mega-Hack -- Preserve the artifact */
5391 a_info[j_ptr->name1].cur_num = 0;
5399 /* Choose a random one */
5400 pick = randint1(candidates);
5402 for (ty = 1; ty < cur_hgt - 1; ty++)
5404 for (tx = 1; tx < cur_wid - 1; tx++)
5406 if (cave_drop_bold(ty, tx))
5410 /* Is this a picked one? */
5424 c_ptr = &cave[by][bx];
5426 /* Scan objects in that grid for combination */
5427 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5431 /* Acquire object */
5432 o_ptr = &o_list[this_o_idx];
5434 /* Acquire next object */
5435 next_o_idx = o_ptr->next_o_idx;
5437 /* Check for combination */
5438 if (object_similar(o_ptr, j_ptr))
5440 /* Combine the items */
5441 object_absorb(o_ptr, j_ptr);
5451 /* Get new object */
5452 if (!done) o_idx = o_pop();
5455 if (!done && !o_idx)
5459 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5461 msg_format("The %s disappear%s.",
5462 o_name, (plural ? "" : "s"));
5468 if (p_ptr->wizard) msg_print("(¥¢¥¤¥Æ¥à¤¬Â¿²á¤®¤ë)");
5470 if (p_ptr->wizard) msg_print("(too many objects)");
5474 /* Hack -- Preserve artifacts */
5475 if (object_is_fixed_artifact(j_ptr))
5477 a_info[j_ptr->name1].cur_num = 0;
5487 /* Structure copy */
5488 object_copy(&o_list[o_idx], j_ptr);
5490 /* Access new object */
5491 j_ptr = &o_list[o_idx];
5498 j_ptr->held_m_idx = 0;
5501 j_ptr->next_o_idx = c_ptr->o_idx;
5503 /* Place the object */
5504 c_ptr->o_idx = o_idx;
5519 /* Mega-Hack -- no message if "dropped" by player */
5520 /* Message when an object falls under the player */
5521 if (chance && player_bold(by, bx))
5524 msg_print("²¿¤«¤¬Â²¼¤Ëž¤¬¤Ã¤Æ¤¤¿¡£");
5526 msg_print("You feel something roll beneath your feet.");
5539 * @brief ³ÍÆÀ¥É¥í¥Ã¥×¤ò¹Ô¤¦¡£
5540 * Scatter some "great" objects near the player
5541 * @param y ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎYºÂɸ
5542 * @param x ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎXºÂɸ
5543 * @param num ³ÍÆÀ¤Î½èÍý²ó¿ô
5544 * @param great TRUE¤Ê¤é¤Ðɬ¤º¹âµéÉʰʾå¤òÍî¤È¤¹
5545 * @param special TRUE¤Ê¤é¤Ðɬ¤ºÆÃÊÌÉʤòÍî¤È¤¹
5546 * @param known TRUE¤Ê¤é¤Ð¥ª¥Ö¥¸¥§¥¯¥È¤¬É¬¤º¡ö´ÕÄê¡öºÑ¤Ë¤Ê¤ë
5549 void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
5552 object_type object_type_body;
5553 u32b mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5558 /* Get local object */
5559 i_ptr = &object_type_body;
5561 /* Wipe the object */
5564 /* Make a good (or great) object (if possible) */
5565 if (!make_object(i_ptr, mode)) continue;
5569 object_aware(i_ptr);
5570 object_known(i_ptr);
5573 /* Drop the object */
5574 (void)drop_near(i_ptr, -1, y1, x1);
5579 * Scatter some "amusing" objects near the player
5582 #define AMS_NOTHING 0x00 /* No restriction */
5583 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5584 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5585 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5586 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5596 amuse_type amuse_info[] =
5598 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5599 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5600 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5601 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5602 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5603 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5604 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5605 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5606 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5607 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5608 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5609 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5610 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5616 * @brief ïÆÀ¥É¥í¥Ã¥×¤ò¹Ô¤¦¡£
5617 * @param y ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎYºÂɸ
5618 * @param x ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎXºÂɸ
5619 * @param num ïÆÀ¤Î½èÍý²ó¿ô
5620 * @param known TRUE¤Ê¤é¤Ð¥ª¥Ö¥¸¥§¥¯¥È¤¬É¬¤º¡ö´ÕÄê¡öºÑ¤Ë¤Ê¤ë
5623 void amusement(int y1, int x1, int num, bool known)
5626 object_type object_type_body;
5629 for (n = 0; amuse_info[n].tval != 0; n++)
5631 t += amuse_info[n].prob;
5637 int i, k_idx, a_idx = 0;
5638 int r = randint0(t);
5639 bool insta_art, fixed_art;
5643 r -= amuse_info[i].prob;
5647 /* Get local object */
5648 i_ptr = &object_type_body;
5650 /* Wipe the object */
5653 /* Wipe the object */
5654 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5656 /* Paranoia - reroll if nothing */
5657 if (!k_idx) continue;
5659 /* Search an artifact index if need */
5660 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5661 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5663 if (insta_art || fixed_art)
5665 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5667 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5668 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5669 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5670 if (a_info[a_idx].cur_num > 0) continue;
5674 if (a_idx >= max_a_idx) continue;
5677 /* Make an object (if possible) */
5678 object_prep(i_ptr, k_idx);
5679 if (a_idx) i_ptr->name1 = a_idx;
5680 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5682 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5684 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5687 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5688 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5692 object_aware(i_ptr);
5693 object_known(i_ptr);
5696 /* Paranoia - reroll if nothing */
5697 if (!(i_ptr->k_idx)) continue;
5699 /* Drop the object */
5700 (void)drop_near(i_ptr, -1, y1, x1);
5707 #define MAX_NORMAL_TRAPS 18
5709 /* See init_feat_variables() in init2.c */
5710 static s16b normal_traps[MAX_NORMAL_TRAPS];
5713 * @brief ¥¿¥°¤Ë½¾¤Ã¤Æ¡¢´ðËܥȥé¥Ã¥×¥Æ¡¼¥Ö¥ë¤ò½é´ü²½¤¹¤ë / Initialize arrays for normal traps
5716 void init_normal_traps(void)
5720 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5721 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5722 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5723 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5724 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5725 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5726 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5727 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5728 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5729 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5730 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5731 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5732 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5733 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5734 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5735 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5736 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5737 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5741 * @brief ´ðËܥȥé¥Ã¥×¤ò¥é¥ó¥À¥à¤ËÁªÂò¤¹¤ë /
5743 * @return ÁªÂò¤·¤¿¥È¥é¥Ã¥×¤ÎID
5745 * XXX XXX XXX This routine should be redone to reflect trap "level".\n
5746 * That is, it does not make sense to have spiked pits at 50 feet.\n
5747 * Actually, it is not this routine, but the "trap instantiation"\n
5748 * code, which should also check for "trap doors" on quest levels.\n
5750 s16b choose_random_trap(void)
5757 /* Hack -- pick a trap */
5758 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5760 /* Accept non-trapdoors */
5761 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5763 /* Hack -- no trap doors on special levels */
5764 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5766 /* Hack -- no trap doors on the deepest level */
5767 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5776 * @brief ¥Þ¥¹¤Ë¸ºß¤¹¤ë¥È¥é¥Ã¥×¤òÈëÆ¿¤¹¤ë /
5777 * Disclose an invisible trap
5778 * @param y ÈëÆ¿¤·¤¿¤¤¥Þ¥¹¤ÎYºÂɸ
5779 * @param x ÈëÆ¿¤·¤¿¤¤¥Þ¥¹¤ÎXºÂɸ
5782 void disclose_grid(int y, int x)
5784 cave_type *c_ptr = &cave[y][x];
5786 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5788 /* No longer hidden */
5789 cave_alter_feat(y, x, FF_SECRET);
5791 else if (c_ptr->mimic)
5793 /* No longer hidden */
5805 * @brief ¥Þ¥¹¤ò¥È¥é¥Ã¥×¤òÇÛÃÖ¤¹¤ë /
5806 * The location must be a legal, naked, floor grid.
5807 * @param y ÇÛÃÖ¤·¤¿¤¤¥Þ¥¹¤ÎYºÂɸ
5808 * @param x ÇÛÃÖ¤·¤¿¤¤¥Þ¥¹¤ÎXºÂɸ
5810 * Note that all traps start out as "invisible" and "untyped", and then\n
5811 * when they are "discovered" (by detecting them or setting them off),\n
5812 * the trap is "instantiated" as a visible, "typed", trap.\n
5814 void place_trap(int y, int x)
5816 cave_type *c_ptr = &cave[y][x];
5818 /* Paranoia -- verify location */
5819 if (!in_bounds(y, x)) return;
5821 /* Require empty, clean, floor grid */
5822 if (!cave_clean_bold(y, x)) return;
5824 /* Place an invisible trap */
5825 c_ptr->mimic = c_ptr->feat;
5826 c_ptr->feat = choose_random_trap();
5830 * @brief ËâÆ»¶ñ¤Î»ÈÍѲó¿ô¤Î»ÄÎ̤ò¼¨¤¹¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë /
5831 * Describe the charges on an item in the inventory.
5832 * @param item »ÄÎ̤òɽ¼¨¤·¤¿¤¤¥×¥ì¥¤¥ä¡¼¤Î¥¢¥¤¥Æ¥à½ê»ý¥¹¥í¥Ã¥È
5835 void inven_item_charges(int item)
5837 object_type *o_ptr = &inventory[item];
5839 /* Require staff/wand */
5840 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5842 /* Require known item */
5843 if (!object_is_known(o_ptr)) return;
5846 if (o_ptr->pval <= 0)
5848 msg_print("¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
5852 msg_format("¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
5855 /* Multiple charges */
5856 if (o_ptr->pval != 1)
5858 /* Print a message */
5859 msg_format("You have %d charges remaining.", o_ptr->pval);
5865 /* Print a message */
5866 msg_format("You have %d charge remaining.", o_ptr->pval);
5873 * @brief ¥¢¥¤¥Æ¥à¤Î»Ä¤ê½ê»ý¿ô¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë /
5874 * Describe an item in the inventory.
5875 * @param item »ÄÎ̤òɽ¼¨¤·¤¿¤¤¥×¥ì¥¤¥ä¡¼¤Î¥¢¥¤¥Æ¥à½ê»ý¥¹¥í¥Ã¥È
5878 void inven_item_describe(int item)
5880 object_type *o_ptr = &inventory[item];
5881 char o_name[MAX_NLEN];
5883 /* Get a description */
5884 object_desc(o_name, o_ptr, 0);
5886 /* Print a message */
5888 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤¹¤ë */
5889 if (o_ptr->number <= 0)
5891 /*FIRST*//*¤³¤³¤Ï¤â¤¦Ä̤é¤Ê¤¤¤«¤â */
5892 msg_format("¤â¤¦%s¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£", o_name);
5896 /* ¥¢¥¤¥Æ¥à̾¤ò±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½Âбþ */
5897 msg_format("¤Þ¤À %s¤ò»ý¤Ã¤Æ¤¤¤ë¡£", o_name);
5900 msg_format("You have %s.", o_name);
5906 * @brief ¥¢¥¤¥Æ¥à¤Î»Ä¤ê½ê»ý¿ô¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë /
5907 * Increase the "number" of an item in the inventory
5908 * @param item ½ê»ý¿ô¤òÁý¤ä¤·¤¿¤¤¥×¥ì¥¤¥ä¡¼¤Î¥¢¥¤¥Æ¥à½ê»ý¥¹¥í¥Ã¥È
5909 * @param num Áý¤ä¤·¤¿¤¤ÎÌ
5912 void inven_item_increase(int item, int num)
5914 object_type *o_ptr = &inventory[item];
5917 num += o_ptr->number;
5920 if (num > 255) num = 255;
5921 else if (num < 0) num = 0;
5924 num -= o_ptr->number;
5926 /* Change the number and weight */
5929 /* Add the number */
5930 o_ptr->number += num;
5932 /* Add the weight */
5933 p_ptr->total_weight += (num * o_ptr->weight);
5935 /* Recalculate bonuses */
5936 p_ptr->update |= (PU_BONUS);
5938 /* Recalculate mana XXX */
5939 p_ptr->update |= (PU_MANA);
5941 /* Combine the pack */
5942 p_ptr->notice |= (PN_COMBINE);
5945 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5947 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5948 if (!o_ptr->number && p_ptr->ele_attack)
5950 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5952 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5954 /* Clear all temporary elemental brands */
5955 set_ele_attack(0, 0);
5963 * @brief ½ê»ý¥¢¥¤¥Æ¥à¥¹¥í¥Ã¥È¤«¤é½ê»ý¿ô¤Î¤Ê¤¯¤Ê¤Ã¤¿¥¢¥¤¥Æ¥à¤ò¾Ãµî¤¹¤ë /
5964 * Erase an inventory slot if it has no more items
5965 * @param item ¾Ãµî¤·¤¿¤¤¥×¥ì¥¤¥ä¡¼¤Î¥¢¥¤¥Æ¥à½ê»ý¥¹¥í¥Ã¥È
5968 void inven_item_optimize(int item)
5970 object_type *o_ptr = &inventory[item];
5972 /* Only optimize real items */
5973 if (!o_ptr->k_idx) return;
5975 /* Only optimize empty items */
5976 if (o_ptr->number) return;
5978 /* The item is in the pack */
5979 if (item < INVEN_RARM)
5986 /* Slide everything down */
5987 for (i = item; i < INVEN_PACK; i++)
5989 /* Structure copy */
5990 inventory[i] = inventory[i+1];
5993 /* Erase the "final" slot */
5994 object_wipe(&inventory[i]);
5997 p_ptr->window |= (PW_INVEN);
6000 /* The item is being wielded */
6006 /* Erase the empty slot */
6007 object_wipe(&inventory[item]);
6009 /* Recalculate bonuses */
6010 p_ptr->update |= (PU_BONUS);
6012 /* Recalculate torch */
6013 p_ptr->update |= (PU_TORCH);
6015 /* Recalculate mana XXX */
6016 p_ptr->update |= (PU_MANA);
6019 p_ptr->window |= (PW_EQUIP);
6023 p_ptr->window |= (PW_SPELL);
6027 * @brief ¾²¾å¤ÎËâÆ»¶ñ¤Î»Ä¤ê»ÄÎÌ¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë /
6028 * Describe the charges on an item on the floor.
6029 * @param item ¥á¥Ã¥»¡¼¥¸¤ÎÂоݤˤ·¤¿¤¤¥¢¥¤¥Æ¥à½ê»ý¥¹¥í¥Ã¥È
6032 void floor_item_charges(int item)
6034 object_type *o_ptr = &o_list[item];
6036 /* Require staff/wand */
6037 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
6039 /* Require known item */
6040 if (!object_is_known(o_ptr)) return;
6043 if (o_ptr->pval <= 0)
6045 msg_print("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
6049 msg_format("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
6052 /* Multiple charges */
6053 if (o_ptr->pval != 1)
6055 /* Print a message */
6056 msg_format("There are %d charges remaining.", o_ptr->pval);
6062 /* Print a message */
6063 msg_format("There is %d charge remaining.", o_ptr->pval);
6070 * @brief ¾²¾å¤Î¥¢¥¤¥Æ¥à¤Î»Ä¤ê¿ô¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë /
6071 * Describe the charges on an item on the floor.
6072 * @param item ¥á¥Ã¥»¡¼¥¸¤ÎÂоݤˤ·¤¿¤¤¥¢¥¤¥Æ¥à½ê»ý¥¹¥í¥Ã¥È
6075 void floor_item_describe(int item)
6077 object_type *o_ptr = &o_list[item];
6078 char o_name[MAX_NLEN];
6080 /* Get a description */
6081 object_desc(o_name, o_ptr, 0);
6083 /* Print a message */
6085 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤òʬ¤±¤ë */
6086 if (o_ptr->number <= 0)
6088 msg_format("¾²¾å¤Ë¤Ï¡¢¤â¤¦%s¤Ï¤Ê¤¤¡£", o_name);
6092 msg_format("¾²¾å¤Ë¤Ï¡¢¤Þ¤À %s¤¬¤¢¤ë¡£", o_name);
6095 msg_format("You see %s.", o_name);
6102 * @brief ¾²¾å¤Î¥¢¥¤¥Æ¥à¤Î¿ô¤òÁý¤ä¤¹ /
6103 * Increase the "number" of an item on the floor
6104 * @param item Áý¤ä¤·¤¿¤¤¥¢¥¤¥Æ¥à¤Î½ê»ý¥¹¥í¥Ã¥È
6105 * @param num Áý¤ä¤·¤¿¤¤¥¢¥¤¥Æ¥à¤Î¿ô
6108 void floor_item_increase(int item, int num)
6110 object_type *o_ptr = &o_list[item];
6113 num += o_ptr->number;
6116 if (num > 255) num = 255;
6117 else if (num < 0) num = 0;
6120 num -= o_ptr->number;
6122 /* Change the number */
6123 o_ptr->number += num;
6128 * @brief ¾²¾å¤Î¿ô¤Î̵¤¯¤Ê¤Ã¤¿¥¢¥¤¥Æ¥à¥¹¥í¥Ã¥È¤ò¾Ãµî¤¹¤ë /
6129 * Optimize an item on the floor (destroy "empty" items)
6130 * @param item ¾Ãµî¤·¤¿¤¤¥¢¥¤¥Æ¥à¤Î½ê»ý¥¹¥í¥Ã¥È
6133 void floor_item_optimize(int item)
6135 object_type *o_ptr = &o_list[item];
6137 /* Paranoia -- be sure it exists */
6138 if (!o_ptr->k_idx) return;
6140 /* Only optimize empty items */
6141 if (o_ptr->number) return;
6143 /* Delete the object */
6144 delete_object_idx(item);
6149 * @brief ¥¢¥¤¥Æ¥à¤ò½¦¤¦ºÝ¤Ë¥¶¥Ã¥¯¤«¤é°î¤ì¤º¤ËºÑ¤à¤«¤òȽÄꤹ¤ë /
6150 * Check if we have space for an item in the pack without overflow
6151 * @param o_ptr ½¦¤¤¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
6152 * @return °î¤ì¤º¤ËºÑ¤à¤Ê¤éTRUE¤òÊÖ¤¹
6154 bool inven_carry_okay(object_type *o_ptr)
6159 if (inven_cnt < INVEN_PACK) return (TRUE);
6162 for (j = 0; j < INVEN_PACK; j++)
6164 object_type *j_ptr = &inventory[j];
6166 /* Skip non-objects */
6167 if (!j_ptr->k_idx) continue;
6169 /* Check if the two items can be combined */
6170 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6178 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤òÄêµÁ¤µ¤ì¤¿´ð½à¤Ë½¾¤¤¥½¡¼¥È¤¹¤ë¤¿¤á¤Î´Ø¿ô /
6179 * Check if we have space for an item in the pack without overflow
6180 * @param o_ptr Èæ³ÓÂоݥª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿1
6181 * @param o_value o_ptr¤Î¥¢¥¤¥Æ¥à²ÁÃ͡ʼêÆ°¤Ç¤¢¤é¤«¤¸¤áÂåÆþ¤¹¤ëɬÍפ¬¤¢¤ë¡©¡Ë
6182 * @return o_ptr¤ÎÊý¤¬¾å°Ì¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
6184 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6188 /* Use empty slots */
6189 if (!j_ptr->k_idx) return TRUE;
6191 /* Hack -- readable books always come first */
6192 if ((o_ptr->tval == REALM1_BOOK) &&
6193 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6194 if ((j_ptr->tval == REALM1_BOOK) &&
6195 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6197 if ((o_ptr->tval == REALM2_BOOK) &&
6198 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6199 if ((j_ptr->tval == REALM2_BOOK) &&
6200 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6202 /* Objects sort by decreasing type */
6203 if (o_ptr->tval > j_ptr->tval) return TRUE;
6204 if (o_ptr->tval < j_ptr->tval) return FALSE;
6206 /* Non-aware (flavored) items always come last */
6207 /* Can happen in the home */
6208 if (!object_is_aware(o_ptr)) return FALSE;
6209 if (!object_is_aware(j_ptr)) return TRUE;
6211 /* Objects sort by increasing sval */
6212 if (o_ptr->sval < j_ptr->sval) return TRUE;
6213 if (o_ptr->sval > j_ptr->sval) return FALSE;
6215 /* Unidentified objects always come last */
6216 /* Objects in the home can be unknown */
6217 if (!object_is_known(o_ptr)) return FALSE;
6218 if (!object_is_known(j_ptr)) return TRUE;
6220 /* Fixed artifacts, random artifacts and ego items */
6221 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6222 else if (o_ptr->art_name) o_type = 2;
6223 else if (object_is_ego(o_ptr)) o_type = 1;
6226 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6227 else if (j_ptr->art_name) j_type = 2;
6228 else if (object_is_ego(j_ptr)) j_type = 1;
6231 if (o_type < j_type) return TRUE;
6232 if (o_type > j_type) return FALSE;
6234 switch (o_ptr->tval)
6240 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6241 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6247 /* Objects sort by increasing hit/damage bonuses */
6248 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6249 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6252 /* Hack: otherwise identical rods sort by
6253 increasing recharge time --dsb */
6255 if (o_ptr->pval < j_ptr->pval) return TRUE;
6256 if (o_ptr->pval > j_ptr->pval) return FALSE;
6260 /* Objects sort by decreasing value */
6261 return o_value > object_value(j_ptr);
6266 * Add an item to the players inventory, and return the slot used.
6268 * If the new item can combine with an existing item in the inventory,
6269 * it will do so, using "object_similar()" and "object_absorb()", else,
6270 * the item will be placed into the "proper" location in the inventory.
6272 * This function can be used to "over-fill" the player's pack, but only
6273 * once, and such an action must trigger the "overflow" code immediately.
6274 * Note that when the pack is being "over-filled", the new item must be
6275 * placed into the "overflow" slot, and the "overflow" must take place
6276 * before the pack is reordered, but (optionally) after the pack is
6277 * combined. This may be tricky. See "dungeon.c" for info.
6279 * Note that this code must remove any location/stack information
6280 * from the object once it is placed into the inventory.
6282 s16b inven_carry(object_type *o_ptr)
6290 /* Check for combining */
6291 for (j = 0; j < INVEN_PACK; j++)
6293 j_ptr = &inventory[j];
6295 /* Skip non-objects */
6296 if (!j_ptr->k_idx) continue;
6298 /* Hack -- track last item */
6301 /* Check if the two items can be combined */
6302 if (object_similar(j_ptr, o_ptr))
6304 /* Combine the items */
6305 object_absorb(j_ptr, o_ptr);
6307 /* Increase the weight */
6308 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6310 /* Recalculate bonuses */
6311 p_ptr->update |= (PU_BONUS);
6314 p_ptr->window |= (PW_INVEN);
6323 if (inven_cnt > INVEN_PACK) return (-1);
6325 /* Find an empty slot */
6326 for (j = 0; j <= INVEN_PACK; j++)
6328 j_ptr = &inventory[j];
6330 /* Use it if found */
6331 if (!j_ptr->k_idx) break;
6338 /* Reorder the pack */
6341 /* Get the "value" of the item */
6342 s32b o_value = object_value(o_ptr);
6344 /* Scan every occupied slot */
6345 for (j = 0; j < INVEN_PACK; j++)
6347 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6354 for (k = n; k >= i; k--)
6356 /* Hack -- Slide the item */
6357 object_copy(&inventory[k+1], &inventory[k]);
6360 /* Wipe the empty slot */
6361 object_wipe(&inventory[i]);
6366 object_copy(&inventory[i], o_ptr);
6368 /* Access new object */
6369 j_ptr = &inventory[i];
6372 j_ptr->next_o_idx = 0;
6374 /* Forget monster */
6375 j_ptr->held_m_idx = 0;
6377 /* Forget location */
6378 j_ptr->iy = j_ptr->ix = 0;
6380 /* Player touches it, and no longer marked */
6381 j_ptr->marked = OM_TOUCHED;
6383 /* Increase the weight */
6384 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6386 /* Count the items */
6389 /* Recalculate bonuses */
6390 p_ptr->update |= (PU_BONUS);
6392 /* Combine and Reorder pack */
6393 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6396 p_ptr->window |= (PW_INVEN);
6398 /* Return the slot */
6404 * Take off (some of) a non-cursed equipment item
6406 * Note that only one item at a time can be wielded per slot.
6408 * Note that taking off an item when "full" may cause that item
6409 * to fall to the ground.
6411 * Return the inventory slot into which the item is placed.
6413 s16b inven_takeoff(int item, int amt)
6424 char o_name[MAX_NLEN];
6427 /* Get the item to take off */
6428 o_ptr = &inventory[item];
6431 if (amt <= 0) return (-1);
6434 if (amt > o_ptr->number) amt = o_ptr->number;
6436 /* Get local object */
6439 /* Obtain a local object */
6440 object_copy(q_ptr, o_ptr);
6442 /* Modify quantity */
6443 q_ptr->number = amt;
6445 /* Describe the object */
6446 object_desc(o_name, q_ptr, 0);
6448 /* Took off weapon */
6449 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6450 object_is_melee_weapon(o_ptr))
6453 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
6455 act = "You were wielding";
6461 else if (item == INVEN_BOW)
6464 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
6466 act = "You were holding";
6471 /* Took off light */
6472 else if (item == INVEN_LITE)
6475 act = "¤ò¸÷¸»¤«¤é¤Ï¤º¤·¤¿";
6477 act = "You were holding";
6482 /* Took off something */
6486 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
6488 act = "You were wearing";
6493 /* Modify, Optimize */
6494 inven_item_increase(item, -amt);
6495 inven_item_optimize(item);
6497 /* Carry the object */
6498 slot = inven_carry(q_ptr);
6502 msg_format("%s(%c)%s¡£", o_name, index_to_label(slot), act);
6504 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6514 * Drop (some of) a non-cursed inventory/equipment item
6516 * The object will be dropped "near" the current location
6518 void inven_drop(int item, int amt)
6525 char o_name[MAX_NLEN];
6528 /* Access original object */
6529 o_ptr = &inventory[item];
6532 if (amt <= 0) return;
6535 if (amt > o_ptr->number) amt = o_ptr->number;
6538 /* Take off equipment */
6539 if (item >= INVEN_RARM)
6541 /* Take off first */
6542 item = inven_takeoff(item, amt);
6544 /* Access original object */
6545 o_ptr = &inventory[item];
6549 /* Get local object */
6552 /* Obtain local object */
6553 object_copy(q_ptr, o_ptr);
6555 /* Distribute charges of wands or rods */
6556 distribute_charges(o_ptr, q_ptr, amt);
6558 /* Modify quantity */
6559 q_ptr->number = amt;
6561 /* Describe local object */
6562 object_desc(o_name, q_ptr, 0);
6566 msg_format("%s(%c)¤òÍî¤È¤·¤¿¡£", o_name, index_to_label(item));
6568 msg_format("You drop %s (%c).", o_name, index_to_label(item));
6572 /* Drop it near the player */
6573 (void)drop_near(q_ptr, 0, py, px);
6575 /* Modify, Describe, Optimize */
6576 inven_item_increase(item, -amt);
6577 inven_item_describe(item);
6578 inven_item_optimize(item);
6583 * Combine items in the pack
6585 * Note special handling of the "overflow" slot
6587 void combine_pack(void)
6592 bool flag = FALSE, combined;
6598 /* Combine the pack (backwards) */
6599 for (i = INVEN_PACK; i > 0; i--)
6602 o_ptr = &inventory[i];
6604 /* Skip empty items */
6605 if (!o_ptr->k_idx) continue;
6607 /* Scan the items above that item */
6608 for (j = 0; j < i; j++)
6613 j_ptr = &inventory[j];
6615 /* Skip empty items */
6616 if (!j_ptr->k_idx) continue;
6619 * Get maximum number of the stack if these
6620 * are similar, get zero otherwise.
6622 max_num = object_similar_part(j_ptr, o_ptr);
6624 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6625 if (max_num && j_ptr->number < max_num)
6627 if (o_ptr->number + j_ptr->number <= max_num)
6632 /* Add together the item counts */
6633 object_absorb(j_ptr, o_ptr);
6635 /* One object is gone */
6638 /* Slide everything down */
6639 for (k = i; k < INVEN_PACK; k++)
6641 /* Structure copy */
6642 inventory[k] = inventory[k+1];
6645 /* Erase the "final" slot */
6646 object_wipe(&inventory[k]);
6650 int old_num = o_ptr->number;
6651 int remain = j_ptr->number + o_ptr->number - max_num;
6653 o_ptr->number -= remain;
6655 /* Add together the item counts */
6656 object_absorb(j_ptr, o_ptr);
6658 o_ptr->number = remain;
6660 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6661 if (o_ptr->tval == TV_ROD)
6663 o_ptr->pval = o_ptr->pval * remain / old_num;
6664 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6667 /* Hack -- if wands are stacking, combine the charges. -LM- */
6668 if (o_ptr->tval == TV_WAND)
6670 o_ptr->pval = o_ptr->pval * remain / old_num;
6675 p_ptr->window |= (PW_INVEN);
6690 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤ò¤Þ¤È¤áľ¤·¤¿¡£");
6692 if (flag) msg_print("You combine some items in your pack.");
6698 * Reorder items in the pack
6700 * Note special handling of the "overflow" slot
6702 void reorder_pack(void)
6712 /* Re-order the pack (forwards) */
6713 for (i = 0; i < INVEN_PACK; i++)
6715 /* Mega-Hack -- allow "proper" over-flow */
6716 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6719 o_ptr = &inventory[i];
6721 /* Skip empty slots */
6722 if (!o_ptr->k_idx) continue;
6724 /* Get the "value" of the item */
6725 o_value = object_value(o_ptr);
6727 /* Scan every occupied slot */
6728 for (j = 0; j < INVEN_PACK; j++)
6730 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6733 /* Never move down */
6734 if (j >= i) continue;
6739 /* Get local object */
6742 /* Save a copy of the moving item */
6743 object_copy(q_ptr, &inventory[i]);
6745 /* Slide the objects */
6746 for (k = i; k > j; k--)
6748 /* Slide the item */
6749 object_copy(&inventory[k], &inventory[k-1]);
6752 /* Insert the moving item */
6753 object_copy(&inventory[j], q_ptr);
6756 p_ptr->window |= (PW_INVEN);
6761 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤òÊ¤Ùľ¤·¤¿¡£");
6763 if (flag) msg_print("You reorder some items in your pack.");
6770 * Hack -- display an object kind in the current window
6772 * Include list of usable spells for readible books
6774 void display_koff(int k_idx)
6783 char o_name[MAX_NLEN];
6786 /* Erase the window */
6787 for (y = 0; y < Term->hgt; y++)
6789 /* Erase the line */
6790 Term_erase(0, y, 255);
6796 /* Get local object */
6799 /* Prepare the object */
6800 object_prep(q_ptr, k_idx);
6803 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6805 /* Mention the object name */
6806 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6808 /* Access the item's sval */
6810 use_realm = tval2realm(q_ptr->tval);
6812 /* Warriors are illiterate */
6813 if (p_ptr->realm1 || p_ptr->realm2)
6815 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6819 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6820 if (!is_magic(use_realm)) return;
6821 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6824 /* Display spells in readible books */
6830 /* Extract spells */
6831 for (spell = 0; spell < 32; spell++)
6833 /* Check for this spell */
6834 if (fake_spell_flags[sval] & (1L << spell))
6836 /* Collect this spell */
6837 spells[num++] = spell;
6842 print_spells(0, spells, num, 2, 0, use_realm);
6846 /* Choose one of items that have warning flag */
6847 object_type *choose_warning_item(void)
6850 int choices[INVEN_TOTAL - INVEN_RARM];
6853 /* Paranoia -- Player has no warning ability */
6854 if (!p_ptr->warning) return NULL;
6856 /* Search Inventory */
6857 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6859 u32b flgs[TR_FLAG_SIZE];
6860 object_type *o_ptr = &inventory[i];
6862 object_flags(o_ptr, flgs);
6863 if (have_flag(flgs, TR_WARNING))
6865 choices[number] = i;
6870 /* Choice one of them */
6871 return number ? &inventory[choices[randint0(number)]] : NULL;
6874 /* Calculate spell damages */
6875 static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int *max)
6877 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6878 int rlev = r_ptr->level;
6879 bool ignore_wraith_form = FALSE;
6881 if (limit) dam = (dam > limit) ? limit : dam;
6883 /* Vulnerability, resistance and immunity */
6887 if (p_ptr->immune_elec)
6890 ignore_wraith_form = TRUE;
6894 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6895 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6896 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6897 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6898 if (IS_OPPOSE_ELEC())
6899 dam = (dam + 2) / 3;
6904 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6905 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6909 if (p_ptr->immune_acid)
6912 ignore_wraith_form = TRUE;
6916 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6917 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6918 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6919 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6925 if (p_ptr->immune_cold)
6928 ignore_wraith_form = TRUE;
6932 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6933 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6934 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6935 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6940 if (p_ptr->immune_fire)
6943 ignore_wraith_form = TRUE;
6947 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6948 if (prace_is_(RACE_ENT)) dam += dam / 3;
6949 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6950 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6951 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6956 ignore_wraith_form = TRUE;
6960 if (!p_ptr->blind &&
6961 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6962 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6965 ignore_wraith_form = TRUE;
6970 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6971 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6972 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6975 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6976 * "dam *= 2;" for later "dam /= 2"
6978 if (p_ptr->wraith_form) dam *= 2;
6982 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6985 ignore_wraith_form = TRUE;
6987 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6991 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6995 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6999 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
7003 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
7007 if (prace_is_(RACE_SPECTRE))
7010 ignore_wraith_form = TRUE;
7012 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
7016 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
7020 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
7024 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
7028 if (p_ptr->levitation) dam = (dam * 2) / 3;
7032 if (p_ptr->resist_shard) dam /= 2;
7036 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
7037 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
7041 if (p_ptr->mimic_form)
7043 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
7046 ignore_wraith_form = TRUE;
7051 switch (p_ptr->prace)
7060 ignore_wraith_form = TRUE;
7067 if (p_ptr->align > 10) dam /= 2;
7068 else if (p_ptr->align < -10) dam *= 2;
7072 if (p_ptr->align > 10) dam *= 2;
7076 case GF_BRAIN_SMASH:
7077 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
7080 ignore_wraith_form = TRUE;
7088 if (100 + rlev / 2 <= p_ptr->skill_sav)
7091 ignore_wraith_form = TRUE;
7096 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
7099 ignore_wraith_form = TRUE;
7104 if (p_ptr->wraith_form && !ignore_wraith_form)
7110 if (dam > *max) *max = dam;
7113 /* Calculate blow damages */
7114 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
7116 int dam = blow_ptr->d_dice * blow_ptr->d_side;
7118 bool check_wraith_form = TRUE;
7120 if (blow_ptr->method != RBM_EXPLODE)
7122 int ac = p_ptr->ac + p_ptr->to_a;
7124 switch (blow_ptr->effect)
7128 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
7129 dam = MAX(dam, tmp_dam * 2);
7135 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
7139 spell_damcalc(m_ptr, GF_ACID, dam, 0, &dummy_max);
7141 check_wraith_form = FALSE;
7145 spell_damcalc(m_ptr, GF_ELEC, dam, 0, &dummy_max);
7147 check_wraith_form = FALSE;
7151 spell_damcalc(m_ptr, GF_FIRE, dam, 0, &dummy_max);
7153 check_wraith_form = FALSE;
7157 spell_damcalc(m_ptr, GF_COLD, dam, 0, &dummy_max);
7159 check_wraith_form = FALSE;
7164 check_wraith_form = FALSE;
7168 if (check_wraith_form && p_ptr->wraith_form)
7176 dam = (dam + 1) / 2;
7177 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, 0, &dummy_max);
7184 /* Examine the grid (xx,yy) and warn the player if there are any danger */
7185 bool process_warning(int xx, int yy)
7189 char o_name[MAX_NLEN];
7191 #define WARNING_AWARE_RANGE 12
7193 static int old_damage = 0;
7195 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7197 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7200 monster_type *m_ptr;
7201 monster_race *r_ptr;
7203 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7205 c_ptr = &cave[my][mx];
7207 if (!c_ptr->m_idx) continue;
7209 m_ptr = &m_list[c_ptr->m_idx];
7211 if (MON_CSLEEP(m_ptr)) continue;
7212 if (!is_hostile(m_ptr)) continue;
7214 r_ptr = &r_info[m_ptr->r_idx];
7216 /* Monster spells (only powerful ones)*/
7217 if (projectable(my, mx, yy, xx))
7219 int breath_dam_div3 = m_ptr->hp / 3;
7220 int breath_dam_div6 = m_ptr->hp / 6;
7221 u32b f4 = r_ptr->flags4;
7222 u32b f5 = r_ptr->flags5;
7223 u32b f6 = r_ptr->flags6;
7225 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7227 int rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
7228 int storm_dam = rlev * 4 + 150;
7229 bool powerful = (bool)(r_ptr->flags2 & RF2_POWERFUL);
7231 if (f4 & RF4_BA_CHAO) spell_damcalc(m_ptr, GF_CHAOS, rlev * (powerful ? 3 : 2) + 100, 0, &dam_max0);
7232 if (f5 & RF5_BA_MANA) spell_damcalc(m_ptr, GF_MANA, storm_dam, 0, &dam_max0);
7233 if (f5 & RF5_BA_DARK) spell_damcalc(m_ptr, GF_DARK, storm_dam, 0, &dam_max0);
7234 if (f5 & RF5_BA_LITE) spell_damcalc(m_ptr, GF_LITE, storm_dam, 0, &dam_max0);
7235 if (f6 & RF6_HAND_DOOM) spell_damcalc(m_ptr, GF_HAND_DOOM, p_ptr->chp * 6 / 10, 0, &dam_max0);
7236 if (f6 & RF6_PSY_SPEAR) spell_damcalc(m_ptr, GF_PSY_SPEAR, powerful ? (rlev * 2 + 150) : (rlev * 3 / 2 + 100), 0, &dam_max0);
7238 if (f4 & RF4_ROCKET) spell_damcalc(m_ptr, GF_ROCKET, m_ptr->hp / 4, 800, &dam_max0);
7239 if (f4 & RF4_BR_ACID) spell_damcalc(m_ptr, GF_ACID, breath_dam_div3, 1600, &dam_max0);
7240 if (f4 & RF4_BR_ELEC) spell_damcalc(m_ptr, GF_ELEC, breath_dam_div3, 1600, &dam_max0);
7241 if (f4 & RF4_BR_FIRE) spell_damcalc(m_ptr, GF_FIRE, breath_dam_div3, 1600, &dam_max0);
7242 if (f4 & RF4_BR_COLD) spell_damcalc(m_ptr, GF_COLD, breath_dam_div3, 1600, &dam_max0);
7243 if (f4 & RF4_BR_POIS) spell_damcalc(m_ptr, GF_POIS, breath_dam_div3, 800, &dam_max0);
7244 if (f4 & RF4_BR_NETH) spell_damcalc(m_ptr, GF_NETHER, breath_dam_div6, 550, &dam_max0);
7245 if (f4 & RF4_BR_LITE) spell_damcalc(m_ptr, GF_LITE, breath_dam_div6, 400, &dam_max0);
7246 if (f4 & RF4_BR_DARK) spell_damcalc(m_ptr, GF_DARK, breath_dam_div6, 400, &dam_max0);
7247 if (f4 & RF4_BR_CONF) spell_damcalc(m_ptr, GF_CONFUSION, breath_dam_div6, 450, &dam_max0);
7248 if (f4 & RF4_BR_SOUN) spell_damcalc(m_ptr, GF_SOUND, breath_dam_div6, 450, &dam_max0);
7249 if (f4 & RF4_BR_CHAO) spell_damcalc(m_ptr, GF_CHAOS, breath_dam_div6, 600, &dam_max0);
7250 if (f4 & RF4_BR_DISE) spell_damcalc(m_ptr, GF_DISENCHANT, breath_dam_div6, 500, &dam_max0);
7251 if (f4 & RF4_BR_NEXU) spell_damcalc(m_ptr, GF_NEXUS, breath_dam_div3, 250, &dam_max0);
7252 if (f4 & RF4_BR_TIME) spell_damcalc(m_ptr, GF_TIME, breath_dam_div3, 150, &dam_max0);
7253 if (f4 & RF4_BR_INER) spell_damcalc(m_ptr, GF_INERTIA, breath_dam_div6, 200, &dam_max0);
7254 if (f4 & RF4_BR_GRAV) spell_damcalc(m_ptr, GF_GRAVITY, breath_dam_div3, 200, &dam_max0);
7255 if (f4 & RF4_BR_SHAR) spell_damcalc(m_ptr, GF_SHARDS, breath_dam_div6, 500, &dam_max0);
7256 if (f4 & RF4_BR_PLAS) spell_damcalc(m_ptr, GF_PLASMA, breath_dam_div6, 150, &dam_max0);
7257 if (f4 & RF4_BR_WALL) spell_damcalc(m_ptr, GF_FORCE, breath_dam_div6, 200, &dam_max0);
7258 if (f4 & RF4_BR_MANA) spell_damcalc(m_ptr, GF_MANA, breath_dam_div3, 250, &dam_max0);
7259 if (f4 & RF4_BR_NUKE) spell_damcalc(m_ptr, GF_NUKE, breath_dam_div3, 800, &dam_max0);
7260 if (f4 & RF4_BR_DISI) spell_damcalc(m_ptr, GF_DISINTEGRATE, breath_dam_div6, 150, &dam_max0);
7263 /* Monster melee attacks */
7264 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7266 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7270 for (m = 0; m < 4; m++)
7272 /* Skip non-attacks */
7273 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7275 /* Extract the attack info */
7276 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7277 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7279 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7283 /* Contribution from this monster */
7284 dam_max += dam_max0;
7288 /* Prevent excessive warning */
7289 if (dam_max > old_damage)
7291 old_damage = dam_max * 3 / 2;
7293 if (dam_max > p_ptr->chp / 2)
7295 object_type *o_ptr = choose_warning_item();
7297 if (o_ptr) object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7299 else strcpy(o_name, "ÂÎ"); /* Warning ability without item */
7300 msg_format("%s¤¬±Ô¤¯¿Ì¤¨¤¿¡ª", o_name);
7302 else strcpy(o_name, "body"); /* Warning ability without item */
7303 msg_format("Your %s pulsates sharply!", o_name);
7307 return get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©");
7309 return get_check("Really want to go ahead? ");
7313 else old_damage = old_damage / 2;
7315 c_ptr = &cave[yy][xx];
7316 if (((!easy_disarm && is_trap(c_ptr->feat))
7317 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7319 object_type *o_ptr = choose_warning_item();
7321 if (o_ptr) object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7323 else strcpy(o_name, "ÂÎ"); /* Warning ability without item */
7324 msg_format("%s¤¬¿Ì¤¨¤¿¡ª", o_name);
7326 else strcpy(o_name, "body"); /* Warning ability without item */
7327 msg_format("Your %s pulsates!", o_name);
7331 return get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©");
7333 return get_check("Really want to go ahead? ");
7341 static bool item_tester_hook_melee_ammo(object_type *o_ptr)
7343 switch (o_ptr->tval)
7356 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
7365 * A structure for smithing
7368 int add; /* TR flag number or special essence id */
7369 cptr add_name; /* Name of this ability */
7370 int type; /* Menu number */
7371 int essence; /* Index for carrying essences */
7372 int value; /* Needed value to add this ability */
7377 * Smithing type data for Weapon smith
7380 static essence_type essence_info[] =
7382 {TR_STR, "ÏÓÎÏ", 4, TR_STR, 20},
7383 {TR_INT, "ÃÎǽ", 4, TR_INT, 20},
7384 {TR_WIS, "¸¤µ", 4, TR_WIS, 20},
7385 {TR_DEX, "´ïÍѤµ", 4, TR_DEX, 20},
7386 {TR_CON, "Âѵ×ÎÏ", 4, TR_CON, 20},
7387 {TR_CHR, "Ì¥ÎÏ", 4, TR_CHR, 20},
7388 {TR_MAGIC_MASTERY, "ËâÎÏ»ÙÇÛ", 4, TR_MAGIC_MASTERY, 20},
7389 {TR_STEALTH, "±£Ì©", 4, TR_STEALTH, 40},
7390 {TR_SEARCH, "õº÷", 4, TR_SEARCH, 15},
7391 {TR_INFRA, "ÀÖ³°Àþ»ëÎÏ", 4, TR_INFRA, 15},
7392 {TR_TUNNEL, "ºÎ·¡", 4, TR_TUNNEL, 15},
7393 {TR_SPEED, "¥¹¥Ô¡¼¥É", 4, TR_SPEED, 12},
7394 {TR_BLOWS, "Äɲù¶·â", 1, TR_BLOWS, 20},
7395 {TR_CHAOTIC, "¥«¥ª¥¹¹¶·â", 1, TR_CHAOTIC, 15},
7396 {TR_VAMPIRIC, "µÛ·ì¹¶·â", 1, TR_VAMPIRIC, 60},
7397 {TR_IMPACT, "ÃÏ¿Ìȯư", 7, TR_IMPACT, 15},
7398 {TR_BRAND_POIS, "ÆÇ»¦", 1, TR_BRAND_POIS, 20},
7399 {TR_BRAND_ACID, "Íϲò", 1, TR_BRAND_ACID, 20},
7400 {TR_BRAND_ELEC, "ÅÅ·â", 1, TR_BRAND_ELEC, 20},
7401 {TR_BRAND_FIRE, "¾Æ´þ", 1, TR_BRAND_FIRE, 20},
7402 {TR_BRAND_COLD, "Åà·ë", 1, TR_BRAND_COLD, 20},
7403 {TR_SUST_STR, "ÏÓÎÏ°Ý»ý", 3, TR_SUST_STR, 15},
7404 {TR_SUST_INT, "ÃÎǽ°Ý»ý", 3, TR_SUST_STR, 15},
7405 {TR_SUST_WIS, "¸¤µ°Ý»ý", 3, TR_SUST_STR, 15},
7406 {TR_SUST_DEX, "´ïÍѤµ°Ý»ý", 3, TR_SUST_STR, 15},
7407 {TR_SUST_CON, "Âѵ×ÎÏ°Ý»ý", 3, TR_SUST_STR, 15},
7408 {TR_SUST_CHR, "Ì¥ÎÏ°Ý»ý", 3, TR_SUST_STR, 15},
7409 {TR_IM_ACID, "»ÀÌȱÖ", 2, TR_IM_ACID, 20},
7410 {TR_IM_ELEC, "ÅÅ·âÌȱÖ", 2, TR_IM_ACID, 20},
7411 {TR_IM_FIRE, "²Ð±êÌȱÖ", 2, TR_IM_ACID, 20},
7412 {TR_IM_COLD, "Î䵤ÌȱÖ", 2, TR_IM_ACID, 20},
7413 {TR_REFLECT, "È¿¼Í", 2, TR_REFLECT, 20},
7414 {TR_FREE_ACT, "ËãáãÃΤ餺", 3, TR_FREE_ACT, 20},
7415 {TR_HOLD_LIFE, "À¸Ì¿ÎÏ°Ý»ý", 3, TR_HOLD_LIFE, 20},
7416 {TR_RES_ACID, "ÂÑ»À", 2, TR_RES_ACID, 15},
7417 {TR_RES_ELEC, "ÂÑÅÅ·â", 2, TR_RES_ELEC, 15},
7418 {TR_RES_FIRE, "ÂѲбê", 2, TR_RES_FIRE, 15},
7419 {TR_RES_COLD, "ÂÑÎ䵤", 2, TR_RES_COLD, 15},
7420 {TR_RES_POIS, "ÂÑÆÇ", 2, TR_RES_POIS, 25},
7421 {TR_RES_FEAR, "ÂѶ²ÉÝ", 2, TR_RES_FEAR, 20},
7422 {TR_RES_LITE, "ÂÑÁ®¸÷", 2, TR_RES_LITE, 20},
7423 {TR_RES_DARK, "ÂѰŹõ", 2, TR_RES_DARK, 20},
7424 {TR_RES_BLIND, "ÂÑÌÕÌÜ", 2, TR_RES_BLIND, 20},
7425 {TR_RES_CONF, "ÂѺ®Íð", 2, TR_RES_CONF, 20},
7426 {TR_RES_SOUND, "Âѹ첻", 2, TR_RES_SOUND, 20},
7427 {TR_RES_SHARDS, "ÂÑÇËÊÒ", 2, TR_RES_SHARDS, 20},
7428 {TR_RES_NETHER, "ÂÑÃϹö", 2, TR_RES_NETHER, 20},
7429 {TR_RES_NEXUS, "ÂÑ°ø²Ìº®Íð", 2, TR_RES_NEXUS, 20},
7430 {TR_RES_CHAOS, "ÂÑ¥«¥ª¥¹", 2, TR_RES_CHAOS, 20},
7431 {TR_RES_DISEN, "ÂÑÎô²½", 2, TR_RES_DISEN, 20},
7432 {TR_SH_FIRE, "", 0, -2, 0},
7433 {TR_SH_ELEC, "", 0, -2, 0},
7434 {TR_SH_COLD, "", 0, -2, 0},
7435 {TR_NO_MAGIC, "È¿ËâË¡", 3, TR_NO_MAGIC, 15},
7436 {TR_WARNING, "·Ù¹ð", 3, TR_WARNING, 20},
7437 {TR_LEVITATION, "ÉâÍ·", 3, TR_LEVITATION, 20},
7438 {TR_LITE_1, "±Êµ×¸÷¸»", 3, TR_LITE_1, 15},
7439 {TR_LITE_2, "", 0, -2, 0},
7440 {TR_LITE_3, "", 0, -2, 0},
7441 {TR_SEE_INVIS, "²Ä»ëÆ©ÌÀ", 3, TR_SEE_INVIS, 20},
7442 {TR_TELEPATHY, "¥Æ¥ì¥Ñ¥·¡¼", 6, TR_TELEPATHY, 15},
7443 {TR_SLOW_DIGEST, "Ãپò½", 3, TR_SLOW_DIGEST, 15},
7444 {TR_REGEN, "µÞ®²óÉü", 3, TR_REGEN, 20},
7445 {TR_TELEPORT, "¥Æ¥ì¥Ý¡¼¥È", 3, TR_TELEPORT, 25},
7447 {TR_SLAY_EVIL, "¼Ù°ÇÜÂÇ", 5, TR_SLAY_EVIL, 100},
7448 {TR_KILL_EVIL, "¼Ù°ÇÜÇÜÂÇ", 0, TR_SLAY_EVIL, 60},
7449 {TR_SLAY_ANIMAL, "ưʪÇÜÂÇ", 5, TR_SLAY_ANIMAL, 20},
7450 {TR_KILL_ANIMAL, "ưʪÇÜÇÜÂÇ", 5, TR_SLAY_ANIMAL, 60},
7451 {TR_SLAY_UNDEAD, "ÉÔ»àÇÜÂÇ", 5, TR_SLAY_UNDEAD, 20},
7452 {TR_KILL_UNDEAD, "ÉÔ»àÇÜÇÜÂÇ", 5, TR_SLAY_UNDEAD, 60},
7453 {TR_SLAY_DEMON, "°ËâÇÜÂÇ", 5, TR_SLAY_DEMON, 20},
7454 {TR_KILL_DEMON, "°ËâÇÜÇÜÂÇ", 5, TR_SLAY_DEMON, 60},
7455 {TR_SLAY_ORC, "¥ª¡¼¥¯ÇÜÂÇ", 5, TR_SLAY_ORC, 15},
7456 {TR_KILL_ORC, "¥ª¡¼¥¯ÇÜÇÜÂÇ", 5, TR_SLAY_ORC, 60},
7457 {TR_SLAY_TROLL, "¥È¥í¥ëÇÜÂÇ", 5, TR_SLAY_TROLL, 15},
7458 {TR_KILL_TROLL, "¥È¥í¥ëÇÜÇÜÂÇ", 5, TR_SLAY_TROLL, 60},
7459 {TR_SLAY_GIANT, "µð¿ÍÇÜÂÇ", 5, TR_SLAY_GIANT, 20},
7460 {TR_KILL_GIANT, "µð¿ÍÇÜÇÜÂÇ", 5, TR_SLAY_GIANT, 60},
7461 {TR_SLAY_DRAGON, "εÇÜÂÇ", 5, TR_SLAY_DRAGON, 20},
7462 {TR_KILL_DRAGON, "εÇÜÇÜÂÇ", 5, TR_SLAY_DRAGON, 60},
7463 {TR_SLAY_HUMAN, "¿Í´ÖÇÜÂÇ", 5, TR_SLAY_HUMAN, 20},
7464 {TR_KILL_HUMAN, "¿Í´ÖÇÜÇÜÂÇ", 5, TR_SLAY_HUMAN, 60},
7466 {TR_ESP_ANIMAL, "ưʪESP", 6, TR_SLAY_ANIMAL, 40},
7467 {TR_ESP_UNDEAD, "ÉÔ»àESP", 6, TR_SLAY_UNDEAD, 40},
7468 {TR_ESP_DEMON, "°ËâESP", 6, TR_SLAY_DEMON, 40},
7469 {TR_ESP_ORC, "¥ª¡¼¥¯ESP", 6, TR_SLAY_ORC, 40},
7470 {TR_ESP_TROLL, "¥È¥í¥ëESP", 6, TR_SLAY_TROLL, 40},
7471 {TR_ESP_GIANT, "µð¿ÍESP", 6, TR_SLAY_GIANT, 40},
7472 {TR_ESP_DRAGON, "εESP", 6, TR_SLAY_DRAGON, 40},
7473 {TR_ESP_HUMAN, "¿Í´ÖESP", 6, TR_SLAY_HUMAN, 40},
7475 {ESSENCE_ATTACK, "¹¶·â", 10, TR_ES_ATTACK, 30},
7476 {ESSENCE_AC, "Ëɸæ", 10, TR_ES_AC, 15},
7477 {ESSENCE_TMP_RES_ACID, "»ÀÂÑÀȯư", 7, TR_RES_ACID, 50},
7478 {ESSENCE_TMP_RES_ELEC, "ÅÅ·âÂÑÀȯư", 7, TR_RES_ELEC, 50},
7479 {ESSENCE_TMP_RES_FIRE, "²Ð±êÂÑÀȯư", 7, TR_RES_FIRE, 50},
7480 {ESSENCE_TMP_RES_COLD, "Î䵤ÂÑÀȯư", 7, TR_RES_COLD, 50},
7481 {ESSENCE_SH_FIRE, "²Ð±ê¥ª¡¼¥é", 7, -1, 50},
7482 {ESSENCE_SH_ELEC, "Åŷ⥪¡¼¥é", 7, -1, 50},
7483 {ESSENCE_SH_COLD, "Î䵤¥ª¡¼¥é", 7, -1, 50},
7484 {ESSENCE_RESISTANCE, "Á´ÂÑÀ", 2, -1, 150},
7485 {ESSENCE_SUSTAIN, "ÁõÈ÷ÊÝ»ý", 10, -1, 10},
7486 {ESSENCE_SLAY_GLOVE, "»¦Ù¤¤Î¾®¼ê", 1, TR_ES_ATTACK, 200},
7488 {-1, NULL, 0, -1, 0}
7491 static essence_type essence_info[] =
7493 {TR_STR, "strength", 4, TR_STR, 20},
7494 {TR_INT, "intelligence", 4, TR_INT, 20},
7495 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7496 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7497 {TR_CON, "constitution", 4, TR_CON, 20},
7498 {TR_CHR, "charisma", 4, TR_CHR, 20},
7499 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7500 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7501 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7502 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7503 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7504 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7505 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7506 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7507 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7508 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7509 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7510 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7511 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7512 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7513 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7514 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7515 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7516 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7517 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7518 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7519 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7520 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7521 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7522 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7523 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7524 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7525 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7526 {TR_HOLD_LIFE, "hold life", 3, TR_HOLD_LIFE, 20},
7527 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7528 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7529 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7530 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7531 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7532 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7533 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7534 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7535 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7536 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7537 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7538 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7539 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7540 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7541 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7542 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7543 {TR_SH_FIRE, "", 0, -2, 0},
7544 {TR_SH_ELEC, "", 0, -2, 0},
7545 {TR_SH_COLD, "", 0, -2, 0},
7546 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7547 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7548 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7549 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7550 {TR_LITE_2, "", 0, -2, 0},
7551 {TR_LITE_3, "", 0, -2, 0},
7552 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7553 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7554 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7555 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7556 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7558 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7559 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7560 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7561 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7562 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7563 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7564 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7565 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7566 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7567 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7568 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7569 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7570 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7571 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7572 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7573 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7574 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7575 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7577 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7578 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7579 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7580 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7581 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7582 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7583 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7584 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7586 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7587 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7588 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7589 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7590 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7591 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7592 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7593 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7594 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7595 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7596 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7597 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7599 {-1, NULL, 0, -1, 0}
7605 * Essense names for Weapon smith
7608 cptr essence_name[] =
7711 static cptr essence_name[] =
7814 static void display_essence(void)
7819 for (i = 1; i < 22; i++)
7824 prt("¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô", 1, 8);
7826 prt("Essence Num Essence Num Essence Num ", 1, 8);
7828 for (i = 0; essence_name[i]; i++)
7830 if (!essence_name[i][0]) continue;
7831 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7835 prt("¸½ºß½ê»ý¤·¤Æ¤¤¤ë¥¨¥Ã¥»¥ó¥¹", 0, 0);
7837 prt("List of all essences you have.", 0, 0);
7844 static void drain_essence(void)
7846 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7849 bool observe = FALSE;
7850 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2, old_timeout;
7851 u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7854 byte iy, ix, marked, number;
7855 s16b next_o_idx, weight;
7857 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7860 item_tester_hook = object_is_weapon_armour_ammo;
7861 item_tester_no_ryoute = TRUE;
7865 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éÃê½Ð¤·¤Þ¤¹¤«¡©";
7866 s = "Ãê½Ð¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
7868 q = "Extract from which item? ";
7869 s = "You have nothing you can extract from.";
7872 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7874 /* Get the item (in the pack) */
7877 o_ptr = &inventory[item];
7880 /* Get the item (on the floor) */
7883 o_ptr = &o_list[0 - item];
7886 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7888 char o_name[MAX_NLEN];
7889 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7891 if (!get_check(format("ËÜÅö¤Ë%s¤«¤éÃê½Ð¤·¤Æ¤è¤í¤·¤¤¤Ç¤¹¤«¡©", o_name))) return;
7893 if (!get_check(format("Really extract from %s? ", o_name))) return;
7899 object_flags(o_ptr, old_flgs);
7900 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7901 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7902 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7903 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7904 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7905 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7906 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7907 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7908 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7910 old_to_a = o_ptr->to_a;
7912 old_to_h = o_ptr->to_h;
7913 old_to_d = o_ptr->to_d;
7916 old_pval = o_ptr->pval;
7917 old_name2 = o_ptr->name2;
7918 old_timeout = o_ptr->timeout;
7919 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7920 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7921 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7922 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7923 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7924 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7925 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7926 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7927 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7928 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7929 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7930 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7931 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7932 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7933 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7934 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7935 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7936 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7937 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7941 next_o_idx = o_ptr->next_o_idx;
7942 marked = o_ptr->marked;
7943 weight = o_ptr->weight;
7944 number = o_ptr->number;
7946 object_prep(o_ptr, o_ptr->k_idx);
7950 o_ptr->next_o_idx=next_o_idx;
7951 o_ptr->marked=marked;
7952 o_ptr->number = number;
7953 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7954 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7955 o_ptr->ident |= (IDENT_MENTAL);
7956 object_aware(o_ptr);
7957 object_known(o_ptr);
7959 object_flags(o_ptr, new_flgs);
7961 for (i = 0; essence_info[i].add_name; i++)
7963 essence_type *es_ptr = &essence_info[i];
7966 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7967 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7969 if (es_ptr->add < TR_FLAG_MAX &&
7970 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7971 have_flag(old_flgs, es_ptr->add))
7975 drain_value[es_ptr->essence] += 10 * pval;
7977 else if (es_ptr->essence != -2)
7979 drain_value[es_ptr->essence] += 10;
7981 else if (es_ptr->add == TR_SH_FIRE)
7983 drain_value[TR_BRAND_FIRE] += 10;
7984 drain_value[TR_RES_FIRE] += 10;
7986 else if (es_ptr->add == TR_SH_ELEC)
7988 drain_value[TR_BRAND_ELEC] += 10;
7989 drain_value[TR_RES_ELEC] += 10;
7991 else if (es_ptr->add == TR_SH_COLD)
7993 drain_value[TR_BRAND_COLD] += 10;
7994 drain_value[TR_RES_COLD] += 10;
7996 else if (es_ptr->add == TR_LITE_2)
7998 drain_value[TR_LITE_1] += 20;
8000 else if (es_ptr->add == TR_LITE_3)
8002 drain_value[TR_LITE_1] += 30;
8007 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
8009 drain_value[TR_INT] += 5;
8010 drain_value[TR_WIS] += 5;
8012 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
8014 drain_value[TR_BRAND_POIS] += 5;
8015 drain_value[TR_BRAND_ACID] += 5;
8016 drain_value[TR_BRAND_ELEC] += 5;
8017 drain_value[TR_BRAND_FIRE] += 5;
8018 drain_value[TR_BRAND_COLD] += 5;
8020 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
8022 drain_value[TR_INT] += 10;
8024 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
8026 drain_value[TR_STR] += 10;
8028 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
8030 drain_value[TR_DEX] += 10;
8032 if (old_name2 == EGO_2WEAPON)
8034 drain_value[TR_DEX] += 20;
8036 if (object_is_weapon_ammo(o_ptr))
8038 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
8040 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
8042 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
8043 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
8044 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
8045 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
8047 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
8049 drain_value[i] *= number;
8050 drain_value[i] = drain_value[i] * dec / 4;
8051 drain_value[i] = MAX(drain_value[i], 0);
8052 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
8060 msg_print(_("¥¨¥Ã¥»¥ó¥¹¤ÏÃê½Ð¤Ç¤¤Þ¤»¤ó¤Ç¤·¤¿¡£", "You were not able to extract any essence."));
8064 msg_print(_("Ãê½Ð¤·¤¿¥¨¥Ã¥»¥ó¥¹:", "Extracted essences:"));
8066 for (i = 0; essence_name[i]; i++)
8068 if (!essence_name[i][0]) continue;
8069 if (!drain_value[i]) continue;
8071 p_ptr->magic_num1[i] += drain_value[i];
8072 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
8074 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("¡£", ". "));
8078 /* Apply autodestroy/inscription to the drained item */
8079 autopick_alter_item(item, TRUE);
8081 /* Combine the pack */
8082 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8085 p_ptr->window |= (PW_INVEN);
8090 static int choose_essence(void)
8094 int menu_line = (use_menu ? 1 : 0);
8097 cptr menu_name[] = {
8107 cptr menu_name[] = {
8117 const int mode_max = 7;
8120 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
8123 #endif /* ALLOW_REPEAT */
8132 for (i = 0; i < mode_max; i++)
8134 prt(format(" %s %s", (menu_line == 1+i) ? "¡Õ" : " ", menu_name[i]), 2 + i, 14);
8135 prt("¤É¤Î¼ïÎà¤Î¥¨¥Ã¥»¥ó¥¹Éղäò¹Ô¤¤¤Þ¤¹¤«¡©", 0, 0);
8137 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
8138 prt("Choose from menu.", 0, 0);
8157 menu_line += mode_max - 1;
8166 if (menu_line > mode_max) menu_line -= mode_max;
8177 for (i = 0; i < mode_max; i++)
8178 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
8181 if (!get_com("²¿¤òÉղä·¤Þ¤¹¤«:", &choice, TRUE))
8183 if (!get_com("Command :", &choice, TRUE))
8190 if (isupper(choice)) choice = tolower(choice);
8192 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8193 mode = (int)choice - 'a' + 1;
8200 #endif /* ALLOW_REPEAT */
8204 static void add_essence(int mode)
8206 int item, max_num = 0;
8215 char o_name[MAX_NLEN];
8217 essence_type *es_ptr;
8219 int menu_line = (use_menu ? 1 : 0);
8221 for (i = 0; essence_info[i].add_name; i++)
8223 es_ptr = &essence_info[i];
8225 if (es_ptr->type != mode) continue;
8230 if (!repeat_pull(&i) || i<0 || i>=max_num)
8232 #endif /* ALLOW_REPEAT */
8235 /* Nothing chosen yet */
8241 /* Build a prompt */
8243 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎǽÎϤòÉղä·¤Þ¤¹¤«¡©");
8245 (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Add which ability? ");
8247 if (use_menu) screen_save();
8249 /* Get a spell from the user */
8251 choice = (always_show_list || use_menu) ? ESCAPE:1;
8255 if( choice==ESCAPE ) choice = ' ';
8256 else if( !get_com(out_val, &choice, FALSE) )break;
8258 if (use_menu && choice != ' ')
8272 menu_line += (max_num-1);
8295 menu_line = max_num;
8309 if (menu_line > max_num) menu_line -= max_num;
8311 /* Request redraw */
8312 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8315 if (!redraw || use_menu)
8319 char dummy[80], dummy2[80];
8327 /* Save the screen */
8328 if (!use_menu) screen_save();
8330 for (y = 1; y < 24; y++)
8333 /* Print header(s) */
8335 prt(format(" %-43s %6s/%s", "ǽÎÏ(ɬÍ×¥¨¥Ã¥»¥ó¥¹)", "ɬÍ׿ô", "½ê»ý¿ô"), 1, x);
8338 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8341 for (ctr = 0; ctr < max_num; ctr++)
8343 es_ptr = &essence_info[num[ctr]];
8347 if (ctr == (menu_line-1))
8349 strcpy(dummy, "¡Õ ");
8351 strcpy(dummy, "> ");
8353 else strcpy(dummy, " ");
8356 /* letter/number for power selection */
8359 sprintf(dummy, "%c) ",I2A(ctr));
8362 strcat(dummy, es_ptr->add_name);
8367 if (es_ptr->essence != -1)
8369 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8370 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8376 case ESSENCE_SH_FIRE:
8378 strcat(dummy, "(¾Æ´þ+ÂѲбê)");
8380 strcat(dummy, "(brand fire + res.fire)");
8382 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8383 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8385 case ESSENCE_SH_ELEC:
8387 strcat(dummy, "(ÅÅ·â+ÂÑÅÅ·â)");
8389 strcat(dummy, "(brand elec. + res. elec.)");
8391 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8392 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8394 case ESSENCE_SH_COLD:
8396 strcat(dummy, "(Åà·ë+ÂÑÎ䵤)");
8398 strcat(dummy, "(brand cold + res. cold)");
8400 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8401 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8403 case ESSENCE_RESISTANCE:
8405 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
8407 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
8409 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8410 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8411 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8412 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8414 case ESSENCE_SUSTAIN:
8416 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
8418 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
8420 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8421 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8422 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8423 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8428 if (!able[ctr]) col = TERM_RED;
8430 if (es_ptr->essence != -1)
8432 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8436 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8439 c_prt(col, dummy2, ctr+2, x);
8449 /* Restore the screen */
8460 ask = (isupper(choice));
8463 if (ask) choice = tolower(choice);
8465 /* Extract request */
8466 i = (islower(choice) ? A2I(choice) : -1);
8469 /* Totally Illegal */
8470 if ((i < 0) || (i >= max_num) || !able[i])
8483 (void) strnfmt(tmp_val, 78, "%s¤òÉղä·¤Þ¤¹¤«¡© ", essence_info[num[i]].add_name);
8485 (void) strnfmt(tmp_val, 78, "Add the abilitiy of %s? ", essence_info[num[i]].add_name);
8488 /* Belay that order */
8489 if (!get_check(tmp_val)) continue;
8496 /* Restore the screen */
8497 if (redraw) screen_load();
8504 #endif /* ALLOW_REPEAT */
8506 es_ptr = &essence_info[num[i]];
8508 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8509 item_tester_tval = TV_GLOVES;
8510 else if (mode == 1 || mode == 5)
8511 item_tester_hook = item_tester_hook_melee_ammo;
8512 else if (es_ptr->add == ESSENCE_ATTACK)
8513 item_tester_hook = object_allow_enchant_weapon;
8514 else if (es_ptr->add == ESSENCE_AC)
8515 item_tester_hook = object_is_armour;
8517 item_tester_hook = object_is_weapon_armour_ammo;
8518 item_tester_no_ryoute = TRUE;
8522 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
8523 s = "²þÎɤǤ¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
8525 q = "Improve which item? ";
8526 s = "You have nothing to improve.";
8529 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8531 /* Get the item (in the pack) */
8534 o_ptr = &inventory[item];
8537 /* Get the item (on the floor) */
8540 o_ptr = &o_list[0 - item];
8543 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8546 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï¤³¤ì°Ê¾å²þÎɤǤ¤Ê¤¤¡£");
8548 msg_print("This item is no more able to be improved.");
8553 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8555 use_essence = es_ptr->value;
8556 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8557 if (o_ptr->number > 1)
8559 use_essence *= o_ptr->number;
8561 msg_format("%d¸Ä¤¢¤ë¤Î¤Ç¥¨¥Ã¥»¥ó¥¹¤Ï%dɬÍפǤ¹¡£", o_ptr->number, use_essence);
8563 msg_format("It will take %d essences.",use_essence);
8568 if (es_ptr->essence != -1)
8570 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8573 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
8575 msg_print("You don't have enough essences.");
8579 if (is_pval_flag(es_ptr->add))
8581 if (o_ptr->pval < 0)
8584 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤ÎǽÎϽ¤Àµ¤ò¶¯²½¤¹¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£");
8586 msg_print("You cannot increase magic number of this item.");
8590 else if (es_ptr->add == TR_BLOWS)
8592 if (o_ptr->pval > 1)
8595 if (!get_check("½¤ÀµÃͤÏ1¤Ë¤Ê¤ê¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) return;
8597 if (!get_check("The magic number of this weapon will become 1. Are you sure? ")) return;
8603 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
8605 msg_format("It will take %d essences.", use_essence);
8608 else if (o_ptr->pval > 0)
8610 use_essence *= o_ptr->pval;
8612 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
8614 msg_format("It will take %d essences.", use_essence);
8622 int limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8625 sprintf(tmp, "¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d): ", limit);
8627 sprintf(tmp, "Enchant how many? (1-%d): ", limit);
8629 strcpy(tmp_val, "1");
8631 if (!get_string(tmp, tmp_val, 1)) return;
8632 pval = atoi(tmp_val);
8633 if (pval > limit) pval = limit;
8634 else if (pval < 1) pval = 1;
8635 o_ptr->pval += pval;
8636 use_essence *= pval;
8638 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
8640 msg_format("It will take %d essences.", use_essence);
8644 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8647 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
8649 msg_print("You don't have enough essences.");
8654 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8658 int get_to_h, get_to_d;
8660 strcpy(tmp_val, "1");
8662 if (!get_string(format("¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
8664 if (!get_string(format("Enchant how many? (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
8666 val = atoi(tmp_val);
8667 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8668 else if (val < 1) val = 1;
8671 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
8673 msg_format("It will take %d essences.", use_essence);
8675 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8678 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
8680 msg_print("You don't have enough essences.");
8684 get_to_h = ((val+1)/2+randint0(val/2+1));
8685 get_to_d = ((val+1)/2+randint0(val/2+1));
8686 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8687 o_ptr->to_h += get_to_h;
8688 o_ptr->to_d += get_to_d;
8690 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8691 if (es_ptr->add == ESSENCE_ATTACK)
8693 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8696 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
8698 msg_print("You failed to enchant.");
8705 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8706 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8709 else if (es_ptr->add == ESSENCE_AC)
8711 if (o_ptr->to_a >= p_ptr->lev/5+5)
8714 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
8716 msg_print("You failed to enchant.");
8723 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8728 o_ptr->xtra3 = es_ptr->add + 1;
8733 bool success = TRUE;
8737 case ESSENCE_SH_FIRE:
8738 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8743 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8744 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8746 case ESSENCE_SH_ELEC:
8747 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8752 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8753 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8755 case ESSENCE_SH_COLD:
8756 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8761 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8762 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8764 case ESSENCE_RESISTANCE:
8765 case ESSENCE_SUSTAIN:
8766 if ((p_ptr->magic_num1[TR_RES_ACID] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8771 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8772 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8773 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8774 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8780 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
8782 msg_print("You don't have enough essences.");
8786 if (es_ptr->add == ESSENCE_SUSTAIN)
8788 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8789 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8790 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8791 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8795 o_ptr->xtra3 = es_ptr->add + 1;
8802 msg_format("%s¤Ë%s¤ÎǽÎϤòÉղä·¤Þ¤·¤¿¡£", o_name, es_ptr->add_name);
8804 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8807 /* Combine the pack */
8808 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8811 p_ptr->window |= (PW_INVEN);
8815 static void erase_essence(void)
8820 char o_name[MAX_NLEN];
8821 u32b flgs[TR_FLAG_SIZE];
8823 item_tester_hook = object_is_smith;
8827 q = "¤É¤Î¥¢¥¤¥Æ¥à¤Î¥¨¥Ã¥»¥ó¥¹¤ò¾Ãµî¤·¤Þ¤¹¤«¡©";
8828 s = "¥¨¥Ã¥»¥ó¥¹¤òÉղä·¤¿¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
8830 q = "Remove from which item? ";
8831 s = "You have nothing to remove essence.";
8834 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8836 /* Get the item (in the pack) */
8839 o_ptr = &inventory[item];
8842 /* Get the item (on the floor) */
8845 o_ptr = &o_list[0 - item];
8848 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8850 if (!get_check(format("¤è¤í¤·¤¤¤Ç¤¹¤«¡© [%s]", o_name))) return;
8852 if (!get_check(format("Are you sure? [%s]", o_name))) return;
8857 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8859 o_ptr->to_h -= (o_ptr->xtra4>>8);
8860 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8862 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8863 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8866 object_flags(o_ptr, flgs);
8867 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8869 msg_print("¥¨¥Ã¥»¥ó¥¹¤ò¼è¤êµî¤Ã¤¿¡£");
8871 msg_print("You removed all essence you have added.");
8874 /* Combine the pack */
8875 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8878 p_ptr->window |= (PW_INVEN);
8881 void do_cmd_kaji(bool only_browse)
8886 int menu_line = (use_menu ? 1 : 0);
8890 if (p_ptr->confused)
8893 msg_print("º®Í𤷤Ƥ¤¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
8895 msg_print("You are too confused!");
8903 msg_print("Ìܤ¬¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
8905 msg_print("You are blind!");
8913 msg_print("¤¦¤Þ¤¯¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
8915 msg_print("You are hallucinating!");
8923 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8925 #endif /* ALLOW_REPEAT */
8927 if (only_browse) screen_save();
8929 if (!only_browse) screen_save();
8935 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", (menu_line == 1) ? "¡Õ" : " "), 2, 14);
8936 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", (menu_line == 2) ? "¡Õ" : " "), 3, 14);
8937 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹¾Ãµî", (menu_line == 3) ? "¡Õ" : " "), 4, 14);
8938 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", (menu_line == 4) ? "¡Õ" : " "), 5, 14);
8939 prt(format(" %s Éð´ï/Ëɶñ¶¯²½", (menu_line == 5) ? "¡Õ" : " "), 6, 14);
8940 prt(format("¤É¤Î¼ïÎà¤Îµ»½Ñ¤ò%s¤Þ¤¹¤«¡©", only_browse ? "Ä´¤Ù" : "»È¤¤"), 0, 0);
8942 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8943 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8944 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8945 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8946 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8947 prt(format("Choose command from menu."), 0, 0);
8974 if (menu_line > 5) menu_line -= 5;
8983 prt(" a) ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", 2, 14);
8984 prt(" b) ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", 3, 14);
8985 prt(" c) ¥¨¥Ã¥»¥ó¥¹¾Ãµî", 4, 14);
8986 prt(" d) ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", 5, 14);
8987 prt(" e) Éð´ï/Ëɶñ¶¯²½", 6, 14);
8988 if (!get_com(format("¤É¤ÎǽÎϤò%s¤Þ¤¹¤«:", only_browse ? "Ä´¤Ù" : "»È¤¤"), &choice, TRUE))
8990 prt(" a) List essences", 2, 14);
8991 prt(" b) Extract essence", 3, 14);
8992 prt(" c) Remove essence", 4, 14);
8993 prt(" d) Add essence", 5, 14);
8994 prt(" e) Enchant weapon/armor", 6, 14);
8995 if (!get_com("Command :", &choice, TRUE))
9032 /* Clear lines, position cursor (really should use strlen here) */
9033 Term_erase(14, 21, 255);
9034 Term_erase(14, 20, 255);
9035 Term_erase(14, 19, 255);
9036 Term_erase(14, 18, 255);
9037 Term_erase(14, 17, 255);
9038 Term_erase(14, 16, 255);
9040 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
9041 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
9043 prt(&temp[j], line, 15);
9048 if (!only_browse) screen_load();
9049 } while (only_browse);
9053 #endif /* ALLOW_REPEAT */
9057 case 1: display_essence();break;
9058 case 2: drain_essence();break;
9059 case 3: erase_essence();break;
9061 mode = choose_essence();
9066 case 5: add_essence(10);break;
9072 * Torches have special abilities when they are flaming.
9074 void torch_flags(object_type *o_ptr, u32b *flgs)
9076 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
9078 if (o_ptr->xtra4 > 0)
9080 add_flag(flgs, TR_BRAND_FIRE);
9081 add_flag(flgs, TR_KILL_UNDEAD);
9082 add_flag(flgs, TR_THROW);
9087 void torch_dice(object_type *o_ptr, int *dd, int *ds)
9089 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
9091 if (o_ptr->xtra4 > 0)
9099 void torch_lost_fuel(object_type *o_ptr)
9101 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
9103 o_ptr->xtra4 -= (FUEL_TORCH / 25);
9104 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;