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 * 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.
454 void wipe_o_list(void)
458 /* Delete the existing objects */
459 for (i = 1; i < o_max; i++)
461 object_type *o_ptr = &o_list[i];
463 /* Skip dead objects */
464 if (!o_ptr->k_idx) continue;
466 /* Mega-Hack -- preserve artifacts */
467 if (!character_dungeon || preserve_mode)
469 /* Hack -- Preserve unknown artifacts */
470 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
472 /* Mega-Hack -- Preserve the artifact */
473 a_info[o_ptr->name1].cur_num = 0;
478 if (o_ptr->held_m_idx)
483 m_ptr = &m_list[o_ptr->held_m_idx];
485 /* Hack -- see above */
486 m_ptr->hold_o_idx = 0;
494 /* Access location */
501 /* Hack -- see above */
505 /* Wipe the object */
518 * Acquires and returns the index of a "free" object.
520 * This routine should almost never fail, but in case it does,
521 * we must be sure to handle "failure" of this routine.
528 /* Initial allocation */
529 if (o_max < max_o_idx)
534 /* Expand object array */
540 /* Use this object */
545 /* Recycle dead objects */
546 for (i = 1; i < o_max; i++)
553 /* Skip live objects */
554 if (o_ptr->k_idx) continue;
559 /* Use this object */
564 /* Warn the player (except during dungeon creation) */
566 if (character_dungeon) msg_print("¥¢¥¤¥Æ¥à¤¬Â¿¤¹¤®¤ë¡ª");
568 if (character_dungeon) msg_print("Too many objects!");
578 * Apply a "object restriction function" to the "object allocation table"
580 static errr get_obj_num_prep(void)
585 alloc_entry *table = alloc_kind_table;
587 /* Scan the allocation table */
588 for (i = 0; i < alloc_kind_size; i++)
590 /* Accept objects which pass the restriction, if any */
591 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
593 /* Accept this object */
594 table[i].prob2 = table[i].prob1;
597 /* Do not use this object */
600 /* Decline this object */
611 * Choose an object kind that seems "appropriate" to the given level
613 * This function uses the "prob2" field of the "object allocation table",
614 * and various local information, to calculate the "prob3" field of the
615 * same table, which is then used to choose an "appropriate" object, in
616 * a relatively efficient manner.
618 * It is (slightly) more likely to acquire an object of the given level
619 * than one of a lower level. This is done by choosing several objects
620 * appropriate to the given level and keeping the "hardest" one.
622 * Note that if no objects are "appropriate", then this function will
623 * fail, and return zero, but this should *almost* never happen.
625 s16b get_obj_num(int level)
631 alloc_entry *table = alloc_kind_table;
633 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
636 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
638 /* Occasional "boost" */
639 if (one_in_(GREAT_OBJ))
641 /* What a bizarre calculation */
642 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
649 /* Process probabilities */
650 for (i = 0; i < alloc_kind_size; i++)
652 /* Objects are sorted by depth */
653 if (table[i].level > level) break;
658 /* Access the index */
659 k_idx = table[i].index;
661 /* Access the actual kind */
662 k_ptr = &k_info[k_idx];
664 /* Hack -- prevent embedded chests */
665 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
668 table[i].prob3 = table[i].prob2;
671 total += table[i].prob3;
674 /* No legal objects */
675 if (total <= 0) return (0);
679 value = randint0(total);
681 /* Find the object */
682 for (i = 0; i < alloc_kind_size; i++)
684 /* Found the entry */
685 if (value < table[i].prob3) break;
688 value = value - table[i].prob3;
695 /* Try for a "better" object once (50%) or twice (10%) */
702 value = randint0(total);
704 /* Find the object */
705 for (i = 0; i < alloc_kind_size; i++)
707 /* Found the entry */
708 if (value < table[i].prob3) break;
711 value = value - table[i].prob3;
714 /* Keep the "best" one */
715 if (table[i].level < table[j].level) i = j;
718 /* Try for a "better" object twice (10%) */
725 value = randint0(total);
727 /* Find the object */
728 for (i = 0; i < alloc_kind_size; i++)
730 /* Found the entry */
731 if (value < table[i].prob3) break;
734 value = value - table[i].prob3;
737 /* Keep the "best" one */
738 if (table[i].level < table[j].level) i = j;
743 return (table[i].index);
748 * Known is true when the "attributes" of an object are "known".
749 * These include tohit, todam, toac, cost, and pval (charges).
751 * Note that "knowing" an object gives you everything that an "awareness"
752 * gives you, and much more. In fact, the player is always "aware" of any
753 * item of which he has full "knowledge".
755 * But having full knowledge of, say, one "wand of wonder", does not, by
756 * itself, give you knowledge, or even awareness, of other "wands of wonder".
757 * It happens that most "identify" routines (including "buying from a shop")
758 * will make the player "aware" of the object as well as fully "know" it.
760 * This routine also removes any inscriptions generated by "feelings".
762 void object_known(object_type *o_ptr)
764 /* Remove "default inscriptions" */
765 o_ptr->feeling = FEEL_NONE;
767 /* Clear the "Felt" info */
768 o_ptr->ident &= ~(IDENT_SENSE);
770 /* Clear the "Empty" info */
771 o_ptr->ident &= ~(IDENT_EMPTY);
773 /* Now we know about the item */
774 o_ptr->ident |= (IDENT_KNOWN);
779 * The player is now aware of the effects of the given object.
781 void object_aware(object_type *o_ptr)
783 bool mihanmei = !object_is_aware(o_ptr);
785 /* Fully aware of the effects */
786 k_info[o_ptr->k_idx].aware = TRUE;
788 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
789 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
793 char o_name[MAX_NLEN];
796 object_copy(q_ptr, o_ptr);
799 object_desc(o_name, q_ptr, OD_NAME_ONLY);
801 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
807 * Something has been "sampled"
809 void object_tried(object_type *o_ptr)
811 /* Mark it as tried (even if "aware") */
812 k_info[o_ptr->k_idx].tried = TRUE;
817 * Return the "value" of an "unknown" item
818 * Make a guess at the value of non-aware items
820 static s32b object_value_base(object_type *o_ptr)
822 /* Aware item -- use template cost */
823 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
825 /* Analyze the type */
830 case TV_FOOD: return (5L);
832 /* Un-aware Potions */
833 case TV_POTION: return (20L);
835 /* Un-aware Scrolls */
836 case TV_SCROLL: return (20L);
838 /* Un-aware Staffs */
839 case TV_STAFF: return (70L);
842 case TV_WAND: return (50L);
845 case TV_ROD: return (90L);
848 case TV_RING: return (45L);
850 /* Un-aware Amulets */
851 case TV_AMULET: return (45L);
853 /* Figurines, relative to monster level */
856 int level = r_info[o_ptr->pval].level;
857 if (level < 20) return level*50L;
858 else if (level < 30) return 1000+(level-20)*150L;
859 else if (level < 40) return 2500+(level-30)*350L;
860 else if (level < 50) return 6000+(level-40)*800L;
861 else return 14000+(level-50)*2000L;
865 if (!o_ptr->pval) return 1000L;
866 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
869 /* Paranoia -- Oops */
874 /* Return the value of the flags the object has... */
875 s32b flag_cost(object_type *o_ptr, int plusses)
878 u32b flgs[TR_FLAG_SIZE];
882 object_kind *k_ptr = &k_info[o_ptr->k_idx];
884 object_flags(o_ptr, flgs);
887 * Exclude fixed flags of the base item.
888 * pval bonuses of base item will be treated later.
890 for (i = 0; i < TR_FLAG_SIZE; i++)
891 flgs[i] &= ~(k_ptr->flags[i]);
893 /* Exclude fixed flags of the fixed artifact. */
894 if (object_is_fixed_artifact(o_ptr))
896 artifact_type *a_ptr = &a_info[o_ptr->name1];
898 for (i = 0; i < TR_FLAG_SIZE; i++)
899 flgs[i] &= ~(a_ptr->flags[i]);
902 /* Exclude fixed flags of the ego-item. */
903 else if (object_is_ego(o_ptr))
905 ego_item_type *e_ptr = &e_info[o_ptr->name2];
907 for (i = 0; i < TR_FLAG_SIZE; i++)
908 flgs[i] &= ~(e_ptr->flags[i]);
913 * Calucurate values of remaining flags
915 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
916 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
917 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
918 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
919 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
920 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
921 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
922 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
923 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
924 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
925 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
926 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
927 total += (10000 + (2500 * plusses));
928 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
929 total += (10000 + (2500 * plusses));
933 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
934 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
935 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
936 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
937 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
938 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
939 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
940 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
941 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
942 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
943 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
944 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
945 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
946 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
947 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
948 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
949 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
950 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
951 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
952 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
953 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
955 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
956 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
957 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
958 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
959 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
960 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
961 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
962 total += (tmp_cost * count);
964 if (have_flag(flgs, TR_SUST_STR)) total += 850;
965 if (have_flag(flgs, TR_SUST_INT)) total += 850;
966 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
967 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
968 if (have_flag(flgs, TR_SUST_CON)) total += 850;
969 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
970 if (have_flag(flgs, TR_RIDING)) total += 0;
971 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
972 if (have_flag(flgs, TR_THROW)) total += 5000;
973 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
974 if (have_flag(flgs, TR_HOLD_LIFE)) total += 8500;
978 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
979 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
980 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
981 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
982 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
983 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
984 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
985 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
986 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
987 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
988 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
989 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
990 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
991 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
992 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
993 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
994 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
995 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
996 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
997 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
998 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
999 total += (tmp_cost * count);
1001 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1002 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1003 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1004 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1005 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1006 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1007 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1008 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1009 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1010 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1011 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1012 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1013 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1014 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1015 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1016 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1017 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1018 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1019 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1020 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1021 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1022 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1023 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1024 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1025 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1026 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1027 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1028 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1029 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1030 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1031 if (have_flag(flgs, TR_REGEN)) total += 2500;
1032 if (have_flag(flgs, TR_WARNING)) total += 2000;
1033 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1034 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1035 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1036 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1037 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1038 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1039 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1040 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1041 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1042 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1043 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1044 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1045 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1046 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1047 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1048 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1049 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1050 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1051 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1052 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1053 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1054 if (have_flag(flgs, TR_TELEPORT))
1056 if (object_is_cursed(o_ptr))
1061 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1062 if (have_flag(flgs, TR_BLESSED)) total += 750;
1063 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1064 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1065 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1066 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1067 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1069 /* Also, give some extra for activatable powers... */
1070 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1072 const activation_type* const act_ptr = find_activation_info(o_ptr);
1074 total += act_ptr->value;
1083 * Return the "real" price of a "known" item, not including discounts
1085 * Wand and staffs get cost for each charge
1087 * Armor is worth an extra 100 gold per bonus point to armor class.
1089 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).
1091 * Missiles are only worth 5 gold per bonus point, since they
1092 * usually appear in groups of 20, and we want the player to get
1093 * the same amount of cash for any "equivalent" item. Note that
1094 * missiles never have any of the "pval" flags, and in fact, they
1095 * only have a few of the available flags, primarily of the "slay"
1096 * and "brand" and "ignore" variety.
1098 * Armor with a negative armor bonus is worthless.
1099 * Weapons with negative hit+damage bonuses are worthless.
1101 * Every wearable item with a "pval" bonus is worth extra (see below).
1103 s32b object_value_real(object_type *o_ptr)
1107 u32b flgs[TR_FLAG_SIZE];
1109 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1112 /* Hack -- "worthless" items */
1113 if (!k_info[o_ptr->k_idx].cost) return (0L);
1116 value = k_info[o_ptr->k_idx].cost;
1118 /* Extract some flags */
1119 object_flags(o_ptr, flgs);
1122 if (object_is_fixed_artifact(o_ptr))
1124 artifact_type *a_ptr = &a_info[o_ptr->name1];
1126 /* Hack -- "worthless" artifacts */
1127 if (!a_ptr->cost) return (0L);
1129 /* Hack -- Use the artifact cost instead */
1130 value = a_ptr->cost;
1131 value += flag_cost(o_ptr, o_ptr->pval);
1133 /* Don't add pval bonuses etc. */
1138 else if (object_is_ego(o_ptr))
1140 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1142 /* Hack -- "worthless" ego-items */
1143 if (!e_ptr->cost) return (0L);
1145 /* Hack -- Reward the ego-item with a bonus */
1146 value += e_ptr->cost;
1147 value += flag_cost(o_ptr, o_ptr->pval);
1155 for (i = 0; i < TR_FLAG_SIZE; i++)
1156 if (o_ptr->art_flags[i]) flag = TRUE;
1158 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1161 /* Analyze pval bonus for normal object */
1162 switch (o_ptr->tval)
1185 if (!o_ptr->pval) break;
1187 /* Hack -- Negative "pval" is always bad */
1188 if (o_ptr->pval < 0) return (0L);
1190 /* Give credit for stat bonuses */
1191 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1192 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1193 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1194 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1195 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1196 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1198 /* Give credit for stealth and searching */
1199 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1200 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1201 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1203 /* Give credit for infra-vision and tunneling */
1204 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1205 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1207 /* Give credit for extra attacks */
1208 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1210 /* Give credit for speed bonus */
1211 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1217 /* Analyze the item */
1218 switch (o_ptr->tval)
1223 /* Pay extra for charges, depending on standard number of
1224 * charges. Handle new-style wands correctly. -LM-
1226 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1233 /* Pay extra for charges, depending on standard number of
1236 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1246 /* Hack -- negative bonuses are bad */
1247 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1249 /* Give credit for bonuses */
1250 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1267 /* Hack -- negative armor bonus */
1268 if (o_ptr->to_a < 0) return (0L);
1270 /* Give credit for bonuses */
1271 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1284 /* Hack -- negative hit/damage bonuses */
1285 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1287 /* Factor in the bonuses */
1288 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1290 /* Hack -- Factor in extra damage dice and sides */
1291 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1292 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1303 /* Hack -- negative hit/damage bonuses */
1304 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1306 /* Factor in the bonuses */
1307 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1309 /* Hack -- Factor in extra damage dice and sides */
1310 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1311 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1317 /* Figurines, relative to monster level */
1320 int level = r_info[o_ptr->pval].level;
1321 if (level < 20) value = level*50L;
1322 else if (level < 30) value = 1000+(level-20)*150L;
1323 else if (level < 40) value = 2500+(level-30)*350L;
1324 else if (level < 50) value = 6000+(level-40)*800L;
1325 else value = 14000+(level-50)*2000L;
1331 if (!o_ptr->pval) value = 1000L;
1332 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1338 if (!o_ptr->pval) value = 0L;
1343 /* Worthless object */
1344 if (value < 0) return 0L;
1346 /* Return the value */
1352 * Return the price of an item including plusses (and charges)
1354 * This function returns the "value" of the given item (qty one)
1356 * Never notice "unknown" bonuses or properties, including "curses",
1357 * since that would give the player information he did not have.
1359 * Note that discounted items stay discounted forever, even if
1360 * the discount is "forgotten" by the player via memory loss.
1362 s32b object_value(object_type *o_ptr)
1367 /* Unknown items -- acquire a base value */
1368 if (object_is_known(o_ptr))
1370 /* Broken items -- worthless */
1371 if (object_is_broken(o_ptr)) return (0L);
1373 /* Cursed items -- worthless */
1374 if (object_is_cursed(o_ptr)) return (0L);
1376 /* Real value (see above) */
1377 value = object_value_real(o_ptr);
1380 /* Known items -- acquire the actual value */
1383 /* Hack -- Felt broken items */
1384 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1386 /* Hack -- Felt cursed items */
1387 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1389 /* Base value (see above) */
1390 value = object_value_base(o_ptr);
1394 /* Apply discount (if any) */
1395 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1398 /* Return the final value */
1404 * Determines whether an object can be destroyed, and makes fake inscription.
1406 bool can_player_destroy_object(object_type *o_ptr)
1408 /* Artifacts cannot be destroyed */
1409 if (!object_is_artifact(o_ptr)) return TRUE;
1411 /* If object is unidentified, makes fake inscription */
1412 if (!object_is_known(o_ptr))
1414 byte feel = FEEL_SPECIAL;
1416 /* Hack -- Handle icky artifacts */
1417 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1419 /* Hack -- inscribe the artifact */
1420 o_ptr->feeling = feel;
1422 /* We have "felt" it (again) */
1423 o_ptr->ident |= (IDENT_SENSE);
1425 /* Combine the pack */
1426 p_ptr->notice |= (PN_COMBINE);
1429 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1435 /* Identified artifact -- Nothing to do */
1441 * Distribute charges of rods or wands.
1443 * o_ptr = source item
1444 * q_ptr = target item, must be of the same type as o_ptr
1445 * amt = number of items that are transfered
1447 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1450 * Hack -- If rods or wands are dropped, the total maximum timeout or
1451 * charges need to be allocated between the two stacks. If all the items
1452 * are being dropped, it makes for a neater message to leave the original
1453 * stack's pval alone. -LM-
1455 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1457 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1458 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1460 /* Hack -- Rods also need to have their timeouts distributed. The
1461 * dropped stack will accept all time remaining to charge up to its
1464 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1466 if (q_ptr->pval > o_ptr->timeout)
1467 q_ptr->timeout = o_ptr->timeout;
1469 q_ptr->timeout = q_ptr->pval;
1471 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1476 void reduce_charges(object_type *o_ptr, int amt)
1479 * Hack -- If rods or wand are destroyed, the total maximum timeout or
1480 * charges of the stack needs to be reduced, unless all the items are
1481 * being destroyed. -LM-
1483 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1484 (amt < o_ptr->number))
1486 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1492 * Determine if an item can "absorb" a second item
1494 * See "object_absorb()" for the actual "absorption" code.
1496 * If permitted, we allow staffs (if they are known to have equal charges
1497 * and both are either known or confirmed empty) and wands (if both are
1498 * either known or confirmed empty) and rods (in all cases) to combine.
1499 * Staffs will unstack (if necessary) when they are used, but wands and
1500 * rods will only unstack if one is dropped. -LM-
1502 * If permitted, we allow weapons/armor to stack, if fully "known".
1504 * Missiles will combine if both stacks have the same "known" status.
1505 * This is done to make unidentified stacks of missiles useful.
1507 * Food, potions, scrolls, and "easy know" items always stack.
1509 * Chests, and activatable items, never stack (for various reasons).
1513 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1515 #define MAX_STACK_SIZE 99
1519 * Determine if an item can partly absorb a second item.
1520 * Return maximum number of stack.
1522 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1526 /* Default maximum number of stack */
1527 int max_num = MAX_STACK_SIZE;
1529 /* Require identical object types */
1530 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1533 /* Analyze the items */
1534 switch (o_ptr->tval)
1536 /* Chests and Statues*/
1547 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1548 if (o_ptr->pval != j_ptr->pval) return 0;
1552 /* Figurines and Corpses*/
1557 if (o_ptr->pval != j_ptr->pval) return 0;
1563 /* Food and Potions and Scrolls */
1575 /* Require either knowledge or known empty for both staffs. */
1576 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1577 !object_is_known(o_ptr)) ||
1578 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1579 !object_is_known(j_ptr))) return 0;
1581 /* Require identical charges, since staffs are bulky. */
1582 if (o_ptr->pval != j_ptr->pval) return 0;
1591 /* Require either knowledge or known empty for both wands. */
1592 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1593 !object_is_known(o_ptr)) ||
1594 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1595 !object_is_known(j_ptr))) return 0;
1597 /* Wand charges combine in O&ZAngband. */
1603 /* Staffs and Wands and Rods */
1606 /* Prevent overflaw of timeout */
1607 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1613 /* Weapons and Armor */
1629 /* Rings, Amulets, Lites */
1635 /* Require full knowledge of both items */
1636 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1646 /* Require identical knowledge of both items */
1647 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1648 if (o_ptr->feeling != j_ptr->feeling) return 0;
1650 /* Require identical "bonuses" */
1651 if (o_ptr->to_h != j_ptr->to_h) return 0;
1652 if (o_ptr->to_d != j_ptr->to_d) return 0;
1653 if (o_ptr->to_a != j_ptr->to_a) return 0;
1655 /* Require identical "pval" code */
1656 if (o_ptr->pval != j_ptr->pval) return 0;
1658 /* Artifacts never stack */
1659 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1661 /* Require identical "ego-item" names */
1662 if (o_ptr->name2 != j_ptr->name2) return 0;
1664 /* Require identical added essence */
1665 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1666 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1668 /* Hack -- Never stack "powerful" items */
1669 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1671 /* Hack -- Never stack recharging items */
1672 if (o_ptr->timeout || j_ptr->timeout) return 0;
1674 /* Require identical "values" */
1675 if (o_ptr->ac != j_ptr->ac) return 0;
1676 if (o_ptr->dd != j_ptr->dd) return 0;
1677 if (o_ptr->ds != j_ptr->ds) return 0;
1686 /* Require knowledge */
1687 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1695 /* Hack -- Identical art_flags! */
1696 for (i = 0; i < TR_FLAG_SIZE; i++)
1697 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1699 /* Hack -- Require identical "cursed" status */
1700 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1702 /* Hack -- Require identical "broken" status */
1703 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1706 /* Hack -- require semi-matching "inscriptions" */
1707 if (o_ptr->inscription && j_ptr->inscription &&
1708 (o_ptr->inscription != j_ptr->inscription))
1711 /* Hack -- normally require matching "inscriptions" */
1712 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1714 /* Hack -- normally require matching "discounts" */
1715 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1718 /* They match, so they must be similar */
1723 * Determine if an item can absorb a second item.
1725 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1727 int total = o_ptr->number + j_ptr->number;
1730 /* Are these objects similar? */
1731 max_num = object_similar_part(o_ptr, j_ptr);
1733 /* Return if not similar */
1734 if (!max_num) return FALSE;
1736 /* Maximal "stacking" limit */
1737 if (total > max_num) return (0);
1740 /* They match, so they must be similar */
1747 * Allow one item to "absorb" another, assuming they are similar
1749 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1751 int max_num = object_similar_part(o_ptr, j_ptr);
1752 int total = o_ptr->number + j_ptr->number;
1753 int diff = (total > max_num) ? total - max_num : 0;
1755 /* Combine quantity, lose excess items */
1756 o_ptr->number = (total > max_num) ? max_num : total;
1758 /* Hack -- blend "known" status */
1759 if (object_is_known(j_ptr)) object_known(o_ptr);
1761 /* Hack -- clear "storebought" if only one has it */
1762 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1763 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1765 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1766 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1769 /* Hack -- blend "mental" status */
1770 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1772 /* Hack -- blend "inscriptions" */
1773 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1775 /* Hack -- blend "feelings" */
1776 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1778 /* Hack -- could average discounts XXX XXX XXX */
1779 /* Hack -- save largest discount XXX XXX XXX */
1780 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1782 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1783 if (o_ptr->tval == TV_ROD)
1785 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1786 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1789 /* Hack -- if wands are stacking, combine the charges. -LM- */
1790 if (o_ptr->tval == TV_WAND)
1792 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1798 * Find the index of the object_kind with the given tval and sval
1800 s16b lookup_kind(int tval, int sval)
1807 for (k = 1; k < max_k_idx; k++)
1809 object_kind *k_ptr = &k_info[k];
1811 /* Require correct tval */
1812 if (k_ptr->tval != tval) continue;
1815 if (k_ptr->sval == sval) return (k);
1817 /* Ignore illegal items */
1818 if (sval != SV_ANY) continue;
1820 /* Apply the randomizer */
1821 if (!one_in_(++num)) continue;
1823 /* Use this value */
1827 /* Return this choice */
1836 msg_format("¥¢¥¤¥Æ¥à¤¬¤Ê¤¤ (%d,%d)", tval, sval);
1838 msg_format("No object (%d,%d)", tval, sval);
1849 * Wipe an object clean.
1851 void object_wipe(object_type *o_ptr)
1853 /* Wipe the structure */
1854 (void)WIPE(o_ptr, object_type);
1859 * Prepare an object based on an existing object
1861 void object_copy(object_type *o_ptr, object_type *j_ptr)
1863 /* Copy the structure */
1864 (void)COPY(o_ptr, j_ptr, object_type);
1869 * Prepare an object based on an object kind.
1871 void object_prep(object_type *o_ptr, int k_idx)
1873 object_kind *k_ptr = &k_info[k_idx];
1875 /* Clear the record */
1878 /* Save the kind index */
1879 o_ptr->k_idx = k_idx;
1881 /* Efficiency -- tval/sval */
1882 o_ptr->tval = k_ptr->tval;
1883 o_ptr->sval = k_ptr->sval;
1885 /* Default "pval" */
1886 o_ptr->pval = k_ptr->pval;
1888 /* Default number */
1891 /* Default weight */
1892 o_ptr->weight = k_ptr->weight;
1895 o_ptr->to_h = k_ptr->to_h;
1896 o_ptr->to_d = k_ptr->to_d;
1897 o_ptr->to_a = k_ptr->to_a;
1900 o_ptr->ac = k_ptr->ac;
1901 o_ptr->dd = k_ptr->dd;
1902 o_ptr->ds = k_ptr->ds;
1904 /* Default activation */
1905 if (k_ptr->act_idx > 0) o_ptr->xtra2 = k_ptr->act_idx;
1907 /* Hack -- worthless items are always "broken" */
1908 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
1910 /* Hack -- cursed items are always "cursed" */
1911 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
1912 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
1913 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
1914 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
1915 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
1916 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
1921 * Help determine an "enchantment bonus" for an object.
1923 * To avoid floating point but still provide a smooth distribution of bonuses,
1924 * we simply round the results of division in such a way as to "average" the
1925 * correct floating point value.
1927 * This function has been changed. It uses "randnor()" to choose values from
1928 * a normal distribution, whose mean moves from zero towards the max as the
1929 * level increases, and whose standard deviation is equal to 1/4 of the max,
1930 * and whose values are forced to lie between zero and the max, inclusive.
1932 * Since the "level" rarely passes 100 before Morgoth is dead, it is very
1933 * rare to get the "full" enchantment on an object, even a deep levels.
1935 * It is always possible (albeit unlikely) to get the "full" enchantment.
1937 * A sample distribution of values from "m_bonus(10, N)" is shown below:
1939 * N 0 1 2 3 4 5 6 7 8 9 10
1940 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
1941 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03
1942 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05
1943 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05
1944 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11
1945 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41
1946 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65
1947 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94
1948 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78
1949 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64
1950 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62
1951 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33
1952 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38
1953 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53
1954 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53
1955 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27
1956 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72
1957 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07
1959 s16b m_bonus(int max, int level)
1961 int bonus, stand, extra, value;
1964 /* Paranoia -- enforce maximal "level" */
1965 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1968 /* The "bonus" moves towards the max */
1969 bonus = ((max * level) / MAX_DEPTH);
1971 /* Hack -- determine fraction of error */
1972 extra = ((max * level) % MAX_DEPTH);
1974 /* Hack -- simulate floating point computations */
1975 if (randint0(MAX_DEPTH) < extra) bonus++;
1978 /* The "stand" is equal to one quarter of the max */
1981 /* Hack -- determine fraction of error */
1984 /* Hack -- simulate floating point computations */
1985 if (randint0(4) < extra) stand++;
1988 /* Choose an "interesting" value */
1989 value = randnor(bonus, stand);
1991 /* Enforce the minimum value */
1992 if (value < 0) return (0);
1994 /* Enforce the maximum value */
1995 if (value > max) return (max);
2003 * Cheat -- describe a created object for the user
2005 static void object_mention(object_type *o_ptr)
2007 char o_name[MAX_NLEN];
2010 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
2013 if (object_is_fixed_artifact(o_ptr))
2017 msg_format("ÅÁÀâ¤Î¥¢¥¤¥Æ¥à (%s)", o_name);
2019 msg_format("Artifact (%s)", o_name);
2024 /* Random Artifact */
2025 else if (o_ptr->art_name)
2028 msg_print("¥é¥ó¥À¥à¡¦¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È");
2030 msg_print("Random artifact");
2036 else if (object_is_ego(o_ptr))
2040 msg_format("̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à (%s)", o_name);
2042 msg_format("Ego-item (%s)", o_name);
2052 msg_format("¥¢¥¤¥Æ¥à (%s)", o_name);
2054 msg_format("Object (%s)", o_name);
2062 * Mega-Hack -- Attempt to create one of the "Special Objects"
2064 * We are only called from "make_object()", and we assume that
2065 * "apply_magic()" is called immediately after we return.
2067 * Note -- see "make_artifact()" and "apply_magic()"
2069 static bool make_artifact_special(object_type *o_ptr)
2075 /* No artifacts in the town */
2076 if (!dun_level) return (FALSE);
2079 if (get_obj_num_hook) return (FALSE);
2081 /* Check the artifact list (just the "specials") */
2082 for (i = 0; i < max_a_idx; i++)
2084 artifact_type *a_ptr = &a_info[i];
2086 /* Skip "empty" artifacts */
2087 if (!a_ptr->name) continue;
2089 /* Cannot make an artifact twice */
2090 if (a_ptr->cur_num) continue;
2092 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2093 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2095 /* XXX XXX Enforce minimum "depth" (loosely) */
2096 if (a_ptr->level > dun_level)
2098 /* Acquire the "out-of-depth factor" */
2099 int d = (a_ptr->level - dun_level) * 2;
2101 /* Roll for out-of-depth creation */
2102 if (!one_in_(d)) continue;
2105 /* Artifact "rarity roll" */
2106 if (!one_in_(a_ptr->rarity)) continue;
2108 /* Find the base object */
2109 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2111 /* XXX XXX Enforce minimum "object" level (loosely) */
2112 if (k_info[k_idx].level > object_level)
2114 /* Acquire the "out-of-depth factor" */
2115 int d = (k_info[k_idx].level - object_level) * 5;
2117 /* Roll for out-of-depth creation */
2118 if (!one_in_(d)) continue;
2121 /* Assign the template */
2122 object_prep(o_ptr, k_idx);
2124 /* Mega-Hack -- mark the item as an artifact */
2127 /* Hack: Some artifacts get random extra powers */
2128 random_artifact_resistance(o_ptr, a_ptr);
2140 * Attempt to change an object into an artifact
2142 * This routine should only be called by "apply_magic()"
2144 * Note -- see "make_artifact_special()" and "apply_magic()"
2146 static bool make_artifact(object_type *o_ptr)
2151 /* No artifacts in the town */
2152 if (!dun_level) return (FALSE);
2154 /* Paranoia -- no "plural" artifacts */
2155 if (o_ptr->number != 1) return (FALSE);
2157 /* Check the artifact list (skip the "specials") */
2158 for (i = 0; i < max_a_idx; i++)
2160 artifact_type *a_ptr = &a_info[i];
2162 /* Skip "empty" items */
2163 if (!a_ptr->name) continue;
2165 /* Cannot make an artifact twice */
2166 if (a_ptr->cur_num) continue;
2168 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2170 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2172 /* Must have the correct fields */
2173 if (a_ptr->tval != o_ptr->tval) continue;
2174 if (a_ptr->sval != o_ptr->sval) continue;
2176 /* XXX XXX Enforce minimum "depth" (loosely) */
2177 if (a_ptr->level > dun_level)
2179 /* Acquire the "out-of-depth factor" */
2180 int d = (a_ptr->level - dun_level) * 2;
2182 /* Roll for out-of-depth creation */
2183 if (!one_in_(d)) continue;
2186 /* We must make the "rarity roll" */
2187 if (!one_in_(a_ptr->rarity)) continue;
2189 /* Hack -- mark the item as an artifact */
2192 /* Hack: Some artifacts get random extra powers */
2193 random_artifact_resistance(o_ptr, a_ptr);
2205 * Choose random ego type
2207 static byte get_random_ego(byte slot, bool good)
2210 ego_item_type *e_ptr;
2214 for (i = 1; i < max_e_idx; i++)
2218 if (e_ptr->slot == slot
2219 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2222 total += (255 / e_ptr->rarity);
2226 value = randint1(total);
2228 for (i = 1; i < max_e_idx; i++)
2232 if (e_ptr->slot == slot
2233 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2236 value -= (255 / e_ptr->rarity);
2237 if (value <= 0L) break;
2245 * Apply magic to an item known to be a "weapon"
2247 * Hack -- note special base damage dice boosting
2248 * Hack -- note special processing for weapon/digger
2250 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2252 int tohit1 = randint1(5) + m_bonus(5, level);
2253 int todam1 = randint1(5) + m_bonus(5, level);
2255 int tohit2 = m_bonus(10, level);
2256 int todam2 = m_bonus(10, level);
2258 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2260 tohit2 = (tohit2+1)/2;
2261 todam2 = (todam2+1)/2;
2268 o_ptr->to_h += tohit1;
2269 o_ptr->to_d += todam1;
2275 o_ptr->to_h += tohit2;
2276 o_ptr->to_d += todam2;
2284 o_ptr->to_h -= tohit1;
2285 o_ptr->to_d -= todam1;
2290 /* Penalize again */
2291 o_ptr->to_h -= tohit2;
2292 o_ptr->to_d -= todam2;
2295 /* Cursed (if "bad") */
2296 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2299 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2302 switch (o_ptr->tval)
2309 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2310 create_artifact(o_ptr, FALSE);
2312 /* Special Ego-item */
2313 o_ptr->name2 = EGO_DIGGING;
2317 else if (power < -1)
2319 /* Hack -- Horrible digging bonus */
2320 o_ptr->pval = 0 - (5 + randint1(5));
2326 /* Hack -- Reverse digging bonus */
2327 o_ptr->pval = 0 - (o_ptr->pval);
2341 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2343 create_artifact(o_ptr, FALSE);
2348 /* Roll for an ego-item */
2349 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2350 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2352 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2354 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2359 switch (o_ptr->name2)
2362 if (one_in_(4) && (level > 40))
2363 add_flag(o_ptr->art_flags, TR_BLOWS);
2367 add_flag(o_ptr->art_flags, TR_RES_POIS);
2369 add_flag(o_ptr->art_flags, TR_WARNING);
2371 case EGO_KILL_DRAGON:
2373 add_flag(o_ptr->art_flags, TR_RES_POIS);
2377 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2379 case EGO_SLAYING_WEAPON:
2380 if (one_in_(3)) /* double damage */
2388 while (one_in_(o_ptr->dd));
2394 while (one_in_(o_ptr->ds));
2399 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2401 if (o_ptr->tval == TV_SWORD && one_in_(3))
2403 add_flag(o_ptr->art_flags, TR_VORPAL);
2408 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2414 add_flag(o_ptr->art_flags, TR_HOLD_LIFE);
2416 add_flag(o_ptr->art_flags, TR_DEX);
2418 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2421 o_ptr->pval = m_bonus(5, level) + 1;
2423 case EGO_EARTHQUAKES:
2424 if (one_in_(3) && (level > 60))
2425 add_flag(o_ptr->art_flags, TR_BLOWS);
2427 o_ptr->pval = m_bonus(3, level);
2431 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2435 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2437 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2439 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2440 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2443 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2444 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2445 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2446 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2450 if (!o_ptr->art_name)
2452 /* Hack -- Super-charge the damage dice */
2453 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2455 /* Hack -- Lower the damage dice */
2456 if (o_ptr->dd > 9) o_ptr->dd = 9;
2461 else if (power < -1)
2463 /* Roll for ego-item */
2464 if (randint0(MAX_DEPTH) < level)
2468 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2469 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2475 switch (o_ptr->name2)
2478 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2479 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2481 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2482 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2483 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2484 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2485 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2486 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2500 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2502 create_artifact(o_ptr, FALSE);
2505 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2519 if (power > 2) /* power > 2 is debug only */
2521 create_artifact(o_ptr, FALSE);
2525 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2527 switch (o_ptr->name2)
2529 case EGO_SLAYING_BOLT:
2534 /* Hack -- super-charge the damage dice */
2535 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2537 /* Hack -- restrict the damage dice */
2538 if (o_ptr->dd > 9) o_ptr->dd = 9;
2542 else if (power < -1)
2544 /* Roll for ego-item */
2545 if (randint0(MAX_DEPTH) < level)
2547 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2557 static void dragon_resist(object_type * o_ptr)
2562 one_dragon_ele_resistance(o_ptr);
2564 one_high_resistance(o_ptr);
2570 static bool add_esp_strong(object_type *o_ptr)
2572 bool nonliv = FALSE;
2574 switch (randint1(3))
2576 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2577 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2578 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2585 static void add_esp_weak(object_type *o_ptr, bool extra)
2588 u32b weak_esp_list[] = {
2600 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2601 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2603 /* Add unduplicated weak esp flags randomly */
2604 for (i = 0; i < add_count; ++ i)
2606 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2608 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2609 weak_esp_list[choice] = weak_esp_list[i];
2615 * Apply magic to an item known to be "armor"
2617 * Hack -- note special processing for crown/helm
2618 * Hack -- note special processing for robe of permanence
2620 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2622 int toac1 = randint1(5) + m_bonus(5, level);
2624 int toac2 = m_bonus(10, level);
2630 o_ptr->to_a += toac1;
2636 o_ptr->to_a += toac2;
2644 o_ptr->to_a -= toac1;
2649 /* Penalize again */
2650 o_ptr->to_a -= toac2;
2653 /* Cursed (if "bad") */
2654 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2659 switch (o_ptr->tval)
2663 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2664 create_artifact(o_ptr, FALSE);
2666 /* Mention the item */
2667 if (cheat_peek) object_mention(o_ptr);
2678 /* Hack -- Try for "Robes of the Magi" */
2679 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2680 (o_ptr->sval == SV_ROBE) &&
2681 (randint0(100) < 15))
2685 o_ptr->name2 = EGO_YOIYAMI;
2686 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2687 o_ptr->sval = SV_YOIYAMI_ROBE;
2693 o_ptr->name2 = EGO_PERMANENCE;
2698 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2700 create_artifact(o_ptr, FALSE);
2706 bool okay_flag = TRUE;
2708 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2710 switch (o_ptr->name2)
2713 if (o_ptr->tval != TV_HARD_ARMOR)
2719 if (o_ptr->tval != TV_SOFT_ARMOR)
2731 switch (o_ptr->name2)
2733 case EGO_RESISTANCE:
2735 add_flag(o_ptr->art_flags, TR_RES_POIS);
2738 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2739 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2743 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2745 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2747 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2748 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2750 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2751 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2752 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2753 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2754 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2755 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2756 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2757 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2760 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2761 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2762 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2763 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2764 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2765 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2778 if (o_ptr->sval == SV_DRAGON_SHIELD)
2780 /* Mention the item */
2781 if (cheat_peek) object_mention(o_ptr);
2782 dragon_resist(o_ptr);
2783 if (!one_in_(3)) break;
2789 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2791 create_artifact(o_ptr, FALSE);
2797 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2798 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2799 && o_ptr->name2 == EGO_S_DWARVEN)
2806 switch (o_ptr->name2)
2809 if (!one_in_(3)) one_high_resistance(o_ptr);
2810 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2812 case EGO_REFLECTION:
2813 if (o_ptr->sval == SV_MIRROR_SHIELD)
2818 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2819 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2828 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2830 /* Mention the item */
2831 if (cheat_peek) object_mention(o_ptr);
2832 dragon_resist(o_ptr);
2833 if (!one_in_(3)) break;
2837 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2839 create_artifact(o_ptr, FALSE);
2842 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2846 else if (power < -1)
2848 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2856 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2858 /* Mention the item */
2859 if (cheat_peek) object_mention(o_ptr);
2860 dragon_resist(o_ptr);
2861 if (!one_in_(3)) break;
2866 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2868 create_artifact(o_ptr, FALSE);
2871 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2873 switch (o_ptr->name2)
2875 case EGO_SLOW_DESCENT:
2878 one_high_resistance(o_ptr);
2884 else if (power < -1)
2886 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2897 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2899 create_artifact(o_ptr, FALSE);
2904 bool ok_flag = TRUE;
2905 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2907 switch (o_ptr->name2)
2910 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2911 else add_esp_weak(o_ptr, FALSE);
2915 case EGO_REGENERATION:
2916 case EGO_LORDLINESS:
2922 if (one_in_(2)) add_esp_strong(o_ptr);
2923 else add_esp_weak(o_ptr, FALSE);
2926 default:/* not existing crown (wisdom,lite, etc...) */
2930 break; /* while (1) */
2936 else if (power < -1)
2940 bool ok_flag = TRUE;
2941 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
2943 switch (o_ptr->name2)
2945 case EGO_ANCIENT_CURSE:
2946 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2947 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2948 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2949 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2950 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2951 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2955 break; /* while (1) */
2964 if (o_ptr->sval == SV_DRAGON_HELM)
2966 /* Mention the item */
2967 if (cheat_peek) object_mention(o_ptr);
2968 dragon_resist(o_ptr);
2969 if (!one_in_(3)) break;
2975 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2977 create_artifact(o_ptr, FALSE);
2982 bool ok_flag = TRUE;
2983 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2985 switch (o_ptr->name2)
2987 case EGO_BRILLIANCE:
2989 case EGO_INFRAVISION:
2990 case EGO_H_PROTECTION:
2995 if (one_in_(2)) add_esp_strong(o_ptr);
2996 else add_esp_weak(o_ptr, FALSE);
3000 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3001 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3004 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3006 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3008 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3009 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3011 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3012 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3013 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3014 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3015 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3016 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3017 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3018 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3020 default:/* not existing helm (Magi, Might, etc...)*/
3024 break; /* while (1) */
3029 else if (power < -1)
3033 bool ok_flag = TRUE;
3034 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3036 switch (o_ptr->name2)
3038 case EGO_ANCIENT_CURSE:
3042 break; /* while (1) */
3053 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3055 create_artifact(o_ptr, FALSE);
3058 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3060 switch (o_ptr->name2)
3069 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3070 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3071 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3072 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3079 else if (power < -1)
3081 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3091 * Apply magic to an item known to be a "ring" or "amulet"
3093 * Hack -- note special "pval boost" code for ring of speed
3094 * Hack -- note that some items must be cursed (or blessed)
3096 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3098 /* Apply magic (good or bad) according to type */
3099 switch (o_ptr->tval)
3104 switch (o_ptr->sval)
3106 case SV_RING_ATTACKS:
3109 o_ptr->pval = m_bonus(2, level);
3110 if (one_in_(15)) o_ptr->pval++;
3111 if (o_ptr->pval < 1) o_ptr->pval = 1;
3117 o_ptr->ident |= (IDENT_BROKEN);
3120 o_ptr->curse_flags |= TRC_CURSED;
3123 o_ptr->pval = 0 - (o_ptr->pval);
3134 /* Strength, Constitution, Dexterity, Intelligence */
3140 o_ptr->pval = 1 + m_bonus(5, level);
3146 o_ptr->ident |= (IDENT_BROKEN);
3149 o_ptr->curse_flags |= TRC_CURSED;
3152 o_ptr->pval = 0 - (o_ptr->pval);
3158 /* Ring of Speed! */
3161 /* Base speed (1 to 10) */
3162 o_ptr->pval = randint1(5) + m_bonus(5, level);
3164 /* Super-charge the ring */
3165 while (randint0(100) < 50) o_ptr->pval++;
3171 o_ptr->ident |= (IDENT_BROKEN);
3174 o_ptr->curse_flags |= TRC_CURSED;
3177 o_ptr->pval = 0 - (o_ptr->pval);
3182 /* Mention the item */
3183 if (cheat_peek) object_mention(o_ptr);
3188 case SV_RING_LORDLY:
3192 one_lordly_high_resistance(o_ptr);
3196 /* Bonus to armor class */
3197 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
3201 case SV_RING_WARNING:
3203 if (one_in_(3)) one_low_esp(o_ptr);
3208 case SV_RING_SEARCHING:
3210 /* Bonus to searching */
3211 o_ptr->pval = 1 + m_bonus(5, level);
3217 o_ptr->ident |= (IDENT_BROKEN);
3220 o_ptr->curse_flags |= TRC_CURSED;
3223 o_ptr->pval = 0 - (o_ptr->pval);
3229 /* Flames, Acid, Ice */
3230 case SV_RING_FLAMES:
3235 /* Bonus to armor class */
3236 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3240 /* Weakness, Stupidity */
3241 case SV_RING_WEAKNESS:
3242 case SV_RING_STUPIDITY:
3245 o_ptr->ident |= (IDENT_BROKEN);
3248 o_ptr->curse_flags |= TRC_CURSED;
3251 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3252 if (power > 0) power = 0 - power;
3257 /* WOE, Stupidity */
3261 o_ptr->ident |= (IDENT_BROKEN);
3264 o_ptr->curse_flags |= TRC_CURSED;
3267 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3268 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3269 if (power > 0) power = 0 - power;
3274 /* Ring of damage */
3275 case SV_RING_DAMAGE:
3277 /* Bonus to damage */
3278 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3284 o_ptr->ident |= (IDENT_BROKEN);
3287 o_ptr->curse_flags |= TRC_CURSED;
3290 o_ptr->to_d = 0 - o_ptr->to_d;
3296 /* Ring of Accuracy */
3297 case SV_RING_ACCURACY:
3300 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3306 o_ptr->ident |= (IDENT_BROKEN);
3309 o_ptr->curse_flags |= TRC_CURSED;
3312 o_ptr->to_h = 0 - o_ptr->to_h;
3318 /* Ring of Protection */
3319 case SV_RING_PROTECTION:
3321 /* Bonus to armor class */
3322 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3328 o_ptr->ident |= (IDENT_BROKEN);
3331 o_ptr->curse_flags |= TRC_CURSED;
3334 o_ptr->to_a = 0 - o_ptr->to_a;
3340 /* Ring of Slaying */
3341 case SV_RING_SLAYING:
3343 /* Bonus to damage and to hit */
3344 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3345 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3351 o_ptr->ident |= (IDENT_BROKEN);
3354 o_ptr->curse_flags |= TRC_CURSED;
3356 /* Reverse bonuses */
3357 o_ptr->to_h = 0 - o_ptr->to_h;
3358 o_ptr->to_d = 0 - o_ptr->to_d;
3364 case SV_RING_MUSCLE:
3366 o_ptr->pval = 1 + m_bonus(3, level);
3367 if (one_in_(4)) o_ptr->pval++;
3373 o_ptr->ident |= (IDENT_BROKEN);
3376 o_ptr->curse_flags |= TRC_CURSED;
3378 /* Reverse bonuses */
3379 o_ptr->pval = 0 - o_ptr->pval;
3384 case SV_RING_AGGRAVATION:
3387 o_ptr->ident |= (IDENT_BROKEN);
3390 o_ptr->curse_flags |= TRC_CURSED;
3392 if (power > 0) power = 0 - power;
3396 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3397 || (power > 2)) /* power > 2 is debug only */
3399 o_ptr->pval = MIN(o_ptr->pval, 4);
3400 /* Randart amulet */
3401 create_artifact(o_ptr, FALSE);
3403 else if ((power == 2) && one_in_(2))
3405 while(!o_ptr->name2)
3407 int tmp = m_bonus(10, level);
3408 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3409 switch(randint1(28))
3412 o_ptr->name2 = EGO_RING_THROW;
3415 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3416 o_ptr->name2 = EGO_RING_REGEN;
3419 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3420 o_ptr->name2 = EGO_RING_LITE;
3423 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3424 o_ptr->name2 = EGO_RING_TELEPORT;
3427 if (o_ptr->to_h) break;
3428 o_ptr->name2 = EGO_RING_TO_H;
3431 if (o_ptr->to_d) break;
3432 o_ptr->name2 = EGO_RING_TO_D;
3435 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3436 o_ptr->name2 = EGO_RING_SLAY;
3439 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3440 o_ptr->name2 = EGO_RING_WIZARD;
3443 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3444 o_ptr->name2 = EGO_RING_HERO;
3447 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3448 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3449 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3450 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3453 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3454 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;
3455 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3456 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3457 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3460 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3461 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;
3462 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3463 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3464 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3467 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3468 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;
3469 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3470 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3473 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3474 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;
3475 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3476 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3478 case 21: case 22: case 23: case 24: case 25: case 26:
3479 switch (o_ptr->sval)
3482 if (!one_in_(3)) break;
3483 o_ptr->name2 = EGO_RING_D_SPEED;
3485 case SV_RING_DAMAGE:
3486 case SV_RING_ACCURACY:
3487 case SV_RING_SLAYING:
3488 if (one_in_(2)) break;
3489 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3492 o_ptr->name2 = EGO_RING_BERSERKER;
3493 o_ptr->to_h -= 2+randint1(4);
3494 o_ptr->to_d += 2+randint1(4);
3497 case SV_RING_PROTECTION:
3498 o_ptr->name2 = EGO_RING_SUPER_AC;
3499 o_ptr->to_a += 7 + m_bonus(5, level);
3501 case SV_RING_RES_FEAR:
3502 o_ptr->name2 = EGO_RING_HERO;
3505 if (one_in_(2)) break;
3506 o_ptr->name2 = EGO_RING_HUNTER;
3508 case SV_RING_SEARCHING:
3509 o_ptr->name2 = EGO_RING_STEALTH;
3511 case SV_RING_TELEPORTATION:
3512 o_ptr->name2 = EGO_RING_TELE_AWAY;
3514 case SV_RING_RES_BLINDNESS:
3516 o_ptr->name2 = EGO_RING_RES_LITE;
3518 o_ptr->name2 = EGO_RING_RES_DARK;
3520 case SV_RING_LORDLY:
3521 if (!one_in_(20)) break;
3522 one_lordly_high_resistance(o_ptr);
3523 one_lordly_high_resistance(o_ptr);
3524 o_ptr->name2 = EGO_RING_TRUE;
3526 case SV_RING_SUSTAIN:
3527 if (!one_in_(4)) break;
3528 o_ptr->name2 = EGO_RING_RES_TIME;
3530 case SV_RING_FLAMES:
3531 if (!one_in_(2)) break;
3532 o_ptr->name2 = EGO_RING_DRAGON_F;
3535 if (!one_in_(2)) break;
3536 o_ptr->name2 = EGO_RING_DRAGON_C;
3538 case SV_RING_WARNING:
3539 if (!one_in_(2)) break;
3540 o_ptr->name2 = EGO_RING_M_DETECT;
3549 o_ptr->curse_flags = 0L;
3551 else if ((power == -2) && one_in_(2))
3553 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3554 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3555 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3556 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3557 o_ptr->art_flags[0] = 0;
3558 o_ptr->art_flags[1] = 0;
3559 while(!o_ptr->name2)
3561 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3565 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3566 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3569 o_ptr->name2 = EGO_RING_NO_MELEE;
3572 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3573 o_ptr->name2 = EGO_RING_AGGRAVATE;
3576 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3577 o_ptr->name2 = EGO_RING_TY_CURSE;
3580 o_ptr->name2 = EGO_RING_ALBINO;
3585 o_ptr->ident |= (IDENT_BROKEN);
3588 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3596 switch (o_ptr->sval)
3598 /* Amulet of wisdom/charisma */
3599 case SV_AMULET_INTELLIGENCE:
3600 case SV_AMULET_WISDOM:
3601 case SV_AMULET_CHARISMA:
3603 o_ptr->pval = 1 + m_bonus(5, level);
3609 o_ptr->ident |= (IDENT_BROKEN);
3612 o_ptr->curse_flags |= (TRC_CURSED);
3614 /* Reverse bonuses */
3615 o_ptr->pval = 0 - o_ptr->pval;
3621 /* Amulet of brilliance */
3622 case SV_AMULET_BRILLIANCE:
3624 o_ptr->pval = 1 + m_bonus(3, level);
3625 if (one_in_(4)) o_ptr->pval++;
3631 o_ptr->ident |= (IDENT_BROKEN);
3634 o_ptr->curse_flags |= (TRC_CURSED);
3636 /* Reverse bonuses */
3637 o_ptr->pval = 0 - o_ptr->pval;
3643 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3647 o_ptr->curse_flags |= (TRC_CURSED);
3652 case SV_AMULET_RESISTANCE:
3654 if (one_in_(5)) one_high_resistance(o_ptr);
3655 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3659 /* Amulet of searching */
3660 case SV_AMULET_SEARCHING:
3662 o_ptr->pval = randint1(2) + m_bonus(4, level);
3668 o_ptr->ident |= (IDENT_BROKEN);
3671 o_ptr->curse_flags |= (TRC_CURSED);
3673 /* Reverse bonuses */
3674 o_ptr->pval = 0 - (o_ptr->pval);
3680 /* Amulet of the Magi -- never cursed */
3681 case SV_AMULET_THE_MAGI:
3683 o_ptr->pval = randint1(5) + m_bonus(5, level);
3684 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3686 /* gain one low ESP */
3687 add_esp_weak(o_ptr, FALSE);
3689 /* Mention the item */
3690 if (cheat_peek) object_mention(o_ptr);
3695 /* Amulet of Doom -- always cursed */
3696 case SV_AMULET_DOOM:
3699 o_ptr->ident |= (IDENT_BROKEN);
3702 o_ptr->curse_flags |= (TRC_CURSED);
3705 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3706 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3707 if (power > 0) power = 0 - power;
3712 case SV_AMULET_MAGIC_MASTERY:
3714 o_ptr->pval = 1 + m_bonus(4, level);
3720 o_ptr->ident |= (IDENT_BROKEN);
3723 o_ptr->curse_flags |= (TRC_CURSED);
3725 /* Reverse bonuses */
3726 o_ptr->pval = 0 - o_ptr->pval;
3732 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3733 || (power > 2)) /* power > 2 is debug only */
3735 o_ptr->pval = MIN(o_ptr->pval, 4);
3736 /* Randart amulet */
3737 create_artifact(o_ptr, FALSE);
3739 else if ((power == 2) && one_in_(2))
3741 while(!o_ptr->name2)
3743 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3744 switch(randint1(21))
3747 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3748 o_ptr->name2 = EGO_AMU_SLOW_D;
3751 if (o_ptr->pval) break;
3752 o_ptr->name2 = EGO_AMU_INFRA;
3755 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3756 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3759 if (have_flag(k_ptr->flags, TR_HOLD_LIFE)) break;
3760 o_ptr->name2 = EGO_AMU_HOLD_LIFE;
3763 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3764 o_ptr->name2 = EGO_AMU_LEVITATION;
3766 case 10: case 11: case 21:
3767 o_ptr->name2 = EGO_AMU_AC;
3770 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3771 if (m_bonus(10, level) > 8)
3772 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3774 o_ptr->name2 = EGO_AMU_RES_FIRE;
3777 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3778 if (m_bonus(10, level) > 8)
3779 o_ptr->name2 = EGO_AMU_RES_COLD_;
3781 o_ptr->name2 = EGO_AMU_RES_COLD;
3784 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3785 if (m_bonus(10, level) > 8)
3786 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3788 o_ptr->name2 = EGO_AMU_RES_ELEC;
3791 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3792 if (m_bonus(10, level) > 8)
3793 o_ptr->name2 = EGO_AMU_RES_ACID_;
3795 o_ptr->name2 = EGO_AMU_RES_ACID;
3797 case 16: case 17: case 18: case 19: case 20:
3798 switch (o_ptr->sval)
3800 case SV_AMULET_TELEPORT:
3801 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3802 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3803 else o_ptr->name2 = EGO_AMU_TELEPORT;
3805 case SV_AMULET_RESIST_ACID:
3806 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3808 case SV_AMULET_SEARCHING:
3809 o_ptr->name2 = EGO_AMU_STEALTH;
3811 case SV_AMULET_BRILLIANCE:
3812 if (!one_in_(3)) break;
3813 o_ptr->name2 = EGO_AMU_IDENT;
3815 case SV_AMULET_CHARISMA:
3816 if (!one_in_(3)) break;
3817 o_ptr->name2 = EGO_AMU_CHARM;
3819 case SV_AMULET_THE_MAGI:
3820 if (one_in_(2)) break;
3821 o_ptr->name2 = EGO_AMU_GREAT;
3823 case SV_AMULET_RESISTANCE:
3824 if (!one_in_(5)) break;
3825 o_ptr->name2 = EGO_AMU_DEFENDER;
3827 case SV_AMULET_TELEPATHY:
3828 if (!one_in_(3)) break;
3829 o_ptr->name2 = EGO_AMU_DETECTION;
3835 o_ptr->curse_flags = 0L;
3837 else if ((power == -2) && one_in_(2))
3839 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3840 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3841 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3842 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3843 o_ptr->art_flags[0] = 0;
3844 o_ptr->art_flags[1] = 0;
3845 while(!o_ptr->name2)
3847 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3851 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3852 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3855 o_ptr->name2 = EGO_AMU_FOOL;
3858 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3859 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3862 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3863 o_ptr->name2 = EGO_AMU_TY_CURSE;
3866 o_ptr->name2 = EGO_AMU_NAIVETY;
3871 o_ptr->ident |= (IDENT_BROKEN);
3874 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3883 * Hack -- help pick an item type
3885 static bool item_monster_okay(int r_idx)
3887 monster_race *r_ptr = &r_info[r_idx];
3890 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3891 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3892 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3893 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3894 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3895 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3903 * Apply magic to an item known to be "boring"
3905 * Hack -- note the special code for various items
3907 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3909 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3914 /* Apply magic (good or bad) according to type */
3915 switch (o_ptr->tval)
3924 o_ptr->ident |= (IDENT_BROKEN);
3927 o_ptr->curse_flags |= (TRC_CURSED);
3934 o_ptr->xtra4 = o_ptr->pval;
3940 /* Hack -- Torches -- random fuel */
3941 if (o_ptr->sval == SV_LITE_TORCH)
3943 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3947 /* Hack -- Lanterns -- random fuel */
3948 if (o_ptr->sval == SV_LITE_LANTERN)
3950 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3954 if (power > 2) /* power > 2 is debug only */
3956 create_artifact(o_ptr, FALSE);
3958 else if ((power == 2) || ((power == 1) && one_in_(3)))
3960 while (!o_ptr->name2)
3964 bool okay_flag = TRUE;
3966 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
3968 switch (o_ptr->name2)
3971 if (o_ptr->sval == SV_LITE_FEANOR)
3979 else if (power == -2)
3981 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
3983 switch (o_ptr->name2)
3985 case EGO_LITE_DARKNESS:
3988 if (o_ptr->sval == SV_LITE_TORCH)
3990 add_flag(o_ptr->art_flags, TR_LITE_M1);
3992 else if (o_ptr->sval == SV_LITE_LANTERN)
3994 add_flag(o_ptr->art_flags, TR_LITE_M2);
3996 else if (o_ptr->sval == SV_LITE_FEANOR)
3998 add_flag(o_ptr->art_flags, TR_LITE_M3);
4010 /* The wand or staff gets a number of initial charges equal
4011 * to between 1/2 (+1) and the full object kind's pval. -LM-
4013 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4019 /* Transfer the pval. -LM- */
4020 o_ptr->pval = k_ptr->pval;
4027 object_aware(o_ptr);
4028 object_known(o_ptr);
4037 monster_race *r_ptr;
4039 /* Pick a random non-unique monster race */
4042 i = randint1(max_r_idx - 1);
4044 if (!item_monster_okay(i)) continue;
4045 if (i == MON_TSUCHINOKO) continue;
4049 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4051 /* Ignore dead monsters */
4052 if (!r_ptr->rarity) continue;
4054 /* Ignore uncommon monsters */
4055 if (r_ptr->rarity > 100) continue;
4057 /* Prefer less out-of-depth monsters */
4058 if (randint0(check)) continue;
4065 /* Some figurines are cursed */
4066 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4071 msg_format("%s¤Î¿Í·Á, ¿¼¤µ +%d%s",
4073 msg_format("Figurine of %s, depth +%d%s",
4076 r_name + r_ptr->name, check - 1,
4077 !object_is_cursed(o_ptr) ? "" : " {cursed}");
4090 monster_race *r_ptr;
4092 if (o_ptr->sval == SV_SKELETON)
4094 match = RF9_DROP_SKELETON;
4096 else if (o_ptr->sval == SV_CORPSE)
4098 match = RF9_DROP_CORPSE;
4101 /* Hack -- Remove the monster restriction */
4102 get_mon_num_prep(item_monster_okay, NULL);
4104 /* Pick a random non-unique monster race */
4107 i = get_mon_num(dun_level);
4111 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4113 /* Ignore dead monsters */
4114 if (!r_ptr->rarity) continue;
4116 /* Ignore corpseless monsters */
4117 if (!(r_ptr->flags9 & match)) continue;
4119 /* Prefer less out-of-depth monsters */
4120 if (randint0(check)) continue;
4130 msg_format("%s¤Î»àÂÎ, ¿¼¤µ +%d",
4132 msg_format("Corpse of %s, depth +%d",
4135 r_name + r_ptr->name, check - 1);
4138 object_aware(o_ptr);
4139 object_known(o_ptr);
4147 monster_race *r_ptr;
4149 /* Pick a random monster race */
4152 i = randint1(max_r_idx - 1);
4156 /* Ignore dead monsters */
4157 if (!r_ptr->rarity) continue;
4167 msg_format("%s¤ÎÁü", r_name + r_ptr->name);
4169 msg_format("Statue of %s", r_name + r_ptr->name);
4173 object_aware(o_ptr);
4174 object_known(o_ptr);
4181 byte obj_level = k_info[o_ptr->k_idx].level;
4183 /* Hack -- skip ruined chests */
4184 if (obj_level <= 0) break;
4186 /* Hack -- pick a "difficulty" */
4187 o_ptr->pval = randint1(obj_level);
4188 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4190 o_ptr->xtra3 = dun_level + 5;
4192 /* Never exceed "difficulty" of 55 to 59 */
4193 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4202 * Complete the "creation" of an object by applying "magic" to the item
4204 * This includes not only rolling for random bonuses, but also putting the
4205 * finishing touches on ego-items and artifacts, giving charges to wands and
4206 * staffs, giving fuel to lites, and placing traps on chests.
4208 * In particular, note that "Instant Artifacts", if "created" by an external
4209 * routine, must pass through this function to complete the actual creation.
4211 * The base "chance" of the item being "good" increases with the "level"
4212 * parameter, which is usually derived from the dungeon level, being equal
4213 * to the level plus 10, up to a maximum of 75. If "good" is true, then
4214 * the object is guaranteed to be "good". If an object is "good", then
4215 * the chance that the object will be "great" (ego-item or artifact), also
4216 * increases with the "level", being equal to half the level, plus 5, up to
4217 * a maximum of 20. If "great" is true, then the object is guaranteed to be
4218 * "great". At dungeon level 65 and below, 15/100 objects are "great".
4220 * If the object is not "good", there is a chance it will be "cursed", and
4221 * if it is "cursed", there is a chance it will be "broken". These chances
4222 * are related to the "good" / "great" chances above.
4224 * Otherwise "normal" rings and amulets will be "good" half the time and
4225 * "cursed" half the time, unless the ring/amulet is always good or cursed.
4227 * If "okay" is true, and the object is going to be "great", then there is
4228 * a chance that an artifact will be created. This is true even if both the
4229 * "good" and "great" arguments are false. As a total hack, if "great" is
4230 * true, then the item gets 3 extra "attempts" to become an artifact.
4232 void apply_magic(object_type *o_ptr, int lev, u32b mode)
4234 int i, rolls, f1, f2, power;
4236 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4238 /* Maximum "level" for various things */
4239 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4241 /* Base chance of being "good" */
4244 /* Maximal chance of being "good" */
4245 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4247 /* Base chance of being "great" */
4250 /* Maximal chance of being "great" */
4251 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4252 f2 = d_info[dungeon_type].obj_great;
4254 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4259 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4268 /* Roll for "good" */
4269 if ((mode & AM_GOOD) || magik(f1))
4274 /* Roll for "great" */
4275 if ((mode & AM_GREAT) || magik(f2))
4279 /* Roll for "special" */
4280 if (mode & AM_SPECIAL) power = 3;
4284 /* Roll for "cursed" */
4287 /* Assume "cursed" */
4290 /* Roll for "broken" */
4291 if (magik(f2)) power = -2;
4295 if (mode & AM_CURSED)
4297 /* Assume 'cursed' */
4302 /* Everything else gets more badly cursed */
4309 /* Assume no rolls */
4312 /* Get one roll if excellent */
4313 if (power >= 2) rolls = 1;
4315 /* Hack -- Get four rolls if forced great or special */
4316 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4318 /* Hack -- Get no rolls if not allowed */
4319 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4321 /* Roll for artifacts if allowed */
4322 for (i = 0; i < rolls; i++)
4324 /* Roll for an artifact */
4325 if (make_artifact(o_ptr)) break;
4326 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4328 if (make_artifact(o_ptr)) break;
4333 /* Hack -- analyze artifacts */
4334 if (object_is_fixed_artifact(o_ptr))
4336 artifact_type *a_ptr = &a_info[o_ptr->name1];
4338 /* Hack -- Mark the artifact as "created" */
4341 /* Hack -- Memorize location of artifact in saved floors */
4342 if (character_dungeon)
4343 a_ptr->floor_id = p_ptr->floor_id;
4345 /* Extract the other fields */
4346 o_ptr->pval = a_ptr->pval;
4347 o_ptr->ac = a_ptr->ac;
4348 o_ptr->dd = a_ptr->dd;
4349 o_ptr->ds = a_ptr->ds;
4350 o_ptr->to_a = a_ptr->to_a;
4351 o_ptr->to_h = a_ptr->to_h;
4352 o_ptr->to_d = a_ptr->to_d;
4353 o_ptr->weight = a_ptr->weight;
4354 o_ptr->xtra2 = a_ptr->act_idx;
4356 if (o_ptr->name1 == ART_MILIM)
4358 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4364 /* Hack -- extract the "broken" flag */
4365 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4367 /* Hack -- extract the "cursed" flag */
4368 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4369 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4370 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4371 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4372 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4373 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4376 /* Cheat -- peek at the item */
4377 if (cheat_peek) object_mention(o_ptr);
4385 switch (o_ptr->tval)
4394 if (power) a_m_aux_1(o_ptr, lev, power);
4400 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4406 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4420 /* Elven Cloak and Black Clothes ... */
4421 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4422 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4423 o_ptr->pval = randint1(4);
4427 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4428 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4429 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4430 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4431 a_m_aux_2(o_ptr, lev, power);
4433 if (power) a_m_aux_2(o_ptr, lev, power);
4441 if (!power && (randint0(100) < 50)) power = -1;
4442 a_m_aux_3(o_ptr, lev, power);
4448 a_m_aux_4(o_ptr, lev, power);
4453 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4454 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4455 (p_ptr->pseikaku == SEIKAKU_SEXY))
4458 add_flag(o_ptr->art_flags, TR_STR);
4459 add_flag(o_ptr->art_flags, TR_INT);
4460 add_flag(o_ptr->art_flags, TR_WIS);
4461 add_flag(o_ptr->art_flags, TR_DEX);
4462 add_flag(o_ptr->art_flags, TR_CON);
4463 add_flag(o_ptr->art_flags, TR_CHR);
4466 /* Hack -- analyze ego-items */
4467 if (object_is_ego(o_ptr))
4469 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4471 /* Hack -- acquire "broken" flag */
4472 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4474 /* Hack -- acquire "cursed" flag */
4475 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4476 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4477 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4478 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4479 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4480 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4482 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4483 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4484 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4485 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4486 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4487 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4488 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4489 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4495 while (one_in_(o_ptr->dd));
4497 if (o_ptr->dd > 9) o_ptr->dd = 9;
4500 /* Hack -- apply activatin index if needed */
4501 if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
4503 /* Hack -- apply extra penalties if needed */
4504 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4506 /* Hack -- obtain bonuses */
4507 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4508 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4509 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4511 /* Hack -- obtain pval */
4512 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4515 /* Hack -- apply extra bonuses if needed */
4518 /* Hack -- obtain bonuses */
4519 if (e_ptr->max_to_h)
4521 if (e_ptr->max_to_h > 127)
4522 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4523 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4525 if (e_ptr->max_to_d)
4527 if (e_ptr->max_to_d > 127)
4528 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4529 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4531 if (e_ptr->max_to_a)
4533 if (e_ptr->max_to_a > 127)
4534 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4535 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4538 /* Accuracy ego must have high to_h */
4539 if(o_ptr->name2 == EGO_ACCURACY)
4541 while(o_ptr->to_h < o_ptr->to_d + 10)
4546 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4549 /* Accuracy ego must have high to_h */
4550 if(o_ptr->name2 == EGO_VELOCITY)
4552 while(o_ptr->to_d < o_ptr->to_h + 10)
4557 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4560 /* Protection ego must have high to_a */
4561 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4563 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4566 /* Hack -- obtain pval */
4567 if (e_ptr->max_pval)
4569 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4572 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4574 else if (o_ptr->name2 == EGO_DEMON)
4576 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4578 o_ptr->pval += randint1(2);
4582 o_ptr->pval += randint1(e_ptr->max_pval);
4585 else if (o_ptr->name2 == EGO_ATTACKS)
4587 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4588 if (o_ptr->pval > 3) o_ptr->pval = 3;
4589 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4590 o_ptr->pval += randint1(2);
4592 else if (o_ptr->name2 == EGO_BAT)
4594 o_ptr->pval = randint1(e_ptr->max_pval);
4595 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4597 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4599 o_ptr->pval = randint1(e_ptr->max_pval);
4603 o_ptr->pval += randint1(e_ptr->max_pval);
4608 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4610 o_ptr->pval = randint1(o_ptr->pval);
4612 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4616 /* Cheat -- describe the item */
4617 if (cheat_peek) object_mention(o_ptr);
4623 /* Examine real objects */
4626 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4628 /* Hack -- acquire "broken" flag */
4629 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4631 /* Hack -- acquire "cursed" flag */
4632 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4633 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4634 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4635 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4636 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4637 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4643 * Hack -- determine if a template is "good"
4645 static bool kind_is_good(int k_idx)
4647 object_kind *k_ptr = &k_info[k_idx];
4649 /* Analyze the item type */
4650 switch (k_ptr->tval)
4652 /* Armor -- Good unless damaged */
4663 if (k_ptr->to_a < 0) return (FALSE);
4667 /* Weapons -- Good unless damaged */
4674 if (k_ptr->to_h < 0) return (FALSE);
4675 if (k_ptr->to_d < 0) return (FALSE);
4679 /* Ammo -- Arrows/Bolts are good */
4686 /* Books -- High level books are good (except Arcane books) */
4688 case TV_SORCERY_BOOK:
4689 case TV_NATURE_BOOK:
4694 case TV_DAEMON_BOOK:
4695 case TV_CRUSADE_BOOK:
4697 case TV_HISSATSU_BOOK:
4700 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4704 /* Rings -- Rings of Speed are good */
4707 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4708 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4712 /* Amulets -- Amulets of the Magi and Resistance are good */
4715 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4716 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4721 /* Assume not good */
4727 * Attempt to make an object (normal or good/great)
4729 * This routine plays nasty games to generate the "special artifacts".
4731 * This routine uses "object_level" for the "generation level".
4733 * We assume that the given object has been "wiped".
4735 bool make_object(object_type *j_ptr, u32b mode)
4741 /* Chance of "special object" */
4742 prob = ((mode & AM_GOOD) ? 10 : 1000);
4744 /* Base level for the object */
4745 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4748 /* Generate a special object, or a normal object */
4749 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4754 if ((mode & AM_GOOD) && !get_obj_num_hook)
4756 /* Activate restriction (if already specified, use that) */
4757 get_obj_num_hook = kind_is_good;
4760 /* Restricted objects - prepare allocation table */
4761 if (get_obj_num_hook) get_obj_num_prep();
4763 /* Pick a random object */
4764 k_idx = get_obj_num(base);
4766 /* Restricted objects */
4767 if (get_obj_num_hook)
4769 /* Clear restriction */
4770 get_obj_num_hook = NULL;
4772 /* Reset allocation table to default */
4776 /* Handle failure */
4777 if (!k_idx) return (FALSE);
4779 /* Prepare the object */
4780 object_prep(j_ptr, k_idx);
4783 /* Apply magic (allow artifacts) */
4784 apply_magic(j_ptr, object_level, mode);
4786 /* Hack -- generate multiple spikes/missiles */
4787 switch (j_ptr->tval)
4795 j_ptr->number = (byte)damroll(6, 7);
4799 obj_level = k_info[j_ptr->k_idx].level;
4800 if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4802 /* Notice "okay" out-of-depth objects */
4803 if (!object_is_cursed(j_ptr) && !object_is_broken(j_ptr) &&
4804 (obj_level > dun_level))
4806 /* Cheat -- peek at items */
4807 if (cheat_peek) object_mention(j_ptr);
4816 * Attempt to place an object (normal or good/great) at the given location.
4818 * This routine plays nasty games to generate the "special artifacts".
4820 * This routine uses "object_level" for the "generation level".
4822 * This routine requires a clean floor grid destination.
4824 void place_object(int y, int x, u32b mode)
4829 cave_type *c_ptr = &cave[y][x];
4835 /* Paranoia -- check bounds */
4836 if (!in_bounds(y, x)) return;
4838 /* Require floor space */
4839 if (!cave_drop_bold(y, x)) return;
4841 /* Avoid stacking on other objects */
4842 if (c_ptr->o_idx) return;
4845 /* Get local object */
4848 /* Wipe the object */
4851 /* Make an object (if possible) */
4852 if (!make_object(q_ptr, mode)) return;
4855 /* Make an object */
4863 /* Acquire object */
4864 o_ptr = &o_list[o_idx];
4866 /* Structure Copy */
4867 object_copy(o_ptr, q_ptr);
4874 o_ptr->next_o_idx = c_ptr->o_idx;
4876 /* Place the object */
4877 c_ptr->o_idx = o_idx;
4887 /* Hack -- Preserve artifacts */
4888 if (object_is_fixed_artifact(q_ptr))
4890 a_info[q_ptr->name1].cur_num = 0;
4897 * Make a treasure object
4899 * The location must be a legal, clean, floor grid.
4901 bool make_gold(object_type *j_ptr)
4908 /* Hack -- Pick a Treasure variety */
4909 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4911 /* Apply "extra" magic */
4912 if (one_in_(GREAT_OBJ))
4914 i += randint1(object_level + 1);
4917 /* Hack -- Creeping Coins only generate "themselves" */
4918 if (coin_type) i = coin_type;
4920 /* Do not create "illegal" Treasure Types */
4921 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4923 /* Prepare a gold object */
4924 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4926 /* Hack -- Base coin cost */
4927 base = k_info[OBJ_GOLD_LIST+i].cost;
4929 /* Determine how much the treasure is "worth" */
4930 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
4938 * Places a treasure (Gold or Gems) at given location
4940 * The location must be a legal, clean, floor grid.
4942 void place_gold(int y, int x)
4947 cave_type *c_ptr = &cave[y][x];
4954 /* Paranoia -- check bounds */
4955 if (!in_bounds(y, x)) return;
4957 /* Require floor space */
4958 if (!cave_drop_bold(y, x)) return;
4960 /* Avoid stacking on other objects */
4961 if (c_ptr->o_idx) return;
4964 /* Get local object */
4967 /* Wipe the object */
4970 /* Make some gold */
4971 if (!make_gold(q_ptr)) return;
4974 /* Make an object */
4982 /* Acquire object */
4983 o_ptr = &o_list[o_idx];
4985 /* Copy the object */
4986 object_copy(o_ptr, q_ptr);
4993 o_ptr->next_o_idx = c_ptr->o_idx;
4995 /* Place the object */
4996 c_ptr->o_idx = o_idx;
5008 * Let an object fall to the ground at or near a location.
5010 * The initial location is assumed to be "in_bounds()".
5012 * This function takes a parameter "chance". This is the percentage
5013 * chance that the item will "disappear" instead of drop. If the object
5014 * has been thrown, then this is the chance of disappearance on contact.
5016 * Hack -- this function uses "chance" to determine if it should produce
5017 * some form of "description" of the drop event (under the player).
5019 * We check several locations to see if we can find a location at which
5020 * the object can combine, stack, or be placed. Artifacts will try very
5021 * hard to be placed, including "teleporting" to a useful grid if needed.
5023 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5034 s16b this_o_idx, next_o_idx = 0;
5038 char o_name[MAX_NLEN];
5044 /* Extract plural */
5045 bool plural = (j_ptr->number != 1);
5048 /* Describe object */
5049 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5052 /* Handle normal "breakage" */
5053 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5057 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5059 msg_format("The %s disappear%s.",
5060 o_name, (plural ? "" : "s"));
5066 if (p_ptr->wizard) msg_print("(ÇË»)");
5068 if (p_ptr->wizard) msg_print("(breakage)");
5087 /* Scan local grids */
5088 for (dy = -3; dy <= 3; dy++)
5090 /* Scan local grids */
5091 for (dx = -3; dx <= 3; dx++)
5095 /* Calculate actual distance */
5096 d = (dy * dy) + (dx * dx);
5098 /* Ignore distant grids */
5099 if (d > 10) continue;
5105 /* Skip illegal grids */
5106 if (!in_bounds(ty, tx)) continue;
5108 /* Require line of projection */
5109 if (!projectable(y, x, ty, tx)) continue;
5112 c_ptr = &cave[ty][tx];
5114 /* Require floor space */
5115 if (!cave_drop_bold(ty, tx)) continue;
5120 /* Scan objects in that grid */
5121 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5125 /* Acquire object */
5126 o_ptr = &o_list[this_o_idx];
5128 /* Acquire next object */
5129 next_o_idx = o_ptr->next_o_idx;
5131 /* Check for possible combination */
5132 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5138 /* Add new object */
5142 if (k > 99) continue;
5144 /* Calculate score */
5145 s = 1000 - (d + k * 5);
5147 /* Skip bad values */
5148 if (s < bs) continue;
5150 /* New best value */
5153 /* Apply the randomizer to equivalent values */
5154 if ((++bn >= 2) && !one_in_(bn)) continue;
5169 /* Handle lack of space */
5170 if (!flag && !object_is_artifact(j_ptr))
5174 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5176 msg_format("The %s disappear%s.",
5177 o_name, (plural ? "" : "s"));
5183 if (p_ptr->wizard) msg_print("(¾²¥¹¥Ú¡¼¥¹¤¬¤Ê¤¤)");
5185 if (p_ptr->wizard) msg_print("(no floor space)");
5195 for (i = 0; !flag && (i < 1000); i++)
5198 ty = rand_spread(by, 1);
5199 tx = rand_spread(bx, 1);
5201 /* Verify location */
5202 if (!in_bounds(ty, tx)) continue;
5204 /* Bounce to that location */
5208 /* Require floor space */
5209 if (!cave_drop_bold(by, bx)) continue;
5218 int candidates = 0, pick;
5220 for (ty = 1; ty < cur_hgt - 1; ty++)
5222 for (tx = 1; tx < cur_wid - 1; tx++)
5224 /* A valid space found */
5225 if (cave_drop_bold(ty, tx)) candidates++;
5229 /* No valid place! */
5234 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5236 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5241 if (p_ptr->wizard) msg_print("(¾²¥¹¥Ú¡¼¥¹¤¬¤Ê¤¤)");
5243 if (p_ptr->wizard) msg_print("(no floor space)");
5246 /* Mega-Hack -- preserve artifacts */
5249 /* Hack -- Preserve unknown artifacts */
5250 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5252 /* Mega-Hack -- Preserve the artifact */
5253 a_info[j_ptr->name1].cur_num = 0;
5261 /* Choose a random one */
5262 pick = randint1(candidates);
5264 for (ty = 1; ty < cur_hgt - 1; ty++)
5266 for (tx = 1; tx < cur_wid - 1; tx++)
5268 if (cave_drop_bold(ty, tx))
5272 /* Is this a picked one? */
5286 c_ptr = &cave[by][bx];
5288 /* Scan objects in that grid for combination */
5289 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5293 /* Acquire object */
5294 o_ptr = &o_list[this_o_idx];
5296 /* Acquire next object */
5297 next_o_idx = o_ptr->next_o_idx;
5299 /* Check for combination */
5300 if (object_similar(o_ptr, j_ptr))
5302 /* Combine the items */
5303 object_absorb(o_ptr, j_ptr);
5313 /* Get new object */
5314 if (!done) o_idx = o_pop();
5317 if (!done && !o_idx)
5321 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5323 msg_format("The %s disappear%s.",
5324 o_name, (plural ? "" : "s"));
5330 if (p_ptr->wizard) msg_print("(¥¢¥¤¥Æ¥à¤¬Â¿²á¤®¤ë)");
5332 if (p_ptr->wizard) msg_print("(too many objects)");
5336 /* Hack -- Preserve artifacts */
5337 if (object_is_fixed_artifact(j_ptr))
5339 a_info[j_ptr->name1].cur_num = 0;
5349 /* Structure copy */
5350 object_copy(&o_list[o_idx], j_ptr);
5352 /* Access new object */
5353 j_ptr = &o_list[o_idx];
5360 j_ptr->held_m_idx = 0;
5363 j_ptr->next_o_idx = c_ptr->o_idx;
5365 /* Place the object */
5366 c_ptr->o_idx = o_idx;
5381 /* Mega-Hack -- no message if "dropped" by player */
5382 /* Message when an object falls under the player */
5383 if (chance && player_bold(by, bx))
5386 msg_print("²¿¤«¤¬Â²¼¤Ëž¤¬¤Ã¤Æ¤¤¿¡£");
5388 msg_print("You feel something roll beneath your feet.");
5401 * Scatter some "great" objects near the player
5403 void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
5406 object_type object_type_body;
5407 u32b mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5412 /* Get local object */
5413 i_ptr = &object_type_body;
5415 /* Wipe the object */
5418 /* Make a good (or great) object (if possible) */
5419 if (!make_object(i_ptr, mode)) continue;
5423 object_aware(i_ptr);
5424 object_known(i_ptr);
5427 /* Drop the object */
5428 (void)drop_near(i_ptr, -1, y1, x1);
5433 * Scatter some "amusing" objects near the player
5436 #define AMS_NOTHING 0x00 /* No restriction */
5437 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5438 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5439 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5440 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5450 amuse_type amuse_info[] =
5452 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5453 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5454 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5455 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5456 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5457 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5458 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5459 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5460 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5461 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5462 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5463 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5464 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5469 void amusement(int y1, int x1, int num, bool known)
5472 object_type object_type_body;
5475 for (n = 0; amuse_info[n].tval != 0; n++)
5477 t += amuse_info[n].prob;
5483 int i, k_idx, a_idx = 0;
5484 int r = randint0(t);
5485 bool insta_art, fixed_art;
5489 r -= amuse_info[i].prob;
5493 /* Get local object */
5494 i_ptr = &object_type_body;
5496 /* Wipe the object */
5499 /* Wipe the object */
5500 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5502 /* Paranoia - reroll if nothing */
5503 if (!k_idx) continue;
5505 /* Search an artifact index if need */
5506 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5507 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5509 if (insta_art || fixed_art)
5511 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5513 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5514 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5515 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5516 if (a_info[a_idx].cur_num > 0) continue;
5520 if (a_idx >= max_a_idx) continue;
5523 /* Make an object (if possible) */
5524 object_prep(i_ptr, k_idx);
5525 if (a_idx) i_ptr->name1 = a_idx;
5526 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5528 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5530 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5533 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5534 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5538 object_aware(i_ptr);
5539 object_known(i_ptr);
5542 /* Paranoia - reroll if nothing */
5543 if (!(i_ptr->k_idx)) continue;
5545 /* Drop the object */
5546 (void)drop_near(i_ptr, -1, y1, x1);
5553 #define MAX_NORMAL_TRAPS 18
5555 /* See init_feat_variables() in init2.c */
5556 static s16b normal_traps[MAX_NORMAL_TRAPS];
5559 * Initialize arrays for normal traps
5561 void init_normal_traps(void)
5565 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5566 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5567 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5568 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5569 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5570 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5571 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5572 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5573 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5574 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5575 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5576 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5577 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5578 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5579 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5580 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5581 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5582 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5588 * XXX XXX XXX This routine should be redone to reflect trap "level".
5589 * That is, it does not make sense to have spiked pits at 50 feet.
5590 * Actually, it is not this routine, but the "trap instantiation"
5591 * code, which should also check for "trap doors" on quest levels.
5593 s16b choose_random_trap(void)
5600 /* Hack -- pick a trap */
5601 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5603 /* Accept non-trapdoors */
5604 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5606 /* Hack -- no trap doors on special levels */
5607 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5609 /* Hack -- no trap doors on the deepest level */
5610 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5619 * Disclose an invisible trap
5621 void disclose_grid(int y, int x)
5623 cave_type *c_ptr = &cave[y][x];
5625 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5627 /* No longer hidden */
5628 cave_alter_feat(y, x, FF_SECRET);
5630 else if (c_ptr->mimic)
5632 /* No longer hidden */
5645 * Places a random trap at the given location.
5647 * The location must be a legal, naked, floor grid.
5649 * Note that all traps start out as "invisible" and "untyped", and then
5650 * when they are "discovered" (by detecting them or setting them off),
5651 * the trap is "instantiated" as a visible, "typed", trap.
5653 void place_trap(int y, int x)
5655 cave_type *c_ptr = &cave[y][x];
5657 /* Paranoia -- verify location */
5658 if (!in_bounds(y, x)) return;
5660 /* Require empty, clean, floor grid */
5661 if (!cave_clean_bold(y, x)) return;
5663 /* Place an invisible trap */
5664 c_ptr->mimic = c_ptr->feat;
5665 c_ptr->feat = choose_random_trap();
5670 * Describe the charges on an item in the inventory.
5672 void inven_item_charges(int item)
5674 object_type *o_ptr = &inventory[item];
5676 /* Require staff/wand */
5677 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5679 /* Require known item */
5680 if (!object_is_known(o_ptr)) return;
5683 if (o_ptr->pval <= 0)
5685 msg_print("¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
5689 msg_format("¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
5692 /* Multiple charges */
5693 if (o_ptr->pval != 1)
5695 /* Print a message */
5696 msg_format("You have %d charges remaining.", o_ptr->pval);
5702 /* Print a message */
5703 msg_format("You have %d charge remaining.", o_ptr->pval);
5711 * Describe an item in the inventory.
5713 void inven_item_describe(int item)
5715 object_type *o_ptr = &inventory[item];
5716 char o_name[MAX_NLEN];
5718 /* Get a description */
5719 object_desc(o_name, o_ptr, 0);
5721 /* Print a message */
5723 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤¹¤ë */
5724 if (o_ptr->number <= 0)
5726 /*FIRST*//*¤³¤³¤Ï¤â¤¦Ä̤é¤Ê¤¤¤«¤â */
5727 msg_format("¤â¤¦%s¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£", o_name);
5731 /* ¥¢¥¤¥Æ¥à̾¤ò±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½Âбþ */
5732 msg_format("¤Þ¤À %s¤ò»ý¤Ã¤Æ¤¤¤ë¡£", o_name);
5735 msg_format("You have %s.", o_name);
5742 * Increase the "number" of an item in the inventory
5744 void inven_item_increase(int item, int num)
5746 object_type *o_ptr = &inventory[item];
5749 num += o_ptr->number;
5752 if (num > 255) num = 255;
5753 else if (num < 0) num = 0;
5756 num -= o_ptr->number;
5758 /* Change the number and weight */
5761 /* Add the number */
5762 o_ptr->number += num;
5764 /* Add the weight */
5765 p_ptr->total_weight += (num * o_ptr->weight);
5767 /* Recalculate bonuses */
5768 p_ptr->update |= (PU_BONUS);
5770 /* Recalculate mana XXX */
5771 p_ptr->update |= (PU_MANA);
5773 /* Combine the pack */
5774 p_ptr->notice |= (PN_COMBINE);
5777 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5779 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5780 if (!o_ptr->number && p_ptr->ele_attack)
5782 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5784 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5786 /* Clear all temporary elemental brands */
5787 set_ele_attack(0, 0);
5796 * Erase an inventory slot if it has no more items
5798 void inven_item_optimize(int item)
5800 object_type *o_ptr = &inventory[item];
5802 /* Only optimize real items */
5803 if (!o_ptr->k_idx) return;
5805 /* Only optimize empty items */
5806 if (o_ptr->number) return;
5808 /* The item is in the pack */
5809 if (item < INVEN_RARM)
5816 /* Slide everything down */
5817 for (i = item; i < INVEN_PACK; i++)
5819 /* Structure copy */
5820 inventory[i] = inventory[i+1];
5823 /* Erase the "final" slot */
5824 object_wipe(&inventory[i]);
5827 p_ptr->window |= (PW_INVEN);
5830 /* The item is being wielded */
5836 /* Erase the empty slot */
5837 object_wipe(&inventory[item]);
5839 /* Recalculate bonuses */
5840 p_ptr->update |= (PU_BONUS);
5842 /* Recalculate torch */
5843 p_ptr->update |= (PU_TORCH);
5845 /* Recalculate mana XXX */
5846 p_ptr->update |= (PU_MANA);
5849 p_ptr->window |= (PW_EQUIP);
5853 p_ptr->window |= (PW_SPELL);
5858 * Describe the charges on an item on the floor.
5860 void floor_item_charges(int item)
5862 object_type *o_ptr = &o_list[item];
5864 /* Require staff/wand */
5865 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5867 /* Require known item */
5868 if (!object_is_known(o_ptr)) return;
5871 if (o_ptr->pval <= 0)
5873 msg_print("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
5877 msg_format("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
5880 /* Multiple charges */
5881 if (o_ptr->pval != 1)
5883 /* Print a message */
5884 msg_format("There are %d charges remaining.", o_ptr->pval);
5890 /* Print a message */
5891 msg_format("There is %d charge remaining.", o_ptr->pval);
5899 * Describe an item in the inventory.
5901 void floor_item_describe(int item)
5903 object_type *o_ptr = &o_list[item];
5904 char o_name[MAX_NLEN];
5906 /* Get a description */
5907 object_desc(o_name, o_ptr, 0);
5909 /* Print a message */
5911 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤òʬ¤±¤ë */
5912 if (o_ptr->number <= 0)
5914 msg_format("¾²¾å¤Ë¤Ï¡¢¤â¤¦%s¤Ï¤Ê¤¤¡£", o_name);
5918 msg_format("¾²¾å¤Ë¤Ï¡¢¤Þ¤À %s¤¬¤¢¤ë¡£", o_name);
5921 msg_format("You see %s.", o_name);
5928 * Increase the "number" of an item on the floor
5930 void floor_item_increase(int item, int num)
5932 object_type *o_ptr = &o_list[item];
5935 num += o_ptr->number;
5938 if (num > 255) num = 255;
5939 else if (num < 0) num = 0;
5942 num -= o_ptr->number;
5944 /* Change the number */
5945 o_ptr->number += num;
5950 * Optimize an item on the floor (destroy "empty" items)
5952 void floor_item_optimize(int item)
5954 object_type *o_ptr = &o_list[item];
5956 /* Paranoia -- be sure it exists */
5957 if (!o_ptr->k_idx) return;
5959 /* Only optimize empty items */
5960 if (o_ptr->number) return;
5962 /* Delete the object */
5963 delete_object_idx(item);
5968 * Check if we have space for an item in the pack without overflow
5970 bool inven_carry_okay(object_type *o_ptr)
5975 if (inven_cnt < INVEN_PACK) return (TRUE);
5978 for (j = 0; j < INVEN_PACK; j++)
5980 object_type *j_ptr = &inventory[j];
5982 /* Skip non-objects */
5983 if (!j_ptr->k_idx) continue;
5985 /* Check if the two items can be combined */
5986 if (object_similar(j_ptr, o_ptr)) return (TRUE);
5994 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
5998 /* Use empty slots */
5999 if (!j_ptr->k_idx) return TRUE;
6001 /* Hack -- readable books always come first */
6002 if ((o_ptr->tval == REALM1_BOOK) &&
6003 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6004 if ((j_ptr->tval == REALM1_BOOK) &&
6005 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6007 if ((o_ptr->tval == REALM2_BOOK) &&
6008 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6009 if ((j_ptr->tval == REALM2_BOOK) &&
6010 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6012 /* Objects sort by decreasing type */
6013 if (o_ptr->tval > j_ptr->tval) return TRUE;
6014 if (o_ptr->tval < j_ptr->tval) return FALSE;
6016 /* Non-aware (flavored) items always come last */
6017 /* Can happen in the home */
6018 if (!object_is_aware(o_ptr)) return FALSE;
6019 if (!object_is_aware(j_ptr)) return TRUE;
6021 /* Objects sort by increasing sval */
6022 if (o_ptr->sval < j_ptr->sval) return TRUE;
6023 if (o_ptr->sval > j_ptr->sval) return FALSE;
6025 /* Unidentified objects always come last */
6026 /* Objects in the home can be unknown */
6027 if (!object_is_known(o_ptr)) return FALSE;
6028 if (!object_is_known(j_ptr)) return TRUE;
6030 /* Fixed artifacts, random artifacts and ego items */
6031 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6032 else if (o_ptr->art_name) o_type = 2;
6033 else if (object_is_ego(o_ptr)) o_type = 1;
6036 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6037 else if (j_ptr->art_name) j_type = 2;
6038 else if (object_is_ego(j_ptr)) j_type = 1;
6041 if (o_type < j_type) return TRUE;
6042 if (o_type > j_type) return FALSE;
6044 switch (o_ptr->tval)
6050 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6051 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6057 /* Objects sort by increasing hit/damage bonuses */
6058 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6059 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6062 /* Hack: otherwise identical rods sort by
6063 increasing recharge time --dsb */
6065 if (o_ptr->pval < j_ptr->pval) return TRUE;
6066 if (o_ptr->pval > j_ptr->pval) return FALSE;
6070 /* Objects sort by decreasing value */
6071 return o_value > object_value(j_ptr);
6076 * Add an item to the players inventory, and return the slot used.
6078 * If the new item can combine with an existing item in the inventory,
6079 * it will do so, using "object_similar()" and "object_absorb()", else,
6080 * the item will be placed into the "proper" location in the inventory.
6082 * This function can be used to "over-fill" the player's pack, but only
6083 * once, and such an action must trigger the "overflow" code immediately.
6084 * Note that when the pack is being "over-filled", the new item must be
6085 * placed into the "overflow" slot, and the "overflow" must take place
6086 * before the pack is reordered, but (optionally) after the pack is
6087 * combined. This may be tricky. See "dungeon.c" for info.
6089 * Note that this code must remove any location/stack information
6090 * from the object once it is placed into the inventory.
6092 s16b inven_carry(object_type *o_ptr)
6100 /* Check for combining */
6101 for (j = 0; j < INVEN_PACK; j++)
6103 j_ptr = &inventory[j];
6105 /* Skip non-objects */
6106 if (!j_ptr->k_idx) continue;
6108 /* Hack -- track last item */
6111 /* Check if the two items can be combined */
6112 if (object_similar(j_ptr, o_ptr))
6114 /* Combine the items */
6115 object_absorb(j_ptr, o_ptr);
6117 /* Increase the weight */
6118 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6120 /* Recalculate bonuses */
6121 p_ptr->update |= (PU_BONUS);
6124 p_ptr->window |= (PW_INVEN);
6133 if (inven_cnt > INVEN_PACK) return (-1);
6135 /* Find an empty slot */
6136 for (j = 0; j <= INVEN_PACK; j++)
6138 j_ptr = &inventory[j];
6140 /* Use it if found */
6141 if (!j_ptr->k_idx) break;
6148 /* Reorder the pack */
6151 /* Get the "value" of the item */
6152 s32b o_value = object_value(o_ptr);
6154 /* Scan every occupied slot */
6155 for (j = 0; j < INVEN_PACK; j++)
6157 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6164 for (k = n; k >= i; k--)
6166 /* Hack -- Slide the item */
6167 object_copy(&inventory[k+1], &inventory[k]);
6170 /* Wipe the empty slot */
6171 object_wipe(&inventory[i]);
6176 object_copy(&inventory[i], o_ptr);
6178 /* Access new object */
6179 j_ptr = &inventory[i];
6182 j_ptr->next_o_idx = 0;
6184 /* Forget monster */
6185 j_ptr->held_m_idx = 0;
6187 /* Forget location */
6188 j_ptr->iy = j_ptr->ix = 0;
6190 /* Player touches it, and no longer marked */
6191 j_ptr->marked = OM_TOUCHED;
6193 /* Increase the weight */
6194 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6196 /* Count the items */
6199 /* Recalculate bonuses */
6200 p_ptr->update |= (PU_BONUS);
6202 /* Combine and Reorder pack */
6203 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6206 p_ptr->window |= (PW_INVEN);
6208 /* Return the slot */
6214 * Take off (some of) a non-cursed equipment item
6216 * Note that only one item at a time can be wielded per slot.
6218 * Note that taking off an item when "full" may cause that item
6219 * to fall to the ground.
6221 * Return the inventory slot into which the item is placed.
6223 s16b inven_takeoff(int item, int amt)
6234 char o_name[MAX_NLEN];
6237 /* Get the item to take off */
6238 o_ptr = &inventory[item];
6241 if (amt <= 0) return (-1);
6244 if (amt > o_ptr->number) amt = o_ptr->number;
6246 /* Get local object */
6249 /* Obtain a local object */
6250 object_copy(q_ptr, o_ptr);
6252 /* Modify quantity */
6253 q_ptr->number = amt;
6255 /* Describe the object */
6256 object_desc(o_name, q_ptr, 0);
6258 /* Took off weapon */
6259 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6260 object_is_melee_weapon(o_ptr))
6263 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
6265 act = "You were wielding";
6271 else if (item == INVEN_BOW)
6274 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
6276 act = "You were holding";
6281 /* Took off light */
6282 else if (item == INVEN_LITE)
6285 act = "¤ò¸÷¸»¤«¤é¤Ï¤º¤·¤¿";
6287 act = "You were holding";
6292 /* Took off something */
6296 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
6298 act = "You were wearing";
6303 /* Modify, Optimize */
6304 inven_item_increase(item, -amt);
6305 inven_item_optimize(item);
6307 /* Carry the object */
6308 slot = inven_carry(q_ptr);
6312 msg_format("%s(%c)%s¡£", o_name, index_to_label(slot), act);
6314 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6324 * Drop (some of) a non-cursed inventory/equipment item
6326 * The object will be dropped "near" the current location
6328 void inven_drop(int item, int amt)
6335 char o_name[MAX_NLEN];
6338 /* Access original object */
6339 o_ptr = &inventory[item];
6342 if (amt <= 0) return;
6345 if (amt > o_ptr->number) amt = o_ptr->number;
6348 /* Take off equipment */
6349 if (item >= INVEN_RARM)
6351 /* Take off first */
6352 item = inven_takeoff(item, amt);
6354 /* Access original object */
6355 o_ptr = &inventory[item];
6359 /* Get local object */
6362 /* Obtain local object */
6363 object_copy(q_ptr, o_ptr);
6365 /* Distribute charges of wands or rods */
6366 distribute_charges(o_ptr, q_ptr, amt);
6368 /* Modify quantity */
6369 q_ptr->number = amt;
6371 /* Describe local object */
6372 object_desc(o_name, q_ptr, 0);
6376 msg_format("%s(%c)¤òÍî¤È¤·¤¿¡£", o_name, index_to_label(item));
6378 msg_format("You drop %s (%c).", o_name, index_to_label(item));
6382 /* Drop it near the player */
6383 (void)drop_near(q_ptr, 0, py, px);
6385 /* Modify, Describe, Optimize */
6386 inven_item_increase(item, -amt);
6387 inven_item_describe(item);
6388 inven_item_optimize(item);
6393 * Combine items in the pack
6395 * Note special handling of the "overflow" slot
6397 void combine_pack(void)
6402 bool flag = FALSE, combined;
6408 /* Combine the pack (backwards) */
6409 for (i = INVEN_PACK; i > 0; i--)
6412 o_ptr = &inventory[i];
6414 /* Skip empty items */
6415 if (!o_ptr->k_idx) continue;
6417 /* Scan the items above that item */
6418 for (j = 0; j < i; j++)
6423 j_ptr = &inventory[j];
6425 /* Skip empty items */
6426 if (!j_ptr->k_idx) continue;
6429 * Get maximum number of the stack if these
6430 * are similar, get zero otherwise.
6432 max_num = object_similar_part(j_ptr, o_ptr);
6434 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6435 if (max_num && j_ptr->number < max_num)
6437 if (o_ptr->number + j_ptr->number <= max_num)
6442 /* Add together the item counts */
6443 object_absorb(j_ptr, o_ptr);
6445 /* One object is gone */
6448 /* Slide everything down */
6449 for (k = i; k < INVEN_PACK; k++)
6451 /* Structure copy */
6452 inventory[k] = inventory[k+1];
6455 /* Erase the "final" slot */
6456 object_wipe(&inventory[k]);
6460 int old_num = o_ptr->number;
6461 int remain = j_ptr->number + o_ptr->number - max_num;
6463 o_ptr->number -= remain;
6465 /* Add together the item counts */
6466 object_absorb(j_ptr, o_ptr);
6468 o_ptr->number = remain;
6470 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6471 if (o_ptr->tval == TV_ROD)
6473 o_ptr->pval = o_ptr->pval * remain / old_num;
6474 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6477 /* Hack -- if wands are stacking, combine the charges. -LM- */
6478 if (o_ptr->tval == TV_WAND)
6480 o_ptr->pval = o_ptr->pval * remain / old_num;
6485 p_ptr->window |= (PW_INVEN);
6500 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤ò¤Þ¤È¤áľ¤·¤¿¡£");
6502 if (flag) msg_print("You combine some items in your pack.");
6508 * Reorder items in the pack
6510 * Note special handling of the "overflow" slot
6512 void reorder_pack(void)
6522 /* Re-order the pack (forwards) */
6523 for (i = 0; i < INVEN_PACK; i++)
6525 /* Mega-Hack -- allow "proper" over-flow */
6526 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6529 o_ptr = &inventory[i];
6531 /* Skip empty slots */
6532 if (!o_ptr->k_idx) continue;
6534 /* Get the "value" of the item */
6535 o_value = object_value(o_ptr);
6537 /* Scan every occupied slot */
6538 for (j = 0; j < INVEN_PACK; j++)
6540 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6543 /* Never move down */
6544 if (j >= i) continue;
6549 /* Get local object */
6552 /* Save a copy of the moving item */
6553 object_copy(q_ptr, &inventory[i]);
6555 /* Slide the objects */
6556 for (k = i; k > j; k--)
6558 /* Slide the item */
6559 object_copy(&inventory[k], &inventory[k-1]);
6562 /* Insert the moving item */
6563 object_copy(&inventory[j], q_ptr);
6566 p_ptr->window |= (PW_INVEN);
6571 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤òÊ¤Ùľ¤·¤¿¡£");
6573 if (flag) msg_print("You reorder some items in your pack.");
6580 * Hack -- display an object kind in the current window
6582 * Include list of usable spells for readible books
6584 void display_koff(int k_idx)
6593 char o_name[MAX_NLEN];
6596 /* Erase the window */
6597 for (y = 0; y < Term->hgt; y++)
6599 /* Erase the line */
6600 Term_erase(0, y, 255);
6606 /* Get local object */
6609 /* Prepare the object */
6610 object_prep(q_ptr, k_idx);
6613 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6615 /* Mention the object name */
6616 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6618 /* Access the item's sval */
6620 use_realm = tval2realm(q_ptr->tval);
6622 /* Warriors are illiterate */
6623 if (p_ptr->realm1 || p_ptr->realm2)
6625 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6629 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6630 if (!is_magic(use_realm)) return;
6631 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6634 /* Display spells in readible books */
6640 /* Extract spells */
6641 for (spell = 0; spell < 32; spell++)
6643 /* Check for this spell */
6644 if (fake_spell_flags[sval] & (1L << spell))
6646 /* Collect this spell */
6647 spells[num++] = spell;
6652 print_spells(0, spells, num, 2, 0, use_realm);
6656 /* Choose one of items that have warning flag */
6657 object_type *choose_warning_item(void)
6660 int choices[INVEN_TOTAL - INVEN_RARM];
6663 /* Paranoia -- Player has no warning ability */
6664 if (!p_ptr->warning) return NULL;
6666 /* Search Inventory */
6667 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6669 u32b flgs[TR_FLAG_SIZE];
6670 object_type *o_ptr = &inventory[i];
6672 object_flags(o_ptr, flgs);
6673 if (have_flag(flgs, TR_WARNING))
6675 choices[number] = i;
6680 /* Choice one of them */
6681 return number ? &inventory[choices[randint0(number)]] : NULL;
6684 /* Calculate spell damages */
6685 static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int *max)
6687 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6688 int rlev = r_ptr->level;
6689 bool ignore_wraith_form = FALSE;
6691 if (limit) dam = (dam > limit) ? limit : dam;
6693 /* Vulnerability, resistance and immunity */
6697 if (p_ptr->immune_elec)
6700 ignore_wraith_form = TRUE;
6704 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6705 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6706 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6707 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6708 if (IS_OPPOSE_ELEC())
6709 dam = (dam + 2) / 3;
6714 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6715 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6719 if (p_ptr->immune_acid)
6722 ignore_wraith_form = TRUE;
6726 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6727 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6728 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6729 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6735 if (p_ptr->immune_cold)
6738 ignore_wraith_form = TRUE;
6742 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6743 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6744 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6745 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6750 if (p_ptr->immune_fire)
6753 ignore_wraith_form = TRUE;
6757 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6758 if (prace_is_(RACE_ENT)) dam += dam / 3;
6759 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6760 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6761 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6766 ignore_wraith_form = TRUE;
6770 if (!p_ptr->blind &&
6771 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6772 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6775 ignore_wraith_form = TRUE;
6780 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6781 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6782 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6785 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6786 * "dam *= 2;" for later "dam /= 2"
6788 if (p_ptr->wraith_form) dam *= 2;
6792 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6795 ignore_wraith_form = TRUE;
6797 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6801 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6805 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6809 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6813 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6817 if (prace_is_(RACE_SPECTRE))
6820 ignore_wraith_form = TRUE;
6822 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6826 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6830 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6834 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6838 if (p_ptr->levitation) dam = (dam * 2) / 3;
6842 if (p_ptr->resist_shard) dam /= 2;
6846 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6847 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6851 if (p_ptr->mimic_form)
6853 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6856 ignore_wraith_form = TRUE;
6861 switch (p_ptr->prace)
6870 ignore_wraith_form = TRUE;
6877 if (p_ptr->align > 10) dam /= 2;
6878 else if (p_ptr->align < -10) dam *= 2;
6882 if (p_ptr->align > 10) dam *= 2;
6886 case GF_BRAIN_SMASH:
6887 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6890 ignore_wraith_form = TRUE;
6898 if (100 + rlev / 2 <= p_ptr->skill_sav)
6901 ignore_wraith_form = TRUE;
6906 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
6909 ignore_wraith_form = TRUE;
6914 if (p_ptr->wraith_form && !ignore_wraith_form)
6920 if (dam > *max) *max = dam;
6923 /* Calculate blow damages */
6924 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
6926 int dam = blow_ptr->d_dice * blow_ptr->d_side;
6928 bool check_wraith_form = TRUE;
6930 if (blow_ptr->method != RBM_EXPLODE)
6932 int ac = p_ptr->ac + p_ptr->to_a;
6934 switch (blow_ptr->effect)
6938 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
6939 dam = MAX(dam, tmp_dam * 2);
6945 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
6949 spell_damcalc(m_ptr, GF_ACID, dam, 0, &dummy_max);
6951 check_wraith_form = FALSE;
6955 spell_damcalc(m_ptr, GF_ELEC, dam, 0, &dummy_max);
6957 check_wraith_form = FALSE;
6961 spell_damcalc(m_ptr, GF_FIRE, dam, 0, &dummy_max);
6963 check_wraith_form = FALSE;
6967 spell_damcalc(m_ptr, GF_COLD, dam, 0, &dummy_max);
6969 check_wraith_form = FALSE;
6974 check_wraith_form = FALSE;
6978 if (check_wraith_form && p_ptr->wraith_form)
6986 dam = (dam + 1) / 2;
6987 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, 0, &dummy_max);
6994 /* Examine the grid (xx,yy) and warn the player if there are any danger */
6995 bool process_warning(int xx, int yy)
6999 char o_name[MAX_NLEN];
7001 #define WARNING_AWARE_RANGE 12
7003 static int old_damage = 0;
7005 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7007 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7010 monster_type *m_ptr;
7011 monster_race *r_ptr;
7013 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7015 c_ptr = &cave[my][mx];
7017 if (!c_ptr->m_idx) continue;
7019 m_ptr = &m_list[c_ptr->m_idx];
7021 if (MON_CSLEEP(m_ptr)) continue;
7022 if (!is_hostile(m_ptr)) continue;
7024 r_ptr = &r_info[m_ptr->r_idx];
7026 /* Monster spells (only powerful ones)*/
7027 if (projectable(my, mx, yy, xx))
7029 int breath_dam_div3 = m_ptr->hp / 3;
7030 int breath_dam_div6 = m_ptr->hp / 6;
7031 u32b f4 = r_ptr->flags4;
7032 u32b f5 = r_ptr->flags5;
7033 u32b f6 = r_ptr->flags6;
7035 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7037 int rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
7038 int storm_dam = rlev * 4 + 150;
7039 bool powerful = (bool)(r_ptr->flags2 & RF2_POWERFUL);
7041 if (f4 & RF4_BA_CHAO) spell_damcalc(m_ptr, GF_CHAOS, rlev * (powerful ? 3 : 2) + 100, 0, &dam_max0);
7042 if (f5 & RF5_BA_MANA) spell_damcalc(m_ptr, GF_MANA, storm_dam, 0, &dam_max0);
7043 if (f5 & RF5_BA_DARK) spell_damcalc(m_ptr, GF_DARK, storm_dam, 0, &dam_max0);
7044 if (f5 & RF5_BA_LITE) spell_damcalc(m_ptr, GF_LITE, storm_dam, 0, &dam_max0);
7045 if (f6 & RF6_HAND_DOOM) spell_damcalc(m_ptr, GF_HAND_DOOM, p_ptr->chp * 6 / 10, 0, &dam_max0);
7046 if (f6 & RF6_PSY_SPEAR) spell_damcalc(m_ptr, GF_PSY_SPEAR, powerful ? (rlev * 2 + 150) : (rlev * 3 / 2 + 100), 0, &dam_max0);
7048 if (f4 & RF4_ROCKET) spell_damcalc(m_ptr, GF_ROCKET, m_ptr->hp / 4, 800, &dam_max0);
7049 if (f4 & RF4_BR_ACID) spell_damcalc(m_ptr, GF_ACID, breath_dam_div3, 1600, &dam_max0);
7050 if (f4 & RF4_BR_ELEC) spell_damcalc(m_ptr, GF_ELEC, breath_dam_div3, 1600, &dam_max0);
7051 if (f4 & RF4_BR_FIRE) spell_damcalc(m_ptr, GF_FIRE, breath_dam_div3, 1600, &dam_max0);
7052 if (f4 & RF4_BR_COLD) spell_damcalc(m_ptr, GF_COLD, breath_dam_div3, 1600, &dam_max0);
7053 if (f4 & RF4_BR_POIS) spell_damcalc(m_ptr, GF_POIS, breath_dam_div3, 800, &dam_max0);
7054 if (f4 & RF4_BR_NETH) spell_damcalc(m_ptr, GF_NETHER, breath_dam_div6, 550, &dam_max0);
7055 if (f4 & RF4_BR_LITE) spell_damcalc(m_ptr, GF_LITE, breath_dam_div6, 400, &dam_max0);
7056 if (f4 & RF4_BR_DARK) spell_damcalc(m_ptr, GF_DARK, breath_dam_div6, 400, &dam_max0);
7057 if (f4 & RF4_BR_CONF) spell_damcalc(m_ptr, GF_CONFUSION, breath_dam_div6, 450, &dam_max0);
7058 if (f4 & RF4_BR_SOUN) spell_damcalc(m_ptr, GF_SOUND, breath_dam_div6, 450, &dam_max0);
7059 if (f4 & RF4_BR_CHAO) spell_damcalc(m_ptr, GF_CHAOS, breath_dam_div6, 600, &dam_max0);
7060 if (f4 & RF4_BR_DISE) spell_damcalc(m_ptr, GF_DISENCHANT, breath_dam_div6, 500, &dam_max0);
7061 if (f4 & RF4_BR_NEXU) spell_damcalc(m_ptr, GF_NEXUS, breath_dam_div3, 250, &dam_max0);
7062 if (f4 & RF4_BR_TIME) spell_damcalc(m_ptr, GF_TIME, breath_dam_div3, 150, &dam_max0);
7063 if (f4 & RF4_BR_INER) spell_damcalc(m_ptr, GF_INERTIA, breath_dam_div6, 200, &dam_max0);
7064 if (f4 & RF4_BR_GRAV) spell_damcalc(m_ptr, GF_GRAVITY, breath_dam_div3, 200, &dam_max0);
7065 if (f4 & RF4_BR_SHAR) spell_damcalc(m_ptr, GF_SHARDS, breath_dam_div6, 500, &dam_max0);
7066 if (f4 & RF4_BR_PLAS) spell_damcalc(m_ptr, GF_PLASMA, breath_dam_div6, 150, &dam_max0);
7067 if (f4 & RF4_BR_WALL) spell_damcalc(m_ptr, GF_FORCE, breath_dam_div6, 200, &dam_max0);
7068 if (f4 & RF4_BR_MANA) spell_damcalc(m_ptr, GF_MANA, breath_dam_div3, 250, &dam_max0);
7069 if (f4 & RF4_BR_NUKE) spell_damcalc(m_ptr, GF_NUKE, breath_dam_div3, 800, &dam_max0);
7070 if (f4 & RF4_BR_DISI) spell_damcalc(m_ptr, GF_DISINTEGRATE, breath_dam_div6, 150, &dam_max0);
7073 /* Monster melee attacks */
7074 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7076 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7080 for (m = 0; m < 4; m++)
7082 /* Skip non-attacks */
7083 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7085 /* Extract the attack info */
7086 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7087 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7089 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7093 /* Contribution from this monster */
7094 dam_max += dam_max0;
7098 /* Prevent excessive warning */
7099 if (dam_max > old_damage)
7101 old_damage = dam_max * 3 / 2;
7103 if (dam_max > p_ptr->chp / 2)
7105 object_type *o_ptr = choose_warning_item();
7107 if (o_ptr) object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7109 else strcpy(o_name, "ÂÎ"); /* Warning ability without item */
7110 msg_format("%s¤¬±Ô¤¯¿Ì¤¨¤¿¡ª", o_name);
7112 else strcpy(o_name, "body"); /* Warning ability without item */
7113 msg_format("Your %s pulsates sharply!", o_name);
7117 return get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©");
7119 return get_check("Really want to go ahead? ");
7123 else old_damage = old_damage / 2;
7125 c_ptr = &cave[yy][xx];
7126 if (((!easy_disarm && is_trap(c_ptr->feat))
7127 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7129 object_type *o_ptr = choose_warning_item();
7131 if (o_ptr) object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7133 else strcpy(o_name, "ÂÎ"); /* Warning ability without item */
7134 msg_format("%s¤¬¿Ì¤¨¤¿¡ª", o_name);
7136 else strcpy(o_name, "body"); /* Warning ability without item */
7137 msg_format("Your %s pulsates!", o_name);
7141 return get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©");
7143 return get_check("Really want to go ahead? ");
7151 static bool item_tester_hook_melee_ammo(object_type *o_ptr)
7153 switch (o_ptr->tval)
7166 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
7175 * A structure for smithing
7178 int add; /* TR flag number or special essence id */
7179 cptr add_name; /* Name of this ability */
7180 int type; /* Menu number */
7181 int essence; /* Index for carrying essences */
7182 int value; /* Needed value to add this ability */
7187 * Smithing type data for Weapon smith
7190 static essence_type essence_info[] =
7192 {TR_STR, "ÏÓÎÏ", 4, TR_STR, 20},
7193 {TR_INT, "ÃÎǽ", 4, TR_INT, 20},
7194 {TR_WIS, "¸¤µ", 4, TR_WIS, 20},
7195 {TR_DEX, "´ïÍѤµ", 4, TR_DEX, 20},
7196 {TR_CON, "Âѵ×ÎÏ", 4, TR_CON, 20},
7197 {TR_CHR, "Ì¥ÎÏ", 4, TR_CHR, 20},
7198 {TR_MAGIC_MASTERY, "ËâÎÏ»ÙÇÛ", 4, TR_MAGIC_MASTERY, 20},
7199 {TR_STEALTH, "±£Ì©", 4, TR_STEALTH, 40},
7200 {TR_SEARCH, "õº÷", 4, TR_SEARCH, 15},
7201 {TR_INFRA, "ÀÖ³°Àþ»ëÎÏ", 4, TR_INFRA, 15},
7202 {TR_TUNNEL, "ºÎ·¡", 4, TR_TUNNEL, 15},
7203 {TR_SPEED, "¥¹¥Ô¡¼¥É", 4, TR_SPEED, 12},
7204 {TR_BLOWS, "Äɲù¶·â", 1, TR_BLOWS, 20},
7205 {TR_CHAOTIC, "¥«¥ª¥¹¹¶·â", 1, TR_CHAOTIC, 15},
7206 {TR_VAMPIRIC, "µÛ·ì¹¶·â", 1, TR_VAMPIRIC, 60},
7207 {TR_IMPACT, "ÃÏ¿Ìȯư", 7, TR_IMPACT, 15},
7208 {TR_BRAND_POIS, "ÆÇ»¦", 1, TR_BRAND_POIS, 20},
7209 {TR_BRAND_ACID, "Íϲò", 1, TR_BRAND_ACID, 20},
7210 {TR_BRAND_ELEC, "ÅÅ·â", 1, TR_BRAND_ELEC, 20},
7211 {TR_BRAND_FIRE, "¾Æ´þ", 1, TR_BRAND_FIRE, 20},
7212 {TR_BRAND_COLD, "Åà·ë", 1, TR_BRAND_COLD, 20},
7213 {TR_SUST_STR, "ÏÓÎÏ°Ý»ý", 3, TR_SUST_STR, 15},
7214 {TR_SUST_INT, "ÃÎǽ°Ý»ý", 3, TR_SUST_STR, 15},
7215 {TR_SUST_WIS, "¸¤µ°Ý»ý", 3, TR_SUST_STR, 15},
7216 {TR_SUST_DEX, "´ïÍѤµ°Ý»ý", 3, TR_SUST_STR, 15},
7217 {TR_SUST_CON, "Âѵ×ÎÏ°Ý»ý", 3, TR_SUST_STR, 15},
7218 {TR_SUST_CHR, "Ì¥ÎÏ°Ý»ý", 3, TR_SUST_STR, 15},
7219 {TR_IM_ACID, "»ÀÌȱÖ", 2, TR_IM_ACID, 20},
7220 {TR_IM_ELEC, "ÅÅ·âÌȱÖ", 2, TR_IM_ACID, 20},
7221 {TR_IM_FIRE, "²Ð±êÌȱÖ", 2, TR_IM_ACID, 20},
7222 {TR_IM_COLD, "Î䵤ÌȱÖ", 2, TR_IM_ACID, 20},
7223 {TR_REFLECT, "È¿¼Í", 2, TR_REFLECT, 20},
7224 {TR_FREE_ACT, "ËãáãÃΤ餺", 3, TR_FREE_ACT, 20},
7225 {TR_HOLD_LIFE, "À¸Ì¿ÎÏ°Ý»ý", 3, TR_HOLD_LIFE, 20},
7226 {TR_RES_ACID, "ÂÑ»À", 2, TR_RES_ACID, 15},
7227 {TR_RES_ELEC, "ÂÑÅÅ·â", 2, TR_RES_ELEC, 15},
7228 {TR_RES_FIRE, "ÂѲбê", 2, TR_RES_FIRE, 15},
7229 {TR_RES_COLD, "ÂÑÎ䵤", 2, TR_RES_COLD, 15},
7230 {TR_RES_POIS, "ÂÑÆÇ", 2, TR_RES_POIS, 25},
7231 {TR_RES_FEAR, "ÂѶ²ÉÝ", 2, TR_RES_FEAR, 20},
7232 {TR_RES_LITE, "ÂÑÁ®¸÷", 2, TR_RES_LITE, 20},
7233 {TR_RES_DARK, "ÂѰŹõ", 2, TR_RES_DARK, 20},
7234 {TR_RES_BLIND, "ÂÑÌÕÌÜ", 2, TR_RES_BLIND, 20},
7235 {TR_RES_CONF, "ÂѺ®Íð", 2, TR_RES_CONF, 20},
7236 {TR_RES_SOUND, "Âѹ첻", 2, TR_RES_SOUND, 20},
7237 {TR_RES_SHARDS, "ÂÑÇËÊÒ", 2, TR_RES_SHARDS, 20},
7238 {TR_RES_NETHER, "ÂÑÃϹö", 2, TR_RES_NETHER, 20},
7239 {TR_RES_NEXUS, "ÂÑ°ø²Ìº®Íð", 2, TR_RES_NEXUS, 20},
7240 {TR_RES_CHAOS, "ÂÑ¥«¥ª¥¹", 2, TR_RES_CHAOS, 20},
7241 {TR_RES_DISEN, "ÂÑÎô²½", 2, TR_RES_DISEN, 20},
7242 {TR_SH_FIRE, "", 0, -2, 0},
7243 {TR_SH_ELEC, "", 0, -2, 0},
7244 {TR_SH_COLD, "", 0, -2, 0},
7245 {TR_NO_MAGIC, "È¿ËâË¡", 3, TR_NO_MAGIC, 15},
7246 {TR_WARNING, "·Ù¹ð", 3, TR_WARNING, 20},
7247 {TR_LEVITATION, "ÉâÍ·", 3, TR_LEVITATION, 20},
7248 {TR_LITE_1, "±Êµ×¸÷¸»", 3, TR_LITE_1, 15},
7249 {TR_LITE_2, "", 0, -2, 0},
7250 {TR_LITE_3, "", 0, -2, 0},
7251 {TR_SEE_INVIS, "²Ä»ëÆ©ÌÀ", 3, TR_SEE_INVIS, 20},
7252 {TR_TELEPATHY, "¥Æ¥ì¥Ñ¥·¡¼", 6, TR_TELEPATHY, 15},
7253 {TR_SLOW_DIGEST, "Ãپò½", 3, TR_SLOW_DIGEST, 15},
7254 {TR_REGEN, "µÞ®²óÉü", 3, TR_REGEN, 20},
7255 {TR_TELEPORT, "¥Æ¥ì¥Ý¡¼¥È", 3, TR_TELEPORT, 25},
7257 {TR_SLAY_EVIL, "¼Ù°ÇÜÂÇ", 5, TR_SLAY_EVIL, 100},
7258 {TR_KILL_EVIL, "¼Ù°ÇÜÇÜÂÇ", 0, TR_SLAY_EVIL, 60},
7259 {TR_SLAY_ANIMAL, "ưʪÇÜÂÇ", 5, TR_SLAY_ANIMAL, 20},
7260 {TR_KILL_ANIMAL, "ưʪÇÜÇÜÂÇ", 5, TR_SLAY_ANIMAL, 60},
7261 {TR_SLAY_UNDEAD, "ÉÔ»àÇÜÂÇ", 5, TR_SLAY_UNDEAD, 20},
7262 {TR_KILL_UNDEAD, "ÉÔ»àÇÜÇÜÂÇ", 5, TR_SLAY_UNDEAD, 60},
7263 {TR_SLAY_DEMON, "°ËâÇÜÂÇ", 5, TR_SLAY_DEMON, 20},
7264 {TR_KILL_DEMON, "°ËâÇÜÇÜÂÇ", 5, TR_SLAY_DEMON, 60},
7265 {TR_SLAY_ORC, "¥ª¡¼¥¯ÇÜÂÇ", 5, TR_SLAY_ORC, 15},
7266 {TR_KILL_ORC, "¥ª¡¼¥¯ÇÜÇÜÂÇ", 5, TR_SLAY_ORC, 60},
7267 {TR_SLAY_TROLL, "¥È¥í¥ëÇÜÂÇ", 5, TR_SLAY_TROLL, 15},
7268 {TR_KILL_TROLL, "¥È¥í¥ëÇÜÇÜÂÇ", 5, TR_SLAY_TROLL, 60},
7269 {TR_SLAY_GIANT, "µð¿ÍÇÜÂÇ", 5, TR_SLAY_GIANT, 20},
7270 {TR_KILL_GIANT, "µð¿ÍÇÜÇÜÂÇ", 5, TR_SLAY_GIANT, 60},
7271 {TR_SLAY_DRAGON, "εÇÜÂÇ", 5, TR_SLAY_DRAGON, 20},
7272 {TR_KILL_DRAGON, "εÇÜÇÜÂÇ", 5, TR_SLAY_DRAGON, 60},
7273 {TR_SLAY_HUMAN, "¿Í´ÖÇÜÂÇ", 5, TR_SLAY_HUMAN, 20},
7274 {TR_KILL_HUMAN, "¿Í´ÖÇÜÇÜÂÇ", 5, TR_SLAY_HUMAN, 60},
7276 {TR_ESP_ANIMAL, "ưʪESP", 6, TR_SLAY_ANIMAL, 40},
7277 {TR_ESP_UNDEAD, "ÉÔ»àESP", 6, TR_SLAY_UNDEAD, 40},
7278 {TR_ESP_DEMON, "°ËâESP", 6, TR_SLAY_DEMON, 40},
7279 {TR_ESP_ORC, "¥ª¡¼¥¯ESP", 6, TR_SLAY_ORC, 40},
7280 {TR_ESP_TROLL, "¥È¥í¥ëESP", 6, TR_SLAY_TROLL, 40},
7281 {TR_ESP_GIANT, "µð¿ÍESP", 6, TR_SLAY_GIANT, 40},
7282 {TR_ESP_DRAGON, "εESP", 6, TR_SLAY_DRAGON, 40},
7283 {TR_ESP_HUMAN, "¿Í´ÖESP", 6, TR_SLAY_HUMAN, 40},
7285 {ESSENCE_ATTACK, "¹¶·â", 10, TR_ES_ATTACK, 30},
7286 {ESSENCE_AC, "Ëɸæ", 10, TR_ES_AC, 15},
7287 {ESSENCE_TMP_RES_ACID, "»ÀÂÑÀȯư", 7, TR_RES_ACID, 50},
7288 {ESSENCE_TMP_RES_ELEC, "ÅÅ·âÂÑÀȯư", 7, TR_RES_ELEC, 50},
7289 {ESSENCE_TMP_RES_FIRE, "²Ð±êÂÑÀȯư", 7, TR_RES_FIRE, 50},
7290 {ESSENCE_TMP_RES_COLD, "Î䵤ÂÑÀȯư", 7, TR_RES_COLD, 50},
7291 {ESSENCE_SH_FIRE, "²Ð±ê¥ª¡¼¥é", 7, -1, 50},
7292 {ESSENCE_SH_ELEC, "Åŷ⥪¡¼¥é", 7, -1, 50},
7293 {ESSENCE_SH_COLD, "Î䵤¥ª¡¼¥é", 7, -1, 50},
7294 {ESSENCE_RESISTANCE, "Á´ÂÑÀ", 2, -1, 150},
7295 {ESSENCE_SUSTAIN, "ÁõÈ÷ÊÝ»ý", 10, -1, 10},
7296 {ESSENCE_SLAY_GLOVE, "»¦Ù¤¤Î¾®¼ê", 1, TR_ES_ATTACK, 200},
7298 {-1, NULL, 0, -1, 0}
7301 static essence_type essence_info[] =
7303 {TR_STR, "strength", 4, TR_STR, 20},
7304 {TR_INT, "intelligence", 4, TR_INT, 20},
7305 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7306 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7307 {TR_CON, "constitution", 4, TR_CON, 20},
7308 {TR_CHR, "charisma", 4, TR_CHR, 20},
7309 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7310 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7311 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7312 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7313 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7314 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7315 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7316 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7317 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7318 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7319 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7320 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7321 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7322 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7323 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7324 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7325 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7326 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7327 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7328 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7329 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7330 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7331 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7332 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7333 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7334 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7335 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7336 {TR_HOLD_LIFE, "hold life", 3, TR_HOLD_LIFE, 20},
7337 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7338 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7339 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7340 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7341 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7342 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7343 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7344 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7345 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7346 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7347 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7348 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7349 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7350 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7351 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7352 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7353 {TR_SH_FIRE, "", 0, -2, 0},
7354 {TR_SH_ELEC, "", 0, -2, 0},
7355 {TR_SH_COLD, "", 0, -2, 0},
7356 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7357 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7358 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7359 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7360 {TR_LITE_2, "", 0, -2, 0},
7361 {TR_LITE_3, "", 0, -2, 0},
7362 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7363 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7364 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7365 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7366 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7368 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7369 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7370 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7371 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7372 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7373 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7374 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7375 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7376 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7377 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7378 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7379 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7380 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7381 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7382 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7383 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7384 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7385 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7387 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7388 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7389 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7390 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7391 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7392 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7393 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7394 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7396 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7397 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7398 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7399 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7400 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7401 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7402 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7403 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7404 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7405 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7406 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7407 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7409 {-1, NULL, 0, -1, 0}
7415 * Essense names for Weapon smith
7418 cptr essence_name[] =
7521 static cptr essence_name[] =
7624 static void display_essence(void)
7629 for (i = 1; i < 22; i++)
7634 prt("¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô", 1, 8);
7636 prt("Essence Num Essence Num Essence Num ", 1, 8);
7638 for (i = 0; essence_name[i]; i++)
7640 if (!essence_name[i][0]) continue;
7641 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7645 prt("¸½ºß½ê»ý¤·¤Æ¤¤¤ë¥¨¥Ã¥»¥ó¥¹", 0, 0);
7647 prt("List of all essences you have.", 0, 0);
7654 static void drain_essence(void)
7656 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7659 bool observe = FALSE;
7660 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2, old_timeout;
7661 u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7664 byte iy, ix, marked, number;
7665 s16b next_o_idx, weight;
7667 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7670 item_tester_hook = object_is_weapon_armour_ammo;
7671 item_tester_no_ryoute = TRUE;
7675 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éÃê½Ð¤·¤Þ¤¹¤«¡©";
7676 s = "Ãê½Ð¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
7678 q = "Extract from which item? ";
7679 s = "You have nothing you can extract from.";
7682 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7684 /* Get the item (in the pack) */
7687 o_ptr = &inventory[item];
7690 /* Get the item (on the floor) */
7693 o_ptr = &o_list[0 - item];
7696 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7698 char o_name[MAX_NLEN];
7699 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7701 if (!get_check(format("ËÜÅö¤Ë%s¤«¤éÃê½Ð¤·¤Æ¤è¤í¤·¤¤¤Ç¤¹¤«¡©", o_name))) return;
7703 if (!get_check(format("Really extract from %s? ", o_name))) return;
7709 object_flags(o_ptr, old_flgs);
7710 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7711 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7712 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7713 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7714 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7715 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7716 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7717 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7718 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7720 old_to_a = o_ptr->to_a;
7722 old_to_h = o_ptr->to_h;
7723 old_to_d = o_ptr->to_d;
7726 old_pval = o_ptr->pval;
7727 old_name2 = o_ptr->name2;
7728 old_timeout = o_ptr->timeout;
7729 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7730 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7731 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7732 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7733 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7734 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7735 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7736 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7737 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7738 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7739 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7740 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7741 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7742 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7743 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7744 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7745 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7746 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7747 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7751 next_o_idx = o_ptr->next_o_idx;
7752 marked = o_ptr->marked;
7753 weight = o_ptr->weight;
7754 number = o_ptr->number;
7756 object_prep(o_ptr, o_ptr->k_idx);
7760 o_ptr->next_o_idx=next_o_idx;
7761 o_ptr->marked=marked;
7762 o_ptr->number = number;
7763 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7764 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7765 o_ptr->ident |= (IDENT_MENTAL);
7766 object_aware(o_ptr);
7767 object_known(o_ptr);
7769 object_flags(o_ptr, new_flgs);
7771 for (i = 0; essence_info[i].add_name; i++)
7773 essence_type *es_ptr = &essence_info[i];
7776 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7777 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7779 if (es_ptr->add < TR_FLAG_MAX &&
7780 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7781 have_flag(old_flgs, es_ptr->add))
7785 drain_value[es_ptr->essence] += 10 * pval;
7787 else if (es_ptr->essence != -2)
7789 drain_value[es_ptr->essence] += 10;
7791 else if (es_ptr->add == TR_SH_FIRE)
7793 drain_value[TR_BRAND_FIRE] += 10;
7794 drain_value[TR_RES_FIRE] += 10;
7796 else if (es_ptr->add == TR_SH_ELEC)
7798 drain_value[TR_BRAND_ELEC] += 10;
7799 drain_value[TR_RES_ELEC] += 10;
7801 else if (es_ptr->add == TR_SH_COLD)
7803 drain_value[TR_BRAND_COLD] += 10;
7804 drain_value[TR_RES_COLD] += 10;
7806 else if (es_ptr->add == TR_LITE_2)
7808 drain_value[TR_LITE_1] += 20;
7810 else if (es_ptr->add == TR_LITE_3)
7812 drain_value[TR_LITE_1] += 30;
7817 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7819 drain_value[TR_INT] += 5;
7820 drain_value[TR_WIS] += 5;
7822 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7824 drain_value[TR_BRAND_POIS] += 5;
7825 drain_value[TR_BRAND_ACID] += 5;
7826 drain_value[TR_BRAND_ELEC] += 5;
7827 drain_value[TR_BRAND_FIRE] += 5;
7828 drain_value[TR_BRAND_COLD] += 5;
7830 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7832 drain_value[TR_INT] += 10;
7834 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7836 drain_value[TR_STR] += 10;
7838 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7840 drain_value[TR_DEX] += 10;
7842 if (old_name2 == EGO_2WEAPON)
7844 drain_value[TR_DEX] += 20;
7846 if (object_is_weapon_ammo(o_ptr))
7848 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7850 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7852 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7853 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7854 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7855 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7857 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7859 drain_value[i] *= number;
7860 drain_value[i] = drain_value[i] * dec / 4;
7861 drain_value[i] = MAX(drain_value[i], 0);
7862 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7870 msg_print(_("¥¨¥Ã¥»¥ó¥¹¤ÏÃê½Ð¤Ç¤¤Þ¤»¤ó¤Ç¤·¤¿¡£", "You were not able to extract any essence."));
7874 msg_print(_("Ãê½Ð¤·¤¿¥¨¥Ã¥»¥ó¥¹:", "Extracted essences:"));
7876 for (i = 0; essence_name[i]; i++)
7878 if (!essence_name[i][0]) continue;
7879 if (!drain_value[i]) continue;
7881 p_ptr->magic_num1[i] += drain_value[i];
7882 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7884 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("¡£", ". "));
7888 /* Apply autodestroy/inscription to the drained item */
7889 autopick_alter_item(item, TRUE);
7891 /* Combine the pack */
7892 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7895 p_ptr->window |= (PW_INVEN);
7900 static int choose_essence(void)
7904 int menu_line = (use_menu ? 1 : 0);
7907 cptr menu_name[] = {
7917 cptr menu_name[] = {
7927 const int mode_max = 7;
7930 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
7933 #endif /* ALLOW_REPEAT */
7942 for (i = 0; i < mode_max; i++)
7944 prt(format(" %s %s", (menu_line == 1+i) ? "¡Õ" : " ", menu_name[i]), 2 + i, 14);
7945 prt("¤É¤Î¼ïÎà¤Î¥¨¥Ã¥»¥ó¥¹Éղäò¹Ô¤¤¤Þ¤¹¤«¡©", 0, 0);
7947 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
7948 prt("Choose from menu.", 0, 0);
7967 menu_line += mode_max - 1;
7976 if (menu_line > mode_max) menu_line -= mode_max;
7987 for (i = 0; i < mode_max; i++)
7988 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
7991 if (!get_com("²¿¤òÉղä·¤Þ¤¹¤«:", &choice, TRUE))
7993 if (!get_com("Command :", &choice, TRUE))
8000 if (isupper(choice)) choice = tolower(choice);
8002 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8003 mode = (int)choice - 'a' + 1;
8010 #endif /* ALLOW_REPEAT */
8014 static void add_essence(int mode)
8016 int item, max_num = 0;
8025 char o_name[MAX_NLEN];
8027 essence_type *es_ptr;
8029 int menu_line = (use_menu ? 1 : 0);
8031 for (i = 0; essence_info[i].add_name; i++)
8033 es_ptr = &essence_info[i];
8035 if (es_ptr->type != mode) continue;
8040 if (!repeat_pull(&i) || i<0 || i>=max_num)
8042 #endif /* ALLOW_REPEAT */
8045 /* Nothing chosen yet */
8051 /* Build a prompt */
8053 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎǽÎϤòÉղä·¤Þ¤¹¤«¡©");
8055 (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Add which ability? ");
8057 if (use_menu) screen_save();
8059 /* Get a spell from the user */
8061 choice = (always_show_list || use_menu) ? ESCAPE:1;
8065 if( choice==ESCAPE ) choice = ' ';
8066 else if( !get_com(out_val, &choice, FALSE) )break;
8068 if (use_menu && choice != ' ')
8082 menu_line += (max_num-1);
8105 menu_line = max_num;
8119 if (menu_line > max_num) menu_line -= max_num;
8121 /* Request redraw */
8122 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8125 if (!redraw || use_menu)
8129 char dummy[80], dummy2[80];
8137 /* Save the screen */
8138 if (!use_menu) screen_save();
8140 for (y = 1; y < 24; y++)
8143 /* Print header(s) */
8145 prt(format(" %-43s %6s/%s", "ǽÎÏ(ɬÍ×¥¨¥Ã¥»¥ó¥¹)", "ɬÍ׿ô", "½ê»ý¿ô"), 1, x);
8148 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8151 for (ctr = 0; ctr < max_num; ctr++)
8153 es_ptr = &essence_info[num[ctr]];
8157 if (ctr == (menu_line-1))
8159 strcpy(dummy, "¡Õ ");
8161 strcpy(dummy, "> ");
8163 else strcpy(dummy, " ");
8166 /* letter/number for power selection */
8169 sprintf(dummy, "%c) ",I2A(ctr));
8172 strcat(dummy, es_ptr->add_name);
8177 if (es_ptr->essence != -1)
8179 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8180 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8186 case ESSENCE_SH_FIRE:
8188 strcat(dummy, "(¾Æ´þ+ÂѲбê)");
8190 strcat(dummy, "(brand fire + res.fire)");
8192 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8193 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8195 case ESSENCE_SH_ELEC:
8197 strcat(dummy, "(ÅÅ·â+ÂÑÅÅ·â)");
8199 strcat(dummy, "(brand elec. + res. elec.)");
8201 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8202 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8204 case ESSENCE_SH_COLD:
8206 strcat(dummy, "(Åà·ë+ÂÑÎ䵤)");
8208 strcat(dummy, "(brand cold + res. cold)");
8210 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8211 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8213 case ESSENCE_RESISTANCE:
8215 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
8217 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
8219 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8220 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8221 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8222 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8224 case ESSENCE_SUSTAIN:
8226 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
8228 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
8230 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8231 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8232 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8233 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8238 if (!able[ctr]) col = TERM_RED;
8240 if (es_ptr->essence != -1)
8242 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8246 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8249 c_prt(col, dummy2, ctr+2, x);
8259 /* Restore the screen */
8270 ask = (isupper(choice));
8273 if (ask) choice = tolower(choice);
8275 /* Extract request */
8276 i = (islower(choice) ? A2I(choice) : -1);
8279 /* Totally Illegal */
8280 if ((i < 0) || (i >= max_num) || !able[i])
8293 (void) strnfmt(tmp_val, 78, "%s¤òÉղä·¤Þ¤¹¤«¡© ", essence_info[num[i]].add_name);
8295 (void) strnfmt(tmp_val, 78, "Add the abilitiy of %s? ", essence_info[num[i]].add_name);
8298 /* Belay that order */
8299 if (!get_check(tmp_val)) continue;
8306 /* Restore the screen */
8307 if (redraw) screen_load();
8314 #endif /* ALLOW_REPEAT */
8316 es_ptr = &essence_info[num[i]];
8318 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8319 item_tester_tval = TV_GLOVES;
8320 else if (mode == 1 || mode == 5)
8321 item_tester_hook = item_tester_hook_melee_ammo;
8322 else if (es_ptr->add == ESSENCE_ATTACK)
8323 item_tester_hook = object_allow_enchant_weapon;
8324 else if (es_ptr->add == ESSENCE_AC)
8325 item_tester_hook = object_is_armour;
8327 item_tester_hook = object_is_weapon_armour_ammo;
8328 item_tester_no_ryoute = TRUE;
8332 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
8333 s = "²þÎɤǤ¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
8335 q = "Improve which item? ";
8336 s = "You have nothing to improve.";
8339 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8341 /* Get the item (in the pack) */
8344 o_ptr = &inventory[item];
8347 /* Get the item (on the floor) */
8350 o_ptr = &o_list[0 - item];
8353 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8356 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï¤³¤ì°Ê¾å²þÎɤǤ¤Ê¤¤¡£");
8358 msg_print("This item is no more able to be improved.");
8363 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8365 use_essence = es_ptr->value;
8366 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8367 if (o_ptr->number > 1)
8369 use_essence *= o_ptr->number;
8371 msg_format("%d¸Ä¤¢¤ë¤Î¤Ç¥¨¥Ã¥»¥ó¥¹¤Ï%dɬÍפǤ¹¡£", o_ptr->number, use_essence);
8373 msg_format("It will take %d essences.",use_essence);
8378 if (es_ptr->essence != -1)
8380 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8383 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
8385 msg_print("You don't have enough essences.");
8389 if (is_pval_flag(es_ptr->add))
8391 if (o_ptr->pval < 0)
8394 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤ÎǽÎϽ¤Àµ¤ò¶¯²½¤¹¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£");
8396 msg_print("You cannot increase magic number of this item.");
8400 else if (es_ptr->add == TR_BLOWS)
8402 if (o_ptr->pval > 1)
8405 if (!get_check("½¤ÀµÃͤÏ1¤Ë¤Ê¤ê¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) return;
8407 if (!get_check("The magic number of this weapon will become 1. Are you sure? ")) return;
8413 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
8415 msg_format("It will take %d essences.", use_essence);
8418 else if (o_ptr->pval > 0)
8420 use_essence *= o_ptr->pval;
8422 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
8424 msg_format("It will take %d essences.", use_essence);
8432 int limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8435 sprintf(tmp, "¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d): ", limit);
8437 sprintf(tmp, "Enchant how many? (1-%d): ", limit);
8439 strcpy(tmp_val, "1");
8441 if (!get_string(tmp, tmp_val, 1)) return;
8442 pval = atoi(tmp_val);
8443 if (pval > limit) pval = limit;
8444 else if (pval < 1) pval = 1;
8445 o_ptr->pval += pval;
8446 use_essence *= pval;
8448 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
8450 msg_format("It will take %d essences.", use_essence);
8454 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8457 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
8459 msg_print("You don't have enough essences.");
8464 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8468 int get_to_h, get_to_d;
8470 strcpy(tmp_val, "1");
8472 if (!get_string(format("¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
8474 if (!get_string(format("Enchant how many? (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
8476 val = atoi(tmp_val);
8477 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8478 else if (val < 1) val = 1;
8481 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
8483 msg_format("It will take %d essences.", use_essence);
8485 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8488 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
8490 msg_print("You don't have enough essences.");
8494 get_to_h = ((val+1)/2+randint0(val/2+1));
8495 get_to_d = ((val+1)/2+randint0(val/2+1));
8496 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8497 o_ptr->to_h += get_to_h;
8498 o_ptr->to_d += get_to_d;
8500 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8501 if (es_ptr->add == ESSENCE_ATTACK)
8503 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8506 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
8508 msg_print("You failed to enchant.");
8515 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8516 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8519 else if (es_ptr->add == ESSENCE_AC)
8521 if (o_ptr->to_a >= p_ptr->lev/5+5)
8524 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
8526 msg_print("You failed to enchant.");
8533 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8538 o_ptr->xtra3 = es_ptr->add + 1;
8543 bool success = TRUE;
8547 case ESSENCE_SH_FIRE:
8548 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8553 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8554 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8556 case ESSENCE_SH_ELEC:
8557 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8562 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8563 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8565 case ESSENCE_SH_COLD:
8566 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8571 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8572 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8574 case ESSENCE_RESISTANCE:
8575 case ESSENCE_SUSTAIN:
8576 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))
8581 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8582 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8583 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8584 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8590 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
8592 msg_print("You don't have enough essences.");
8596 if (es_ptr->add == ESSENCE_SUSTAIN)
8598 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8599 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8600 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8601 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8605 o_ptr->xtra3 = es_ptr->add + 1;
8612 msg_format("%s¤Ë%s¤ÎǽÎϤòÉղä·¤Þ¤·¤¿¡£", o_name, es_ptr->add_name);
8614 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8617 /* Combine the pack */
8618 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8621 p_ptr->window |= (PW_INVEN);
8625 static void erase_essence(void)
8630 char o_name[MAX_NLEN];
8631 u32b flgs[TR_FLAG_SIZE];
8633 item_tester_hook = object_is_smith;
8637 q = "¤É¤Î¥¢¥¤¥Æ¥à¤Î¥¨¥Ã¥»¥ó¥¹¤ò¾Ãµî¤·¤Þ¤¹¤«¡©";
8638 s = "¥¨¥Ã¥»¥ó¥¹¤òÉղä·¤¿¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
8640 q = "Remove from which item? ";
8641 s = "You have nothing to remove essence.";
8644 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8646 /* Get the item (in the pack) */
8649 o_ptr = &inventory[item];
8652 /* Get the item (on the floor) */
8655 o_ptr = &o_list[0 - item];
8658 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8660 if (!get_check(format("¤è¤í¤·¤¤¤Ç¤¹¤«¡© [%s]", o_name))) return;
8662 if (!get_check(format("Are you sure? [%s]", o_name))) return;
8667 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8669 o_ptr->to_h -= (o_ptr->xtra4>>8);
8670 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8672 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8673 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8676 object_flags(o_ptr, flgs);
8677 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8679 msg_print("¥¨¥Ã¥»¥ó¥¹¤ò¼è¤êµî¤Ã¤¿¡£");
8681 msg_print("You removed all essence you have added.");
8684 /* Combine the pack */
8685 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8688 p_ptr->window |= (PW_INVEN);
8691 void do_cmd_kaji(bool only_browse)
8696 int menu_line = (use_menu ? 1 : 0);
8700 if (p_ptr->confused)
8703 msg_print("º®Í𤷤Ƥ¤¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
8705 msg_print("You are too confused!");
8713 msg_print("Ìܤ¬¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
8715 msg_print("You are blind!");
8723 msg_print("¤¦¤Þ¤¯¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
8725 msg_print("You are hallucinating!");
8733 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8735 #endif /* ALLOW_REPEAT */
8737 if (only_browse) screen_save();
8739 if (!only_browse) screen_save();
8745 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", (menu_line == 1) ? "¡Õ" : " "), 2, 14);
8746 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", (menu_line == 2) ? "¡Õ" : " "), 3, 14);
8747 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹¾Ãµî", (menu_line == 3) ? "¡Õ" : " "), 4, 14);
8748 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", (menu_line == 4) ? "¡Õ" : " "), 5, 14);
8749 prt(format(" %s Éð´ï/Ëɶñ¶¯²½", (menu_line == 5) ? "¡Õ" : " "), 6, 14);
8750 prt(format("¤É¤Î¼ïÎà¤Îµ»½Ñ¤ò%s¤Þ¤¹¤«¡©", only_browse ? "Ä´¤Ù" : "»È¤¤"), 0, 0);
8752 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8753 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8754 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8755 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8756 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8757 prt(format("Choose command from menu."), 0, 0);
8784 if (menu_line > 5) menu_line -= 5;
8793 prt(" a) ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", 2, 14);
8794 prt(" b) ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", 3, 14);
8795 prt(" c) ¥¨¥Ã¥»¥ó¥¹¾Ãµî", 4, 14);
8796 prt(" d) ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", 5, 14);
8797 prt(" e) Éð´ï/Ëɶñ¶¯²½", 6, 14);
8798 if (!get_com(format("¤É¤ÎǽÎϤò%s¤Þ¤¹¤«:", only_browse ? "Ä´¤Ù" : "»È¤¤"), &choice, TRUE))
8800 prt(" a) List essences", 2, 14);
8801 prt(" b) Extract essence", 3, 14);
8802 prt(" c) Remove essence", 4, 14);
8803 prt(" d) Add essence", 5, 14);
8804 prt(" e) Enchant weapon/armor", 6, 14);
8805 if (!get_com("Command :", &choice, TRUE))
8842 /* Clear lines, position cursor (really should use strlen here) */
8843 Term_erase(14, 21, 255);
8844 Term_erase(14, 20, 255);
8845 Term_erase(14, 19, 255);
8846 Term_erase(14, 18, 255);
8847 Term_erase(14, 17, 255);
8848 Term_erase(14, 16, 255);
8850 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8851 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8853 prt(&temp[j], line, 15);
8858 if (!only_browse) screen_load();
8859 } while (only_browse);
8863 #endif /* ALLOW_REPEAT */
8867 case 1: display_essence();break;
8868 case 2: drain_essence();break;
8869 case 3: erase_essence();break;
8871 mode = choose_essence();
8876 case 5: add_essence(10);break;
8882 * Torches have special abilities when they are flaming.
8884 void torch_flags(object_type *o_ptr, u32b *flgs)
8886 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8888 if (o_ptr->xtra4 > 0)
8890 add_flag(flgs, TR_BRAND_FIRE);
8891 add_flag(flgs, TR_KILL_UNDEAD);
8892 add_flag(flgs, TR_THROW);
8897 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8899 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8901 if (o_ptr->xtra4 > 0)
8909 void torch_lost_fuel(object_type *o_ptr)
8911 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8913 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8914 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;