3 /* Purpose: Object code, part 2 */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
19 * Excise a dungeon object from any stacks
21 void excise_object_idx(int o_idx)
25 s16b this_o_idx, next_o_idx = 0;
31 j_ptr = &o_list[o_idx];
34 if (j_ptr->held_m_idx)
39 m_ptr = &m_list[j_ptr->held_m_idx];
41 /* Scan all objects in the grid */
42 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
47 o_ptr = &o_list[this_o_idx];
49 /* Acquire next object */
50 next_o_idx = o_ptr->next_o_idx;
53 if (this_o_idx == o_idx)
58 /* Remove from list */
59 m_ptr->hold_o_idx = next_o_idx;
68 k_ptr = &o_list[prev_o_idx];
70 /* Remove from list */
71 k_ptr->next_o_idx = next_o_idx;
74 /* Forget next pointer */
75 o_ptr->next_o_idx = 0;
82 prev_o_idx = this_o_idx;
97 /* Scan all objects in the grid */
98 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
103 o_ptr = &o_list[this_o_idx];
105 /* Acquire next object */
106 next_o_idx = o_ptr->next_o_idx;
109 if (this_o_idx == o_idx)
114 /* Remove from list */
115 c_ptr->o_idx = next_o_idx;
123 /* Previous object */
124 k_ptr = &o_list[prev_o_idx];
126 /* Remove from list */
127 k_ptr->next_o_idx = next_o_idx;
130 /* Forget next pointer */
131 o_ptr->next_o_idx = 0;
137 /* Save prev_o_idx */
138 prev_o_idx = this_o_idx;
145 * Delete a dungeon object
147 * Handle "stacks" of objects correctly.
149 void delete_object_idx(int o_idx)
154 excise_object_idx(o_idx);
157 j_ptr = &o_list[o_idx];
160 if (!(j_ptr->held_m_idx))
172 /* Wipe the object */
181 * Deletes all objects at given location
183 void delete_object(int y, int x)
187 s16b this_o_idx, next_o_idx = 0;
190 /* Refuse "illegal" locations */
191 if (!in_bounds(y, x)) return;
197 /* Scan all objects in the grid */
198 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
203 o_ptr = &o_list[this_o_idx];
205 /* Acquire next object */
206 next_o_idx = o_ptr->next_o_idx;
208 /* Wipe the object */
215 /* Objects are gone */
224 * Move an object from index i1 to index i2 in the object list
226 static void compact_objects_aux(int i1, int i2)
236 if (i1 == i2) return;
240 for (i = 1; i < o_max; i++)
245 /* Skip "dead" objects */
246 if (!o_ptr->k_idx) continue;
248 /* Repair "next" pointers */
249 if (o_ptr->next_o_idx == i1)
252 o_ptr->next_o_idx = i2;
262 if (o_ptr->held_m_idx)
266 /* Acquire monster */
267 m_ptr = &m_list[o_ptr->held_m_idx];
270 if (m_ptr->hold_o_idx == i1)
273 m_ptr->hold_o_idx = i2;
282 /* Acquire location */
290 if (c_ptr->o_idx == i1)
299 o_list[i2] = o_list[i1];
307 * Compact and Reorder the object list
309 * This function can be very dangerous, use with caution!
311 * When actually "compacting" objects, we base the saving throw on a
312 * combination of object level, distance from player, and current
315 * After "compacting" (if needed), we "reorder" the objects into a more
316 * compact order, and we reset the allocation info, and the "live" array.
318 void compact_objects(int size)
320 int i, y, x, num, cnt;
321 int cur_lev, cur_dis, chance;
330 msg_print("¥¢¥¤¥Æ¥à¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
332 msg_print("Compacting objects...");
337 p_ptr->redraw |= (PR_MAP);
340 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
344 /* Compact at least 'size' objects */
345 for (num = 0, cnt = 1; num < size; cnt++)
347 /* Get more vicious each iteration */
350 /* Get closer each iteration */
351 cur_dis = 5 * (20 - cnt);
353 /* Examine the objects */
354 for (i = 1; i < o_max; i++)
358 /* Skip dead objects */
359 if (!o_ptr->k_idx) continue;
361 /* Hack -- High level objects start out "immune" */
362 if (get_object_level(o_ptr) > cur_lev) continue;
365 if (o_ptr->held_m_idx)
369 /* Acquire monster */
370 m_ptr = &m_list[o_ptr->held_m_idx];
372 /* Get the location */
376 /* Monsters protect their objects */
377 if (randint0(100) < 90) continue;
383 /* Get the location */
388 /* Nearby objects start out "immune" */
389 if ((cur_dis > 0) && (distance(py, px, y, x) < cur_dis)) continue;
394 /* Hack -- only compact artifacts in emergencies */
395 if ((artifact_p(o_ptr) || o_ptr->art_name) &&
396 (cnt < 1000)) chance = 100;
398 /* Apply the saving throw */
399 if (randint0(100) < chance) continue;
401 /* Delete the object */
402 delete_object_idx(i);
410 /* Excise dead objects (backwards!) */
411 for (i = o_max - 1; i >= 1; i--)
415 /* Skip real objects */
416 if (o_ptr->k_idx) continue;
418 /* Move last object into open hole */
419 compact_objects_aux(o_max - 1, i);
421 /* Compress "o_max" */
428 * Delete all the items when player leaves the level
430 * Note -- we do NOT visually reflect these (irrelevant) changes
432 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
433 * and the "m_ptr->next_o_idx" field for every monster, since
434 * we know we are clearing every object. Technically, we only
435 * clear those fields for grids/monsters containing objects,
436 * and we clear it once for every such object.
438 void wipe_o_list(void)
442 /* Delete the existing objects */
443 for (i = 1; i < o_max; i++)
445 object_type *o_ptr = &o_list[i];
447 /* Skip dead objects */
448 if (!o_ptr->k_idx) continue;
450 /* Mega-Hack -- preserve artifacts */
451 if (!character_dungeon || preserve_mode)
453 /* Hack -- Preserve unknown artifacts */
454 if (artifact_p(o_ptr) && !object_known_p(o_ptr))
456 /* Mega-Hack -- Preserve the artifact */
457 a_info[o_ptr->name1].cur_num = 0;
462 if (o_ptr->held_m_idx)
467 m_ptr = &m_list[o_ptr->held_m_idx];
469 /* Hack -- see above */
470 m_ptr->hold_o_idx = 0;
478 /* Access location */
485 /* Hack -- see above */
489 /* Wipe the object */
502 * Acquires and returns the index of a "free" object.
504 * This routine should almost never fail, but in case it does,
505 * we must be sure to handle "failure" of this routine.
512 /* Initial allocation */
513 if (o_max < max_o_idx)
518 /* Expand object array */
524 /* Use this object */
529 /* Recycle dead objects */
530 for (i = 1; i < o_max; i++)
537 /* Skip live objects */
538 if (o_ptr->k_idx) continue;
543 /* Use this object */
548 /* Warn the player (except during dungeon creation) */
550 if (character_dungeon) msg_print("¥¢¥¤¥Æ¥à¤¬Â¿¤¹¤®¤ë¡ª");
552 if (character_dungeon) msg_print("Too many objects!");
562 * Apply a "object restriction function" to the "object allocation table"
564 errr get_obj_num_prep(void)
569 alloc_entry *table = alloc_kind_table;
571 /* Scan the allocation table */
572 for (i = 0; i < alloc_kind_size; i++)
574 /* Accept objects which pass the restriction, if any */
575 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
577 /* Accept this object */
578 table[i].prob2 = table[i].prob1;
581 /* Do not use this object */
584 /* Decline this object */
595 * Choose an object kind that seems "appropriate" to the given level
597 * This function uses the "prob2" field of the "object allocation table",
598 * and various local information, to calculate the "prob3" field of the
599 * same table, which is then used to choose an "appropriate" object, in
600 * a relatively efficient manner.
602 * It is (slightly) more likely to acquire an object of the given level
603 * than one of a lower level. This is done by choosing several objects
604 * appropriate to the given level and keeping the "hardest" one.
606 * Note that if no objects are "appropriate", then this function will
607 * fail, and return zero, but this should *almost* never happen.
609 s16b get_obj_num(int level)
615 alloc_entry *table = alloc_kind_table;
617 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
620 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
622 /* Occasional "boost" */
623 if (one_in_(GREAT_OBJ))
625 /* What a bizarre calculation */
626 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
633 /* Process probabilities */
634 for (i = 0; i < alloc_kind_size; i++)
636 /* Objects are sorted by depth */
637 if (table[i].level > level) break;
642 /* Access the index */
643 k_idx = table[i].index;
645 /* Access the actual kind */
646 k_ptr = &k_info[k_idx];
648 /* Hack -- prevent embedded chests */
649 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
652 table[i].prob3 = table[i].prob2;
655 total += table[i].prob3;
658 /* No legal objects */
659 if (total <= 0) return (0);
663 value = randint0(total);
665 /* Find the object */
666 for (i = 0; i < alloc_kind_size; i++)
668 /* Found the entry */
669 if (value < table[i].prob3) break;
672 value = value - table[i].prob3;
679 /* Try for a "better" object once (50%) or twice (10%) */
686 value = randint0(total);
688 /* Find the object */
689 for (i = 0; i < alloc_kind_size; i++)
691 /* Found the entry */
692 if (value < table[i].prob3) break;
695 value = value - table[i].prob3;
698 /* Keep the "best" one */
699 if (table[i].level < table[j].level) i = j;
702 /* Try for a "better" object twice (10%) */
709 value = randint0(total);
711 /* Find the object */
712 for (i = 0; i < alloc_kind_size; i++)
714 /* Found the entry */
715 if (value < table[i].prob3) break;
718 value = value - table[i].prob3;
721 /* Keep the "best" one */
722 if (table[i].level < table[j].level) i = j;
727 return (table[i].index);
732 * Known is true when the "attributes" of an object are "known".
733 * These include tohit, todam, toac, cost, and pval (charges).
735 * Note that "knowing" an object gives you everything that an "awareness"
736 * gives you, and much more. In fact, the player is always "aware" of any
737 * item of which he has full "knowledge".
739 * But having full knowledge of, say, one "wand of wonder", does not, by
740 * itself, give you knowledge, or even awareness, of other "wands of wonder".
741 * It happens that most "identify" routines (including "buying from a shop")
742 * will make the player "aware" of the object as well as fully "know" it.
744 * This routine also removes any inscriptions generated by "feelings".
746 void object_known(object_type *o_ptr)
748 /* Remove "default inscriptions" */
749 o_ptr->feeling = FEEL_NONE;
751 /* Clear the "Felt" info */
752 o_ptr->ident &= ~(IDENT_SENSE);
754 /* Clear the "Empty" info */
755 o_ptr->ident &= ~(IDENT_EMPTY);
757 /* Now we know about the item */
758 o_ptr->ident |= (IDENT_KNOWN);
763 * The player is now aware of the effects of the given object.
765 void object_aware(object_type *o_ptr)
767 bool mihanmei = !object_aware_p(o_ptr);
769 #ifndef SCRIPT_OBJ_KIND
770 /* Fully aware of the effects */
771 k_info[o_ptr->k_idx].aware = TRUE;
772 #else /* SCRIPT_OBJ_KIND */
773 /* Fully aware of the effects */
775 #endif /* SCRIPT_OBJ_KIND */
777 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
778 !death && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
782 char o_name[MAX_NLEN];
785 object_copy(q_ptr, o_ptr);
788 object_desc(o_name, q_ptr, TRUE, 0);
790 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
796 * Something has been "sampled"
798 void object_tried(object_type *o_ptr)
800 #ifndef SCRIPT_OBJ_KIND
801 /* Mark it as tried (even if "aware") */
802 k_info[o_ptr->k_idx].tried = TRUE;
803 #else /* SCRIPT_OBJ_KIND */
805 #endif /* SCRIPT_OBJ_KIND */
810 * Return the "value" of an "unknown" item
811 * Make a guess at the value of non-aware items
813 static s32b object_value_base(object_type *o_ptr)
815 /* Aware item -- use template cost */
816 if (object_aware_p(o_ptr)) return (get_object_cost(o_ptr));
818 /* Analyze the type */
823 case TV_FOOD: return (5L);
825 /* Un-aware Potions */
826 case TV_POTION: return (20L);
828 /* Un-aware Scrolls */
829 case TV_SCROLL: return (20L);
831 /* Un-aware Staffs */
832 case TV_STAFF: return (70L);
835 case TV_WAND: return (50L);
838 case TV_ROD: return (90L);
841 case TV_RING: return (45L);
843 /* Un-aware Amulets */
844 case TV_AMULET: return (45L);
846 /* Figurines, relative to monster level */
849 int level = r_info[o_ptr->pval].level;
850 if (level < 20) return level*50L;
851 else if (level < 30) return 1000+(level-20)*150L;
852 else if (level < 40) return 2500+(level-30)*350L;
853 else if (level < 50) return 6000+(level-40)*800L;
854 else return 14000+(level-50)*2000L;
859 if (!o_ptr->pval) return 1000L;
860 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
863 /* Paranoia -- Oops */
868 /* Return the value of the flags the object has... */
869 s32b flag_cost(object_type * o_ptr, int plusses)
876 object_flags(o_ptr, &f1, &f2, &f3);
880 artifact_type *a_ptr = &a_info[o_ptr->name1];
882 f1 &= ~(a_ptr->flags1);
883 f2 &= ~(a_ptr->flags2);
884 f3 &= ~(a_ptr->flags3);
890 ego_item_type *e_ptr = &e_info[o_ptr->name2];
892 f1 &= ~(e_ptr->flags1);
893 f2 &= ~(e_ptr->flags2);
894 f3 &= ~(e_ptr->flags3);
895 if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET))
897 object_kind *k_ptr = &k_info[o_ptr->k_idx];
899 f1 &= ~(k_ptr->flags1);
900 f2 &= ~(k_ptr->flags2);
901 f3 &= ~(k_ptr->flags3);
904 else if (o_ptr->art_name)
910 if (f1 & TR1_STR) total += (1500 * plusses);
911 if (f1 & TR1_INT) total += (1500 * plusses);
912 if (f1 & TR1_WIS) total += (1500 * plusses);
913 if (f1 & TR1_DEX) total += (1500 * plusses);
914 if (f1 & TR1_CON) total += (1500 * plusses);
915 if (f1 & TR1_CHR) total += (750 * plusses);
916 if (f1 & TR1_MAGIC_MASTERY) total += (600 * plusses);
917 if (f1 & TR1_STEALTH) total += (250 * plusses);
918 if (f1 & TR1_SEARCH) total += (100 * plusses);
919 if (f1 & TR1_INFRA) total += (150 * plusses);
920 if (f1 & TR1_TUNNEL) total += (175 * plusses);
921 if ((f1 & TR1_SPEED) && (plusses > 0))
922 total += (10000 + (2500 * plusses));
923 if ((f1 & TR1_BLOWS) && (plusses > 0))
924 total += (10000 + (2500 * plusses));
925 if (f3 & TR3_DEC_MANA) total += 10000;
929 if (f1 & TR1_CHAOTIC) {total += 5000;count++;}
930 if (f1 & TR1_VAMPIRIC) {total += 6500;count++;}
931 if (f1 & TR1_FORCE_WEAPON) {tmp_cost += 2500;count++;}
932 if (f1 & TR1_SLAY_ANIMAL) {tmp_cost += 1800;count++;}
933 if (f1 & TR1_SLAY_EVIL) {tmp_cost += 2300;count++;}
934 if (f3 & TR3_SLAY_HUMAN) {tmp_cost += 1800;count++;}
935 if (f1 & TR1_SLAY_UNDEAD) {tmp_cost += 1800;count++;}
936 if (f1 & TR1_SLAY_DEMON) {tmp_cost += 1800;count++;}
937 if (f1 & TR1_SLAY_ORC) {tmp_cost += 1500;count++;}
938 if (f1 & TR1_SLAY_TROLL) {tmp_cost += 1800;count++;}
939 if (f1 & TR1_SLAY_GIANT) {tmp_cost += 1800;count++;}
940 if (f1 & TR1_KILL_DRAGON) {tmp_cost += 2800;count++;}
941 else if (f1 & TR1_SLAY_DRAGON) {tmp_cost += 1800;count++;}
943 if (f1 & TR1_VORPAL) {tmp_cost += 2500;count++;}
944 if (f1 & TR1_IMPACT) {tmp_cost += 2500;count++;}
945 if (f1 & TR1_BRAND_POIS) {tmp_cost += 3800;count++;}
946 if (f1 & TR1_BRAND_ACID) {tmp_cost += 3800;count++;}
947 if (f1 & TR1_BRAND_ELEC) {tmp_cost += 3800;count++;}
948 if (f1 & TR1_BRAND_FIRE) {tmp_cost += 2500;count++;}
949 if (f1 & TR1_BRAND_COLD) {tmp_cost += 2500;count++;}
950 total += (tmp_cost * count);
952 if (f2 & TR2_SUST_STR) total += 850;
953 if (f2 & TR2_SUST_INT) total += 850;
954 if (f2 & TR2_SUST_WIS) total += 850;
955 if (f2 & TR2_SUST_DEX) total += 850;
956 if (f2 & TR2_SUST_CON) total += 850;
957 if (f2 & TR2_SUST_CHR) total += 250;
958 if (f2 & TR2_RIDING) total += 0;
959 if (f2 & TR2_XXX2) total += 0;
960 if (f2 & TR2_THROW) total += 5000;
961 if (f2 & TR2_FREE_ACT) total += 4500;
962 if (f2 & TR2_HOLD_LIFE) total += 8500;
966 if (f2 & TR2_IM_ACID) {tmp_cost += 15000;count += 2;}
967 if (f2 & TR2_IM_ELEC) {tmp_cost += 15000;count += 2;}
968 if (f2 & TR2_IM_FIRE) {tmp_cost += 15000;count += 2;}
969 if (f2 & TR2_IM_COLD) {tmp_cost += 15000;count += 2;}
970 if (f2 & TR2_REFLECT) {tmp_cost += 5000;count += 2;}
971 if (f2 & TR2_RES_ACID) {tmp_cost += 500;count++;}
972 if (f2 & TR2_RES_ELEC) {tmp_cost += 500;count++;}
973 if (f2 & TR2_RES_FIRE) {tmp_cost += 500;count++;}
974 if (f2 & TR2_RES_COLD) {tmp_cost += 500;count++;}
975 if (f2 & TR2_RES_POIS) {tmp_cost += 1000;count += 2;}
976 if (f2 & TR2_RES_FEAR) {tmp_cost += 1000;count += 2;}
977 if (f2 & TR2_RES_LITE) {tmp_cost += 800;count += 2;}
978 if (f2 & TR2_RES_DARK) {tmp_cost += 800;count += 2;}
979 if (f2 & TR2_RES_BLIND) {tmp_cost += 900;count += 2;}
980 if (f2 & TR2_RES_CONF) {tmp_cost += 900;count += 2;}
981 if (f2 & TR2_RES_SOUND) {tmp_cost += 900;count += 2;}
982 if (f2 & TR2_RES_SHARDS) {tmp_cost += 900;count += 2;}
983 if (f2 & TR2_RES_NETHER) {tmp_cost += 900;count += 2;}
984 if (f2 & TR2_RES_NEXUS) {tmp_cost += 900;count += 2;}
985 if (f2 & TR2_RES_CHAOS) {tmp_cost += 1000;count += 2;}
986 if (f2 & TR2_RES_DISEN) {tmp_cost += 2000;count += 2;}
987 total += (tmp_cost * count);
989 if (f3 & TR3_SH_FIRE) total += 5000;
990 if (f3 & TR3_SH_ELEC) total += 5000;
991 if (f3 & TR3_SH_COLD) total += 5000;
992 if (f3 & TR3_NO_TELE) total -= 10000;
993 if (f3 & TR3_NO_MAGIC) total += 2500;
994 if (f3 & TR3_TY_CURSE) total -= 15000;
995 if (f3 & TR3_HIDE_TYPE) total += 0;
996 if (f3 & TR3_SHOW_MODS) total += 0;
997 if (f3 & TR3_FEATHER) total += 1250;
998 if (f3 & TR3_LITE) total += 1250;
999 if (f3 & TR3_SEE_INVIS) total += 2000;
1000 if (f3 & TR3_TELEPATHY) total += 20000;
1001 if (f3 & TR3_SLOW_DIGEST) total += 750;
1002 if (f3 & TR3_REGEN) total += 2500;
1003 if (f3 & TR3_WARNING) total += 2000;
1004 if (f3 & TR3_XTRA_MIGHT) total += 2250;
1005 if (f3 & TR3_XTRA_SHOTS) total += 10000;
1006 if (f3 & TR3_IGNORE_ACID) total += 100;
1007 if (f3 & TR3_IGNORE_ELEC) total += 100;
1008 if (f3 & TR3_IGNORE_FIRE) total += 100;
1009 if (f3 & TR3_IGNORE_COLD) total += 100;
1010 if (f3 & TR3_ACTIVATE) total += 100;
1011 if (f3 & TR3_DRAIN_EXP) total -= 12500;
1012 if (f3 & TR3_TELEPORT)
1014 if (cursed_p(o_ptr))
1019 if (f3 & TR3_AGGRAVATE) total -= 10000;
1020 if (f3 & TR3_BLESSED) total += 750;
1021 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1022 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1023 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1025 /* Also, give some extra for activatable powers... */
1026 if (o_ptr->art_name && (o_ptr->art_flags3 & TR3_ACTIVATE))
1028 int type = o_ptr->xtra2;
1030 if (type == ACT_SUNLIGHT) total += 250;
1031 else if (type == ACT_BO_MISS_1) total += 250;
1032 else if (type == ACT_BA_POIS_1) total += 300;
1033 else if (type == ACT_BO_ELEC_1) total += 250;
1034 else if (type == ACT_BO_ACID_1) total += 250;
1035 else if (type == ACT_BO_COLD_1) total += 250;
1036 else if (type == ACT_BO_FIRE_1) total += 250;
1037 else if (type == ACT_BA_COLD_1) total += 750;
1038 else if (type == ACT_BA_FIRE_1) total += 1000;
1039 else if (type == ACT_DRAIN_1) total += 500;
1040 else if (type == ACT_BA_COLD_2) total += 1250;
1041 else if (type == ACT_BA_ELEC_2) total += 1500;
1042 else if (type == ACT_DRAIN_2) total += 750;
1043 else if (type == ACT_VAMPIRE_1) total += 1000;
1044 else if (type == ACT_BO_MISS_2) total += 1000;
1045 else if (type == ACT_BA_FIRE_2) total += 1750;
1046 else if (type == ACT_BA_COLD_3) total += 2500;
1047 else if (type == ACT_BA_ELEC_3) total += 2500;
1048 else if (type == ACT_WHIRLWIND) total += 7500;
1049 else if (type == ACT_VAMPIRE_2) total += 2500;
1050 else if (type == ACT_CALL_CHAOS) total += 5000;
1051 else if (type == ACT_ROCKET) total += 5000;
1052 else if (type == ACT_DISP_EVIL) total += 4000;
1053 else if (type == ACT_DISP_GOOD) total += 3500;
1054 else if (type == ACT_BA_MISS_3) total += 5000;
1055 else if (type == ACT_CONFUSE) total += 500;
1056 else if (type == ACT_SLEEP) total += 750;
1057 else if (type == ACT_QUAKE) total += 600;
1058 else if (type == ACT_TERROR) total += 2500;
1059 else if (type == ACT_TELE_AWAY) total += 2000;
1060 else if (type == ACT_BANISH_EVIL) total += 2000;
1061 else if (type == ACT_GENOCIDE) total += 10000;
1062 else if (type == ACT_MASS_GENO) total += 10000;
1063 else if (type == ACT_CHARM_ANIMAL) total += 7500;
1064 else if (type == ACT_CHARM_UNDEAD) total += 10000;
1065 else if (type == ACT_CHARM_OTHER) total += 10000;
1066 else if (type == ACT_CHARM_ANIMALS) total += 12500;
1067 else if (type == ACT_CHARM_OTHERS) total += 17500;
1068 else if (type == ACT_SUMMON_ANIMAL) total += 10000;
1069 else if (type == ACT_SUMMON_PHANTOM) total += 12000;
1070 else if (type == ACT_SUMMON_ELEMENTAL) total += 15000;
1071 else if (type == ACT_SUMMON_DEMON) total += 20000;
1072 else if (type == ACT_SUMMON_UNDEAD) total += 20000;
1073 else if (type == ACT_CURE_LW) total += 500;
1074 else if (type == ACT_CURE_MW) total += 750;
1075 else if (type == ACT_CURE_POISON) total += 1000;
1076 else if (type == ACT_REST_LIFE) total += 7500;
1077 else if (type == ACT_REST_ALL) total += 15000;
1078 else if (type == ACT_CURE_700) total += 10000;
1079 else if (type == ACT_CURE_1000) total += 15000;
1080 else if (type == ACT_ESP) total += 1500;
1081 else if (type == ACT_BERSERK) total += 800;
1082 else if (type == ACT_PROT_EVIL) total += 5000;
1083 else if (type == ACT_RESIST_ALL) total += 5000;
1084 else if (type == ACT_SPEED) total += 15000;
1085 else if (type == ACT_XTRA_SPEED) total += 25000;
1086 else if (type == ACT_WRAITH) total += 25000;
1087 else if (type == ACT_INVULN) total += 25000;
1088 else if (type == ACT_LIGHT) total += 150;
1089 else if (type == ACT_MAP_LIGHT) total += 500;
1090 else if (type == ACT_DETECT_ALL) total += 1000;
1091 else if (type == ACT_DETECT_XTRA) total += 12500;
1092 else if (type == ACT_ID_FULL) total += 10000;
1093 else if (type == ACT_ID_PLAIN) total += 1250;
1094 else if (type == ACT_RUNE_EXPLO) total += 4000;
1095 else if (type == ACT_RUNE_PROT) total += 10000;
1096 else if (type == ACT_SATIATE) total += 2000;
1097 else if (type == ACT_DEST_DOOR) total += 100;
1098 else if (type == ACT_STONE_MUD) total += 1000;
1099 else if (type == ACT_RECHARGE) total += 1000;
1100 else if (type == ACT_ALCHEMY) total += 10000;
1101 else if (type == ACT_DIM_DOOR) total += 10000;
1102 else if (type == ACT_TELEPORT) total += 2000;
1103 else if (type == ACT_RECALL) total += 7500;
1111 * Return the "real" price of a "known" item, not including discounts
1113 * Wand and staffs get cost for each charge
1115 * Armor is worth an extra 100 gold per bonus point to armor class.
1117 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).
1119 * Missiles are only worth 5 gold per bonus point, since they
1120 * usually appear in groups of 20, and we want the player to get
1121 * the same amount of cash for any "equivalent" item. Note that
1122 * missiles never have any of the "pval" flags, and in fact, they
1123 * only have a few of the available flags, primarily of the "slay"
1124 * and "brand" and "ignore" variety.
1126 * Armor with a negative armor bonus is worthless.
1127 * Weapons with negative hit+damage bonuses are worthless.
1129 * Every wearable item with a "pval" bonus is worth extra (see below).
1131 s32b object_value_real(object_type *o_ptr)
1137 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1140 /* Hack -- "worthless" items */
1141 if (!get_object_cost(o_ptr)) return (0L);
1144 value = get_object_cost(o_ptr);
1146 /* Extract some flags */
1147 object_flags(o_ptr, &f1, &f2, &f3);
1152 artifact_type *a_ptr = &a_info[o_ptr->name1];
1154 /* Hack -- "worthless" artifacts */
1155 if (!a_ptr->cost) return (0L);
1157 /* Hack -- Use the artifact cost instead */
1158 value = a_ptr->cost;
1159 value += flag_cost(o_ptr, o_ptr->pval);
1164 else if (o_ptr->name2)
1166 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1168 /* Hack -- "worthless" ego-items */
1169 if (!e_ptr->cost) return (0L);
1171 /* Hack -- Reward the ego-item with a bonus */
1172 value += e_ptr->cost;
1173 value += flag_cost(o_ptr, o_ptr->pval);
1176 else if (o_ptr->art_flags1 || o_ptr->art_flags2 || o_ptr->art_flags3)
1178 value += flag_cost(o_ptr, o_ptr->pval);
1182 /* Analyze pval bonus */
1183 switch (o_ptr->tval)
1206 /* Hack -- Negative "pval" is always bad */
1207 if (o_ptr->pval < 0) return (0L);
1210 if (!o_ptr->pval) break;
1212 /* Give credit for stat bonuses */
1213 if (f1 & (TR1_STR)) value += (o_ptr->pval * 200L);
1214 if (f1 & (TR1_INT)) value += (o_ptr->pval * 200L);
1215 if (f1 & (TR1_WIS)) value += (o_ptr->pval * 200L);
1216 if (f1 & (TR1_DEX)) value += (o_ptr->pval * 200L);
1217 if (f1 & (TR1_CON)) value += (o_ptr->pval * 200L);
1218 if (f1 & (TR1_CHR)) value += (o_ptr->pval * 200L);
1220 /* Give credit for stealth and searching */
1221 if (f1 & (TR1_MAGIC_MASTERY)) value += (o_ptr->pval * 100L);
1222 if (f1 & (TR1_STEALTH)) value += (o_ptr->pval * 100L);
1223 if (f1 & (TR1_SEARCH)) value += (o_ptr->pval * 100L);
1225 /* Give credit for infra-vision and tunneling */
1226 if (f1 & (TR1_INFRA)) value += (o_ptr->pval * 50L);
1227 if (f1 & (TR1_TUNNEL)) value += (o_ptr->pval * 50L);
1229 /* Give credit for extra attacks */
1230 if (f1 & (TR1_BLOWS)) value += (o_ptr->pval * 5000L);
1232 /* Give credit for speed bonus */
1233 if (f1 & (TR1_SPEED)) value += (o_ptr->pval * 10000L);
1240 /* Analyze the item */
1241 switch (o_ptr->tval)
1246 /* Pay extra for charges, depending on standard number of
1247 * charges. Handle new-style wands correctly. -LM-
1249 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1256 /* Pay extra for charges, depending on standard number of
1259 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1269 /* Hack -- negative bonuses are bad */
1270 if (o_ptr->to_a < 0) return (0L);
1271 if (o_ptr->to_h < 0) return (0L);
1272 if (o_ptr->to_d < 0) return (0L);
1274 /* Give credit for bonuses */
1275 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1292 /* Hack -- negative armor bonus */
1293 if (o_ptr->to_a < 0) return (0L);
1295 /* Give credit for bonuses */
1296 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1309 /* Hack -- negative hit/damage bonuses */
1310 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1312 /* Factor in the bonuses */
1313 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1315 /* Hack -- Factor in extra damage dice and sides */
1316 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1317 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1328 /* Hack -- negative hit/damage bonuses */
1329 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1331 /* Factor in the bonuses */
1332 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1334 /* Hack -- Factor in extra damage dice and sides */
1335 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1336 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1342 /* Figurines, relative to monster level */
1345 int level = r_info[o_ptr->pval].level;
1346 if (level < 20) value = level*50L;
1347 else if (level < 30) value = 1000+(level-20)*150L;
1348 else if (level < 40) value = 2500+(level-30)*350L;
1349 else if (level < 50) value = 6000+(level-40)*800L;
1350 else value = 14000+(level-50)*2000L;
1356 if (!o_ptr->pval) value = 1000L;
1357 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1363 if (!o_ptr->pval) value = 0L;
1368 /* Return the value */
1374 * Return the price of an item including plusses (and charges)
1376 * This function returns the "value" of the given item (qty one)
1378 * Never notice "unknown" bonuses or properties, including "curses",
1379 * since that would give the player information he did not have.
1381 * Note that discounted items stay discounted forever, even if
1382 * the discount is "forgotten" by the player via memory loss.
1384 s32b object_value(object_type *o_ptr)
1389 /* Unknown items -- acquire a base value */
1390 if (object_known_p(o_ptr))
1392 /* Broken items -- worthless */
1393 if (broken_p(o_ptr)) return (0L);
1395 /* Cursed items -- worthless */
1396 if (cursed_p(o_ptr)) return (0L);
1398 /* Real value (see above) */
1399 value = object_value_real(o_ptr);
1402 /* Known items -- acquire the actual value */
1405 /* Hack -- Felt broken items */
1406 if ((o_ptr->ident & (IDENT_SENSE)) && broken_p(o_ptr)) return (0L);
1408 /* Hack -- Felt cursed items */
1409 if ((o_ptr->ident & (IDENT_SENSE)) && cursed_p(o_ptr)) return (0L);
1411 /* Base value (see above) */
1412 value = object_value_base(o_ptr);
1416 /* Apply discount (if any) */
1417 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1420 /* Return the final value */
1426 * Distribute charges of rods or wands.
1428 * o_ptr = source item
1429 * q_ptr = target item, must be of the same type as o_ptr
1430 * amt = number of items that are transfered
1432 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1435 * Hack -- If rods or wands are dropped, the total maximum timeout or
1436 * charges need to be allocated between the two stacks. If all the items
1437 * are being dropped, it makes for a neater message to leave the original
1438 * stack's pval alone. -LM-
1440 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1442 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1443 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1445 /* Hack -- Rods also need to have their timeouts distributed. The
1446 * dropped stack will accept all time remaining to charge up to its
1449 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1451 if (q_ptr->pval > o_ptr->timeout)
1452 q_ptr->timeout = o_ptr->timeout;
1454 q_ptr->timeout = q_ptr->pval;
1456 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1461 void reduce_charges(object_type *o_ptr, int amt)
1464 * Hack -- If rods or wand are destroyed, the total maximum timeout or
1465 * charges of the stack needs to be reduced, unless all the items are
1466 * being destroyed. -LM-
1468 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1469 (amt < o_ptr->number))
1471 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1477 * Determine if an item can "absorb" a second item
1479 * See "object_absorb()" for the actual "absorption" code.
1481 * If permitted, we allow staffs (if they are known to have equal charges
1482 * and both are either known or confirmed empty) and wands (if both are
1483 * either known or confirmed empty) and rods (in all cases) to combine.
1484 * Staffs will unstack (if necessary) when they are used, but wands and
1485 * rods will only unstack if one is dropped. -LM-
1487 * If permitted, we allow weapons/armor to stack, if fully "known".
1489 * Missiles will combine if both stacks have the same "known" status.
1490 * This is done to make unidentified stacks of missiles useful.
1492 * Food, potions, scrolls, and "easy know" items always stack.
1494 * Chests, and activatable items, never stack (for various reasons).
1498 * Determine if an item can partly absorb a second item.
1500 bool object_similar_part(object_type *o_ptr, object_type *j_ptr)
1502 /* Require identical object types */
1503 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1506 /* Analyze the items */
1507 switch (o_ptr->tval)
1509 /* Chests and Statues*/
1520 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return (0);
1521 if (o_ptr->pval != j_ptr->pval) return (0);
1525 /* Figurines and Corpses*/
1530 if (o_ptr->pval != j_ptr->pval) return (0);
1536 /* Food and Potions and Scrolls */
1548 /* Require either knowledge or known empty for both staffs. */
1549 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1550 !object_known_p(o_ptr)) ||
1551 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1552 !object_known_p(j_ptr))) return(0);
1554 /* Require identical charges, since staffs are bulky. */
1555 if (o_ptr->pval != j_ptr->pval) return (0);
1564 /* Require either knowledge or known empty for both wands. */
1565 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1566 !object_known_p(o_ptr)) ||
1567 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1568 !object_known_p(j_ptr))) return(0);
1570 /* Wand charges combine in O&ZAngband. */
1576 /* Staffs and Wands and Rods */
1583 /* Weapons and Armor */
1599 /* Require permission */
1600 if (!stack_allow_items) return (0);
1605 /* Rings, Amulets, Lites */
1610 /* Require full knowledge of both items */
1611 if (!object_known_p(o_ptr) || !object_known_p(j_ptr)) return (0);
1621 /* Require identical knowledge of both items */
1622 if (object_known_p(o_ptr) != object_known_p(j_ptr)) return (0);
1624 /* Require identical "bonuses" */
1625 if (o_ptr->to_h != j_ptr->to_h) return (FALSE);
1626 if (o_ptr->to_d != j_ptr->to_d) return (FALSE);
1627 if (o_ptr->to_a != j_ptr->to_a) return (FALSE);
1629 /* Require identical "pval" code */
1630 if (o_ptr->pval != j_ptr->pval) return (FALSE);
1632 /* Require identical "artifact" names */
1633 if (o_ptr->name1 != j_ptr->name1) return (FALSE);
1635 /* Random artifacts never stack */
1636 if (o_ptr->art_name || j_ptr->art_name) return (FALSE);
1638 /* Require identical "ego-item" names */
1639 if (o_ptr->name2 != j_ptr->name2) return (FALSE);
1641 /* Require identical added essence */
1642 if (o_ptr->xtra3 != j_ptr->xtra3) return (FALSE);
1643 if (o_ptr->xtra4 != j_ptr->xtra4) return (FALSE);
1645 /* Hack -- Never stack "powerful" items */
1646 if (o_ptr->xtra1 || j_ptr->xtra1) return (FALSE);
1648 /* Hack -- Never stack recharging items */
1649 if (o_ptr->timeout || j_ptr->timeout) return (FALSE);
1651 /* Require identical "values" */
1652 if (o_ptr->ac != j_ptr->ac) return (FALSE);
1653 if (o_ptr->dd != j_ptr->dd) return (FALSE);
1654 if (o_ptr->ds != j_ptr->ds) return (FALSE);
1663 /* Require knowledge */
1664 if (!object_known_p(o_ptr) || !object_known_p(j_ptr)) return (0);
1672 /* Hack -- Identical art_flags! */
1673 if ((o_ptr->art_flags1 != j_ptr->art_flags1) ||
1674 (o_ptr->art_flags2 != j_ptr->art_flags2) ||
1675 (o_ptr->art_flags3 != j_ptr->art_flags3))
1678 /* Hack -- Require identical "cursed" status */
1679 if (o_ptr->curse_flags != j_ptr->curse_flags) return (0);
1681 /* Hack -- Require identical "broken" status */
1682 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return (0);
1685 /* Hack -- require semi-matching "inscriptions" */
1686 if (o_ptr->inscription && j_ptr->inscription &&
1687 (o_ptr->inscription != j_ptr->inscription))
1690 /* Hack -- normally require matching "inscriptions" */
1691 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return (0);
1693 /* Hack -- normally require matching "discounts" */
1694 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return (0);
1697 /* They match, so they must be similar */
1702 * Determine if an item can absorb a second item.
1704 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1706 int total = o_ptr->number + j_ptr->number;
1708 if (!object_similar_part(o_ptr, j_ptr))
1711 /* Maximal "stacking" limit */
1712 if (total >= MAX_STACK_SIZE) return (0);
1715 /* They match, so they must be similar */
1722 * Allow one item to "absorb" another, assuming they are similar
1724 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1726 int total = o_ptr->number + j_ptr->number;
1728 /* Add together the item counts */
1729 o_ptr->number = ((total < MAX_STACK_SIZE) ? total : (MAX_STACK_SIZE - 1));
1731 /* Hack -- blend "known" status */
1732 if (object_known_p(j_ptr)) object_known(o_ptr);
1734 /* Hack -- clear "storebought" if only one has it */
1735 if (((o_ptr->ident & IDENT_STOREB) || (j_ptr->ident & IDENT_STOREB)) &&
1736 (!((o_ptr->ident & IDENT_STOREB) && (j_ptr->ident & IDENT_STOREB))))
1738 if (j_ptr->ident & IDENT_STOREB) j_ptr->ident &= 0xEF;
1739 if (o_ptr->ident & IDENT_STOREB) o_ptr->ident &= 0xEF;
1742 /* Hack -- blend "mental" status */
1743 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1745 /* Hack -- blend "inscriptions" */
1746 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1748 /* Hack -- blend "feelings" */
1749 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1751 /* Hack -- could average discounts XXX XXX XXX */
1752 /* Hack -- save largest discount XXX XXX XXX */
1753 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1755 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1756 if (o_ptr->tval == TV_ROD)
1758 o_ptr->pval += j_ptr->pval;
1759 o_ptr->timeout += j_ptr->timeout;
1762 /* Hack -- if wands are stacking, combine the charges. -LM- */
1763 if (o_ptr->tval == TV_WAND)
1765 o_ptr->pval += j_ptr->pval;
1771 * Find the index of the object_kind with the given tval and sval
1773 s16b lookup_kind(int tval, int sval)
1780 for (k = 1; k < max_k_idx; k++)
1782 object_kind *k_ptr = &k_info[k];
1784 /* Require correct tval */
1785 if (k_ptr->tval != tval) continue;
1788 if (k_ptr->sval == sval) return (k);
1790 /* Ignore illegal items */
1791 if (sval != SV_ANY) continue;
1793 /* Apply the randomizer */
1794 if (!one_in_(++num)) continue;
1796 /* Use this value */
1800 /* Return this choice */
1809 msg_format("¥¢¥¤¥Æ¥à¤¬¤Ê¤¤ (%d,%d)", tval, sval);
1811 msg_format("No object (%d,%d)", tval, sval);
1822 * Wipe an object clean.
1824 void object_wipe(object_type *o_ptr)
1826 /* Wipe the structure */
1827 (void)WIPE(o_ptr, object_type);
1832 * Prepare an object based on an existing object
1834 void object_copy(object_type *o_ptr, object_type *j_ptr)
1836 /* Copy the structure */
1837 COPY(o_ptr, j_ptr, object_type);
1842 * Prepare an object based on an object kind.
1844 void object_prep(object_type *o_ptr, int k_idx)
1846 object_kind *k_ptr = &k_info[k_idx];
1848 /* Clear the record */
1851 /* Save the kind index */
1852 o_ptr->k_idx = k_idx;
1854 /* Efficiency -- tval/sval */
1855 o_ptr->tval = k_ptr->tval;
1856 o_ptr->sval = k_ptr->sval;
1858 /* Default "pval" */
1859 o_ptr->pval = k_ptr->pval;
1861 /* Default number */
1864 /* Default weight */
1865 o_ptr->weight = k_ptr->weight;
1868 o_ptr->to_h = k_ptr->to_h;
1869 o_ptr->to_d = k_ptr->to_d;
1870 o_ptr->to_a = k_ptr->to_a;
1873 o_ptr->ac = k_ptr->ac;
1874 o_ptr->dd = k_ptr->dd;
1875 o_ptr->ds = k_ptr->ds;
1877 /* Hack -- worthless items are always "broken" */
1878 if (get_object_cost(o_ptr) <= 0) o_ptr->ident |= (IDENT_BROKEN);
1880 /* Hack -- cursed items are always "cursed" */
1881 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
1882 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
1883 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
1884 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
1885 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
1886 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
1891 * Help determine an "enchantment bonus" for an object.
1893 * To avoid floating point but still provide a smooth distribution of bonuses,
1894 * we simply round the results of division in such a way as to "average" the
1895 * correct floating point value.
1897 * This function has been changed. It uses "randnor()" to choose values from
1898 * a normal distribution, whose mean moves from zero towards the max as the
1899 * level increases, and whose standard deviation is equal to 1/4 of the max,
1900 * and whose values are forced to lie between zero and the max, inclusive.
1902 * Since the "level" rarely passes 100 before Morgoth is dead, it is very
1903 * rare to get the "full" enchantment on an object, even a deep levels.
1905 * It is always possible (albeit unlikely) to get the "full" enchantment.
1907 * A sample distribution of values from "m_bonus(10, N)" is shown below:
1909 * N 0 1 2 3 4 5 6 7 8 9 10
1910 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
1911 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03
1912 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05
1913 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05
1914 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11
1915 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41
1916 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65
1917 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94
1918 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78
1919 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64
1920 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62
1921 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33
1922 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38
1923 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53
1924 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53
1925 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27
1926 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72
1927 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07
1929 s16b m_bonus(int max, int level)
1931 int bonus, stand, extra, value;
1934 /* Paranoia -- enforce maximal "level" */
1935 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1938 /* The "bonus" moves towards the max */
1939 bonus = ((max * level) / MAX_DEPTH);
1941 /* Hack -- determine fraction of error */
1942 extra = ((max * level) % MAX_DEPTH);
1944 /* Hack -- simulate floating point computations */
1945 if (randint0(MAX_DEPTH) < extra) bonus++;
1948 /* The "stand" is equal to one quarter of the max */
1951 /* Hack -- determine fraction of error */
1954 /* Hack -- simulate floating point computations */
1955 if (randint0(4) < extra) stand++;
1958 /* Choose an "interesting" value */
1959 value = randnor(bonus, stand);
1961 /* Enforce the minimum value */
1962 if (value < 0) return (0);
1964 /* Enforce the maximum value */
1965 if (value > max) return (max);
1973 * Cheat -- describe a created object for the user
1975 static void object_mention(object_type *o_ptr)
1977 char o_name[MAX_NLEN];
1980 object_desc_store(o_name, o_ptr, FALSE, 0);
1983 if (artifact_p(o_ptr))
1987 msg_format("ÅÁÀâ¤Î¥¢¥¤¥Æ¥à (%s)", o_name);
1989 msg_format("Artifact (%s)", o_name);
1994 /* Random Artifact */
1995 else if (o_ptr->art_name)
1998 msg_print("¥é¥ó¥À¥à¡¦¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È");
2000 msg_print("Random artifact");
2006 else if (ego_item_p(o_ptr))
2010 msg_format("̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à (%s)", o_name);
2012 msg_format("Ego-item (%s)", o_name);
2022 msg_format("¥¢¥¤¥Æ¥à (%s)", o_name);
2024 msg_format("Object (%s)", o_name);
2032 * Mega-Hack -- Attempt to create one of the "Special Objects"
2034 * We are only called from "make_object()", and we assume that
2035 * "apply_magic()" is called immediately after we return.
2037 * Note -- see "make_artifact()" and "apply_magic()"
2039 static bool make_artifact_special(object_type *o_ptr)
2045 /* No artifacts in the town */
2046 if (!dun_level) return (FALSE);
2049 if (get_obj_num_hook) return (FALSE);
2051 /* Check the artifact list (just the "specials") */
2052 for (i = 0; i < max_a_idx; i++)
2054 artifact_type *a_ptr = &a_info[i];
2056 /* Skip "empty" artifacts */
2057 if (!a_ptr->name) continue;
2059 /* Cannot make an artifact twice */
2060 if (a_ptr->cur_num) continue;
2062 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2063 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2065 /* XXX XXX Enforce minimum "depth" (loosely) */
2066 if (a_ptr->level > dun_level)
2068 /* Acquire the "out-of-depth factor" */
2069 int d = (a_ptr->level - dun_level) * 2;
2071 /* Roll for out-of-depth creation */
2072 if (!one_in_(d)) continue;
2075 /* Artifact "rarity roll" */
2076 if (!one_in_(a_ptr->rarity)) continue;
2078 /* Find the base object */
2079 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2081 /* XXX XXX Enforce minimum "object" level (loosely) */
2082 if (k_info[k_idx].level > object_level)
2084 /* Acquire the "out-of-depth factor" */
2085 int d = (k_info[k_idx].level - object_level) * 5;
2087 /* Roll for out-of-depth creation */
2088 if (!one_in_(d)) continue;
2091 /* Assign the template */
2092 object_prep(o_ptr, k_idx);
2094 /* Mega-Hack -- mark the item as an artifact */
2097 /* Hack: Some artifacts get random extra powers */
2098 random_artifact_resistance(o_ptr, a_ptr);
2110 * Attempt to change an object into an artifact
2112 * This routine should only be called by "apply_magic()"
2114 * Note -- see "make_artifact_special()" and "apply_magic()"
2116 static bool make_artifact(object_type *o_ptr)
2121 /* No artifacts in the town */
2122 if (!dun_level) return (FALSE);
2124 /* Paranoia -- no "plural" artifacts */
2125 if (o_ptr->number != 1) return (FALSE);
2127 /* Check the artifact list (skip the "specials") */
2128 for (i = 0; i < max_a_idx; i++)
2130 artifact_type *a_ptr = &a_info[i];
2132 /* Skip "empty" items */
2133 if (!a_ptr->name) continue;
2135 /* Cannot make an artifact twice */
2136 if (a_ptr->cur_num) continue;
2138 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2140 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2142 /* Must have the correct fields */
2143 if (a_ptr->tval != o_ptr->tval) continue;
2144 if (a_ptr->sval != o_ptr->sval) continue;
2146 /* XXX XXX Enforce minimum "depth" (loosely) */
2147 if (a_ptr->level > dun_level)
2149 /* Acquire the "out-of-depth factor" */
2150 int d = (a_ptr->level - dun_level) * 2;
2152 /* Roll for out-of-depth creation */
2153 if (!one_in_(d)) continue;
2156 /* We must make the "rarity roll" */
2157 if (!one_in_(a_ptr->rarity)) continue;
2159 /* Hack -- mark the item as an artifact */
2162 /* Hack: Some artifacts get random extra powers */
2163 random_artifact_resistance(o_ptr, a_ptr);
2175 * Choose random ego type
2177 static byte get_random_ego(byte slot, bool good, int level)
2180 ego_item_type *e_ptr;
2184 for (i = 1; i < max_e_idx; i++)
2188 if (e_ptr->slot == slot
2189 /* && level >= e_ptr->level */
2190 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2193 total += (255 / e_ptr->rarity);
2197 value = randint1(total);
2199 for (i = 1; i < max_e_idx; i++)
2203 if (e_ptr->slot == slot
2204 /* && level >= e_ptr->level */
2205 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2208 value -= (255 / e_ptr->rarity);
2209 if (value <= 0L) break;
2217 * Apply magic to an item known to be a "weapon"
2219 * Hack -- note special base damage dice boosting
2220 * Hack -- note special processing for weapon/digger
2221 * Hack -- note special rating boost for dragon scale mail
2223 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2225 int tohit1 = randint1(5) + m_bonus(5, level);
2226 int todam1 = randint1(5) + m_bonus(5, level);
2228 int tohit2 = m_bonus(10, level);
2229 int todam2 = m_bonus(10, level);
2231 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2233 tohit2 = (tohit2+1)/2;
2234 todam2 = (todam2+1)/2;
2241 o_ptr->to_h += tohit1;
2242 o_ptr->to_d += todam1;
2248 o_ptr->to_h += tohit2;
2249 o_ptr->to_d += todam2;
2257 o_ptr->to_h -= tohit1;
2258 o_ptr->to_d -= todam1;
2263 /* Penalize again */
2264 o_ptr->to_h -= tohit2;
2265 o_ptr->to_d -= todam2;
2268 /* Cursed (if "bad") */
2269 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2272 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2275 switch (o_ptr->tval)
2283 create_artifact(o_ptr, FALSE);
2285 /* Special Ego-item */
2286 o_ptr->name2 = EGO_DIGGING;
2290 else if (power < -1)
2292 /* Hack -- Horrible digging bonus */
2293 o_ptr->pval = 0 - (5 + randint1(5));
2299 /* Hack -- Reverse digging bonus */
2300 o_ptr->pval = 0 - (o_ptr->pval);
2316 create_artifact(o_ptr, FALSE);
2321 /* Roll for an ego-item */
2322 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE, level);
2323 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2325 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2330 switch (o_ptr->name2)
2333 if (one_in_(4) && (level > 40))
2334 o_ptr->art_flags1 |= TR1_BLOWS;
2338 o_ptr->art_flags2 |= TR2_RES_POIS;
2340 o_ptr->art_flags3 |= TR3_WARNING;
2342 case EGO_KILL_DRAGON:
2344 o_ptr->art_flags2 |= TR2_RES_POIS;
2348 o_ptr->art_flags2 |= TR2_RES_FEAR;
2350 case EGO_SLAYING_WEAPON:
2351 if (one_in_(3)) /* double damage */
2359 while (one_in_(o_ptr->dd));
2365 while (one_in_(o_ptr->ds));
2370 o_ptr->art_flags1 |= TR1_BRAND_POIS;
2372 if (o_ptr->tval == TV_SWORD && one_in_(3))
2374 o_ptr->art_flags1 |= TR1_VORPAL;
2379 o_ptr->art_flags1 |= TR1_SLAY_DEMON;
2385 o_ptr->art_flags2 |= TR2_HOLD_LIFE;
2387 o_ptr->art_flags1 |= TR1_DEX;
2389 o_ptr->art_flags2 |= TR2_RES_FEAR;
2392 o_ptr->pval = m_bonus(5, level) + 1;
2394 case EGO_EARTHQUAKES:
2395 if (one_in_(3) && (level > 60))
2396 o_ptr->art_flags1 |= TR1_BLOWS;
2398 o_ptr->pval = m_bonus(3, level);
2402 o_ptr->art_flags3 |= TR3_SLAY_HUMAN;
2406 if (!o_ptr->art_name)
2408 /* Hack -- Super-charge the damage dice */
2409 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2411 /* Hack -- Lower the damage dice */
2412 if (o_ptr->dd > 9) o_ptr->dd = 9;
2417 else if (power < -1)
2419 /* Roll for ego-item */
2420 if (randint0(MAX_DEPTH) < level)
2422 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE, level);
2423 switch (o_ptr->name2)
2426 if (one_in_(6)) o_ptr->art_flags3 |= TR3_TY_CURSE;
2442 create_artifact(o_ptr, FALSE);
2445 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE, level);
2459 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE, level);
2461 switch (o_ptr->name2)
2463 case EGO_SLAYING_BOLT:
2468 /* Hack -- super-charge the damage dice */
2469 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2471 /* Hack -- restrict the damage dice */
2472 if (o_ptr->dd > 9) o_ptr->dd = 9;
2476 else if (power < -1)
2478 /* Roll for ego-item */
2479 if (randint0(MAX_DEPTH) < level)
2481 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE, level);
2491 static void dragon_resist(object_type * o_ptr)
2496 one_dragon_ele_resistance(o_ptr);
2498 one_high_resistance(o_ptr);
2505 * Apply magic to an item known to be "armor"
2507 * Hack -- note special processing for crown/helm
2508 * Hack -- note special processing for robe of permanence
2510 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2512 int toac1 = randint1(5) + m_bonus(5, level);
2514 int toac2 = m_bonus(10, level);
2520 o_ptr->to_a += toac1;
2526 o_ptr->to_a += toac2;
2534 o_ptr->to_a -= toac1;
2539 /* Penalize again */
2540 o_ptr->to_a -= toac2;
2543 /* Cursed (if "bad") */
2544 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2549 switch (o_ptr->tval)
2556 create_artifact(o_ptr, FALSE);
2558 /* Mention the item */
2559 if (cheat_peek) object_mention(o_ptr);
2570 /* Hack -- Try for "Robes of the Magi" */
2571 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2572 (o_ptr->sval == SV_ROBE) &&
2573 (randint0(100) < 15))
2577 o_ptr->name2 = EGO_YOIYAMI;
2578 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2579 o_ptr->sval = SV_YOIYAMI_ROBE;
2585 o_ptr->name2 = EGO_PERMANENCE;
2592 create_artifact(o_ptr, FALSE);
2598 bool okay_flag = TRUE;
2600 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE, level);
2602 switch (o_ptr->name2)
2604 case EGO_RESISTANCE:
2606 o_ptr->art_flags2 |= TR2_RES_POIS;
2611 if (o_ptr->tval != TV_HARD_ARMOR)
2618 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2619 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2621 o_ptr->art_flags1 |= TR1_CON;
2637 if (o_ptr->sval == SV_DRAGON_SHIELD)
2642 /* Mention the item */
2643 if (cheat_peek) object_mention(o_ptr);
2644 dragon_resist(o_ptr);
2645 if (!one_in_(3)) break;
2653 create_artifact(o_ptr, FALSE);
2656 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE, level);
2658 switch (o_ptr->name2)
2661 if (!one_in_(3)) one_high_resistance(o_ptr);
2662 if (one_in_(4)) o_ptr->art_flags2 |= TR2_RES_POIS;
2664 case EGO_REFLECTION:
2665 if (o_ptr->sval == SV_SHIELD_OF_DEFLECTION)
2675 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2680 /* Mention the item */
2681 if (cheat_peek) object_mention(o_ptr);
2682 dragon_resist(o_ptr);
2683 if (!one_in_(3)) break;
2689 create_artifact(o_ptr, FALSE);
2692 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE, level);
2696 else if (power < -1)
2698 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE, level);
2706 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2711 /* Mention the item */
2712 if (cheat_peek) object_mention(o_ptr);
2713 dragon_resist(o_ptr);
2714 if (!one_in_(3)) break;
2721 create_artifact(o_ptr, FALSE);
2724 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE, level);
2726 switch (o_ptr->name2)
2728 case EGO_SLOW_DESCENT:
2731 one_high_resistance(o_ptr);
2737 else if (power < -1)
2739 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE, level);
2752 create_artifact(o_ptr, FALSE);
2757 bool ok_flag = TRUE;
2758 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE, level);
2760 switch (o_ptr->name2)
2765 case EGO_REGENERATION:
2766 case EGO_LORDLINESS:
2769 if (one_in_(3)) o_ptr->art_flags3 |= TR3_TELEPATHY;
2771 default:/* not existing crown (wisdom,lite, etc...) */
2775 break; /* while (1) */
2781 else if (power < -1)
2783 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE, level);
2791 if (o_ptr->sval == SV_DRAGON_HELM)
2796 /* Mention the item */
2797 if (cheat_peek) object_mention(o_ptr);
2798 dragon_resist(o_ptr);
2799 if (!one_in_(3)) break;
2807 create_artifact(o_ptr, FALSE);
2812 bool ok_flag = TRUE;
2813 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE, level);
2815 switch (o_ptr->name2)
2817 case EGO_INTELLIGENCE:
2821 case EGO_INFRAVISION:
2824 if (one_in_(7)) o_ptr->art_flags3 |= TR3_TELEPATHY;
2826 default:/* not existing helm (Magi, Might, etc...)*/
2830 break; /* while (1) */
2835 else if (power < -1)
2837 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE, level);
2849 create_artifact(o_ptr, FALSE);
2852 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE, level);
2854 switch (o_ptr->name2)
2865 else if (power < -1)
2867 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE, level);
2877 * Apply magic to an item known to be a "ring" or "amulet"
2879 * Hack -- note special rating boost for ring of speed
2880 * Hack -- note special rating boost for amulet of the magi
2881 * Hack -- note special "pval boost" code for ring of speed
2882 * Hack -- note that some items must be cursed (or blessed)
2884 static void a_m_aux_3(object_type *o_ptr, int level, int power)
2886 /* Apply magic (good or bad) according to type */
2887 switch (o_ptr->tval)
2892 switch (o_ptr->sval)
2894 case SV_RING_ATTACKS:
2897 o_ptr->pval = m_bonus(2, level);
2898 if (one_in_(15)) o_ptr->pval++;
2899 if (o_ptr->pval < 1) o_ptr->pval = 1;
2905 o_ptr->ident |= (IDENT_BROKEN);
2908 o_ptr->curse_flags |= TRC_CURSED;
2911 o_ptr->pval = 0 - (o_ptr->pval);
2922 /* Strength, Constitution, Dexterity, Intelligence */
2928 o_ptr->pval = 1 + m_bonus(5, level);
2934 o_ptr->ident |= (IDENT_BROKEN);
2937 o_ptr->curse_flags |= TRC_CURSED;
2940 o_ptr->pval = 0 - (o_ptr->pval);
2946 /* Ring of Speed! */
2949 /* Base speed (1 to 10) */
2950 o_ptr->pval = randint1(5) + m_bonus(5, level);
2952 /* Super-charge the ring */
2953 while (randint0(100) < 50) o_ptr->pval++;
2959 o_ptr->ident |= (IDENT_BROKEN);
2962 o_ptr->curse_flags |= TRC_CURSED;
2965 o_ptr->pval = 0 - (o_ptr->pval);
2973 /* Mention the item */
2974 if (cheat_peek) object_mention(o_ptr);
2979 case SV_RING_LORDLY:
2983 one_lordly_high_resistance(o_ptr);
2987 /* Bonus to armor class */
2988 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
2994 case SV_RING_SEARCHING:
2996 /* Bonus to searching */
2997 o_ptr->pval = 1 + m_bonus(5, level);
3003 o_ptr->ident |= (IDENT_BROKEN);
3006 o_ptr->curse_flags |= TRC_CURSED;
3009 o_ptr->pval = 0 - (o_ptr->pval);
3015 /* Flames, Acid, Ice */
3016 case SV_RING_FLAMES:
3021 /* Bonus to armor class */
3022 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3026 /* Weakness, Stupidity */
3027 case SV_RING_WEAKNESS:
3028 case SV_RING_STUPIDITY:
3031 o_ptr->ident |= (IDENT_BROKEN);
3034 o_ptr->curse_flags |= TRC_CURSED;
3037 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3038 if (power > 0) power = 0 - power;
3043 /* WOE, Stupidity */
3047 o_ptr->ident |= (IDENT_BROKEN);
3050 o_ptr->curse_flags |= TRC_CURSED;
3053 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3054 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3055 if (power > 0) power = 0 - power;
3060 /* Ring of damage */
3061 case SV_RING_DAMAGE:
3063 /* Bonus to damage */
3064 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3070 o_ptr->ident |= (IDENT_BROKEN);
3073 o_ptr->curse_flags |= TRC_CURSED;
3076 o_ptr->to_d = 0 - o_ptr->to_d;
3082 /* Ring of Accuracy */
3083 case SV_RING_ACCURACY:
3086 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3092 o_ptr->ident |= (IDENT_BROKEN);
3095 o_ptr->curse_flags |= TRC_CURSED;
3098 o_ptr->to_h = 0 - o_ptr->to_h;
3104 /* Ring of Protection */
3105 case SV_RING_PROTECTION:
3107 /* Bonus to armor class */
3108 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3114 o_ptr->ident |= (IDENT_BROKEN);
3117 o_ptr->curse_flags |= TRC_CURSED;
3120 o_ptr->to_a = 0 - o_ptr->to_a;
3126 /* Ring of Slaying */
3127 case SV_RING_SLAYING:
3129 /* Bonus to damage and to hit */
3130 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3131 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3137 o_ptr->ident |= (IDENT_BROKEN);
3140 o_ptr->curse_flags |= TRC_CURSED;
3142 /* Reverse bonuses */
3143 o_ptr->to_h = 0 - o_ptr->to_h;
3144 o_ptr->to_d = 0 - o_ptr->to_d;
3150 case SV_RING_MUSCLE:
3152 o_ptr->pval = 1 + m_bonus(3, level);
3153 if (one_in_(4)) o_ptr->pval++;
3159 o_ptr->ident |= (IDENT_BROKEN);
3162 o_ptr->curse_flags |= TRC_CURSED;
3164 /* Reverse bonuses */
3165 o_ptr->pval = 0 - o_ptr->pval;
3170 case SV_RING_AGGRAVATION:
3173 o_ptr->ident |= (IDENT_BROKEN);
3176 o_ptr->curse_flags |= TRC_CURSED;
3178 if (power > 0) power = 0 - power;
3182 if (one_in_(400) && (power > 0) && !cursed_p(o_ptr) && (level > 79))
3184 o_ptr->pval = MIN(o_ptr->pval,4);
3185 /* Randart amulet */
3186 create_artifact(o_ptr, FALSE);
3188 else if ((power == 2) && one_in_(2))
3190 while(!o_ptr->name2)
3192 int tmp = m_bonus(10, level);
3193 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3194 switch(randint1(28))
3197 o_ptr->name2 = EGO_RING_THROW;
3200 if (k_ptr->flags3 & TR3_REGEN) break;
3201 o_ptr->name2 = EGO_RING_REGEN;
3204 if (k_ptr->flags3 & TR3_LITE)
3205 o_ptr->name2 = EGO_RING_LITE;
3208 if (k_ptr->flags2 & TR3_TELEPORT) break;
3209 o_ptr->name2 = EGO_RING_TELEPORT;
3212 if (o_ptr->to_h) break;
3213 o_ptr->name2 = EGO_RING_TO_H;
3216 if (o_ptr->to_d) break;
3217 o_ptr->name2 = EGO_RING_TO_D;
3220 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3221 o_ptr->name2 = EGO_RING_SLAY;
3224 if ((k_ptr->flags1 & TR1_STR) || o_ptr->to_h || o_ptr->to_d) break;
3225 o_ptr->name2 = EGO_RING_WIZARD;
3228 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3229 o_ptr->name2 = EGO_RING_HERO;
3232 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3233 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3234 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3235 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3238 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3239 if (!(k_ptr->flags2 & TR2_RES_FIRE) && (k_ptr->flags2 & (TR2_RES_COLD | TR2_RES_ELEC | TR2_RES_ACID))) break;
3240 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3241 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3242 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3245 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3246 if (!(k_ptr->flags2 & TR2_RES_COLD) && (k_ptr->flags2 & (TR2_RES_FIRE | TR2_RES_ELEC | TR2_RES_ACID))) break;
3247 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3248 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3249 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3252 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3253 if (!(k_ptr->flags2 & TR2_RES_ELEC) && (k_ptr->flags2 & (TR2_RES_COLD | TR2_RES_FIRE | TR2_RES_ACID))) break;
3254 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3255 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3258 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3259 if (!(k_ptr->flags2 & TR2_RES_ACID) && (k_ptr->flags2 & (TR2_RES_COLD | TR2_RES_ELEC | TR2_RES_FIRE))) break;
3260 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3261 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3263 case 21: case 22: case 23: case 24: case 25: case 26:
3264 switch (o_ptr->sval)
3267 if (!one_in_(3)) break;
3268 o_ptr->name2 = EGO_RING_D_SPEED;
3270 case SV_RING_DAMAGE:
3271 case SV_RING_ACCURACY:
3272 case SV_RING_SLAYING:
3273 if (one_in_(2)) break;
3274 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3277 o_ptr->name2 = EGO_RING_BERSERKER;
3278 o_ptr->to_h -= 2+randint1(4);
3281 case SV_RING_PROTECTION:
3282 o_ptr->name2 = EGO_RING_SUPER_AC;
3283 o_ptr->to_a += m_bonus(5, level);
3285 case SV_RING_RES_FEAR:
3286 o_ptr->name2 = EGO_RING_HERO;
3289 if (one_in_(2)) break;
3290 o_ptr->name2 = EGO_RING_HUNTER;
3292 case SV_RING_SEARCHING:
3293 o_ptr->name2 = EGO_RING_STEALTH;
3295 case SV_RING_TELEPORTATION:
3296 o_ptr->name2 = EGO_RING_TELE_AWAY;
3298 case SV_RING_RES_BLINDNESS:
3300 o_ptr->name2 = EGO_RING_RES_LITE;
3302 o_ptr->name2 = EGO_RING_RES_DARK;
3304 case SV_RING_LORDLY:
3305 if (!one_in_(20)) break;
3306 one_lordly_high_resistance(o_ptr);
3307 one_lordly_high_resistance(o_ptr);
3308 o_ptr->name2 = EGO_RING_TRUE;
3310 case SV_RING_SUSTAIN:
3311 if (!one_in_(4)) break;
3312 o_ptr->name2 = EGO_RING_RES_TIME;
3314 case SV_RING_FLAMES:
3315 if (!one_in_(2)) break;
3316 o_ptr->name2 = EGO_RING_DRAGON_F;
3319 if (!one_in_(2)) break;
3320 o_ptr->name2 = EGO_RING_DRAGON_C;
3322 case SV_RING_WARNING:
3323 if (!one_in_(2)) break;
3324 o_ptr->name2 = EGO_RING_M_DETECT;
3333 o_ptr->curse_flags = 0L;
3335 else if ((power == -2) && one_in_(2))
3337 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3338 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3339 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3340 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3341 o_ptr->art_flags1 = 0;
3342 o_ptr->art_flags2 = 0;
3343 while(!o_ptr->name2)
3345 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3349 if (k_ptr->flags3 & TR3_DRAIN_EXP) break;
3350 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3353 o_ptr->name2 = EGO_RING_NO_MELEE;
3356 if (k_ptr->flags3 & TR3_AGGRAVATE) break;
3357 o_ptr->name2 = EGO_RING_AGGRAVATE;
3360 if (k_ptr->flags3 & TR3_TY_CURSE) break;
3361 o_ptr->name2 = EGO_RING_TY_CURSE;
3364 o_ptr->name2 = EGO_RING_ALBINO;
3369 o_ptr->ident |= (IDENT_BROKEN);
3372 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3380 switch (o_ptr->sval)
3382 /* Amulet of wisdom/charisma */
3383 case SV_AMULET_INTELLIGENCE:
3384 case SV_AMULET_WISDOM:
3385 case SV_AMULET_CHARISMA:
3387 o_ptr->pval = 1 + m_bonus(5, level);
3393 o_ptr->ident |= (IDENT_BROKEN);
3396 o_ptr->curse_flags |= (TRC_CURSED);
3398 /* Reverse bonuses */
3399 o_ptr->pval = 0 - o_ptr->pval;
3405 /* Amulet of brilliance */
3406 case SV_AMULET_BRILLIANCE:
3408 o_ptr->pval = 1 + m_bonus(3, level);
3409 if (one_in_(4)) o_ptr->pval++;
3415 o_ptr->ident |= (IDENT_BROKEN);
3418 o_ptr->curse_flags |= (TRC_CURSED);
3420 /* Reverse bonuses */
3421 o_ptr->pval = 0 - o_ptr->pval;
3427 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3431 o_ptr->curse_flags |= (TRC_CURSED);
3436 case SV_AMULET_RESISTANCE:
3438 if (one_in_(5)) one_high_resistance(o_ptr);
3439 if (one_in_(5)) o_ptr->art_flags2 |= TR2_RES_POIS;
3443 /* Amulet of searching */
3444 case SV_AMULET_SEARCHING:
3446 o_ptr->pval = randint1(2) + m_bonus(4, level);
3452 o_ptr->ident |= (IDENT_BROKEN);
3455 o_ptr->curse_flags |= (TRC_CURSED);
3457 /* Reverse bonuses */
3458 o_ptr->pval = 0 - (o_ptr->pval);
3464 /* Amulet of the Magi -- never cursed */
3465 case SV_AMULET_THE_MAGI:
3467 o_ptr->pval = randint1(5) + m_bonus(5, level);
3468 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3470 /* Boost the rating */
3473 /* Mention the item */
3474 if (cheat_peek) object_mention(o_ptr);
3479 /* Amulet of Doom -- always cursed */
3480 case SV_AMULET_DOOM:
3483 o_ptr->ident |= (IDENT_BROKEN);
3486 o_ptr->curse_flags |= (TRC_CURSED);
3489 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3490 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3491 if (power > 0) power = 0 - power;
3496 case SV_AMULET_MAGIC_MASTERY:
3498 o_ptr->pval = 1 + m_bonus(4, level);
3504 o_ptr->ident |= (IDENT_BROKEN);
3507 o_ptr->curse_flags |= (TRC_CURSED);
3509 /* Reverse bonuses */
3510 o_ptr->pval = 0 - o_ptr->pval;
3516 if (one_in_(150) && (power > 0) && !cursed_p(o_ptr) && (level > 79))
3518 o_ptr->pval = MIN(o_ptr->pval,4);
3519 /* Randart amulet */
3520 create_artifact(o_ptr, FALSE);
3522 else if ((power == 2) && one_in_(2))
3524 while(!o_ptr->name2)
3526 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3527 switch(randint1(21))
3530 if (k_ptr->flags3 & TR3_SLOW_DIGEST) break;
3531 o_ptr->name2 = EGO_AMU_SLOW_D;
3534 if (o_ptr->pval) break;
3535 o_ptr->name2 = EGO_AMU_INFRA;
3538 if (k_ptr->flags3 & TR3_SEE_INVIS) break;
3539 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3542 if (k_ptr->flags2 & TR2_HOLD_LIFE) break;
3543 o_ptr->name2 = EGO_AMU_HOLD_LIFE;
3546 if (k_ptr->flags3 & TR3_FEATHER) break;
3547 o_ptr->name2 = EGO_AMU_LEVITATION;
3549 case 10: case 11: case 21:
3550 o_ptr->name2 = EGO_AMU_AC;
3553 if (k_ptr->flags2 & TR2_RES_FIRE) break;
3554 if (m_bonus(10, level) > 8)
3555 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3557 o_ptr->name2 = EGO_AMU_RES_FIRE;
3560 if (k_ptr->flags2 & TR2_RES_COLD) break;
3561 if (m_bonus(10, level) > 8)
3562 o_ptr->name2 = EGO_AMU_RES_COLD_;
3564 o_ptr->name2 = EGO_AMU_RES_COLD;
3567 if (k_ptr->flags2 & TR2_RES_ELEC) break;
3568 if (m_bonus(10, level) > 8)
3569 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3571 o_ptr->name2 = EGO_AMU_RES_ELEC;
3574 if (k_ptr->flags2 & TR2_RES_ACID) break;
3575 if (m_bonus(10, level) > 8)
3576 o_ptr->name2 = EGO_AMU_RES_ACID_;
3578 o_ptr->name2 = EGO_AMU_RES_ACID;
3580 case 16: case 17: case 18: case 19: case 20:
3581 switch (o_ptr->sval)
3583 case SV_AMULET_TELEPORT:
3584 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3585 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3586 else o_ptr->name2 = EGO_AMU_TELEPORT;
3588 case SV_AMULET_RESIST_ACID:
3589 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3591 case SV_AMULET_SEARCHING:
3592 o_ptr->name2 = EGO_AMU_STEALTH;
3594 case SV_AMULET_BRILLIANCE:
3595 if (!one_in_(3)) break;
3596 o_ptr->name2 = EGO_AMU_IDENT;
3598 case SV_AMULET_CHARISMA:
3599 if (!one_in_(3)) break;
3600 o_ptr->name2 = EGO_AMU_CHARM;
3602 case SV_AMULET_THE_MAGI:
3603 if (one_in_(2)) break;
3604 o_ptr->name2 = EGO_AMU_GREAT;
3606 case SV_AMULET_RESISTANCE:
3607 if (!one_in_(5)) break;
3608 o_ptr->name2 = EGO_AMU_DEFENDER;
3610 case SV_AMULET_TELEPATHY:
3611 if (!one_in_(3)) break;
3612 o_ptr->name2 = EGO_AMU_DETECTION;
3618 o_ptr->curse_flags = 0L;
3620 else if ((power == -2) && one_in_(2))
3622 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3623 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3624 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3625 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3626 o_ptr->art_flags1 = 0;
3627 o_ptr->art_flags2 = 0;
3628 while(!o_ptr->name2)
3630 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3634 if (k_ptr->flags3 & TR3_DRAIN_EXP) break;
3635 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3638 o_ptr->name2 = EGO_AMU_FOOL;
3641 if (k_ptr->flags3 & TR3_AGGRAVATE) break;
3642 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3645 if (k_ptr->flags3 & TR3_TY_CURSE) break;
3646 o_ptr->name2 = EGO_AMU_TY_CURSE;
3649 o_ptr->name2 = EGO_AMU_NAIVETY;
3654 o_ptr->ident |= (IDENT_BROKEN);
3657 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3666 * Hack -- help pick an item type
3668 static bool item_monster_okay(int r_idx)
3670 monster_race *r_ptr = &r_info[r_idx];
3673 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3674 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3675 if (r_ptr->flags3 & RF3_RES_ALL) return (FALSE);
3676 if (r_ptr->flags7 & RF7_UNIQUE_7) return (FALSE);
3677 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3678 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3686 * Apply magic to an item known to be "boring"
3688 * Hack -- note the special code for various items
3690 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3692 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3694 /* Apply magic (good or bad) according to type */
3695 switch (o_ptr->tval)
3704 o_ptr->ident |= (IDENT_BROKEN);
3707 o_ptr->curse_flags |= (TRC_CURSED);
3714 o_ptr->xtra4 = o_ptr->pval;
3720 /* Hack -- Torches -- random fuel */
3721 if (o_ptr->sval == SV_LITE_TORCH)
3723 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3727 /* Hack -- Lanterns -- random fuel */
3728 if (o_ptr->sval == SV_LITE_LANTERN)
3730 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3734 if ((power == 2) || ((power == 1) && one_in_(3)))
3736 while (!o_ptr->name2)
3740 bool okay_flag = TRUE;
3742 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE, level);
3744 switch (o_ptr->name2)
3747 if (o_ptr->sval == SV_LITE_FEANOR)
3755 else if (power == -2)
3757 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE, level);
3759 switch (o_ptr->name2)
3761 case EGO_LITE_DARKNESS:
3773 /* The wand or staff gets a number of initial charges equal
3774 * to between 1/2 (+1) and the full object kind's pval. -LM-
3776 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
3782 /* Transfer the pval. -LM- */
3783 o_ptr->pval = k_ptr->pval;
3790 object_aware(o_ptr);
3791 object_known(o_ptr);
3800 monster_race *r_ptr;
3802 /* Pick a random non-unique monster race */
3805 i = randint1(max_r_idx - 1);
3807 if (!item_monster_okay(i)) continue;
3808 if (i == MON_TSUCHINOKO) continue;
3812 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
3814 /* Ignore dead monsters */
3815 if (!r_ptr->rarity) continue;
3817 /* Prefer less out-of-depth monsters */
3818 if (randint0(check)) continue;
3825 /* Some figurines are cursed */
3826 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
3831 msg_format("%s¤Î¿Í·Á, ¿¼¤µ +%d%s",
3833 msg_format("Figurine of %s, depth +%d%s",
3836 r_name + r_ptr->name, check - 1,
3837 !cursed_p(o_ptr) ? "" : " {cursed}");
3850 monster_race *r_ptr;
3852 if (o_ptr->sval == SV_SKELETON)
3854 match = RF9_DROP_SKELETON;
3856 else if (o_ptr->sval == SV_CORPSE)
3858 match = RF9_DROP_CORPSE;
3861 /* Hack -- Remove the monster restriction */
3862 get_mon_num_prep(item_monster_okay, NULL);
3864 /* Pick a random non-unique monster race */
3867 i = get_mon_num(dun_level);
3871 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
3873 /* Ignore dead monsters */
3874 if (!r_ptr->rarity) continue;
3876 /* Ignore corpseless monsters */
3877 if (!(r_ptr->flags9 & match)) continue;
3879 /* Prefer less out-of-depth monsters */
3880 if (randint0(check)) continue;
3890 msg_format("%s¤Î»àÂÎ,¿¼¤µ +%d",
3892 msg_format("Corpse of %s, depth +%d",
3895 r_name + r_ptr->name, check - 1);
3898 object_aware(o_ptr);
3899 object_known(o_ptr);
3907 monster_race *r_ptr;
3909 /* Pick a random monster race */
3912 i = randint1(max_r_idx - 1);
3916 /* Ignore dead monsters */
3917 if (!r_ptr->rarity) continue;
3927 msg_format("%s¤ÎÁü,", r_name + r_ptr->name);
3929 msg_format("Statue of %s", r_name + r_ptr->name);
3933 object_aware(o_ptr);
3934 object_known(o_ptr);
3941 byte obj_level = get_object_level(o_ptr);
3943 /* Hack -- skip ruined chests */
3944 if (obj_level <= 0) break;
3946 /* Hack -- pick a "difficulty" */
3947 o_ptr->pval = randint1(obj_level);
3948 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
3950 o_ptr->xtra3 = dun_level + 5;
3952 /* Never exceed "difficulty" of 55 to 59 */
3953 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
3962 * Complete the "creation" of an object by applying "magic" to the item
3964 * This includes not only rolling for random bonuses, but also putting the
3965 * finishing touches on ego-items and artifacts, giving charges to wands and
3966 * staffs, giving fuel to lites, and placing traps on chests.
3968 * In particular, note that "Instant Artifacts", if "created" by an external
3969 * routine, must pass through this function to complete the actual creation.
3971 * The base "chance" of the item being "good" increases with the "level"
3972 * parameter, which is usually derived from the dungeon level, being equal
3973 * to the level plus 10, up to a maximum of 75. If "good" is true, then
3974 * the object is guaranteed to be "good". If an object is "good", then
3975 * the chance that the object will be "great" (ego-item or artifact), also
3976 * increases with the "level", being equal to half the level, plus 5, up to
3977 * a maximum of 20. If "great" is true, then the object is guaranteed to be
3978 * "great". At dungeon level 65 and below, 15/100 objects are "great".
3980 * If the object is not "good", there is a chance it will be "cursed", and
3981 * if it is "cursed", there is a chance it will be "broken". These chances
3982 * are related to the "good" / "great" chances above.
3984 * Otherwise "normal" rings and amulets will be "good" half the time and
3985 * "cursed" half the time, unless the ring/amulet is always good or cursed.
3987 * If "okay" is true, and the object is going to be "great", then there is
3988 * a chance that an artifact will be created. This is true even if both the
3989 * "good" and "great" arguments are false. As a total hack, if "great" is
3990 * true, then the item gets 3 extra "attempts" to become an artifact.
3992 void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great, bool curse)
3995 int i, rolls, f1, f2, power;
3997 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
3999 /* Maximum "level" for various things */
4000 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4002 /* Base chance of being "good" */
4005 /* Maximal chance of being "good" */
4006 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4008 /* Base chance of being "great" */
4011 /* Maximal chance of being "great" */
4012 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4013 f2 = d_info[dungeon_type].obj_great;
4015 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4020 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4029 /* Roll for "good" */
4030 if (good || magik(f1))
4035 /* Roll for "great" */
4036 if (great || magik(f2)) power = 2;
4039 /* Roll for "cursed" */
4042 /* Assume "cursed" */
4045 /* Roll for "broken" */
4046 if (magik(f2)) power = -2;
4052 /* Assume 'cursed' */
4057 /* Everything else gets more badly cursed */
4064 /* Assume no rolls */
4067 /* Get one roll if excellent */
4068 if (power >= 2) rolls = 1;
4070 /* Hack -- Get four rolls if forced great */
4071 if (great) rolls = 4;
4073 /* Hack -- Get no rolls if not allowed */
4074 if (!okay || o_ptr->name1) rolls = 0;
4076 /* Roll for artifacts if allowed */
4077 for (i = 0; i < rolls; i++)
4079 /* Roll for an artifact */
4080 if (make_artifact(o_ptr)) break;
4081 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4083 if (make_artifact(o_ptr)) break;
4088 /* Hack -- analyze artifacts */
4091 artifact_type *a_ptr = &a_info[o_ptr->name1];
4093 /* Hack -- Mark the artifact as "created" */
4096 /* Extract the other fields */
4097 o_ptr->pval = a_ptr->pval;
4098 o_ptr->ac = a_ptr->ac;
4099 o_ptr->dd = a_ptr->dd;
4100 o_ptr->ds = a_ptr->ds;
4101 o_ptr->to_a = a_ptr->to_a;
4102 o_ptr->to_h = a_ptr->to_h;
4103 o_ptr->to_d = a_ptr->to_d;
4104 o_ptr->weight = a_ptr->weight;
4106 /* Hack -- extract the "broken" flag */
4107 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4109 /* Hack -- extract the "cursed" flag */
4110 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4111 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4112 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4113 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4114 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4115 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4117 /* Mega-Hack -- increase the rating */
4120 /* Mega-Hack -- increase the rating again */
4121 if (a_ptr->cost > 50000L) rating += 10;
4123 /* Mega-Hack -- increase the rating again */
4124 if (a_ptr->cost > 100000L) rating += 10;
4126 /* Set the good item flag */
4127 good_item_flag = TRUE;
4129 /* Cheat -- peek at the item */
4130 if (cheat_peek) object_mention(o_ptr);
4138 switch (o_ptr->tval)
4147 if (power) a_m_aux_1(o_ptr, lev, power);
4153 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4159 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4173 /* Elven Cloak and Black Clothes ... */
4174 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4175 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4176 o_ptr->pval = randint1(4);
4180 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4181 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4182 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4183 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4184 a_m_aux_2(o_ptr, lev, power);
4186 if (power) a_m_aux_2(o_ptr, lev, power);
4194 if (!power && (randint0(100) < 50)) power = -1;
4195 a_m_aux_3(o_ptr, lev, power);
4201 a_m_aux_4(o_ptr, lev, power);
4206 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4207 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4208 (p_ptr->pseikaku == SEIKAKU_SEXY))
4211 o_ptr->art_flags1 |= (TR1_STR | TR1_INT | TR1_WIS | TR1_DEX | TR1_CON | TR1_CHR);
4214 if (o_ptr->art_name) rating += 30;
4216 /* Hack -- analyze ego-items */
4217 else if (o_ptr->name2)
4219 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4221 /* Hack -- acquire "broken" flag */
4222 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4224 /* Hack -- acquire "cursed" flag */
4225 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4226 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4227 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4228 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4229 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4230 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4232 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4233 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4234 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4235 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4236 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4237 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4238 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4240 /* Hack -- apply extra penalties if needed */
4241 if (cursed_p(o_ptr) || broken_p(o_ptr))
4243 /* Hack -- obtain bonuses */
4244 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4245 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4246 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4248 /* Hack -- obtain pval */
4249 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4252 /* Hack -- apply extra bonuses if needed */
4255 /* Hack -- obtain bonuses */
4256 if (e_ptr->max_to_h)
4258 if (e_ptr->max_to_h > 127)
4259 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4260 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4262 if (e_ptr->max_to_d)
4264 if (e_ptr->max_to_d > 127)
4265 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4266 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4268 if (e_ptr->max_to_a)
4270 if (e_ptr->max_to_a > 127)
4271 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4272 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4275 /* Hack -- obtain pval */
4276 if (e_ptr->max_pval)
4278 if ((o_ptr->name2 == EGO_HA) && (o_ptr->art_flags1 & TR1_BLOWS))
4281 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4283 else if (o_ptr->name2 == EGO_ATTACKS)
4285 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4286 if (o_ptr->pval > 3) o_ptr->pval = 3;
4287 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4288 o_ptr->pval += randint1(2);
4290 else if (o_ptr->name2 == EGO_BAT)
4292 o_ptr->pval = randint1(e_ptr->max_pval);
4293 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4297 o_ptr->pval += randint1(e_ptr->max_pval);
4300 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4302 o_ptr->pval = randint1(o_ptr->pval);
4304 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4308 /* Hack -- apply rating bonus */
4309 rating += e_ptr->rating;
4311 /* Cheat -- describe the item */
4312 if (cheat_peek) object_mention(o_ptr);
4318 /* Examine real objects */
4321 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4323 /* Hack -- acquire "broken" flag */
4324 if (!get_object_cost(o_ptr)) o_ptr->ident |= (IDENT_BROKEN);
4326 /* Hack -- acquire "cursed" flag */
4327 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4328 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4329 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4330 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4331 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4332 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4338 * Hack -- determine if a template is "good"
4340 static bool kind_is_good(int k_idx)
4342 object_kind *k_ptr = &k_info[k_idx];
4344 /* Analyze the item type */
4345 switch (k_ptr->tval)
4347 /* Armor -- Good unless damaged */
4358 if (k_ptr->to_a < 0) return (FALSE);
4362 /* Weapons -- Good unless damaged */
4369 if (k_ptr->to_h < 0) return (FALSE);
4370 if (k_ptr->to_d < 0) return (FALSE);
4374 /* Ammo -- Arrows/Bolts are good */
4381 /* Books -- High level books are good (except Arcane books) */
4383 case TV_SORCERY_BOOK:
4384 case TV_NATURE_BOOK:
4388 case TV_ENCHANT_BOOK:
4389 case TV_DAEMON_BOOK:
4391 case TV_HISSATSU_BOOK:
4393 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4397 /* Rings -- Rings of Speed are good */
4400 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4401 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4405 /* Amulets -- Amulets of the Magi and Resistance are good */
4408 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4409 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4414 /* Assume not good */
4420 * Attempt to make an object (normal or good/great)
4422 * This routine plays nasty games to generate the "special artifacts".
4424 * This routine uses "object_level" for the "generation level".
4426 * We assume that the given object has been "wiped".
4428 bool make_object(object_type *j_ptr, bool good, bool great)
4434 /* Chance of "special object" */
4435 prob = (good ? 10 : 1000);
4437 /* Base level for the object */
4438 base = (good ? (object_level + 10) : object_level);
4441 /* Generate a special object, or a normal object */
4442 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4449 /* Activate restriction */
4450 get_obj_num_hook = kind_is_good;
4452 /* Prepare allocation table */
4456 /* Pick a random object */
4457 k_idx = get_obj_num(base);
4460 if (get_obj_num_hook)
4462 /* Clear restriction */
4463 get_obj_num_hook = NULL;
4465 /* Prepare allocation table */
4469 /* Handle failure */
4470 if (!k_idx) return (FALSE);
4472 /* Prepare the object */
4473 object_prep(j_ptr, k_idx);
4476 /* Apply magic (allow artifacts) */
4477 apply_magic(j_ptr, object_level, TRUE, good, great, FALSE);
4479 /* Hack -- generate multiple spikes/missiles */
4480 switch (j_ptr->tval)
4488 j_ptr->number = (byte)damroll(6, 7);
4492 obj_level = get_object_level(j_ptr);
4493 if (artifact_p(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4495 /* Notice "okay" out-of-depth objects */
4496 if (!cursed_p(j_ptr) && !broken_p(j_ptr) &&
4497 (obj_level > dun_level))
4499 /* Rating increase */
4500 rating += (obj_level - dun_level);
4502 /* Cheat -- peek at items */
4503 if (cheat_peek) object_mention(j_ptr);
4512 * Attempt to place an object (normal or good/great) at the given location.
4514 * This routine plays nasty games to generate the "special artifacts".
4516 * This routine uses "object_level" for the "generation level".
4518 * This routine requires a clean floor grid destination.
4520 void place_object(int y, int x, bool good, bool great)
4530 /* Paranoia -- check bounds */
4531 if (!in_bounds(y, x)) return;
4533 /* Require clean floor space */
4534 if (!cave_clean_bold(y, x)) return;
4537 /* Get local object */
4540 /* Wipe the object */
4543 /* Make an object (if possible) */
4544 if (!make_object(q_ptr, good, great)) return;
4547 /* Make an object */
4555 /* Acquire object */
4556 o_ptr = &o_list[o_idx];
4558 /* Structure Copy */
4559 object_copy(o_ptr, q_ptr);
4566 c_ptr = &cave[y][x];
4569 o_ptr->next_o_idx = c_ptr->o_idx;
4571 /* Place the object */
4572 c_ptr->o_idx = o_idx;
4582 /* Hack -- Preserve artifacts */
4585 a_info[q_ptr->name1].cur_num = 0;
4592 * Make a treasure object
4594 * The location must be a legal, clean, floor grid.
4596 bool make_gold(object_type *j_ptr)
4603 /* Hack -- Pick a Treasure variety */
4604 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4606 /* Apply "extra" magic */
4607 if (one_in_(GREAT_OBJ))
4609 i += randint1(object_level + 1);
4612 /* Hack -- Creeping Coins only generate "themselves" */
4613 if (coin_type) i = coin_type;
4615 /* Do not create "illegal" Treasure Types */
4616 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4618 /* Prepare a gold object */
4619 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4621 /* Hack -- Base coin cost */
4622 base = k_info[OBJ_GOLD_LIST+i].cost;
4624 /* Determine how much the treasure is "worth" */
4625 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
4633 * Places a treasure (Gold or Gems) at given location
4635 * The location must be a legal, clean, floor grid.
4637 void place_gold(int y, int x)
4647 /* Paranoia -- check bounds */
4648 if (!in_bounds(y, x)) return;
4650 /* Require clean floor space */
4651 if (!cave_clean_bold(y, x)) return;
4654 /* Get local object */
4657 /* Wipe the object */
4660 /* Make some gold */
4661 if (!make_gold(q_ptr)) return;
4664 /* Make an object */
4672 /* Acquire object */
4673 o_ptr = &o_list[o_idx];
4675 /* Copy the object */
4676 object_copy(o_ptr, q_ptr);
4683 c_ptr = &cave[y][x];
4686 o_ptr->next_o_idx = c_ptr->o_idx;
4688 /* Place the object */
4689 c_ptr->o_idx = o_idx;
4701 * Let an object fall to the ground at or near a location.
4703 * The initial location is assumed to be "in_bounds()".
4705 * This function takes a parameter "chance". This is the percentage
4706 * chance that the item will "disappear" instead of drop. If the object
4707 * has been thrown, then this is the chance of disappearance on contact.
4709 * Hack -- this function uses "chance" to determine if it should produce
4710 * some form of "description" of the drop event (under the player).
4712 * We check several locations to see if we can find a location at which
4713 * the object can combine, stack, or be placed. Artifacts will try very
4714 * hard to be placed, including "teleporting" to a useful grid if needed.
4716 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
4727 s16b this_o_idx, next_o_idx = 0;
4731 char o_name[MAX_NLEN];
4736 bool plural = FALSE;
4739 /* Extract plural */
4740 if (j_ptr->number != 1) plural = TRUE;
4742 /* Describe object */
4743 object_desc(o_name, j_ptr, FALSE, 0);
4746 /* Handle normal "breakage" */
4747 if (!(j_ptr->art_name || artifact_p(j_ptr)) && (randint0(100) < chance))
4751 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
4753 msg_format("The %s disappear%s.",
4754 o_name, (plural ? "" : "s"));
4760 if (wizard) msg_print("(ÇË»)");
4762 if (wizard) msg_print("(breakage)");
4781 /* Scan local grids */
4782 for (dy = -3; dy <= 3; dy++)
4784 /* Scan local grids */
4785 for (dx = -3; dx <= 3; dx++)
4789 /* Calculate actual distance */
4790 d = (dy * dy) + (dx * dx);
4792 /* Ignore distant grids */
4793 if (d > 10) continue;
4799 /* Skip illegal grids */
4800 if (!in_bounds(ty, tx)) continue;
4802 /* Require line of sight */
4803 if (!los(y, x, ty, tx)) continue;
4806 c_ptr = &cave[ty][tx];
4808 /* Require floor space */
4809 if ((c_ptr->feat != FEAT_FLOOR) &&
4810 (c_ptr->feat != FEAT_SHAL_WATER) &&
4811 (c_ptr->feat != FEAT_GRASS) &&
4812 (c_ptr->feat != FEAT_DIRT) &&
4813 (c_ptr->feat != FEAT_FLOWER) &&
4814 (c_ptr->feat != FEAT_DEEP_GRASS) &&
4815 (c_ptr->feat != FEAT_SHAL_LAVA) &&
4816 (c_ptr->feat != FEAT_TREES)) continue;
4818 if (c_ptr->info & CAVE_TRAP) continue;
4823 /* Scan objects in that grid */
4824 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
4828 /* Acquire object */
4829 o_ptr = &o_list[this_o_idx];
4831 /* Acquire next object */
4832 next_o_idx = o_ptr->next_o_idx;
4834 /* Check for possible combination */
4835 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
4841 /* Add new object */
4845 if (k > 99) continue;
4847 /* Calculate score */
4848 s = 1000 - (d + k * 5);
4850 /* Skip bad values */
4851 if (s < bs) continue;
4853 /* New best value */
4856 /* Apply the randomizer to equivalent values */
4857 if ((++bn >= 2) && !one_in_(bn)) continue;
4872 /* Handle lack of space */
4873 if (!flag && !(artifact_p(j_ptr) || j_ptr->art_name))
4877 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
4879 msg_format("The %s disappear%s.",
4880 o_name, (plural ? "" : "s"));
4886 if (wizard) msg_print("(¾²¥¹¥Ú¡¼¥¹¤¬¤Ê¤¤)");
4888 if (wizard) msg_print("(no floor space)");
4898 for (i = 0; !flag; i++)
4903 ty = rand_spread(by, 1);
4904 tx = rand_spread(bx, 1);
4907 /* Random locations */
4910 ty = randint0(cur_hgt);
4911 tx = randint0(cur_wid);
4915 c_ptr = &cave[ty][tx];
4917 /* Require floor space (or shallow terrain) -KMW- */
4918 if ((c_ptr->feat != FEAT_FLOOR) &&
4919 (c_ptr->feat != FEAT_SHAL_WATER) &&
4920 (c_ptr->feat != FEAT_GRASS) &&
4921 (c_ptr->feat != FEAT_DIRT) &&
4922 (c_ptr->feat != FEAT_SHAL_LAVA)) continue;
4924 /* Bounce to that location */
4928 /* Require floor space */
4929 if (!cave_clean_bold(by, bx)) continue;
4937 c_ptr = &cave[by][bx];
4939 /* Scan objects in that grid for combination */
4940 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
4944 /* Acquire object */
4945 o_ptr = &o_list[this_o_idx];
4947 /* Acquire next object */
4948 next_o_idx = o_ptr->next_o_idx;
4950 /* Check for combination */
4951 if (object_similar(o_ptr, j_ptr))
4953 /* Combine the items */
4954 object_absorb(o_ptr, j_ptr);
4964 /* Get new object */
4965 if (!done) o_idx = o_pop();
4968 if (!done && !o_idx)
4972 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
4974 msg_format("The %s disappear%s.",
4975 o_name, (plural ? "" : "s"));
4981 if (wizard) msg_print("(¥¢¥¤¥Æ¥à¤¬Â¿²á¤®¤ë)");
4983 if (wizard) msg_print("(too many objects)");
4987 /* Hack -- Preserve artifacts */
4990 a_info[j_ptr->name1].cur_num = 0;
5000 /* Structure copy */
5001 object_copy(&o_list[o_idx], j_ptr);
5003 /* Access new object */
5004 j_ptr = &o_list[o_idx];
5011 j_ptr->held_m_idx = 0;
5014 j_ptr->next_o_idx = c_ptr->o_idx;
5016 /* Place the object */
5017 c_ptr->o_idx = o_idx;
5032 /* Mega-Hack -- no message if "dropped" by player */
5033 /* Message when an object falls under the player */
5034 if (chance && (by == py) && (bx == px))
5037 msg_print("²¿¤«¤¬Â²¼¤Ëž¤¬¤Ã¤Æ¤¤¿¡£");
5039 msg_print("You feel something roll beneath your feet.");
5052 * Scatter some "great" objects near the player
5054 void acquirement(int y1, int x1, int num, bool great, bool known)
5057 object_type object_type_body;
5062 /* Get local object */
5063 i_ptr = &object_type_body;
5065 /* Wipe the object */
5068 /* Make a good (or great) object (if possible) */
5069 if (!make_object(i_ptr, TRUE, great)) continue;
5073 object_aware(i_ptr);
5074 object_known(i_ptr);
5077 /* Drop the object */
5078 (void)drop_near(i_ptr, -1, y1, x1);
5083 #define MAX_TRAPS 18
5085 static int trap_num[MAX_TRAPS] =
5089 FEAT_TRAP_SPIKED_PIT,
5090 FEAT_TRAP_POISON_PIT,
5109 * Hack -- instantiate a trap
5111 * XXX XXX XXX This routine should be redone to reflect trap "level".
5112 * That is, it does not make sense to have spiked pits at 50 feet.
5113 * Actually, it is not this routine, but the "trap instantiation"
5114 * code, which should also check for "trap doors" on quest levels.
5116 void pick_trap(int y, int x)
5120 cave_type *c_ptr = &cave[y][x];
5123 if (!(c_ptr->info & CAVE_TRAP)) return;
5124 c_ptr->info &= ~(CAVE_TRAP);
5129 /* Hack -- pick a trap */
5130 feat = trap_num[randint0(MAX_TRAPS)];
5132 /* Accept non-trapdoors */
5133 if (feat != FEAT_TRAP_TRAPDOOR) break;
5135 /* Hack -- no trap doors on special levels */
5136 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5138 /* Hack -- no trap doors on the deepest level */
5139 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5144 /* Activate the trap */
5145 cave_set_feat(y, x, feat);
5150 * Places a random trap at the given location.
5152 * The location must be a legal, naked, floor grid.
5154 * Note that all traps start out as "invisible" and "untyped", and then
5155 * when they are "discovered" (by detecting them or setting them off),
5156 * the trap is "instantiated" as a visible, "typed", trap.
5158 void place_trap(int y, int x)
5160 /* Paranoia -- verify location */
5161 if (!in_bounds(y, x)) return;
5163 /* Require empty, clean, floor grid */
5164 if (!cave_naked_bold(y, x)) return;
5166 /* Place an invisible trap */
5167 cave[y][x].info |= CAVE_TRAP;
5172 * Describe the charges on an item in the inventory.
5174 void inven_item_charges(int item)
5176 object_type *o_ptr = &inventory[item];
5178 /* Require staff/wand */
5179 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5181 /* Require known item */
5182 if (!object_known_p(o_ptr)) return;
5185 if (o_ptr->pval <= 0)
5187 msg_print("¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
5191 msg_format("¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
5194 /* Multiple charges */
5195 if (o_ptr->pval != 1)
5197 /* Print a message */
5198 msg_format("You have %d charges remaining.", o_ptr->pval);
5204 /* Print a message */
5205 msg_format("You have %d charge remaining.", o_ptr->pval);
5213 * Describe an item in the inventory.
5215 void inven_item_describe(int item)
5217 object_type *o_ptr = &inventory[item];
5218 char o_name[MAX_NLEN];
5220 /* Get a description */
5221 object_desc(o_name, o_ptr, TRUE, 3);
5223 /* Print a message */
5225 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤¹¤ë */
5226 if (o_ptr->number <= 0)
5228 /*FIRST*//*¤³¤³¤Ï¤â¤¦Ä̤é¤Ê¤¤¤«¤â */
5229 msg_format("¤â¤¦%s¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£", o_name);
5233 /* ¥¢¥¤¥Æ¥à̾¤ò±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½Âбþ */
5234 msg_format("¤Þ¤À %s¤ò»ý¤Ã¤Æ¤¤¤ë¡£", o_name);
5237 msg_format("You have %s.", o_name);
5244 * Increase the "number" of an item in the inventory
5246 void inven_item_increase(int item, int num)
5248 object_type *o_ptr = &inventory[item];
5251 num += o_ptr->number;
5254 if (num > 255) num = 255;
5255 else if (num < 0) num = 0;
5258 num -= o_ptr->number;
5260 /* Change the number and weight */
5263 /* Add the number */
5264 o_ptr->number += num;
5266 /* Add the weight */
5267 p_ptr->total_weight += (num * o_ptr->weight);
5269 /* Recalculate bonuses */
5270 p_ptr->update |= (PU_BONUS);
5272 /* Recalculate mana XXX */
5273 p_ptr->update |= (PU_MANA);
5275 /* Combine the pack */
5276 p_ptr->notice |= (PN_COMBINE);
5279 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5285 * Erase an inventory slot if it has no more items
5287 void inven_item_optimize(int item)
5289 object_type *o_ptr = &inventory[item];
5291 /* Only optimize real items */
5292 if (!o_ptr->k_idx) return;
5294 /* Only optimize empty items */
5295 if (o_ptr->number) return;
5297 /* The item is in the pack */
5298 if (item < INVEN_RARM)
5305 /* Slide everything down */
5306 for (i = item; i < INVEN_PACK; i++)
5308 /* Structure copy */
5309 inventory[i] = inventory[i+1];
5312 /* Erase the "final" slot */
5313 object_wipe(&inventory[i]);
5316 p_ptr->window |= (PW_INVEN);
5319 /* The item is being wielded */
5325 /* Erase the empty slot */
5326 object_wipe(&inventory[item]);
5328 /* Recalculate bonuses */
5329 p_ptr->update |= (PU_BONUS);
5331 /* Recalculate torch */
5332 p_ptr->update |= (PU_TORCH);
5334 /* Recalculate mana XXX */
5335 p_ptr->update |= (PU_MANA);
5338 p_ptr->window |= (PW_EQUIP);
5342 p_ptr->window |= (PW_SPELL);
5347 * Describe the charges on an item on the floor.
5349 void floor_item_charges(int item)
5351 object_type *o_ptr = &o_list[item];
5353 /* Require staff/wand */
5354 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5356 /* Require known item */
5357 if (!object_known_p(o_ptr)) return;
5360 if (o_ptr->pval <= 0)
5362 msg_print("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
5366 msg_format("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
5369 /* Multiple charges */
5370 if (o_ptr->pval != 1)
5372 /* Print a message */
5373 msg_format("There are %d charges remaining.", o_ptr->pval);
5379 /* Print a message */
5380 msg_format("There is %d charge remaining.", o_ptr->pval);
5388 * Describe an item in the inventory.
5390 void floor_item_describe(int item)
5392 object_type *o_ptr = &o_list[item];
5393 char o_name[MAX_NLEN];
5395 /* Get a description */
5396 object_desc(o_name, o_ptr, TRUE, 3);
5398 /* Print a message */
5400 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤òʬ¤±¤ë */
5401 if (o_ptr->number <= 0)
5403 msg_format("¾²¾å¤Ë¤Ï¡¢¤â¤¦%s¤Ï¤Ê¤¤¡£", o_name);
5407 msg_format("¾²¾å¤Ë¤Ï¡¢¤Þ¤À %s¤¬¤¢¤ë¡£", o_name);
5410 msg_format("You see %s.", o_name);
5417 * Increase the "number" of an item on the floor
5419 void floor_item_increase(int item, int num)
5421 object_type *o_ptr = &o_list[item];
5424 num += o_ptr->number;
5427 if (num > 255) num = 255;
5428 else if (num < 0) num = 0;
5431 num -= o_ptr->number;
5433 /* Change the number */
5434 o_ptr->number += num;
5439 * Optimize an item on the floor (destroy "empty" items)
5441 void floor_item_optimize(int item)
5443 object_type *o_ptr = &o_list[item];
5445 /* Paranoia -- be sure it exists */
5446 if (!o_ptr->k_idx) return;
5448 /* Only optimize empty items */
5449 if (o_ptr->number) return;
5451 /* Delete the object */
5452 delete_object_idx(item);
5457 * Check if we have space for an item in the pack without overflow
5459 bool inven_carry_okay(object_type *o_ptr)
5464 if (inven_cnt < INVEN_PACK) return (TRUE);
5467 for (j = 0; j < INVEN_PACK; j++)
5469 object_type *j_ptr = &inventory[j];
5471 /* Skip non-objects */
5472 if (!j_ptr->k_idx) continue;
5474 /* Check if the two items can be combined */
5475 if (object_similar(j_ptr, o_ptr)) return (TRUE);
5484 * Add an item to the players inventory, and return the slot used.
5486 * If the new item can combine with an existing item in the inventory,
5487 * it will do so, using "object_similar()" and "object_absorb()", else,
5488 * the item will be placed into the "proper" location in the inventory.
5490 * This function can be used to "over-fill" the player's pack, but only
5491 * once, and such an action must trigger the "overflow" code immediately.
5492 * Note that when the pack is being "over-filled", the new item must be
5493 * placed into the "overflow" slot, and the "overflow" must take place
5494 * before the pack is reordered, but (optionally) after the pack is
5495 * combined. This may be tricky. See "dungeon.c" for info.
5497 * Note that this code must remove any location/stack information
5498 * from the object once it is placed into the inventory.
5500 s16b inven_carry(object_type *o_ptr)
5508 /* Check for combining */
5509 for (j = 0; j < INVEN_PACK; j++)
5511 j_ptr = &inventory[j];
5513 /* Skip non-objects */
5514 if (!j_ptr->k_idx) continue;
5516 /* Hack -- track last item */
5519 /* Check if the two items can be combined */
5520 if (object_similar(j_ptr, o_ptr))
5522 /* Combine the items */
5523 object_absorb(j_ptr, o_ptr);
5525 /* Increase the weight */
5526 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
5528 /* Recalculate bonuses */
5529 p_ptr->update |= (PU_BONUS);
5532 p_ptr->window |= (PW_INVEN);
5541 if (inven_cnt > INVEN_PACK) return (-1);
5543 /* Find an empty slot */
5544 for (j = 0; j <= INVEN_PACK; j++)
5546 j_ptr = &inventory[j];
5548 /* Use it if found */
5549 if (!j_ptr->k_idx) break;
5556 /* Reorder the pack */
5559 s32b o_value, j_value;
5561 /* Get the "value" of the item */
5562 o_value = object_value(o_ptr);
5564 /* Scan every occupied slot */
5565 for (j = 0; j < INVEN_PACK; j++)
5567 j_ptr = &inventory[j];
5569 /* Use empty slots */
5570 if (!j_ptr->k_idx) break;
5572 /* Hack -- readable books always come first */
5573 if ((o_ptr->tval == REALM1_BOOK) &&
5574 (j_ptr->tval != REALM1_BOOK)) break;
5575 if ((j_ptr->tval == REALM1_BOOK) &&
5576 (o_ptr->tval != REALM1_BOOK)) continue;
5578 if ((o_ptr->tval == REALM2_BOOK) &&
5579 (j_ptr->tval != REALM2_BOOK)) break;
5580 if ((j_ptr->tval == REALM2_BOOK) &&
5581 (o_ptr->tval != REALM2_BOOK)) continue;
5583 /* Objects sort by decreasing type */
5584 if (o_ptr->tval > j_ptr->tval) break;
5585 if (o_ptr->tval < j_ptr->tval) continue;
5587 /* Non-aware (flavored) items always come last */
5588 if (!object_aware_p(o_ptr)) continue;
5589 if (!object_aware_p(j_ptr)) break;
5591 /* Objects sort by increasing sval */
5592 if (o_ptr->sval < j_ptr->sval) break;
5593 if (o_ptr->sval > j_ptr->sval) continue;
5595 /* Unidentified objects always come last */
5596 if (!object_known_p(o_ptr)) continue;
5597 if (!object_known_p(j_ptr)) break;
5599 /* Hack: otherwise identical rods sort by
5600 increasing recharge time --dsb */
5601 if (o_ptr->tval == TV_ROD)
5603 if (o_ptr->pval < j_ptr->pval) break;
5604 if (o_ptr->pval > j_ptr->pval) continue;
5607 /* Determine the "value" of the pack item */
5608 j_value = object_value(j_ptr);
5610 /* Objects sort by decreasing value */
5611 if (o_value > j_value) break;
5612 if (o_value < j_value) continue;
5619 for (k = n; k >= i; k--)
5621 /* Hack -- Slide the item */
5622 object_copy(&inventory[k+1], &inventory[k]);
5625 /* Wipe the empty slot */
5626 object_wipe(&inventory[i]);
5631 object_copy(&inventory[i], o_ptr);
5633 /* Access new object */
5634 j_ptr = &inventory[i];
5637 j_ptr->next_o_idx = 0;
5639 /* Forget monster */
5640 j_ptr->held_m_idx = 0;
5642 /* Forget location */
5643 j_ptr->iy = j_ptr->ix = 0;
5645 /* No longer marked */
5646 j_ptr->marked = FALSE;
5648 /* Increase the weight */
5649 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
5651 /* Count the items */
5654 /* Recalculate bonuses */
5655 p_ptr->update |= (PU_BONUS);
5657 /* Combine and Reorder pack */
5658 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5661 p_ptr->window |= (PW_INVEN);
5663 /* Return the slot */
5669 * Take off (some of) a non-cursed equipment item
5671 * Note that only one item at a time can be wielded per slot.
5673 * Note that taking off an item when "full" may cause that item
5674 * to fall to the ground.
5676 * Return the inventory slot into which the item is placed.
5678 s16b inven_takeoff(int item, int amt)
5689 char o_name[MAX_NLEN];
5692 /* Get the item to take off */
5693 o_ptr = &inventory[item];
5696 if (amt <= 0) return (-1);
5699 if (amt > o_ptr->number) amt = o_ptr->number;
5701 /* Get local object */
5704 /* Obtain a local object */
5705 object_copy(q_ptr, o_ptr);
5707 /* Modify quantity */
5708 q_ptr->number = amt;
5710 /* Describe the object */
5711 object_desc(o_name, q_ptr, TRUE, 3);
5713 /* Took off weapon */
5714 if (item == INVEN_RARM)
5717 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
5719 act = "You were wielding";
5725 else if (item == INVEN_BOW)
5728 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
5730 act = "You were holding";
5735 /* Took off light */
5736 else if (item == INVEN_LITE)
5739 act = "¤ò¸÷¸»¤«¤é¤Ï¤º¤·¤¿";
5741 act = "You were holding";
5746 /* Took off something */
5750 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
5752 act = "You were wearing";
5757 /* Modify, Optimize */
5758 inven_item_increase(item, -amt);
5759 inven_item_optimize(item);
5761 /* Carry the object */
5762 slot = inven_carry(q_ptr);
5766 msg_format("%s(%c)%s¡£", o_name, index_to_label(slot), act);
5768 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
5778 * Drop (some of) a non-cursed inventory/equipment item
5780 * The object will be dropped "near" the current location
5782 void inven_drop(int item, int amt)
5789 char o_name[MAX_NLEN];
5792 /* Access original object */
5793 o_ptr = &inventory[item];
5796 if (amt <= 0) return;
5799 if (amt > o_ptr->number) amt = o_ptr->number;
5802 /* Take off equipment */
5803 if (item >= INVEN_RARM)
5805 /* Take off first */
5806 item = inven_takeoff(item, amt);
5808 /* Access original object */
5809 o_ptr = &inventory[item];
5813 /* Get local object */
5816 /* Obtain local object */
5817 object_copy(q_ptr, o_ptr);
5819 /* Distribute charges of wands or rods */
5820 distribute_charges(o_ptr, q_ptr, amt);
5822 /* Modify quantity */
5823 q_ptr->number = amt;
5825 /* Describe local object */
5826 object_desc(o_name, q_ptr, TRUE, 3);
5830 msg_format("%s(%c)¤òÍî¤È¤·¤¿¡£", o_name, index_to_label(item));
5832 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5836 /* Drop it near the player */
5837 (void)drop_near(q_ptr, 0, py, px);
5839 /* Modify, Describe, Optimize */
5840 inven_item_increase(item, -amt);
5841 inven_item_describe(item);
5842 inven_item_optimize(item);
5847 * Combine items in the pack
5849 * Note special handling of the "overflow" slot
5851 void combine_pack(void)
5859 /* Combine the pack (backwards) */
5860 for (i = INVEN_PACK; i > 0; i--)
5863 o_ptr = &inventory[i];
5865 /* Skip empty items */
5866 if (!o_ptr->k_idx) continue;
5868 /* Scan the items above that item */
5869 for (j = 0; j < i; j++)
5872 j_ptr = &inventory[j];
5874 /* Skip empty items */
5875 if (!j_ptr->k_idx) continue;
5877 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
5878 if (object_similar_part(j_ptr, o_ptr)
5879 && j_ptr->number < MAX_STACK_SIZE-1)
5881 if (o_ptr->number + j_ptr->number < MAX_STACK_SIZE)
5886 /* Add together the item counts */
5887 object_absorb(j_ptr, o_ptr);
5889 /* One object is gone */
5892 /* Slide everything down */
5893 for (k = i; k < INVEN_PACK; k++)
5895 /* Structure copy */
5896 inventory[k] = inventory[k+1];
5899 /* Erase the "final" slot */
5900 object_wipe(&inventory[k]);
5904 int remain = j_ptr->number + o_ptr->number - 99;
5906 o_ptr->number -= remain;
5908 /* Add together the item counts */
5909 object_absorb(j_ptr, o_ptr);
5911 o_ptr->number = remain;
5915 p_ptr->window |= (PW_INVEN);
5925 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤ò¤Þ¤È¤áľ¤·¤¿¡£");
5927 if (flag) msg_print("You combine some items in your pack.");
5934 * Reorder items in the pack
5936 * Note special handling of the "overflow" slot
5938 void reorder_pack(void)
5950 /* Re-order the pack (forwards) */
5951 for (i = 0; i < INVEN_PACK; i++)
5953 /* Mega-Hack -- allow "proper" over-flow */
5954 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
5957 o_ptr = &inventory[i];
5959 /* Skip empty slots */
5960 if (!o_ptr->k_idx) continue;
5962 /* Get the "value" of the item */
5963 o_value = object_value(o_ptr);
5965 /* Scan every occupied slot */
5966 for (j = 0; j < INVEN_PACK; j++)
5968 /* Get the item already there */
5969 j_ptr = &inventory[j];
5971 /* Use empty slots */
5972 if (!j_ptr->k_idx) break;
5974 /* Hack -- readable books always come first */
5975 if ((o_ptr->tval == REALM1_BOOK) &&
5976 (j_ptr->tval != REALM1_BOOK)) break;
5977 if ((j_ptr->tval == REALM1_BOOK) &&
5978 (o_ptr->tval != REALM1_BOOK)) continue;
5980 if ((o_ptr->tval == REALM2_BOOK) &&
5981 (j_ptr->tval != REALM2_BOOK)) break;
5982 if ((j_ptr->tval == REALM2_BOOK) &&
5983 (o_ptr->tval != REALM2_BOOK)) continue;
5985 /* Objects sort by decreasing type */
5986 if (o_ptr->tval > j_ptr->tval) break;
5987 if (o_ptr->tval < j_ptr->tval) continue;
5989 /* Non-aware (flavored) items always come last */
5990 if (!object_aware_p(o_ptr)) continue;
5991 if (!object_aware_p(j_ptr)) break;
5993 /* Objects sort by increasing sval */
5994 if (o_ptr->sval < j_ptr->sval) break;
5995 if (o_ptr->sval > j_ptr->sval) continue;
5997 /* Unidentified objects always come last */
5998 if (!object_known_p(o_ptr)) continue;
5999 if (!object_known_p(j_ptr)) break;
6001 /* Hack: otherwise identical rods sort by
6002 increasing recharge time --dsb */
6003 if (o_ptr->tval == TV_ROD)
6005 if (o_ptr->pval < j_ptr->pval) break;
6006 if (o_ptr->pval > j_ptr->pval) continue;
6009 /* Determine the "value" of the pack item */
6010 j_value = object_value(j_ptr);
6014 /* Objects sort by decreasing value */
6015 if (o_value > j_value) break;
6016 if (o_value < j_value) continue;
6019 /* Never move down */
6020 if (j >= i) continue;
6025 /* Get local object */
6028 /* Save a copy of the moving item */
6029 object_copy(q_ptr, &inventory[i]);
6031 /* Slide the objects */
6032 for (k = i; k > j; k--)
6034 /* Slide the item */
6035 object_copy(&inventory[k], &inventory[k-1]);
6038 /* Insert the moving item */
6039 object_copy(&inventory[j], q_ptr);
6042 p_ptr->window |= (PW_INVEN);
6047 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤òÊ¤Ùľ¤·¤¿¡£");
6049 if (flag) msg_print("You reorder some items in your pack.");
6056 * Hack -- display an object kind in the current window
6058 * Include list of usable spells for readible books
6060 void display_koff(int k_idx)
6067 char o_name[MAX_NLEN];
6070 /* Erase the window */
6071 for (y = 0; y < Term->hgt; y++)
6073 /* Erase the line */
6074 Term_erase(0, y, 255);
6080 /* Get local object */
6083 /* Prepare the object */
6084 object_prep(q_ptr, k_idx);
6087 object_desc_store(o_name, q_ptr, FALSE, 0);
6089 /* Mention the object name */
6090 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6092 /* Warriors are illiterate */
6093 if (!(p_ptr->realm1 || p_ptr->realm2)) return;
6095 /* Display spells in readible books */
6096 if ((q_ptr->tval == REALM1_BOOK) ||
6097 (q_ptr->tval == REALM2_BOOK))
6105 /* Access the item's sval */
6108 /* Extract spells */
6109 for (spell = 0; spell < 32; spell++)
6111 /* Check for this spell */
6112 if (fake_spell_flags[sval] & (1L << spell))
6114 /* Collect this spell */
6115 spells[num++] = spell;
6120 print_spells(0, spells, num, 2, 0,
6121 (q_ptr->tval == REALM1_BOOK ? p_ptr->realm1 - 1 : p_ptr->realm2 - 1));
6125 /* Choose one of items that have warning flag */
6126 object_type *choose_warning_item(void)
6129 int choices[INVEN_TOTAL-INVEN_RARM];
6132 /* Paranoia -- Player has no warning-item */
6133 if (!p_ptr->warning) return (NULL);
6135 /* Search Inventry */
6136 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6139 object_type *o_ptr = &inventory[i];
6141 object_flags(o_ptr, &f1, &f2, &f3);
6142 if (f3 & (TR3_WARNING))
6144 choices[number] = i;
6149 /* Choice one of them */
6150 return (&inventory[choices[randint0(number)]]);
6153 /* Examine the grid (xx,yy) and warn the player if there are any danger */
6154 bool process_frakir(int xx, int yy)
6158 char o_name[MAX_NLEN];
6160 #define FRAKIR_AWARE_RANGE 12
6162 static int old_damage = 0;
6164 for (mx = xx-FRAKIR_AWARE_RANGE; mx < xx+FRAKIR_AWARE_RANGE+1; mx++)
6166 for (my = yy-FRAKIR_AWARE_RANGE; my < yy+FRAKIR_AWARE_RANGE+1; my++)
6169 monster_type *m_ptr;
6170 monster_race *r_ptr;
6174 if (!in_bounds(my,mx) || (distance(my,mx,yy,xx)>FRAKIR_AWARE_RANGE)) continue;
6176 c_ptr = &cave[my][mx];
6178 if (!c_ptr->m_idx) continue;
6180 m_ptr = &m_list[c_ptr->m_idx];
6181 r_ptr = &r_info[m_ptr->r_idx];
6187 rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
6189 if (m_ptr->csleep) continue;
6190 if (is_pet(m_ptr)) continue;
6192 /* Monster spells (only powerful ones)*/
6193 if(projectable(my,mx,yy,xx))
6196 #define DAMCALC(f,val,max,im,vln,res,resx,resy,op,opx,opy,dmax) \
6197 if (f){ int dam = (val)>(max)? (max):(val); \
6199 if (vln) dam *= 2; \
6200 if (res) {dam = (dam * resx) / resy;} \
6201 if (op) {dam = (dam * opx) / opy;} \
6202 if (dam>dmax) dmax = dam; \
6205 DAMCALC(f4 & (RF4_BR_FIRE), m_ptr->hp / 3, 1600,
6206 p_ptr->immune_fire, p_ptr->muta3 & MUT3_VULN_ELEM,
6207 p_ptr->resist_fire, 1, 3,
6208 p_ptr->oppose_fire, 1, 3, dam_max0);
6210 DAMCALC(f4 & (RF4_BR_COLD), m_ptr->hp / 3, 1600,
6211 p_ptr->immune_cold, p_ptr->muta3 & MUT3_VULN_ELEM,
6212 p_ptr->resist_cold, 1, 3,
6213 p_ptr->oppose_cold, 1, 3, dam_max0);
6215 DAMCALC(f4 & (RF4_BR_ELEC), m_ptr->hp / 3, 1600,
6216 p_ptr->immune_elec, p_ptr->muta3 & MUT3_VULN_ELEM,
6217 p_ptr->resist_elec, 1, 3,
6218 p_ptr->oppose_elec, 1, 3, dam_max0);
6220 DAMCALC(f4 & (RF4_BR_ACID), m_ptr->hp / 3, 1600,
6221 p_ptr->immune_acid, p_ptr->muta3 & MUT3_VULN_ELEM,
6222 p_ptr->resist_acid, 1, 3,
6223 p_ptr->oppose_acid, 1, 3, dam_max0);
6225 DAMCALC(f4 & (RF4_BR_POIS), m_ptr->hp / 3, 800,
6227 p_ptr->resist_pois, 1, 3,
6228 p_ptr->oppose_pois, 1, 3, dam_max0);
6231 DAMCALC(f4 & (RF4_BR_NETH), m_ptr->hp / 6, 550, FALSE , FALSE,
6232 p_ptr->resist_neth, 6, 9, FALSE, 1, 1, dam_max0);
6234 DAMCALC(f4 & (RF4_BR_LITE), m_ptr->hp / 6, 400, FALSE , FALSE,
6235 p_ptr->resist_lite, 4, 9, FALSE, 1, 1, dam_max0);
6237 DAMCALC(f4 & (RF4_BR_DARK), m_ptr->hp / 6, 400, FALSE , FALSE,
6238 p_ptr->resist_dark, 4, 9, FALSE, 1, 1, dam_max0);
6240 DAMCALC(f4 & (RF4_BR_CONF), m_ptr->hp / 6, 450, FALSE , FALSE,
6241 p_ptr->resist_conf, 5, 9, FALSE, 1, 1, dam_max0);
6243 DAMCALC(f4 & (RF4_BR_SOUN), m_ptr->hp / 6, 450, FALSE , FALSE,
6244 p_ptr->resist_sound, 5, 9, FALSE, 1, 1, dam_max0);
6246 DAMCALC(f4 & (RF4_BR_CHAO), m_ptr->hp / 6, 600, FALSE , FALSE,
6247 p_ptr->resist_chaos, 6, 9, FALSE, 1, 1, dam_max0);
6249 DAMCALC(f4 & (RF4_BR_DISE), m_ptr->hp / 6, 500, FALSE , FALSE,
6250 p_ptr->resist_disen, 6, 9, FALSE, 1, 1, dam_max0);
6252 DAMCALC(f4 & (RF4_BR_NEXU), m_ptr->hp / 3, 250, FALSE , FALSE,
6253 p_ptr->resist_nexus, 6, 9, FALSE, 1, 1, dam_max0);
6255 DAMCALC(f4 & (RF4_BR_TIME), m_ptr->hp / 3, 150, FALSE , FALSE,
6256 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6258 DAMCALC(f4 & (RF4_BR_INER), m_ptr->hp / 6, 200, FALSE , FALSE,
6259 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6261 DAMCALC(f4 & (RF4_BR_GRAV), m_ptr->hp / 3, 200, FALSE , FALSE,
6262 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6264 DAMCALC(f4 & (RF4_BR_SHAR), m_ptr->hp / 6, 500, FALSE , FALSE,
6265 p_ptr->resist_shard, 6, 9, FALSE, 1, 1, dam_max0);
6267 DAMCALC(f4 & (RF4_BR_PLAS), m_ptr->hp / 6, 150, FALSE , FALSE,
6268 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6270 DAMCALC(f4 & (RF4_BR_WALL), m_ptr->hp / 6, 200, FALSE , FALSE,
6271 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6273 DAMCALC(f4 & (RF4_BR_MANA), m_ptr->hp / 3, 250, FALSE , FALSE,
6274 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6276 DAMCALC(f4 & (RF4_BR_NUKE), m_ptr->hp / 3, 800, FALSE , FALSE,
6277 p_ptr->resist_pois, 2, 5,
6278 p_ptr->oppose_pois, 2, 5, dam_max0);
6280 DAMCALC(f4 & (RF4_BR_DISI), m_ptr->hp / 3, 300, FALSE , FALSE,
6281 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6284 DAMCALC(f4 & (RF4_ROCKET), m_ptr->hp / 4, 800, FALSE , FALSE,
6285 p_ptr->resist_shard, 1, 2, FALSE, 1, 1, dam_max0);
6287 DAMCALC(f5 & (RF5_BA_MANA), rlev*4 + 150, 9999, FALSE , FALSE,
6288 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6290 DAMCALC(f5 & (RF5_BA_DARK), rlev*4 + 150, 9999, FALSE , FALSE,
6291 p_ptr->resist_dark, 4, 9, FALSE, 1, 1, dam_max0);
6293 DAMCALC(f5 & (RF5_BA_LITE), rlev*4 + 150, 9999, FALSE , FALSE,
6294 p_ptr->resist_lite, 4, 9, FALSE, 1, 1, dam_max0);
6297 DAMCALC(f6 & (RF6_HAND_DOOM), p_ptr->chp*6/10, 9999, FALSE , FALSE,
6298 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6302 /* Monster melee attacks */
6303 if(mx <= xx+1 && mx >= xx-1 && my <=yy+1 && my >= yy-1)
6307 for (m = 0; m < 4; m++)
6311 /* Skip non-attacks */
6312 if (!r_ptr->blow[m].method) continue;
6314 /* Extract the attack info */
6315 d1 = r_ptr->blow[m].d_dice;
6316 d2 = r_ptr->blow[m].d_side;
6320 if(dam_melee>dam_max0)dam_max0=dam_melee;
6323 /* Contribution from this monster */
6328 /* Prevent excessive warning */
6329 if(dam_max > old_damage)
6331 old_damage=dam_max * 3 / 2;
6333 if (dam_max>(p_ptr->chp)/2)
6335 object_type *o_ptr = choose_warning_item();
6337 object_desc(o_name, o_ptr, FALSE, 0);
6339 msg_format("%s¤¬±Ô¤¯¿Ì¤¨¤¿¡ª", o_name);
6341 msg_format("%s pulsates sharply!", o_name);
6345 return (get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©"));
6347 return (get_check("Realy want to go ahead? "));
6351 else old_damage = old_damage/2;
6353 c_ptr = &cave[yy][xx];
6354 if (((is_trap(c_ptr->feat) && !easy_disarm) || (c_ptr->info & CAVE_TRAP)) && !one_in_(13))
6356 object_type *o_ptr = choose_warning_item();
6358 object_desc(o_name, o_ptr, FALSE, 0);
6360 msg_format("%s¤¬¿Ì¤¨¤¿¡ª", o_name);
6362 msg_format("%s pulsates!", o_name);
6366 return (get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©"));
6368 return (get_check("Realy want to go ahead? "));
6375 typedef struct essence_type essence_type;
6386 static essence_type essence_info[MAX_ESSENCE] = {
6387 {"ÏÓÎÏ","ÏÓÎÏ", 1, 4, 20},
6388 {"ÃÎǽ","ÃÎǽ", 2, 4, 20},
6389 {"¸¤µ","¸¤µ", 3, 4, 20},
6390 {"´ïÍѤµ","´ïÍѤµ", 4, 4, 20},
6391 {"Âѵ×ÎÏ","Âѵ×ÎÏ", 5, 4, 20},
6392 {"Ì¥ÎÏ","Ì¥ÎÏ", 6, 4, 20},
6393 {"ËâÎÏ»ÙÇÛ","ËâÎÏ»ÙÇÛ", 7, 4, 20},
6395 {"±£Ì©","±£Ì©", 9, 4, 40},
6396 {"õº÷","õº÷", 10, 4, 15},
6397 {"ÀÖ³°Àþ»ëÎÏ","ÀÖ³°Àþ»ëÎÏ", 11, 4, 15},
6398 {"ºÎ·¡","ºÎ·¡", 12, 4, 15},
6399 {"¥¹¥Ô¡¼¥É","¥¹¥Ô¡¼¥É", 13, 4, 12},
6400 {"Äɲù¶·â","Äɲù¶·â", 14, 1, 20},
6401 {"¥«¥ª¥¹¹¶·â","¥«¥ª¥¹¹¶·â", 15, 1, 15},
6402 {"µÛ·ì¹¶·â","µÛ·ì¹¶·â", 16, 1, 60},
6403 {"ưʪÇÜÂÇ","ưʪÇÜÂÇ", 17, 1, 20},
6404 {"¼Ù°ÇÜÂÇ","¼Ù°ÇÜÂÇ", 18, 1, 100},
6405 {"ÉÔ»àÇÜÂÇ","ÉÔ»àÇÜÂÇ", 19, 1, 20},
6406 {"°ËâÇÜÂÇ","°ËâÇÜÂÇ", 20, 1, 20},
6407 {"¥ª¡¼¥¯ÇÜÂÇ","¥ª¡¼¥¯ÇÜÂÇ", 21, 1, 15},
6408 {"¥È¥í¥ëÇÜÂÇ","¥È¥í¥ëÇÜÂÇ", 22, 1, 15},
6409 {"µð¿ÍÇÜÂÇ","µð¿ÍÇÜÂÇ", 23, 1, 20},
6410 {"εÇÜÂÇ","εÇÜÂÇ", 24, 1, 20},
6411 {"","εÇÜÇÜÂÇ", 24, 1, 60},
6413 {"ÃÏ¿Ì","ÃÏ¿Ìȯư", 27, 5, 15},
6414 {"ÆÇ»¦","ÆÇ»¦", 28, 1, 20},
6415 {"Íϲò","Íϲò", 29, 1, 20},
6416 {"ÅÅ·â","ÅÅ·â", 30, 1, 20},
6417 {"¾Æ´þ","¾Æ´þ", 31, 1, 20},
6418 {"Åà·ë","Åà·ë", 32, 1, 20},
6419 {"ǽÎÏ°Ý»ý","ÏÓÎÏ°Ý»ý", 33, 3, 15},
6420 {"","ÃÎǽ°Ý»ý", 33, 3, 15},
6421 {"","¸¤µ°Ý»ý", 33, 3, 15},
6422 {"","´ïÍѤµ°Ý»ý", 33, 3, 15},
6423 {"","Âѵ×ÎÏ°Ý»ý", 33, 3, 15},
6424 {"","Ì¥ÎÏ°Ý»ý", 33, 3, 15},
6427 {"ÌȱÖ","»ÀÌȱÖ", 41, 2, 20},
6428 {"","ÅÅ·âÌȱÖ", 41, 2, 20},
6429 {"","²Ð±êÌȱÖ", 41, 2, 20},
6430 {"","Î䵤ÌȱÖ", 41, 2, 20},
6432 {"È¿¼Í","È¿¼Í", 46, 2, 20},
6433 {"ËãáãÃΤ餺","ËãáãÃΤ餺", 47, 3, 20},
6434 {"À¸Ì¿ÎÏ°Ý»ý","À¸Ì¿ÎÏ°Ý»ý", 48, 3, 20},
6435 {"ÂÑ»À","ÂÑ»À", 49, 2, 15},
6436 {"ÂÑÅÅ·â","ÂÑÅÅ·â", 50, 2, 15},
6437 {"ÂѲбê","ÂѲбê", 51, 2, 15},
6438 {"ÂÑÎ䵤","ÂÑÎ䵤", 52, 2, 15},
6439 {"ÂÑÆÇ","ÂÑÆÇ", 53, 2, 25},
6440 {"ÂѶ²ÉÝ","ÂѶ²ÉÝ", 54, 2, 20},
6441 {"ÂÑÁ®¸÷","ÂÑÁ®¸÷", 55, 2, 20},
6442 {"ÂѰŹõ","ÂѰŹõ", 56, 2, 20},
6443 {"ÂÑÌÕÌÜ","ÂÑÌÕÌÜ", 57, 2, 20},
6444 {"ÂѺ®Íð","ÂѺ®Íð", 58, 2, 20},
6445 {"Âѹ첻","Âѹ첻", 59, 2, 20},
6446 {"ÂÑÇËÊÒ","ÂÑÇËÊÒ", 60, 2, 20},
6447 {"ÂÑÃϹö","ÂÑÃϹö", 61, 2, 20},
6448 {"ÂÑ°ø²Ìº®Íð","ÂÑ°ø²Ìº®Íð", 62, 2, 20},
6449 {"ÂÑ¥«¥ª¥¹","ÂÑ¥«¥ª¥¹", 63, 2, 20},
6450 {"ÂÑÎô²½","ÂÑÎô²½", 64, 2, 20},
6453 {"¿Í´ÖÇÜÂÇ","¿Í´ÖÇÜÂÇ", 67, 1, 20},
6456 {"È¿ËâË¡","È¿ËâË¡", 70, 3, 15},
6459 {"·Ù¹ð","·Ù¹ð", 73, 3, 20},
6463 {"ÉâÍ·","ÉâÍ·", 77, 3, 20},
6464 {"±Êµ×¸÷¸»","±Êµ×¸÷¸»", 78, 3, 15},
6465 {"²Ä»ëÆ©ÌÀ","²Ä»ëÆ©ÌÀ", 79, 3, 20},
6466 {"¥Æ¥ì¥Ñ¥·¡¼","¥Æ¥ì¥Ñ¥·¡¼", 80, 3, 15},
6467 {"Ãپò½","Ãپò½", 81, 3, 15},
6468 {"µÞ®²óÉü","µÞ®²óÉü", 82, 3, 20},
6477 {"¥Æ¥ì¥Ý¡¼¥È","¥Æ¥ì¥Ý¡¼¥È", 91, 3, 25},
6483 {"¹¶·â","¹¶·â", 97, 6, 30},
6484 {"Ëɸæ","Ëɸæ", 98, 6, 15},
6485 {"","»ÀÂÑÀȯư", 49, 5, 50},
6486 {"","ÅÅ·âÂÑÀȯư", 50, 5, 50},
6487 {"","²Ð±êÂÑÀȯư", 51, 5, 50},
6488 {"","Î䵤ÂÑÀȯư", 52, 5, 50},
6489 {"","²Ð±ê¥ª¡¼¥é", 0, 5, 30},
6490 {"","Åŷ⥪¡¼¥é", 0, 5, 30},
6491 {"","Î䵤¥ª¡¼¥é", 0, 5, 30},
6492 {"","Á´ÂÑÀ", 0, 2, 150},
6493 {"","ÁõÈ÷ÊÝ»ý", 0, 6, 10},
6494 {"","»¦Ù¤¤Î¾®¼ê", 97, 1, 200},
6497 static essence_type essence_info[MAX_ESSENCE] = {
6498 {"strength","strength", 1, 4, 20},
6499 {"intelligen.","intelligence", 2, 4, 20},
6500 {"wisdom","wisdom", 3, 4, 20},
6501 {"dexterity","dexterity", 4, 4, 20},
6502 {"constitut.","constitution", 5, 4, 20},
6503 {"charisma","charisma", 6, 4, 20},
6504 {"magic mast.","magic mastery", 7, 4, 20},
6506 {"stealth","stealth", 9, 4, 40},
6507 {"serching","serching", 10, 4, 15},
6508 {"inflavision","inflavision", 11, 4, 15},
6509 {"digging","digging", 12, 4, 15},
6510 {"speed","speed", 13, 4, 12},
6511 {"extra atk","extra attack", 14, 1, 20},
6512 {"chaos brand","chaos brand", 15, 1, 15},
6513 {"vampiric","vampiric brand", 16, 1, 60},
6514 {"slay animal","slay animal", 17, 1, 20},
6515 {"slay evil","slay evil", 18, 1, 100},
6516 {"slay undead","slay undead", 19, 1, 20},
6517 {"slay demon","slay demon", 20, 1, 20},
6518 {"slay orc","slay orc", 21, 1, 15},
6519 {"slay troll","slay troll", 22, 1, 15},
6520 {"slay giant","slay giant", 23, 1, 20},
6521 {"slay dragon","slay dragon", 24, 1, 20},
6522 {"","kill dragon", 24, 1, 60},
6524 {"quake","quake activation", 27, 5, 15},
6525 {"pois. brand","poison brand", 28, 1, 20},
6526 {"acid brand","acid brand", 29, 1, 20},
6527 {"elec. brand","electric brand", 30, 1, 20},
6528 {"fire brand","fire brand", 31, 1, 20},
6529 {"cold brand","cold brand", 32, 1, 20},
6530 {"sustain","sustain strength", 33, 3, 15},
6531 {"","sustain intelligence", 33, 3, 15},
6532 {"","sustain wisdom", 33, 3, 15},
6533 {"","sustain dexterity", 33, 3, 15},
6534 {"","sustain constitution", 33, 3, 15},
6535 {"","sustain charisma", 33, 3, 15},
6538 {"immunity","acid immunity", 41, 2, 20},
6539 {"","electric immunity", 41, 2, 20},
6540 {"","fire immunity", 41, 2, 20},
6541 {"","cold immunity", 41, 2, 20},
6543 {"reflection","reflection", 46, 2, 20},
6544 {"free action","free action", 47, 3, 20},
6545 {"hold life","hold life", 48, 3, 20},
6546 {"res. acid","resistance to acid", 49, 2, 15},
6547 {"res. elec.","resistance to electric", 50, 2, 15},
6548 {"res. fire","resistance to fire", 51, 2, 15},
6549 {"res. cold","resistance to cold", 52, 2, 15},
6550 {"res. poison","resistance to poison", 53, 2, 25},
6551 {"res. fear","resistance to fear", 54, 2, 20},
6552 {"res. light","resistance to light", 55, 2, 20},
6553 {"res. dark","resistance to dark", 56, 2, 20},
6554 {"res. blind","resistance to blind", 57, 2, 20},
6555 {"res.confuse","resistance to confusion", 58, 2, 20},
6556 {"res. sound","resistance to sound", 59, 2, 20},
6557 {"res. shard","resistance to shard", 60, 2, 20},
6558 {"res. nether","resistance to nether", 61, 2, 20},
6559 {"res. nexus","resistance to nexus", 62, 2, 20},
6560 {"res. chaos","resistance to chaos", 63, 2, 20},
6561 {"res. disen.","resistance to disenchantment", 64, 2, 20},
6564 {"slay human","slay human", 67, 1, 20},
6567 {"anti magic","anti magic", 70, 3, 15},
6570 {"warning","warning", 73, 3, 20},
6574 {"levitation","levitation", 77, 3, 20},
6575 {"perm. light","permanent light", 78, 3, 15},
6576 {"see invis.","see invisible", 79, 3, 20},
6577 {"telepathy","telepathy", 80, 3, 15},
6578 {"slow dige.","slow digestion", 81, 3, 15},
6579 {"regen.","regeneration", 82, 3, 20},
6588 {"teleport","teleport", 91, 3, 25},
6594 {"weapon enc.","weapon enchant", 97, 6, 30},
6595 {"armor enc.","armor enchant", 98, 6, 15},
6596 {"","resist acid activation", 49, 5, 50},
6597 {"","resist electricity activation", 50, 5, 50},
6598 {"","resist fire activation", 51, 5, 50},
6599 {"","resist cold activation", 52, 5, 50},
6600 {"","fiery sheath", 0, 5, 30},
6601 {"","electric sheath", 0, 5, 30},
6602 {"","coldly sheath", 0, 5, 30},
6603 {"","resistance", 0, 2, 150},
6604 {"","elements proof", 0, 6, 10},
6605 {"","gauntlets of slay", 97, 1, 200},
6609 bool item_tester_hook_melee_ammo(object_type *o_ptr)
6611 switch (o_ptr->tval)
6624 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
6632 static void display_essence(void)
6637 for (i = 1; i < 22; i++)
6642 prt("¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô", 1, 8);
6644 prt("Essence Num Essence Num Essence Num ", 1, 8);
6646 for (i = 0; i < MAX_ESSENCE; i++)
6648 if (!essence_info[i].drain_name[0]) continue;
6649 prt(format("%-11s %5d", essence_info[i].drain_name, p_ptr->magic_num1[i]), 2+num%20, 8+num/20*22);
6653 prt("¸½ºß½ê»ý¤·¤Æ¤¤¤ë¥¨¥Ã¥»¥ó¥¹", 0, 0);
6655 prt("List of all essences you have.", 0, 0);
6662 static void drain_essence(void)
6664 int drain_value[MAX_ESSENCE];
6667 bool observe = FALSE;
6668 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
6669 u32b old_f1, old_f2, old_f3, new_f1, new_f2, new_f3;
6672 byte iy, ix, marked, number;
6673 s16b next_o_idx, weight;
6675 for (i = 0; i < MAX_ESSENCE; i++)
6678 item_tester_hook = item_tester_hook_weapon_armour;
6679 item_tester_no_ryoute = TRUE;
6683 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éÃê½Ð¤·¤Þ¤¹¤«¡©";
6684 s = "Ãê½Ð¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
6686 q = "Extract from which item? ";
6687 s = "You have nothing you can extract from.";
6690 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
6692 /* Get the item (in the pack) */
6695 o_ptr = &inventory[item];
6698 /* Get the item (on the floor) */
6701 o_ptr = &o_list[0 - item];
6704 if (object_known_p(o_ptr) && (o_ptr->name1 || o_ptr->name2 || o_ptr->art_name || o_ptr->xtra3)) {
6705 char o_name[MAX_NLEN];
6706 object_desc(o_name, o_ptr, FALSE, 0);
6708 if (!get_check(format("ËÜÅö¤Ë%s¤«¤éÃê½Ð¤·¤Æ¤è¤í¤·¤¤¤Ç¤¹¤«¡©", o_name))) return;
6710 if (!get_check(format("Really extract from %s? ", o_name))) return;
6716 object_flags(o_ptr, &old_f1, &old_f2, &old_f3);
6717 if (old_f1 & TR1_KILL_DRAGON) old_f1 |= TR1_SLAY_DRAGON;
6719 old_to_a = o_ptr->to_a;
6721 old_to_h = o_ptr->to_h;
6722 old_to_d = o_ptr->to_d;
6725 old_pval = o_ptr->pval;
6726 old_name2 = o_ptr->name2;
6727 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
6728 if (old_f3 & (TR3_AGGRAVATE)) dec--;
6729 if (old_f3 & (TR3_NO_TELE)) dec--;
6730 if (old_f3 & (TR3_DRAIN_EXP)) dec--;
6731 if (old_f3 & (TR3_TY_CURSE)) dec--;
6735 next_o_idx = o_ptr->next_o_idx;
6736 marked = o_ptr->marked;
6737 weight = o_ptr->weight;
6738 number = o_ptr->number;
6740 object_prep(o_ptr, o_ptr->k_idx);
6744 o_ptr->next_o_idx=next_o_idx;
6745 o_ptr->marked=marked;
6746 o_ptr->number = number;
6747 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
6748 o_ptr->ident |= (IDENT_MENTAL);
6749 object_aware(o_ptr);
6750 object_known(o_ptr);
6752 object_flags(o_ptr, &new_f1, &new_f2, &new_f3);
6754 for (i = 0; i < 96; i++)
6760 if (((1 << i) & TR1_PVAL_MASK) && old_pval) pval = ((new_f1 >> i) & 0x00000001) ? old_pval-o_ptr->pval : old_pval;
6761 if ((!((new_f1 >> i) & 0x00000001) || pval) && ((old_f1 >> i) & 0x00000001) && essence_info[i].link)
6763 drain_value[essence_info[i].link-1] += (10 * (pval ? pval : 1));
6768 if (!((new_f2 >> (i-32)) & 0x00000001) && ((old_f2 >> (i-32)) & 0x00000001) && essence_info[i].link)
6770 drain_value[essence_info[i].link-1] += 10;
6775 if (!((new_f3 >> (i-64)) & 0x00000001) && ((old_f3 >> (i-64)) & 0x00000001) && essence_info[i].link)
6777 if (essence_info[i].link == -1)
6779 if (i == ESSENCE__SH__FIRE-1)
6781 drain_value[ESSENCE_B_FIRE-1] += 10;
6782 drain_value[ESSENCE_RES_FIRE-1] += 10;
6784 else if (i == ESSENCE__SH__ELEC-1)
6786 drain_value[ESSENCE_B_ELEC-1] += 10;
6787 drain_value[ESSENCE_RES_ELEC-1] += 10;
6789 else if (i == ESSENCE__SH__COLD-1)
6791 drain_value[ESSENCE_B_COLD-1] += 10;
6792 drain_value[ESSENCE_RES_COLD-1] += 10;
6795 else drain_value[essence_info[i].link-1] += 10;
6800 if ((old_f1 & TR1_FORCE_WEAPON) && !(new_f1 & TR1_FORCE_WEAPON))
6802 drain_value[ESSENCE_INT-1] += 5;
6803 drain_value[ESSENCE_WIS-1] += 5;
6805 if ((old_f1 & TR1_VORPAL) && !(new_f1 & TR1_VORPAL))
6807 drain_value[ESSENCE_B_POIS-1] += 5;
6808 drain_value[ESSENCE_B_ACID-1] += 5;
6809 drain_value[ESSENCE_B_ELEC-1] += 5;
6810 drain_value[ESSENCE_B_FIRE-1] += 5;
6811 drain_value[ESSENCE_B_COLD-1] += 5;
6813 if ((old_f3 & TR3_DEC_MANA) && !(new_f3 & TR3_DEC_MANA))
6815 drain_value[ESSENCE_INT-1] += 10;
6817 if ((old_f3 & TR3_XTRA_MIGHT) && !(new_f3 & TR3_XTRA_MIGHT))
6819 drain_value[ESSENCE_STR-1] += 10;
6821 if ((old_f3 & TR3_XTRA_SHOTS) && !(new_f3 & TR3_XTRA_SHOTS))
6823 drain_value[ESSENCE_DEX-1] += 10;
6825 if (old_name2 == EGO_2WEAPON)
6827 drain_value[ESSENCE_DEX-1] += 20;
6829 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_SWORD) && (o_ptr->tval != TV_BOW))
6831 if (old_ds > o_ptr->ds) drain_value[ESSENCE_ATTACK-1] += (old_ds-o_ptr->ds)*10;
6833 if (old_dd > o_ptr->dd) drain_value[ESSENCE_ATTACK-1] += (old_dd-o_ptr->dd)*10;
6835 if (old_to_h > o_ptr->to_h) drain_value[ESSENCE_ATTACK-1] += (old_to_h-o_ptr->to_h)*10;
6836 if (old_to_d > o_ptr->to_d) drain_value[ESSENCE_ATTACK-1] += (old_to_d-o_ptr->to_d)*10;
6837 if (old_ac > o_ptr->ac) drain_value[ESSENCE_AC-1] += (old_ac-o_ptr->ac)*10;
6838 if (old_to_a > o_ptr->to_a) drain_value[ESSENCE_AC-1] += (old_to_a-o_ptr->to_a)*10;
6840 for (i = 0; i < MAX_ESSENCE; i++)
6842 drain_value[i] *= number;
6843 drain_value[i] = drain_value[i] * dec / 4;
6844 drain_value[i] = MAX(drain_value[i], 0);
6845 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
6854 msg_print("¥¨¥Ã¥»¥ó¥¹¤ÏÃê½Ð¤Ç¤¤Þ¤»¤ó¤Ç¤·¤¿¡£");
6856 msg_print("You were not able to extract any essence.");
6862 msg_print("Ãê½Ð¤·¤¿¥¨¥Ã¥»¥ó¥¹:");
6864 msg_print("Extracted essences:");
6866 for (i = 0; i < MAX_ESSENCE; i++)
6868 if (!drain_value[i]) continue;
6869 p_ptr->magic_num1[i] += drain_value[i];
6870 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
6872 msg_format("%s...%d", essence_info[i].drain_name, drain_value[i]);
6876 /* Combine the pack */
6877 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6880 p_ptr->window |= (PW_INVEN);
6885 static int choose_essence()
6889 int menu_line = (use_menu ? 1 : 0);
6892 if (repeat_pull(&mode) && 1 <= mode && mode <= 5)
6895 #endif /* ALLOW_REPEAT */
6904 prt(format(" %s Éð´ï°À", (menu_line == 1) ? "¡Õ" : " "), 2, 14);
6905 prt(format(" %s ÂÑÀ", (menu_line == 2) ? "¡Õ" : " "), 3, 14);
6906 prt(format(" %s ǽÎÏ", (menu_line == 3) ? "¡Õ" : " "), 4, 14);
6907 prt(format(" %s ¿ôÃÍ", (menu_line == 4) ? "¡Õ" : " "), 5, 14);
6908 prt(format(" %s ¤½¤Î¾", (menu_line == 5) ? "¡Õ" : " "), 6, 14);
6909 prt("¤É¤Î¼ïÎà¤Î¥¨¥Ã¥»¥ó¥¹Éղäò¹Ô¤¤¤Þ¤¹¤«¡©", 0, 0);
6911 prt(format(" %s Brand weapon", (menu_line == 1) ? "> " : " "), 2, 14);
6912 prt(format(" %s Resistance", (menu_line == 2) ? "> " : " "), 3, 14);
6913 prt(format(" %s Ability", (menu_line == 3) ? "> " : " "), 4, 14);
6914 prt(format(" %s Magic number", (menu_line == 4) ? "> " : " "), 5, 14);
6915 prt(format(" %s Others", (menu_line == 5) ? "> " : " "), 6, 14);
6916 prt("Choose from menu.", 0, 0);
6943 if (menu_line > 5) menu_line -= 5;
6953 prt(" a) ¹¶·â°À", 2, 14);
6954 prt(" b) ÂÑÀ", 3, 14);
6955 prt(" c) ǽÎÏ", 4, 14);
6956 prt(" d) ¿ôÃÍ", 5, 14);
6957 prt(" e) ¤½¤Î¾", 6, 14);
6958 if (!get_com("²¿¤òÉղä·¤Þ¤¹¤«:", &choice, TRUE))
6960 prt(" a) Brand weapon", 2, 14);
6961 prt(" b) Resistance", 3, 14);
6962 prt(" c) Ability", 4, 14);
6963 prt(" d) Magic number", 5, 14);
6964 prt(" e) Others", 6, 14);
6965 if (!get_com("Command :", &choice, TRUE))
7001 #endif /* ALLOW_REPEAT */
7005 static void add_essence(int mode)
7007 int item, max_num = 0;
7016 char o_name[MAX_NLEN];
7019 int menu_line = (use_menu ? 1 : 0);
7021 for (i = 0; i < MAX_ESSENCE; i++)
7023 if (essence_info[i].type != mode) continue;
7028 if (!repeat_pull(&i) || i<0 || i>=max_num)
7030 #endif /* ALLOW_REPEAT */
7033 /* Nothing chosen yet */
7039 /* Build a prompt */
7041 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎǽÎϤòÉղä·¤Þ¤¹¤«¡©");
7043 (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Add which ability? ");
7045 if (use_menu) screen_save();
7047 /* Get a spell from the user */
7049 choice = (always_show_list || use_menu) ? ESCAPE:1;
7053 if( choice==ESCAPE ) choice = ' ';
7054 else if( !get_com(out_val, &choice, FALSE) )break;
7056 if (use_menu && choice != ' ')
7071 menu_line += (max_num-1);
7094 menu_line = max_num;
7108 if (menu_line > max_num) menu_line -= max_num;
7110 /* Request redraw */
7111 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
7114 if (!redraw || use_menu)
7118 char dummy[80], dummy2[80];
7126 /* Save the screen */
7127 if (!use_menu) screen_save();
7129 for (y = 1; y < 24; y++)
7132 /* Print header(s) */
7134 prt(" ǽÎÏ(ɬÍ×¥¨¥Ã¥»¥ó¥¹) ɬÍ׿ô/½ê»ý¿ô", 1, x);
7137 prt(" Ability(essence to need) Needs/Possess", 1, x);
7140 for (ctr = 0; ctr < max_num; ctr++)
7144 if (ctr == (menu_line-1))
7146 strcpy(dummy, "¡Õ ");
7148 strcpy(dummy, "> ");
7150 else strcpy(dummy, " ");
7153 /* letter/number for power selection */
7156 sprintf(dummy, "%c) ",I2A(ctr));
7159 strcat(dummy, essence_info[num[ctr]].add_name);
7164 if (essence_info[num[ctr]].link)
7166 strcat(dummy, format("(%s)", essence_info[essence_info[num[ctr]].link-1].drain_name));
7167 if (p_ptr->magic_num1[essence_info[num[ctr]].link-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7173 case ESSENCE_SH_FIRE:
7175 strcat(dummy, "(¾Æ´þ+ÂѲбê) ");
7177 strcat(dummy, "(brand fire + res.fire) ");
7179 if (p_ptr->magic_num1[ESSENCE_B_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7180 if (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7182 case ESSENCE_SH_ELEC:
7184 strcat(dummy, "(ÅÅ·â+ÂÑÅÅ·â) ");
7186 strcat(dummy, "(brand elec. + res. elec.) ");
7188 if (p_ptr->magic_num1[ESSENCE_B_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7189 if (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7191 case ESSENCE_SH_COLD:
7193 strcat(dummy, "(Åà·ë+ÂÑÎ䵤) ");
7195 strcat(dummy, "(brand cold + res. cold) ");
7197 if (p_ptr->magic_num1[ESSENCE_B_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7198 if (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7200 case ESSENCE_RESISTANCE:
7202 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
7204 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
7206 if (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7207 if (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7208 if (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7209 if (p_ptr->magic_num1[ESSENCE_RES_ACID-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7211 case ESSENCE_SUSTAIN:
7213 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
7215 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
7217 if (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7218 if (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7219 if (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7220 if (p_ptr->magic_num1[ESSENCE_RES_ACID-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7225 if (!able[ctr]) col = TERM_RED;
7227 strcpy(dummy2, format("%-50s",dummy));
7229 if (essence_info[num[ctr]].link)
7231 strcat(dummy2, format(" %d/%d",essence_info[num[ctr]].value, p_ptr->magic_num1[essence_info[num[ctr]].link-1]));
7235 strcat(dummy2, format(" %d/(\?\?)",essence_info[num[ctr]].value));
7238 c_prt(col, dummy2, ctr+2, x);
7248 /* Restore the screen */
7259 ask = (isupper(choice));
7262 if (ask) choice = tolower(choice);
7264 /* Extract request */
7265 i = (islower(choice) ? A2I(choice) : -1);
7268 /* Totally Illegal */
7269 if ((i < 0) || (i >= max_num) || !able[i])
7282 (void) strnfmt(tmp_val, 78, "%s¤òÉղä·¤Þ¤¹¤«¡© ", essence_info[num[i]].add_name);
7284 (void) strnfmt(tmp_val, 78, "Add the abilitiy of %s? ", essence_info[num[i]].add_name);
7287 /* Belay that order */
7288 if (!get_check(tmp_val)) continue;
7295 /* Restore the screen */
7296 if (redraw) screen_load();
7303 #endif /* ALLOW_REPEAT */
7305 if (num[i] == ESSENCE_SLAY_GLOVE-1)
7306 item_tester_tval = TV_GLOVES;
7308 item_tester_hook = item_tester_hook_melee_ammo;
7309 else if (num[i] == ESSENCE_ATTACK-1)
7310 item_tester_hook = item_tester_hook_weapon;
7311 else if (num[i] == ESSENCE_AC-1)
7312 item_tester_hook = item_tester_hook_armour;
7314 item_tester_hook = item_tester_hook_weapon_armour;
7315 item_tester_no_ryoute = TRUE;
7319 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
7320 s = "²þÎɤǤ¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
7322 q = "Improve which item? ";
7323 s = "You have nothing to improve.";
7326 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7328 /* Get the item (in the pack) */
7331 o_ptr = &inventory[item];
7334 /* Get the item (on the floor) */
7337 o_ptr = &o_list[0 - item];
7340 if ((mode != 6) && (o_ptr->name1 || o_ptr->art_name || o_ptr->xtra3))
7343 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï¤³¤ì°Ê¾å²þÎɤǤ¤Ê¤¤¡£");
7345 msg_print("This item is no more able to be improved");
7350 object_desc(o_name, o_ptr, FALSE, 0);
7352 use_essence = essence_info[num[i]].value;
7353 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
7354 if (o_ptr->number > 1)
7356 use_essence *= o_ptr->number;
7358 msg_format("%d¸Ä¤¢¤ë¤Î¤Ç¥¨¥Ã¥»¥ó¥¹¤Ï%dɬÍפǤ¹¡£", o_ptr->number, use_essence);
7360 msg_format("It will take %d essences.",use_essence);
7365 if (essence_info[num[i]].link)
7367 if (p_ptr->magic_num1[essence_info[num[i]].link-1] < use_essence)
7370 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7372 msg_print("You don't have enough essences.");
7376 if ((num[i] < 32) && (TR1_PVAL_MASK & (0x1L << num[i])))
7378 if (num[i] == ESSENCE_BLOWS-1)
7380 if (o_ptr->pval > 1)
7383 if (!get_check("½¤ÀµÃͤÏ1¤Ë¤Ê¤ê¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) return;
7385 if (!get_check("The magic number of this weapon will become 1. Are you sure? ")) return;
7390 else if (o_ptr->pval)
7392 use_essence *= o_ptr->pval;
7394 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
7396 msg_format("It will take %d essences.",use_essence);
7404 int limit = MIN(5, p_ptr->magic_num1[essence_info[num[i]].link-1]/essence_info[num[i]].value);
7408 sprintf(tmp, "¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d): ", limit);
7410 sprintf(tmp, "Enchant how many? (1-%d): ", limit);
7412 strcpy(tmp_val, "1");
7414 if (!get_string(tmp, tmp_val, 1)) return;
7415 pval = atoi(tmp_val);
7416 if (pval > limit) pval = limit;
7417 else if (pval < 1) pval = 1;
7419 use_essence *= pval;
7421 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
7423 msg_format("It will take %d essences.",use_essence);
7426 if (p_ptr->magic_num1[essence_info[num[i]].link-1] < use_essence)
7429 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7431 msg_print("You don't have enough essences.");
7436 else if (num[i] == ESSENCE_SLAY_GLOVE-1)
7440 int get_to_h, get_to_d;
7442 strcpy(tmp_val, "1");
7444 if (!get_string(format("¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
7446 if (!get_string(format("Enchant how many? (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
7448 val = atoi(tmp_val);
7449 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
7450 else if (val < 1) val = 1;
7453 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
7455 msg_format("It will take %d essences.",use_essence);
7457 if (p_ptr->magic_num1[essence_info[num[i]].link-1] < use_essence)
7460 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7462 msg_print("You don't have enough essences");
7466 get_to_h = ((val+1)/2+randint0(val/2+1));
7467 get_to_d = ((val+1)/2+randint0(val/2+1));
7468 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
7469 o_ptr->to_h += get_to_h;
7470 o_ptr->to_d += get_to_d;
7472 p_ptr->magic_num1[essence_info[num[i]].link-1] -= use_essence;
7473 if (num[i] == ESSENCE_ATTACK-1)
7475 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
7478 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
7480 msg_print("You failed to enchant.");
7487 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
7488 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
7491 else if (num[i] == ESSENCE_AC-1)
7493 if (o_ptr->to_a >= p_ptr->lev/5+5)
7496 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
7498 msg_print("You failed to enchant.");
7505 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
7510 o_ptr->xtra3 = num[i]+1;
7515 bool success = TRUE;
7519 case ESSENCE_SH_FIRE:
7520 if ((p_ptr->magic_num1[ESSENCE_B_FIRE-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < use_essence))
7525 p_ptr->magic_num1[ESSENCE_B_FIRE-1] -= use_essence;
7526 p_ptr->magic_num1[ESSENCE_RES_FIRE-1] -= use_essence;
7528 case ESSENCE_SH_ELEC:
7529 if ((p_ptr->magic_num1[ESSENCE_B_ELEC-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < use_essence))
7534 p_ptr->magic_num1[ESSENCE_B_ELEC-1] -= use_essence;
7535 p_ptr->magic_num1[ESSENCE_RES_ELEC-1] -= use_essence;
7537 case ESSENCE_SH_COLD:
7538 if ((p_ptr->magic_num1[ESSENCE_B_COLD-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < use_essence))
7543 p_ptr->magic_num1[ESSENCE_B_COLD-1] -= use_essence;
7544 p_ptr->magic_num1[ESSENCE_RES_COLD-1] -= use_essence;
7546 case ESSENCE_RESISTANCE:
7547 case ESSENCE_SUSTAIN:
7548 if ((p_ptr->magic_num1[ESSENCE_RES_ACID-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < use_essence))
7553 p_ptr->magic_num1[ESSENCE_RES_ACID-1] -= use_essence;
7554 p_ptr->magic_num1[ESSENCE_RES_ELEC-1] -= use_essence;
7555 p_ptr->magic_num1[ESSENCE_RES_FIRE-1] -= use_essence;
7556 p_ptr->magic_num1[ESSENCE_RES_COLD-1] -= use_essence;
7562 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7564 msg_print("You don't have enough essences");
7568 if (num[i] == ESSENCE_SUSTAIN-1)
7569 o_ptr->art_flags3 |= (TR3_IGNORE_ACID | TR3_IGNORE_ELEC | TR3_IGNORE_FIRE | TR3_IGNORE_COLD);
7570 else o_ptr->xtra3 = num[i]+1;
7576 msg_format("%s¤Ë%s¤ÎǽÎϤòÉղä·¤Þ¤·¤¿¡£", o_name, essence_info[num[i]].add_name);
7578 msg_format("You have added ability of %s to %s.", essence_info[num[i]].add_name, o_name);
7581 /* Combine the pack */
7582 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7585 p_ptr->window |= (PW_INVEN);
7589 bool item_tester_hook_kaji(object_type *o_ptr)
7591 switch (o_ptr->tval)
7611 if (o_ptr->xtra3) return (TRUE);
7619 void erase_essence(void)
7624 char o_name[MAX_NLEN];
7627 item_tester_hook = item_tester_hook_kaji;
7631 q = "¤É¤Î¥¢¥¤¥Æ¥à¤Î¥¨¥Ã¥»¥ó¥¹¤ò¾Ãµî¤·¤Þ¤¹¤«¡©";
7632 s = "¥¨¥Ã¥»¥ó¥¹¤òÉղä·¤¿¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
7634 q = "Remove from which item? ";
7635 s = "You have nothing to remove essence.";
7638 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7640 /* Get the item (in the pack) */
7643 o_ptr = &inventory[item];
7646 /* Get the item (on the floor) */
7649 o_ptr = &o_list[0 - item];
7652 object_desc(o_name, o_ptr, FALSE, 0);
7654 if (!get_check(format("¤è¤í¤·¤¤¤Ç¤¹¤«¡©[%s]", o_name))) return;
7656 if (!get_check(format("Are you sure?[%s]", o_name))) return;
7661 if (o_ptr->xtra3 == ESSENCE_SLAY_GLOVE)
7663 o_ptr->to_h -= (o_ptr->xtra4>>8);
7664 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
7668 object_flags(o_ptr, &f1, &f2, &f3);
7669 if (!(f1 & TR1_PVAL_MASK)) o_ptr->pval = 0;
7671 msg_print("¥¨¥Ã¥»¥ó¥¹¤ò¼è¤êµî¤Ã¤¿¡£");
7673 msg_print("You removed all essence you have added");
7676 /* Combine the pack */
7677 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7680 p_ptr->window |= (PW_INVEN);
7683 void do_cmd_kaji(bool only_browse)
7688 int menu_line = (use_menu ? 1 : 0);
7692 if (p_ptr->confused)
7695 msg_print("º®Í𤷤Ƥ¤¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
7697 msg_print("You are too confused!");
7705 msg_print("Ìܤ¬¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
7707 msg_print("You are blind!");
7715 msg_print("¤¦¤Þ¤¯¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
7717 msg_print("You are hullcinating!");
7725 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
7727 #endif /* ALLOW_REPEAT */
7729 if (only_browse) screen_save();
7731 if (!only_browse) screen_save();
7737 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", (menu_line == 1) ? "¡Õ" : " "), 2, 14);
7738 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", (menu_line == 2) ? "¡Õ" : " "), 3, 14);
7739 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹¾Ãµî", (menu_line == 3) ? "¡Õ" : " "), 4, 14);
7740 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", (menu_line == 4) ? "¡Õ" : " "), 5, 14);
7741 prt(format(" %s Éð´ï/Ëɶñ¶¯²½", (menu_line == 5) ? "¡Õ" : " "), 6, 14);
7742 prt(format("¤É¤Î¼ïÎà¤Îµ»½Ñ¤ò%s¤Þ¤¹¤«¡©", only_browse ? "Ä´¤Ù" : "»È¤¤"), 0, 0);
7744 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
7745 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
7746 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
7747 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
7748 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
7749 prt(format("Choose command from menu."), 0, 0);
7776 if (menu_line > 5) menu_line -= 5;
7785 prt(" a) ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", 2, 14);
7786 prt(" b) ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", 3, 14);
7787 prt(" c) ¥¨¥Ã¥»¥ó¥¹¾Ãµî", 4, 14);
7788 prt(" d) ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", 5, 14);
7789 prt(" e) Éð´ï/Ëɶñ¶¯²½", 6, 14);
7790 if (!get_com(format("¤É¤ÎǽÎϤò%s¤Þ¤¹¤«:", only_browse ? "Ä´¤Ù" : "»È¤¤"), &choice, TRUE))
7792 prt(" a) List essences", 2, 14);
7793 prt(" b) Extract essence", 3, 14);
7794 prt(" c) Remove essence", 4, 14);
7795 prt(" d) Add essence", 5, 14);
7796 prt(" e) Enchant weapon/armor", 6, 14);
7797 if (!get_com("Command :", &choice, TRUE))
7834 /* Clear lines, position cursor (really should use strlen here) */
7835 Term_erase(14, 21, 255);
7836 Term_erase(14, 20, 255);
7837 Term_erase(14, 19, 255);
7838 Term_erase(14, 18, 255);
7839 Term_erase(14, 17, 255);
7840 Term_erase(14, 16, 255);
7842 roff_to_buf( kaji_tips[mode-1],62,temp);
7843 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
7845 prt(&temp[j], line, 15);
7850 if (!only_browse) screen_load();
7851 } while (only_browse);
7855 #endif /* ALLOW_REPEAT */
7859 case 1: display_essence();break;
7860 case 2: drain_essence();break;
7861 case 3: erase_essence();break;
7863 mode = choose_essence();
7868 case 5: add_essence(6);break;