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].flags3 & TR3_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 (f1 & TR1_SLAY_UNDEAD) {tmp_cost += 1800;count++;}
935 if (f1 & TR1_SLAY_DEMON) {tmp_cost += 1800;count++;}
936 if (f1 & TR1_SLAY_ORC) {tmp_cost += 1500;count++;}
937 if (f1 & TR1_SLAY_TROLL) {tmp_cost += 1800;count++;}
938 if (f1 & TR1_SLAY_GIANT) {tmp_cost += 1800;count++;}
939 if (f1 & TR1_KILL_DRAGON) {tmp_cost += 2800;count++;}
940 else if (f1 & TR1_SLAY_DRAGON) {tmp_cost += 1800;count++;}
942 if (f1 & TR1_VORPAL) {tmp_cost += 2500;count++;}
943 if (f1 & TR1_IMPACT) {tmp_cost += 2500;count++;}
944 if (f1 & TR1_BRAND_POIS) {tmp_cost += 3800;count++;}
945 if (f1 & TR1_BRAND_ACID) {tmp_cost += 3800;count++;}
946 if (f1 & TR1_BRAND_ELEC) {tmp_cost += 3800;count++;}
947 if (f1 & TR1_BRAND_FIRE) {tmp_cost += 2500;count++;}
948 if (f1 & TR1_BRAND_COLD) {tmp_cost += 2500;count++;}
949 total += (tmp_cost * count);
951 if (f2 & TR2_SUST_STR) total += 850;
952 if (f2 & TR2_SUST_INT) total += 850;
953 if (f2 & TR2_SUST_WIS) total += 850;
954 if (f2 & TR2_SUST_DEX) total += 850;
955 if (f2 & TR2_SUST_CON) total += 850;
956 if (f2 & TR2_SUST_CHR) total += 250;
957 if (f2 & TR2_RIDING) total += 0;
958 if (f2 & TR2_XXX2) total += 0;
959 if (f2 & TR2_THROW) total += 5000;
960 if (f2 & TR2_FREE_ACT) total += 4500;
961 if (f2 & TR2_HOLD_LIFE) total += 8500;
965 if (f2 & TR2_IM_ACID) {tmp_cost += 15000;count += 2;}
966 if (f2 & TR2_IM_ELEC) {tmp_cost += 15000;count += 2;}
967 if (f2 & TR2_IM_FIRE) {tmp_cost += 15000;count += 2;}
968 if (f2 & TR2_IM_COLD) {tmp_cost += 15000;count += 2;}
969 if (f2 & TR2_REFLECT) {tmp_cost += 5000;count += 2;}
970 if (f2 & TR2_RES_ACID) {tmp_cost += 500;count++;}
971 if (f2 & TR2_RES_ELEC) {tmp_cost += 500;count++;}
972 if (f2 & TR2_RES_FIRE) {tmp_cost += 500;count++;}
973 if (f2 & TR2_RES_COLD) {tmp_cost += 500;count++;}
974 if (f2 & TR2_RES_POIS) {tmp_cost += 1000;count += 2;}
975 if (f2 & TR2_RES_FEAR) {tmp_cost += 1000;count += 2;}
976 if (f2 & TR2_RES_LITE) {tmp_cost += 800;count += 2;}
977 if (f2 & TR2_RES_DARK) {tmp_cost += 800;count += 2;}
978 if (f2 & TR2_RES_BLIND) {tmp_cost += 900;count += 2;}
979 if (f2 & TR2_RES_CONF) {tmp_cost += 900;count += 2;}
980 if (f2 & TR2_RES_SOUND) {tmp_cost += 900;count += 2;}
981 if (f2 & TR2_RES_SHARDS) {tmp_cost += 900;count += 2;}
982 if (f2 & TR2_RES_NETHER) {tmp_cost += 900;count += 2;}
983 if (f2 & TR2_RES_NEXUS) {tmp_cost += 900;count += 2;}
984 if (f2 & TR2_RES_CHAOS) {tmp_cost += 1000;count += 2;}
985 if (f2 & TR2_RES_DISEN) {tmp_cost += 2000;count += 2;}
986 total += (tmp_cost * count);
988 if (f3 & TR3_SH_FIRE) total += 5000;
989 if (f3 & TR3_SH_ELEC) total += 5000;
990 if (f3 & TR3_SH_COLD) total += 5000;
991 if (f3 & TR3_QUESTITEM) total += 0;
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_INSTA_ART) total += 0;
998 if (f3 & TR3_FEATHER) total += 1250;
999 if (f3 & TR3_LITE) total += 1250;
1000 if (f3 & TR3_SEE_INVIS) total += 2000;
1001 if (f3 & TR3_TELEPATHY) total += 20000;
1002 if (f3 & TR3_SLOW_DIGEST) total += 750;
1003 if (f3 & TR3_REGEN) total += 2500;
1004 if (f3 & TR3_WARNING) total += 2000;
1005 if (f3 & TR3_XTRA_MIGHT) total += 2250;
1006 if (f3 & TR3_XTRA_SHOTS) total += 10000;
1007 if (f3 & TR3_IGNORE_ACID) total += 100;
1008 if (f3 & TR3_IGNORE_ELEC) total += 100;
1009 if (f3 & TR3_IGNORE_FIRE) total += 100;
1010 if (f3 & TR3_IGNORE_COLD) total += 100;
1011 if (f3 & TR3_ACTIVATE) total += 100;
1012 if (f3 & TR3_DRAIN_EXP) total -= 12500;
1013 if (f3 & TR3_TELEPORT)
1015 if (o_ptr->ident & IDENT_CURSED)
1020 if (f3 & TR3_AGGRAVATE) total -= 10000;
1021 if (f3 & TR3_BLESSED) total += 750;
1022 if (f3 & TR3_CURSED) total -= 5000;
1023 if (f3 & TR3_HEAVY_CURSE) total -= 12500;
1024 if (f3 & TR3_PERMA_CURSE) total -= 15000;
1026 /* Also, give some extra for activatable powers... */
1027 if (o_ptr->art_name && (o_ptr->art_flags3 & TR3_ACTIVATE))
1029 int type = o_ptr->xtra2;
1031 if (type == ACT_SUNLIGHT) total += 250;
1032 else if (type == ACT_BO_MISS_1) total += 250;
1033 else if (type == ACT_BA_POIS_1) total += 300;
1034 else if (type == ACT_BO_ELEC_1) total += 250;
1035 else if (type == ACT_BO_ACID_1) total += 250;
1036 else if (type == ACT_BO_COLD_1) total += 250;
1037 else if (type == ACT_BO_FIRE_1) total += 250;
1038 else if (type == ACT_BA_COLD_1) total += 750;
1039 else if (type == ACT_BA_FIRE_1) total += 1000;
1040 else if (type == ACT_DRAIN_1) total += 500;
1041 else if (type == ACT_BA_COLD_2) total += 1250;
1042 else if (type == ACT_BA_ELEC_2) total += 1500;
1043 else if (type == ACT_DRAIN_2) total += 750;
1044 else if (type == ACT_VAMPIRE_1) total = 1000;
1045 else if (type == ACT_BO_MISS_2) total += 1000;
1046 else if (type == ACT_BA_FIRE_2) total += 1750;
1047 else if (type == ACT_BA_COLD_3) total += 2500;
1048 else if (type == ACT_BA_ELEC_3) total += 2500;
1049 else if (type == ACT_WHIRLWIND) total += 7500;
1050 else if (type == ACT_VAMPIRE_2) total += 2500;
1051 else if (type == ACT_CALL_CHAOS) total += 5000;
1052 else if (type == ACT_ROCKET) total += 5000;
1053 else if (type == ACT_DISP_EVIL) total += 4000;
1054 else if (type == ACT_DISP_GOOD) total += 3500;
1055 else if (type == ACT_BA_MISS_3) total += 5000;
1056 else if (type == ACT_CONFUSE) total += 500;
1057 else if (type == ACT_SLEEP) total += 750;
1058 else if (type == ACT_QUAKE) total += 600;
1059 else if (type == ACT_TERROR) total += 2500;
1060 else if (type == ACT_TELE_AWAY) 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_REST_LIFE) total += 7500;
1076 else if (type == ACT_REST_ALL) total += 15000;
1077 else if (type == ACT_CURE_700) total += 10000;
1078 else if (type == ACT_CURE_1000) total += 15000;
1079 else if (type == ACT_ESP) total += 1500;
1080 else if (type == ACT_BERSERK) total += 800;
1081 else if (type == ACT_PROT_EVIL) total += 5000;
1082 else if (type == ACT_RESIST_ALL) total += 5000;
1083 else if (type == ACT_SPEED) total += 15000;
1084 else if (type == ACT_XTRA_SPEED) total += 25000;
1085 else if (type == ACT_WRAITH) total += 25000;
1086 else if (type == ACT_INVULN) total += 25000;
1087 else if (type == ACT_LIGHT) total += 150;
1088 else if (type == ACT_MAP_LIGHT) total += 500;
1089 else if (type == ACT_DETECT_ALL) total += 1000;
1090 else if (type == ACT_DETECT_XTRA) total += 12500;
1091 else if (type == ACT_ID_FULL) total += 10000;
1092 else if (type == ACT_ID_PLAIN) total += 1250;
1093 else if (type == ACT_RUNE_EXPLO) total += 4000;
1094 else if (type == ACT_RUNE_PROT) total += 10000;
1095 else if (type == ACT_SATIATE) total += 2000;
1096 else if (type == ACT_DEST_DOOR) total += 100;
1097 else if (type == ACT_STONE_MUD) total += 1000;
1098 else if (type == ACT_RECHARGE) total += 1000;
1099 else if (type == ACT_ALCHEMY) total += 10000;
1100 else if (type == ACT_DIM_DOOR) total += 10000;
1101 else if (type == ACT_TELEPORT) total += 2000;
1102 else if (type == ACT_RECALL) total += 7500;
1110 * Return the "real" price of a "known" item, not including discounts
1112 * Wand and staffs get cost for each charge
1114 * Armor is worth an extra 100 gold per bonus point to armor class.
1116 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).
1118 * Missiles are only worth 5 gold per bonus point, since they
1119 * usually appear in groups of 20, and we want the player to get
1120 * the same amount of cash for any "equivalent" item. Note that
1121 * missiles never have any of the "pval" flags, and in fact, they
1122 * only have a few of the available flags, primarily of the "slay"
1123 * and "brand" and "ignore" variety.
1125 * Armor with a negative armor bonus is worthless.
1126 * Weapons with negative hit+damage bonuses are worthless.
1128 * Every wearable item with a "pval" bonus is worth extra (see below).
1130 s32b object_value_real(object_type *o_ptr)
1136 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1139 /* Hack -- "worthless" items */
1140 if (!get_object_cost(o_ptr)) return (0L);
1143 value = get_object_cost(o_ptr);
1145 /* Extract some flags */
1146 object_flags(o_ptr, &f1, &f2, &f3);
1151 artifact_type *a_ptr = &a_info[o_ptr->name1];
1153 /* Hack -- "worthless" artifacts */
1154 if (!a_ptr->cost) return (0L);
1156 /* Hack -- Use the artifact cost instead */
1157 value = a_ptr->cost;
1158 value += flag_cost(o_ptr, o_ptr->pval);
1163 else if (o_ptr->name2)
1165 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1167 /* Hack -- "worthless" ego-items */
1168 if (!e_ptr->cost) return (0L);
1170 /* Hack -- Reward the ego-item with a bonus */
1171 value += e_ptr->cost;
1172 value += flag_cost(o_ptr, o_ptr->pval);
1175 else if (o_ptr->art_flags1 || o_ptr->art_flags2 || o_ptr->art_flags3)
1177 value += flag_cost(o_ptr, o_ptr->pval);
1181 /* Analyze pval bonus */
1182 switch (o_ptr->tval)
1205 /* Hack -- Negative "pval" is always bad */
1206 if (o_ptr->pval < 0) return (0L);
1209 if (!o_ptr->pval) break;
1211 /* Give credit for stat bonuses */
1212 if (f1 & (TR1_STR)) value += (o_ptr->pval * 200L);
1213 if (f1 & (TR1_INT)) value += (o_ptr->pval * 200L);
1214 if (f1 & (TR1_WIS)) value += (o_ptr->pval * 200L);
1215 if (f1 & (TR1_DEX)) value += (o_ptr->pval * 200L);
1216 if (f1 & (TR1_CON)) value += (o_ptr->pval * 200L);
1217 if (f1 & (TR1_CHR)) value += (o_ptr->pval * 200L);
1219 /* Give credit for stealth and searching */
1220 if (f1 & (TR1_MAGIC_MASTERY)) value += (o_ptr->pval * 100L);
1221 if (f1 & (TR1_STEALTH)) value += (o_ptr->pval * 100L);
1222 if (f1 & (TR1_SEARCH)) value += (o_ptr->pval * 100L);
1224 /* Give credit for infra-vision and tunneling */
1225 if (f1 & (TR1_INFRA)) value += (o_ptr->pval * 50L);
1226 if (f1 & (TR1_TUNNEL)) value += (o_ptr->pval * 50L);
1228 /* Give credit for extra attacks */
1229 if (f1 & (TR1_BLOWS)) value += (o_ptr->pval * 5000L);
1231 /* Give credit for speed bonus */
1232 if (f1 & (TR1_SPEED)) value += (o_ptr->pval * 10000L);
1239 /* Analyze the item */
1240 switch (o_ptr->tval)
1245 /* Pay extra for charges, depending on standard number of
1246 * charges. Handle new-style wands correctly. -LM-
1248 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1255 /* Pay extra for charges, depending on standard number of
1258 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1268 /* Hack -- negative bonuses are bad */
1269 if (o_ptr->to_a < 0) return (0L);
1270 if (o_ptr->to_h < 0) return (0L);
1271 if (o_ptr->to_d < 0) return (0L);
1273 /* Give credit for bonuses */
1274 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1291 /* Hack -- negative armor bonus */
1292 if (o_ptr->to_a < 0) return (0L);
1294 /* Give credit for bonuses */
1295 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1308 /* Hack -- negative hit/damage bonuses */
1309 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1311 /* Factor in the bonuses */
1312 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1314 /* Hack -- Factor in extra damage dice */
1315 if ((o_ptr->dd > k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
1317 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 100L;
1329 /* Hack -- negative hit/damage bonuses */
1330 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1332 /* Factor in the bonuses */
1333 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1335 /* Hack -- Factor in extra damage dice */
1336 if ((o_ptr->dd > k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
1338 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1345 /* Figurines, relative to monster level */
1348 int level = r_info[o_ptr->pval].level;
1349 if (level < 20) value = level*50L;
1350 else if (level < 30) value = 1000+(level-20)*150L;
1351 else if (level < 40) value = 2500+(level-30)*350L;
1352 else if (level < 50) value = 6000+(level-40)*800L;
1353 else value = 14000+(level-50)*2000L;
1359 if (!o_ptr->pval) value = 1000L;
1360 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1366 if (!o_ptr->pval) value = 0L;
1371 /* Return the value */
1377 * Return the price of an item including plusses (and charges)
1379 * This function returns the "value" of the given item (qty one)
1381 * Never notice "unknown" bonuses or properties, including "curses",
1382 * since that would give the player information he did not have.
1384 * Note that discounted items stay discounted forever, even if
1385 * the discount is "forgotten" by the player via memory loss.
1387 s32b object_value(object_type *o_ptr)
1392 /* Unknown items -- acquire a base value */
1393 if (object_known_p(o_ptr))
1395 /* Broken items -- worthless */
1396 if (broken_p(o_ptr)) return (0L);
1398 /* Cursed items -- worthless */
1399 if (cursed_p(o_ptr)) return (0L);
1401 /* Real value (see above) */
1402 value = object_value_real(o_ptr);
1405 /* Known items -- acquire the actual value */
1408 /* Hack -- Felt broken items */
1409 if ((o_ptr->ident & (IDENT_SENSE)) && broken_p(o_ptr)) return (0L);
1411 /* Hack -- Felt cursed items */
1412 if ((o_ptr->ident & (IDENT_SENSE)) && cursed_p(o_ptr)) return (0L);
1414 /* Base value (see above) */
1415 value = object_value_base(o_ptr);
1419 /* Apply discount (if any) */
1420 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1423 /* Return the final value */
1429 * Distribute charges of rods or wands.
1431 * o_ptr = source item
1432 * q_ptr = target item, must be of the same type as o_ptr
1433 * amt = number of items that are transfered
1435 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1438 * Hack -- If rods or wands are dropped, the total maximum timeout or
1439 * charges need to be allocated between the two stacks. If all the items
1440 * are being dropped, it makes for a neater message to leave the original
1441 * stack's pval alone. -LM-
1443 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1445 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1446 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1448 /* Hack -- Rods also need to have their timeouts distributed. The
1449 * dropped stack will accept all time remaining to charge up to its
1452 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1454 if (q_ptr->pval > o_ptr->timeout)
1455 q_ptr->timeout = o_ptr->timeout;
1457 q_ptr->timeout = q_ptr->pval;
1459 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1464 void reduce_charges(object_type *o_ptr, int amt)
1467 * Hack -- If rods or wand are destroyed, the total maximum timeout or
1468 * charges of the stack needs to be reduced, unless all the items are
1469 * being destroyed. -LM-
1471 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1472 (amt < o_ptr->number))
1474 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1480 * Determine if an item can "absorb" a second item
1482 * See "object_absorb()" for the actual "absorption" code.
1484 * If permitted, we allow staffs (if they are known to have equal charges
1485 * and both are either known or confirmed empty) and wands (if both are
1486 * either known or confirmed empty) and rods (in all cases) to combine.
1487 * Staffs will unstack (if necessary) when they are used, but wands and
1488 * rods will only unstack if one is dropped. -LM-
1490 * If permitted, we allow weapons/armor to stack, if fully "known".
1492 * Missiles will combine if both stacks have the same "known" status.
1493 * This is done to make unidentified stacks of missiles useful.
1495 * Food, potions, scrolls, and "easy know" items always stack.
1497 * Chests, and activatable items, never stack (for various reasons).
1501 * Determine if an item can partly absorb a second item.
1503 bool object_similar_part(object_type *o_ptr, object_type *j_ptr)
1505 /* Require identical object types */
1506 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1509 /* Analyze the items */
1510 switch (o_ptr->tval)
1512 /* Chests and Statues*/
1523 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return (0);
1524 if (o_ptr->pval != j_ptr->pval) return (0);
1528 /* Figurines and Corpses*/
1533 if (o_ptr->pval != j_ptr->pval) return (0);
1539 /* Food and Potions and Scrolls */
1551 /* Require either knowledge or known empty for both staffs. */
1552 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1553 !object_known_p(o_ptr)) ||
1554 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1555 !object_known_p(j_ptr))) return(0);
1557 /* Require identical charges, since staffs are bulky. */
1558 if (o_ptr->pval != j_ptr->pval) return (0);
1567 /* Require either knowledge or known empty for both wands. */
1568 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1569 !object_known_p(o_ptr)) ||
1570 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1571 !object_known_p(j_ptr))) return(0);
1573 /* Wand charges combine in O&ZAngband. */
1579 /* Staffs and Wands and Rods */
1586 /* Weapons and Armor */
1602 /* Require permission */
1603 if (!stack_allow_items) return (0);
1608 /* Rings, Amulets, Lites */
1613 /* Require full knowledge of both items */
1614 if (!object_known_p(o_ptr) || !object_known_p(j_ptr)) return (0);
1624 /* Require identical knowledge of both items */
1625 if (object_known_p(o_ptr) != object_known_p(j_ptr)) return (0);
1627 /* Require identical "bonuses" */
1628 if (o_ptr->to_h != j_ptr->to_h) return (FALSE);
1629 if (o_ptr->to_d != j_ptr->to_d) return (FALSE);
1630 if (o_ptr->to_a != j_ptr->to_a) return (FALSE);
1632 /* Require identical "pval" code */
1633 if (o_ptr->pval != j_ptr->pval) return (FALSE);
1635 /* Require identical "artifact" names */
1636 if (o_ptr->name1 != j_ptr->name1) return (FALSE);
1638 /* Random artifacts never stack */
1639 if (o_ptr->art_name || j_ptr->art_name) return (FALSE);
1641 /* Require identical "ego-item" names */
1642 if (o_ptr->name2 != j_ptr->name2) return (FALSE);
1644 /* Require identical added essence */
1645 if (o_ptr->xtra3 != j_ptr->xtra3) return (FALSE);
1646 if (o_ptr->xtra4 != j_ptr->xtra4) return (FALSE);
1648 /* Hack -- Never stack "powerful" items */
1649 if (o_ptr->xtra1 || j_ptr->xtra1) return (FALSE);
1651 /* Hack -- Never stack recharging items */
1652 if (o_ptr->timeout || j_ptr->timeout) return (FALSE);
1654 /* Require identical "values" */
1655 if (o_ptr->ac != j_ptr->ac) return (FALSE);
1656 if (o_ptr->dd != j_ptr->dd) return (FALSE);
1657 if (o_ptr->ds != j_ptr->ds) return (FALSE);
1666 /* Require knowledge */
1667 if (!object_known_p(o_ptr) || !object_known_p(j_ptr)) return (0);
1675 /* Hack -- Identical art_flags! */
1676 if ((o_ptr->art_flags1 != j_ptr->art_flags1) ||
1677 (o_ptr->art_flags2 != j_ptr->art_flags2) ||
1678 (o_ptr->art_flags3 != j_ptr->art_flags3))
1681 /* Hack -- Require identical "cursed" status */
1682 if ((o_ptr->ident & (IDENT_CURSED)) != (j_ptr->ident & (IDENT_CURSED))) return (0);
1684 /* Hack -- Require identical "broken" status */
1685 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return (0);
1688 /* Hack -- require semi-matching "inscriptions" */
1689 if (o_ptr->inscription && j_ptr->inscription &&
1690 (o_ptr->inscription != j_ptr->inscription))
1693 /* Hack -- normally require matching "inscriptions" */
1694 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return (0);
1696 /* Hack -- normally require matching "discounts" */
1697 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return (0);
1700 /* They match, so they must be similar */
1705 * Determine if an item can absorb a second item.
1707 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1709 int total = o_ptr->number + j_ptr->number;
1711 if (!object_similar_part(o_ptr, j_ptr))
1714 /* Maximal "stacking" limit */
1715 if (total >= MAX_STACK_SIZE) return (0);
1718 /* They match, so they must be similar */
1725 * Allow one item to "absorb" another, assuming they are similar
1727 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1729 int total = o_ptr->number + j_ptr->number;
1731 /* Add together the item counts */
1732 o_ptr->number = ((total < MAX_STACK_SIZE) ? total : (MAX_STACK_SIZE - 1));
1734 /* Hack -- blend "known" status */
1735 if (object_known_p(j_ptr)) object_known(o_ptr);
1737 /* Hack -- clear "storebought" if only one has it */
1738 if (((o_ptr->ident & IDENT_STOREB) || (j_ptr->ident & IDENT_STOREB)) &&
1739 (!((o_ptr->ident & IDENT_STOREB) && (j_ptr->ident & IDENT_STOREB))))
1741 if (j_ptr->ident & IDENT_STOREB) j_ptr->ident &= 0xEF;
1742 if (o_ptr->ident & IDENT_STOREB) o_ptr->ident &= 0xEF;
1745 /* Hack -- blend "mental" status */
1746 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1748 /* Hack -- blend "inscriptions" */
1749 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1751 /* Hack -- blend "feelings" */
1752 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1754 /* Hack -- could average discounts XXX XXX XXX */
1755 /* Hack -- save largest discount XXX XXX XXX */
1756 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1758 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1759 if (o_ptr->tval == TV_ROD)
1761 o_ptr->pval += j_ptr->pval;
1762 o_ptr->timeout += j_ptr->timeout;
1765 /* Hack -- if wands are stacking, combine the charges. -LM- */
1766 if (o_ptr->tval == TV_WAND)
1768 o_ptr->pval += j_ptr->pval;
1774 * Find the index of the object_kind with the given tval and sval
1776 s16b lookup_kind(int tval, int sval)
1783 for (k = 1; k < max_k_idx; k++)
1785 object_kind *k_ptr = &k_info[k];
1787 /* Require correct tval */
1788 if (k_ptr->tval != tval) continue;
1791 if (k_ptr->sval == sval) return (k);
1793 /* Ignore illegal items */
1794 if (sval != SV_ANY) continue;
1796 /* Apply the randomizer */
1797 if (!one_in_(++num)) continue;
1799 /* Use this value */
1803 /* Return this choice */
1812 msg_format("¥¢¥¤¥Æ¥à¤¬¤Ê¤¤ (%d,%d)", tval, sval);
1814 msg_format("No object (%d,%d)", tval, sval);
1825 * Wipe an object clean.
1827 void object_wipe(object_type *o_ptr)
1829 /* Wipe the structure */
1830 (void)WIPE(o_ptr, object_type);
1835 * Prepare an object based on an existing object
1837 void object_copy(object_type *o_ptr, object_type *j_ptr)
1839 /* Copy the structure */
1840 COPY(o_ptr, j_ptr, object_type);
1845 * Prepare an object based on an object kind.
1847 void object_prep(object_type *o_ptr, int k_idx)
1849 object_kind *k_ptr = &k_info[k_idx];
1851 /* Clear the record */
1854 /* Save the kind index */
1855 o_ptr->k_idx = k_idx;
1857 /* Efficiency -- tval/sval */
1858 o_ptr->tval = k_ptr->tval;
1859 o_ptr->sval = k_ptr->sval;
1861 /* Default "pval" */
1862 o_ptr->pval = k_ptr->pval;
1864 /* Default number */
1867 /* Default weight */
1868 o_ptr->weight = k_ptr->weight;
1871 o_ptr->to_h = k_ptr->to_h;
1872 o_ptr->to_d = k_ptr->to_d;
1873 o_ptr->to_a = k_ptr->to_a;
1876 o_ptr->ac = k_ptr->ac;
1877 o_ptr->dd = k_ptr->dd;
1878 o_ptr->ds = k_ptr->ds;
1880 /* Hack -- worthless items are always "broken" */
1881 if (get_object_cost(o_ptr) <= 0) o_ptr->ident |= (IDENT_BROKEN);
1883 /* Hack -- cursed items are always "cursed" */
1884 if (k_ptr->flags3 & (TR3_CURSED)) o_ptr->ident |= (IDENT_CURSED);
1889 * Help determine an "enchantment bonus" for an object.
1891 * To avoid floating point but still provide a smooth distribution of bonuses,
1892 * we simply round the results of division in such a way as to "average" the
1893 * correct floating point value.
1895 * This function has been changed. It uses "randnor()" to choose values from
1896 * a normal distribution, whose mean moves from zero towards the max as the
1897 * level increases, and whose standard deviation is equal to 1/4 of the max,
1898 * and whose values are forced to lie between zero and the max, inclusive.
1900 * Since the "level" rarely passes 100 before Morgoth is dead, it is very
1901 * rare to get the "full" enchantment on an object, even a deep levels.
1903 * It is always possible (albeit unlikely) to get the "full" enchantment.
1905 * A sample distribution of values from "m_bonus(10, N)" is shown below:
1907 * N 0 1 2 3 4 5 6 7 8 9 10
1908 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
1909 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03
1910 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05
1911 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05
1912 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11
1913 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41
1914 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65
1915 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94
1916 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78
1917 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64
1918 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62
1919 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33
1920 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38
1921 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53
1922 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53
1923 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27
1924 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72
1925 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07
1927 s16b m_bonus(int max, int level)
1929 int bonus, stand, extra, value;
1932 /* Paranoia -- enforce maximal "level" */
1933 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1936 /* The "bonus" moves towards the max */
1937 bonus = ((max * level) / MAX_DEPTH);
1939 /* Hack -- determine fraction of error */
1940 extra = ((max * level) % MAX_DEPTH);
1942 /* Hack -- simulate floating point computations */
1943 if (randint0(MAX_DEPTH) < extra) bonus++;
1946 /* The "stand" is equal to one quarter of the max */
1949 /* Hack -- determine fraction of error */
1952 /* Hack -- simulate floating point computations */
1953 if (randint0(4) < extra) stand++;
1956 /* Choose an "interesting" value */
1957 value = randnor(bonus, stand);
1959 /* Enforce the minimum value */
1960 if (value < 0) return (0);
1962 /* Enforce the maximum value */
1963 if (value > max) return (max);
1971 * Cheat -- describe a created object for the user
1973 static void object_mention(object_type *o_ptr)
1975 char o_name[MAX_NLEN];
1978 object_desc_store(o_name, o_ptr, FALSE, 0);
1981 if (artifact_p(o_ptr))
1985 msg_format("ÅÁÀâ¤Î¥¢¥¤¥Æ¥à (%s)", o_name);
1987 msg_format("Artifact (%s)", o_name);
1992 /* Random Artifact */
1993 else if (o_ptr->art_name)
1996 msg_print("¥é¥ó¥À¥à¡¦¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È");
1998 msg_print("Random artifact");
2004 else if (ego_item_p(o_ptr))
2008 msg_format("̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à (%s)", o_name);
2010 msg_format("Ego-item (%s)", o_name);
2020 msg_format("¥¢¥¤¥Æ¥à (%s)", o_name);
2022 msg_format("Object (%s)", o_name);
2030 * Mega-Hack -- Attempt to create one of the "Special Objects"
2032 * We are only called from "make_object()", and we assume that
2033 * "apply_magic()" is called immediately after we return.
2035 * Note -- see "make_artifact()" and "apply_magic()"
2037 static bool make_artifact_special(object_type *o_ptr)
2043 /* No artifacts in the town */
2044 if (!dun_level) return (FALSE);
2047 if (get_obj_num_hook) return (FALSE);
2049 /* Check the artifact list (just the "specials") */
2050 for (i = 0; i < max_a_idx; i++)
2052 artifact_type *a_ptr = &a_info[i];
2054 /* Skip "empty" artifacts */
2055 if (!a_ptr->name) continue;
2057 /* Cannot make an artifact twice */
2058 if (a_ptr->cur_num) continue;
2060 if (a_ptr->flags3 & TR3_QUESTITEM) continue;
2061 if (!(a_ptr->flags3 & TR3_INSTA_ART)) continue;
2063 /* XXX XXX Enforce minimum "depth" (loosely) */
2064 if (a_ptr->level > dun_level)
2066 /* Acquire the "out-of-depth factor" */
2067 int d = (a_ptr->level - dun_level) * 2;
2069 /* Roll for out-of-depth creation */
2070 if (!one_in_(d)) continue;
2073 /* Artifact "rarity roll" */
2074 if (!one_in_(a_ptr->rarity)) continue;
2076 /* Find the base object */
2077 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2079 /* XXX XXX Enforce minimum "object" level (loosely) */
2080 if (k_info[k_idx].level > object_level)
2082 /* Acquire the "out-of-depth factor" */
2083 int d = (k_info[k_idx].level - object_level) * 5;
2085 /* Roll for out-of-depth creation */
2086 if (!one_in_(d)) continue;
2089 /* Assign the template */
2090 object_prep(o_ptr, k_idx);
2092 /* Mega-Hack -- mark the item as an artifact */
2095 /* Hack: Some artifacts get random extra powers */
2096 random_artifact_resistance(o_ptr);
2108 * Attempt to change an object into an artifact
2110 * This routine should only be called by "apply_magic()"
2112 * Note -- see "make_artifact_special()" and "apply_magic()"
2114 static bool make_artifact(object_type *o_ptr)
2119 /* No artifacts in the town */
2120 if (!dun_level) return (FALSE);
2122 /* Paranoia -- no "plural" artifacts */
2123 if (o_ptr->number != 1) return (FALSE);
2125 /* Check the artifact list (skip the "specials") */
2126 for (i = 0; i < max_a_idx; i++)
2128 artifact_type *a_ptr = &a_info[i];
2130 /* Skip "empty" items */
2131 if (!a_ptr->name) continue;
2133 /* Cannot make an artifact twice */
2134 if (a_ptr->cur_num) continue;
2136 if (a_ptr->flags3 & TR3_QUESTITEM) continue;
2138 if (a_ptr->flags3 & TR3_INSTA_ART) continue;
2140 /* Must have the correct fields */
2141 if (a_ptr->tval != o_ptr->tval) continue;
2142 if (a_ptr->sval != o_ptr->sval) continue;
2144 /* XXX XXX Enforce minimum "depth" (loosely) */
2145 if (a_ptr->level > dun_level)
2147 /* Acquire the "out-of-depth factor" */
2148 int d = (a_ptr->level - dun_level) * 2;
2150 /* Roll for out-of-depth creation */
2151 if (!one_in_(d)) continue;
2154 /* We must make the "rarity roll" */
2155 if (!one_in_(a_ptr->rarity)) continue;
2157 /* Hack -- mark the item as an artifact */
2160 /* Hack: Some artifacts get random extra powers */
2161 random_artifact_resistance(o_ptr);
2173 * Choose random ego type
2175 static byte get_random_ego(byte slot, bool good, int level)
2178 ego_item_type *e_ptr;
2182 for (i = 1; i < max_e_idx; i++)
2186 if (e_ptr->slot == slot
2187 /* && level >= e_ptr->level */
2188 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2191 total += (255 / e_ptr->rarity);
2195 value = randint1(total);
2197 for (i = 1; i < max_e_idx; i++)
2201 if (e_ptr->slot == slot
2202 /* && level >= e_ptr->level */
2203 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2206 value -= (255 / e_ptr->rarity);
2207 if (value <= 0L) break;
2215 * Apply magic to an item known to be a "weapon"
2217 * Hack -- note special base damage dice boosting
2218 * Hack -- note special processing for weapon/digger
2219 * Hack -- note special rating boost for dragon scale mail
2221 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2223 int tohit1 = randint1(5) + m_bonus(5, level);
2224 int todam1 = randint1(5) + m_bonus(5, level);
2226 int tohit2 = m_bonus(10, level);
2227 int todam2 = m_bonus(10, level);
2229 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2231 tohit2 = (tohit2+1)/2;
2232 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->ident |= (IDENT_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;
2339 random_resistance(o_ptr, FALSE, randint1(22)+16);
2341 case EGO_SLAY_DRAGON:
2342 random_resistance(o_ptr, FALSE, randint1(12) + 4);
2344 case EGO_KILL_DRAGON:
2345 random_resistance(o_ptr, FALSE, randint1(12) + 4);
2347 o_ptr->art_flags2 |= TR2_RES_POIS;
2348 random_resistance(o_ptr, FALSE, randint1(14) + 4);
2351 o_ptr->art_flags2 |= TR2_RES_FEAR;
2354 random_resistance(o_ptr, FALSE, (randint1(34) + 4));
2356 case EGO_SLAYING_WEAPON:
2357 if (one_in_(3)) /* double damage */
2365 while (one_in_(o_ptr->dd));
2371 while (one_in_(o_ptr->ds));
2376 o_ptr->art_flags1 |= TR1_BRAND_POIS;
2378 if (o_ptr->tval == TV_SWORD && one_in_(3))
2380 o_ptr->art_flags1 |= TR1_VORPAL;
2384 random_resistance(o_ptr, FALSE, (randint1(22) + 16));
2386 o_ptr->art_flags1 |= TR1_SLAY_DEMON;
2390 o_ptr->art_flags2 |= TR2_HOLD_LIFE;
2392 o_ptr->art_flags1 |= TR1_DEX;
2394 o_ptr->art_flags2 |= TR2_RES_FEAR;
2395 random_resistance(o_ptr, FALSE, (randint1(22) + 16));
2398 o_ptr->pval = m_bonus(5, level) + 1;
2400 case EGO_EARTHQUAKES:
2401 if (one_in_(3) && (level > 60))
2402 o_ptr->art_flags1 |= TR1_BLOWS;
2404 o_ptr->pval = m_bonus(3, level);
2408 if (!o_ptr->art_name)
2410 /* Hack -- Super-charge the damage dice */
2411 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2413 /* Hack -- Lower the damage dice */
2414 if (o_ptr->dd > 9) o_ptr->dd = 9;
2419 else if (power < -1)
2421 /* Roll for ego-item */
2422 if (randint0(MAX_DEPTH) < level)
2424 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE, level);
2425 switch (o_ptr->name2)
2428 if (one_in_(6)) o_ptr->art_flags3 |= TR3_TY_CURSE;
2444 create_artifact(o_ptr, FALSE);
2447 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE, level);
2449 switch (o_ptr->name2)
2451 case EGO_EXTRA_MIGHT:
2452 random_resistance(o_ptr, FALSE, rand_range(5, 38));
2468 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE, level);
2470 switch (o_ptr->name2)
2472 case EGO_SLAYING_BOLT:
2477 /* Hack -- super-charge the damage dice */
2478 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2480 /* Hack -- restrict the damage dice */
2481 if (o_ptr->dd > 9) o_ptr->dd = 9;
2485 else if (power < -1)
2487 /* Roll for ego-item */
2488 if (randint0(MAX_DEPTH) < level)
2490 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE, level);
2500 static void dragon_resist(object_type * o_ptr)
2507 random_resistance(o_ptr, FALSE, (randint1(14) + 4));
2509 random_resistance(o_ptr, FALSE, (randint1(22) + 16));
2516 * Apply magic to an item known to be "armor"
2518 * Hack -- note special processing for crown/helm
2519 * Hack -- note special processing for robe of permanence
2521 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2523 int toac1 = randint1(5) + m_bonus(5, level);
2525 int toac2 = m_bonus(10, level);
2533 o_ptr->to_a += toac1;
2539 o_ptr->to_a += toac2;
2547 o_ptr->to_a -= toac1;
2552 /* Penalize again */
2553 o_ptr->to_a -= toac2;
2556 /* Cursed (if "bad") */
2557 if (o_ptr->to_a < 0) o_ptr->ident |= (IDENT_CURSED);
2562 switch (o_ptr->tval)
2569 create_artifact(o_ptr, FALSE);
2571 /* Mention the item */
2572 if (cheat_peek) object_mention(o_ptr);
2583 /* Hack -- Try for "Robes of the Magi" */
2584 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2585 (o_ptr->sval == SV_ROBE) &&
2586 (randint0(100) < 15))
2590 o_ptr->name2 = EGO_YOIYAMI;
2591 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2592 o_ptr->sval = SV_YOIYAMI_ROBE;
2597 o_ptr->name2 = EGO_PERMANENCE;
2603 create_artifact(o_ptr, FALSE);
2609 bool okay_flag = TRUE;
2611 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE, level);
2613 switch (o_ptr->name2)
2615 case EGO_RESISTANCE:
2617 o_ptr->art_flags2 |= TR2_RES_POIS;
2618 random_resistance(o_ptr, FALSE, (randint1(22) + 16));
2621 if (o_ptr->tval != TV_HARD_ARMOR)
2628 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2629 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2631 o_ptr->art_flags1 |= TR1_CON;
2647 if (o_ptr->sval == SV_DRAGON_SHIELD)
2652 /* Mention the item */
2653 if (cheat_peek) object_mention(o_ptr);
2654 dragon_resist(o_ptr);
2655 if (!one_in_(3)) break;
2663 create_artifact(o_ptr, FALSE);
2666 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE, level);
2668 switch (o_ptr->name2)
2671 random_resistance(o_ptr, FALSE, (randint1(34) + 4));
2672 if (one_in_(4)) o_ptr->art_flags2 |= TR2_RES_POIS;
2674 case EGO_REFLECTION:
2675 if (o_ptr->sval == SV_SHIELD_OF_DEFLECTION)
2685 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2690 /* Mention the item */
2691 if (cheat_peek) object_mention(o_ptr);
2692 dragon_resist(o_ptr);
2693 if (!one_in_(3)) break;
2699 create_artifact(o_ptr, FALSE);
2702 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE, level);
2704 switch (o_ptr->name2)
2707 random_resistance(o_ptr, FALSE, (randint1(22) + 16));
2713 else if (power < -1)
2715 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE, level);
2723 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2728 /* Mention the item */
2729 if (cheat_peek) object_mention(o_ptr);
2730 dragon_resist(o_ptr);
2731 if (!one_in_(3)) break;
2738 create_artifact(o_ptr, FALSE);
2741 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE, level);
2743 switch (o_ptr->name2)
2745 case EGO_SLOW_DESCENT:
2748 random_resistance(o_ptr, FALSE, (randint1(22) + 16));
2754 else if (power < -1)
2756 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE, level);
2769 create_artifact(o_ptr, FALSE);
2774 bool ok_flag = TRUE;
2775 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE, level);
2777 switch (o_ptr->name2)
2780 random_resistance(o_ptr, FALSE, (randint1(22) + 16));
2783 random_resistance(o_ptr, FALSE, (randint1(22) + 16));
2786 case EGO_REGENERATION:
2788 case EGO_LORDLINESS:
2789 random_resistance(o_ptr, FALSE, (randint1(22) + 16));
2792 if (one_in_(3)) o_ptr->art_flags3 |= TR3_TELEPATHY;
2794 default:/* not existing crown (wisdom,lite, etc...) */
2798 break; /* while (1) */
2804 else if (power < -1)
2806 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE, level);
2814 if (o_ptr->sval == SV_DRAGON_HELM)
2819 /* Mention the item */
2820 if (cheat_peek) object_mention(o_ptr);
2821 dragon_resist(o_ptr);
2822 if (!one_in_(3)) break;
2830 create_artifact(o_ptr, FALSE);
2835 bool ok_flag = TRUE;
2836 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE, level);
2838 switch (o_ptr->name2)
2840 case EGO_INTELLIGENCE:
2844 case EGO_INFRAVISION:
2847 if (one_in_(7)) o_ptr->art_flags3 |= TR3_TELEPATHY;
2849 default:/* not existing helm (Magi, Might, etc...)*/
2853 break; /* while (1) */
2858 else if (power < -1)
2860 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE, level);
2872 create_artifact(o_ptr, FALSE);
2875 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE, level);
2877 switch (o_ptr->name2)
2888 else if (power < -1)
2890 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE, level);
2900 * Apply magic to an item known to be a "ring" or "amulet"
2902 * Hack -- note special rating boost for ring of speed
2903 * Hack -- note special rating boost for amulet of the magi
2904 * Hack -- note special "pval boost" code for ring of speed
2905 * Hack -- note that some items must be cursed (or blessed)
2907 static void a_m_aux_3(object_type *o_ptr, int level, int power)
2912 /* Apply magic (good or bad) according to type */
2913 switch (o_ptr->tval)
2918 switch (o_ptr->sval)
2920 case SV_RING_ATTACKS:
2923 o_ptr->pval = m_bonus(2, level);
2924 if (one_in_(15)) o_ptr->pval++;
2925 if (o_ptr->pval < 1) o_ptr->pval = 1;
2931 o_ptr->ident |= (IDENT_BROKEN);
2934 o_ptr->ident |= (IDENT_CURSED);
2937 o_ptr->pval = 0 - (o_ptr->pval);
2948 /* Strength, Constitution, Dexterity, Intelligence */
2954 o_ptr->pval = 1 + m_bonus(5, level);
2960 o_ptr->ident |= (IDENT_BROKEN);
2963 o_ptr->ident |= (IDENT_CURSED);
2966 o_ptr->pval = 0 - (o_ptr->pval);
2972 /* Ring of Speed! */
2975 /* Base speed (1 to 10) */
2976 o_ptr->pval = randint1(5) + m_bonus(5, level);
2978 /* Super-charge the ring */
2979 while (randint0(100) < 50) o_ptr->pval++;
2985 o_ptr->ident |= (IDENT_BROKEN);
2988 o_ptr->ident |= (IDENT_CURSED);
2991 o_ptr->pval = 0 - (o_ptr->pval);
2999 /* Mention the item */
3000 if (cheat_peek) object_mention(o_ptr);
3005 case SV_RING_LORDLY:
3009 random_resistance(o_ptr, FALSE, randint1(20) + 18);
3013 /* Bonus to armor class */
3014 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
3020 case SV_RING_SEARCHING:
3022 /* Bonus to searching */
3023 o_ptr->pval = 1 + m_bonus(5, level);
3029 o_ptr->ident |= (IDENT_BROKEN);
3032 o_ptr->ident |= (IDENT_CURSED);
3035 o_ptr->pval = 0 - (o_ptr->pval);
3041 /* Flames, Acid, Ice */
3042 case SV_RING_FLAMES:
3047 /* Bonus to armor class */
3048 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3052 /* Weakness, Stupidity */
3053 case SV_RING_WEAKNESS:
3054 case SV_RING_STUPIDITY:
3057 o_ptr->ident |= (IDENT_BROKEN);
3060 o_ptr->ident |= (IDENT_CURSED);
3063 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3064 if (power > 0) power = 0 - power;
3069 /* WOE, Stupidity */
3073 o_ptr->ident |= (IDENT_BROKEN);
3076 o_ptr->ident |= (IDENT_CURSED);
3079 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3080 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3081 if (power > 0) power = 0 - power;
3086 /* Ring of damage */
3087 case SV_RING_DAMAGE:
3089 /* Bonus to damage */
3090 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3096 o_ptr->ident |= (IDENT_BROKEN);
3099 o_ptr->ident |= (IDENT_CURSED);
3102 o_ptr->to_d = 0 - o_ptr->to_d;
3108 /* Ring of Accuracy */
3109 case SV_RING_ACCURACY:
3112 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3118 o_ptr->ident |= (IDENT_BROKEN);
3121 o_ptr->ident |= (IDENT_CURSED);
3124 o_ptr->to_h = 0 - o_ptr->to_h;
3130 /* Ring of Protection */
3131 case SV_RING_PROTECTION:
3133 /* Bonus to armor class */
3134 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3140 o_ptr->ident |= (IDENT_BROKEN);
3143 o_ptr->ident |= (IDENT_CURSED);
3146 o_ptr->to_a = 0 - o_ptr->to_a;
3152 /* Ring of Slaying */
3153 case SV_RING_SLAYING:
3155 /* Bonus to damage and to hit */
3156 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3157 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3163 o_ptr->ident |= (IDENT_BROKEN);
3166 o_ptr->ident |= (IDENT_CURSED);
3168 /* Reverse bonuses */
3169 o_ptr->to_h = 0 - o_ptr->to_h;
3170 o_ptr->to_d = 0 - o_ptr->to_d;
3176 case SV_RING_MUSCLE:
3178 o_ptr->pval = 1 + m_bonus(3, level);
3179 if (one_in_(4)) o_ptr->pval++;
3185 o_ptr->ident |= (IDENT_BROKEN);
3188 o_ptr->ident |= (IDENT_CURSED);
3190 /* Reverse bonuses */
3191 o_ptr->pval = 0 - o_ptr->pval;
3196 case SV_RING_AGGRAVATION:
3199 o_ptr->ident |= (IDENT_BROKEN);
3202 o_ptr->ident |= (IDENT_CURSED);
3204 if (power > 0) power = 0 - power;
3208 if (one_in_(400) && (power > 0) && !(o_ptr->ident & IDENT_CURSED) && (level > 79))
3210 o_ptr->pval = MIN(o_ptr->pval,4);
3211 /* Randart amulet */
3212 create_artifact(o_ptr, FALSE);
3214 else if ((power == 2) && one_in_(2))
3216 while(!o_ptr->name2)
3218 int tmp = m_bonus(10, level);
3219 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3220 switch(randint1(28))
3223 o_ptr->name2 = EGO_RING_THROW;
3226 if (k_ptr->flags3 & TR3_REGEN) break;
3227 o_ptr->name2 = EGO_RING_REGEN;
3230 if (k_ptr->flags3 & TR3_LITE)
3231 o_ptr->name2 = EGO_RING_LITE;
3234 if (k_ptr->flags2 & TR3_TELEPORT) break;
3235 o_ptr->name2 = EGO_RING_TELEPORT;
3238 if (o_ptr->to_h) break;
3239 o_ptr->name2 = EGO_RING_TO_H;
3242 if (o_ptr->to_d) break;
3243 o_ptr->name2 = EGO_RING_TO_D;
3246 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3247 o_ptr->name2 = EGO_RING_SLAY;
3250 if ((k_ptr->flags1 & TR1_STR) || o_ptr->to_h || o_ptr->to_d) break;
3251 o_ptr->name2 = EGO_RING_WIZARD;
3254 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3255 o_ptr->name2 = EGO_RING_HERO;
3258 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3259 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3260 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3261 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3264 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3265 if (!(k_ptr->flags2 & TR2_RES_FIRE) && (k_ptr->flags2 & (TR2_RES_COLD | TR2_RES_ELEC | TR2_RES_ACID))) break;
3266 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3267 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3268 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3271 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3272 if (!(k_ptr->flags2 & TR2_RES_COLD) && (k_ptr->flags2 & (TR2_RES_FIRE | TR2_RES_ELEC | TR2_RES_ACID))) break;
3273 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3274 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3275 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3278 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3279 if (!(k_ptr->flags2 & TR2_RES_ELEC) && (k_ptr->flags2 & (TR2_RES_COLD | TR2_RES_FIRE | TR2_RES_ACID))) break;
3280 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3281 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3284 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3285 if (!(k_ptr->flags2 & TR2_RES_ACID) && (k_ptr->flags2 & (TR2_RES_COLD | TR2_RES_ELEC | TR2_RES_FIRE))) break;
3286 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3287 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3289 case 21: case 22: case 23: case 24: case 25: case 26:
3290 switch (o_ptr->sval)
3293 if (!one_in_(3)) break;
3294 o_ptr->name2 = EGO_RING_D_SPEED;
3296 case SV_RING_DAMAGE:
3297 case SV_RING_ACCURACY:
3298 case SV_RING_SLAYING:
3299 if (one_in_(2)) break;
3300 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3303 o_ptr->name2 = EGO_RING_BERSERKER;
3304 o_ptr->to_h -= 2+randint1(4);
3307 case SV_RING_PROTECTION:
3308 o_ptr->name2 = EGO_RING_SUPER_AC;
3309 o_ptr->to_a += m_bonus(5, level);
3311 case SV_RING_RES_FEAR:
3312 o_ptr->name2 = EGO_RING_HERO;
3315 if (one_in_(2)) break;
3316 o_ptr->name2 = EGO_RING_HUNTER;
3318 case SV_RING_SEARCHING:
3319 o_ptr->name2 = EGO_RING_STEALTH;
3321 case SV_RING_TELEPORTATION:
3322 o_ptr->name2 = EGO_RING_TELE_AWAY;
3324 case SV_RING_RES_BLINDNESS:
3326 o_ptr->name2 = EGO_RING_RES_LITE;
3328 o_ptr->name2 = EGO_RING_RES_DARK;
3330 case SV_RING_LORDLY:
3331 if (!one_in_(20)) break;
3332 random_resistance(o_ptr, FALSE, randint1(20) + 18);
3333 random_resistance(o_ptr, FALSE, randint1(20) + 18);
3334 o_ptr->name2 = EGO_RING_TRUE;
3336 case SV_RING_SUSTAIN:
3337 if (!one_in_(4)) break;
3338 o_ptr->name2 = EGO_RING_RES_TIME;
3340 case SV_RING_FLAMES:
3341 if (!one_in_(2)) break;
3342 o_ptr->name2 = EGO_RING_DRAGON_F;
3345 if (!one_in_(2)) break;
3346 o_ptr->name2 = EGO_RING_DRAGON_C;
3348 case SV_RING_WARNING:
3349 if (!one_in_(2)) break;
3350 o_ptr->name2 = EGO_RING_M_DETECT;
3359 o_ptr->ident &= ~(IDENT_CURSED);
3361 if (o_ptr->art_flags3 & TR3_CURSED)
3362 o_ptr->art_flags3 &= ~(TR3_CURSED);
3364 if (o_ptr->art_flags3 & TR3_HEAVY_CURSE)
3365 o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
3367 else if ((power == -2) && one_in_(2))
3369 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3370 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3371 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3372 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3373 o_ptr->art_flags1 = 0;
3374 o_ptr->art_flags2 = 0;
3375 while(!o_ptr->name2)
3377 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3381 if (k_ptr->flags3 & TR3_DRAIN_EXP) break;
3382 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3385 o_ptr->name2 = EGO_RING_NO_MELEE;
3388 if (k_ptr->flags3 & TR3_AGGRAVATE) break;
3389 o_ptr->name2 = EGO_RING_AGGRAVATE;
3392 if (k_ptr->flags3 & TR3_TY_CURSE) break;
3393 o_ptr->name2 = EGO_RING_TY_CURSE;
3396 o_ptr->name2 = EGO_RING_ALBINO;
3401 o_ptr->ident |= (IDENT_BROKEN);
3404 o_ptr->ident |= (IDENT_CURSED);
3412 switch (o_ptr->sval)
3414 /* Amulet of wisdom/charisma */
3415 case SV_AMULET_INTELLIGENCE:
3416 case SV_AMULET_WISDOM:
3417 case SV_AMULET_CHARISMA:
3419 o_ptr->pval = 1 + m_bonus(5, level);
3425 o_ptr->ident |= (IDENT_BROKEN);
3428 o_ptr->ident |= (IDENT_CURSED);
3430 /* Reverse bonuses */
3431 o_ptr->pval = 0 - o_ptr->pval;
3437 /* Amulet of brilliance */
3438 case SV_AMULET_BRILLIANCE:
3440 o_ptr->pval = 1 + m_bonus(3, level);
3441 if (one_in_(4)) o_ptr->pval++;
3447 o_ptr->ident |= (IDENT_BROKEN);
3450 o_ptr->ident |= (IDENT_CURSED);
3452 /* Reverse bonuses */
3453 o_ptr->pval = 0 - o_ptr->pval;
3459 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3463 o_ptr->ident |= (IDENT_CURSED);
3468 case SV_AMULET_RESISTANCE:
3470 if (one_in_(3)) random_resistance(o_ptr, FALSE, (randint1(34) + 4));
3471 if (one_in_(5)) o_ptr->art_flags2 |= TR2_RES_POIS;
3475 /* Amulet of searching */
3476 case SV_AMULET_SEARCHING:
3478 o_ptr->pval = randint1(2) + m_bonus(4, level);
3484 o_ptr->ident |= (IDENT_BROKEN);
3487 o_ptr->ident |= (IDENT_CURSED);
3489 /* Reverse bonuses */
3490 o_ptr->pval = 0 - (o_ptr->pval);
3496 /* Amulet of the Magi -- never cursed */
3497 case SV_AMULET_THE_MAGI:
3499 o_ptr->pval = randint1(5) + m_bonus(5, level);
3500 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3502 /* Boost the rating */
3505 /* Mention the item */
3506 if (cheat_peek) object_mention(o_ptr);
3511 /* Amulet of Doom -- always cursed */
3512 case SV_AMULET_DOOM:
3515 o_ptr->ident |= (IDENT_BROKEN);
3518 o_ptr->ident |= (IDENT_CURSED);
3521 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3522 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3523 if (power > 0) power = 0 - power;
3528 case SV_AMULET_MAGIC_MASTERY:
3530 o_ptr->pval = 1 + m_bonus(4, level);
3536 o_ptr->ident |= (IDENT_BROKEN);
3539 o_ptr->ident |= (IDENT_CURSED);
3541 /* Reverse bonuses */
3542 o_ptr->pval = 0 - o_ptr->pval;
3548 if (one_in_(150) && (power > 0) && !(o_ptr->ident & IDENT_CURSED) && (level > 79))
3550 o_ptr->pval = MIN(o_ptr->pval,4);
3551 /* Randart amulet */
3552 create_artifact(o_ptr, FALSE);
3554 else if ((power == 2) && one_in_(2))
3556 while(!o_ptr->name2)
3558 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3559 switch(randint1(21))
3562 if (k_ptr->flags3 & TR3_SLOW_DIGEST) break;
3563 o_ptr->name2 = EGO_AMU_SLOW_D;
3566 if (o_ptr->pval) break;
3567 o_ptr->name2 = EGO_AMU_INFRA;
3570 if (k_ptr->flags3 & TR3_SEE_INVIS) break;
3571 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3574 if (k_ptr->flags2 & TR2_HOLD_LIFE) break;
3575 o_ptr->name2 = EGO_AMU_HOLD_LIFE;
3578 if (k_ptr->flags3 & TR3_FEATHER) break;
3579 o_ptr->name2 = EGO_AMU_LEVITATION;
3581 case 10: case 11: case 21:
3582 o_ptr->name2 = EGO_AMU_AC;
3585 if (k_ptr->flags2 & TR2_RES_FIRE) break;
3586 if (m_bonus(10, level) > 8)
3587 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3589 o_ptr->name2 = EGO_AMU_RES_FIRE;
3592 if (k_ptr->flags2 & TR2_RES_COLD) break;
3593 if (m_bonus(10, level) > 8)
3594 o_ptr->name2 = EGO_AMU_RES_COLD_;
3596 o_ptr->name2 = EGO_AMU_RES_COLD;
3599 if (k_ptr->flags2 & TR2_RES_ELEC) break;
3600 if (m_bonus(10, level) > 8)
3601 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3603 o_ptr->name2 = EGO_AMU_RES_ELEC;
3606 if (k_ptr->flags2 & TR2_RES_ACID) break;
3607 if (m_bonus(10, level) > 8)
3608 o_ptr->name2 = EGO_AMU_RES_ACID_;
3610 o_ptr->name2 = EGO_AMU_RES_ACID;
3612 case 16: case 17: case 18: case 19: case 20:
3613 switch (o_ptr->sval)
3615 case SV_AMULET_TELEPORT:
3616 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3617 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3618 else o_ptr->name2 = EGO_AMU_TELEPORT;
3620 case SV_AMULET_RESIST_ACID:
3621 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3623 case SV_AMULET_SEARCHING:
3624 o_ptr->name2 = EGO_AMU_STEALTH;
3626 case SV_AMULET_BRILLIANCE:
3627 if (!one_in_(3)) break;
3628 o_ptr->name2 = EGO_AMU_IDENT;
3630 case SV_AMULET_CHARISMA:
3631 if (!one_in_(3)) break;
3632 o_ptr->name2 = EGO_AMU_CHARM;
3634 case SV_AMULET_THE_MAGI:
3635 if (one_in_(2)) break;
3636 o_ptr->name2 = EGO_AMU_GREAT;
3638 case SV_AMULET_RESISTANCE:
3639 if (!one_in_(5)) break;
3640 o_ptr->name2 = EGO_AMU_DEFENDER;
3642 case SV_AMULET_TELEPATHY:
3643 if (!one_in_(3)) break;
3644 o_ptr->name2 = EGO_AMU_DETECTION;
3650 o_ptr->ident &= ~(IDENT_CURSED);
3652 if (o_ptr->art_flags3 & TR3_CURSED)
3653 o_ptr->art_flags3 &= ~(TR3_CURSED);
3655 if (o_ptr->art_flags3 & TR3_HEAVY_CURSE)
3656 o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
3658 else if ((power == -2) && one_in_(2))
3660 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3661 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3662 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3663 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3664 o_ptr->art_flags1 = 0;
3665 o_ptr->art_flags2 = 0;
3666 while(!o_ptr->name2)
3668 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3672 if (k_ptr->flags3 & TR3_DRAIN_EXP) break;
3673 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3676 o_ptr->name2 = EGO_AMU_FOOL;
3679 if (k_ptr->flags3 & TR3_AGGRAVATE) break;
3680 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3683 if (k_ptr->flags3 & TR3_TY_CURSE) break;
3684 o_ptr->name2 = EGO_AMU_TY_CURSE;
3687 o_ptr->name2 = EGO_AMU_NAIVETY;
3692 o_ptr->ident |= (IDENT_BROKEN);
3695 o_ptr->ident |= (IDENT_CURSED);
3704 * Hack -- help pick an item type
3706 static bool item_monster_okay(int r_idx)
3708 monster_race *r_ptr = &r_info[r_idx];
3711 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3712 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3713 if (r_ptr->flags3 & RF3_RES_ALL) return (FALSE);
3714 if (r_ptr->flags7 & RF7_UNIQUE_7) return (FALSE);
3715 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3716 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3724 * Apply magic to an item known to be "boring"
3726 * Hack -- note the special code for various items
3728 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3730 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3732 /* Apply magic (good or bad) according to type */
3733 switch (o_ptr->tval)
3742 o_ptr->ident |= (IDENT_BROKEN);
3745 o_ptr->ident |= (IDENT_CURSED);
3752 o_ptr->xtra4 = o_ptr->pval;
3758 /* Hack -- Torches -- random fuel */
3759 if (o_ptr->sval == SV_LITE_TORCH)
3761 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3765 /* Hack -- Lanterns -- random fuel */
3766 if (o_ptr->sval == SV_LITE_LANTERN)
3768 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3772 if ((power == 2) || ((power == 1) && one_in_(3)))
3774 while (!o_ptr->name2)
3778 bool okay_flag = TRUE;
3780 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE, level);
3782 switch (o_ptr->name2)
3785 if (o_ptr->sval == SV_LITE_FEANOR)
3793 else if (power == -2)
3795 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE, level);
3797 switch (o_ptr->name2)
3799 case EGO_LITE_DARKNESS:
3811 /* The wand or staff gets a number of initial charges equal
3812 * to between 1/2 (+1) and the full object kind's pval. -LM-
3814 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
3820 /* Transfer the pval. -LM- */
3821 o_ptr->pval = k_ptr->pval;
3828 object_aware(o_ptr);
3829 object_known(o_ptr);
3838 monster_race *r_ptr;
3840 /* Pick a random non-unique monster race */
3843 i = randint1(max_r_idx - 1);
3845 if (!item_monster_okay(i)) continue;
3846 if (i == MON_TSUCHINOKO) continue;
3850 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
3852 /* Ignore dead monsters */
3853 if (!r_ptr->rarity) continue;
3855 /* Prefer less out-of-depth monsters */
3856 if (randint0(check)) continue;
3863 /* Some figurines are cursed */
3864 if (one_in_(6)) o_ptr->ident |= IDENT_CURSED;
3869 msg_format("%s¤Î¿Í·Á, ¿¼¤µ +%d%s",
3871 msg_format("Figurine of %s, depth +%d%s",
3874 r_name + r_ptr->name, check - 1,
3875 !(o_ptr->ident & IDENT_CURSED) ? "" : " {cursed}");
3888 monster_race *r_ptr;
3890 if (o_ptr->sval == SV_SKELETON)
3892 match = RF9_DROP_SKELETON;
3894 else if (o_ptr->sval == SV_CORPSE)
3896 match = RF9_DROP_CORPSE;
3899 /* Hack -- Remove the monster restriction */
3900 get_mon_num_prep(item_monster_okay, NULL);
3902 /* Pick a random non-unique monster race */
3905 i = get_mon_num(dun_level);
3909 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
3911 /* Ignore dead monsters */
3912 if (!r_ptr->rarity) continue;
3914 /* Ignore corpseless monsters */
3915 if (!(r_ptr->flags9 & match)) continue;
3917 /* Prefer less out-of-depth monsters */
3918 if (randint0(check)) continue;
3928 msg_format("%s¤Î»àÂÎ,¿¼¤µ +%d",
3930 msg_format("Corpse of %s, depth +%d",
3933 r_name + r_ptr->name, check - 1);
3936 object_aware(o_ptr);
3937 object_known(o_ptr);
3945 monster_race *r_ptr;
3947 /* Pick a random monster race */
3950 i = randint1(max_r_idx - 1);
3954 /* Ignore dead monsters */
3955 if (!r_ptr->rarity) continue;
3965 msg_format("%s¤ÎÁü,", r_name + r_ptr->name);
3967 msg_format("Statue of %s", r_name + r_ptr->name);
3971 object_aware(o_ptr);
3972 object_known(o_ptr);
3979 byte obj_level = get_object_level(o_ptr);
3981 /* Hack -- skip ruined chests */
3982 if (obj_level <= 0) break;
3984 /* Hack -- pick a "difficulty" */
3985 o_ptr->pval = randint1(obj_level);
3986 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
3988 o_ptr->xtra3 = dun_level + 5;
3990 /* Never exceed "difficulty" of 55 to 59 */
3991 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4000 * Complete the "creation" of an object by applying "magic" to the item
4002 * This includes not only rolling for random bonuses, but also putting the
4003 * finishing touches on ego-items and artifacts, giving charges to wands and
4004 * staffs, giving fuel to lites, and placing traps on chests.
4006 * In particular, note that "Instant Artifacts", if "created" by an external
4007 * routine, must pass through this function to complete the actual creation.
4009 * The base "chance" of the item being "good" increases with the "level"
4010 * parameter, which is usually derived from the dungeon level, being equal
4011 * to the level plus 10, up to a maximum of 75. If "good" is true, then
4012 * the object is guaranteed to be "good". If an object is "good", then
4013 * the chance that the object will be "great" (ego-item or artifact), also
4014 * increases with the "level", being equal to half the level, plus 5, up to
4015 * a maximum of 20. If "great" is true, then the object is guaranteed to be
4016 * "great". At dungeon level 65 and below, 15/100 objects are "great".
4018 * If the object is not "good", there is a chance it will be "cursed", and
4019 * if it is "cursed", there is a chance it will be "broken". These chances
4020 * are related to the "good" / "great" chances above.
4022 * Otherwise "normal" rings and amulets will be "good" half the time and
4023 * "cursed" half the time, unless the ring/amulet is always good or cursed.
4025 * If "okay" is true, and the object is going to be "great", then there is
4026 * a chance that an artifact will be created. This is true even if both the
4027 * "good" and "great" arguments are false. As a total hack, if "great" is
4028 * true, then the item gets 3 extra "attempts" to become an artifact.
4030 void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great, bool curse)
4033 int i, rolls, f1, f2, power;
4035 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4037 /* Maximum "level" for various things */
4038 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4040 /* Base chance of being "good" */
4043 /* Maximal chance of being "good" */
4044 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4046 /* Base chance of being "great" */
4049 /* Maximal chance of being "great" */
4050 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4051 f2 = d_info[dungeon_type].obj_great;
4053 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4058 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4067 /* Roll for "good" */
4068 if (good || magik(f1))
4073 /* Roll for "great" */
4074 if (great || magik(f2)) power = 2;
4077 /* Roll for "cursed" */
4080 /* Assume "cursed" */
4083 /* Roll for "broken" */
4084 if (magik(f2)) power = -2;
4090 /* Assume 'cursed' */
4095 /* Everything else gets more badly cursed */
4102 /* Assume no rolls */
4105 /* Get one roll if excellent */
4106 if (power >= 2) rolls = 1;
4108 /* Hack -- Get four rolls if forced great */
4109 if (great) rolls = 4;
4111 /* Hack -- Get no rolls if not allowed */
4112 if (!okay || o_ptr->name1) rolls = 0;
4114 /* Roll for artifacts if allowed */
4115 for (i = 0; i < rolls; i++)
4117 /* Roll for an artifact */
4118 if (make_artifact(o_ptr)) break;
4119 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4121 if (make_artifact(o_ptr)) break;
4126 /* Hack -- analyze artifacts */
4129 artifact_type *a_ptr = &a_info[o_ptr->name1];
4131 /* Hack -- Mark the artifact as "created" */
4134 /* Extract the other fields */
4135 o_ptr->pval = a_ptr->pval;
4136 o_ptr->ac = a_ptr->ac;
4137 o_ptr->dd = a_ptr->dd;
4138 o_ptr->ds = a_ptr->ds;
4139 o_ptr->to_a = a_ptr->to_a;
4140 o_ptr->to_h = a_ptr->to_h;
4141 o_ptr->to_d = a_ptr->to_d;
4142 o_ptr->weight = a_ptr->weight;
4144 /* Hack -- extract the "broken" flag */
4145 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4147 /* Hack -- extract the "cursed" flag */
4148 if (a_ptr->flags3 & TR3_CURSED) o_ptr->ident |= (IDENT_CURSED);
4150 /* Mega-Hack -- increase the rating */
4153 /* Mega-Hack -- increase the rating again */
4154 if (a_ptr->cost > 50000L) rating += 10;
4156 /* Mega-Hack -- increase the rating again */
4157 if (a_ptr->cost > 100000L) rating += 10;
4159 /* Set the good item flag */
4160 good_item_flag = TRUE;
4162 /* Cheat -- peek at the item */
4163 if (cheat_peek) object_mention(o_ptr);
4171 switch (o_ptr->tval)
4180 if (power) a_m_aux_1(o_ptr, lev, power);
4186 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4192 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4206 /* Elven Cloak and Black Clothes ... */
4207 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4208 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4209 o_ptr->pval = randint1(4);
4213 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4214 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4215 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4216 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4217 a_m_aux_2(o_ptr, lev, power);
4219 if (power) a_m_aux_2(o_ptr, lev, power);
4227 if (!power && (randint0(100) < 50)) power = -1;
4228 a_m_aux_3(o_ptr, lev, power);
4234 a_m_aux_4(o_ptr, lev, power);
4239 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4240 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4241 (p_ptr->pseikaku == SEIKAKU_SEXY))
4244 o_ptr->art_flags1 |= (TR1_STR | TR1_INT | TR1_WIS | TR1_DEX | TR1_CON | TR1_CHR);
4247 if (o_ptr->art_name) rating += 30;
4249 /* Hack -- analyze ego-items */
4250 else if (o_ptr->name2)
4252 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4254 /* Hack -- extra powers */
4255 switch (o_ptr->name2)
4257 /* Weapon (Holy Avenger) */
4260 o_ptr->xtra1 = EGO_XTRA_SUSTAIN;
4264 /* Weapon (Defender) */
4267 o_ptr->xtra1 = EGO_XTRA_SUSTAIN;
4271 /* Weapon (Blessed) */
4272 case EGO_BLESS_BLADE:
4274 o_ptr->xtra1 = EGO_XTRA_ABILITY;
4281 if (one_in_(7)) o_ptr->xtra1 = EGO_XTRA_ABILITY;
4285 /* Robe of Permanance */
4286 case EGO_PERMANENCE:
4288 o_ptr->xtra1 = EGO_XTRA_POWER;
4292 /* Armor of Elvenkind */
4295 o_ptr->xtra1 = EGO_XTRA_POWER;
4299 /* Crown of the Magi */
4302 o_ptr->xtra1 = EGO_XTRA_ABILITY;
4309 o_ptr->xtra1 = EGO_XTRA_POWER;
4314 /* Randomize the "xtra" power */
4315 if (o_ptr->xtra1 && !o_ptr->art_name)
4316 o_ptr->xtra2 = randint1(256);
4318 /* Hack -- acquire "broken" flag */
4319 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4321 /* Hack -- acquire "cursed" flag */
4322 if (e_ptr->flags3 & (TR3_CURSED)) o_ptr->ident |= (IDENT_CURSED);
4324 /* Hack -- apply extra penalties if needed */
4325 if (cursed_p(o_ptr) || broken_p(o_ptr))
4327 /* Hack -- obtain bonuses */
4328 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4329 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4330 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4332 /* Hack -- obtain pval */
4333 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4336 /* Hack -- apply extra bonuses if needed */
4339 /* Hack -- obtain bonuses */
4340 if (e_ptr->max_to_h)
4342 if (e_ptr->max_to_h > 127)
4343 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4344 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4346 if (e_ptr->max_to_d)
4348 if (e_ptr->max_to_d > 127)
4349 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4350 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4352 if (e_ptr->max_to_a)
4354 if (e_ptr->max_to_a > 127)
4355 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4356 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4359 /* Hack -- obtain pval */
4360 if (e_ptr->max_pval)
4362 if ((o_ptr->name2 == EGO_HA) && (o_ptr->art_flags1 & TR1_BLOWS))
4365 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4367 else if (o_ptr->name2 == EGO_ATTACKS)
4369 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4370 if (o_ptr->pval > 3) o_ptr->pval = 3;
4371 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4372 o_ptr->pval += randint1(2);
4374 else if (o_ptr->name2 == EGO_BAT)
4376 o_ptr->pval = randint1(e_ptr->max_pval);
4377 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4381 o_ptr->pval += randint1(e_ptr->max_pval);
4384 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4386 o_ptr->pval = randint1(o_ptr->pval);
4388 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4392 /* Hack -- apply rating bonus */
4393 rating += e_ptr->rating;
4395 /* Cheat -- describe the item */
4396 if (cheat_peek) object_mention(o_ptr);
4402 /* Examine real objects */
4405 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4407 /* Hack -- acquire "broken" flag */
4408 if (!get_object_cost(o_ptr)) o_ptr->ident |= (IDENT_BROKEN);
4410 /* Hack -- acquire "cursed" flag */
4411 if (k_ptr->flags3 & (TR3_CURSED)) o_ptr->ident |= (IDENT_CURSED);
4417 * Hack -- determine if a template is "good"
4419 static bool kind_is_good(int k_idx)
4421 object_kind *k_ptr = &k_info[k_idx];
4423 /* Analyze the item type */
4424 switch (k_ptr->tval)
4426 /* Armor -- Good unless damaged */
4437 if (k_ptr->to_a < 0) return (FALSE);
4441 /* Weapons -- Good unless damaged */
4448 if (k_ptr->to_h < 0) return (FALSE);
4449 if (k_ptr->to_d < 0) return (FALSE);
4453 /* Ammo -- Arrows/Bolts are good */
4460 /* Books -- High level books are good (except Arcane books) */
4462 case TV_SORCERY_BOOK:
4463 case TV_NATURE_BOOK:
4467 case TV_ENCHANT_BOOK:
4468 case TV_DAEMON_BOOK:
4470 case TV_HISSATSU_BOOK:
4472 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4476 /* Rings -- Rings of Speed are good */
4479 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4480 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4484 /* Amulets -- Amulets of the Magi and Resistance are good */
4487 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4488 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4493 /* Assume not good */
4499 * Attempt to make an object (normal or good/great)
4501 * This routine plays nasty games to generate the "special artifacts".
4503 * This routine uses "object_level" for the "generation level".
4505 * We assume that the given object has been "wiped".
4507 bool make_object(object_type *j_ptr, bool good, bool great)
4513 /* Chance of "special object" */
4514 prob = (good ? 10 : 1000);
4516 /* Base level for the object */
4517 base = (good ? (object_level + 10) : object_level);
4520 /* Generate a special object, or a normal object */
4521 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4528 /* Activate restriction */
4529 get_obj_num_hook = kind_is_good;
4531 /* Prepare allocation table */
4535 /* Pick a random object */
4536 k_idx = get_obj_num(base);
4539 if (get_obj_num_hook)
4541 /* Clear restriction */
4542 get_obj_num_hook = NULL;
4544 /* Prepare allocation table */
4548 /* Handle failure */
4549 if (!k_idx) return (FALSE);
4551 /* Prepare the object */
4552 object_prep(j_ptr, k_idx);
4555 /* Apply magic (allow artifacts) */
4556 apply_magic(j_ptr, object_level, TRUE, good, great, FALSE);
4558 /* Hack -- generate multiple spikes/missiles */
4559 switch (j_ptr->tval)
4567 j_ptr->number = (byte)damroll(6, 7);
4571 obj_level = get_object_level(j_ptr);
4572 if (artifact_p(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4574 /* Notice "okay" out-of-depth objects */
4575 if (!cursed_p(j_ptr) && !broken_p(j_ptr) &&
4576 (obj_level > dun_level))
4578 /* Rating increase */
4579 rating += (obj_level - dun_level);
4581 /* Cheat -- peek at items */
4582 if (cheat_peek) object_mention(j_ptr);
4591 * Attempt to place an object (normal or good/great) at the given location.
4593 * This routine plays nasty games to generate the "special artifacts".
4595 * This routine uses "object_level" for the "generation level".
4597 * This routine requires a clean floor grid destination.
4599 void place_object(int y, int x, bool good, bool great)
4609 /* Paranoia -- check bounds */
4610 if (!in_bounds(y, x)) return;
4612 /* Require clean floor space */
4613 if (!cave_clean_bold(y, x)) return;
4616 /* Get local object */
4619 /* Wipe the object */
4622 /* Make an object (if possible) */
4623 if (!make_object(q_ptr, good, great)) return;
4626 /* Make an object */
4634 /* Acquire object */
4635 o_ptr = &o_list[o_idx];
4637 /* Structure Copy */
4638 object_copy(o_ptr, q_ptr);
4645 c_ptr = &cave[y][x];
4648 o_ptr->next_o_idx = c_ptr->o_idx;
4650 /* Place the object */
4651 c_ptr->o_idx = o_idx;
4661 /* Hack -- Preserve artifacts */
4664 a_info[q_ptr->name1].cur_num = 0;
4671 * Make a treasure object
4673 * The location must be a legal, clean, floor grid.
4675 bool make_gold(object_type *j_ptr)
4682 /* Hack -- Pick a Treasure variety */
4683 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4685 /* Apply "extra" magic */
4686 if (one_in_(GREAT_OBJ))
4688 i += randint1(object_level + 1);
4691 /* Hack -- Creeping Coins only generate "themselves" */
4692 if (coin_type) i = coin_type;
4694 /* Do not create "illegal" Treasure Types */
4695 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4697 /* Prepare a gold object */
4698 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4700 /* Hack -- Base coin cost */
4701 base = k_info[OBJ_GOLD_LIST+i].cost;
4703 /* Determine how much the treasure is "worth" */
4704 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
4712 * Places a treasure (Gold or Gems) at given location
4714 * The location must be a legal, clean, floor grid.
4716 void place_gold(int y, int x)
4726 /* Paranoia -- check bounds */
4727 if (!in_bounds(y, x)) return;
4729 /* Require clean floor space */
4730 if (!cave_clean_bold(y, x)) return;
4733 /* Get local object */
4736 /* Wipe the object */
4739 /* Make some gold */
4740 if (!make_gold(q_ptr)) return;
4743 /* Make an object */
4751 /* Acquire object */
4752 o_ptr = &o_list[o_idx];
4754 /* Copy the object */
4755 object_copy(o_ptr, q_ptr);
4762 c_ptr = &cave[y][x];
4765 o_ptr->next_o_idx = c_ptr->o_idx;
4767 /* Place the object */
4768 c_ptr->o_idx = o_idx;
4780 * Let an object fall to the ground at or near a location.
4782 * The initial location is assumed to be "in_bounds()".
4784 * This function takes a parameter "chance". This is the percentage
4785 * chance that the item will "disappear" instead of drop. If the object
4786 * has been thrown, then this is the chance of disappearance on contact.
4788 * Hack -- this function uses "chance" to determine if it should produce
4789 * some form of "description" of the drop event (under the player).
4791 * We check several locations to see if we can find a location at which
4792 * the object can combine, stack, or be placed. Artifacts will try very
4793 * hard to be placed, including "teleporting" to a useful grid if needed.
4795 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
4806 s16b this_o_idx, next_o_idx = 0;
4810 char o_name[MAX_NLEN];
4815 bool plural = FALSE;
4818 /* Extract plural */
4819 if (j_ptr->number != 1) plural = TRUE;
4821 /* Describe object */
4822 object_desc(o_name, j_ptr, FALSE, 0);
4825 /* Handle normal "breakage" */
4826 if (!(j_ptr->art_name || artifact_p(j_ptr)) && (randint0(100) < chance))
4830 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
4832 msg_format("The %s disappear%s.",
4833 o_name, (plural ? "" : "s"));
4839 if (wizard) msg_print("(ÇË»)");
4841 if (wizard) msg_print("(breakage)");
4860 /* Scan local grids */
4861 for (dy = -3; dy <= 3; dy++)
4863 /* Scan local grids */
4864 for (dx = -3; dx <= 3; dx++)
4868 /* Calculate actual distance */
4869 d = (dy * dy) + (dx * dx);
4871 /* Ignore distant grids */
4872 if (d > 10) continue;
4878 /* Skip illegal grids */
4879 if (!in_bounds(ty, tx)) continue;
4881 /* Require line of sight */
4882 if (!los(y, x, ty, tx)) continue;
4885 c_ptr = &cave[ty][tx];
4887 /* Require floor space */
4888 if ((c_ptr->feat != FEAT_FLOOR) &&
4889 (c_ptr->feat != FEAT_SHAL_WATER) &&
4890 (c_ptr->feat != FEAT_GRASS) &&
4891 (c_ptr->feat != FEAT_DIRT) &&
4892 (c_ptr->feat != FEAT_FLOWER) &&
4893 (c_ptr->feat != FEAT_DEEP_GRASS) &&
4894 (c_ptr->feat != FEAT_SHAL_LAVA) &&
4895 (c_ptr->feat != FEAT_TREES)) continue;
4897 if (c_ptr->info & CAVE_TRAP) continue;
4902 /* Scan objects in that grid */
4903 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
4907 /* Acquire object */
4908 o_ptr = &o_list[this_o_idx];
4910 /* Acquire next object */
4911 next_o_idx = o_ptr->next_o_idx;
4913 /* Check for possible combination */
4914 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
4920 /* Add new object */
4924 if (k > 99) continue;
4926 /* Calculate score */
4927 s = 1000 - (d + k * 5);
4929 /* Skip bad values */
4930 if (s < bs) continue;
4932 /* New best value */
4935 /* Apply the randomizer to equivalent values */
4936 if ((++bn >= 2) && !one_in_(bn)) continue;
4951 /* Handle lack of space */
4952 if (!flag && !(artifact_p(j_ptr) || j_ptr->art_name))
4956 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
4958 msg_format("The %s disappear%s.",
4959 o_name, (plural ? "" : "s"));
4965 if (wizard) msg_print("(¾²¥¹¥Ú¡¼¥¹¤¬¤Ê¤¤)");
4967 if (wizard) msg_print("(no floor space)");
4977 for (i = 0; !flag; i++)
4982 ty = rand_spread(by, 1);
4983 tx = rand_spread(bx, 1);
4986 /* Random locations */
4989 ty = randint0(cur_hgt);
4990 tx = randint0(cur_wid);
4994 c_ptr = &cave[ty][tx];
4996 /* Require floor space (or shallow terrain) -KMW- */
4997 if ((c_ptr->feat != FEAT_FLOOR) &&
4998 (c_ptr->feat != FEAT_SHAL_WATER) &&
4999 (c_ptr->feat != FEAT_GRASS) &&
5000 (c_ptr->feat != FEAT_DIRT) &&
5001 (c_ptr->feat != FEAT_SHAL_LAVA)) continue;
5003 /* Bounce to that location */
5007 /* Require floor space */
5008 if (!cave_clean_bold(by, bx)) continue;
5016 c_ptr = &cave[by][bx];
5018 /* Scan objects in that grid for combination */
5019 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5023 /* Acquire object */
5024 o_ptr = &o_list[this_o_idx];
5026 /* Acquire next object */
5027 next_o_idx = o_ptr->next_o_idx;
5029 /* Check for combination */
5030 if (object_similar(o_ptr, j_ptr))
5032 /* Combine the items */
5033 object_absorb(o_ptr, j_ptr);
5043 /* Get new object */
5044 if (!done) o_idx = o_pop();
5047 if (!done && !o_idx)
5051 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5053 msg_format("The %s disappear%s.",
5054 o_name, (plural ? "" : "s"));
5060 if (wizard) msg_print("(¥¢¥¤¥Æ¥à¤¬Â¿²á¤®¤ë)");
5062 if (wizard) msg_print("(too many objects)");
5066 /* Hack -- Preserve artifacts */
5069 a_info[j_ptr->name1].cur_num = 0;
5079 /* Structure copy */
5080 object_copy(&o_list[o_idx], j_ptr);
5082 /* Access new object */
5083 j_ptr = &o_list[o_idx];
5090 j_ptr->held_m_idx = 0;
5093 j_ptr->next_o_idx = c_ptr->o_idx;
5095 /* Place the object */
5096 c_ptr->o_idx = o_idx;
5111 /* Mega-Hack -- no message if "dropped" by player */
5112 /* Message when an object falls under the player */
5113 if (chance && (by == py) && (bx == px))
5116 msg_print("²¿¤«¤¬Â²¼¤Ëž¤¬¤Ã¤Æ¤¤¿¡£");
5118 msg_print("You feel something roll beneath your feet.");
5131 * Scatter some "great" objects near the player
5133 void acquirement(int y1, int x1, int num, bool great, bool known)
5136 object_type object_type_body;
5141 /* Get local object */
5142 i_ptr = &object_type_body;
5144 /* Wipe the object */
5147 /* Make a good (or great) object (if possible) */
5148 if (!make_object(i_ptr, TRUE, great)) continue;
5152 object_aware(i_ptr);
5153 object_known(i_ptr);
5156 /* Drop the object */
5157 (void)drop_near(i_ptr, -1, y1, x1);
5162 #define MAX_TRAPS 17
5164 static int trap_num[MAX_TRAPS] =
5168 FEAT_TRAP_SPIKED_PIT,
5169 FEAT_TRAP_POISON_PIT,
5187 * Hack -- instantiate a trap
5189 * XXX XXX XXX This routine should be redone to reflect trap "level".
5190 * That is, it does not make sense to have spiked pits at 50 feet.
5191 * Actually, it is not this routine, but the "trap instantiation"
5192 * code, which should also check for "trap doors" on quest levels.
5194 void pick_trap(int y, int x)
5198 cave_type *c_ptr = &cave[y][x];
5201 if (!(c_ptr->info & CAVE_TRAP)) return;
5202 c_ptr->info &= ~(CAVE_TRAP);
5207 /* Hack -- pick a trap */
5208 feat = trap_num[randint0(MAX_TRAPS)];
5210 /* Accept non-trapdoors */
5211 if (feat != FEAT_TRAP_TRAPDOOR) break;
5213 /* Hack -- no trap doors on special levels */
5214 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5216 /* Hack -- no trap doors on the deepest level */
5217 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5222 /* Activate the trap */
5223 cave_set_feat(y, x, feat);
5228 * Places a random trap at the given location.
5230 * The location must be a legal, naked, floor grid.
5232 * Note that all traps start out as "invisible" and "untyped", and then
5233 * when they are "discovered" (by detecting them or setting them off),
5234 * the trap is "instantiated" as a visible, "typed", trap.
5236 void place_trap(int y, int x)
5238 /* Paranoia -- verify location */
5239 if (!in_bounds(y, x)) return;
5241 /* Require empty, clean, floor grid */
5242 if (!cave_naked_bold(y, x)) return;
5244 /* Place an invisible trap */
5245 cave[y][x].info |= CAVE_TRAP;
5250 * Describe the charges on an item in the inventory.
5252 void inven_item_charges(int item)
5254 object_type *o_ptr = &inventory[item];
5256 /* Require staff/wand */
5257 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5259 /* Require known item */
5260 if (!object_known_p(o_ptr)) return;
5263 if (o_ptr->pval <= 0)
5265 msg_print("¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
5269 msg_format("¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
5272 /* Multiple charges */
5273 if (o_ptr->pval != 1)
5275 /* Print a message */
5276 msg_format("You have %d charges remaining.", o_ptr->pval);
5282 /* Print a message */
5283 msg_format("You have %d charge remaining.", o_ptr->pval);
5291 * Describe an item in the inventory.
5293 void inven_item_describe(int item)
5295 object_type *o_ptr = &inventory[item];
5296 char o_name[MAX_NLEN];
5298 /* Get a description */
5299 object_desc(o_name, o_ptr, TRUE, 3);
5301 /* Print a message */
5303 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤¹¤ë */
5304 if (o_ptr->number <= 0)
5306 /*FIRST*//*¤³¤³¤Ï¤â¤¦Ä̤é¤Ê¤¤¤«¤â */
5307 msg_format("¤â¤¦%s¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£", o_name);
5311 /* ¥¢¥¤¥Æ¥à̾¤ò±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½Âбþ */
5312 msg_format("¤Þ¤À %s¤ò»ý¤Ã¤Æ¤¤¤ë¡£", o_name);
5315 msg_format("You have %s.", o_name);
5322 * Increase the "number" of an item in the inventory
5324 void inven_item_increase(int item, int num)
5326 object_type *o_ptr = &inventory[item];
5329 num += o_ptr->number;
5332 if (num > 255) num = 255;
5333 else if (num < 0) num = 0;
5336 num -= o_ptr->number;
5338 /* Change the number and weight */
5341 /* Add the number */
5342 o_ptr->number += num;
5344 /* Add the weight */
5345 p_ptr->total_weight += (num * o_ptr->weight);
5347 /* Recalculate bonuses */
5348 p_ptr->update |= (PU_BONUS);
5350 /* Recalculate mana XXX */
5351 p_ptr->update |= (PU_MANA);
5353 /* Combine the pack */
5354 p_ptr->notice |= (PN_COMBINE);
5357 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5363 * Erase an inventory slot if it has no more items
5365 void inven_item_optimize(int item)
5367 object_type *o_ptr = &inventory[item];
5369 /* Only optimize real items */
5370 if (!o_ptr->k_idx) return;
5372 /* Only optimize empty items */
5373 if (o_ptr->number) return;
5375 /* The item is in the pack */
5376 if (item < INVEN_RARM)
5383 /* Slide everything down */
5384 for (i = item; i < INVEN_PACK; i++)
5386 /* Structure copy */
5387 inventory[i] = inventory[i+1];
5390 /* Erase the "final" slot */
5391 object_wipe(&inventory[i]);
5394 p_ptr->window |= (PW_INVEN);
5397 /* The item is being wielded */
5403 /* Erase the empty slot */
5404 object_wipe(&inventory[item]);
5406 /* Recalculate bonuses */
5407 p_ptr->update |= (PU_BONUS);
5409 /* Recalculate torch */
5410 p_ptr->update |= (PU_TORCH);
5412 /* Recalculate mana XXX */
5413 p_ptr->update |= (PU_MANA);
5416 p_ptr->window |= (PW_EQUIP);
5420 p_ptr->window |= (PW_SPELL);
5425 * Describe the charges on an item on the floor.
5427 void floor_item_charges(int item)
5429 object_type *o_ptr = &o_list[item];
5431 /* Require staff/wand */
5432 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5434 /* Require known item */
5435 if (!object_known_p(o_ptr)) return;
5438 if (o_ptr->pval <= 0)
5440 msg_print("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
5444 msg_format("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
5447 /* Multiple charges */
5448 if (o_ptr->pval != 1)
5450 /* Print a message */
5451 msg_format("There are %d charges remaining.", o_ptr->pval);
5457 /* Print a message */
5458 msg_format("There is %d charge remaining.", o_ptr->pval);
5466 * Describe an item in the inventory.
5468 void floor_item_describe(int item)
5470 object_type *o_ptr = &o_list[item];
5471 char o_name[MAX_NLEN];
5473 /* Get a description */
5474 object_desc(o_name, o_ptr, TRUE, 3);
5476 /* Print a message */
5478 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤òʬ¤±¤ë */
5479 if (o_ptr->number <= 0)
5481 msg_format("¾²¾å¤Ë¤Ï¡¢¤â¤¦%s¤Ï¤Ê¤¤¡£", o_name);
5485 msg_format("¾²¾å¤Ë¤Ï¡¢¤Þ¤À %s¤¬¤¢¤ë¡£", o_name);
5488 msg_format("You see %s.", o_name);
5495 * Increase the "number" of an item on the floor
5497 void floor_item_increase(int item, int num)
5499 object_type *o_ptr = &o_list[item];
5502 num += o_ptr->number;
5505 if (num > 255) num = 255;
5506 else if (num < 0) num = 0;
5509 num -= o_ptr->number;
5511 /* Change the number */
5512 o_ptr->number += num;
5517 * Optimize an item on the floor (destroy "empty" items)
5519 void floor_item_optimize(int item)
5521 object_type *o_ptr = &o_list[item];
5523 /* Paranoia -- be sure it exists */
5524 if (!o_ptr->k_idx) return;
5526 /* Only optimize empty items */
5527 if (o_ptr->number) return;
5529 /* Delete the object */
5530 delete_object_idx(item);
5535 * Check if we have space for an item in the pack without overflow
5537 bool inven_carry_okay(object_type *o_ptr)
5542 if (inven_cnt < INVEN_PACK) return (TRUE);
5545 for (j = 0; j < INVEN_PACK; j++)
5547 object_type *j_ptr = &inventory[j];
5549 /* Skip non-objects */
5550 if (!j_ptr->k_idx) continue;
5552 /* Check if the two items can be combined */
5553 if (object_similar(j_ptr, o_ptr)) return (TRUE);
5562 * Add an item to the players inventory, and return the slot used.
5564 * If the new item can combine with an existing item in the inventory,
5565 * it will do so, using "object_similar()" and "object_absorb()", else,
5566 * the item will be placed into the "proper" location in the inventory.
5568 * This function can be used to "over-fill" the player's pack, but only
5569 * once, and such an action must trigger the "overflow" code immediately.
5570 * Note that when the pack is being "over-filled", the new item must be
5571 * placed into the "overflow" slot, and the "overflow" must take place
5572 * before the pack is reordered, but (optionally) after the pack is
5573 * combined. This may be tricky. See "dungeon.c" for info.
5575 * Note that this code must remove any location/stack information
5576 * from the object once it is placed into the inventory.
5578 s16b inven_carry(object_type *o_ptr)
5586 /* Check for combining */
5587 for (j = 0; j < INVEN_PACK; j++)
5589 j_ptr = &inventory[j];
5591 /* Skip non-objects */
5592 if (!j_ptr->k_idx) continue;
5594 /* Hack -- track last item */
5597 /* Check if the two items can be combined */
5598 if (object_similar(j_ptr, o_ptr))
5600 /* Combine the items */
5601 object_absorb(j_ptr, o_ptr);
5603 /* Increase the weight */
5604 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
5606 /* Recalculate bonuses */
5607 p_ptr->update |= (PU_BONUS);
5610 p_ptr->window |= (PW_INVEN);
5619 if (inven_cnt > INVEN_PACK) return (-1);
5621 /* Find an empty slot */
5622 for (j = 0; j <= INVEN_PACK; j++)
5624 j_ptr = &inventory[j];
5626 /* Use it if found */
5627 if (!j_ptr->k_idx) break;
5634 /* Reorder the pack */
5637 s32b o_value, j_value;
5639 /* Get the "value" of the item */
5640 o_value = object_value(o_ptr);
5642 /* Scan every occupied slot */
5643 for (j = 0; j < INVEN_PACK; j++)
5645 j_ptr = &inventory[j];
5647 /* Use empty slots */
5648 if (!j_ptr->k_idx) break;
5650 /* Hack -- readable books always come first */
5651 if ((o_ptr->tval == REALM1_BOOK) &&
5652 (j_ptr->tval != REALM1_BOOK)) break;
5653 if ((j_ptr->tval == REALM1_BOOK) &&
5654 (o_ptr->tval != REALM1_BOOK)) continue;
5656 if ((o_ptr->tval == REALM2_BOOK) &&
5657 (j_ptr->tval != REALM2_BOOK)) break;
5658 if ((j_ptr->tval == REALM2_BOOK) &&
5659 (o_ptr->tval != REALM2_BOOK)) continue;
5661 /* Objects sort by decreasing type */
5662 if (o_ptr->tval > j_ptr->tval) break;
5663 if (o_ptr->tval < j_ptr->tval) continue;
5665 /* Non-aware (flavored) items always come last */
5666 if (!object_aware_p(o_ptr)) continue;
5667 if (!object_aware_p(j_ptr)) break;
5669 /* Objects sort by increasing sval */
5670 if (o_ptr->sval < j_ptr->sval) break;
5671 if (o_ptr->sval > j_ptr->sval) continue;
5673 /* Unidentified objects always come last */
5674 if (!object_known_p(o_ptr)) continue;
5675 if (!object_known_p(j_ptr)) break;
5677 /* Hack: otherwise identical rods sort by
5678 increasing recharge time --dsb */
5679 if (o_ptr->tval == TV_ROD)
5681 if (o_ptr->pval < j_ptr->pval) break;
5682 if (o_ptr->pval > j_ptr->pval) continue;
5685 /* Determine the "value" of the pack item */
5686 j_value = object_value(j_ptr);
5688 /* Objects sort by decreasing value */
5689 if (o_value > j_value) break;
5690 if (o_value < j_value) continue;
5697 for (k = n; k >= i; k--)
5699 /* Hack -- Slide the item */
5700 object_copy(&inventory[k+1], &inventory[k]);
5703 /* Wipe the empty slot */
5704 object_wipe(&inventory[i]);
5709 object_copy(&inventory[i], o_ptr);
5711 /* Access new object */
5712 j_ptr = &inventory[i];
5715 j_ptr->next_o_idx = 0;
5717 /* Forget monster */
5718 j_ptr->held_m_idx = 0;
5720 /* Forget location */
5721 j_ptr->iy = j_ptr->ix = 0;
5723 /* No longer marked */
5724 j_ptr->marked = FALSE;
5726 /* Increase the weight */
5727 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
5729 /* Count the items */
5732 /* Recalculate bonuses */
5733 p_ptr->update |= (PU_BONUS);
5735 /* Combine and Reorder pack */
5736 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5739 p_ptr->window |= (PW_INVEN);
5741 /* Return the slot */
5747 * Take off (some of) a non-cursed equipment item
5749 * Note that only one item at a time can be wielded per slot.
5751 * Note that taking off an item when "full" may cause that item
5752 * to fall to the ground.
5754 * Return the inventory slot into which the item is placed.
5756 s16b inven_takeoff(int item, int amt)
5767 char o_name[MAX_NLEN];
5770 /* Get the item to take off */
5771 o_ptr = &inventory[item];
5774 if (amt <= 0) return (-1);
5777 if (amt > o_ptr->number) amt = o_ptr->number;
5779 /* Get local object */
5782 /* Obtain a local object */
5783 object_copy(q_ptr, o_ptr);
5785 /* Modify quantity */
5786 q_ptr->number = amt;
5788 /* Describe the object */
5789 object_desc(o_name, q_ptr, TRUE, 3);
5791 /* Took off weapon */
5792 if (item == INVEN_RARM)
5795 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
5797 act = "You were wielding";
5803 else if (item == INVEN_BOW)
5806 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
5808 act = "You were holding";
5813 /* Took off light */
5814 else if (item == INVEN_LITE)
5817 act = "¤ò¸÷¸»¤«¤é¤Ï¤º¤·¤¿";
5819 act = "You were holding";
5824 /* Took off something */
5828 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
5830 act = "You were wearing";
5835 /* Modify, Optimize */
5836 inven_item_increase(item, -amt);
5837 inven_item_optimize(item);
5839 /* Carry the object */
5840 slot = inven_carry(q_ptr);
5844 msg_format("%s(%c)%s¡£", o_name, index_to_label(slot), act);
5846 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
5856 * Drop (some of) a non-cursed inventory/equipment item
5858 * The object will be dropped "near" the current location
5860 void inven_drop(int item, int amt)
5867 char o_name[MAX_NLEN];
5870 /* Access original object */
5871 o_ptr = &inventory[item];
5874 if (amt <= 0) return;
5877 if (amt > o_ptr->number) amt = o_ptr->number;
5880 /* Take off equipment */
5881 if (item >= INVEN_RARM)
5883 /* Take off first */
5884 item = inven_takeoff(item, amt);
5886 /* Access original object */
5887 o_ptr = &inventory[item];
5891 /* Get local object */
5894 /* Obtain local object */
5895 object_copy(q_ptr, o_ptr);
5897 /* Distribute charges of wands or rods */
5898 distribute_charges(o_ptr, q_ptr, amt);
5900 /* Modify quantity */
5901 q_ptr->number = amt;
5903 /* Describe local object */
5904 object_desc(o_name, q_ptr, TRUE, 3);
5908 msg_format("%s(%c)¤òÍî¤È¤·¤¿¡£", o_name, index_to_label(item));
5910 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5914 /* Drop it near the player */
5915 (void)drop_near(q_ptr, 0, py, px);
5917 /* Modify, Describe, Optimize */
5918 inven_item_increase(item, -amt);
5919 inven_item_describe(item);
5920 inven_item_optimize(item);
5925 * Combine items in the pack
5927 * Note special handling of the "overflow" slot
5929 void combine_pack(void)
5937 /* Combine the pack (backwards) */
5938 for (i = INVEN_PACK; i > 0; i--)
5941 o_ptr = &inventory[i];
5943 /* Skip empty items */
5944 if (!o_ptr->k_idx) continue;
5946 /* Scan the items above that item */
5947 for (j = 0; j < i; j++)
5950 j_ptr = &inventory[j];
5952 /* Skip empty items */
5953 if (!j_ptr->k_idx) continue;
5955 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
5956 if (object_similar_part(j_ptr, o_ptr)
5957 && j_ptr->number < MAX_STACK_SIZE-1)
5959 if (o_ptr->number + j_ptr->number < MAX_STACK_SIZE)
5964 /* Add together the item counts */
5965 object_absorb(j_ptr, o_ptr);
5967 /* One object is gone */
5970 /* Slide everything down */
5971 for (k = i; k < INVEN_PACK; k++)
5973 /* Structure copy */
5974 inventory[k] = inventory[k+1];
5977 /* Erase the "final" slot */
5978 object_wipe(&inventory[k]);
5982 int remain = j_ptr->number + o_ptr->number - 99;
5984 o_ptr->number -= remain;
5986 /* Add together the item counts */
5987 object_absorb(j_ptr, o_ptr);
5989 o_ptr->number = remain;
5993 p_ptr->window |= (PW_INVEN);
6003 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤ò¤Þ¤È¤áľ¤·¤¿¡£");
6005 if (flag) msg_print("You combine some items in your pack.");
6012 * Reorder items in the pack
6014 * Note special handling of the "overflow" slot
6016 void reorder_pack(void)
6028 /* Re-order the pack (forwards) */
6029 for (i = 0; i < INVEN_PACK; i++)
6031 /* Mega-Hack -- allow "proper" over-flow */
6032 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6035 o_ptr = &inventory[i];
6037 /* Skip empty slots */
6038 if (!o_ptr->k_idx) continue;
6040 /* Get the "value" of the item */
6041 o_value = object_value(o_ptr);
6043 /* Scan every occupied slot */
6044 for (j = 0; j < INVEN_PACK; j++)
6046 /* Get the item already there */
6047 j_ptr = &inventory[j];
6049 /* Use empty slots */
6050 if (!j_ptr->k_idx) break;
6052 /* Hack -- readable books always come first */
6053 if ((o_ptr->tval == REALM1_BOOK) &&
6054 (j_ptr->tval != REALM1_BOOK)) break;
6055 if ((j_ptr->tval == REALM1_BOOK) &&
6056 (o_ptr->tval != REALM1_BOOK)) continue;
6058 if ((o_ptr->tval == REALM2_BOOK) &&
6059 (j_ptr->tval != REALM2_BOOK)) break;
6060 if ((j_ptr->tval == REALM2_BOOK) &&
6061 (o_ptr->tval != REALM2_BOOK)) continue;
6063 /* Objects sort by decreasing type */
6064 if (o_ptr->tval > j_ptr->tval) break;
6065 if (o_ptr->tval < j_ptr->tval) continue;
6067 /* Non-aware (flavored) items always come last */
6068 if (!object_aware_p(o_ptr)) continue;
6069 if (!object_aware_p(j_ptr)) break;
6071 /* Objects sort by increasing sval */
6072 if (o_ptr->sval < j_ptr->sval) break;
6073 if (o_ptr->sval > j_ptr->sval) continue;
6075 /* Unidentified objects always come last */
6076 if (!object_known_p(o_ptr)) continue;
6077 if (!object_known_p(j_ptr)) break;
6079 /* Hack: otherwise identical rods sort by
6080 increasing recharge time --dsb */
6081 if (o_ptr->tval == TV_ROD)
6083 if (o_ptr->pval < j_ptr->pval) break;
6084 if (o_ptr->pval > j_ptr->pval) continue;
6087 /* Determine the "value" of the pack item */
6088 j_value = object_value(j_ptr);
6092 /* Objects sort by decreasing value */
6093 if (o_value > j_value) break;
6094 if (o_value < j_value) continue;
6097 /* Never move down */
6098 if (j >= i) continue;
6103 /* Get local object */
6106 /* Save a copy of the moving item */
6107 object_copy(q_ptr, &inventory[i]);
6109 /* Slide the objects */
6110 for (k = i; k > j; k--)
6112 /* Slide the item */
6113 object_copy(&inventory[k], &inventory[k-1]);
6116 /* Insert the moving item */
6117 object_copy(&inventory[j], q_ptr);
6120 p_ptr->window |= (PW_INVEN);
6125 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤òÊ¤Ùľ¤·¤¿¡£");
6127 if (flag) msg_print("You reorder some items in your pack.");
6134 * Hack -- display an object kind in the current window
6136 * Include list of usable spells for readible books
6138 void display_koff(int k_idx)
6145 char o_name[MAX_NLEN];
6148 /* Erase the window */
6149 for (y = 0; y < Term->hgt; y++)
6151 /* Erase the line */
6152 Term_erase(0, y, 255);
6158 /* Get local object */
6161 /* Prepare the object */
6162 object_prep(q_ptr, k_idx);
6165 object_desc_store(o_name, q_ptr, FALSE, 0);
6167 /* Mention the object name */
6168 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6170 /* Warriors are illiterate */
6171 if (!(p_ptr->realm1 || p_ptr->realm2)) return;
6173 /* Display spells in readible books */
6174 if ((q_ptr->tval == REALM1_BOOK) ||
6175 (q_ptr->tval == REALM2_BOOK))
6183 /* Access the item's sval */
6186 /* Extract spells */
6187 for (spell = 0; spell < 32; spell++)
6189 /* Check for this spell */
6190 if (fake_spell_flags[sval] & (1L << spell))
6192 /* Collect this spell */
6193 spells[num++] = spell;
6198 print_spells(0, spells, num, 2, 0,
6199 (q_ptr->tval == REALM1_BOOK ? p_ptr->realm1 - 1 : p_ptr->realm2 - 1));
6203 /* Choose one of items that have warning flag */
6204 object_type *choose_warning_item(void)
6207 int choices[INVEN_TOTAL-INVEN_RARM];
6210 /* Paranoia -- Player has no warning-item */
6211 if (!p_ptr->warning) return (NULL);
6213 /* Search Inventry */
6214 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6217 object_type *o_ptr = &inventory[i];
6219 object_flags(o_ptr, &f1, &f2, &f3);
6220 if (f3 & (TR3_WARNING))
6222 choices[number] = i;
6227 /* Choice one of them */
6228 return (&inventory[choices[randint0(number)]]);
6231 /* Examine the grid (xx,yy) and warn the player if there are any danger */
6232 bool process_frakir(int xx, int yy)
6236 char o_name[MAX_NLEN];
6238 #define FRAKIR_AWARE_RANGE 12
6240 static int old_damage = 0;
6242 for (mx = xx-FRAKIR_AWARE_RANGE; mx < xx+FRAKIR_AWARE_RANGE+1; mx++)
6244 for (my = yy-FRAKIR_AWARE_RANGE; my < yy+FRAKIR_AWARE_RANGE+1; my++)
6247 monster_type *m_ptr;
6248 monster_race *r_ptr;
6252 if (!in_bounds(my,mx) || (distance(my,mx,yy,xx)>FRAKIR_AWARE_RANGE)) continue;
6254 c_ptr = &cave[my][mx];
6256 if (!c_ptr->m_idx) continue;
6258 m_ptr = &m_list[c_ptr->m_idx];
6259 r_ptr = &r_info[m_ptr->r_idx];
6265 rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
6267 if (m_ptr->csleep) continue;
6268 if (is_pet(m_ptr)) continue;
6270 /* Monster spells (only powerful ones)*/
6271 if(projectable(my,mx,yy,xx))
6274 #define DAMCALC(f,val,max,im,vln,res,resx,resy,op,opx,opy,dmax) \
6275 if (f){ int dam = (val)>(max)? (max):(val); \
6277 if (vln) dam *= 2; \
6278 if (res) {dam = (dam * resx) / resy;} \
6279 if (op) {dam = (dam * opx) / opy;} \
6280 if (dam>dmax) dmax = dam; \
6283 DAMCALC(f4 & (RF4_BR_FIRE), m_ptr->hp / 3, 1600,
6284 p_ptr->immune_fire, p_ptr->muta3 & MUT3_VULN_ELEM,
6285 p_ptr->resist_fire, 1, 3,
6286 p_ptr->oppose_fire, 1, 3, dam_max0);
6288 DAMCALC(f4 & (RF4_BR_COLD), m_ptr->hp / 3, 1600,
6289 p_ptr->immune_cold, p_ptr->muta3 & MUT3_VULN_ELEM,
6290 p_ptr->resist_cold, 1, 3,
6291 p_ptr->oppose_cold, 1, 3, dam_max0);
6293 DAMCALC(f4 & (RF4_BR_ELEC), m_ptr->hp / 3, 1600,
6294 p_ptr->immune_elec, p_ptr->muta3 & MUT3_VULN_ELEM,
6295 p_ptr->resist_elec, 1, 3,
6296 p_ptr->oppose_elec, 1, 3, dam_max0);
6298 DAMCALC(f4 & (RF4_BR_ACID), m_ptr->hp / 3, 1600,
6299 p_ptr->immune_acid, p_ptr->muta3 & MUT3_VULN_ELEM,
6300 p_ptr->resist_acid, 1, 3,
6301 p_ptr->oppose_acid, 1, 3, dam_max0);
6303 DAMCALC(f4 & (RF4_BR_POIS), m_ptr->hp / 3, 800,
6305 p_ptr->resist_pois, 1, 3,
6306 p_ptr->oppose_pois, 1, 3, dam_max0);
6309 DAMCALC(f4 & (RF4_BR_NETH), m_ptr->hp / 6, 550, FALSE , FALSE,
6310 p_ptr->resist_neth, 6, 9, FALSE, 1, 1, dam_max0);
6312 DAMCALC(f4 & (RF4_BR_LITE), m_ptr->hp / 6, 400, FALSE , FALSE,
6313 p_ptr->resist_lite, 4, 9, FALSE, 1, 1, dam_max0);
6315 DAMCALC(f4 & (RF4_BR_DARK), m_ptr->hp / 6, 400, FALSE , FALSE,
6316 p_ptr->resist_dark, 4, 9, FALSE, 1, 1, dam_max0);
6318 DAMCALC(f4 & (RF4_BR_CONF), m_ptr->hp / 6, 450, FALSE , FALSE,
6319 p_ptr->resist_conf, 5, 9, FALSE, 1, 1, dam_max0);
6321 DAMCALC(f4 & (RF4_BR_SOUN), m_ptr->hp / 6, 450, FALSE , FALSE,
6322 p_ptr->resist_sound, 5, 9, FALSE, 1, 1, dam_max0);
6324 DAMCALC(f4 & (RF4_BR_CHAO), m_ptr->hp / 6, 600, FALSE , FALSE,
6325 p_ptr->resist_chaos, 6, 9, FALSE, 1, 1, dam_max0);
6327 DAMCALC(f4 & (RF4_BR_DISE), m_ptr->hp / 6, 500, FALSE , FALSE,
6328 p_ptr->resist_disen, 6, 9, FALSE, 1, 1, dam_max0);
6330 DAMCALC(f4 & (RF4_BR_NEXU), m_ptr->hp / 3, 250, FALSE , FALSE,
6331 p_ptr->resist_nexus, 6, 9, FALSE, 1, 1, dam_max0);
6333 DAMCALC(f4 & (RF4_BR_TIME), m_ptr->hp / 3, 150, FALSE , FALSE,
6334 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6336 DAMCALC(f4 & (RF4_BR_INER), m_ptr->hp / 6, 200, FALSE , FALSE,
6337 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6339 DAMCALC(f4 & (RF4_BR_GRAV), m_ptr->hp / 3, 200, FALSE , FALSE,
6340 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6342 DAMCALC(f4 & (RF4_BR_SHAR), m_ptr->hp / 6, 500, FALSE , FALSE,
6343 p_ptr->resist_shard, 6, 9, FALSE, 1, 1, dam_max0);
6345 DAMCALC(f4 & (RF4_BR_PLAS), m_ptr->hp / 6, 150, FALSE , FALSE,
6346 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6348 DAMCALC(f4 & (RF4_BR_WALL), m_ptr->hp / 6, 200, FALSE , FALSE,
6349 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6351 DAMCALC(f4 & (RF4_BR_MANA), m_ptr->hp / 3, 250, FALSE , FALSE,
6352 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6354 DAMCALC(f4 & (RF4_BR_NUKE), m_ptr->hp / 3, 800, FALSE , FALSE,
6355 p_ptr->resist_pois, 2, 5,
6356 p_ptr->oppose_pois, 2, 5, dam_max0);
6358 DAMCALC(f4 & (RF4_BR_DISI), m_ptr->hp / 3, 300, FALSE , FALSE,
6359 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6362 DAMCALC(f4 & (RF4_ROCKET), m_ptr->hp / 4, 800, FALSE , FALSE,
6363 p_ptr->resist_shard, 1, 2, FALSE, 1, 1, dam_max0);
6365 DAMCALC(f5 & (RF5_BA_MANA), rlev*4 + 150, 9999, FALSE , FALSE,
6366 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6368 DAMCALC(f5 & (RF5_BA_DARK), rlev*4 + 150, 9999, FALSE , FALSE,
6369 p_ptr->resist_dark, 4, 9, FALSE, 1, 1, dam_max0);
6371 DAMCALC(f5 & (RF5_BA_LITE), rlev*4 + 150, 9999, FALSE , FALSE,
6372 p_ptr->resist_lite, 4, 9, FALSE, 1, 1, dam_max0);
6375 DAMCALC(f6 & (RF6_HAND_DOOM), p_ptr->chp*6/10, 9999, FALSE , FALSE,
6376 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6380 /* Monster melee attacks */
6381 if(mx <= xx+1 && mx >= xx-1 && my <=yy+1 && my >= yy-1)
6385 for (m = 0; m < 4; m++)
6389 /* Skip non-attacks */
6390 if (!r_ptr->blow[m].method) continue;
6392 /* Extract the attack info */
6393 d1 = r_ptr->blow[m].d_dice;
6394 d2 = r_ptr->blow[m].d_side;
6398 if(dam_melee>dam_max0)dam_max0=dam_melee;
6401 /* Contribution from this monster */
6406 /* Prevent excessive warning */
6407 if(dam_max > old_damage)
6409 old_damage=dam_max * 3 / 2;
6411 if (dam_max>(p_ptr->chp)/2)
6413 object_type *o_ptr = choose_warning_item();
6415 object_desc(o_name, o_ptr, FALSE, 0);
6417 msg_format("%s¤¬±Ô¤¯¿Ì¤¨¤¿¡ª", o_name);
6419 msg_format("%s pulsates sharply!", o_name);
6423 return (get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©"));
6425 return (get_check("Realy want to go ahead? "));
6429 else old_damage = old_damage/2;
6431 c_ptr = &cave[yy][xx];
6432 if (((is_trap(c_ptr->feat) && !easy_disarm) || (c_ptr->info & CAVE_TRAP)) && !one_in_(13))
6434 object_type *o_ptr = choose_warning_item();
6436 object_desc(o_name, o_ptr, FALSE, 0);
6438 msg_format("%s¤¬¿Ì¤¨¤¿¡ª", o_name);
6440 msg_format("%s pulsates!", o_name);
6444 return (get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©"));
6446 return (get_check("Realy want to go ahead? "));
6453 typedef struct essence_type essence_type;
6464 static essence_type essence_info[MAX_ESSENCE] = {
6465 {"ÏÓÎÏ","ÏÓÎÏ", 1, 4, 20},
6466 {"ÃÎǽ","ÃÎǽ", 2, 4, 20},
6467 {"¸¤µ","¸¤µ", 3, 4, 20},
6468 {"´ïÍѤµ","´ïÍѤµ", 4, 4, 20},
6469 {"Âѵ×ÎÏ","Âѵ×ÎÏ", 5, 4, 20},
6470 {"Ì¥ÎÏ","Ì¥ÎÏ", 6, 4, 20},
6471 {"ËâÎÏ»ÙÇÛ","ËâÎÏ»ÙÇÛ", 7, 4, 20},
6473 {"±£Ì©","±£Ì©", 9, 4, 40},
6474 {"õº÷","õº÷", 10, 4, 15},
6475 {"ÀÖ³°Àþ»ëÎÏ","ÀÖ³°Àþ»ëÎÏ", 11, 4, 15},
6476 {"ºÎ·¡","ºÎ·¡", 12, 4, 15},
6477 {"¥¹¥Ô¡¼¥É","¥¹¥Ô¡¼¥É", 13, 4, 12},
6478 {"Äɲù¶·â","Äɲù¶·â", 14, 1, 20},
6479 {"¥«¥ª¥¹¹¶·â","¥«¥ª¥¹¹¶·â", 15, 1, 15},
6480 {"µÛ·ì¹¶·â","µÛ·ì¹¶·â", 16, 1, 60},
6481 {"ưʪÇÜÂÇ","ưʪÇÜÂÇ", 17, 1, 20},
6482 {"¼Ù°ÇÜÂÇ","¼Ù°ÇÜÂÇ", 18, 1, 100},
6483 {"ÉÔ»àÇÜÂÇ","ÉÔ»àÇÜÂÇ", 19, 1, 20},
6484 {"°ËâÇÜÂÇ","°ËâÇÜÂÇ", 20, 1, 20},
6485 {"¥ª¡¼¥¯ÇÜÂÇ","¥ª¡¼¥¯ÇÜÂÇ", 21, 1, 15},
6486 {"¥È¥í¥ëÇÜÂÇ","¥È¥í¥ëÇÜÂÇ", 22, 1, 15},
6487 {"µð¿ÍÇÜÂÇ","µð¿ÍÇÜÂÇ", 23, 1, 20},
6488 {"εÇÜÂÇ","εÇÜÂÇ", 24, 1, 20},
6489 {"","εÇÜÇÜÂÇ", 24, 1, 60},
6491 {"ÃÏ¿Ì","ÃÏ¿Ìȯư", 27, 5, 15},
6492 {"ÆÇ»¦","ÆÇ»¦", 28, 1, 20},
6493 {"Íϲò","Íϲò", 29, 1, 20},
6494 {"ÅÅ·â","ÅÅ·â", 30, 1, 20},
6495 {"¾Æ´þ","¾Æ´þ", 31, 1, 20},
6496 {"Åà·ë","Åà·ë", 32, 1, 20},
6497 {"ǽÎÏ°Ý»ý","ÏÓÎÏ°Ý»ý", 33, 3, 15},
6498 {"","ÃÎǽ°Ý»ý", 33, 3, 15},
6499 {"","¸¤µ°Ý»ý", 33, 3, 15},
6500 {"","´ïÍѤµ°Ý»ý", 33, 3, 15},
6501 {"","Âѵ×ÎÏ°Ý»ý", 33, 3, 15},
6502 {"","Ì¥ÎÏ°Ý»ý", 33, 3, 15},
6505 {"ÌȱÖ","»ÀÌȱÖ", 41, 2, 20},
6506 {"","ÅÅ·âÌȱÖ", 41, 2, 20},
6507 {"","²Ð±êÌȱÖ", 41, 2, 20},
6508 {"","Î䵤ÌȱÖ", 41, 2, 20},
6510 {"È¿¼Í","È¿¼Í", 46, 2, 20},
6511 {"ËãáãÃΤ餺","ËãáãÃΤ餺", 47, 3, 20},
6512 {"À¸Ì¿ÎÏ°Ý»ý","À¸Ì¿ÎÏ°Ý»ý", 48, 3, 20},
6513 {"ÂÑ»À","ÂÑ»À", 49, 2, 15},
6514 {"ÂÑÅÅ·â","ÂÑÅÅ·â", 50, 2, 15},
6515 {"ÂѲбê","ÂѲбê", 51, 2, 15},
6516 {"ÂÑÎ䵤","ÂÑÎ䵤", 52, 2, 15},
6517 {"ÂÑÆÇ","ÂÑÆÇ", 53, 2, 25},
6518 {"ÂѶ²ÉÝ","ÂѶ²ÉÝ", 54, 2, 20},
6519 {"ÂÑÁ®¸÷","ÂÑÁ®¸÷", 55, 2, 20},
6520 {"ÂѰŹõ","ÂѰŹõ", 56, 2, 20},
6521 {"ÂÑÌÕÌÜ","ÂÑÌÕÌÜ", 57, 2, 20},
6522 {"ÂѺ®Íð","ÂѺ®Íð", 58, 2, 20},
6523 {"Âѹ첻","Âѹ첻", 59, 2, 20},
6524 {"ÂÑÇËÊÒ","ÂÑÇËÊÒ", 60, 2, 20},
6525 {"ÂÑÃϹö","ÂÑÃϹö", 61, 2, 20},
6526 {"ÂÑ°ø²Ìº®Íð","ÂÑ°ø²Ìº®Íð", 62, 2, 20},
6527 {"ÂÑ¥«¥ª¥¹","ÂÑ¥«¥ª¥¹", 63, 2, 20},
6528 {"ÂÑÎô²½","ÂÑÎô²½", 64, 2, 20},
6534 {"È¿ËâË¡","È¿ËâË¡", 70, 3, 15},
6541 {"ÉâÍ·","ÉâÍ·", 77, 3, 20},
6542 {"±Êµ×¸÷¸»","±Êµ×¸÷¸»", 78, 3, 15},
6543 {"²Ä»ëÆ©ÌÀ","²Ä»ëÆ©ÌÀ", 79, 3, 20},
6544 {"¥Æ¥ì¥Ñ¥·¡¼","¥Æ¥ì¥Ñ¥·¡¼", 80, 3, 15},
6545 {"Ãپò½","Ãپò½", 81, 3, 15},
6546 {"µÞ®²óÉü","µÞ®²óÉü", 82, 3, 20},
6555 {"¥Æ¥ì¥Ý¡¼¥È","¥Æ¥ì¥Ý¡¼¥È", 91, 3, 25},
6561 {"¹¶·â","¹¶·â", 97, 6, 30},
6562 {"Ëɸæ","Ëɸæ", 98, 6, 15},
6563 {"","»ÀÂÑÀȯư", 49, 5, 50},
6564 {"","ÅÅ·âÂÑÀȯư", 50, 5, 50},
6565 {"","²Ð±êÂÑÀȯư", 51, 5, 50},
6566 {"","Î䵤ÂÑÀȯư", 52, 5, 50},
6567 {"","²Ð±ê¥ª¡¼¥é", 0, 5, 30},
6568 {"","Åŷ⥪¡¼¥é", 0, 5, 30},
6569 {"","Î䵤¥ª¡¼¥é", 0, 5, 30},
6570 {"","Á´ÂÑÀ", 0, 2, 150},
6571 {"","ÁõÈ÷ÊÝ»ý", 0, 6, 10},
6572 {"","»¦Ù¤¤Î¾®¼ê", 97, 1, 200},
6575 static essence_type essence_info[MAX_ESSENCE] = {
6576 {"strength","strength", 1, 4, 20},
6577 {"intelligen.","intelligence", 2, 4, 20},
6578 {"wisdom","wisdom", 3, 4, 20},
6579 {"dexterity","dexterity", 4, 4, 20},
6580 {"constitut.","constitution", 5, 4, 20},
6581 {"charisma","charisma", 6, 4, 20},
6582 {"magic mast.","magic mastery", 7, 4, 20},
6584 {"stealth","stealth", 9, 4, 40},
6585 {"serching","serching", 10, 4, 15},
6586 {"inflavision","inflavision", 11, 4, 15},
6587 {"digging","digging", 12, 4, 15},
6588 {"speed","speed", 13, 4, 12},
6589 {"extra atk","extra attack", 14, 1, 20},
6590 {"chaos brand","chaos brand", 15, 1, 15},
6591 {"vampiric","vampiric brand", 16, 1, 60},
6592 {"slay animal","slay animal", 17, 1, 20},
6593 {"slay evil","slay evil", 18, 1, 100},
6594 {"slay undead","slay undead", 19, 1, 20},
6595 {"slay demon","slay demon", 20, 1, 20},
6596 {"slay orc","slay orc", 21, 1, 15},
6597 {"slay troll","slay troll", 22, 1, 15},
6598 {"slay giant","slay giant", 23, 1, 20},
6599 {"slay dragon","slay dragon", 24, 1, 20},
6600 {"","kill dragon", 24, 1, 60},
6602 {"quake","quake activation", 27, 5, 15},
6603 {"pois. brand","poison brand", 28, 1, 20},
6604 {"acid brand","acid brand", 29, 1, 20},
6605 {"elec. brand","electric brand", 30, 1, 20},
6606 {"fire brand","fire brand", 31, 1, 20},
6607 {"cold brand","cold brand", 32, 1, 20},
6608 {"sustain","sustain strength", 33, 3, 15},
6609 {"","sustain intelligence", 33, 3, 15},
6610 {"","sustain wisdom", 33, 3, 15},
6611 {"","sustain dexterity", 33, 3, 15},
6612 {"","sustain constitution", 33, 3, 15},
6613 {"","sustain charisma", 33, 3, 15},
6616 {"immunity","acid immunity", 41, 2, 20},
6617 {"","electric immunity", 41, 2, 20},
6618 {"","fire immunity", 41, 2, 20},
6619 {"","cold immunity", 41, 2, 20},
6621 {"reflection","reflection", 46, 2, 20},
6622 {"free action","free action", 47, 3, 20},
6623 {"hold life","hold life", 48, 3, 20},
6624 {"res. acid","resistance to acid", 49, 2, 15},
6625 {"res. elec.","resistance to electric", 50, 2, 15},
6626 {"res. fire","resistance to fire", 51, 2, 15},
6627 {"res. cold","resistance to cold", 52, 2, 15},
6628 {"res. poison","resistance to poison", 53, 2, 25},
6629 {"res. fear","resistance to fear", 54, 2, 20},
6630 {"res. light","resistance to light", 55, 2, 20},
6631 {"res. dark","resistance to dark", 56, 2, 20},
6632 {"res. blind","resistance to blind", 57, 2, 20},
6633 {"res.confuse","resistance to confusion", 58, 2, 20},
6634 {"res. sound","resistance to sound", 59, 2, 20},
6635 {"res. shard","resistance to shard", 60, 2, 20},
6636 {"res. nether","resistance to nether", 61, 2, 20},
6637 {"res. nexus","resistance to nexus", 62, 2, 20},
6638 {"res. chaos","resistance to chaos", 63, 2, 20},
6639 {"res. disen.","resistance to disenchantment", 64, 2, 20},
6645 {"anti magic","anti magic", 70, 3, 15},
6652 {"levitation","levitation", 77, 3, 20},
6653 {"perm. light","permanent light", 78, 3, 15},
6654 {"see invis.","see invisible", 79, 3, 20},
6655 {"telepathy","telepathy", 80, 3, 15},
6656 {"slow dige.","slow digestion", 81, 3, 15},
6657 {"regen.","regeneration", 82, 3, 20},
6666 {"teleport","teleport", 91, 3, 25},
6672 {"weapon enc.","weapon enchant", 97, 6, 30},
6673 {"armor enc.","armor enchant", 98, 6, 15},
6674 {"","resist acid activation", 49, 5, 50},
6675 {"","resist electricity activation", 50, 5, 50},
6676 {"","resist fire activation", 51, 5, 50},
6677 {"","resist cold activation", 52, 5, 50},
6678 {"","fiery sheath", 0, 5, 30},
6679 {"","electric sheath", 0, 5, 30},
6680 {"","coldly sheath", 0, 5, 30},
6681 {"","resistance", 0, 2, 150},
6682 {"","elements proof", 0, 6, 10},
6683 {"","gauntlets of slay", 97, 1, 200},
6687 bool item_tester_hook_melee_ammo(object_type *o_ptr)
6689 switch (o_ptr->tval)
6702 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
6710 static void display_essence(void)
6715 for (i = 1; i < 22; i++)
6720 prt("¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô", 1, 8);
6722 prt("Essence Num Essence Num Essence Num ", 1, 8);
6724 for (i = 0; i < MAX_ESSENCE; i++)
6726 if (!essence_info[i].drain_name[0]) continue;
6727 prt(format("%-11s %5d", essence_info[i].drain_name, p_ptr->magic_num1[i]), 2+num%20, 8+num/20*22);
6731 prt("¸½ºß½ê»ý¤·¤Æ¤¤¤ë¥¨¥Ã¥»¥ó¥¹", 0, 0);
6733 prt("List of all essences you have.", 0, 0);
6740 static void drain_essence(void)
6742 int drain_value[MAX_ESSENCE];
6745 bool observe = FALSE;
6746 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
6747 u32b old_f1, old_f2, old_f3, new_f1, new_f2, new_f3;
6750 byte iy, ix, marked, number;
6751 s16b next_o_idx, weight;
6753 for (i = 0; i < MAX_ESSENCE; i++)
6756 item_tester_hook = item_tester_hook_weapon_armour;
6757 item_tester_no_ryoute = TRUE;
6761 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éÃê½Ð¤·¤Þ¤¹¤«¡©";
6762 s = "Ãê½Ð¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
6764 q = "Extract from which item? ";
6765 s = "You have nothing you can extract from.";
6768 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
6770 /* Get the item (in the pack) */
6773 o_ptr = &inventory[item];
6776 /* Get the item (on the floor) */
6779 o_ptr = &o_list[0 - item];
6782 if (object_known_p(o_ptr) && (o_ptr->name1 || o_ptr->name2 || o_ptr->art_name || o_ptr->xtra3)) {
6783 char o_name[MAX_NLEN];
6784 object_desc(o_name, o_ptr, FALSE, 0);
6786 if (!get_check(format("ËÜÅö¤Ë%s¤«¤éÃê½Ð¤·¤Æ¤è¤í¤·¤¤¤Ç¤¹¤«¡©", o_name))) return;
6788 if (!get_check(format("Really extract from %s? ", o_name))) return;
6794 object_flags(o_ptr, &old_f1, &old_f2, &old_f3);
6795 if (old_f1 & TR1_KILL_DRAGON) old_f1 |= TR1_SLAY_DRAGON;
6797 old_to_a = o_ptr->to_a;
6799 old_to_h = o_ptr->to_h;
6800 old_to_d = o_ptr->to_d;
6803 old_pval = o_ptr->pval;
6804 old_name2 = o_ptr->name2;
6805 if (old_f3 & (TR3_CURSED | TR3_HEAVY_CURSE | TR3_PERMA_CURSE)) dec--;
6806 if (old_f3 & (TR3_AGGRAVATE)) dec--;
6807 if (old_f3 & (TR3_NO_TELE)) dec--;
6808 if (old_f3 & (TR3_DRAIN_EXP)) dec--;
6809 if (old_f3 & (TR3_TY_CURSE)) dec--;
6813 next_o_idx = o_ptr->next_o_idx;
6814 marked = o_ptr->marked;
6815 weight = o_ptr->weight;
6816 number = o_ptr->number;
6818 object_prep(o_ptr, o_ptr->k_idx);
6822 o_ptr->next_o_idx=next_o_idx;
6823 o_ptr->marked=marked;
6824 o_ptr->number = number;
6825 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
6826 o_ptr->ident |= (IDENT_MENTAL);
6827 object_aware(o_ptr);
6828 object_known(o_ptr);
6830 object_flags(o_ptr, &new_f1, &new_f2, &new_f3);
6832 for (i = 0; i < 96; i++)
6838 if (((1 << i) & TR1_PVAL_MASK) && old_pval) pval = ((new_f1 >> i) & 0x00000001) ? old_pval-o_ptr->pval : old_pval;
6839 if ((!((new_f1 >> i) & 0x00000001) || pval) && ((old_f1 >> i) & 0x00000001) && essence_info[i].link)
6841 drain_value[essence_info[i].link-1] += (10 * (pval ? pval : 1));
6846 if (!((new_f2 >> (i-32)) & 0x00000001) && ((old_f2 >> (i-32)) & 0x00000001) && essence_info[i].link)
6848 drain_value[essence_info[i].link-1] += 10;
6853 if (!((new_f3 >> (i-64)) & 0x00000001) && ((old_f3 >> (i-64)) & 0x00000001) && essence_info[i].link)
6855 if (essence_info[i].link == -1)
6857 if (i == ESSENCE__SH__FIRE-1)
6859 drain_value[ESSENCE_B_FIRE-1] += 10;
6860 drain_value[ESSENCE_RES_FIRE-1] += 10;
6862 else if (i == ESSENCE__SH__ELEC-1)
6864 drain_value[ESSENCE_B_ELEC-1] += 10;
6865 drain_value[ESSENCE_RES_ELEC-1] += 10;
6867 else if (i == ESSENCE__SH__COLD-1)
6869 drain_value[ESSENCE_B_COLD-1] += 10;
6870 drain_value[ESSENCE_RES_COLD-1] += 10;
6873 else drain_value[essence_info[i].link-1] += 10;
6878 if ((old_f1 & TR1_FORCE_WEAPON) && !(new_f1 & TR1_FORCE_WEAPON))
6880 drain_value[ESSENCE_INT-1] += 5;
6881 drain_value[ESSENCE_WIS-1] += 5;
6883 if ((old_f1 & TR1_VORPAL) && !(new_f1 & TR1_VORPAL))
6885 drain_value[ESSENCE_B_POIS-1] += 5;
6886 drain_value[ESSENCE_B_ACID-1] += 5;
6887 drain_value[ESSENCE_B_ELEC-1] += 5;
6888 drain_value[ESSENCE_B_FIRE-1] += 5;
6889 drain_value[ESSENCE_B_COLD-1] += 5;
6891 if ((old_f3 & TR3_DEC_MANA) && !(new_f3 & TR3_DEC_MANA))
6893 drain_value[ESSENCE_INT-1] += 10;
6895 if ((old_f3 & TR3_XTRA_MIGHT) && !(new_f3 & TR3_XTRA_MIGHT))
6897 drain_value[ESSENCE_STR-1] += 10;
6899 if ((old_f3 & TR3_XTRA_SHOTS) && !(new_f3 & TR3_XTRA_SHOTS))
6901 drain_value[ESSENCE_DEX-1] += 10;
6903 if (old_name2 == EGO_2WEAPON)
6905 drain_value[ESSENCE_DEX] += 20;
6907 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_SWORD) && (o_ptr->tval != TV_BOW))
6909 if (old_ds > o_ptr->ds) drain_value[ESSENCE_ATTACK-1] += (old_ds-o_ptr->ds)*10;
6911 if (old_dd > o_ptr->dd) drain_value[ESSENCE_ATTACK-1] += (old_dd-o_ptr->dd)*10;
6913 if (old_to_h > o_ptr->to_h) drain_value[ESSENCE_ATTACK-1] += (old_to_h-o_ptr->to_h)*10;
6914 if (old_to_d > o_ptr->to_d) drain_value[ESSENCE_ATTACK-1] += (old_to_d-o_ptr->to_d)*10;
6915 if (old_ac > o_ptr->ac) drain_value[ESSENCE_AC-1] += (old_ac-o_ptr->ac)*10;
6916 if (old_to_a > o_ptr->to_a) drain_value[ESSENCE_AC-1] += (old_to_a-o_ptr->to_a)*10;
6918 for (i = 0; i < MAX_ESSENCE; i++)
6920 drain_value[i] *= number;
6921 drain_value[i] = drain_value[i] * dec / 4;
6922 drain_value[i] = MAX(drain_value[i], 0);
6923 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
6932 msg_print("¥¨¥Ã¥»¥ó¥¹¤ÏÃê½Ð¤Ç¤¤Þ¤»¤ó¤Ç¤·¤¿¡£");
6934 msg_print("You were not able to extract any essence.");
6940 msg_print("Ãê½Ð¤·¤¿¥¨¥Ã¥»¥ó¥¹:");
6942 msg_print("Extracted essences:");
6944 for (i = 0; i < MAX_ESSENCE; i++)
6946 if (!drain_value[i]) continue;
6947 p_ptr->magic_num1[i] += drain_value[i];
6948 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
6950 msg_format("%s...%d", essence_info[i].drain_name, drain_value[i]);
6954 /* Combine the pack */
6955 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6958 p_ptr->window |= (PW_INVEN);
6963 static int choose_essence()
6967 int menu_line = (use_menu ? 1 : 0);
6970 if (repeat_pull(&mode) && 1 <= mode && mode <= 5)
6973 #endif /* ALLOW_REPEAT */
6982 prt(format(" %s Éð´ï°À", (menu_line == 1) ? "¡Õ" : " "), 2, 14);
6983 prt(format(" %s ÂÑÀ", (menu_line == 2) ? "¡Õ" : " "), 3, 14);
6984 prt(format(" %s ǽÎÏ", (menu_line == 3) ? "¡Õ" : " "), 4, 14);
6985 prt(format(" %s ¿ôÃÍ", (menu_line == 4) ? "¡Õ" : " "), 5, 14);
6986 prt(format(" %s ¤½¤Î¾", (menu_line == 5) ? "¡Õ" : " "), 6, 14);
6987 prt("¤É¤Î¼ïÎà¤Î¥¨¥Ã¥»¥ó¥¹Éղäò¹Ô¤¤¤Þ¤¹¤«¡©", 0, 0);
6989 prt(format(" %s Brand weapon", (menu_line == 1) ? "> " : " "), 2, 14);
6990 prt(format(" %s Resistance", (menu_line == 2) ? "> " : " "), 3, 14);
6991 prt(format(" %s Ability", (menu_line == 3) ? "> " : " "), 4, 14);
6992 prt(format(" %s Magic number", (menu_line == 4) ? "> " : " "), 5, 14);
6993 prt(format(" %s Others", (menu_line == 5) ? "> " : " "), 6, 14);
6994 prt("Choose from menu.", 0, 0);
7020 if (menu_line > 5) menu_line -= 5;
7030 prt(" a) ¹¶·â°À", 2, 14);
7031 prt(" b) ÂÑÀ", 3, 14);
7032 prt(" c) ǽÎÏ", 4, 14);
7033 prt(" d) ¿ôÃÍ", 5, 14);
7034 prt(" e) ¤½¤Î¾", 6, 14);
7035 if (!get_com("²¿¤òÉղä·¤Þ¤¹¤«:", &choice, TRUE))
7037 prt(" a) Brand weapon", 2, 14);
7038 prt(" b) Resistance", 3, 14);
7039 prt(" c) Ability", 4, 14);
7040 prt(" d) Magic number", 5, 14);
7041 prt(" e) Others", 6, 14);
7042 if (!get_com("Command :", &choice, TRUE))
7078 #endif /* ALLOW_REPEAT */
7082 static void add_essence(int mode)
7084 int item, max_num = 0;
7093 char o_name[MAX_NLEN];
7096 int menu_line = (use_menu ? 1 : 0);
7098 for (i = 0; i < MAX_ESSENCE; i++)
7100 if (essence_info[i].type != mode) continue;
7105 if (!repeat_pull(&i) || i<0 || i>=max_num)
7107 #endif /* ALLOW_REPEAT */
7110 /* Nothing chosen yet */
7116 /* Build a prompt */
7118 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎǽÎϤòÉղä·¤Þ¤¹¤«¡©");
7120 (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Add which ability? ");
7122 if (use_menu) screen_save();
7124 /* Get a spell from the user */
7126 choice = (always_show_list || use_menu) ? ESCAPE:1;
7130 if( choice==ESCAPE ) choice = ' ';
7131 else if( !get_com(out_val, &choice, FALSE) )break;
7133 if (use_menu && choice != ' ')
7148 menu_line += (max_num-1);
7171 menu_line = max_num;
7184 if (menu_line > max_num) menu_line -= max_num;
7186 /* Request redraw */
7187 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
7190 if (!redraw || use_menu)
7194 char dummy[80], dummy2[80];
7202 /* Save the screen */
7203 if (!use_menu) screen_save();
7205 for (y = 1; y < 24; y++)
7208 /* Print header(s) */
7210 prt(" ǽÎÏ(ɬÍ×¥¨¥Ã¥»¥ó¥¹) ɬÍ׿ô/½ê»ý¿ô", 1, x);
7213 prt(" Ability(essence to need) Needs/Possess", 1, x);
7216 for (ctr = 0; ctr < max_num; ctr++)
7220 if (ctr == (menu_line-1))
7222 strcpy(dummy, "¡Õ ");
7224 strcpy(dummy, "> ");
7226 else strcpy(dummy, " ");
7229 /* letter/number for power selection */
7232 sprintf(dummy, "%c) ",I2A(ctr));
7235 strcat(dummy, essence_info[num[ctr]].add_name);
7240 if (essence_info[num[ctr]].link)
7242 strcat(dummy, format("(%s)", essence_info[essence_info[num[ctr]].link-1].drain_name));
7243 if (p_ptr->magic_num1[essence_info[num[ctr]].link-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7249 case ESSENCE_SH_FIRE:
7251 strcat(dummy, "(¾Æ´þ+ÂѲбê) ");
7253 strcat(dummy, "(brand fire + res.fire) ");
7255 if (p_ptr->magic_num1[ESSENCE_B_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7256 if (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7258 case ESSENCE_SH_ELEC:
7260 strcat(dummy, "(ÅÅ·â+ÂÑÅÅ·â) ");
7262 strcat(dummy, "(brand elec. + res. elec.) ");
7264 if (p_ptr->magic_num1[ESSENCE_B_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7265 if (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7267 case ESSENCE_SH_COLD:
7269 strcat(dummy, "(Åà·ë+ÂÑÎ䵤) ");
7271 strcat(dummy, "(brand cold + res. cold) ");
7273 if (p_ptr->magic_num1[ESSENCE_B_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7274 if (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7276 case ESSENCE_RESISTANCE:
7278 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
7280 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
7282 if (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7283 if (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7284 if (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7285 if (p_ptr->magic_num1[ESSENCE_RES_ACID-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7287 case ESSENCE_SUSTAIN:
7289 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
7291 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
7293 if (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7294 if (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7295 if (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7296 if (p_ptr->magic_num1[ESSENCE_RES_ACID-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7301 if (!able[ctr]) col = TERM_RED;
7303 strcpy(dummy2, format("%-50s",dummy));
7305 if (essence_info[num[ctr]].link)
7307 strcat(dummy2, format(" %d/%d",essence_info[num[ctr]].value, p_ptr->magic_num1[essence_info[num[ctr]].link-1]));
7311 strcat(dummy2, format(" %d/(\?\?)",essence_info[num[ctr]].value));
7314 c_prt(col, dummy2, ctr+2, x);
7324 /* Restore the screen */
7335 ask = (isupper(choice));
7338 if (ask) choice = tolower(choice);
7340 /* Extract request */
7341 i = (islower(choice) ? A2I(choice) : -1);
7344 /* Totally Illegal */
7345 if ((i < 0) || (i >= max_num) || !able[i])
7358 (void) strnfmt(tmp_val, 78, "%s¤òÉղä·¤Þ¤¹¤«¡© ", essence_info[num[i]].add_name);
7360 (void) strnfmt(tmp_val, 78, "Add the abilitiy of %s? ", essence_info[num[i]].add_name);
7363 /* Belay that order */
7364 if (!get_check(tmp_val)) continue;
7371 /* Restore the screen */
7372 if (redraw) screen_load();
7379 #endif /* ALLOW_REPEAT */
7381 if (num[i] == ESSENCE_SLAY_GLOVE-1)
7382 item_tester_tval = TV_GLOVES;
7384 item_tester_hook = item_tester_hook_melee_ammo;
7385 else if (num[i] == ESSENCE_ATTACK-1)
7386 item_tester_hook = item_tester_hook_weapon;
7387 else if (num[i] == ESSENCE_AC-1)
7388 item_tester_hook = item_tester_hook_armour;
7390 item_tester_hook = item_tester_hook_weapon_armour;
7391 item_tester_no_ryoute = TRUE;
7395 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
7396 s = "²þÎɤǤ¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
7398 q = "Improve which item? ";
7399 s = "You have nothing to improve.";
7402 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7404 /* Get the item (in the pack) */
7407 o_ptr = &inventory[item];
7410 /* Get the item (on the floor) */
7413 o_ptr = &o_list[0 - item];
7416 if ((mode != 6) && (o_ptr->name1 || o_ptr->art_name || o_ptr->xtra3))
7419 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï¤³¤ì°Ê¾å²þÎɤǤ¤Ê¤¤¡£");
7421 msg_print("This item is no more able to be improved");
7426 object_desc(o_name, o_ptr, FALSE, 0);
7428 use_essence = essence_info[num[i]].value;
7429 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
7430 if (o_ptr->number > 1)
7432 use_essence *= o_ptr->number;
7434 msg_format("%d¸Ä¤¢¤ë¤Î¤Ç¥¨¥Ã¥»¥ó¥¹¤Ï%dɬÍפǤ¹¡£", o_ptr->number, use_essence);
7436 msg_format("It will take %d essences.",use_essence);
7441 if (essence_info[num[i]].link)
7443 if (p_ptr->magic_num1[essence_info[num[i]].link-1] < use_essence)
7446 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7448 msg_print("You don't have enough essences.");
7452 if ((num[i] < 32) && (TR1_PVAL_MASK & (0x1L << num[i])))
7454 if (num[i] == ESSENCE_BLOWS-1)
7456 if (o_ptr->pval > 1)
7459 if (!get_check("½¤ÀµÃͤÏ1¤Ë¤Ê¤ê¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) return;
7461 if (!get_check("The magic number of this weapon will become 1. Are you sure? ")) return;
7466 else if (o_ptr->pval)
7468 use_essence *= o_ptr->pval;
7470 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
7472 msg_format("It will take %d essences.",use_essence);
7480 int limit = MIN(5, p_ptr->magic_num1[essence_info[num[i]].link-1]/essence_info[num[i]].value);
7484 sprintf(tmp, "¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d): ", limit);
7486 sprintf(tmp, "Enchant how many? (1-%d): ", limit);
7488 strcpy(tmp_val, "1");
7490 if (!get_string(tmp, tmp_val, 1)) return;
7491 pval = atoi(tmp_val);
7492 if (pval > limit) pval = limit;
7493 else if (pval < 1) pval = 1;
7495 use_essence *= pval;
7497 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
7499 msg_format("It will take %d essences.",use_essence);
7502 if (p_ptr->magic_num1[essence_info[num[i]].link-1] < use_essence)
7505 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7507 msg_print("You don't have enough essences.");
7512 else if (num[i] == ESSENCE_SLAY_GLOVE-1)
7516 int get_to_h, get_to_d;
7518 strcpy(tmp_val, "1");
7520 if (!get_string(format("¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
7522 if (!get_string(format("Enchant how many? (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
7524 val = atoi(tmp_val);
7525 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
7526 else if (val < 1) val = 1;
7529 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
7531 msg_format("It will take %d essences.",use_essence);
7533 if (p_ptr->magic_num1[essence_info[num[i]].link-1] < use_essence)
7536 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7538 msg_print("You don't have enough essences");
7542 get_to_h = ((val+1)/2+randint0(val/2+1));
7543 get_to_d = ((val+1)/2+randint0(val/2+1));
7544 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
7545 o_ptr->to_h += get_to_h;
7546 o_ptr->to_d += get_to_d;
7548 p_ptr->magic_num1[essence_info[num[i]].link-1] -= use_essence;
7549 if (num[i] == ESSENCE_ATTACK-1)
7551 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
7554 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
7556 msg_print("You failed to enchant.");
7563 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
7564 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
7567 else if (num[i] == ESSENCE_AC-1)
7569 if (o_ptr->to_a >= p_ptr->lev/5+5)
7572 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
7574 msg_print("You failed to enchant.");
7581 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
7586 o_ptr->xtra3 = num[i]+1;
7591 bool success = TRUE;
7595 case ESSENCE_SH_FIRE:
7596 if ((p_ptr->magic_num1[ESSENCE_B_FIRE-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < use_essence))
7601 p_ptr->magic_num1[ESSENCE_B_FIRE-1] -= use_essence;
7602 p_ptr->magic_num1[ESSENCE_RES_FIRE-1] -= use_essence;
7604 case ESSENCE_SH_ELEC:
7605 if ((p_ptr->magic_num1[ESSENCE_B_ELEC-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < use_essence))
7610 p_ptr->magic_num1[ESSENCE_B_ELEC-1] -= use_essence;
7611 p_ptr->magic_num1[ESSENCE_RES_ELEC-1] -= use_essence;
7613 case ESSENCE_SH_COLD:
7614 if ((p_ptr->magic_num1[ESSENCE_B_COLD-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < use_essence))
7619 p_ptr->magic_num1[ESSENCE_B_COLD-1] -= use_essence;
7620 p_ptr->magic_num1[ESSENCE_RES_COLD-1] -= use_essence;
7622 case ESSENCE_RESISTANCE:
7623 case ESSENCE_SUSTAIN:
7624 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))
7629 p_ptr->magic_num1[ESSENCE_RES_ACID-1] -= use_essence;
7630 p_ptr->magic_num1[ESSENCE_RES_ELEC-1] -= use_essence;
7631 p_ptr->magic_num1[ESSENCE_RES_FIRE-1] -= use_essence;
7632 p_ptr->magic_num1[ESSENCE_RES_COLD-1] -= use_essence;
7638 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7640 msg_print("You don't have enough essences");
7644 if (num[i] == ESSENCE_SUSTAIN-1)
7645 o_ptr->art_flags3 |= (TR3_IGNORE_ACID | TR3_IGNORE_ELEC | TR3_IGNORE_FIRE | TR3_IGNORE_COLD);
7646 else o_ptr->xtra3 = num[i]+1;
7652 msg_format("%s¤Ë%s¤ÎǽÎϤòÉղä·¤Þ¤·¤¿¡£", o_name, essence_info[num[i]].add_name);
7654 msg_format("You have added ability of %s to %s.", essence_info[num[i]].add_name, o_name);
7657 /* Combine the pack */
7658 p_ptr->notice |= (PN_COMBINE);
7661 p_ptr->window |= (PW_INVEN);
7665 bool item_tester_hook_kaji(object_type *o_ptr)
7667 switch (o_ptr->tval)
7687 if (o_ptr->xtra3) return (TRUE);
7695 void erase_essence(void)
7700 char o_name[MAX_NLEN];
7703 item_tester_hook = item_tester_hook_kaji;
7707 q = "¤É¤Î¥¢¥¤¥Æ¥à¤Î¥¨¥Ã¥»¥ó¥¹¤ò¾Ãµî¤·¤Þ¤¹¤«¡©";
7708 s = "¥¨¥Ã¥»¥ó¥¹¤òÉղä·¤¿¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
7710 q = "Remove from which item? ";
7711 s = "You have nothing to remove essence.";
7714 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7716 /* Get the item (in the pack) */
7719 o_ptr = &inventory[item];
7722 /* Get the item (on the floor) */
7725 o_ptr = &o_list[0 - item];
7728 object_desc(o_name, o_ptr, FALSE, 0);
7730 if (!get_check(format("¤è¤í¤·¤¤¤Ç¤¹¤«¡©[%s]", o_name))) return;
7732 if (!get_check(format("Are you sure?[%s]", o_name))) return;
7737 if (o_ptr->xtra3 == ESSENCE_SLAY_GLOVE)
7739 o_ptr->to_h -= (o_ptr->xtra4>>8);
7740 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
7744 object_flags(o_ptr, &f1, &f2, &f3);
7745 if (!(f1 & TR1_PVAL_MASK)) o_ptr->pval = 0;
7747 msg_print("¥¨¥Ã¥»¥ó¥¹¤ò¼è¤êµî¤Ã¤¿¡£");
7749 msg_print("You removed all essence you have added");
7752 /* Combine the pack */
7753 p_ptr->notice |= (PN_COMBINE);
7756 p_ptr->window |= (PW_INVEN);
7759 void do_cmd_kaji(bool only_browse)
7764 int menu_line = (use_menu ? 1 : 0);
7768 if (p_ptr->confused)
7771 msg_print("º®Í𤷤Ƥ¤¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
7773 msg_print("You are too confused!");
7781 msg_print("Ìܤ¬¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
7783 msg_print("You are blind!");
7791 msg_print("¤¦¤Þ¤¯¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
7793 msg_print("You are hullcinating!");
7801 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
7803 #endif /* ALLOW_REPEAT */
7805 if (only_browse) screen_save();
7807 if (!only_browse) screen_save();
7813 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", (menu_line == 1) ? "¡Õ" : " "), 2, 14);
7814 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", (menu_line == 2) ? "¡Õ" : " "), 3, 14);
7815 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹¾Ãµî", (menu_line == 3) ? "¡Õ" : " "), 4, 14);
7816 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", (menu_line == 4) ? "¡Õ" : " "), 5, 14);
7817 prt(format(" %s Éð´ï/Ëɶñ¶¯²½", (menu_line == 5) ? "¡Õ" : " "), 6, 14);
7818 prt(format("¤É¤Î¼ïÎà¤Îµ»½Ñ¤ò%s¤Þ¤¹¤«¡©", only_browse ? "Ä´¤Ù" : "»È¤¤"), 0, 0);
7820 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
7821 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
7822 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
7823 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
7824 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
7825 prt(format("Choose command from menu."), 0, 0);
7851 if (menu_line > 5) menu_line -= 5;
7860 prt(" a) ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", 2, 14);
7861 prt(" b) ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", 3, 14);
7862 prt(" c) ¥¨¥Ã¥»¥ó¥¹¾Ãµî", 4, 14);
7863 prt(" d) ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", 5, 14);
7864 prt(" e) Éð´ï/Ëɶñ¶¯²½", 6, 14);
7865 if (!get_com(format("¤É¤ÎǽÎϤò%s¤Þ¤¹¤«:", only_browse ? "Ä´¤Ù" : "»È¤¤"), &choice, TRUE))
7867 prt(" a) List essences", 2, 14);
7868 prt(" b) Extract essence", 3, 14);
7869 prt(" c) Remove essence", 4, 14);
7870 prt(" d) Add essence", 5, 14);
7871 prt(" e) Enchant weapon/armor", 6, 14);
7872 if (!get_com("Command :", &choice, TRUE))
7909 /* Clear lines, position cursor (really should use strlen here) */
7910 Term_erase(14, 21, 255);
7911 Term_erase(14, 20, 255);
7912 Term_erase(14, 19, 255);
7913 Term_erase(14, 18, 255);
7914 Term_erase(14, 17, 255);
7915 Term_erase(14, 16, 255);
7917 roff_to_buf( kaji_tips[mode-1],62,temp);
7918 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
7920 prt(&temp[j], line, 15);
7925 if (!only_browse) screen_load();
7926 } while (only_browse);
7930 #endif /* ALLOW_REPEAT */
7934 case 1: display_essence();break;
7935 case 2: drain_essence();break;
7936 case 3: erase_essence();break;
7938 mode = choose_essence();
7943 case 5: add_essence(6);break;