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))
173 object_delete_callback(j_ptr);
174 #endif /* USE_SCRIPT */
176 /* Wipe the object */
185 * Deletes all objects at given location
187 void delete_object(int y, int x)
191 s16b this_o_idx, next_o_idx = 0;
194 /* Refuse "illegal" locations */
195 if (!in_bounds(y, x)) return;
201 /* Scan all objects in the grid */
202 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
207 o_ptr = &o_list[this_o_idx];
209 /* Acquire next object */
210 next_o_idx = o_ptr->next_o_idx;
213 object_delete_callback(o_ptr);
214 #endif /* USE_SCRIPT */
216 /* Wipe the object */
223 /* Objects are gone */
232 * Move an object from index i1 to index i2 in the object list
234 static void compact_objects_aux(int i1, int i2)
244 if (i1 == i2) return;
248 for (i = 1; i < o_max; i++)
253 /* Skip "dead" objects */
254 if (!o_ptr->k_idx) continue;
256 /* Repair "next" pointers */
257 if (o_ptr->next_o_idx == i1)
260 o_ptr->next_o_idx = i2;
270 if (o_ptr->held_m_idx)
274 /* Acquire monster */
275 m_ptr = &m_list[o_ptr->held_m_idx];
278 if (m_ptr->hold_o_idx == i1)
281 m_ptr->hold_o_idx = i2;
290 /* Acquire location */
298 if (c_ptr->o_idx == i1)
307 o_list[i2] = o_list[i1];
310 object_delete_callback(o_ptr);
311 #endif /* USE_SCRIPT */
319 * Compact and Reorder the object list
321 * This function can be very dangerous, use with caution!
323 * When actually "compacting" objects, we base the saving throw on a
324 * combination of object level, distance from player, and current
327 * After "compacting" (if needed), we "reorder" the objects into a more
328 * compact order, and we reset the allocation info, and the "live" array.
330 void compact_objects(int size)
332 int i, y, x, num, cnt;
333 int cur_lev, cur_dis, chance;
342 msg_print("¥¢¥¤¥Æ¥à¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
344 msg_print("Compacting objects...");
349 p_ptr->redraw |= (PR_MAP);
352 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
356 /* Compact at least 'size' objects */
357 for (num = 0, cnt = 1; num < size; cnt++)
359 /* Get more vicious each iteration */
362 /* Get closer each iteration */
363 cur_dis = 5 * (20 - cnt);
365 /* Examine the objects */
366 for (i = 1; i < o_max; i++)
370 /* Skip dead objects */
371 if (!o_ptr->k_idx) continue;
373 /* Hack -- High level objects start out "immune" */
374 if (get_object_level(o_ptr) > cur_lev) continue;
377 if (o_ptr->held_m_idx)
381 /* Acquire monster */
382 m_ptr = &m_list[o_ptr->held_m_idx];
384 /* Get the location */
388 /* Monsters protect their objects */
389 if (rand_int(100) < 90) continue;
395 /* Get the location */
400 /* Nearby objects start out "immune" */
401 if ((cur_dis > 0) && (distance(py, px, y, x) < cur_dis)) continue;
406 /* Hack -- only compact artifacts in emergencies */
407 if ((artifact_p(o_ptr) || o_ptr->art_name) &&
408 (cnt < 1000)) chance = 100;
410 /* Apply the saving throw */
411 if (rand_int(100) < chance) continue;
413 /* Delete the object */
414 delete_object_idx(i);
422 /* Excise dead objects (backwards!) */
423 for (i = o_max - 1; i >= 1; i--)
427 /* Skip real objects */
428 if (o_ptr->k_idx) continue;
430 /* Move last object into open hole */
431 compact_objects_aux(o_max - 1, i);
433 /* Compress "o_max" */
440 * Delete all the items when player leaves the level
442 * Note -- we do NOT visually reflect these (irrelevant) changes
444 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
445 * and the "m_ptr->next_o_idx" field for every monster, since
446 * we know we are clearing every object. Technically, we only
447 * clear those fields for grids/monsters containing objects,
448 * and we clear it once for every such object.
450 void wipe_o_list(void)
454 /* Delete the existing objects */
455 for (i = 1; i < o_max; i++)
457 object_type *o_ptr = &o_list[i];
459 /* Skip dead objects */
460 if (!o_ptr->k_idx) continue;
462 /* Mega-Hack -- preserve artifacts */
463 if (!character_dungeon || preserve_mode)
465 /* Hack -- Preserve unknown artifacts */
466 if (artifact_p(o_ptr) && !object_known_p(o_ptr))
468 /* Mega-Hack -- Preserve the artifact */
469 a_info[o_ptr->name1].cur_num = 0;
474 if (o_ptr->held_m_idx)
479 m_ptr = &m_list[o_ptr->held_m_idx];
481 /* Hack -- see above */
482 m_ptr->hold_o_idx = 0;
490 /* Access location */
497 /* Hack -- see above */
502 object_delete_callback(o_ptr);
503 #endif /* USE_SCRIPT */
505 /* Wipe the object */
518 * Acquires and returns the index of a "free" object.
520 * This routine should almost never fail, but in case it does,
521 * we must be sure to handle "failure" of this routine.
528 /* Initial allocation */
529 if (o_max < max_o_idx)
534 /* Expand object array */
540 /* Use this object */
545 /* Recycle dead objects */
546 for (i = 1; i < o_max; i++)
553 /* Skip live objects */
554 if (o_ptr->k_idx) continue;
559 /* Use this object */
564 /* Warn the player (except during dungeon creation) */
566 if (character_dungeon) msg_print("¥¢¥¤¥Æ¥à¤¬Â¿¤¹¤®¤ë¡ª");
568 if (character_dungeon) msg_print("Too many objects!");
578 * Apply a "object restriction function" to the "object allocation table"
580 errr get_obj_num_prep(void)
585 alloc_entry *table = alloc_kind_table;
587 /* Scan the allocation table */
588 for (i = 0; i < alloc_kind_size; i++)
590 /* Accept objects which pass the restriction, if any */
591 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
593 /* Accept this object */
594 table[i].prob2 = table[i].prob1;
597 /* Do not use this object */
600 /* Decline this object */
611 * Choose an object kind that seems "appropriate" to the given level
613 * This function uses the "prob2" field of the "object allocation table",
614 * and various local information, to calculate the "prob3" field of the
615 * same table, which is then used to choose an "appropriate" object, in
616 * a relatively efficient manner.
618 * It is (slightly) more likely to acquire an object of the given level
619 * than one of a lower level. This is done by choosing several objects
620 * appropriate to the given level and keeping the "hardest" one.
622 * Note that if no objects are "appropriate", then this function will
623 * fail, and return zero, but this should *almost* never happen.
625 s16b get_obj_num(int level)
631 alloc_entry *table = alloc_kind_table;
633 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
636 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
638 /* Occasional "boost" */
639 if (rand_int(GREAT_OBJ) == 0)
641 /* What a bizarre calculation */
642 level = 1 + (level * MAX_DEPTH / randint(MAX_DEPTH));
649 /* Process probabilities */
650 for (i = 0; i < alloc_kind_size; i++)
652 /* Objects are sorted by depth */
653 if (table[i].level > level) break;
658 /* Access the index */
659 k_idx = table[i].index;
661 /* Access the actual kind */
662 k_ptr = &k_info[k_idx];
664 /* Hack -- prevent embedded chests */
665 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
668 table[i].prob3 = table[i].prob2;
671 total += table[i].prob3;
674 /* No legal objects */
675 if (total <= 0) return (0);
679 value = rand_int(total);
681 /* Find the object */
682 for (i = 0; i < alloc_kind_size; i++)
684 /* Found the entry */
685 if (value < table[i].prob3) break;
688 value = value - table[i].prob3;
695 /* Try for a "better" object once (50%) or twice (10%) */
702 value = rand_int(total);
704 /* Find the object */
705 for (i = 0; i < alloc_kind_size; i++)
707 /* Found the entry */
708 if (value < table[i].prob3) break;
711 value = value - table[i].prob3;
714 /* Keep the "best" one */
715 if (table[i].level < table[j].level) i = j;
718 /* Try for a "better" object twice (10%) */
725 value = rand_int(total);
727 /* Find the object */
728 for (i = 0; i < alloc_kind_size; i++)
730 /* Found the entry */
731 if (value < table[i].prob3) break;
734 value = value - table[i].prob3;
737 /* Keep the "best" one */
738 if (table[i].level < table[j].level) i = j;
743 return (table[i].index);
748 * Known is true when the "attributes" of an object are "known".
749 * These include tohit, todam, toac, cost, and pval (charges).
751 * Note that "knowing" an object gives you everything that an "awareness"
752 * gives you, and much more. In fact, the player is always "aware" of any
753 * item of which he has full "knowledge".
755 * But having full knowledge of, say, one "wand of wonder", does not, by
756 * itself, give you knowledge, or even awareness, of other "wands of wonder".
757 * It happens that most "identify" routines (including "buying from a shop")
758 * will make the player "aware" of the object as well as fully "know" it.
760 * This routine also removes any inscriptions generated by "feelings".
762 void object_known(object_type *o_ptr)
764 /* Remove "default inscriptions" */
765 o_ptr->feeling = FEEL_NONE;
767 /* Clear the "Felt" info */
768 o_ptr->ident &= ~(IDENT_SENSE);
770 /* Clear the "Empty" info */
771 o_ptr->ident &= ~(IDENT_EMPTY);
773 /* Now we know about the item */
774 o_ptr->ident |= (IDENT_KNOWN);
779 * The player is now aware of the effects of the given object.
781 void object_aware(object_type *o_ptr)
783 bool mihanmei = !object_aware_p(o_ptr);
785 #ifndef SCRIPT_OBJ_KIND
786 /* Fully aware of the effects */
787 k_info[o_ptr->k_idx].aware = TRUE;
788 #else /* SCRIPT_OBJ_KIND */
789 /* Fully aware of the effects */
791 #endif /* SCRIPT_OBJ_KIND */
793 if(mihanmei && !(k_info[o_ptr->k_idx].flags3 & TR3_INSTA_ART) && record_ident &&
794 !death && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
798 char o_name[MAX_NLEN];
801 object_copy(q_ptr, o_ptr);
804 object_desc(o_name, q_ptr, TRUE, 0);
806 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
812 * Something has been "sampled"
814 void object_tried(object_type *o_ptr)
816 #ifndef SCRIPT_OBJ_KIND
817 /* Mark it as tried (even if "aware") */
818 k_info[o_ptr->k_idx].tried = TRUE;
819 #else /* SCRIPT_OBJ_KIND */
821 #endif /* SCRIPT_OBJ_KIND */
826 * Return the "value" of an "unknown" item
827 * Make a guess at the value of non-aware items
829 static s32b object_value_base(object_type *o_ptr)
831 /* Aware item -- use template cost */
832 if (object_aware_p(o_ptr)) return (get_object_cost(o_ptr));
834 /* Analyze the type */
839 case TV_FOOD: return (5L);
841 /* Un-aware Potions */
842 case TV_POTION: return (20L);
844 /* Un-aware Scrolls */
845 case TV_SCROLL: return (20L);
847 /* Un-aware Staffs */
848 case TV_STAFF: return (70L);
851 case TV_WAND: return (50L);
854 case TV_ROD: return (90L);
857 case TV_RING: return (45L);
859 /* Un-aware Amulets */
860 case TV_AMULET: return (45L);
862 /* Figurines, relative to monster level */
865 int level = r_info[o_ptr->pval].level;
866 if (level < 20) return level*50L;
867 else if (level < 30) return 1000+(level-20)*150L;
868 else if (level < 40) return 2500+(level-30)*350L;
869 else if (level < 50) return 6000+(level-40)*800L;
870 else return 14000+(level-50)*2000L;
875 if (!o_ptr->pval) return 1000L;
876 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
879 /* Paranoia -- Oops */
884 /* Return the value of the flags the object has... */
885 s32b flag_cost(object_type * o_ptr, int plusses)
892 object_flags(o_ptr, &f1, &f2, &f3);
896 artifact_type *a_ptr = &a_info[o_ptr->name1];
898 f1 &= ~(a_ptr->flags1);
899 f2 &= ~(a_ptr->flags2);
900 f3 &= ~(a_ptr->flags3);
906 ego_item_type *e_ptr = &e_info[o_ptr->name2];
908 f1 &= ~(e_ptr->flags1);
909 f2 &= ~(e_ptr->flags2);
910 f3 &= ~(e_ptr->flags3);
911 if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET))
913 object_kind *k_ptr = &k_info[o_ptr->k_idx];
915 f1 &= ~(k_ptr->flags1);
916 f2 &= ~(k_ptr->flags2);
917 f3 &= ~(k_ptr->flags3);
920 else if (o_ptr->art_name)
926 if (f1 & TR1_STR) total += (1500 * plusses);
927 if (f1 & TR1_INT) total += (1500 * plusses);
928 if (f1 & TR1_WIS) total += (1500 * plusses);
929 if (f1 & TR1_DEX) total += (1500 * plusses);
930 if (f1 & TR1_CON) total += (1500 * plusses);
931 if (f1 & TR1_CHR) total += (750 * plusses);
932 if (f1 & TR1_MAGIC_MASTERY) total += (600 * plusses);
933 if (f1 & TR1_STEALTH) total += (250 * plusses);
934 if (f1 & TR1_SEARCH) total += (100 * plusses);
935 if (f1 & TR1_INFRA) total += (150 * plusses);
936 if (f1 & TR1_TUNNEL) total += (175 * plusses);
937 if ((f1 & TR1_SPEED) && (plusses > 0))
938 total += (10000 + (2500 * plusses));
939 if ((f1 & TR1_BLOWS) && (plusses > 0))
940 total += (10000 + (2500 * plusses));
941 if (f3 & TR3_DEC_MANA) total += 10000;
945 if (f1 & TR1_CHAOTIC) {total += 5000;count++;}
946 if (f1 & TR1_VAMPIRIC) {total += 6500;count++;}
947 if (f1 & TR1_FORCE_WEPON) {tmp_cost += 2500;count++;}
948 if (f1 & TR1_SLAY_ANIMAL) {tmp_cost += 1800;count++;}
949 if (f1 & TR1_SLAY_EVIL) {tmp_cost += 2300;count++;}
950 if (f1 & TR1_SLAY_UNDEAD) {tmp_cost += 1800;count++;}
951 if (f1 & TR1_SLAY_DEMON) {tmp_cost += 1800;count++;}
952 if (f1 & TR1_SLAY_ORC) {tmp_cost += 1500;count++;}
953 if (f1 & TR1_SLAY_TROLL) {tmp_cost += 1800;count++;}
954 if (f1 & TR1_SLAY_GIANT) {tmp_cost += 1800;count++;}
955 if (f1 & TR1_KILL_DRAGON) {tmp_cost += 2800;count++;}
956 else if (f1 & TR1_SLAY_DRAGON) {tmp_cost += 1800;count++;}
958 if (f1 & TR1_VORPAL) {tmp_cost += 2500;count++;}
959 if (f1 & TR1_IMPACT) {tmp_cost += 2500;count++;}
960 if (f1 & TR1_BRAND_POIS) {tmp_cost += 3800;count++;}
961 if (f1 & TR1_BRAND_ACID) {tmp_cost += 3800;count++;}
962 if (f1 & TR1_BRAND_ELEC) {tmp_cost += 3800;count++;}
963 if (f1 & TR1_BRAND_FIRE) {tmp_cost += 2500;count++;}
964 if (f1 & TR1_BRAND_COLD) {tmp_cost += 2500;count++;}
965 total += (tmp_cost * count);
967 if (f2 & TR2_SUST_STR) total += 850;
968 if (f2 & TR2_SUST_INT) total += 850;
969 if (f2 & TR2_SUST_WIS) total += 850;
970 if (f2 & TR2_SUST_DEX) total += 850;
971 if (f2 & TR2_SUST_CON) total += 850;
972 if (f2 & TR2_SUST_CHR) total += 250;
973 if (f2 & TR2_RIDING) total += 0;
974 if (f2 & TR2_XXX2) total += 0;
975 if (f2 & TR2_THROW) total += 5000;
976 if (f2 & TR2_FREE_ACT) total += 4500;
977 if (f2 & TR2_HOLD_LIFE) total += 8500;
981 if (f2 & TR2_IM_ACID) {tmp_cost += 15000;count += 2;}
982 if (f2 & TR2_IM_ELEC) {tmp_cost += 15000;count += 2;}
983 if (f2 & TR2_IM_FIRE) {tmp_cost += 15000;count += 2;}
984 if (f2 & TR2_IM_COLD) {tmp_cost += 15000;count += 2;}
985 if (f2 & TR2_REFLECT) {tmp_cost += 5000;count += 2;}
986 if (f2 & TR2_RES_ACID) {tmp_cost += 500;count++;}
987 if (f2 & TR2_RES_ELEC) {tmp_cost += 500;count++;}
988 if (f2 & TR2_RES_FIRE) {tmp_cost += 500;count++;}
989 if (f2 & TR2_RES_COLD) {tmp_cost += 500;count++;}
990 if (f2 & TR2_RES_POIS) {tmp_cost += 1000;count += 2;}
991 if (f2 & TR2_RES_FEAR) {tmp_cost += 1000;count += 2;}
992 if (f2 & TR2_RES_LITE) {tmp_cost += 800;count += 2;}
993 if (f2 & TR2_RES_DARK) {tmp_cost += 800;count += 2;}
994 if (f2 & TR2_RES_BLIND) {tmp_cost += 900;count += 2;}
995 if (f2 & TR2_RES_CONF) {tmp_cost += 900;count += 2;}
996 if (f2 & TR2_RES_SOUND) {tmp_cost += 900;count += 2;}
997 if (f2 & TR2_RES_SHARDS) {tmp_cost += 900;count += 2;}
998 if (f2 & TR2_RES_NETHER) {tmp_cost += 900;count += 2;}
999 if (f2 & TR2_RES_NEXUS) {tmp_cost += 900;count += 2;}
1000 if (f2 & TR2_RES_CHAOS) {tmp_cost += 1000;count += 2;}
1001 if (f2 & TR2_RES_DISEN) {tmp_cost += 2000;count += 2;}
1002 total += (tmp_cost * count);
1004 if (f3 & TR3_SH_FIRE) total += 5000;
1005 if (f3 & TR3_SH_ELEC) total += 5000;
1006 if (f3 & TR3_SH_COLD) total += 5000;
1007 if (f3 & TR3_QUESTITEM) total += 0;
1008 if (f3 & TR3_NO_TELE) total -= 10000;
1009 if (f3 & TR3_NO_MAGIC) total += 2500;
1010 if (f3 & TR3_TY_CURSE) total -= 15000;
1011 if (f3 & TR3_HIDE_TYPE) total += 0;
1012 if (f3 & TR3_SHOW_MODS) total += 0;
1013 if (f3 & TR3_INSTA_ART) total += 0;
1014 if (f3 & TR3_FEATHER) total += 1250;
1015 if (f3 & TR3_LITE) total += 1250;
1016 if (f3 & TR3_SEE_INVIS) total += 2000;
1017 if (f3 & TR3_TELEPATHY) total += 20000;
1018 if (f3 & TR3_SLOW_DIGEST) total += 750;
1019 if (f3 & TR3_REGEN) total += 2500;
1020 if (f3 & TR3_XTRA_MIGHT) total += 2250;
1021 if (f3 & TR3_XTRA_SHOTS) total += 10000;
1022 if (f3 & TR3_IGNORE_ACID) total += 100;
1023 if (f3 & TR3_IGNORE_ELEC) total += 100;
1024 if (f3 & TR3_IGNORE_FIRE) total += 100;
1025 if (f3 & TR3_IGNORE_COLD) total += 100;
1026 if (f3 & TR3_ACTIVATE) total += 100;
1027 if (f3 & TR3_DRAIN_EXP) total -= 12500;
1028 if (f3 & TR3_TELEPORT)
1030 if (o_ptr->ident & IDENT_CURSED)
1035 if (f3 & TR3_AGGRAVATE) total -= 10000;
1036 if (f3 & TR3_BLESSED) total += 750;
1037 if (f3 & TR3_CURSED) total -= 5000;
1038 if (f3 & TR3_HEAVY_CURSE) total -= 12500;
1039 if (f3 & TR3_PERMA_CURSE) total -= 15000;
1041 /* Also, give some extra for activatable powers... */
1042 if (o_ptr->art_name && (o_ptr->art_flags3 & TR3_ACTIVATE))
1044 int type = o_ptr->xtra2;
1046 if (type == ACT_SUNLIGHT) total += 250;
1047 else if (type == ACT_BO_MISS_1) total += 250;
1048 else if (type == ACT_BA_POIS_1) total += 300;
1049 else if (type == ACT_BO_ELEC_1) total += 250;
1050 else if (type == ACT_BO_ACID_1) total += 250;
1051 else if (type == ACT_BO_COLD_1) total += 250;
1052 else if (type == ACT_BO_FIRE_1) total += 250;
1053 else if (type == ACT_BA_COLD_1) total += 750;
1054 else if (type == ACT_BA_FIRE_1) total += 1000;
1055 else if (type == ACT_DRAIN_1) total += 500;
1056 else if (type == ACT_BA_COLD_2) total += 1250;
1057 else if (type == ACT_BA_ELEC_2) total += 1500;
1058 else if (type == ACT_DRAIN_2) total += 750;
1059 else if (type == ACT_VAMPIRE_1) total = 1000;
1060 else if (type == ACT_BO_MISS_2) total += 1000;
1061 else if (type == ACT_BA_FIRE_2) total += 1750;
1062 else if (type == ACT_BA_COLD_3) total += 2500;
1063 else if (type == ACT_BA_ELEC_3) total += 2500;
1064 else if (type == ACT_WHIRLWIND) total += 7500;
1065 else if (type == ACT_VAMPIRE_2) total += 2500;
1066 else if (type == ACT_CALL_CHAOS) total += 5000;
1067 else if (type == ACT_ROCKET) total += 5000;
1068 else if (type == ACT_DISP_EVIL) total += 4000;
1069 else if (type == ACT_DISP_GOOD) total += 3500;
1070 else if (type == ACT_BA_MISS_3) total += 5000;
1071 else if (type == ACT_CONFUSE) total += 500;
1072 else if (type == ACT_SLEEP) total += 750;
1073 else if (type == ACT_QUAKE) total += 600;
1074 else if (type == ACT_TERROR) total += 2500;
1075 else if (type == ACT_TELE_AWAY) total += 2000;
1076 else if (type == ACT_GENOCIDE) total += 10000;
1077 else if (type == ACT_MASS_GENO) total += 10000;
1078 else if (type == ACT_CHARM_ANIMAL) total += 7500;
1079 else if (type == ACT_CHARM_UNDEAD) total += 10000;
1080 else if (type == ACT_CHARM_OTHER) total += 10000;
1081 else if (type == ACT_CHARM_ANIMALS) total += 12500;
1082 else if (type == ACT_CHARM_OTHERS) total += 17500;
1083 else if (type == ACT_SUMMON_ANIMAL) total += 10000;
1084 else if (type == ACT_SUMMON_PHANTOM) total += 12000;
1085 else if (type == ACT_SUMMON_ELEMENTAL) total += 15000;
1086 else if (type == ACT_SUMMON_DEMON) total += 20000;
1087 else if (type == ACT_SUMMON_UNDEAD) total += 20000;
1088 else if (type == ACT_CURE_LW) total += 500;
1089 else if (type == ACT_CURE_MW) total += 750;
1090 else if (type == ACT_REST_LIFE) total += 7500;
1091 else if (type == ACT_REST_ALL) total += 15000;
1092 else if (type == ACT_CURE_700) total += 10000;
1093 else if (type == ACT_CURE_1000) total += 15000;
1094 else if (type == ACT_ESP) total += 1500;
1095 else if (type == ACT_BERSERK) total += 800;
1096 else if (type == ACT_PROT_EVIL) total += 5000;
1097 else if (type == ACT_RESIST_ALL) total += 5000;
1098 else if (type == ACT_SPEED) total += 15000;
1099 else if (type == ACT_XTRA_SPEED) total += 25000;
1100 else if (type == ACT_WRAITH) total += 25000;
1101 else if (type == ACT_INVULN) total += 25000;
1102 else if (type == ACT_LIGHT) total += 150;
1103 else if (type == ACT_MAP_LIGHT) total += 500;
1104 else if (type == ACT_DETECT_ALL) total += 1000;
1105 else if (type == ACT_DETECT_XTRA) total += 12500;
1106 else if (type == ACT_ID_FULL) total += 10000;
1107 else if (type == ACT_ID_PLAIN) total += 1250;
1108 else if (type == ACT_RUNE_EXPLO) total += 4000;
1109 else if (type == ACT_RUNE_PROT) total += 10000;
1110 else if (type == ACT_SATIATE) total += 2000;
1111 else if (type == ACT_DEST_DOOR) total += 100;
1112 else if (type == ACT_STONE_MUD) total += 1000;
1113 else if (type == ACT_RECHARGE) total += 1000;
1114 else if (type == ACT_ALCHEMY) total += 10000;
1115 else if (type == ACT_DIM_DOOR) total += 10000;
1116 else if (type == ACT_TELEPORT) total += 2000;
1117 else if (type == ACT_RECALL) total += 7500;
1125 * Return the "real" price of a "known" item, not including discounts
1127 * Wand and staffs get cost for each charge
1129 * Armor is worth an extra 100 gold per bonus point to armor class.
1131 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).
1133 * Missiles are only worth 5 gold per bonus point, since they
1134 * usually appear in groups of 20, and we want the player to get
1135 * the same amount of cash for any "equivalent" item. Note that
1136 * missiles never have any of the "pval" flags, and in fact, they
1137 * only have a few of the available flags, primarily of the "slay"
1138 * and "brand" and "ignore" variety.
1140 * Armor with a negative armor bonus is worthless.
1141 * Weapons with negative hit+damage bonuses are worthless.
1143 * Every wearable item with a "pval" bonus is worth extra (see below).
1145 s32b object_value_real(object_type *o_ptr)
1151 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1154 /* Hack -- "worthless" items */
1155 if (!get_object_cost(o_ptr)) return (0L);
1158 value = get_object_cost(o_ptr);
1160 /* Extract some flags */
1161 object_flags(o_ptr, &f1, &f2, &f3);
1166 artifact_type *a_ptr = &a_info[o_ptr->name1];
1168 /* Hack -- "worthless" artifacts */
1169 if (!a_ptr->cost) return (0L);
1171 /* Hack -- Use the artifact cost instead */
1172 value = a_ptr->cost;
1173 value += flag_cost(o_ptr, o_ptr->pval);
1178 else if (o_ptr->name2)
1180 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1182 /* Hack -- "worthless" ego-items */
1183 if (!e_ptr->cost) return (0L);
1185 /* Hack -- Reward the ego-item with a bonus */
1186 value += e_ptr->cost;
1187 value += flag_cost(o_ptr, o_ptr->pval);
1190 else if (o_ptr->art_flags1 || o_ptr->art_flags2 || o_ptr->art_flags3)
1192 value += flag_cost(o_ptr, o_ptr->pval);
1196 /* Analyze pval bonus */
1197 switch (o_ptr->tval)
1220 /* Hack -- Negative "pval" is always bad */
1221 if (o_ptr->pval < 0) return (0L);
1224 if (!o_ptr->pval) break;
1226 /* Give credit for stat bonuses */
1227 if (f1 & (TR1_STR)) value += (o_ptr->pval * 200L);
1228 if (f1 & (TR1_INT)) value += (o_ptr->pval * 200L);
1229 if (f1 & (TR1_WIS)) value += (o_ptr->pval * 200L);
1230 if (f1 & (TR1_DEX)) value += (o_ptr->pval * 200L);
1231 if (f1 & (TR1_CON)) value += (o_ptr->pval * 200L);
1232 if (f1 & (TR1_CHR)) value += (o_ptr->pval * 200L);
1234 /* Give credit for stealth and searching */
1235 if (f1 & (TR1_MAGIC_MASTERY)) value += (o_ptr->pval * 100L);
1236 if (f1 & (TR1_STEALTH)) value += (o_ptr->pval * 100L);
1237 if (f1 & (TR1_SEARCH)) value += (o_ptr->pval * 100L);
1239 /* Give credit for infra-vision and tunneling */
1240 if (f1 & (TR1_INFRA)) value += (o_ptr->pval * 50L);
1241 if (f1 & (TR1_TUNNEL)) value += (o_ptr->pval * 50L);
1243 /* Give credit for extra attacks */
1244 if (f1 & (TR1_BLOWS)) value += (o_ptr->pval * 5000L);
1246 /* Give credit for speed bonus */
1247 if (f1 & (TR1_SPEED)) value += (o_ptr->pval * 10000L);
1254 /* Analyze the item */
1255 switch (o_ptr->tval)
1260 /* Pay extra for charges, depending on standard number of
1261 * charges. Handle new-style wands correctly. -LM-
1263 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1270 /* Pay extra for charges, depending on standard number of
1273 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1283 /* Hack -- negative bonuses are bad */
1284 if (o_ptr->to_a < 0) return (0L);
1285 if (o_ptr->to_h < 0) return (0L);
1286 if (o_ptr->to_d < 0) return (0L);
1288 /* Give credit for bonuses */
1289 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1306 /* Hack -- negative armor bonus */
1307 if (o_ptr->to_a < 0) return (0L);
1309 /* Give credit for bonuses */
1310 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1323 /* Hack -- negative hit/damage bonuses */
1324 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1326 /* Factor in the bonuses */
1327 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1329 /* Hack -- Factor in extra damage dice */
1330 if ((o_ptr->dd > k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
1332 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 100L;
1344 /* Hack -- negative hit/damage bonuses */
1345 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1347 /* Factor in the bonuses */
1348 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1350 /* Hack -- Factor in extra damage dice */
1351 if ((o_ptr->dd > k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
1353 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1360 /* Figurines, relative to monster level */
1363 int level = r_info[o_ptr->pval].level;
1364 if (level < 20) value = level*50L;
1365 else if (level < 30) value = 1000+(level-20)*150L;
1366 else if (level < 40) value = 2500+(level-30)*350L;
1367 else if (level < 50) value = 6000+(level-40)*800L;
1368 else value = 14000+(level-50)*2000L;
1374 if (!o_ptr->pval) value = 1000L;
1375 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1381 if (!o_ptr->pval) value = 0L;
1386 /* Return the value */
1392 * Return the price of an item including plusses (and charges)
1394 * This function returns the "value" of the given item (qty one)
1396 * Never notice "unknown" bonuses or properties, including "curses",
1397 * since that would give the player information he did not have.
1399 * Note that discounted items stay discounted forever, even if
1400 * the discount is "forgotten" by the player via memory loss.
1402 s32b object_value(object_type *o_ptr)
1407 /* Unknown items -- acquire a base value */
1408 if (object_known_p(o_ptr))
1410 /* Broken items -- worthless */
1411 if (broken_p(o_ptr)) return (0L);
1413 /* Cursed items -- worthless */
1414 if (cursed_p(o_ptr)) return (0L);
1416 /* Real value (see above) */
1417 value = object_value_real(o_ptr);
1420 /* Known items -- acquire the actual value */
1423 /* Hack -- Felt broken items */
1424 if ((o_ptr->ident & (IDENT_SENSE)) && broken_p(o_ptr)) return (0L);
1426 /* Hack -- Felt cursed items */
1427 if ((o_ptr->ident & (IDENT_SENSE)) && cursed_p(o_ptr)) return (0L);
1429 /* Base value (see above) */
1430 value = object_value_base(o_ptr);
1434 /* Apply discount (if any) */
1435 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1438 /* Return the final value */
1444 * Distribute charges of rods or wands.
1446 * o_ptr = source item
1447 * q_ptr = target item, must be of the same type as o_ptr
1448 * amt = number of items that are transfered
1450 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1453 * Hack -- If rods or wands are dropped, the total maximum timeout or
1454 * charges need to be allocated between the two stacks. If all the items
1455 * are being dropped, it makes for a neater message to leave the original
1456 * stack's pval alone. -LM-
1458 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1460 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1461 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1463 /* Hack -- Rods also need to have their timeouts distributed. The
1464 * dropped stack will accept all time remaining to charge up to its
1467 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1469 if (q_ptr->pval > o_ptr->timeout)
1470 q_ptr->timeout = o_ptr->timeout;
1472 q_ptr->timeout = q_ptr->pval;
1474 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1479 void reduce_charges(object_type *o_ptr, int amt)
1482 * Hack -- If rods or wand are destroyed, the total maximum timeout or
1483 * charges of the stack needs to be reduced, unless all the items are
1484 * being destroyed. -LM-
1486 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1487 (amt < o_ptr->number))
1489 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1495 * Determine if an item can "absorb" a second item
1497 * See "object_absorb()" for the actual "absorption" code.
1499 * If permitted, we allow staffs (if they are known to have equal charges
1500 * and both are either known or confirmed empty) and wands (if both are
1501 * either known or confirmed empty) and rods (in all cases) to combine.
1502 * Staffs will unstack (if necessary) when they are used, but wands and
1503 * rods will only unstack if one is dropped. -LM-
1505 * If permitted, we allow weapons/armor to stack, if fully "known".
1507 * Missiles will combine if both stacks have the same "known" status.
1508 * This is done to make unidentified stacks of missiles useful.
1510 * Food, potions, scrolls, and "easy know" items always stack.
1512 * Chests, and activatable items, never stack (for various reasons).
1514 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1516 int total = o_ptr->number + j_ptr->number;
1519 /* Require identical object types */
1520 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1523 /* Analyze the items */
1524 switch (o_ptr->tval)
1526 /* Chests and Statues*/
1537 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return (0);
1538 if (o_ptr->pval != j_ptr->pval) return (0);
1542 /* Figurines and Corpses*/
1547 if (o_ptr->pval != j_ptr->pval) return (0);
1553 /* Food and Potions and Scrolls */
1565 /* Require either knowledge or known empty for both staffs. */
1566 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1567 !object_known_p(o_ptr)) ||
1568 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1569 !object_known_p(j_ptr))) return(0);
1571 /* Require identical charges, since staffs are bulky. */
1572 if (o_ptr->pval != j_ptr->pval) return (0);
1581 /* Require either knowledge or known empty for both wands. */
1582 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1583 !object_known_p(o_ptr)) ||
1584 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1585 !object_known_p(j_ptr))) return(0);
1587 /* Wand charges combine in O&ZAngband. */
1593 /* Staffs and Wands and Rods */
1600 /* Weapons and Armor */
1616 /* Require permission */
1617 if (!stack_allow_items) return (0);
1622 /* Rings, Amulets, Lites */
1627 /* Require full knowledge of both items */
1628 if (!object_known_p(o_ptr) || !object_known_p(j_ptr)) return (0);
1638 /* Require identical knowledge of both items */
1639 if (object_known_p(o_ptr) != object_known_p(j_ptr)) return (0);
1641 /* Require identical "bonuses" */
1642 if (o_ptr->to_h != j_ptr->to_h) return (FALSE);
1643 if (o_ptr->to_d != j_ptr->to_d) return (FALSE);
1644 if (o_ptr->to_a != j_ptr->to_a) return (FALSE);
1646 /* Require identical "pval" code */
1647 if (o_ptr->pval != j_ptr->pval) return (FALSE);
1649 /* Require identical "artifact" names */
1650 if (o_ptr->name1 != j_ptr->name1) return (FALSE);
1652 /* Random artifacts never stack */
1653 if (o_ptr->art_name || j_ptr->art_name) return (FALSE);
1655 /* Require identical "ego-item" names */
1656 if (o_ptr->name2 != j_ptr->name2) return (FALSE);
1658 /* Require identical added essence */
1659 if (o_ptr->xtra3 != j_ptr->xtra3) return (FALSE);
1660 if (o_ptr->xtra4 != j_ptr->xtra4) return (FALSE);
1662 /* Hack -- Never stack "powerful" items */
1663 if (o_ptr->xtra1 || j_ptr->xtra1) return (FALSE);
1665 /* Hack -- Never stack recharging items */
1666 if (o_ptr->timeout || j_ptr->timeout) return (FALSE);
1668 /* Require identical "values" */
1669 if (o_ptr->ac != j_ptr->ac) return (FALSE);
1670 if (o_ptr->dd != j_ptr->dd) return (FALSE);
1671 if (o_ptr->ds != j_ptr->ds) return (FALSE);
1680 /* Require knowledge */
1681 if (!object_known_p(o_ptr) || !object_known_p(j_ptr)) return (0);
1689 /* Hack -- Identical art_flags! */
1690 if ((o_ptr->art_flags1 != j_ptr->art_flags1) ||
1691 (o_ptr->art_flags2 != j_ptr->art_flags2) ||
1692 (o_ptr->art_flags3 != j_ptr->art_flags3))
1695 /* Hack -- Require identical "cursed" status */
1696 if ((o_ptr->ident & (IDENT_CURSED)) != (j_ptr->ident & (IDENT_CURSED))) return (0);
1698 /* Hack -- Require identical "broken" status */
1699 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return (0);
1702 /* Hack -- require semi-matching "inscriptions" */
1703 if (o_ptr->inscription && j_ptr->inscription &&
1704 (o_ptr->inscription != j_ptr->inscription))
1707 /* Hack -- normally require matching "inscriptions" */
1708 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return (0);
1710 /* Hack -- normally require matching "discounts" */
1711 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return (0);
1714 /* Maximal "stacking" limit */
1715 if (total >= MAX_STACK_SIZE) return (0);
1718 /* They match, so they must be similar */
1724 * Allow one item to "absorb" another, assuming they are similar
1726 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1728 int total = o_ptr->number + j_ptr->number;
1730 /* Add together the item counts */
1731 o_ptr->number = ((total < MAX_STACK_SIZE) ? total : (MAX_STACK_SIZE - 1));
1733 /* Hack -- blend "known" status */
1734 if (object_known_p(j_ptr)) object_known(o_ptr);
1736 /* Hack -- clear "storebought" if only one has it */
1737 if (((o_ptr->ident & IDENT_STOREB) || (j_ptr->ident & IDENT_STOREB)) &&
1738 (!((o_ptr->ident & IDENT_STOREB) && (j_ptr->ident & IDENT_STOREB))))
1740 if (j_ptr->ident & IDENT_STOREB) j_ptr->ident &= 0xEF;
1741 if (o_ptr->ident & IDENT_STOREB) o_ptr->ident &= 0xEF;
1744 /* Hack -- blend "mental" status */
1745 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1747 /* Hack -- blend "inscriptions" */
1748 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1750 /* Hack -- blend "feelings" */
1751 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1753 /* Hack -- could average discounts XXX XXX XXX */
1754 /* Hack -- save largest discount XXX XXX XXX */
1755 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1757 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1758 if (o_ptr->tval == TV_ROD)
1760 o_ptr->pval += j_ptr->pval;
1761 o_ptr->timeout += j_ptr->timeout;
1764 /* Hack -- if wands are stacking, combine the charges. -LM- */
1765 if (o_ptr->tval == TV_WAND)
1767 o_ptr->pval += j_ptr->pval;
1773 * Find the index of the object_kind with the given tval and sval
1775 s16b lookup_kind(int tval, int sval)
1782 for (k = 1; k < max_k_idx; k++)
1784 object_kind *k_ptr = &k_info[k];
1786 /* Require correct tval */
1787 if (k_ptr->tval != tval) continue;
1790 if (k_ptr->sval == sval) return (k);
1792 /* Ignore illegal items */
1793 if (sval != SV_ANY) continue;
1795 /* Apply the randomizer */
1796 if (!one_in_(++num)) continue;
1798 /* Use this value */
1802 /* Return this choice */
1811 msg_format("¥¢¥¤¥Æ¥à¤¬¤Ê¤¤ (%d,%d)", tval, sval);
1813 msg_format("No object (%d,%d)", tval, sval);
1824 * Wipe an object clean.
1826 void object_wipe(object_type *o_ptr)
1828 /* Wipe the structure */
1829 (void)WIPE(o_ptr, object_type);
1834 * Prepare an object based on an existing object
1836 void object_copy(object_type *o_ptr, object_type *j_ptr)
1838 /* Copy the structure */
1839 COPY(o_ptr, j_ptr, object_type);
1842 j_ptr->python = object_copy_callback(o_ptr, j_ptr);
1843 #endif /* USE_SCRIPT */
1848 * Prepare an object based on an object kind.
1850 void object_prep(object_type *o_ptr, int k_idx)
1852 object_kind *k_ptr = &k_info[k_idx];
1854 /* Clear the record */
1857 /* Save the kind index */
1858 o_ptr->k_idx = k_idx;
1860 /* Efficiency -- tval/sval */
1861 o_ptr->tval = k_ptr->tval;
1862 o_ptr->sval = k_ptr->sval;
1864 /* Default "pval" */
1865 o_ptr->pval = k_ptr->pval;
1867 /* Default number */
1870 /* Default weight */
1871 o_ptr->weight = k_ptr->weight;
1874 o_ptr->to_h = k_ptr->to_h;
1875 o_ptr->to_d = k_ptr->to_d;
1876 o_ptr->to_a = k_ptr->to_a;
1879 o_ptr->ac = k_ptr->ac;
1880 o_ptr->dd = k_ptr->dd;
1881 o_ptr->ds = k_ptr->ds;
1883 /* Hack -- worthless items are always "broken" */
1884 if (get_object_cost(o_ptr) <= 0) o_ptr->ident |= (IDENT_BROKEN);
1886 /* Hack -- cursed items are always "cursed" */
1887 if (k_ptr->flags3 & (TR3_CURSED)) o_ptr->ident |= (IDENT_CURSED);
1892 * Help determine an "enchantment bonus" for an object.
1894 * To avoid floating point but still provide a smooth distribution of bonuses,
1895 * we simply round the results of division in such a way as to "average" the
1896 * correct floating point value.
1898 * This function has been changed. It uses "randnor()" to choose values from
1899 * a normal distribution, whose mean moves from zero towards the max as the
1900 * level increases, and whose standard deviation is equal to 1/4 of the max,
1901 * and whose values are forced to lie between zero and the max, inclusive.
1903 * Since the "level" rarely passes 100 before Morgoth is dead, it is very
1904 * rare to get the "full" enchantment on an object, even a deep levels.
1906 * It is always possible (albeit unlikely) to get the "full" enchantment.
1908 * A sample distribution of values from "m_bonus(10, N)" is shown below:
1910 * N 0 1 2 3 4 5 6 7 8 9 10
1911 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
1912 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03
1913 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05
1914 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05
1915 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11
1916 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41
1917 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65
1918 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94
1919 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78
1920 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64
1921 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62
1922 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33
1923 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38
1924 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53
1925 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53
1926 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27
1927 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72
1928 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07
1930 s16b m_bonus(int max, int level)
1932 int bonus, stand, extra, value;
1935 /* Paranoia -- enforce maximal "level" */
1936 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1939 /* The "bonus" moves towards the max */
1940 bonus = ((max * level) / MAX_DEPTH);
1942 /* Hack -- determine fraction of error */
1943 extra = ((max * level) % MAX_DEPTH);
1945 /* Hack -- simulate floating point computations */
1946 if (rand_int(MAX_DEPTH) < extra) bonus++;
1949 /* The "stand" is equal to one quarter of the max */
1952 /* Hack -- determine fraction of error */
1955 /* Hack -- simulate floating point computations */
1956 if (rand_int(4) < extra) stand++;
1959 /* Choose an "interesting" value */
1960 value = randnor(bonus, stand);
1962 /* Enforce the minimum value */
1963 if (value < 0) return (0);
1965 /* Enforce the maximum value */
1966 if (value > max) return (max);
1974 * Cheat -- describe a created object for the user
1976 static void object_mention(object_type *o_ptr)
1978 char o_name[MAX_NLEN];
1981 object_desc_store(o_name, o_ptr, FALSE, 0);
1984 if (artifact_p(o_ptr))
1988 msg_format("ÅÁÀâ¤Î¥¢¥¤¥Æ¥à (%s)", o_name);
1990 msg_format("Artifact (%s)", o_name);
1995 /* Random Artifact */
1996 else if (o_ptr->art_name)
1999 msg_print("¥é¥ó¥À¥à¡¦¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È");
2001 msg_print("Random artifact");
2007 else if (ego_item_p(o_ptr))
2011 msg_format("̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à (%s)", o_name);
2013 msg_format("Ego-item (%s)", o_name);
2023 msg_format("¥¢¥¤¥Æ¥à (%s)", o_name);
2025 msg_format("Object (%s)", o_name);
2033 * Mega-Hack -- Attempt to create one of the "Special Objects"
2035 * We are only called from "make_object()", and we assume that
2036 * "apply_magic()" is called immediately after we return.
2038 * Note -- see "make_artifact()" and "apply_magic()"
2040 static bool make_artifact_special(object_type *o_ptr)
2046 /* No artifacts in the town */
2047 if (!dun_level) 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 (rand_int(d) != 0) continue;
2073 /* Artifact "rarity roll" */
2074 if (rand_int(a_ptr->rarity) != 0) 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 (rand_int(d) != 0) 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 (rand_int(d) != 0) continue;
2154 /* We must make the "rarity roll" */
2155 if (rand_int(a_ptr->rarity) != 0) 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 && level >= e_ptr->level
2187 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2190 total += (255 / e_ptr->rarity);
2194 value = randint(total);
2196 for (i = 1; i < max_e_idx; i++)
2200 if (e_ptr->slot == slot && level >= e_ptr->level
2201 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2204 value -= (255 / e_ptr->rarity);
2205 if (value <= 0L) break;
2213 * Apply magic to an item known to be a "weapon"
2215 * Hack -- note special base damage dice boosting
2216 * Hack -- note special processing for weapon/digger
2217 * Hack -- note special rating boost for dragon scale mail
2219 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2221 int tohit1 = randint(5) + m_bonus(5, level);
2222 int todam1 = randint(5) + m_bonus(5, level);
2224 int tohit2 = m_bonus(10, level);
2225 int todam2 = m_bonus(10, level);
2227 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2229 tohit2 = (tohit2+1)/2;
2230 tohit2 = (todam2+1)/2;
2239 o_ptr->to_h += tohit1;
2240 o_ptr->to_d += todam1;
2246 o_ptr->to_h += tohit2;
2247 o_ptr->to_d += todam2;
2255 o_ptr->to_h -= tohit1;
2256 o_ptr->to_d -= todam1;
2261 /* Penalize again */
2262 o_ptr->to_h -= tohit2;
2263 o_ptr->to_d -= todam2;
2266 /* Cursed (if "bad") */
2267 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->ident |= (IDENT_CURSED);
2270 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2273 switch (o_ptr->tval)
2280 if (randint(30) == 1)
2281 create_artifact(o_ptr, FALSE);
2283 /* Special Ego-item */
2284 o_ptr->name2 = EGO_DIGGING;
2288 else if (power < -1)
2290 /* Hack -- Horrible digging bonus */
2291 o_ptr->pval = 0 - (5 + randint(5));
2297 /* Hack -- Reverse digging bonus */
2298 o_ptr->pval = 0 - (o_ptr->pval);
2312 if (one_in_((o_ptr->tval == TV_POLEARM) ? 42 : 44))
2314 create_artifact(o_ptr, FALSE);
2319 /* Roll for an ego-item */
2320 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE, level);
2321 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2323 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2328 switch (o_ptr->name2)
2331 if ((randint(4) == 1) && (level > 40))
2332 o_ptr->art_flags1 |= TR1_BLOWS;
2335 if (randint(3) == 1)
2336 o_ptr->art_flags2 |= TR2_RES_POIS;
2337 random_resistance(o_ptr, FALSE, randint(22)+16);
2339 case EGO_SLAY_DRAGON:
2340 random_resistance(o_ptr, FALSE, randint(12) + 4);
2342 case EGO_KILL_DRAGON:
2343 random_resistance(o_ptr, FALSE, randint(12) + 4);
2344 if (randint(3) == 1)
2345 o_ptr->art_flags2 |= TR2_RES_POIS;
2346 random_resistance(o_ptr, FALSE, randint(14) + 4);
2348 if (randint(3) == 1)
2349 o_ptr->art_flags2 |= TR2_RES_FEAR;
2352 random_resistance(o_ptr, FALSE, (randint(34) + 4));
2354 case EGO_SLAYING_WEAPON:
2355 if (randint(3) == 1) /* double damage */
2363 while (randint(o_ptr->dd) == 1);
2369 while (randint(o_ptr->ds) == 1);
2372 if (randint(5) == 1)
2374 o_ptr->art_flags1 |= TR1_BRAND_POIS;
2376 if (o_ptr->tval == TV_SWORD && (randint(3) == 1))
2378 o_ptr->art_flags1 |= TR1_VORPAL;
2382 random_resistance(o_ptr, FALSE, (randint(22) + 16));
2383 if (randint(5) == 1)
2384 o_ptr->art_flags1 |= TR1_SLAY_DEMON;
2387 if (randint(3) == 1)
2388 o_ptr->art_flags2 |= TR2_HOLD_LIFE;
2389 if (randint(3) == 1)
2390 o_ptr->art_flags1 |= TR1_DEX;
2391 if (randint(5) == 1)
2392 o_ptr->art_flags2 |= TR2_RES_FEAR;
2393 random_resistance(o_ptr, FALSE, (randint(22) + 16));
2396 o_ptr->pval = m_bonus(5, level) + 1;
2398 case EGO_EARTHQUAKES:
2399 if ((randint(3) == 1) && (level > 60))
2400 o_ptr->art_flags1 |= TR1_BLOWS;
2402 o_ptr->pval = m_bonus(3, level);
2406 if (!o_ptr->art_name)
2408 /* Hack -- Super-charge the damage dice */
2409 while (rand_int(10L * o_ptr->dd * o_ptr->ds) == 0) o_ptr->dd++;
2411 /* Hack -- Lower the damage dice */
2412 if (o_ptr->dd > 9) o_ptr->dd = 9;
2417 else if (power < -1)
2419 /* Roll for ego-item */
2420 if (rand_int(MAX_DEPTH) < level)
2422 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE, level);
2423 switch (o_ptr->name2)
2426 if (one_in_(6)) o_ptr->art_flags3 |= TR3_TY_CURSE;
2442 create_artifact(o_ptr, FALSE);
2445 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE, level);
2447 switch (o_ptr->name2)
2449 case EGO_EXTRA_MIGHT:
2450 random_resistance(o_ptr, FALSE, rand_range(5, 38));
2466 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE, level);
2468 switch (o_ptr->name2)
2470 case EGO_SLAYING_BOLT:
2475 /* Hack -- super-charge the damage dice */
2476 while (rand_int(10L * o_ptr->dd * o_ptr->ds) == 0) o_ptr->dd++;
2478 /* Hack -- restrict the damage dice */
2479 if (o_ptr->dd > 9) o_ptr->dd = 9;
2483 else if (power < -1)
2485 /* Roll for ego-item */
2486 if (rand_int(MAX_DEPTH) < level)
2488 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE, level);
2498 static void dragon_resist(object_type * o_ptr)
2504 if (randint(4) == 1)
2505 random_resistance(o_ptr, FALSE, (randint(14) + 4));
2507 random_resistance(o_ptr, FALSE, (randint(22) + 16));
2509 while (randint(2) == 1);
2514 * Apply magic to an item known to be "armor"
2516 * Hack -- note special processing for crown/helm
2517 * Hack -- note special processing for robe of permanence
2519 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2521 int toac1 = randint(5) + m_bonus(5, level);
2523 int toac2 = m_bonus(10, level);
2531 o_ptr->to_a += toac1;
2537 o_ptr->to_a += toac2;
2545 o_ptr->to_a -= toac1;
2550 /* Penalize again */
2551 o_ptr->to_a -= toac2;
2554 /* Cursed (if "bad") */
2555 if (o_ptr->to_a < 0) o_ptr->ident |= (IDENT_CURSED);
2560 switch (o_ptr->tval)
2566 if(rand_int(50) == 1)
2567 create_artifact(o_ptr, FALSE);
2569 /* Mention the item */
2570 if (cheat_peek) object_mention(o_ptr);
2581 /* Hack -- Try for "Robes of the Magi" */
2582 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2583 (o_ptr->sval == SV_ROBE) &&
2584 (rand_int(100) < 15))
2588 o_ptr->name2 = EGO_YOIYAMI;
2589 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2590 o_ptr->sval = SV_YOIYAMI_ROBE;
2595 o_ptr->name2 = EGO_PERMANENCE;
2599 if (one_in_((o_ptr->tval == TV_HARD_ARMOR) ? 21 : 19))
2601 create_artifact(o_ptr, FALSE);
2607 bool okay_flag = TRUE;
2609 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE, level);
2611 switch (o_ptr->name2)
2613 case EGO_RESISTANCE:
2615 o_ptr->art_flags2 |= TR2_RES_POIS;
2616 random_resistance(o_ptr, FALSE, (randint(22) + 16));
2619 if (o_ptr->tval != TV_HARD_ARMOR)
2626 if (randint(4) == 1)
2627 o_ptr->art_flags1 |= TR1_CON;
2643 if (o_ptr->sval == SV_DRAGON_SHIELD)
2648 /* Mention the item */
2649 if (cheat_peek) object_mention(o_ptr);
2650 dragon_resist(o_ptr);
2651 if (randint(3) != 1) break;
2659 create_artifact(o_ptr, FALSE);
2662 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE, level);
2664 switch (o_ptr->name2)
2667 random_resistance(o_ptr, FALSE, (randint(34) + 4));
2668 if (one_in_(4)) o_ptr->art_flags2 |= TR2_RES_POIS;
2670 case EGO_REFLECTION:
2671 if (o_ptr->sval == SV_SHIELD_OF_DEFLECTION)
2681 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2686 /* Mention the item */
2687 if (cheat_peek) object_mention(o_ptr);
2688 dragon_resist(o_ptr);
2689 if (randint(3) != 1) break;
2695 create_artifact(o_ptr, FALSE);
2698 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE, level);
2700 switch (o_ptr->name2)
2703 random_resistance(o_ptr, FALSE, (randint(22) + 16));
2709 else if (power < -1)
2711 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE, level);
2719 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2724 /* Mention the item */
2725 if (cheat_peek) object_mention(o_ptr);
2726 dragon_resist(o_ptr);
2727 if (randint(3) != 1) break;
2734 create_artifact(o_ptr, FALSE);
2737 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE, level);
2739 switch (o_ptr->name2)
2741 case EGO_SLOW_DESCENT:
2744 random_resistance(o_ptr, FALSE, (randint(22) + 16));
2750 else if (power < -1)
2752 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE, level);
2765 create_artifact(o_ptr, FALSE);
2770 bool ok_flag = TRUE;
2771 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE, level);
2773 switch (o_ptr->name2)
2776 random_resistance(o_ptr, FALSE, (randint(22) + 16));
2779 random_resistance(o_ptr, FALSE, (randint(22) + 16));
2782 case EGO_REGENERATION:
2784 case EGO_LORDLINESS:
2785 random_resistance(o_ptr, FALSE, (randint(22) + 16));
2788 if (one_in_(3)) o_ptr->art_flags3 |= TR3_TELEPATHY;
2790 default:/* not existing crown (wisdom,lite, etc...) */
2794 break; /* while (1) */
2800 else if (power < -1)
2802 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE, level);
2810 if (o_ptr->sval == SV_DRAGON_HELM)
2815 /* Mention the item */
2816 if (cheat_peek) object_mention(o_ptr);
2817 dragon_resist(o_ptr);
2818 if (randint(3) != 1) break;
2826 create_artifact(o_ptr, FALSE);
2831 bool ok_flag = TRUE;
2832 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE, level);
2834 switch (o_ptr->name2)
2836 case EGO_INTELLIGENCE:
2840 case EGO_INFRAVISION:
2843 if (one_in_(7)) o_ptr->art_flags3 |= TR3_TELEPATHY;
2845 default:/* not existing helm (Magi, Might, etc...)*/
2849 break; /* while (1) */
2854 else if (power < -1)
2856 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE, level);
2863 if (o_ptr->sval == SV_ELVEN_CLOAK)
2864 o_ptr->pval = randint(4); /* No cursed elven cloaks...? */
2871 create_artifact(o_ptr, FALSE);
2874 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE, level);
2876 switch (o_ptr->name2)
2887 else if (power < -1)
2889 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE, level);
2899 * Apply magic to an item known to be a "ring" or "amulet"
2901 * Hack -- note special rating boost for ring of speed
2902 * Hack -- note special rating boost for amulet of the magi
2903 * Hack -- note special "pval boost" code for ring of speed
2904 * Hack -- note that some items must be cursed (or blessed)
2906 static void a_m_aux_3(object_type *o_ptr, int level, int power)
2911 /* Apply magic (good or bad) according to type */
2912 switch (o_ptr->tval)
2917 switch (o_ptr->sval)
2919 case SV_RING_ATTACKS:
2922 o_ptr->pval = m_bonus(2, level);
2923 if (one_in_(15)) o_ptr->pval++;
2924 if (o_ptr->pval < 1) o_ptr->pval = 1;
2930 o_ptr->ident |= (IDENT_BROKEN);
2933 o_ptr->ident |= (IDENT_CURSED);
2936 o_ptr->pval = 0 - (o_ptr->pval);
2947 /* Strength, Constitution, Dexterity, Intelligence */
2953 o_ptr->pval = 1 + m_bonus(5, level);
2959 o_ptr->ident |= (IDENT_BROKEN);
2962 o_ptr->ident |= (IDENT_CURSED);
2965 o_ptr->pval = 0 - (o_ptr->pval);
2971 /* Ring of Speed! */
2974 /* Base speed (1 to 10) */
2975 o_ptr->pval = randint(5) + m_bonus(5, level);
2977 /* Super-charge the ring */
2978 while (rand_int(100) < 50) o_ptr->pval++;
2984 o_ptr->ident |= (IDENT_BROKEN);
2987 o_ptr->ident |= (IDENT_CURSED);
2990 o_ptr->pval = 0 - (o_ptr->pval);
2998 /* Mention the item */
2999 if (cheat_peek) object_mention(o_ptr);
3004 case SV_RING_LORDLY:
3008 random_resistance(o_ptr, FALSE, randint(20) + 18);
3010 while (randint(4) == 1);
3012 /* Bonus to armor class */
3013 o_ptr->to_a = 10 + randint(5) + m_bonus(10, level);
3019 case SV_RING_SEARCHING:
3021 /* Bonus to searching */
3022 o_ptr->pval = 1 + m_bonus(5, level);
3028 o_ptr->ident |= (IDENT_BROKEN);
3031 o_ptr->ident |= (IDENT_CURSED);
3034 o_ptr->pval = 0 - (o_ptr->pval);
3040 /* Flames, Acid, Ice */
3041 case SV_RING_FLAMES:
3046 /* Bonus to armor class */
3047 o_ptr->to_a = 5 + randint(5) + m_bonus(10, level);
3051 /* Weakness, Stupidity */
3052 case SV_RING_WEAKNESS:
3053 case SV_RING_STUPIDITY:
3056 o_ptr->ident |= (IDENT_BROKEN);
3059 o_ptr->ident |= (IDENT_CURSED);
3062 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3063 if (power > 0) power = 0 - power;
3068 /* WOE, Stupidity */
3072 o_ptr->ident |= (IDENT_BROKEN);
3075 o_ptr->ident |= (IDENT_CURSED);
3078 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3079 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3080 if (power > 0) power = 0 - power;
3085 /* Ring of damage */
3086 case SV_RING_DAMAGE:
3088 /* Bonus to damage */
3089 o_ptr->to_d = 1 + randint(5) + m_bonus(16, level);
3095 o_ptr->ident |= (IDENT_BROKEN);
3098 o_ptr->ident |= (IDENT_CURSED);
3101 o_ptr->to_d = 0 - o_ptr->to_d;
3107 /* Ring of Accuracy */
3108 case SV_RING_ACCURACY:
3111 o_ptr->to_h = 1 + randint(5) + m_bonus(16, level);
3117 o_ptr->ident |= (IDENT_BROKEN);
3120 o_ptr->ident |= (IDENT_CURSED);
3123 o_ptr->to_h = 0 - o_ptr->to_h;
3129 /* Ring of Protection */
3130 case SV_RING_PROTECTION:
3132 /* Bonus to armor class */
3133 o_ptr->to_a = 5 + randint(8) + m_bonus(10, level);
3139 o_ptr->ident |= (IDENT_BROKEN);
3142 o_ptr->ident |= (IDENT_CURSED);
3145 o_ptr->to_a = 0 - o_ptr->to_a;
3151 /* Ring of Slaying */
3152 case SV_RING_SLAYING:
3154 /* Bonus to damage and to hit */
3155 o_ptr->to_d = randint(5) + m_bonus(12, level);
3156 o_ptr->to_h = randint(5) + m_bonus(12, level);
3162 o_ptr->ident |= (IDENT_BROKEN);
3165 o_ptr->ident |= (IDENT_CURSED);
3167 /* Reverse bonuses */
3168 o_ptr->to_h = 0 - o_ptr->to_h;
3169 o_ptr->to_d = 0 - o_ptr->to_d;
3175 case SV_RING_MUSCLE:
3177 o_ptr->pval = 1 + m_bonus(3, level);
3178 if (one_in_(4)) o_ptr->pval++;
3184 o_ptr->ident |= (IDENT_BROKEN);
3187 o_ptr->ident |= (IDENT_CURSED);
3189 /* Reverse bonuses */
3190 o_ptr->pval = 0 - o_ptr->pval;
3195 case SV_RING_AGGRAVATION:
3198 o_ptr->ident |= (IDENT_BROKEN);
3201 o_ptr->ident |= (IDENT_CURSED);
3203 if (power > 0) power = 0 - power;
3207 if (randint(400) == 1 && (power > 0) && !(o_ptr->ident & IDENT_CURSED) && (level > 79))
3209 o_ptr->pval = MIN(o_ptr->pval,4);
3210 /* Randart amulet */
3211 create_artifact(o_ptr, FALSE);
3213 else if ((power == 2) && one_in_(2))
3215 while(!o_ptr->name2)
3217 int tmp = m_bonus(10, level);
3218 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3222 o_ptr->name2 = EGO_RING_THROW;
3225 if (k_ptr->flags3 & TR3_REGEN) break;
3226 o_ptr->name2 = EGO_RING_REGEN;
3229 if (k_ptr->flags3 & TR3_LITE)
3230 o_ptr->name2 = EGO_RING_LITE;
3233 if (k_ptr->flags2 & TR3_TELEPORT) break;
3234 o_ptr->name2 = EGO_RING_TELEPORT;
3237 if (o_ptr->to_h) break;
3238 o_ptr->name2 = EGO_RING_TO_H;
3241 if (o_ptr->to_d) break;
3242 o_ptr->name2 = EGO_RING_TO_D;
3245 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3246 o_ptr->name2 = EGO_RING_SLAY;
3249 if ((k_ptr->flags1 & TR1_STR) || o_ptr->to_h || o_ptr->to_d) break;
3250 o_ptr->name2 = EGO_RING_WIZARD;
3253 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3254 o_ptr->name2 = EGO_RING_HERO;
3257 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3258 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3259 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3260 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3263 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3264 if (!(k_ptr->flags2 & TR2_RES_FIRE) && (k_ptr->flags2 & (TR2_RES_COLD | TR2_RES_ELEC | TR2_RES_ACID))) break;
3265 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3266 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3267 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3270 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3271 if (!(k_ptr->flags2 & TR2_RES_COLD) && (k_ptr->flags2 & (TR2_RES_FIRE | TR2_RES_ELEC | TR2_RES_ACID))) break;
3272 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3273 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3274 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3277 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3278 if (!(k_ptr->flags2 & TR2_RES_ELEC) && (k_ptr->flags2 & (TR2_RES_COLD | TR2_RES_FIRE | TR2_RES_ACID))) break;
3279 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3280 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3283 if (k_ptr->flags3 & TR3_ACTIVATE) break;
3284 if (!(k_ptr->flags2 & TR2_RES_ACID) && (k_ptr->flags2 & (TR2_RES_COLD | TR2_RES_ELEC | TR2_RES_FIRE))) break;
3285 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3286 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3288 case 21: case 22: case 23: case 24: case 25: case 26:
3289 switch (o_ptr->sval)
3292 if (!one_in_(3)) break;
3293 o_ptr->name2 = EGO_RING_D_SPEED;
3295 case SV_RING_DAMAGE:
3296 case SV_RING_ACCURACY:
3297 case SV_RING_SLAYING:
3298 if (one_in_(2)) break;
3299 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3302 o_ptr->name2 = EGO_RING_BERSERKER;
3303 o_ptr->to_h -= 2+randint(4);
3306 case SV_RING_PROTECTION:
3307 o_ptr->name2 = EGO_RING_SUPER_AC;
3308 o_ptr->to_a += m_bonus(5, level);
3310 case SV_RING_RES_FEAR:
3311 o_ptr->name2 = EGO_RING_HERO;
3314 if (one_in_(2)) break;
3315 o_ptr->name2 = EGO_RING_HUNTER;
3317 case SV_RING_SEARCHING:
3318 o_ptr->name2 = EGO_RING_STEALTH;
3320 case SV_RING_TELEPORTATION:
3321 o_ptr->name2 = EGO_RING_TELE_AWAY;
3323 case SV_RING_RES_BLINDNESS:
3325 o_ptr->name2 = EGO_RING_RES_LITE;
3327 o_ptr->name2 = EGO_RING_RES_DARK;
3329 case SV_RING_LORDLY:
3330 if (!one_in_(20)) break;
3331 random_resistance(o_ptr, FALSE, randint(20) + 18);
3332 random_resistance(o_ptr, FALSE, randint(20) + 18);
3333 o_ptr->name2 = EGO_RING_TRUE;
3335 case SV_RING_SUSTAIN:
3336 if (!one_in_(4)) break;
3337 o_ptr->name2 = EGO_RING_RES_TIME;
3339 case SV_RING_FLAMES:
3340 if (!one_in_(2)) break;
3341 o_ptr->name2 = EGO_RING_DRAGON_F;
3344 if (!one_in_(2)) break;
3345 o_ptr->name2 = EGO_RING_DRAGON_C;
3347 case SV_RING_WARNING:
3348 if (!one_in_(2)) break;
3349 o_ptr->name2 = EGO_RING_M_DETECT;
3358 o_ptr->ident &= ~(IDENT_CURSED);
3360 if (o_ptr->art_flags3 & TR3_CURSED)
3361 o_ptr->art_flags3 &= ~(TR3_CURSED);
3363 if (o_ptr->art_flags3 & TR3_HEAVY_CURSE)
3364 o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
3366 else if ((power == -2) && one_in_(2))
3368 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3369 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3370 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3371 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3372 o_ptr->art_flags1 = 0;
3373 o_ptr->art_flags2 = 0;
3374 while(!o_ptr->name2)
3376 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3380 if (k_ptr->flags3 & TR3_DRAIN_EXP) break;
3381 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3384 o_ptr->name2 = EGO_RING_NO_MELEE;
3387 if (k_ptr->flags3 & TR3_AGGRAVATE) break;
3388 o_ptr->name2 = EGO_RING_AGGRAVATE;
3391 if (k_ptr->flags3 & TR3_TY_CURSE) break;
3392 o_ptr->name2 = EGO_RING_TY_CURSE;
3395 o_ptr->name2 = EGO_RING_ALBINO;
3400 o_ptr->ident |= (IDENT_BROKEN);
3403 o_ptr->ident |= (IDENT_CURSED);
3411 switch (o_ptr->sval)
3413 /* Amulet of wisdom/charisma */
3414 case SV_AMULET_INTELLIGENCE:
3415 case SV_AMULET_WISDOM:
3416 case SV_AMULET_CHARISMA:
3418 o_ptr->pval = 1 + m_bonus(5, level);
3424 o_ptr->ident |= (IDENT_BROKEN);
3427 o_ptr->ident |= (IDENT_CURSED);
3429 /* Reverse bonuses */
3430 o_ptr->pval = 0 - o_ptr->pval;
3436 /* Amulet of brilliance */
3437 case SV_AMULET_BRILLIANCE:
3439 o_ptr->pval = 1 + m_bonus(3, level);
3440 if (one_in_(4)) o_ptr->pval++;
3446 o_ptr->ident |= (IDENT_BROKEN);
3449 o_ptr->ident |= (IDENT_CURSED);
3451 /* Reverse bonuses */
3452 o_ptr->pval = 0 - o_ptr->pval;
3458 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3462 o_ptr->ident |= (IDENT_CURSED);
3467 case SV_AMULET_RESISTANCE:
3469 if (randint(3) == 1) random_resistance(o_ptr, FALSE, (randint(34) + 4));
3470 if (randint(5) == 1) o_ptr->art_flags2 |= TR2_RES_POIS;
3474 /* Amulet of searching */
3475 case SV_AMULET_SEARCHING:
3477 o_ptr->pval = randint(2) + m_bonus(4, level);
3483 o_ptr->ident |= (IDENT_BROKEN);
3486 o_ptr->ident |= (IDENT_CURSED);
3488 /* Reverse bonuses */
3489 o_ptr->pval = 0 - (o_ptr->pval);
3495 /* Amulet of the Magi -- never cursed */
3496 case SV_AMULET_THE_MAGI:
3498 o_ptr->pval = randint(5) + m_bonus(5, level);
3499 o_ptr->to_a = randint(5) + m_bonus(5, level);
3501 /* Boost the rating */
3504 /* Mention the item */
3505 if (cheat_peek) object_mention(o_ptr);
3510 /* Amulet of Doom -- always cursed */
3511 case SV_AMULET_DOOM:
3514 o_ptr->ident |= (IDENT_BROKEN);
3517 o_ptr->ident |= (IDENT_CURSED);
3520 o_ptr->pval = 0 - (randint(5) + m_bonus(5, level));
3521 o_ptr->to_a = 0 - (randint(5) + m_bonus(5, level));
3522 if (power > 0) power = 0 - power;
3527 case SV_AMULET_MAGIC_MASTERY:
3529 o_ptr->pval = 1 + m_bonus(4, level);
3535 o_ptr->ident |= (IDENT_BROKEN);
3538 o_ptr->ident |= (IDENT_CURSED);
3540 /* Reverse bonuses */
3541 o_ptr->pval = 0 - o_ptr->pval;
3547 if (randint(150) == 1 && (power > 0) && !(o_ptr->ident & IDENT_CURSED) && (level > 79))
3549 o_ptr->pval = MIN(o_ptr->pval,4);
3550 /* Randart amulet */
3551 create_artifact(o_ptr, FALSE);
3553 else if ((power == 2) && one_in_(2))
3555 while(!o_ptr->name2)
3557 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3561 if (k_ptr->flags3 & TR3_SLOW_DIGEST) break;
3562 o_ptr->name2 = EGO_AMU_SLOW_D;
3565 if (o_ptr->pval) break;
3566 o_ptr->name2 = EGO_AMU_INFRA;
3569 if (k_ptr->flags3 & TR3_SEE_INVIS) break;
3570 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3573 if (k_ptr->flags2 & TR2_HOLD_LIFE) break;
3574 o_ptr->name2 = EGO_AMU_HOLD_LIFE;
3577 if (k_ptr->flags3 & TR3_FEATHER) break;
3578 o_ptr->name2 = EGO_AMU_LEVITATION;
3580 case 10: case 11: case 21:
3581 o_ptr->name2 = EGO_AMU_AC;
3584 if (k_ptr->flags2 & TR2_RES_FIRE) break;
3585 if (m_bonus(10, level) > 8)
3586 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3588 o_ptr->name2 = EGO_AMU_RES_FIRE;
3591 if (k_ptr->flags2 & TR2_RES_COLD) break;
3592 if (m_bonus(10, level) > 8)
3593 o_ptr->name2 = EGO_AMU_RES_COLD_;
3595 o_ptr->name2 = EGO_AMU_RES_COLD;
3598 if (k_ptr->flags2 & TR2_RES_ELEC) break;
3599 if (m_bonus(10, level) > 8)
3600 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3602 o_ptr->name2 = EGO_AMU_RES_ELEC;
3605 if (k_ptr->flags2 & TR2_RES_ACID) break;
3606 if (m_bonus(10, level) > 8)
3607 o_ptr->name2 = EGO_AMU_RES_ACID_;
3609 o_ptr->name2 = EGO_AMU_RES_ACID;
3611 case 16: case 17: case 18: case 19: case 20:
3612 switch (o_ptr->sval)
3614 case SV_AMULET_TELEPORT:
3615 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3616 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3617 else o_ptr->name2 = EGO_AMU_TELEPORT;
3619 case SV_AMULET_RESIST_ACID:
3620 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3622 case SV_AMULET_SEARCHING:
3623 o_ptr->name2 = EGO_AMU_STEALTH;
3625 case SV_AMULET_BRILLIANCE:
3626 if (!one_in_(3)) break;
3627 o_ptr->name2 = EGO_AMU_IDENT;
3629 case SV_AMULET_CHARISMA:
3630 if (!one_in_(3)) break;
3631 o_ptr->name2 = EGO_AMU_CHARM;
3633 case SV_AMULET_THE_MAGI:
3634 if (one_in_(2)) break;
3635 o_ptr->name2 = EGO_AMU_GREAT;
3637 case SV_AMULET_RESISTANCE:
3638 if (!one_in_(5)) break;
3639 o_ptr->name2 = EGO_AMU_DEFENDER;
3641 case SV_AMULET_TELEPATHY:
3642 if (!one_in_(3)) break;
3643 o_ptr->name2 = EGO_AMU_DETECTION;
3649 o_ptr->ident &= ~(IDENT_CURSED);
3651 if (o_ptr->art_flags3 & TR3_CURSED)
3652 o_ptr->art_flags3 &= ~(TR3_CURSED);
3654 if (o_ptr->art_flags3 & TR3_HEAVY_CURSE)
3655 o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
3657 else if ((power == -2) && one_in_(2))
3659 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3660 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3661 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3662 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3663 o_ptr->art_flags1 = 0;
3664 o_ptr->art_flags2 = 0;
3665 while(!o_ptr->name2)
3667 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3671 if (k_ptr->flags3 & TR3_DRAIN_EXP) break;
3672 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3675 o_ptr->name2 = EGO_AMU_FOOL;
3678 if (k_ptr->flags3 & TR3_AGGRAVATE) break;
3679 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3682 if (k_ptr->flags3 & TR3_TY_CURSE) break;
3683 o_ptr->name2 = EGO_AMU_TY_CURSE;
3686 o_ptr->name2 = EGO_AMU_NAIVETY;
3691 o_ptr->ident |= (IDENT_BROKEN);
3694 o_ptr->ident |= (IDENT_CURSED);
3703 * Hack -- help pick an item type
3705 static bool item_monster_okay(int r_idx)
3707 monster_race *r_ptr = &r_info[r_idx];
3710 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3711 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3712 if (r_ptr->flags3 & RF3_RES_ALL) return (FALSE);
3713 if (r_ptr->flags7 & RF7_UNIQUE_7) return (FALSE);
3714 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3715 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3723 * Apply magic to an item known to be "boring"
3725 * Hack -- note the special code for various items
3727 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3729 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3731 /* Apply magic (good or bad) according to type */
3732 switch (o_ptr->tval)
3741 o_ptr->ident |= (IDENT_BROKEN);
3744 o_ptr->ident |= (IDENT_CURSED);
3751 o_ptr->xtra4 = o_ptr->pval;
3757 /* Hack -- Torches -- random fuel */
3758 if (o_ptr->sval == SV_LITE_TORCH)
3760 if (o_ptr->pval > 0) o_ptr->xtra4 = randint(o_ptr->pval);
3764 /* Hack -- Lanterns -- random fuel */
3765 if (o_ptr->sval == SV_LITE_LANTERN)
3767 if (o_ptr->pval > 0) o_ptr->xtra4 = randint(o_ptr->pval);
3771 if ((power == 2) || ((power == 1) && one_in_(3)))
3773 while (!o_ptr->name2)
3777 bool okay_flag = TRUE;
3779 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE, level);
3781 switch (o_ptr->name2)
3784 if (o_ptr->sval == SV_LITE_FEANOR)
3792 else if (power == -2)
3794 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE, level);
3796 switch (o_ptr->name2)
3798 case EGO_LITE_DARKNESS:
3810 /* The wand or staff gets a number of initial charges equal
3811 * to between 1/2 (+1) and the full object kind's pval. -LM-
3813 o_ptr->pval = k_ptr->pval / 2 + randint((k_ptr->pval + 1) / 2);
3819 /* Transfer the pval. -LM- */
3820 o_ptr->pval = k_ptr->pval;
3827 object_aware(o_ptr);
3828 object_known(o_ptr);
3837 monster_race *r_ptr;
3839 /* Pick a random non-unique monster race */
3842 i = randint(max_r_idx - 1);
3844 if (!item_monster_okay(i)) continue;
3845 if (i == MON_TSUCHINOKO) continue;
3849 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
3851 /* Ignore dead monsters */
3852 if (!r_ptr->rarity) continue;
3854 /* Prefer less out-of-depth monsters */
3855 if (rand_int(check)) continue;
3862 /* Some figurines are cursed */
3863 if (one_in_(6)) o_ptr->ident |= IDENT_CURSED;
3868 msg_format("%s¤Î¿Í·Á, ¿¼¤µ +%d%s",
3870 msg_format("Figurine of %s, depth +%d%s",
3873 r_name + r_ptr->name, check - 1,
3874 !(o_ptr->ident & IDENT_CURSED) ? "" : " {cursed}");
3887 monster_race *r_ptr;
3889 if (o_ptr->sval == SV_SKELETON)
3891 match = RF9_DROP_SKELETON;
3893 else if (o_ptr->sval == SV_CORPSE)
3895 match = RF9_DROP_CORPSE;
3898 /* Hack -- Remove the monster restriction */
3899 get_mon_num_prep(item_monster_okay, NULL);
3901 /* Pick a random non-unique monster race */
3904 i = get_mon_num(dun_level);
3908 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
3910 /* Ignore dead monsters */
3911 if (!r_ptr->rarity) continue;
3913 /* Ignore corpseless monsters */
3914 if (!(r_ptr->flags9 & match)) continue;
3916 /* Prefer less out-of-depth monsters */
3917 if (rand_int(check)) continue;
3927 msg_format("%s¤Î»àÂÎ,¿¼¤µ +%d",
3929 msg_format("Corpse of %s, depth +%d",
3932 r_name + r_ptr->name, check - 1);
3935 object_aware(o_ptr);
3936 object_known(o_ptr);
3944 monster_race *r_ptr;
3946 /* Pick a random monster race */
3949 i = randint(max_r_idx - 1);
3953 /* Ignore dead monsters */
3954 if (!r_ptr->rarity) continue;
3964 msg_format("%s¤ÎÁü,", r_name + r_ptr->name);
3966 msg_format("Statue of %s", r_name + r_ptr->name);
3970 object_aware(o_ptr);
3971 object_known(o_ptr);
3978 byte obj_level = get_object_level(o_ptr);
3980 /* Hack -- skip ruined chests */
3981 if (obj_level <= 0) break;
3983 /* Hack -- pick a "difficulty" */
3984 o_ptr->pval = randint(obj_level);
3985 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
3987 o_ptr->xtra3 = dun_level + 5;
3989 /* Never exceed "difficulty" of 55 to 59 */
3990 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)rand_int(5);
3999 * Complete the "creation" of an object by applying "magic" to the item
4001 * This includes not only rolling for random bonuses, but also putting the
4002 * finishing touches on ego-items and artifacts, giving charges to wands and
4003 * staffs, giving fuel to lites, and placing traps on chests.
4005 * In particular, note that "Instant Artifacts", if "created" by an external
4006 * routine, must pass through this function to complete the actual creation.
4008 * The base "chance" of the item being "good" increases with the "level"
4009 * parameter, which is usually derived from the dungeon level, being equal
4010 * to the level plus 10, up to a maximum of 75. If "good" is true, then
4011 * the object is guaranteed to be "good". If an object is "good", then
4012 * the chance that the object will be "great" (ego-item or artifact), also
4013 * increases with the "level", being equal to half the level, plus 5, up to
4014 * a maximum of 20. If "great" is true, then the object is guaranteed to be
4015 * "great". At dungeon level 65 and below, 15/100 objects are "great".
4017 * If the object is not "good", there is a chance it will be "cursed", and
4018 * if it is "cursed", there is a chance it will be "broken". These chances
4019 * are related to the "good" / "great" chances above.
4021 * Otherwise "normal" rings and amulets will be "good" half the time and
4022 * "cursed" half the time, unless the ring/amulet is always good or cursed.
4024 * If "okay" is true, and the object is going to be "great", then there is
4025 * a chance that an artifact will be created. This is true even if both the
4026 * "good" and "great" arguments are false. As a total hack, if "great" is
4027 * true, then the item gets 3 extra "attempts" to become an artifact.
4029 void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great, bool curse)
4032 int i, rolls, f1, f2, power;
4034 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += rand_int(p_ptr->lev/2+10);
4036 /* Maximum "level" for various things */
4037 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4039 /* Base chance of being "good" */
4042 /* Maximal chance of being "good" */
4043 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4045 /* Base chance of being "great" */
4048 /* Maximal chance of being "great" */
4049 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4050 f2 = d_info[dungeon_type].obj_great;
4052 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4057 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4066 /* Roll for "good" */
4067 if (good || magik(f1))
4072 /* Roll for "great" */
4073 if (great || magik(f2)) power = 2;
4076 /* Roll for "cursed" */
4079 /* Assume "cursed" */
4082 /* Roll for "broken" */
4083 if (magik(f2)) power = -2;
4089 /* Assume 'cursed' */
4094 /* Everything else gets more badly cursed */
4101 /* Assume no rolls */
4104 /* Get one roll if excellent */
4105 if (power >= 2) rolls = 1;
4107 /* Hack -- Get four rolls if forced great */
4108 if (great) rolls = 4;
4110 /* Hack -- Get no rolls if not allowed */
4111 if (!okay || o_ptr->name1) rolls = 0;
4113 /* Roll for artifacts if allowed */
4114 for (i = 0; i < rolls; i++)
4116 /* Roll for an artifact */
4117 if (make_artifact(o_ptr)) break;
4118 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4120 if (make_artifact(o_ptr)) break;
4125 /* Hack -- analyze artifacts */
4128 artifact_type *a_ptr = &a_info[o_ptr->name1];
4130 /* Hack -- Mark the artifact as "created" */
4133 /* Extract the other fields */
4134 o_ptr->pval = a_ptr->pval;
4135 o_ptr->ac = a_ptr->ac;
4136 o_ptr->dd = a_ptr->dd;
4137 o_ptr->ds = a_ptr->ds;
4138 o_ptr->to_a = a_ptr->to_a;
4139 o_ptr->to_h = a_ptr->to_h;
4140 o_ptr->to_d = a_ptr->to_d;
4141 o_ptr->weight = a_ptr->weight;
4143 /* Hack -- extract the "broken" flag */
4144 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4146 /* Hack -- extract the "cursed" flag */
4147 if (a_ptr->flags3 & TR3_CURSED) o_ptr->ident |= (IDENT_CURSED);
4149 /* Mega-Hack -- increase the rating */
4152 /* Mega-Hack -- increase the rating again */
4153 if (a_ptr->cost > 50000L) rating += 10;
4155 /* Mega-Hack -- increase the rating again */
4156 if (a_ptr->cost > 100000L) rating += 10;
4158 /* Set the good item flag */
4159 good_item_flag = TRUE;
4161 /* Cheat -- peek at the item */
4162 if (cheat_peek) object_mention(o_ptr);
4170 switch (o_ptr->tval)
4179 if (power) a_m_aux_1(o_ptr, lev, power);
4185 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4191 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4207 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4208 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4209 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4210 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)) ||
4211 ((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)))
4212 a_m_aux_2(o_ptr, lev, power);
4214 if (power) a_m_aux_2(o_ptr, lev, power);
4222 if (!power && (rand_int(100) < 50)) power = -1;
4223 a_m_aux_3(o_ptr, lev, power);
4229 a_m_aux_4(o_ptr, lev, power);
4234 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4235 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4236 (p_ptr->pseikaku == SEIKAKU_SEXY))
4239 o_ptr->art_flags1 |= (TR1_STR | TR1_INT | TR1_WIS | TR1_DEX | TR1_CON | TR1_CHR);
4242 if (o_ptr->art_name) rating += 30;
4244 /* Hack -- analyze ego-items */
4245 else if (o_ptr->name2)
4247 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4249 /* Hack -- extra powers */
4250 switch (o_ptr->name2)
4252 /* Weapon (Holy Avenger) */
4255 o_ptr->xtra1 = EGO_XTRA_SUSTAIN;
4259 /* Weapon (Defender) */
4262 o_ptr->xtra1 = EGO_XTRA_SUSTAIN;
4266 /* Weapon (Blessed) */
4267 case EGO_BLESS_BLADE:
4269 o_ptr->xtra1 = EGO_XTRA_ABILITY;
4276 if (randint(7) == 1) o_ptr->xtra1 = EGO_XTRA_ABILITY;
4280 /* Robe of Permanance */
4281 case EGO_PERMANENCE:
4283 o_ptr->xtra1 = EGO_XTRA_POWER;
4287 /* Armor of Elvenkind */
4290 o_ptr->xtra1 = EGO_XTRA_POWER;
4294 /* Crown of the Magi */
4297 o_ptr->xtra1 = EGO_XTRA_ABILITY;
4304 o_ptr->xtra1 = EGO_XTRA_POWER;
4310 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
4311 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
4316 /* Randomize the "xtra" power */
4317 if (o_ptr->xtra1 && !o_ptr->art_name)
4318 o_ptr->xtra2 = randint(256);
4320 /* Hack -- acquire "broken" flag */
4321 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4323 /* Hack -- acquire "cursed" flag */
4324 if (e_ptr->flags3 & (TR3_CURSED)) o_ptr->ident |= (IDENT_CURSED);
4326 /* Hack -- apply extra penalties if needed */
4327 if (cursed_p(o_ptr) || broken_p(o_ptr))
4329 /* Hack -- obtain bonuses */
4330 if (e_ptr->max_to_h) o_ptr->to_h -= randint(e_ptr->max_to_h);
4331 if (e_ptr->max_to_d) o_ptr->to_d -= randint(e_ptr->max_to_d);
4332 if (e_ptr->max_to_a) o_ptr->to_a -= randint(e_ptr->max_to_a);
4334 /* Hack -- obtain pval */
4335 if (e_ptr->max_pval) o_ptr->pval -= randint(e_ptr->max_pval);
4338 /* Hack -- apply extra bonuses if needed */
4341 /* Hack -- obtain bonuses */
4342 if (e_ptr->max_to_h)
4344 if (e_ptr->max_to_h > 127)
4345 o_ptr->to_h -= randint(256-e_ptr->max_to_h);
4346 else o_ptr->to_h += randint(e_ptr->max_to_h);
4348 if (e_ptr->max_to_d)
4350 if (e_ptr->max_to_d > 127)
4351 o_ptr->to_d -= randint(256-e_ptr->max_to_d);
4352 else o_ptr->to_d += randint(e_ptr->max_to_d);
4354 if (e_ptr->max_to_a)
4356 if (e_ptr->max_to_a > 127)
4357 o_ptr->to_a -= randint(256-e_ptr->max_to_a);
4358 else o_ptr->to_a += randint(e_ptr->max_to_a);
4361 /* Hack -- obtain pval */
4362 if (e_ptr->max_pval)
4364 if ((o_ptr->name2 == EGO_HA) && (o_ptr->art_flags1 & TR1_BLOWS))
4367 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4369 else if (o_ptr->name2 == EGO_ATTACKS)
4371 o_ptr->pval = randint(e_ptr->max_pval*lev/100+1);
4372 if (o_ptr->pval > 3) o_ptr->pval = 3;
4373 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4374 o_ptr->pval += randint(2);
4376 else if (o_ptr->name2 == EGO_BAT)
4378 o_ptr->pval = randint(e_ptr->max_pval);
4379 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint(2);
4383 o_ptr->pval += randint(e_ptr->max_pval);
4386 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4388 o_ptr->pval = randint(o_ptr->pval);
4390 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4394 /* Hack -- apply rating bonus */
4395 rating += e_ptr->rating;
4397 /* Cheat -- describe the item */
4398 if (cheat_peek) object_mention(o_ptr);
4404 /* Examine real objects */
4407 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4409 /* Hack -- acquire "broken" flag */
4410 if (!get_object_cost(o_ptr)) o_ptr->ident |= (IDENT_BROKEN);
4412 /* Hack -- acquire "cursed" flag */
4413 if (k_ptr->flags3 & (TR3_CURSED)) o_ptr->ident |= (IDENT_CURSED);
4419 * Hack -- determine if a template is "good"
4421 static bool kind_is_good(int k_idx)
4423 object_kind *k_ptr = &k_info[k_idx];
4425 /* Analyze the item type */
4426 switch (k_ptr->tval)
4428 /* Armor -- Good unless damaged */
4439 if (k_ptr->to_a < 0) return (FALSE);
4443 /* Weapons -- Good unless damaged */
4450 if (k_ptr->to_h < 0) return (FALSE);
4451 if (k_ptr->to_d < 0) return (FALSE);
4455 /* Ammo -- Arrows/Bolts are good */
4462 /* Books -- High level books are good (except Arcane books) */
4464 case TV_SORCERY_BOOK:
4465 case TV_NATURE_BOOK:
4469 case TV_ENCHANT_BOOK:
4470 case TV_DAEMON_BOOK:
4472 case TV_HISSATSU_BOOK:
4474 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4478 /* Rings -- Rings of Speed are good */
4481 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4482 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4486 /* Amulets -- Amulets of the Magi and Resistance are good */
4489 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4490 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4495 /* Assume not good */
4501 * Attempt to make an object (normal or good/great)
4503 * This routine plays nasty games to generate the "special artifacts".
4505 * This routine uses "object_level" for the "generation level".
4507 * We assume that the given object has been "wiped".
4509 bool make_object(object_type *j_ptr, bool good, bool great)
4515 /* Chance of "special object" */
4516 prob = (good ? 10 : 1000);
4518 /* Base level for the object */
4519 base = (good ? (object_level + 10) : object_level);
4522 /* Generate a special object, or a normal object */
4523 if ((rand_int(prob) != 0) || !make_artifact_special(j_ptr))
4530 /* Activate restriction */
4531 get_obj_num_hook = kind_is_good;
4533 /* Prepare allocation table */
4537 /* Pick a random object */
4538 k_idx = get_obj_num(base);
4541 if (get_obj_num_hook)
4543 /* Clear restriction */
4544 get_obj_num_hook = NULL;
4546 /* Prepare allocation table */
4550 /* Handle failure */
4551 if (!k_idx) return (FALSE);
4553 /* Prepare the object */
4554 object_prep(j_ptr, k_idx);
4557 /* Apply magic (allow artifacts) */
4558 apply_magic(j_ptr, object_level, TRUE, good, great, FALSE);
4560 /* Hack -- generate multiple spikes/missiles */
4561 switch (j_ptr->tval)
4569 j_ptr->number = (byte)damroll(6, 7);
4573 obj_level = get_object_level(j_ptr);
4574 if (artifact_p(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4576 /* Notice "okay" out-of-depth objects */
4577 if (!cursed_p(j_ptr) && !broken_p(j_ptr) &&
4578 (obj_level > dun_level))
4580 /* Rating increase */
4581 rating += (obj_level - dun_level);
4583 /* Cheat -- peek at items */
4584 if (cheat_peek) object_mention(j_ptr);
4593 * Attempt to place an object (normal or good/great) at the given location.
4595 * This routine plays nasty games to generate the "special artifacts".
4597 * This routine uses "object_level" for the "generation level".
4599 * This routine requires a clean floor grid destination.
4601 void place_object(int y, int x, bool good, bool great)
4611 /* Paranoia -- check bounds */
4612 if (!in_bounds(y, x)) return;
4614 /* Require clean floor space */
4615 if (!cave_clean_bold(y, x)) return;
4618 /* Get local object */
4621 /* Wipe the object */
4624 /* Make an object (if possible) */
4625 if (!make_object(q_ptr, good, great)) return;
4628 /* Make an object */
4636 /* Acquire object */
4637 o_ptr = &o_list[o_idx];
4639 /* Structure Copy */
4640 object_copy(o_ptr, q_ptr);
4647 c_ptr = &cave[y][x];
4650 o_ptr->next_o_idx = c_ptr->o_idx;
4652 /* Place the object */
4653 c_ptr->o_idx = o_idx;
4656 o_ptr->python = object_create_callback(o_ptr);
4657 #endif /* USE_SCRIPT */
4667 /* Hack -- Preserve artifacts */
4670 a_info[q_ptr->name1].cur_num = 0;
4677 * Make a treasure object
4679 * The location must be a legal, clean, floor grid.
4681 bool make_gold(object_type *j_ptr)
4688 /* Hack -- Pick a Treasure variety */
4689 i = ((randint(object_level + 2) + 2) / 2) - 1;
4691 /* Apply "extra" magic */
4692 if (rand_int(GREAT_OBJ) == 0)
4694 i += randint(object_level + 1);
4697 /* Hack -- Creeping Coins only generate "themselves" */
4698 if (coin_type) i = coin_type;
4700 /* Do not create "illegal" Treasure Types */
4701 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4703 /* Prepare a gold object */
4704 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4706 /* Hack -- Base coin cost */
4707 base = k_info[OBJ_GOLD_LIST+i].cost;
4709 /* Determine how much the treasure is "worth" */
4710 j_ptr->pval = (base + (8L * randint(base)) + randint(8));
4718 * Places a treasure (Gold or Gems) at given location
4720 * The location must be a legal, clean, floor grid.
4722 void place_gold(int y, int x)
4732 /* Paranoia -- check bounds */
4733 if (!in_bounds(y, x)) return;
4735 /* Require clean floor space */
4736 if (!cave_clean_bold(y, x)) return;
4739 /* Get local object */
4742 /* Wipe the object */
4745 /* Make some gold */
4746 if (!make_gold(q_ptr)) return;
4749 /* Make an object */
4757 /* Acquire object */
4758 o_ptr = &o_list[o_idx];
4760 /* Copy the object */
4761 object_copy(o_ptr, q_ptr);
4768 c_ptr = &cave[y][x];
4771 o_ptr->next_o_idx = c_ptr->o_idx;
4773 /* Place the object */
4774 c_ptr->o_idx = o_idx;
4777 o_ptr->python = object_create_callback(o_ptr);
4778 #endif /* USE_SCRIPT */
4790 * Let an object fall to the ground at or near a location.
4792 * The initial location is assumed to be "in_bounds()".
4794 * This function takes a parameter "chance". This is the percentage
4795 * chance that the item will "disappear" instead of drop. If the object
4796 * has been thrown, then this is the chance of disappearance on contact.
4798 * Hack -- this function uses "chance" to determine if it should produce
4799 * some form of "description" of the drop event (under the player).
4801 * We check several locations to see if we can find a location at which
4802 * the object can combine, stack, or be placed. Artifacts will try very
4803 * hard to be placed, including "teleporting" to a useful grid if needed.
4805 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
4816 s16b this_o_idx, next_o_idx = 0;
4820 char o_name[MAX_NLEN];
4825 bool plural = FALSE;
4828 /* Extract plural */
4829 if (j_ptr->number != 1) plural = TRUE;
4831 /* Describe object */
4832 object_desc(o_name, j_ptr, FALSE, 0);
4835 /* Handle normal "breakage" */
4836 if (!(j_ptr->art_name || artifact_p(j_ptr)) && (rand_int(100) < chance))
4840 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
4842 msg_format("The %s disappear%s.",
4843 o_name, (plural ? "" : "s"));
4849 if (wizard) msg_print("(ÇË»)");
4851 if (wizard) msg_print("(breakage)");
4870 /* Scan local grids */
4871 for (dy = -3; dy <= 3; dy++)
4873 /* Scan local grids */
4874 for (dx = -3; dx <= 3; dx++)
4878 /* Calculate actual distance */
4879 d = (dy * dy) + (dx * dx);
4881 /* Ignore distant grids */
4882 if (d > 10) continue;
4888 /* Skip illegal grids */
4889 if (!in_bounds(ty, tx)) continue;
4891 /* Require line of sight */
4892 if (!los(y, x, ty, tx)) continue;
4895 c_ptr = &cave[ty][tx];
4897 /* Require floor space */
4898 if ((c_ptr->feat != FEAT_FLOOR) &&
4899 (c_ptr->feat != FEAT_SHAL_WATER) &&
4900 (c_ptr->feat != FEAT_GRASS) &&
4901 (c_ptr->feat != FEAT_DIRT) &&
4902 (c_ptr->feat != FEAT_FLOWER) &&
4903 (c_ptr->feat != FEAT_DEEP_GRASS) &&
4904 (c_ptr->feat != FEAT_SHAL_LAVA) &&
4905 (c_ptr->feat != FEAT_TREES)) continue;
4907 if (c_ptr->info & CAVE_TRAP) continue;
4912 /* Scan objects in that grid */
4913 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
4917 /* Acquire object */
4918 o_ptr = &o_list[this_o_idx];
4920 /* Acquire next object */
4921 next_o_idx = o_ptr->next_o_idx;
4923 /* Check for possible combination */
4924 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
4930 /* Add new object */
4934 if (k > 99) continue;
4936 /* Calculate score */
4937 s = 1000 - (d + k * 5);
4939 /* Skip bad values */
4940 if (s < bs) continue;
4942 /* New best value */
4945 /* Apply the randomizer to equivalent values */
4946 if ((++bn >= 2) && (rand_int(bn) != 0)) continue;
4961 /* Handle lack of space */
4962 if (!flag && !(artifact_p(j_ptr) || j_ptr->art_name))
4966 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
4968 msg_format("The %s disappear%s.",
4969 o_name, (plural ? "" : "s"));
4975 if (wizard) msg_print("(¾²¥¹¥Ú¡¼¥¹¤¬¤Ê¤¤)");
4977 if (wizard) msg_print("(no floor space)");
4987 for (i = 0; !flag; i++)
4992 ty = rand_spread(by, 1);
4993 tx = rand_spread(bx, 1);
4996 /* Random locations */
4999 ty = rand_int(cur_hgt);
5000 tx = rand_int(cur_wid);
5004 c_ptr = &cave[ty][tx];
5006 /* Require floor space (or shallow terrain) -KMW- */
5007 if ((c_ptr->feat != FEAT_FLOOR) &&
5008 (c_ptr->feat != FEAT_SHAL_WATER) &&
5009 (c_ptr->feat != FEAT_GRASS) &&
5010 (c_ptr->feat != FEAT_DIRT) &&
5011 (c_ptr->feat != FEAT_SHAL_LAVA)) continue;
5013 /* Bounce to that location */
5017 /* Require floor space */
5018 if (!cave_clean_bold(by, bx)) continue;
5026 c_ptr = &cave[by][bx];
5028 /* Scan objects in that grid for combination */
5029 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5033 /* Acquire object */
5034 o_ptr = &o_list[this_o_idx];
5036 /* Acquire next object */
5037 next_o_idx = o_ptr->next_o_idx;
5039 /* Check for combination */
5040 if (object_similar(o_ptr, j_ptr))
5042 /* Combine the items */
5043 object_absorb(o_ptr, j_ptr);
5053 /* Get new object */
5054 if (!done) o_idx = o_pop();
5057 if (!done && !o_idx)
5061 msg_format("%s¤Ï¾Ã¤¨¤¿¡£", o_name);
5063 msg_format("The %s disappear%s.",
5064 o_name, (plural ? "" : "s"));
5070 if (wizard) msg_print("(¥¢¥¤¥Æ¥à¤¬Â¿²á¤®¤ë)");
5072 if (wizard) msg_print("(too many objects)");
5076 /* Hack -- Preserve artifacts */
5079 a_info[j_ptr->name1].cur_num = 0;
5089 /* Structure copy */
5090 object_copy(&o_list[o_idx], j_ptr);
5092 /* Access new object */
5093 j_ptr = &o_list[o_idx];
5100 j_ptr->held_m_idx = 0;
5103 j_ptr->next_o_idx = c_ptr->o_idx;
5105 /* Place the object */
5106 c_ptr->o_idx = o_idx;
5121 /* Mega-Hack -- no message if "dropped" by player */
5122 /* Message when an object falls under the player */
5123 if (chance && (by == py) && (bx == px))
5126 msg_print("²¿¤«¤¬Â²¼¤Ëž¤¬¤Ã¤Æ¤¤¿¡£");
5128 msg_print("You feel something roll beneath your feet.");
5141 * Scatter some "great" objects near the player
5143 void acquirement(int y1, int x1, int num, bool great, bool known)
5146 object_type object_type_body;
5151 /* Get local object */
5152 i_ptr = &object_type_body;
5154 /* Wipe the object */
5157 /* Make a good (or great) object (if possible) */
5158 if (!make_object(i_ptr, TRUE, great)) continue;
5162 object_aware(i_ptr);
5163 object_known(i_ptr);
5167 i_ptr->python = object_create_callback(i_ptr);
5168 #endif /* USE_SCRIPT */
5170 /* Drop the object */
5171 (void)drop_near(i_ptr, -1, y1, x1);
5176 #define MAX_TRAPS 17
5178 static int trap_num[MAX_TRAPS] =
5182 FEAT_TRAP_SPIKED_PIT,
5183 FEAT_TRAP_POISON_PIT,
5201 * Hack -- instantiate a trap
5203 * XXX XXX XXX This routine should be redone to reflect trap "level".
5204 * That is, it does not make sense to have spiked pits at 50 feet.
5205 * Actually, it is not this routine, but the "trap instantiation"
5206 * code, which should also check for "trap doors" on quest levels.
5208 void pick_trap(int y, int x)
5212 cave_type *c_ptr = &cave[y][x];
5215 if (!(c_ptr->info & CAVE_TRAP)) return;
5216 c_ptr->info &= ~(CAVE_TRAP);
5221 /* Hack -- pick a trap */
5222 feat = trap_num[rand_int(MAX_TRAPS)];
5224 /* Accept non-trapdoors */
5225 if (feat != FEAT_TRAP_TRAPDOOR) break;
5227 /* Hack -- no trap doors on special levels */
5228 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5230 /* Hack -- no trap doors on the deepest level */
5231 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5236 /* Activate the trap */
5237 cave_set_feat(y, x, feat);
5242 * Places a random trap at the given location.
5244 * The location must be a legal, naked, floor grid.
5246 * Note that all traps start out as "invisible" and "untyped", and then
5247 * when they are "discovered" (by detecting them or setting them off),
5248 * the trap is "instantiated" as a visible, "typed", trap.
5250 void place_trap(int y, int x)
5252 /* Paranoia -- verify location */
5253 if (!in_bounds(y, x)) return;
5255 /* Require empty, clean, floor grid */
5256 if (!cave_naked_bold(y, x)) return;
5258 /* Place an invisible trap */
5259 cave[y][x].info |= CAVE_TRAP;
5264 * Describe the charges on an item in the inventory.
5266 void inven_item_charges(int item)
5268 object_type *o_ptr = &inventory[item];
5270 /* Require staff/wand */
5271 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5273 /* Require known item */
5274 if (!object_known_p(o_ptr)) return;
5277 if (o_ptr->pval <= 0)
5279 msg_print("¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
5283 msg_format("¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
5286 /* Multiple charges */
5287 if (o_ptr->pval != 1)
5289 /* Print a message */
5290 msg_format("You have %d charges remaining.", o_ptr->pval);
5296 /* Print a message */
5297 msg_format("You have %d charge remaining.", o_ptr->pval);
5305 * Describe an item in the inventory.
5307 void inven_item_describe(int item)
5309 object_type *o_ptr = &inventory[item];
5310 char o_name[MAX_NLEN];
5312 /* Get a description */
5313 object_desc(o_name, o_ptr, TRUE, 3);
5315 /* Print a message */
5317 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤¹¤ë */
5318 if (o_ptr->number <= 0)
5320 /*FIRST*//*¤³¤³¤Ï¤â¤¦Ä̤é¤Ê¤¤¤«¤â */
5321 msg_format("¤â¤¦%s¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£", o_name);
5325 /* ¥¢¥¤¥Æ¥à̾¤ò±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½Âбþ */
5326 msg_format("¤Þ¤À %s¤ò»ý¤Ã¤Æ¤¤¤ë¡£", o_name);
5329 msg_format("You have %s.", o_name);
5336 * Increase the "number" of an item in the inventory
5338 void inven_item_increase(int item, int num)
5340 object_type *o_ptr = &inventory[item];
5343 num += o_ptr->number;
5346 if (num > 255) num = 255;
5347 else if (num < 0) num = 0;
5350 num -= o_ptr->number;
5352 /* Change the number and weight */
5355 /* Add the number */
5356 o_ptr->number += num;
5358 /* Add the weight */
5359 p_ptr->total_weight += (num * o_ptr->weight);
5361 /* Recalculate bonuses */
5362 p_ptr->update |= (PU_BONUS);
5364 /* Recalculate mana XXX */
5365 p_ptr->update |= (PU_MANA);
5367 /* Combine the pack */
5368 p_ptr->notice |= (PN_COMBINE);
5371 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5377 * Erase an inventory slot if it has no more items
5379 void inven_item_optimize(int item)
5381 object_type *o_ptr = &inventory[item];
5383 /* Only optimize real items */
5384 if (!o_ptr->k_idx) return;
5386 /* Only optimize empty items */
5387 if (o_ptr->number) return;
5389 /* The item is in the pack */
5390 if (item < INVEN_RARM)
5398 object_delete_callback(&inventory[item]);
5399 #endif /* USE_SCRIPT */
5401 /* Slide everything down */
5402 for (i = item; i < INVEN_PACK; i++)
5404 /* Structure copy */
5405 inventory[i] = inventory[i+1];
5408 /* Erase the "final" slot */
5409 object_wipe(&inventory[i]);
5412 p_ptr->window |= (PW_INVEN);
5415 /* The item is being wielded */
5422 object_delete_callback(&inventory[item]);
5423 #endif /* USE_SCRIPT */
5425 /* Erase the empty slot */
5426 object_wipe(&inventory[item]);
5428 /* Recalculate bonuses */
5429 p_ptr->update |= (PU_BONUS);
5431 /* Recalculate torch */
5432 p_ptr->update |= (PU_TORCH);
5434 /* Recalculate mana XXX */
5435 p_ptr->update |= (PU_MANA);
5438 p_ptr->window |= (PW_EQUIP);
5442 p_ptr->window |= (PW_SPELL);
5447 * Describe the charges on an item on the floor.
5449 void floor_item_charges(int item)
5451 object_type *o_ptr = &o_list[item];
5453 /* Require staff/wand */
5454 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5456 /* Require known item */
5457 if (!object_known_p(o_ptr)) return;
5460 if (o_ptr->pval <= 0)
5462 msg_print("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
5466 msg_format("¤³¤Î¾²¾å¤Î¥¢¥¤¥Æ¥à¤Ï¡¢¤¢¤È %d ²óʬ¤ÎËâÎϤ¬»Ä¤Ã¤Æ¤¤¤ë¡£", o_ptr->pval);
5469 /* Multiple charges */
5470 if (o_ptr->pval != 1)
5472 /* Print a message */
5473 msg_format("There are %d charges remaining.", o_ptr->pval);
5479 /* Print a message */
5480 msg_format("There is %d charge remaining.", o_ptr->pval);
5488 * Describe an item in the inventory.
5490 void floor_item_describe(int item)
5492 object_type *o_ptr = &o_list[item];
5493 char o_name[MAX_NLEN];
5495 /* Get a description */
5496 object_desc(o_name, o_ptr, TRUE, 3);
5498 /* Print a message */
5500 /* "no more" ¤Î¾ì¹ç¤Ï¤³¤Á¤é¤Çɽ¼¨¤òʬ¤±¤ë */
5501 if (o_ptr->number <= 0)
5503 msg_format("¾²¾å¤Ë¤Ï¡¢¤â¤¦%s¤Ï¤Ê¤¤¡£", o_name);
5507 msg_format("¾²¾å¤Ë¤Ï¡¢¤Þ¤À %s¤¬¤¢¤ë¡£", o_name);
5510 msg_format("You see %s.", o_name);
5517 * Increase the "number" of an item on the floor
5519 void floor_item_increase(int item, int num)
5521 object_type *o_ptr = &o_list[item];
5524 num += o_ptr->number;
5527 if (num > 255) num = 255;
5528 else if (num < 0) num = 0;
5531 num -= o_ptr->number;
5533 /* Change the number */
5534 o_ptr->number += num;
5539 * Optimize an item on the floor (destroy "empty" items)
5541 void floor_item_optimize(int item)
5543 object_type *o_ptr = &o_list[item];
5545 /* Paranoia -- be sure it exists */
5546 if (!o_ptr->k_idx) return;
5548 /* Only optimize empty items */
5549 if (o_ptr->number) return;
5551 /* Delete the object */
5552 delete_object_idx(item);
5557 * Check if we have space for an item in the pack without overflow
5559 bool inven_carry_okay(object_type *o_ptr)
5564 if (inven_cnt < INVEN_PACK) return (TRUE);
5567 for (j = 0; j < INVEN_PACK; j++)
5569 object_type *j_ptr = &inventory[j];
5571 /* Skip non-objects */
5572 if (!j_ptr->k_idx) continue;
5574 /* Check if the two items can be combined */
5575 if (object_similar(j_ptr, o_ptr)) return (TRUE);
5584 * Add an item to the players inventory, and return the slot used.
5586 * If the new item can combine with an existing item in the inventory,
5587 * it will do so, using "object_similar()" and "object_absorb()", else,
5588 * the item will be placed into the "proper" location in the inventory.
5590 * This function can be used to "over-fill" the player's pack, but only
5591 * once, and such an action must trigger the "overflow" code immediately.
5592 * Note that when the pack is being "over-filled", the new item must be
5593 * placed into the "overflow" slot, and the "overflow" must take place
5594 * before the pack is reordered, but (optionally) after the pack is
5595 * combined. This may be tricky. See "dungeon.c" for info.
5597 * Note that this code must remove any location/stack information
5598 * from the object once it is placed into the inventory.
5600 s16b inven_carry(object_type *o_ptr)
5608 /* Check for combining */
5609 for (j = 0; j < INVEN_PACK; j++)
5611 j_ptr = &inventory[j];
5613 /* Skip non-objects */
5614 if (!j_ptr->k_idx) continue;
5616 /* Hack -- track last item */
5619 /* Check if the two items can be combined */
5620 if (object_similar(j_ptr, o_ptr))
5622 /* Combine the items */
5623 object_absorb(j_ptr, o_ptr);
5625 /* Increase the weight */
5626 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
5628 /* Recalculate bonuses */
5629 p_ptr->update |= (PU_BONUS);
5632 p_ptr->window |= (PW_INVEN);
5641 if (inven_cnt > INVEN_PACK) return (-1);
5643 /* Find an empty slot */
5644 for (j = 0; j <= INVEN_PACK; j++)
5646 j_ptr = &inventory[j];
5648 /* Use it if found */
5649 if (!j_ptr->k_idx) break;
5656 /* Reorder the pack */
5659 s32b o_value, j_value;
5661 /* Get the "value" of the item */
5662 o_value = object_value(o_ptr);
5664 /* Scan every occupied slot */
5665 for (j = 0; j < INVEN_PACK; j++)
5667 j_ptr = &inventory[j];
5669 /* Use empty slots */
5670 if (!j_ptr->k_idx) break;
5672 /* Hack -- readable books always come first */
5673 if ((o_ptr->tval == REALM1_BOOK) &&
5674 (j_ptr->tval != REALM1_BOOK)) break;
5675 if ((j_ptr->tval == REALM1_BOOK) &&
5676 (o_ptr->tval != REALM1_BOOK)) continue;
5678 if ((o_ptr->tval == REALM2_BOOK) &&
5679 (j_ptr->tval != REALM2_BOOK)) break;
5680 if ((j_ptr->tval == REALM2_BOOK) &&
5681 (o_ptr->tval != REALM2_BOOK)) continue;
5683 /* Objects sort by decreasing type */
5684 if (o_ptr->tval > j_ptr->tval) break;
5685 if (o_ptr->tval < j_ptr->tval) continue;
5687 /* Non-aware (flavored) items always come last */
5688 if (!object_aware_p(o_ptr)) continue;
5689 if (!object_aware_p(j_ptr)) break;
5691 /* Objects sort by increasing sval */
5692 if (o_ptr->sval < j_ptr->sval) break;
5693 if (o_ptr->sval > j_ptr->sval) continue;
5695 /* Unidentified objects always come last */
5696 if (!object_known_p(o_ptr)) continue;
5697 if (!object_known_p(j_ptr)) break;
5699 /* Hack: otherwise identical rods sort by
5700 increasing recharge time --dsb */
5701 if (o_ptr->tval == TV_ROD)
5703 if (o_ptr->pval < j_ptr->pval) break;
5704 if (o_ptr->pval > j_ptr->pval) continue;
5707 /* Determine the "value" of the pack item */
5708 j_value = object_value(j_ptr);
5710 /* Objects sort by decreasing value */
5711 if (o_value > j_value) break;
5712 if (o_value < j_value) continue;
5719 for (k = n; k >= i; k--)
5721 /* Hack -- Slide the item */
5722 object_copy(&inventory[k+1], &inventory[k]);
5726 /* Not a real deletion */
5727 /* object_delete_callback(&inventory[i]); */
5728 #endif /* USE_SCRIPT */
5730 /* Wipe the empty slot */
5731 object_wipe(&inventory[i]);
5736 object_copy(&inventory[i], o_ptr);
5738 /* Access new object */
5739 j_ptr = &inventory[i];
5742 j_ptr->next_o_idx = 0;
5744 /* Forget monster */
5745 j_ptr->held_m_idx = 0;
5747 /* Forget location */
5748 j_ptr->iy = j_ptr->ix = 0;
5750 /* No longer marked */
5751 j_ptr->marked = FALSE;
5753 /* Increase the weight */
5754 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
5756 /* Count the items */
5759 /* Recalculate bonuses */
5760 p_ptr->update |= (PU_BONUS);
5762 /* Combine and Reorder pack */
5763 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5766 p_ptr->window |= (PW_INVEN);
5768 /* Return the slot */
5774 * Take off (some of) a non-cursed equipment item
5776 * Note that only one item at a time can be wielded per slot.
5778 * Note that taking off an item when "full" may cause that item
5779 * to fall to the ground.
5781 * Return the inventory slot into which the item is placed.
5783 s16b inven_takeoff(int item, int amt)
5794 char o_name[MAX_NLEN];
5797 /* Get the item to take off */
5798 o_ptr = &inventory[item];
5801 if (amt <= 0) return (-1);
5804 if (amt > o_ptr->number) amt = o_ptr->number;
5806 /* Get local object */
5809 /* Obtain a local object */
5810 object_copy(q_ptr, o_ptr);
5812 /* Modify quantity */
5813 q_ptr->number = amt;
5815 /* Describe the object */
5816 object_desc(o_name, q_ptr, TRUE, 3);
5818 /* Took off weapon */
5819 if (item == INVEN_RARM)
5822 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
5824 act = "You were wielding";
5830 else if (item == INVEN_BOW)
5833 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
5835 act = "You were holding";
5840 /* Took off light */
5841 else if (item == INVEN_LITE)
5844 act = "¤ò¸÷¸»¤«¤é¤Ï¤º¤·¤¿";
5846 act = "You were holding";
5851 /* Took off something */
5855 act = "¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤¿";
5857 act = "You were wearing";
5862 /* Modify, Optimize */
5863 inven_item_increase(item, -amt);
5864 inven_item_optimize(item);
5866 /* Carry the object */
5867 slot = inven_carry(q_ptr);
5871 msg_format("%s(%c)%s¡£", o_name, index_to_label(slot), act);
5873 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
5883 * Drop (some of) a non-cursed inventory/equipment item
5885 * The object will be dropped "near" the current location
5887 void inven_drop(int item, int amt)
5894 char o_name[MAX_NLEN];
5897 /* Access original object */
5898 o_ptr = &inventory[item];
5901 if (amt <= 0) return;
5904 if (amt > o_ptr->number) amt = o_ptr->number;
5907 /* Take off equipment */
5908 if (item >= INVEN_RARM)
5910 /* Take off first */
5911 item = inven_takeoff(item, amt);
5913 /* Access original object */
5914 o_ptr = &inventory[item];
5918 /* Get local object */
5921 /* Obtain local object */
5922 object_copy(q_ptr, o_ptr);
5924 /* Distribute charges of wands or rods */
5925 distribute_charges(o_ptr, q_ptr, amt);
5927 /* Modify quantity */
5928 q_ptr->number = amt;
5930 /* Describe local object */
5931 object_desc(o_name, q_ptr, TRUE, 3);
5935 msg_format("%s(%c)¤òÍî¤È¤·¤¿¡£", o_name, index_to_label(item));
5937 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5941 /* Drop it near the player */
5942 (void)drop_near(q_ptr, 0, py, px);
5944 /* Modify, Describe, Optimize */
5945 inven_item_increase(item, -amt);
5946 inven_item_describe(item);
5947 inven_item_optimize(item);
5952 * Combine items in the pack
5954 * Note special handling of the "overflow" slot
5956 void combine_pack(void)
5964 /* Combine the pack (backwards) */
5965 for (i = INVEN_PACK; i > 0; i--)
5968 o_ptr = &inventory[i];
5970 /* Skip empty items */
5971 if (!o_ptr->k_idx) continue;
5973 /* Scan the items above that item */
5974 for (j = 0; j < i; j++)
5977 j_ptr = &inventory[j];
5979 /* Skip empty items */
5980 if (!j_ptr->k_idx) continue;
5982 /* Can we drop "o_ptr" onto "j_ptr"? */
5983 if (object_similar(j_ptr, o_ptr))
5988 /* Add together the item counts */
5989 object_absorb(j_ptr, o_ptr);
5991 /* One object is gone */
5994 /* Slide everything down */
5995 for (k = i; k < INVEN_PACK; k++)
5997 /* Structure copy */
5998 inventory[k] = inventory[k+1];
6002 object_delete_callback(&inventory[k]);
6003 #endif /* USE_SCRIPT */
6005 /* Erase the "final" slot */
6006 object_wipe(&inventory[k]);
6009 p_ptr->window |= (PW_INVEN);
6019 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤ò¤Þ¤È¤áľ¤·¤¿¡£");
6021 if (flag) msg_print("You combine some items in your pack.");
6028 * Reorder items in the pack
6030 * Note special handling of the "overflow" slot
6032 void reorder_pack(void)
6044 /* Re-order the pack (forwards) */
6045 for (i = 0; i < INVEN_PACK; i++)
6047 /* Mega-Hack -- allow "proper" over-flow */
6048 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6051 o_ptr = &inventory[i];
6053 /* Skip empty slots */
6054 if (!o_ptr->k_idx) continue;
6056 /* Get the "value" of the item */
6057 o_value = object_value(o_ptr);
6059 /* Scan every occupied slot */
6060 for (j = 0; j < INVEN_PACK; j++)
6062 /* Get the item already there */
6063 j_ptr = &inventory[j];
6065 /* Use empty slots */
6066 if (!j_ptr->k_idx) break;
6068 /* Hack -- readable books always come first */
6069 if ((o_ptr->tval == REALM1_BOOK) &&
6070 (j_ptr->tval != REALM1_BOOK)) break;
6071 if ((j_ptr->tval == REALM1_BOOK) &&
6072 (o_ptr->tval != REALM1_BOOK)) continue;
6074 if ((o_ptr->tval == REALM2_BOOK) &&
6075 (j_ptr->tval != REALM2_BOOK)) break;
6076 if ((j_ptr->tval == REALM2_BOOK) &&
6077 (o_ptr->tval != REALM2_BOOK)) continue;
6079 /* Objects sort by decreasing type */
6080 if (o_ptr->tval > j_ptr->tval) break;
6081 if (o_ptr->tval < j_ptr->tval) continue;
6083 /* Non-aware (flavored) items always come last */
6084 if (!object_aware_p(o_ptr)) continue;
6085 if (!object_aware_p(j_ptr)) break;
6087 /* Objects sort by increasing sval */
6088 if (o_ptr->sval < j_ptr->sval) break;
6089 if (o_ptr->sval > j_ptr->sval) continue;
6091 /* Unidentified objects always come last */
6092 if (!object_known_p(o_ptr)) continue;
6093 if (!object_known_p(j_ptr)) break;
6095 /* Hack: otherwise identical rods sort by
6096 increasing recharge time --dsb */
6097 if (o_ptr->tval == TV_ROD)
6099 if (o_ptr->pval < j_ptr->pval) break;
6100 if (o_ptr->pval > j_ptr->pval) continue;
6103 /* Determine the "value" of the pack item */
6104 j_value = object_value(j_ptr);
6108 /* Objects sort by decreasing value */
6109 if (o_value > j_value) break;
6110 if (o_value < j_value) continue;
6113 /* Never move down */
6114 if (j >= i) continue;
6119 /* Get local object */
6122 /* Save a copy of the moving item */
6123 object_copy(q_ptr, &inventory[i]);
6125 /* Slide the objects */
6126 for (k = i; k > j; k--)
6128 /* Slide the item */
6129 object_copy(&inventory[k], &inventory[k-1]);
6132 /* Insert the moving item */
6133 object_copy(&inventory[j], q_ptr);
6136 p_ptr->window |= (PW_INVEN);
6141 if (flag) msg_print("¥¶¥Ã¥¯¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤òÊ¤Ùľ¤·¤¿¡£");
6143 if (flag) msg_print("You reorder some items in your pack.");
6150 * Hack -- display an object kind in the current window
6152 * Include list of usable spells for readible books
6154 void display_koff(int k_idx)
6161 char o_name[MAX_NLEN];
6164 /* Erase the window */
6165 for (y = 0; y < Term->hgt; y++)
6167 /* Erase the line */
6168 Term_erase(0, y, 255);
6174 /* Get local object */
6177 /* Prepare the object */
6178 object_prep(q_ptr, k_idx);
6181 object_desc_store(o_name, q_ptr, FALSE, 0);
6183 /* Mention the object name */
6184 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6186 /* Warriors are illiterate */
6187 if (!(p_ptr->realm1 || p_ptr->realm2)) return;
6189 /* Display spells in readible books */
6190 if ((q_ptr->tval == REALM1_BOOK) ||
6191 (q_ptr->tval == REALM2_BOOK))
6199 /* Access the item's sval */
6202 /* Extract spells */
6203 for (spell = 0; spell < 32; spell++)
6205 /* Check for this spell */
6206 if (fake_spell_flags[sval] & (1L << spell))
6208 /* Collect this spell */
6209 spells[num++] = spell;
6214 print_spells(0, spells, num, 2, 0,
6215 (q_ptr->tval == REALM1_BOOK ? p_ptr->realm1 - 1 : p_ptr->realm2 - 1));
6219 /* Examine the grid (xx,yy) and warn the player if there are any danger */
6220 bool process_frakir(int xx, int yy){
6224 #define FRAKIR_AWARE_RANGE 12
6226 static int old_damage = 0;
6228 for (mx=xx-FRAKIR_AWARE_RANGE;mx<xx+FRAKIR_AWARE_RANGE+1;mx++){
6229 for (my=yy-FRAKIR_AWARE_RANGE;my<yy+FRAKIR_AWARE_RANGE+1;my++){
6230 if (!in_bounds(my,mx) || (distance(my,mx,yy,xx)>FRAKIR_AWARE_RANGE))continue;
6232 c_ptr = &cave[my][mx];
6233 if (c_ptr->m_idx > 0){
6236 int m_idx = c_ptr->m_idx;
6237 monster_type *m_ptr = &m_list[m_idx];
6238 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6240 u32b f4 = r_ptr->flags4;
6241 u32b f5 = r_ptr->flags5;
6242 u32b f6 = r_ptr->flags6;
6244 int rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
6246 if (m_ptr->csleep) continue;
6247 if (is_pet(m_ptr)) continue;
6249 /* Monster spells (only powerful ones)*/
6250 if(projectable(my,mx,yy,xx)){
6252 #define DAMCALC(f,val,max,im,vln,res,resx,resy,op,opx,opy,dmax) \
6253 if (f){ int dam = (val)>(max)? (max):(val); \
6255 if (vln) dam *= 2; \
6256 if (res) {dam = (dam * resx) / resy;} \
6257 if (op) {dam = (dam * opx) / opy;} \
6258 if (dam>dmax) dmax = dam; \
6261 DAMCALC(f4 & (RF4_BR_FIRE), m_ptr->hp / 3, 1600,
6262 p_ptr->immune_fire, p_ptr->muta3 & MUT3_VULN_ELEM,
6263 p_ptr->resist_fire, 1, 3,
6264 p_ptr->oppose_fire, 1, 3, dam_max0);
6266 DAMCALC(f4 & (RF4_BR_COLD), m_ptr->hp / 3, 1600,
6267 p_ptr->immune_cold, p_ptr->muta3 & MUT3_VULN_ELEM,
6268 p_ptr->resist_cold, 1, 3,
6269 p_ptr->oppose_cold, 1, 3, dam_max0);
6271 DAMCALC(f4 & (RF4_BR_ELEC), m_ptr->hp / 3, 1600,
6272 p_ptr->immune_elec, p_ptr->muta3 & MUT3_VULN_ELEM,
6273 p_ptr->resist_elec, 1, 3,
6274 p_ptr->oppose_elec, 1, 3, dam_max0);
6276 DAMCALC(f4 & (RF4_BR_ACID), m_ptr->hp / 3, 1600,
6277 p_ptr->immune_acid, p_ptr->muta3 & MUT3_VULN_ELEM,
6278 p_ptr->resist_acid, 1, 3,
6279 p_ptr->oppose_acid, 1, 3, dam_max0);
6281 DAMCALC(f4 & (RF4_BR_POIS), m_ptr->hp / 3, 800,
6283 p_ptr->resist_pois, 1, 3,
6284 p_ptr->oppose_pois, 1, 3, dam_max0);
6287 DAMCALC(f4 & (RF4_BR_NETH), m_ptr->hp / 6, 550, FALSE , FALSE,
6288 p_ptr->resist_neth, 6, 9, FALSE, 1, 1, dam_max0);
6290 DAMCALC(f4 & (RF4_BR_LITE), m_ptr->hp / 6, 400, FALSE , FALSE,
6291 p_ptr->resist_lite, 4, 9, FALSE, 1, 1, dam_max0);
6293 DAMCALC(f4 & (RF4_BR_DARK), m_ptr->hp / 6, 400, FALSE , FALSE,
6294 p_ptr->resist_dark, 4, 9, FALSE, 1, 1, dam_max0);
6296 DAMCALC(f4 & (RF4_BR_CONF), m_ptr->hp / 6, 450, FALSE , FALSE,
6297 p_ptr->resist_conf, 5, 9, FALSE, 1, 1, dam_max0);
6299 DAMCALC(f4 & (RF4_BR_SOUN), m_ptr->hp / 6, 450, FALSE , FALSE,
6300 p_ptr->resist_sound, 5, 9, FALSE, 1, 1, dam_max0);
6302 DAMCALC(f4 & (RF4_BR_CHAO), m_ptr->hp / 6, 600, FALSE , FALSE,
6303 p_ptr->resist_chaos, 6, 9, FALSE, 1, 1, dam_max0);
6305 DAMCALC(f4 & (RF4_BR_DISE), m_ptr->hp / 6, 500, FALSE , FALSE,
6306 p_ptr->resist_disen, 6, 9, FALSE, 1, 1, dam_max0);
6308 DAMCALC(f4 & (RF4_BR_NEXU), m_ptr->hp / 3, 250, FALSE , FALSE,
6309 p_ptr->resist_nexus, 6, 9, FALSE, 1, 1, dam_max0);
6311 DAMCALC(f4 & (RF4_BR_TIME), m_ptr->hp / 3, 150, FALSE , FALSE,
6312 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6314 DAMCALC(f4 & (RF4_BR_INER), m_ptr->hp / 6, 200, FALSE , FALSE,
6315 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6317 DAMCALC(f4 & (RF4_BR_GRAV), m_ptr->hp / 3, 200, FALSE , FALSE,
6318 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6320 DAMCALC(f4 & (RF4_BR_SHAR), m_ptr->hp / 6, 500, FALSE , FALSE,
6321 p_ptr->resist_shard, 6, 9, FALSE, 1, 1, dam_max0);
6323 DAMCALC(f4 & (RF4_BR_PLAS), m_ptr->hp / 6, 150, FALSE , FALSE,
6324 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6326 DAMCALC(f4 & (RF4_BR_WALL), m_ptr->hp / 6, 200, FALSE , FALSE,
6327 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6329 DAMCALC(f4 & (RF4_BR_MANA), m_ptr->hp / 3, 250, FALSE , FALSE,
6330 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6332 DAMCALC(f4 & (RF4_BR_NUKE), m_ptr->hp / 3, 800, FALSE , FALSE,
6333 p_ptr->resist_pois, 2, 5,
6334 p_ptr->oppose_pois, 2, 5, dam_max0);
6336 DAMCALC(f4 & (RF4_BR_DISI), m_ptr->hp / 3, 300, FALSE , FALSE,
6337 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6340 DAMCALC(f4 & (RF4_ROCKET), m_ptr->hp / 4, 800, FALSE , FALSE,
6341 p_ptr->resist_shard, 1, 2, FALSE, 1, 1, dam_max0);
6343 DAMCALC(f5 & (RF5_BA_MANA), rlev*4 + 150, 9999, FALSE , FALSE,
6344 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6346 DAMCALC(f5 & (RF5_BA_DARK), rlev*4 + 150, 9999, FALSE , FALSE,
6347 p_ptr->resist_dark, 4, 9, FALSE, 1, 1, dam_max0);
6349 DAMCALC(f5 & (RF5_BA_LITE), rlev*4 + 150, 9999, FALSE , FALSE,
6350 p_ptr->resist_lite, 4, 9, FALSE, 1, 1, dam_max0);
6353 DAMCALC(f4 & (RF4_ROCKET),m_ptr->hp / 4, 800, FALSE , FALSE,
6354 p_ptr->resist_shard, 1, 2, FALSE, 1, 1, dam_max0);
6356 DAMCALC(f6 & (RF6_HAND_DOOM), p_ptr->chp*6/10, 9999, FALSE , FALSE,
6357 FALSE, 1, 1, FALSE, 1, 1, dam_max0);
6361 /* Monster melee attacks */
6362 if( mx <= xx+1 && mx >= xx-1 && my <=yy+1 && my >= yy-1 ){
6365 for (m = 0; m < 4; m++)
6369 /* Skip non-attacks */
6370 if (!r_ptr->blow[m].method) continue;
6372 /* Extract the attack info */
6373 d1 = r_ptr->blow[m].d_dice;
6374 d2 = r_ptr->blow[m].d_side;
6378 if(dam_melee>dam_max0)dam_max0=dam_melee;
6381 /* Contribution from this monster */
6389 /* Prevent excessive warning */
6390 if(dam_max>old_damage){
6391 old_damage=dam_max * 3 / 2;
6393 if (dam_max>(p_ptr->chp)/2){
6395 msg_print("»ØÎؤ¬±Ô¤¯¿Ì¤¨¤¿¡ª");
6397 msg_print("The Ring pulsates sharply!");
6401 return(get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©"));
6403 return(get_check("Realy want to go ahead? "));
6407 else old_damage = old_damage/2;
6409 c_ptr = &cave[yy][xx];
6410 if (((is_trap(c_ptr->feat) && !easy_disarm) || (c_ptr->info & CAVE_TRAP)) && randint(13)!=1){
6412 msg_print("»ØÎؤ¬¿Ì¤¨¤¿¡ª");
6414 msg_print("The Ring pulsates!");
6418 return(get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©"));
6420 return(get_check("Realy want to go ahead? "));
6427 typedef struct essence_type essence_type;
6438 static essence_type essence_info[MAX_ESSENCE] = {
6439 {"ÏÓÎÏ","ÏÓÎÏ", 1, 4, 20},
6440 {"ÃÎǽ","ÃÎǽ", 2, 4, 20},
6441 {"¸¤µ","¸¤µ", 3, 4, 20},
6442 {"´ïÍѤµ","´ïÍѤµ", 4, 4, 20},
6443 {"Âѵ×ÎÏ","Âѵ×ÎÏ", 5, 4, 20},
6444 {"Ì¥ÎÏ","Ì¥ÎÏ", 6, 4, 20},
6445 {"ËâÎÏ»ÙÇÛ","ËâÎÏ»ÙÇÛ", 7, 4, 20},
6447 {"±£Ì©","±£Ì©", 9, 4, 40},
6448 {"õº÷","õº÷", 10, 4, 15},
6449 {"ÀÖ³°Àþ»ëÎÏ","ÀÖ³°Àþ»ëÎÏ", 11, 4, 15},
6450 {"ºÎ·¡","ºÎ·¡", 12, 4, 15},
6451 {"¥¹¥Ô¡¼¥É","¥¹¥Ô¡¼¥É", 13, 4, 12},
6452 {"Äɲù¶·â","Äɲù¶·â", 14, 1, 20},
6453 {"¥«¥ª¥¹¹¶·â","¥«¥ª¥¹¹¶·â", 15, 1, 15},
6454 {"µÛ·ì¹¶·â","µÛ·ì¹¶·â", 16, 1, 60},
6455 {"ưʪÇÜÂÇ","ưʪÇÜÂÇ", 17, 1, 20},
6456 {"¼Ù°ÇÜÂÇ","¼Ù°ÇÜÂÇ", 18, 1, 100},
6457 {"ÉÔ»àÇÜÂÇ","ÉÔ»àÇÜÂÇ", 19, 1, 20},
6458 {"°ËâÇÜÂÇ","°ËâÇÜÂÇ", 20, 1, 20},
6459 {"¥ª¡¼¥¯ÇÜÂÇ","¥ª¡¼¥¯ÇÜÂÇ", 21, 1, 15},
6460 {"¥È¥í¥ëÇÜÂÇ","¥È¥í¥ëÇÜÂÇ", 22, 1, 15},
6461 {"µð¿ÍÇÜÂÇ","µð¿ÍÇÜÂÇ", 23, 1, 20},
6462 {"εÇÜÂÇ","εÇÜÂÇ", 24, 1, 20},
6463 {"","εÇÜÇÜÂÇ", 24, 1, 60},
6465 {"ÃÏ¿Ì","ÃÏ¿Ìȯư", 27, 5, 15},
6466 {"ÆÇ»¦","ÆÇ»¦", 28, 1, 20},
6467 {"Íϲò","Íϲò", 29, 1, 20},
6468 {"ÅÅ·â","ÅÅ·â", 30, 1, 20},
6469 {"¾Æ´þ","¾Æ´þ", 31, 1, 20},
6470 {"Åà·ë","Åà·ë", 32, 1, 20},
6471 {"ǽÎÏ°Ý»ý","ÏÓÎÏ°Ý»ý", 33, 3, 15},
6472 {"","ÃÎǽ°Ý»ý", 33, 3, 15},
6473 {"","¸¤µ°Ý»ý", 33, 3, 15},
6474 {"","´ïÍѤµ°Ý»ý", 33, 3, 15},
6475 {"","Âѵ×ÎÏ°Ý»ý", 33, 3, 15},
6476 {"","Ì¥ÎÏ°Ý»ý", 33, 3, 15},
6479 {"ÌȱÖ","»ÀÌȱÖ", 41, 2, 20},
6480 {"","ÅÅ·âÌȱÖ", 41, 2, 20},
6481 {"","²Ð±êÌȱÖ", 41, 2, 20},
6482 {"","Î䵤ÌȱÖ", 41, 2, 20},
6484 {"È¿¼Í","È¿¼Í", 46, 2, 20},
6485 {"ËãáãÃΤ餺","ËãáãÃΤ餺", 47, 3, 20},
6486 {"À¸Ì¿ÎÏ°Ý»ý","À¸Ì¿ÎÏ°Ý»ý", 48, 3, 20},
6487 {"ÂÑ»À","ÂÑ»À", 49, 2, 15},
6488 {"ÂÑÅÅ·â","ÂÑÅÅ·â", 50, 2, 15},
6489 {"ÂѲбê","ÂѲбê", 51, 2, 15},
6490 {"ÂÑÎ䵤","ÂÑÎ䵤", 52, 2, 15},
6491 {"ÂÑÆÇ","ÂÑÆÇ", 53, 2, 25},
6492 {"ÂѶ²ÉÝ","ÂѶ²ÉÝ", 54, 2, 20},
6493 {"ÂÑÁ®¸÷","ÂÑÁ®¸÷", 55, 2, 20},
6494 {"ÂѰŹõ","ÂѰŹõ", 56, 2, 20},
6495 {"ÂÑÌÕÌÜ","ÂÑÌÕÌÜ", 57, 2, 20},
6496 {"ÂѺ®Íð","ÂѺ®Íð", 58, 2, 20},
6497 {"Âѹ첻","Âѹ첻", 59, 2, 20},
6498 {"ÂÑÇËÊÒ","ÂÑÇËÊÒ", 60, 2, 20},
6499 {"ÂÑÃϹö","ÂÑÃϹö", 61, 2, 20},
6500 {"ÂÑ°ø²Ìº®Íð","ÂÑ°ø²Ìº®Íð", 62, 2, 20},
6501 {"ÂÑ¥«¥ª¥¹","ÂÑ¥«¥ª¥¹", 63, 2, 20},
6502 {"ÂÑÎô²½","ÂÑÎô²½", 64, 2, 20},
6508 {"È¿ËâË¡","È¿ËâË¡", 70, 3, 15},
6515 {"ÉâÍ·","ÉâÍ·", 77, 3, 20},
6516 {"±Êµ×¸÷¸»","±Êµ×¸÷¸»", 78, 3, 15},
6517 {"²Ä»ëÆ©ÌÀ","²Ä»ëÆ©ÌÀ", 79, 3, 20},
6518 {"¥Æ¥ì¥Ñ¥·¡¼","¥Æ¥ì¥Ñ¥·¡¼", 80, 3, 15},
6519 {"Ãپò½","Ãپò½", 81, 3, 15},
6520 {"µÞ®²óÉü","µÞ®²óÉü", 82, 3, 20},
6529 {"¥Æ¥ì¥Ý¡¼¥È","¥Æ¥ì¥Ý¡¼¥È", 91, 3, 25},
6535 {"¹¶·â","¹¶·â", 97, 6, 30},
6536 {"Ëɸæ","Ëɸæ", 98, 6, 15},
6537 {"","»ÀÂÑÀȯư", 49, 5, 50},
6538 {"","ÅÅ·âÂÑÀȯư", 50, 5, 50},
6539 {"","²Ð±êÂÑÀȯư", 51, 5, 50},
6540 {"","Î䵤ÂÑÀȯư", 52, 5, 50},
6541 {"","²Ð±ê¥ª¡¼¥é", 0, 5, 30},
6542 {"","Åŷ⥪¡¼¥é", 0, 5, 30},
6543 {"","Î䵤¥ª¡¼¥é", 0, 5, 30},
6544 {"","Á´ÂÑÀ", 0, 2, 150},
6545 {"","ÁõÈ÷ÊÝ»ý", 0, 6, 10},
6546 {"","»¦Ù¤¤Î¾®¼ê", 97, 1, 200},
6549 static essence_type essence_info[MAX_ESSENCE] = {
6550 {"strength","strength", 1, 4, 20},
6551 {"intelligen.","intelligence", 2, 4, 20},
6552 {"wisdom","wisdom", 3, 4, 20},
6553 {"dexterity","dexterity", 4, 4, 20},
6554 {"constitut.","constitution", 5, 4, 20},
6555 {"charisma","charisma", 6, 4, 20},
6556 {"magic mast.","magic mastery", 7, 4, 20},
6558 {"stealth","stealth", 9, 4, 40},
6559 {"serching","serching", 10, 4, 15},
6560 {"inflavision","inflavision", 11, 4, 15},
6561 {"digging","digging", 12, 4, 15},
6562 {"speed","speed", 13, 4, 12},
6563 {"extra atk","extra attack", 14, 1, 20},
6564 {"chaos brand","chaos brand", 15, 1, 15},
6565 {"vampiric","vampiric brand", 16, 1, 60},
6566 {"slay animal","slay animal", 17, 1, 20},
6567 {"slay evil","slay evil", 18, 1, 100},
6568 {"slay undead","slay undead", 19, 1, 20},
6569 {"slay demon","slay demon", 20, 1, 20},
6570 {"slay orc","slay orc", 21, 1, 15},
6571 {"slay troll","slay troll", 22, 1, 15},
6572 {"slay giant","slay giant", 23, 1, 20},
6573 {"slay dragon","slay dragon", 24, 1, 20},
6574 {"","kill dragon", 24, 1, 60},
6576 {"quake","quake activation", 27, 5, 15},
6577 {"pois. brand","poison brand", 28, 1, 20},
6578 {"acid brand","acid brand", 29, 1, 20},
6579 {"elec. brand","electric brand", 30, 1, 20},
6580 {"fire brand","fire brand", 31, 1, 20},
6581 {"cold brand","cold brand", 32, 1, 20},
6582 {"sustain","sustain strength", 33, 3, 15},
6583 {"","sustain intelligence", 33, 3, 15},
6584 {"","sustain wisdom", 33, 3, 15},
6585 {"","sustain dexterity", 33, 3, 15},
6586 {"","sustain constitution", 33, 3, 15},
6587 {"","sustain charisma", 33, 3, 15},
6590 {"immunity","acid immunity", 41, 2, 20},
6591 {"","electric immunity", 41, 2, 20},
6592 {"","fire immunity", 41, 2, 20},
6593 {"","cold immunity", 41, 2, 20},
6595 {"reflection","reflection", 46, 2, 20},
6596 {"free action","free action", 47, 3, 20},
6597 {"hold life","hold life", 48, 3, 20},
6598 {"res. acid","resistance to acid", 49, 2, 15},
6599 {"res. elec.","resistance to electric", 50, 2, 15},
6600 {"res. fire","resistance to fire", 51, 2, 15},
6601 {"res. cold","resistance to cold", 52, 2, 15},
6602 {"res. poison","resistance to poison", 53, 2, 25},
6603 {"res. fear","resistance to fear", 54, 2, 20},
6604 {"res. light","resistance to light", 55, 2, 20},
6605 {"res. dark","resistance to dark", 56, 2, 20},
6606 {"res. blind","resistance to blind", 57, 2, 20},
6607 {"res.confuse","resistance to confusion", 58, 2, 20},
6608 {"res. sound","resistance to sound", 59, 2, 20},
6609 {"res. shard","resistance to shard", 60, 2, 20},
6610 {"res. nether","resistance to nether", 61, 2, 20},
6611 {"res. nexus","resistance to nexus", 62, 2, 20},
6612 {"res. chaos","resistance to chaos", 63, 2, 20},
6613 {"res. disen.","resistance to disenchantment", 64, 2, 20},
6619 {"anti magic","anti magic", 70, 3, 15},
6626 {"levitation","levitation", 77, 3, 20},
6627 {"perm. light","permanent light", 78, 3, 15},
6628 {"see invis.","see invisible", 79, 3, 20},
6629 {"telepathy","telepathy", 80, 3, 15},
6630 {"slow dige.","slow digestion", 81, 3, 15},
6631 {"regen.","regeneration", 82, 3, 20},
6640 {"teleport","teleport", 91, 3, 25},
6646 {"weapon enc.","weapon enchant", 97, 6, 30},
6647 {"armor enc.","armor enchant", 98, 6, 15},
6648 {"","resist acid activation", 49, 5, 50},
6649 {"","resist electricity activation", 50, 5, 50},
6650 {"","resist fire activation", 51, 5, 50},
6651 {"","resist cold activation", 52, 5, 50},
6652 {"","fiery sheath", 0, 5, 30},
6653 {"","electric sheath", 0, 5, 30},
6654 {"","coldly sheath", 0, 5, 30},
6655 {"","resistance", 0, 2, 150},
6656 {"","elements proof", 0, 6, 10},
6657 {"","gauntlets of slay", 97, 1, 200},
6661 bool item_tester_hook_melee_ammo(object_type *o_ptr)
6663 switch (o_ptr->tval)
6676 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
6684 static void display_essence(void)
6689 for (i = 1; i < 22; i++)
6694 prt("¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô ¥¨¥Ã¥»¥ó¥¹ ¸Ä¿ô", 1, 8);
6696 prt("Essence Num Essence Num Essence Num ", 1, 8);
6698 for (i = 0; i < MAX_ESSENCE; i++)
6700 if (!essence_info[i].drain_name[0]) continue;
6701 prt(format("%-11s %5d", essence_info[i].drain_name, p_ptr->magic_num1[i]), 2+num%20, 8+num/20*22);
6705 prt("¸½ºß½ê»ý¤·¤Æ¤¤¤ë¥¨¥Ã¥»¥ó¥¹", 0, 0);
6707 prt("List of all essences you have.", 0, 0);
6714 static void drain_essence(void)
6716 int drain_value[MAX_ESSENCE];
6719 bool observe = FALSE;
6720 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
6721 u32b old_f1, old_f2, old_f3, new_f1, new_f2, new_f3;
6724 byte iy, ix, marked, number;
6725 s16b next_o_idx, weight;
6727 for (i = 0; i < MAX_ESSENCE; i++)
6730 item_tester_hook = item_tester_hook_weapon_armour;
6731 item_tester_no_ryoute = TRUE;
6735 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éÃê½Ð¤·¤Þ¤¹¤«¡©";
6736 s = "Ãê½Ð¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
6738 q = "Extract from which item? ";
6739 s = "You have nothing you can extract from.";
6742 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
6744 /* Get the item (in the pack) */
6747 o_ptr = &inventory[item];
6750 /* Get the item (on the floor) */
6753 o_ptr = &o_list[0 - item];
6756 if (object_known_p(o_ptr) && (o_ptr->name1 || o_ptr->name2 || o_ptr->art_name || o_ptr->xtra3)) {
6757 char o_name[MAX_NLEN];
6758 object_desc(o_name, o_ptr, FALSE, 0);
6760 if (!get_check(format("ËÜÅö¤Ë%s¤«¤éÃê½Ð¤·¤Æ¤è¤í¤·¤¤¤Ç¤¹¤«¡©", o_name))) return;
6762 if (!get_check(format("Really extract from %s? ", o_name))) return;
6768 object_flags(o_ptr, &old_f1, &old_f2, &old_f3);
6769 if (old_f1 & TR1_KILL_DRAGON) old_f1 |= TR1_SLAY_DRAGON;
6771 old_to_a = o_ptr->to_a;
6773 old_to_h = o_ptr->to_h;
6774 old_to_d = o_ptr->to_d;
6777 old_pval = o_ptr->pval;
6778 old_name2 = o_ptr->name2;
6779 if (old_f3 & (TR3_CURSED | TR3_HEAVY_CURSE | TR3_PERMA_CURSE)) dec--;
6780 if (old_f3 & (TR3_AGGRAVATE)) dec--;
6781 if (old_f3 & (TR3_NO_TELE)) dec--;
6782 if (old_f3 & (TR3_DRAIN_EXP)) dec--;
6783 if (old_f3 & (TR3_TY_CURSE)) dec--;
6787 next_o_idx = o_ptr->next_o_idx;
6788 marked = o_ptr->marked;
6789 weight = o_ptr->weight;
6790 number = o_ptr->number;
6792 object_prep(o_ptr, o_ptr->k_idx);
6796 o_ptr->next_o_idx=next_o_idx;
6797 o_ptr->marked=marked;
6798 o_ptr->number = number;
6799 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
6800 o_ptr->ident |= (IDENT_MENTAL);
6801 object_aware(o_ptr);
6802 object_known(o_ptr);
6804 object_flags(o_ptr, &new_f1, &new_f2, &new_f3);
6806 for (i = 0; i < 96; i++)
6812 if (((1 << i) & TR1_PVAL_MASK) && old_pval) pval = ((new_f1 >> i) & 0x00000001) ? old_pval-o_ptr->pval : old_pval;
6813 if ((!((new_f1 >> i) & 0x00000001) || pval) && ((old_f1 >> i) & 0x00000001) && essence_info[i].link)
6815 drain_value[essence_info[i].link-1] += (10 * (pval ? pval : 1));
6820 if (!((new_f2 >> (i-32)) & 0x00000001) && ((old_f2 >> (i-32)) & 0x00000001) && essence_info[i].link)
6822 drain_value[essence_info[i].link-1] += 10;
6827 if (!((new_f3 >> (i-64)) & 0x00000001) && ((old_f3 >> (i-64)) & 0x00000001) && essence_info[i].link)
6829 if (essence_info[i].link == -1)
6831 if (i == ESSENCE__SH__FIRE-1)
6833 drain_value[ESSENCE_B_FIRE-1] += 10;
6834 drain_value[ESSENCE_RES_FIRE-1] += 10;
6836 else if (i == ESSENCE__SH__ELEC-1)
6838 drain_value[ESSENCE_B_ELEC-1] += 10;
6839 drain_value[ESSENCE_RES_ELEC-1] += 10;
6841 else if (i == ESSENCE__SH__COLD-1)
6843 drain_value[ESSENCE_B_COLD-1] += 10;
6844 drain_value[ESSENCE_RES_COLD-1] += 10;
6847 else drain_value[essence_info[i].link-1] += 10;
6852 if ((old_f1 & TR1_FORCE_WEPON) && !(new_f1 & TR1_FORCE_WEPON))
6854 drain_value[ESSENCE_INT-1] += 5;
6855 drain_value[ESSENCE_WIS-1] += 5;
6857 if ((old_f1 & TR1_VORPAL) && !(new_f1 & TR1_VORPAL))
6859 drain_value[ESSENCE_B_POIS-1] += 5;
6860 drain_value[ESSENCE_B_ACID-1] += 5;
6861 drain_value[ESSENCE_B_ELEC-1] += 5;
6862 drain_value[ESSENCE_B_FIRE-1] += 5;
6863 drain_value[ESSENCE_B_COLD-1] += 5;
6865 if ((old_f3 & TR3_DEC_MANA) && !(new_f3 & TR3_DEC_MANA))
6867 drain_value[ESSENCE_INT-1] += 10;
6869 if ((old_f3 & TR3_XTRA_MIGHT) && !(new_f3 & TR3_XTRA_MIGHT))
6871 drain_value[ESSENCE_STR-1] += 10;
6873 if ((old_f3 & TR3_XTRA_SHOTS) && !(new_f3 & TR3_XTRA_SHOTS))
6875 drain_value[ESSENCE_DEX-1] += 10;
6877 if (old_name2 == EGO_2HAND)
6879 drain_value[ESSENCE_DEX] += 20;
6881 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_SWORD) && (o_ptr->tval != TV_BOW))
6883 if (old_ds > o_ptr->ds) drain_value[ESSENCE_ATTACK-1] += (old_ds-o_ptr->ds)*10;
6885 if (old_dd > o_ptr->dd) drain_value[ESSENCE_ATTACK-1] += (old_dd-o_ptr->dd)*10;
6887 if (old_to_h > o_ptr->to_h) drain_value[ESSENCE_ATTACK-1] += (old_to_h-o_ptr->to_h)*10;
6888 if (old_to_d > o_ptr->to_d) drain_value[ESSENCE_ATTACK-1] += (old_to_d-o_ptr->to_d)*10;
6889 if (old_ac > o_ptr->ac) drain_value[ESSENCE_AC-1] += (old_ac-o_ptr->ac)*10;
6890 if (old_to_a > o_ptr->to_a) drain_value[ESSENCE_AC-1] += (old_to_a-o_ptr->to_a)*10;
6892 for (i = 0; i < MAX_ESSENCE; i++)
6894 drain_value[i] *= number;
6895 drain_value[i] = drain_value[i] * dec / 4;
6896 drain_value[i] = MAX(drain_value[i], 0);
6897 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
6906 msg_print("¥¨¥Ã¥»¥ó¥¹¤ÏÃê½Ð¤Ç¤¤Þ¤»¤ó¤Ç¤·¤¿¡£");
6908 msg_print("You were not able to extract any essence.");
6914 msg_print("Ãê½Ð¤·¤¿¥¨¥Ã¥»¥ó¥¹:");
6916 msg_print("Extracted essences:");
6918 for (i = 0; i < MAX_ESSENCE; i++)
6920 if (!drain_value[i]) continue;
6921 p_ptr->magic_num1[i] += drain_value[i];
6922 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
6924 msg_format("%s...%d", essence_info[i].drain_name, drain_value[i]);
6928 /* Combine the pack */
6929 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6932 p_ptr->window |= (PW_INVEN);
6937 static int choose_essence()
6941 int menu_line = (use_menu ? 1 : 0);
6944 if (repeat_pull(&mode) && 1 <= mode && mode <= 5)
6947 #endif /* ALLOW_REPEAT */
6956 prt(format(" %s Éð´ï°À", (menu_line == 1) ? "¡Õ" : " "), 2, 14);
6957 prt(format(" %s ÂÑÀ", (menu_line == 2) ? "¡Õ" : " "), 3, 14);
6958 prt(format(" %s ǽÎÏ", (menu_line == 3) ? "¡Õ" : " "), 4, 14);
6959 prt(format(" %s ¿ôÃÍ", (menu_line == 4) ? "¡Õ" : " "), 5, 14);
6960 prt(format(" %s ¤½¤Î¾", (menu_line == 5) ? "¡Õ" : " "), 6, 14);
6961 prt("¤É¤Î¼ïÎà¤Î¥¨¥Ã¥»¥ó¥¹Éղäò¹Ô¤¤¤Þ¤¹¤«¡©", 0, 0);
6963 prt(format(" %s Brand weapon", (menu_line == 1) ? "> " : " "), 2, 14);
6964 prt(format(" %s Resistance", (menu_line == 2) ? "> " : " "), 3, 14);
6965 prt(format(" %s Ability", (menu_line == 3) ? "> " : " "), 4, 14);
6966 prt(format(" %s Magic number", (menu_line == 4) ? "> " : " "), 5, 14);
6967 prt(format(" %s Others", (menu_line == 5) ? "> " : " "), 6, 14);
6968 prt("Choose from menu.", 0, 0);
6994 if (menu_line > 5) menu_line -= 5;
7004 prt(" a) ¹¶·â°À", 2, 14);
7005 prt(" b) ÂÑÀ", 3, 14);
7006 prt(" c) ǽÎÏ", 4, 14);
7007 prt(" d) ¿ôÃÍ", 5, 14);
7008 prt(" e) ¤½¤Î¾", 6, 14);
7009 if (!get_com("²¿¤òÉղä·¤Þ¤¹¤«:", &choice, TRUE))
7011 prt(" a) Brand weapon", 2, 14);
7012 prt(" b) Resistance", 3, 14);
7013 prt(" c) Ability", 4, 14);
7014 prt(" d) Magic number", 5, 14);
7015 prt(" e) Others", 6, 14);
7016 if (!get_com("Command :", &choice, TRUE))
7052 #endif /* ALLOW_REPEAT */
7056 static void add_essence(int mode)
7058 int item, max_num = 0;
7067 char o_name[MAX_NLEN];
7070 int menu_line = (use_menu ? 1 : 0);
7072 for (i = 0; i < MAX_ESSENCE; i++)
7074 if (essence_info[i].type != mode) continue;
7079 if (!repeat_pull(&i) || i<0 || i>=max_num)
7081 #endif /* ALLOW_REPEAT */
7084 /* Nothing chosen yet */
7090 /* Build a prompt */
7092 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎǽÎϤòÉղä·¤Þ¤¹¤«¡©");
7094 (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Add which ability? ");
7096 if (use_menu) screen_save();
7098 /* Get a spell from the user */
7100 choice = (always_show_list || use_menu) ? ESCAPE:1;
7104 if( choice==ESCAPE ) choice = ' ';
7105 else if( !get_com(out_val, &choice, FALSE) )break;
7107 if (use_menu && choice != ' ')
7122 menu_line += (max_num-1);
7145 menu_line = max_num;
7158 if (menu_line > max_num) menu_line -= max_num;
7160 /* Request redraw */
7161 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
7164 if (!redraw || use_menu)
7168 char dummy[80], dummy2[80];
7176 /* Save the screen */
7177 if (!use_menu) screen_save();
7179 for (y = 1; y < 24; y++)
7182 /* Print header(s) */
7184 prt(" ǽÎÏ(ɬÍ×¥¨¥Ã¥»¥ó¥¹) ɬÍ׿ô/½ê»ý¿ô", 1, x);
7187 prt(" Ability(essence to need) Needs/Possess", 1, x);
7190 for (ctr = 0; ctr < max_num; ctr++)
7194 if (ctr == (menu_line-1))
7196 strcpy(dummy, "¡Õ ");
7198 strcpy(dummy, "> ");
7200 else strcpy(dummy, " ");
7203 /* letter/number for power selection */
7206 sprintf(dummy, "%c) ",I2A(ctr));
7209 strcat(dummy, essence_info[num[ctr]].add_name);
7214 if (essence_info[num[ctr]].link)
7216 strcat(dummy, format("(%s)", essence_info[essence_info[num[ctr]].link-1].drain_name));
7217 if (p_ptr->magic_num1[essence_info[num[ctr]].link-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7223 case ESSENCE_SH_FIRE:
7225 strcat(dummy, "(¾Æ´þ+ÂѲбê) ");
7227 strcat(dummy, "(brand fire + res.fire) ");
7229 if (p_ptr->magic_num1[ESSENCE_B_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7230 if (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7232 case ESSENCE_SH_ELEC:
7234 strcat(dummy, "(ÅÅ·â+ÂÑÅÅ·â) ");
7236 strcat(dummy, "(brand elec. + res. elec.) ");
7238 if (p_ptr->magic_num1[ESSENCE_B_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7239 if (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7241 case ESSENCE_SH_COLD:
7243 strcat(dummy, "(Åà·ë+ÂÑÎ䵤) ");
7245 strcat(dummy, "(brand cold + res. cold) ");
7247 if (p_ptr->magic_num1[ESSENCE_B_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7248 if (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7250 case ESSENCE_RESISTANCE:
7252 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
7254 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
7256 if (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7257 if (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7258 if (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7259 if (p_ptr->magic_num1[ESSENCE_RES_ACID-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7261 case ESSENCE_SUSTAIN:
7263 strcat(dummy, "(ÂѲбê+ÂÑÎ䵤+ÂÑÅÅ·â+ÂÑ»À)");
7265 strcat(dummy, "(r.fire+r.cold+r.elec+r.acid)");
7267 if (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7268 if (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7269 if (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7270 if (p_ptr->magic_num1[ESSENCE_RES_ACID-1] < essence_info[num[ctr]].value) able[ctr] = FALSE;
7275 if (!able[ctr]) col = TERM_RED;
7277 strcpy(dummy2, format("%-50s",dummy));
7279 if (essence_info[num[ctr]].link)
7281 strcat(dummy2, format(" %d/%d",essence_info[num[ctr]].value, p_ptr->magic_num1[essence_info[num[ctr]].link-1]));
7285 strcat(dummy2, format(" %d/(\?\?)",essence_info[num[ctr]].value));
7288 c_prt(col, dummy2, ctr+2, x);
7298 /* Restore the screen */
7309 ask = (isupper(choice));
7312 if (ask) choice = tolower(choice);
7314 /* Extract request */
7315 i = (islower(choice) ? A2I(choice) : -1);
7318 /* Totally Illegal */
7319 if ((i < 0) || (i >= max_num) || !able[i])
7332 (void) strnfmt(tmp_val, 78, "%s¤òÉղä·¤Þ¤¹¤«¡© ", essence_info[num[i]].add_name);
7334 (void) strnfmt(tmp_val, 78, "Add the abilitiy of %s? ", essence_info[num[i]].add_name);
7337 /* Belay that order */
7338 if (!get_check(tmp_val)) continue;
7345 /* Restore the screen */
7346 if (redraw) screen_load();
7353 #endif /* ALLOW_REPEAT */
7355 if (num[i] == ESSENCE_SLAY_GLOVE-1)
7356 item_tester_tval = TV_GLOVES;
7358 item_tester_hook = item_tester_hook_melee_ammo;
7359 else if (num[i] == ESSENCE_ATTACK-1)
7360 item_tester_hook = item_tester_hook_weapon;
7361 else if (num[i] == ESSENCE_AC-1)
7362 item_tester_hook = item_tester_hook_armour;
7364 item_tester_hook = item_tester_hook_weapon_armour;
7365 item_tester_no_ryoute = TRUE;
7369 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
7370 s = "²þÎɤǤ¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
7372 q = "Improve which item? ";
7373 s = "You have nothing to improve.";
7376 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7378 /* Get the item (in the pack) */
7381 o_ptr = &inventory[item];
7384 /* Get the item (on the floor) */
7387 o_ptr = &o_list[0 - item];
7390 if ((mode != 6) && (o_ptr->name1 || o_ptr->art_name || o_ptr->xtra3))
7393 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï¤³¤ì°Ê¾å²þÎɤǤ¤Ê¤¤¡£");
7395 msg_print("This item is no more able to be improved");
7400 object_desc(o_name, o_ptr, FALSE, 0);
7402 use_essence = essence_info[num[i]].value;
7403 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
7404 if (o_ptr->number > 1)
7406 use_essence *= o_ptr->number;
7408 msg_format("%d¸Ä¤¢¤ë¤Î¤Ç¥¨¥Ã¥»¥ó¥¹¤Ï%dɬÍפǤ¹¡£", o_ptr->number, use_essence);
7410 msg_format("It will take %d essences.",use_essence);
7415 if (essence_info[num[i]].link)
7417 if (p_ptr->magic_num1[essence_info[num[i]].link-1] < use_essence)
7420 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7422 msg_print("You don't have enough essences.");
7426 if ((num[i] < 32) && (TR1_PVAL_MASK & (0x1L << num[i])))
7428 if (num[i] == ESSENCE_BLOWS-1)
7430 if (o_ptr->pval > 1)
7433 if (!get_check("½¤ÀµÃͤÏ1¤Ë¤Ê¤ê¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) return;
7435 if (!get_check("The magic number of this weapon will become 1. Are you sure? ")) return;
7440 else if (o_ptr->pval)
7442 use_essence *= o_ptr->pval;
7444 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
7446 msg_format("It will take %d essences.",use_essence);
7454 int limit = MIN(5, p_ptr->magic_num1[essence_info[num[i]].link-1]/essence_info[num[i]].value);
7458 sprintf(tmp, "¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d): ", limit);
7460 sprintf(tmp, "Enchant how many? (1-%d): ", limit);
7462 strcpy(tmp_val, "1");
7464 if (!get_string(tmp, tmp_val, 1)) return;
7465 pval = atoi(tmp_val);
7466 if (pval > limit) pval = limit;
7467 else if (pval < 1) pval = 1;
7469 use_essence *= pval;
7471 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
7473 msg_format("It will take %d essences.",use_essence);
7476 if (p_ptr->magic_num1[essence_info[num[i]].link-1] < use_essence)
7479 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7481 msg_print("You don't have enough essences.");
7486 else if (num[i] == ESSENCE_SLAY_GLOVE-1)
7490 int get_to_h, get_to_d;
7492 strcpy(tmp_val, "1");
7494 if (!get_string(format("¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
7496 if (!get_string(format("Enchant how many? (1-%d):", p_ptr->lev/7+3), tmp_val, 2)) return;
7498 val = atoi(tmp_val);
7499 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
7500 else if (val < 1) val = 1;
7503 msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
7505 msg_format("It will take %d essences.",use_essence);
7507 if (p_ptr->magic_num1[essence_info[num[i]].link-1] < use_essence)
7510 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7512 msg_print("You don't have enough essences");
7516 get_to_h = ((val+1)/2+rand_int(val/2+1));
7517 get_to_d = ((val+1)/2+rand_int(val/2+1));
7518 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
7519 o_ptr->to_h += get_to_h;
7520 o_ptr->to_d += get_to_d;
7522 p_ptr->magic_num1[essence_info[num[i]].link-1] -= use_essence;
7523 if (num[i] == ESSENCE_ATTACK-1)
7525 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
7528 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
7530 msg_print("You failed to enchant.");
7537 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
7538 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
7541 else if (num[i] == ESSENCE_AC-1)
7543 if (o_ptr->to_a >= p_ptr->lev/5+5)
7546 msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
7548 msg_print("You failed to enchant.");
7555 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
7560 o_ptr->xtra3 = num[i]+1;
7565 bool success = TRUE;
7569 case ESSENCE_SH_FIRE:
7570 if ((p_ptr->magic_num1[ESSENCE_B_FIRE-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_FIRE-1] < use_essence))
7575 p_ptr->magic_num1[ESSENCE_B_FIRE-1] -= use_essence;
7576 p_ptr->magic_num1[ESSENCE_RES_FIRE-1] -= use_essence;
7578 case ESSENCE_SH_ELEC:
7579 if ((p_ptr->magic_num1[ESSENCE_B_ELEC-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_ELEC-1] < use_essence))
7584 p_ptr->magic_num1[ESSENCE_B_ELEC-1] -= use_essence;
7585 p_ptr->magic_num1[ESSENCE_RES_ELEC-1] -= use_essence;
7587 case ESSENCE_SH_COLD:
7588 if ((p_ptr->magic_num1[ESSENCE_B_COLD-1] < use_essence) || (p_ptr->magic_num1[ESSENCE_RES_COLD-1] < use_essence))
7593 p_ptr->magic_num1[ESSENCE_B_COLD-1] -= use_essence;
7594 p_ptr->magic_num1[ESSENCE_RES_COLD-1] -= use_essence;
7596 case ESSENCE_RESISTANCE:
7597 case ESSENCE_SUSTAIN:
7598 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))
7603 p_ptr->magic_num1[ESSENCE_RES_ACID-1] -= use_essence;
7604 p_ptr->magic_num1[ESSENCE_RES_ELEC-1] -= use_essence;
7605 p_ptr->magic_num1[ESSENCE_RES_FIRE-1] -= use_essence;
7606 p_ptr->magic_num1[ESSENCE_RES_COLD-1] -= use_essence;
7612 msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â¤ê¤Ê¤¤¡£");
7614 msg_print("You don't have enough essences");
7618 if (num[i] == ESSENCE_SUSTAIN-1)
7619 o_ptr->art_flags3 |= (TR3_IGNORE_ACID | TR3_IGNORE_ELEC | TR3_IGNORE_FIRE | TR3_IGNORE_COLD);
7620 else o_ptr->xtra3 = num[i]+1;
7626 msg_format("%s¤Ë%s¤ÎǽÎϤòÉղä·¤Þ¤·¤¿¡£", o_name, essence_info[num[i]].add_name);
7628 msg_format("You have added ability of %s to %s.", essence_info[num[i]].add_name, o_name);
7631 /* Combine the pack */
7632 p_ptr->notice |= (PN_COMBINE);
7635 p_ptr->window |= (PW_INVEN);
7639 bool item_tester_hook_kaji(object_type *o_ptr)
7641 switch (o_ptr->tval)
7661 if (o_ptr->xtra3) return (TRUE);
7669 void erase_essence(void)
7674 char o_name[MAX_NLEN];
7677 item_tester_hook = item_tester_hook_kaji;
7681 q = "¤É¤Î¥¢¥¤¥Æ¥à¤Î¥¨¥Ã¥»¥ó¥¹¤ò¾Ãµî¤·¤Þ¤¹¤«¡©";
7682 s = "¥¨¥Ã¥»¥ó¥¹¤òÉղä·¤¿¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
7684 q = "Remove from which item? ";
7685 s = "You have nothing to remove essence.";
7688 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7690 /* Get the item (in the pack) */
7693 o_ptr = &inventory[item];
7696 /* Get the item (on the floor) */
7699 o_ptr = &o_list[0 - item];
7702 object_desc(o_name, o_ptr, FALSE, 0);
7704 if (!get_check(format("¤è¤í¤·¤¤¤Ç¤¹¤«¡©[%s]", o_name))) return;
7706 if (!get_check(format("Are you sure?[%s]", o_name))) return;
7711 if (o_ptr->xtra3 == ESSENCE_SLAY_GLOVE)
7713 o_ptr->to_h -= (o_ptr->xtra4>>8);
7714 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
7718 object_flags(o_ptr, &f1, &f2, &f3);
7719 if (!(f1 & TR1_PVAL_MASK)) o_ptr->pval = 0;
7721 msg_print("¥¨¥Ã¥»¥ó¥¹¤ò¼è¤êµî¤Ã¤¿¡£");
7723 msg_print("You removed all essence you have added");
7726 /* Combine the pack */
7727 p_ptr->notice |= (PN_COMBINE);
7730 p_ptr->window |= (PW_INVEN);
7733 void do_cmd_kaji(bool only_browse)
7738 int menu_line = (use_menu ? 1 : 0);
7742 if (p_ptr->confused)
7745 msg_print("º®Í𤷤Ƥ¤¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
7747 msg_print("You are too confused!");
7755 msg_print("Ìܤ¬¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
7757 msg_print("You are blind!");
7765 msg_print("¤¦¤Þ¤¯¸«¤¨¤Ê¤¯¤Æºî¶È¤Ç¤¤Ê¤¤¡ª");
7767 msg_print("You are hullcinating!");
7775 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
7777 #endif /* ALLOW_REPEAT */
7779 if (only_browse) screen_save();
7781 if (!only_browse) screen_save();
7787 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", (menu_line == 1) ? "¡Õ" : " "), 2, 14);
7788 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", (menu_line == 2) ? "¡Õ" : " "), 3, 14);
7789 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹¾Ãµî", (menu_line == 3) ? "¡Õ" : " "), 4, 14);
7790 prt(format(" %s ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", (menu_line == 4) ? "¡Õ" : " "), 5, 14);
7791 prt(format(" %s Éð´ï/Ëɶñ¶¯²½", (menu_line == 5) ? "¡Õ" : " "), 6, 14);
7792 prt(format("¤É¤Î¼ïÎà¤Îµ»½Ñ¤ò%s¤Þ¤¹¤«¡©", only_browse ? "Ä´¤Ù" : "»È¤¤"), 0, 0);
7794 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
7795 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
7796 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
7797 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
7798 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
7799 prt(format("Choose command from menu."), 0, 0);
7825 if (menu_line > 5) menu_line -= 5;
7834 prt(" a) ¥¨¥Ã¥»¥ó¥¹°ìÍ÷", 2, 14);
7835 prt(" b) ¥¨¥Ã¥»¥ó¥¹Ãê½Ð", 3, 14);
7836 prt(" c) ¥¨¥Ã¥»¥ó¥¹¾Ãµî", 4, 14);
7837 prt(" d) ¥¨¥Ã¥»¥ó¥¹ÉÕ²Ã", 5, 14);
7838 prt(" e) Éð´ï/Ëɶñ¶¯²½", 6, 14);
7839 if (!get_com(format("¤É¤ÎǽÎϤò%s¤Þ¤¹¤«:", only_browse ? "Ä´¤Ù" : "»È¤¤"), &choice, TRUE))
7841 prt(" a) List essences", 2, 14);
7842 prt(" b) Extract essence", 3, 14);
7843 prt(" c) Remove essence", 4, 14);
7844 prt(" d) Add essence", 5, 14);
7845 prt(" e) Enchant weapon/armor", 6, 14);
7846 if (!get_com("Command :", &choice, TRUE))
7883 /* Clear lines, position cursor (really should use strlen here) */
7884 Term_erase(14, 21, 255);
7885 Term_erase(14, 20, 255);
7886 Term_erase(14, 19, 255);
7887 Term_erase(14, 18, 255);
7888 Term_erase(14, 17, 255);
7889 Term_erase(14, 16, 255);
7891 roff_to_buf( kaji_tips[mode-1],62,temp);
7892 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
7894 prt(&temp[j], line, 15);
7899 if (!only_browse) screen_load();
7900 } while (only_browse);
7904 #endif /* ALLOW_REPEAT */
7908 case 1: display_essence();break;
7909 case 2: drain_essence();break;
7910 case 3: erase_essence();break;
7912 mode = choose_essence();
7917 case 5: add_essence(6);break;