3 * @brief オブジェクトの実装 / Object code, part 2
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
8 * This software may be copied and distributed for educational, research,\n
9 * and not for profit purposes provided that this copyright and statement\n
10 * are included in all such copies. Other copyrights may also apply.\n
11 * 2014 Deskull rearranged comment for Doxygen.\n
15 #include "object-hook.h"
16 #include "object-curse.h"
18 static void one_sustain(object_type *o_ptr);
21 static cptr const kaji_tips[5] =
24 "現在持っているエッセンスの一覧を表示する。",
25 "アイテムからエッセンスを取り出す。エッセンスを取られたアイテムは全く魔法がかかっていない初期状態に戻る。",
26 "既にエッセンスが付加されたアイテムからエッセンスのみ消し去る。エッセンスは手に入らない。",
27 "アイテムにエッセンスを付加する。既にエッセンスが付加されたアイテムやアーティファクトには付加できない。",
28 "武器や防具を強化したり、攻撃で傷つかないようにしたりする。エッセンスが付加されたアイテムやアーティファクトに対しても使用できる。",
30 "Display essences you have.",
31 "Extract essences from an item. The item become non magical.",
32 "Remove added essences from an equipment which was improved before. The removed essence will be ruined.",
33 "Add essences to an item. The improved items or artifacts cannot be reimprove.",
34 "Enchant an equipment or make an equiment element-proofed. The improved items and artifacts can be enchanted too.",
39 * @brief 対象のオブジェクトにランダムな能力維持を一つ付加する。/ Choose one random sustain
41 * @param o_ptr 対象のオブジェクト構造体ポインタ
44 static void one_sustain(object_type *o_ptr)
48 case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break;
49 case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break;
50 case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break;
51 case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break;
52 case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break;
53 case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break;
58 * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
59 * @param o_idx 削除対象のオブジェクト構造体ポインタ
62 void excise_object_idx(OBJECT_IDX o_idx)
66 OBJECT_IDX this_o_idx, next_o_idx = 0;
72 j_ptr = &o_list[o_idx];
75 if (j_ptr->held_m_idx)
80 m_ptr = &m_list[j_ptr->held_m_idx];
82 /* Scan all objects in the grid */
83 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
88 o_ptr = &o_list[this_o_idx];
90 /* Acquire next object */
91 next_o_idx = o_ptr->next_o_idx;
93 if (this_o_idx == o_idx)
98 /* Remove from list */
99 m_ptr->hold_o_idx = next_o_idx;
107 /* Previous object */
108 k_ptr = &o_list[prev_o_idx];
110 /* Remove from list */
111 k_ptr->next_o_idx = next_o_idx;
114 /* Forget next pointer */
115 o_ptr->next_o_idx = 0;
120 /* Save prev_o_idx */
121 prev_o_idx = this_o_idx;
130 POSITION y = j_ptr->iy;
131 POSITION x = j_ptr->ix;
136 /* Scan all objects in the grid */
137 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
142 o_ptr = &o_list[this_o_idx];
144 /* Acquire next object */
145 next_o_idx = o_ptr->next_o_idx;
147 if (this_o_idx == o_idx)
152 /* Remove from list */
153 c_ptr->o_idx = next_o_idx;
161 /* Previous object */
162 k_ptr = &o_list[prev_o_idx];
164 /* Remove from list */
165 k_ptr->next_o_idx = next_o_idx;
168 /* Forget next pointer */
169 o_ptr->next_o_idx = 0;
174 /* Save prev_o_idx */
175 prev_o_idx = this_o_idx;
181 * @brief オブジェクトを削除する /
182 * Delete a dungeon object
183 * @param o_idx 削除対象のオブジェクト構造体ポインタ
186 * Handle "stacks" of objects correctly.
188 void delete_object_idx(OBJECT_IDX o_idx)
193 excise_object_idx(o_idx);
196 j_ptr = &o_list[o_idx];
199 if (!(j_ptr->held_m_idx))
210 /* Wipe the object */
219 * @brief フロアにマスに落ちているオブジェクトを全て削除する / Deletes all objects at given location
220 * Delete a dungeon object
221 * @param y 削除したフロアマスのY座標
222 * @param x 削除したフロアマスのX座標
225 void delete_object(POSITION y, POSITION x)
228 OBJECT_IDX this_o_idx, next_o_idx = 0;
230 /* Refuse "illegal" locations */
231 if (!in_bounds(y, x)) return;
236 /* Scan all objects in the grid */
237 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
242 o_ptr = &o_list[this_o_idx];
244 /* Acquire next object */
245 next_o_idx = o_ptr->next_o_idx;
247 /* Wipe the object */
254 /* Objects are gone */
263 * @brief グローバルオブジェクト配列に対し指定範囲のオブジェクトを整理してIDの若い順に寄せる /
264 * Move an object from index i1 to index i2 in the object list
265 * @param i1 整理したい配列の始点
266 * @param i2 整理したい配列の終点
269 static void compact_objects_aux(IDX i1, IDX i2)
276 if (i1 == i2) return;
280 for (i = 1; i < o_max; i++)
285 /* Skip "dead" objects */
286 if (!o_ptr->k_idx) continue;
288 /* Repair "next" pointers */
289 if (o_ptr->next_o_idx == i1)
292 o_ptr->next_o_idx = i2;
302 if (o_ptr->held_m_idx)
306 /* Acquire monster */
307 m_ptr = &m_list[o_ptr->held_m_idx];
310 if (m_ptr->hold_o_idx == i1)
313 m_ptr->hold_o_idx = i2;
322 /* Acquire location */
330 if (c_ptr->o_idx == i1)
339 o_list[i2] = o_list[i1];
347 * @brief グローバルオブジェクト配列から優先度の低いものを削除し、データを圧縮する。 /
348 * Compact and Reorder the object list.
349 * @param size 最低でも減らしたいオブジェクト数の水準
353 * This function can be very dangerous, use with caution!\n
355 * When actually "compacting" objects, we base the saving throw on a\n
356 * combination of object level, distance from player, and current\n
359 * After "compacting" (if needed), we "reorder" the objects into a more\n
360 * compact order, and we reset the allocation info, and the "live" array.\n
362 void compact_objects(int size)
367 int cur_lev, cur_dis, chance;
374 msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
377 p_ptr->redraw |= (PR_MAP);
379 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
383 /* Compact at least 'size' objects */
384 for (num = 0, cnt = 1; num < size; cnt++)
386 /* Get more vicious each iteration */
389 /* Get closer each iteration */
390 cur_dis = 5 * (20 - cnt);
392 /* Examine the objects */
393 for (i = 1; i < o_max; i++)
397 /* Skip dead objects */
398 if (!o_ptr->k_idx) continue;
400 /* Hack -- High level objects start out "immune" */
401 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
404 if (o_ptr->held_m_idx)
408 /* Acquire monster */
409 m_ptr = &m_list[o_ptr->held_m_idx];
411 /* Get the location */
415 /* Monsters protect their objects */
416 if (randint0(100) < 90) continue;
422 /* Get the location */
427 /* Nearby objects start out "immune" */
428 if ((cur_dis > 0) && (distance(p_ptr->y, p_ptr->x, y, x) < cur_dis)) continue;
433 /* Hack -- only compact artifacts in emergencies */
434 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
435 (cnt < 1000)) chance = 100;
437 /* Apply the saving throw */
438 if (randint0(100) < chance) continue;
440 /* Delete the object */
441 delete_object_idx(i);
449 /* Excise dead objects (backwards!) */
450 for (i = o_max - 1; i >= 1; i--)
454 /* Skip real objects */
455 if (o_ptr->k_idx) continue;
457 /* Move last object into open hole */
458 compact_objects_aux(o_max - 1, i);
460 /* Compress "o_max" */
467 * @brief グローバルオブジェクト配列を初期化する /
468 * Delete all the items when player leaves the level
469 * @note we do NOT visually reflect these (irrelevant) changes
471 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
472 * and the "m_ptr->next_o_idx" field for every monster, since
473 * we know we are clearing every object. Technically, we only
474 * clear those fields for grids/monsters containing objects,
475 * and we clear it once for every such object.
478 void wipe_o_list(void)
482 /* Delete the existing objects */
483 for (i = 1; i < o_max; i++)
485 object_type *o_ptr = &o_list[i];
487 /* Skip dead objects */
488 if (!o_ptr->k_idx) continue;
490 /* Mega-Hack -- preserve artifacts */
491 if (!character_dungeon || preserve_mode)
493 /* Hack -- Preserve unknown artifacts */
494 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
496 /* Mega-Hack -- Preserve the artifact */
497 a_info[o_ptr->name1].cur_num = 0;
502 if (o_ptr->held_m_idx)
507 m_ptr = &m_list[o_ptr->held_m_idx];
509 /* Hack -- see above */
510 m_ptr->hold_o_idx = 0;
518 /* Access location */
519 POSITION y = o_ptr->iy;
520 POSITION x = o_ptr->ix;
525 /* Hack -- see above */
529 /* Wipe the object */
542 * @brief グローバルオブジェクト配列から空きを取得する /
543 * Acquires and returns the index of a "free" object.
544 * @return 開いているオブジェクト要素のID
546 * This routine should almost never fail, but in case it does,
547 * we must be sure to handle "failure" of this routine.
549 OBJECT_IDX o_pop(void)
553 /* Initial allocation */
554 if (o_max < max_o_idx)
559 /* Expand object array */
565 /* Use this object */
570 /* Recycle dead objects */
571 for (i = 1; i < o_max; i++)
578 /* Skip live objects */
579 if (o_ptr->k_idx) continue;
584 /* Use this object */
589 /* Warn the player (except during dungeon creation) */
590 if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!"));
598 * @brief オブジェクト生成テーブルに生成制約を加える /
599 * Apply a "object restriction function" to the "object allocation table"
601 * @details 生成の制約はグローバルのget_obj_num_hook関数ポインタで加える
603 static errr get_obj_num_prep(void)
608 alloc_entry *table = alloc_kind_table;
610 /* Scan the allocation table */
611 for (i = 0; i < alloc_kind_size; i++)
613 /* Accept objects which pass the restriction, if any */
614 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
616 /* Accept this object */
617 table[i].prob2 = table[i].prob1;
620 /* Do not use this object */
623 /* Decline this object */
634 * @brief オブジェクト生成テーブルからアイテムを取得する /
635 * Choose an object kind that seems "appropriate" to the given level
637 * @return 選ばれたオブジェクトベースID
639 * This function uses the "prob2" field of the "object allocation table",\n
640 * and various local information, to calculate the "prob3" field of the\n
641 * same table, which is then used to choose an "appropriate" object, in\n
642 * a relatively efficient manner.\n
644 * It is (slightly) more likely to acquire an object of the given level\n
645 * than one of a lower level. This is done by choosing several objects\n
646 * appropriate to the given level and keeping the "hardest" one.\n
648 * Note that if no objects are "appropriate", then this function will\n
649 * fail, and return zero, but this should *almost* never happen.\n
651 OBJECT_IDX get_obj_num(DEPTH level)
654 KIND_OBJECT_IDX k_idx;
657 alloc_entry *table = alloc_kind_table;
659 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
662 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
664 /* Occasional "boost" */
665 if (one_in_(GREAT_OBJ))
667 /* What a bizarre calculation */
668 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
675 /* Process probabilities */
676 for (i = 0; i < alloc_kind_size; i++)
678 /* Objects are sorted by depth */
679 if (table[i].level > level) break;
684 /* Access the index */
685 k_idx = table[i].index;
687 /* Access the actual kind */
688 k_ptr = &k_info[k_idx];
690 /* Hack -- prevent embedded chests */
691 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
694 table[i].prob3 = table[i].prob2;
697 total += table[i].prob3;
700 /* No legal objects */
701 if (total <= 0) return (0);
705 value = randint0(total);
707 /* Find the object */
708 for (i = 0; i < alloc_kind_size; i++)
710 /* Found the entry */
711 if (value < table[i].prob3) break;
714 value = value - table[i].prob3;
721 /* Try for a "better" object once (50%) or twice (10%) */
728 value = randint0(total);
730 /* Find the object */
731 for (i = 0; i < alloc_kind_size; i++)
733 /* Found the entry */
734 if (value < table[i].prob3) break;
737 value = value - table[i].prob3;
740 /* Keep the "best" one */
741 if (table[i].level < table[j].level) i = j;
744 /* Try for a "better" object twice (10%) */
751 value = randint0(total);
753 /* Find the object */
754 for (i = 0; i < alloc_kind_size; i++)
756 /* Found the entry */
757 if (value < table[i].prob3) break;
760 value = value - table[i].prob3;
763 /* Keep the "best" one */
764 if (table[i].level < table[j].level) i = j;
769 return (table[i].index);
774 * @brief オブジェクトを鑑定済にする /
775 * Known is true when the "attributes" of an object are "known".
776 * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
778 * These include tohit, todam, toac, cost, and pval (charges).\n
780 * Note that "knowing" an object gives you everything that an "awareness"\n
781 * gives you, and much more. In fact, the player is always "aware" of any\n
782 * item of which he has full "knowledge".\n
784 * But having full knowledge of, say, one "wand of wonder", does not, by\n
785 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
786 * It happens that most "identify" routines (including "buying from a shop")\n
787 * will make the player "aware" of the object as well as fully "know" it.\n
789 * This routine also removes any inscriptions generated by "feelings".\n
791 void object_known(object_type *o_ptr)
793 /* Remove "default inscriptions" */
794 o_ptr->feeling = FEEL_NONE;
796 /* Clear the "Felt" info */
797 o_ptr->ident &= ~(IDENT_SENSE);
799 /* Clear the "Empty" info */
800 o_ptr->ident &= ~(IDENT_EMPTY);
802 /* Now we know about the item */
803 o_ptr->ident |= (IDENT_KNOWN);
807 * @brief オブジェクトを*鑑定*済にする /
808 * The player is now aware of the effects of the given object.
809 * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
812 void object_aware(object_type *o_ptr)
814 bool mihanmei = !object_is_aware(o_ptr);
816 /* Fully aware of the effects */
817 k_info[o_ptr->k_idx].aware = TRUE;
819 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
820 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
824 char o_name[MAX_NLEN];
827 object_copy(q_ptr, o_ptr);
830 object_desc(o_name, q_ptr, OD_NAME_ONLY);
832 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
837 * @brief オブジェクトを試行済にする /
838 * Something has been "sampled"
839 * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
842 void object_tried(object_type *o_ptr)
844 /* Mark it as tried (even if "aware") */
845 k_info[o_ptr->k_idx].tried = TRUE;
849 * @brief 重度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 1 (Heavy).
850 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
851 * @return 擬似鑑定結果のIDを返す。
853 byte value_check_aux1(object_type *o_ptr)
856 if (object_is_artifact(o_ptr))
859 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_TERRIBLE;
866 if (object_is_ego(o_ptr))
869 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_WORTHLESS;
872 return FEEL_EXCELLENT;
876 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
879 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
881 if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) return FEEL_AVERAGE;
883 /* Good "armor" bonus */
884 if (o_ptr->to_a > 0) return FEEL_GOOD;
886 /* Good "weapon" bonus */
887 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_GOOD;
889 /* Default to "average" */
894 * @brief 軽度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 2 (Light).
895 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
896 * @return 擬似鑑定結果のIDを返す。
898 byte value_check_aux2(object_type *o_ptr)
900 /* Cursed items (all of them) */
901 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
903 /* Broken items (all of them) */
904 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
906 /* Artifacts -- except cursed/broken ones */
907 if (object_is_artifact(o_ptr)) return FEEL_UNCURSED;
909 /* Ego-Items -- except cursed/broken ones */
910 if (object_is_ego(o_ptr)) return FEEL_UNCURSED;
912 /* Good armor bonus */
913 if (o_ptr->to_a > 0) return FEEL_UNCURSED;
915 /* Good weapon bonuses */
916 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_UNCURSED;
923 * @brief 未鑑定なベースアイテムの基本価格を返す /
924 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
925 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
926 * @return オブジェクトの未鑑定価格
928 static s32b object_value_base(object_type *o_ptr)
930 /* Aware item -- use template cost */
931 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
933 /* Analyze the type */
938 case TV_FOOD: return (5L);
940 /* Un-aware Potions */
941 case TV_POTION: return (20L);
943 /* Un-aware Scrolls */
944 case TV_SCROLL: return (20L);
946 /* Un-aware Staffs */
947 case TV_STAFF: return (70L);
950 case TV_WAND: return (50L);
953 case TV_ROD: return (90L);
956 case TV_RING: return (45L);
958 /* Un-aware Amulets */
959 case TV_AMULET: return (45L);
961 /* Figurines, relative to monster level */
964 DEPTH level = r_info[o_ptr->pval].level;
965 if (level < 20) return level*50L;
966 else if (level < 30) return 1000+(level-20)*150L;
967 else if (level < 40) return 2500+(level-30)*350L;
968 else if (level < 50) return 6000+(level-40)*800L;
969 else return 14000+(level-50)*2000L;
973 if (!o_ptr->pval) return 1000L;
974 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
977 /* Paranoia -- Oops */
983 * @brief オブジェクトのフラグ類から価格を算出する /
984 * Return the value of the flags the object has...
985 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
986 * @param plusses フラグに与える価格の基本重み
987 * @return オブジェクトのフラグ価格
989 s32b flag_cost(object_type *o_ptr, int plusses)
992 BIT_FLAGS flgs[TR_FLAG_SIZE];
996 object_kind *k_ptr = &k_info[o_ptr->k_idx];
998 object_flags(o_ptr, flgs);
1001 * Exclude fixed flags of the base item.
1002 * pval bonuses of base item will be treated later.
1004 for (i = 0; i < TR_FLAG_SIZE; i++)
1005 flgs[i] &= ~(k_ptr->flags[i]);
1007 /* Exclude fixed flags of the fixed artifact. */
1008 if (object_is_fixed_artifact(o_ptr))
1010 artifact_type *a_ptr = &a_info[o_ptr->name1];
1012 for (i = 0; i < TR_FLAG_SIZE; i++)
1013 flgs[i] &= ~(a_ptr->flags[i]);
1016 /* Exclude fixed flags of the ego-item. */
1017 else if (object_is_ego(o_ptr))
1019 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1021 for (i = 0; i < TR_FLAG_SIZE; i++)
1022 flgs[i] &= ~(e_ptr->flags[i]);
1027 * Calucurate values of remaining flags
1029 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
1030 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
1031 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
1032 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
1033 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
1034 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
1035 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
1036 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
1037 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
1038 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
1039 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
1040 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
1041 total += (10000 + (2500 * plusses));
1042 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
1043 total += (10000 + (2500 * plusses));
1047 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
1048 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
1049 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
1050 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
1051 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
1052 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
1053 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
1054 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
1055 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
1056 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
1057 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
1058 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
1059 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
1060 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
1061 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
1062 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
1063 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
1064 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
1065 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
1066 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
1067 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
1069 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
1070 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
1071 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
1072 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
1073 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
1074 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
1075 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
1076 total += (tmp_cost * count);
1078 if (have_flag(flgs, TR_SUST_STR)) total += 850;
1079 if (have_flag(flgs, TR_SUST_INT)) total += 850;
1080 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
1081 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
1082 if (have_flag(flgs, TR_SUST_CON)) total += 850;
1083 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
1084 if (have_flag(flgs, TR_RIDING)) total += 0;
1085 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
1086 if (have_flag(flgs, TR_THROW)) total += 5000;
1087 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
1088 if (have_flag(flgs, TR_HOLD_EXP)) total += 8500;
1092 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
1093 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
1094 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
1095 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
1096 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
1097 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
1098 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1099 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1100 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1101 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1102 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1103 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1104 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1105 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1106 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1107 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1108 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1109 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1110 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1111 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1112 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1113 total += (tmp_cost * count);
1115 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1116 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1117 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1118 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1119 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1120 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1121 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1122 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1123 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1124 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1125 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1126 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1127 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1128 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1129 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1130 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1131 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1132 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1133 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1134 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1135 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1136 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1137 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1138 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1139 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1140 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1141 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1142 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1143 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1144 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1145 if (have_flag(flgs, TR_REGEN)) total += 2500;
1146 if (have_flag(flgs, TR_WARNING)) total += 2000;
1147 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1148 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1149 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1150 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1151 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1152 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1153 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1154 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1155 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1156 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1157 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1158 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1159 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1160 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1161 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1162 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1163 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1164 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1165 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1166 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1167 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1168 if (have_flag(flgs, TR_TELEPORT))
1170 if (object_is_cursed(o_ptr))
1175 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1176 if (have_flag(flgs, TR_BLESSED)) total += 750;
1177 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1178 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1179 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1180 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1181 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1183 /* Also, give some extra for activatable powers... */
1184 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1186 const activation_type* const act_ptr = find_activation_info(o_ptr);
1188 total += act_ptr->value;
1197 * @brief オブジェクトの真の価格を算出する /
1198 * Return the value of the flags the object has...
1199 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
1200 * @return オブジェクトの本価格
1202 * Return the "real" price of a "known" item, not including discounts\n
1204 * Wand and staffs get cost for each charge\n
1206 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1208 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1210 * Missiles are only worth 5 gold per bonus point, since they\n
1211 * usually appear in groups of 20, and we want the player to get\n
1212 * the same amount of cash for any "equivalent" item. Note that\n
1213 * missiles never have any of the "pval" flags, and in fact, they\n
1214 * only have a few of the available flags, primarily of the "slay"\n
1215 * and "brand" and "ignore" variety.\n
1217 * Armor with a negative armor bonus is worthless.\n
1218 * Weapons with negative hit+damage bonuses are worthless.\n
1220 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1222 PRICE object_value_real(object_type *o_ptr)
1225 BIT_FLAGS flgs[TR_FLAG_SIZE];
1226 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1229 /* Hack -- "worthless" items */
1230 if (!k_info[o_ptr->k_idx].cost) return (0L);
1233 value = k_info[o_ptr->k_idx].cost;
1235 /* Extract some flags */
1236 object_flags(o_ptr, flgs);
1239 if (object_is_fixed_artifact(o_ptr))
1241 artifact_type *a_ptr = &a_info[o_ptr->name1];
1243 /* Hack -- "worthless" artifacts */
1244 if (!a_ptr->cost) return (0L);
1246 /* Hack -- Use the artifact cost instead */
1247 value = a_ptr->cost;
1248 value += flag_cost(o_ptr, o_ptr->pval);
1250 /* Don't add pval bonuses etc. */
1255 else if (object_is_ego(o_ptr))
1257 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1259 /* Hack -- "worthless" ego-items */
1260 if (!e_ptr->cost) return (0L);
1262 /* Hack -- Reward the ego-item with a bonus */
1263 value += e_ptr->cost;
1264 value += flag_cost(o_ptr, o_ptr->pval);
1272 for (i = 0; i < TR_FLAG_SIZE; i++)
1273 if (o_ptr->art_flags[i]) flag = TRUE;
1275 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1278 /* Analyze pval bonus for normal object */
1279 switch (o_ptr->tval)
1302 if (!o_ptr->pval) break;
1304 /* Hack -- Negative "pval" is always bad */
1305 if (o_ptr->pval < 0) return (0L);
1307 /* Give credit for stat bonuses */
1308 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1309 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1310 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1311 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1312 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1313 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1315 /* Give credit for stealth and searching */
1316 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1317 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1318 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1320 /* Give credit for infra-vision and tunneling */
1321 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1322 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1324 /* Give credit for extra attacks */
1325 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1327 /* Give credit for speed bonus */
1328 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1334 /* Analyze the item */
1335 switch (o_ptr->tval)
1340 /* Pay extra for charges, depending on standard number of
1341 * charges. Handle new-style wands correctly. -LM-
1343 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1349 /* Pay extra for charges, depending on standard number of
1352 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1361 /* Hack -- negative bonuses are bad */
1362 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1364 /* Give credit for bonuses */
1365 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1381 /* Hack -- negative armor bonus */
1382 if (o_ptr->to_a < 0) return (0L);
1384 /* Give credit for bonuses */
1385 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1397 /* Hack -- negative hit/damage bonuses */
1398 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1400 /* Factor in the bonuses */
1401 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1403 /* Hack -- Factor in extra damage dice and sides */
1404 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1405 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1415 /* Hack -- negative hit/damage bonuses */
1416 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1418 /* Factor in the bonuses */
1419 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1421 /* Hack -- Factor in extra damage dice and sides */
1422 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1423 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1428 /* Figurines, relative to monster level */
1431 DEPTH level = r_info[o_ptr->pval].level;
1432 if (level < 20) value = level*50L;
1433 else if (level < 30) value = 1000+(level-20)*150L;
1434 else if (level < 40) value = 2500+(level-30)*350L;
1435 else if (level < 50) value = 6000+(level-40)*800L;
1436 else value = 14000+(level-50)*2000L;
1442 if (!o_ptr->pval) value = 1000L;
1443 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1449 if (!o_ptr->pval) value = 0L;
1454 /* Worthless object */
1455 if (value < 0) return 0L;
1457 /* Return the value */
1463 * @brief オブジェクト価格算出のメインルーチン /
1464 * Return the price of an item including plusses (and charges)
1465 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
1466 * @return オブジェクトの判明している現価格
1468 * This function returns the "value" of the given item (qty one)\n
1470 * Never notice "unknown" bonuses or properties, including "curses",\n
1471 * since that would give the player information he did not have.\n
1473 * Note that discounted items stay discounted forever, even if\n
1474 * the discount is "forgotten" by the player via memory loss.\n
1476 PRICE object_value(object_type *o_ptr)
1480 /* Unknown items -- acquire a base value */
1481 if (object_is_known(o_ptr))
1483 /* Broken items -- worthless */
1484 if (object_is_broken(o_ptr)) return (0L);
1486 /* Cursed items -- worthless */
1487 if (object_is_cursed(o_ptr)) return (0L);
1489 /* Real value (see above) */
1490 value = object_value_real(o_ptr);
1493 /* Known items -- acquire the actual value */
1496 /* Hack -- Felt broken items */
1497 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1499 /* Hack -- Felt cursed items */
1500 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1502 /* Base value (see above) */
1503 value = object_value_base(o_ptr);
1507 /* Apply discount (if any) */
1508 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1511 /* Return the final value */
1518 * @brief 破壊可能なアイテムかを返す /
1519 * Determines whether an object can be destroyed, and makes fake inscription.
1520 * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
1521 * @return オブジェクトが破壊可能ならばTRUEを返す
1523 bool can_player_destroy_object(object_type *o_ptr)
1525 /* Artifacts cannot be destroyed */
1526 if (!object_is_artifact(o_ptr)) return TRUE;
1528 /* If object is unidentified, makes fake inscription */
1529 if (!object_is_known(o_ptr))
1531 byte feel = FEEL_SPECIAL;
1533 /* Hack -- Handle icky artifacts */
1534 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1536 /* Hack -- inscribe the artifact */
1537 o_ptr->feeling = feel;
1539 /* We have "felt" it (again) */
1540 o_ptr->ident |= (IDENT_SENSE);
1542 /* Combine the pack */
1543 p_ptr->notice |= (PN_COMBINE);
1545 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1550 /* Identified artifact -- Nothing to do */
1556 * @brief 魔法棒やロッドのスロット分割時に使用回数を分配する /
1557 * Distribute charges of rods or wands.
1558 * @param o_ptr 分割元オブジェクトの構造体参照ポインタ source item
1559 * @param q_ptr 分割先オブジェクトの構造体参照ポインタ target item, must be of the same type as o_ptr
1560 * @param amt 分割したい回数量 number of items that are transfered
1563 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1564 * charges need to be allocated between the two stacks. If all the items\n
1565 * are being dropped, it makes for a neater message to leave the original\n
1566 * stack's pval alone. -LM-\n
1568 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1570 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1572 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1573 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1575 /* Hack -- Rods also need to have their timeouts distributed. The
1576 * dropped stack will accept all time remaining to charge up to its
1579 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1581 if (q_ptr->pval > o_ptr->timeout)
1582 q_ptr->timeout = o_ptr->timeout;
1584 q_ptr->timeout = q_ptr->pval;
1586 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1592 * @brief 魔法棒やロッドの使用回数を減らす /
1593 * @param o_ptr オブジェクトの構造体参照ポインタ source item
1594 * @param amt 減らしたい回数量 number of items that are transfered
1597 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1598 * charges of the stack needs to be reduced, unless all the items are\n
1599 * being destroyed. -LM-\n
1601 void reduce_charges(object_type *o_ptr, int amt)
1603 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1604 (amt < o_ptr->number))
1606 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1611 * Determine if an item can "absorb" a second item
1613 * See "object_absorb()" for the actual "absorption" code.
1615 * If permitted, we allow staffs (if they are known to have equal charges
1616 * and both are either known or confirmed empty) and wands (if both are
1617 * either known or confirmed empty) and rods (in all cases) to combine.
1618 * Staffs will unstack (if necessary) when they are used, but wands and
1619 * rods will only unstack if one is dropped. -LM-
1621 * If permitted, we allow weapons/armor to stack, if fully "known".
1623 * Missiles will combine if both stacks have the same "known" status.
1624 * This is done to make unidentified stacks of missiles useful.
1626 * Food, potions, scrolls, and "easy know" items always stack.
1628 * Chests, and activatable items, never stack (for various reasons).
1632 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1634 #define MAX_STACK_SIZE 99
1638 * @brief 両オブジェクトをスロットに重ね合わせ可能な最大数を返す。
1639 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1640 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1641 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1642 * @return 重ね合わせ可能なアイテム数
1644 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1648 /* Default maximum number of stack */
1649 int max_num = MAX_STACK_SIZE;
1651 /* Require identical object types */
1652 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1655 /* Analyze the items */
1656 switch (o_ptr->tval)
1658 /* Chests and Statues*/
1669 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1670 if (o_ptr->pval != j_ptr->pval) return 0;
1674 /* Figurines and Corpses*/
1679 if (o_ptr->pval != j_ptr->pval) return 0;
1685 /* Food and Potions and Scrolls */
1697 /* Require either knowledge or known empty for both staffs. */
1698 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1699 !object_is_known(o_ptr)) ||
1700 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1701 !object_is_known(j_ptr))) return 0;
1703 /* Require identical charges, since staffs are bulky. */
1704 if (o_ptr->pval != j_ptr->pval) return 0;
1713 /* Require either knowledge or known empty for both wands. */
1714 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1715 !object_is_known(o_ptr)) ||
1716 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1717 !object_is_known(j_ptr))) return 0;
1719 /* Wand charges combine in O&ZAngband. */
1725 /* Staffs and Wands and Rods */
1728 /* Prevent overflaw of timeout */
1729 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1735 /* Weapons and Armor */
1751 /* Rings, Amulets, Lites */
1757 /* Require full knowledge of both items */
1758 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1768 /* Require identical knowledge of both items */
1769 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1770 if (o_ptr->feeling != j_ptr->feeling) return 0;
1772 /* Require identical "bonuses" */
1773 if (o_ptr->to_h != j_ptr->to_h) return 0;
1774 if (o_ptr->to_d != j_ptr->to_d) return 0;
1775 if (o_ptr->to_a != j_ptr->to_a) return 0;
1777 /* Require identical "pval" code */
1778 if (o_ptr->pval != j_ptr->pval) return 0;
1780 /* Artifacts never stack */
1781 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1783 /* Require identical "ego-item" names */
1784 if (o_ptr->name2 != j_ptr->name2) return 0;
1786 /* Require identical added essence */
1787 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1788 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1790 /* Hack -- Never stack "powerful" items */
1791 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1793 /* Hack -- Never stack recharging items */
1794 if (o_ptr->timeout || j_ptr->timeout) return 0;
1796 /* Require identical "values" */
1797 if (o_ptr->ac != j_ptr->ac) return 0;
1798 if (o_ptr->dd != j_ptr->dd) return 0;
1799 if (o_ptr->ds != j_ptr->ds) return 0;
1808 /* Require knowledge */
1809 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1817 /* Hack -- Identical art_flags! */
1818 for (i = 0; i < TR_FLAG_SIZE; i++)
1819 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1821 /* Hack -- Require identical "cursed" status */
1822 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1824 /* Hack -- Require identical "broken" status */
1825 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1828 /* Hack -- require semi-matching "inscriptions" */
1829 if (o_ptr->inscription && j_ptr->inscription &&
1830 (o_ptr->inscription != j_ptr->inscription))
1833 /* Hack -- normally require matching "inscriptions" */
1834 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1836 /* Hack -- normally require matching "discounts" */
1837 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1840 /* They match, so they must be similar */
1845 * @brief 両オブジェクトをスロットに重ねることができるかどうかを返す。
1846 * Determine if an item can absorb a second item.
1847 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1848 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1849 * @return 重ね合わせ可能ならばTRUEを返す。
1851 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1853 int total = o_ptr->number + j_ptr->number;
1856 /* Are these objects similar? */
1857 max_num = object_similar_part(o_ptr, j_ptr);
1859 /* Return if not similar */
1860 if (!max_num) return FALSE;
1862 /* Maximal "stacking" limit */
1863 if (total > max_num) return (0);
1866 /* They match, so they must be similar */
1872 * @brief 両オブジェクトをスロットに重ね合わせる。
1873 * Allow one item to "absorb" another, assuming they are similar
1874 * @param o_ptr 重ね合わせ先のオブジェクトの構造体参照ポインタ
1875 * @param j_ptr 重ね合わせ元のオブジェクトの構造体参照ポインタ
1878 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1880 int max_num = object_similar_part(o_ptr, j_ptr);
1881 int total = o_ptr->number + j_ptr->number;
1882 int diff = (total > max_num) ? total - max_num : 0;
1884 /* Combine quantity, lose excess items */
1885 o_ptr->number = (total > max_num) ? max_num : total;
1887 /* Hack -- blend "known" status */
1888 if (object_is_known(j_ptr)) object_known(o_ptr);
1890 /* Hack -- clear "storebought" if only one has it */
1891 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1892 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1894 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1895 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1898 /* Hack -- blend "mental" status */
1899 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1901 /* Hack -- blend "inscriptions" */
1902 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1904 /* Hack -- blend "feelings" */
1905 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1907 /* Hack -- could average discounts XXX XXX XXX */
1908 /* Hack -- save largest discount XXX XXX XXX */
1909 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1911 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1912 if (o_ptr->tval == TV_ROD)
1914 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1915 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1918 /* Hack -- if wands are stacking, combine the charges. -LM- */
1919 if (o_ptr->tval == TV_WAND)
1921 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1927 * @brief tvalとsvalに対応するベースアイテムのIDを返す。
1928 * Find the index of the object_kind with the given tval and sval
1929 * @param tval 検索したいベースアイテムのtval
1930 * @param sval 検索したいベースアイテムのsval
1933 IDX lookup_kind(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval)
1940 for (k = 1; k < max_k_idx; k++)
1942 object_kind *k_ptr = &k_info[k];
1944 /* Require correct tval */
1945 if (k_ptr->tval != tval) continue;
1948 if (k_ptr->sval == sval) return (k);
1950 /* Ignore illegal items */
1951 if (sval != SV_ANY) continue;
1953 /* Apply the randomizer */
1954 if (!one_in_(++num)) continue;
1956 /* Use this value */
1960 /* Return this choice */
1968 msg_format(_("アイテムがない (%d,%d)", "No object (%d,%d)"), tval, sval);
1978 * @brief オブジェクトを初期化する
1979 * Wipe an object clean.
1980 * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ
1983 void object_wipe(object_type *o_ptr)
1985 /* Wipe the structure */
1986 (void)WIPE(o_ptr, object_type);
1991 * @brief オブジェクトを複製する
1992 * Wipe an object clean.
1993 * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ
1994 * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ
1997 void object_copy(object_type *o_ptr, object_type *j_ptr)
1999 /* Copy the structure */
2000 (void)COPY(o_ptr, j_ptr, object_type);
2005 * @brief オブジェクト構造体にベースアイテムを作成する
2006 * Prepare an object based on an object kind.
2007 * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ
2008 * @param k_idx 新たに作成したいベースアイテム情報のID
2011 void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx)
2013 object_kind *k_ptr = &k_info[k_idx];
2015 /* Clear the record */
2018 /* Save the kind index */
2019 o_ptr->k_idx = k_idx;
2021 /* Efficiency -- tval/sval */
2022 o_ptr->tval = k_ptr->tval;
2023 o_ptr->sval = k_ptr->sval;
2025 /* Default "pval" */
2026 o_ptr->pval = k_ptr->pval;
2028 /* Default number */
2031 /* Default weight */
2032 o_ptr->weight = k_ptr->weight;
2035 o_ptr->to_h = k_ptr->to_h;
2036 o_ptr->to_d = k_ptr->to_d;
2037 o_ptr->to_a = k_ptr->to_a;
2040 o_ptr->ac = k_ptr->ac;
2041 o_ptr->dd = k_ptr->dd;
2042 o_ptr->ds = k_ptr->ds;
2044 /* Default activation */
2045 if (k_ptr->act_idx > 0) o_ptr->xtra2 = (XTRA8)k_ptr->act_idx;
2047 /* Hack -- worthless items are always "broken" */
2048 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
2050 /* Hack -- cursed items are always "cursed" */
2051 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
2052 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2053 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
2054 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
2055 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
2056 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
2061 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
2062 * Help determine an "enchantment bonus" for an object.
2063 * @param max ボーナス値の限度
2064 * @param level ボーナス値に加味する基準生成階
2065 * @return 算出されたボーナス値
2067 * To avoid floating point but still provide a smooth distribution of bonuses,\n
2068 * we simply round the results of division in such a way as to "average" the\n
2069 * correct floating point value.\n
2071 * This function has been changed. It uses "randnor()" to choose values from\n
2072 * a normal distribution, whose mean moves from zero towards the max as the\n
2073 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
2074 * and whose values are forced to lie between zero and the max, inclusive.\n
2076 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2077 * rare to get the "full" enchantment on an object, even a deep levels.\n
2079 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2081 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2083 * N 0 1 2 3 4 5 6 7 8 9 10\n
2084 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2085 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2086 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2087 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2088 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2089 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2090 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2091 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2092 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2093 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2094 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2095 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2096 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2097 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2098 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2099 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2100 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2101 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2103 int m_bonus(int max, DEPTH level)
2105 int bonus, stand, extra, value;
2108 /* Paranoia -- enforce maximal "level" */
2109 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2112 /* The "bonus" moves towards the max */
2113 bonus = ((max * level) / MAX_DEPTH);
2115 /* Hack -- determine fraction of error */
2116 extra = ((max * level) % MAX_DEPTH);
2118 /* Hack -- simulate floating point computations */
2119 if (randint0(MAX_DEPTH) < extra) bonus++;
2122 /* The "stand" is equal to one quarter of the max */
2125 /* Hack -- determine fraction of error */
2128 /* Hack -- simulate floating point computations */
2129 if (randint0(4) < extra) stand++;
2132 /* Choose an "interesting" value */
2133 value = randnor(bonus, stand);
2135 /* Enforce the minimum value */
2136 if (value < 0) return (0);
2138 /* Enforce the maximum value */
2139 if (value > max) return (max);
2147 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
2148 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
2151 static void object_mention(object_type *o_ptr)
2153 char o_name[MAX_NLEN];
2155 object_aware(o_ptr);
2156 object_known(o_ptr);
2158 /* Mark the item as fully known */
2159 o_ptr->ident |= (IDENT_MENTAL);
2162 object_desc(o_name, o_ptr, 0);
2163 msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
2167 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2168 * Mega-Hack -- Attempt to create one of the "Special Objects"
2169 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2170 * @return 生成に成功したらTRUEを返す。
2172 * We are only called from "make_object()", and we assume that\n
2173 * "apply_magic()" is called immediately after we return.\n
2175 * Note -- see "make_artifact()" and "apply_magic()"\n
2177 static bool make_artifact_special(object_type *o_ptr)
2180 KIND_OBJECT_IDX k_idx = 0;
2182 /*! @note 地上ではキャンセルする / No artifacts in the town */
2183 if (!dun_level) return (FALSE);
2185 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2186 if (get_obj_num_hook) return (FALSE);
2188 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2189 for (i = 0; i < max_a_idx; i++)
2191 artifact_type *a_ptr = &a_info[i];
2193 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2194 if (!a_ptr->name) continue;
2196 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2197 if (a_ptr->cur_num) continue;
2198 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2199 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2201 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2202 * XXX XXX Enforce minimum "depth" (loosely) */
2203 if (a_ptr->level > object_level)
2205 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2206 int d = (a_ptr->level - object_level) * 2;
2207 if (!one_in_(d)) continue;
2210 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2211 if (!one_in_(a_ptr->rarity)) continue;
2213 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2214 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2215 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2216 if (k_info[k_idx].level > object_level)
2218 int d = (k_info[k_idx].level - object_level) * 5;
2219 if (!one_in_(d)) continue;
2222 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2223 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2224 object_prep(o_ptr, k_idx);
2227 random_artifact_resistance(o_ptr, a_ptr);
2231 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2237 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2238 * Mega-Hack -- Attempt to create one of the "Special Objects"
2239 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2240 * @return 生成に成功したらTRUEを返す。
2242 * Attempt to change an object into an artifact\n
2243 * This routine should only be called by "apply_magic()"\n
2244 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2246 static bool make_artifact(object_type *o_ptr)
2251 /* No artifacts in the town */
2252 if (!dun_level) return (FALSE);
2254 /* Paranoia -- no "plural" artifacts */
2255 if (o_ptr->number != 1) return (FALSE);
2257 /* Check the artifact list (skip the "specials") */
2258 for (i = 0; i < max_a_idx; i++)
2260 artifact_type *a_ptr = &a_info[i];
2262 /* Skip "empty" items */
2263 if (!a_ptr->name) continue;
2265 /* Cannot make an artifact twice */
2266 if (a_ptr->cur_num) continue;
2268 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2270 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2272 /* Must have the correct fields */
2273 if (a_ptr->tval != o_ptr->tval) continue;
2274 if (a_ptr->sval != o_ptr->sval) continue;
2276 /* XXX XXX Enforce minimum "depth" (loosely) */
2277 if (a_ptr->level > dun_level)
2279 /* Acquire the "out-of-depth factor" */
2280 int d = (a_ptr->level - dun_level) * 2;
2282 /* Roll for out-of-depth creation */
2283 if (!one_in_(d)) continue;
2286 /* We must make the "rarity roll" */
2287 if (!one_in_(a_ptr->rarity)) continue;
2289 /* Hack -- mark the item as an artifact */
2292 /* Hack: Some artifacts get random extra powers */
2293 random_artifact_resistance(o_ptr, a_ptr);
2305 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2306 * Choose random ego type
2307 * @param slot 取得したいエゴの装備部位
2308 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2309 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2311 static byte get_random_ego(byte slot, bool good)
2314 ego_item_type *e_ptr;
2318 for (i = 1; i < max_e_idx; i++)
2322 if (e_ptr->slot == slot
2323 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2326 total += (255 / e_ptr->rarity);
2330 value = randint1(total);
2332 for (i = 1; i < max_e_idx; i++)
2336 if (e_ptr->slot == slot
2337 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2340 value -= (255 / e_ptr->rarity);
2341 if (value <= 0L) break;
2349 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2350 * Apply magic to an item known to be a "weapon"
2351 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2352 * @param level 生成基準階
2353 * @param power 生成ランク
2356 * Hack -- note special base damage dice boosting\n
2357 * Hack -- note special processing for weapon/digger\n
2359 static void a_m_aux_1(object_type *o_ptr, DEPTH level, int power)
2361 HIT_PROB tohit1 = randint1(5) + (HIT_PROB)m_bonus(5, level);
2362 HIT_POINT todam1 = randint1(5) + (HIT_POINT)m_bonus(5, level);
2364 HIT_PROB tohit2 = (HIT_PROB)m_bonus(10, level);
2365 HIT_POINT todam2 = (HIT_POINT)m_bonus(10, level);
2367 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2369 tohit2 = (tohit2+1)/2;
2370 todam2 = (todam2+1)/2;
2377 o_ptr->to_h += tohit1;
2378 o_ptr->to_d += todam1;
2384 o_ptr->to_h += tohit2;
2385 o_ptr->to_d += todam2;
2393 o_ptr->to_h -= tohit1;
2394 o_ptr->to_d -= todam1;
2399 /* Penalize again */
2400 o_ptr->to_h -= tohit2;
2401 o_ptr->to_d -= todam2;
2404 /* Cursed (if "bad") */
2405 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2408 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2411 switch (o_ptr->tval)
2418 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2419 create_artifact(o_ptr, FALSE);
2421 /* Special Ego-item */
2422 o_ptr->name2 = EGO_DIGGING;
2426 else if (power < -1)
2428 /* Hack -- Horrible digging bonus */
2429 o_ptr->pval = 0 - (5 + randint1(5));
2435 /* Hack -- Reverse digging bonus */
2436 o_ptr->pval = 0 - (o_ptr->pval);
2450 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2452 create_artifact(o_ptr, FALSE);
2457 /* Roll for an ego-item */
2458 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2459 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2461 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2463 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2468 switch (o_ptr->name2)
2471 if (one_in_(4) && (level > 40))
2472 add_flag(o_ptr->art_flags, TR_BLOWS);
2476 add_flag(o_ptr->art_flags, TR_RES_POIS);
2478 add_flag(o_ptr->art_flags, TR_WARNING);
2480 case EGO_KILL_DRAGON:
2482 add_flag(o_ptr->art_flags, TR_RES_POIS);
2486 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2488 case EGO_SLAYING_WEAPON:
2489 if (one_in_(3)) /* double damage */
2497 while (one_in_(o_ptr->dd));
2503 while (one_in_(o_ptr->ds));
2508 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2510 if (o_ptr->tval == TV_SWORD && one_in_(3))
2512 add_flag(o_ptr->art_flags, TR_VORPAL);
2517 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2523 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2525 add_flag(o_ptr->art_flags, TR_DEX);
2527 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2530 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, level) + 1;
2532 case EGO_EARTHQUAKES:
2533 if (one_in_(3) && (level > 60))
2534 add_flag(o_ptr->art_flags, TR_BLOWS);
2536 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, level);
2540 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2544 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2546 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2548 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2549 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2552 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2553 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2554 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2555 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2559 if (!o_ptr->art_name)
2561 /* Hack -- Super-charge the damage dice */
2562 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2564 /* Hack -- Lower the damage dice */
2565 if (o_ptr->dd > 9) o_ptr->dd = 9;
2570 else if (power < -1)
2572 /* Roll for ego-item */
2573 if (randint0(MAX_DEPTH) < level)
2577 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2578 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2584 switch (o_ptr->name2)
2587 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2588 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2590 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2591 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2592 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2593 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2594 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2595 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2609 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2611 create_artifact(o_ptr, FALSE);
2614 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2628 if (power > 2) /* power > 2 is debug only */
2630 create_artifact(o_ptr, FALSE);
2634 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2636 switch (o_ptr->name2)
2638 case EGO_SLAYING_BOLT:
2643 /* Hack -- super-charge the damage dice */
2644 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2646 /* Hack -- restrict the damage dice */
2647 if (o_ptr->dd > 9) o_ptr->dd = 9;
2651 else if (power < -1)
2653 /* Roll for ego-item */
2654 if (randint0(MAX_DEPTH) < level)
2656 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2666 * @brief ドラゴン装備にランダムな耐性を与える
2667 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2670 static void dragon_resist(object_type * o_ptr)
2675 one_dragon_ele_resistance(o_ptr);
2677 one_high_resistance(o_ptr);
2683 * @brief オブジェクトにランダムな強いESPを与える
2684 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2687 static bool add_esp_strong(object_type *o_ptr)
2689 bool nonliv = FALSE;
2691 switch (randint1(3))
2693 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2694 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2695 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2702 * @brief オブジェクトにランダムな弱いESPを与える
2703 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2704 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2707 static void add_esp_weak(object_type *o_ptr, bool extra)
2710 u32b weak_esp_list[] = {
2722 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2723 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2725 /* Add unduplicated weak esp flags randomly */
2726 for (i = 0; i < add_count; ++ i)
2728 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2730 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2731 weak_esp_list[choice] = weak_esp_list[i];
2737 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2738 * Apply magic to an item known to be "armor"
2739 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2740 * @param level 生成基準階
2741 * @param power 生成ランク
2744 * Hack -- note special processing for crown/helm\n
2745 * Hack -- note special processing for robe of permanence\n
2747 static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power)
2749 ARMOUR_CLASS toac1 = (ARMOUR_CLASS)randint1(5) + m_bonus(5, level);
2750 ARMOUR_CLASS toac2 = (ARMOUR_CLASS)m_bonus(10, level);
2756 o_ptr->to_a += toac1;
2762 o_ptr->to_a += toac2;
2770 o_ptr->to_a -= toac1;
2775 /* Penalize again */
2776 o_ptr->to_a -= toac2;
2779 /* Cursed (if "bad") */
2780 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2785 switch (o_ptr->tval)
2789 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2790 create_artifact(o_ptr, FALSE);
2800 /* Hack -- Try for "Robes of the Magi" */
2801 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2802 (o_ptr->sval == SV_ROBE) &&
2803 (randint0(100) < 15))
2807 o_ptr->name2 = EGO_YOIYAMI;
2808 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2809 o_ptr->sval = SV_YOIYAMI_ROBE;
2815 o_ptr->name2 = EGO_PERMANENCE;
2820 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2822 create_artifact(o_ptr, FALSE);
2828 bool okay_flag = TRUE;
2830 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2832 switch (o_ptr->name2)
2835 if (o_ptr->tval != TV_HARD_ARMOR)
2841 if (o_ptr->tval != TV_SOFT_ARMOR)
2850 if (okay_flag) break;
2852 switch (o_ptr->name2)
2854 case EGO_RESISTANCE:
2856 add_flag(o_ptr->art_flags, TR_RES_POIS);
2859 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2860 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2864 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2866 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2868 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2869 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2871 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2872 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2873 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2874 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2875 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2876 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2877 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2878 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2881 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2882 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2883 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2884 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2885 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2886 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2899 if (o_ptr->sval == SV_DRAGON_SHIELD)
2901 dragon_resist(o_ptr);
2902 if (!one_in_(3)) break;
2908 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2910 create_artifact(o_ptr, FALSE);
2916 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2917 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2918 && o_ptr->name2 == EGO_S_DWARVEN)
2925 switch (o_ptr->name2)
2928 if (!one_in_(3)) one_high_resistance(o_ptr);
2929 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2931 case EGO_REFLECTION:
2932 if (o_ptr->sval == SV_MIRROR_SHIELD)
2937 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2938 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2947 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2949 dragon_resist(o_ptr);
2950 if (!one_in_(3)) break;
2954 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2956 create_artifact(o_ptr, FALSE);
2959 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2963 else if (power < -1)
2965 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2973 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2975 dragon_resist(o_ptr);
2976 if (!one_in_(3)) break;
2981 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2983 create_artifact(o_ptr, FALSE);
2986 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2988 switch (o_ptr->name2)
2990 case EGO_SLOW_DESCENT:
2993 one_high_resistance(o_ptr);
2999 else if (power < -1)
3001 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
3012 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3014 create_artifact(o_ptr, FALSE);
3019 bool ok_flag = TRUE;
3020 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3022 switch (o_ptr->name2)
3025 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
3026 else add_esp_weak(o_ptr, FALSE);
3030 case EGO_REGENERATION:
3031 case EGO_LORDLINESS:
3037 if (one_in_(2)) add_esp_strong(o_ptr);
3038 else add_esp_weak(o_ptr, FALSE);
3041 default:/* not existing crown (wisdom,lite, etc...) */
3045 break; /* while (1) */
3051 else if (power < -1)
3055 bool ok_flag = TRUE;
3056 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3058 switch (o_ptr->name2)
3060 case EGO_ANCIENT_CURSE:
3061 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3062 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3063 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3064 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3065 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3066 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3070 break; /* while (1) */
3079 if (o_ptr->sval == SV_DRAGON_HELM)
3081 dragon_resist(o_ptr);
3082 if (!one_in_(3)) break;
3088 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3090 create_artifact(o_ptr, FALSE);
3095 bool ok_flag = TRUE;
3096 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3098 switch (o_ptr->name2)
3100 case EGO_BRILLIANCE:
3102 case EGO_INFRAVISION:
3103 case EGO_H_PROTECTION:
3108 if (one_in_(2)) add_esp_strong(o_ptr);
3109 else add_esp_weak(o_ptr, FALSE);
3113 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3114 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3117 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3119 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3121 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3122 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3124 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3125 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3126 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3127 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3128 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3129 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3130 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3131 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3133 default:/* not existing helm (Magi, Might, etc...)*/
3137 break; /* while (1) */
3142 else if (power < -1)
3146 bool ok_flag = TRUE;
3147 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3149 switch (o_ptr->name2)
3151 case EGO_ANCIENT_CURSE:
3155 break; /* while (1) */
3166 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3168 create_artifact(o_ptr, FALSE);
3171 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3173 switch (o_ptr->name2)
3182 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3183 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3184 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3185 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3192 else if (power < -1)
3194 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3205 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3206 * Apply magic to an item known to be a "ring" or "amulet"
3207 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3208 * @param level 生成基準階
3209 * @param power 生成ランク
3212 * Hack -- note special "pval boost" code for ring of speed\n
3213 * Hack -- note that some items must be cursed (or blessed)\n
3215 static void a_m_aux_3(object_type *o_ptr, DEPTH level, int power)
3217 /* Apply magic (good or bad) according to type */
3218 switch (o_ptr->tval)
3223 switch (o_ptr->sval)
3225 case SV_RING_ATTACKS:
3228 o_ptr->pval = (PARAMETER_VALUE)m_bonus(2, level);
3229 if (one_in_(15)) o_ptr->pval++;
3230 if (o_ptr->pval < 1) o_ptr->pval = 1;
3236 o_ptr->ident |= (IDENT_BROKEN);
3239 o_ptr->curse_flags |= TRC_CURSED;
3242 o_ptr->pval = 0 - (o_ptr->pval);
3253 /* Strength, Constitution, Dexterity, Intelligence */
3259 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3265 o_ptr->ident |= (IDENT_BROKEN);
3268 o_ptr->curse_flags |= TRC_CURSED;
3271 o_ptr->pval = 0 - (o_ptr->pval);
3277 /* Ring of Speed! */
3280 /* Base speed (1 to 10) */
3281 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3283 /* Super-charge the ring */
3284 while (randint0(100) < 50) o_ptr->pval++;
3290 o_ptr->ident |= (IDENT_BROKEN);
3293 o_ptr->curse_flags |= TRC_CURSED;
3296 o_ptr->pval = 0 - (o_ptr->pval);
3304 case SV_RING_LORDLY:
3308 one_lordly_high_resistance(o_ptr);
3312 /* Bonus to armor class */
3313 o_ptr->to_a = 10 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3317 case SV_RING_WARNING:
3319 if (one_in_(3)) one_low_esp(o_ptr);
3324 case SV_RING_SEARCHING:
3326 /* Bonus to searching */
3327 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3333 o_ptr->ident |= (IDENT_BROKEN);
3336 o_ptr->curse_flags |= TRC_CURSED;
3339 o_ptr->pval = 0 - (o_ptr->pval);
3345 /* Flames, Acid, Ice */
3346 case SV_RING_FLAMES:
3351 /* Bonus to armor class */
3352 o_ptr->to_a = 5 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3356 /* Weakness, Stupidity */
3357 case SV_RING_WEAKNESS:
3358 case SV_RING_STUPIDITY:
3361 o_ptr->ident |= (IDENT_BROKEN);
3364 o_ptr->curse_flags |= TRC_CURSED;
3367 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3368 if (power > 0) power = 0 - power;
3373 /* WOE, Stupidity */
3377 o_ptr->ident |= (IDENT_BROKEN);
3380 o_ptr->curse_flags |= TRC_CURSED;
3383 o_ptr->to_a = 0 - (5 + (ARMOUR_CLASS)m_bonus(10, level));
3384 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3385 if (power > 0) power = 0 - power;
3390 /* Ring of damage */
3391 case SV_RING_DAMAGE:
3393 /* Bonus to damage */
3394 o_ptr->to_d = 1 + randint1(5) + (HIT_POINT)m_bonus(16, level);
3400 o_ptr->ident |= (IDENT_BROKEN);
3403 o_ptr->curse_flags |= TRC_CURSED;
3406 o_ptr->to_d = 0 - o_ptr->to_d;
3412 /* Ring of Accuracy */
3413 case SV_RING_ACCURACY:
3416 o_ptr->to_h = 1 + randint1(5) + (HIT_PROB)m_bonus(16, level);
3422 o_ptr->ident |= (IDENT_BROKEN);
3425 o_ptr->curse_flags |= TRC_CURSED;
3428 o_ptr->to_h = 0 - o_ptr->to_h;
3434 /* Ring of Protection */
3435 case SV_RING_PROTECTION:
3437 /* Bonus to armor class */
3438 o_ptr->to_a = 5 + randint1(8) + (ARMOUR_CLASS)m_bonus(10, level);
3444 o_ptr->ident |= (IDENT_BROKEN);
3447 o_ptr->curse_flags |= TRC_CURSED;
3450 o_ptr->to_a = 0 - o_ptr->to_a;
3456 /* Ring of Slaying */
3457 case SV_RING_SLAYING:
3459 /* Bonus to damage and to hit */
3460 o_ptr->to_d = randint1(5) + (HIT_POINT)m_bonus(12, level);
3461 o_ptr->to_h = randint1(5) + (HIT_PROB)m_bonus(12, level);
3467 o_ptr->ident |= (IDENT_BROKEN);
3470 o_ptr->curse_flags |= TRC_CURSED;
3472 /* Reverse bonuses */
3473 o_ptr->to_h = 0 - o_ptr->to_h;
3474 o_ptr->to_d = 0 - o_ptr->to_d;
3480 case SV_RING_MUSCLE:
3482 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(3, level);
3483 if (one_in_(4)) o_ptr->pval++;
3489 o_ptr->ident |= (IDENT_BROKEN);
3492 o_ptr->curse_flags |= TRC_CURSED;
3494 /* Reverse bonuses */
3495 o_ptr->pval = 0 - o_ptr->pval;
3500 case SV_RING_AGGRAVATION:
3503 o_ptr->ident |= (IDENT_BROKEN);
3506 o_ptr->curse_flags |= TRC_CURSED;
3508 if (power > 0) power = 0 - power;
3512 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3513 || (power > 2)) /* power > 2 is debug only */
3515 o_ptr->pval = MIN(o_ptr->pval, 4);
3516 /* Randart amulet */
3517 create_artifact(o_ptr, FALSE);
3519 else if ((power == 2) && one_in_(2))
3521 while(!o_ptr->name2)
3523 int tmp = m_bonus(10, level);
3524 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3525 switch(randint1(28))
3528 o_ptr->name2 = EGO_RING_THROW;
3531 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3532 o_ptr->name2 = EGO_RING_REGEN;
3535 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3536 o_ptr->name2 = EGO_RING_LITE;
3539 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3540 o_ptr->name2 = EGO_RING_TELEPORT;
3543 if (o_ptr->to_h) break;
3544 o_ptr->name2 = EGO_RING_TO_H;
3547 if (o_ptr->to_d) break;
3548 o_ptr->name2 = EGO_RING_TO_D;
3551 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3552 o_ptr->name2 = EGO_RING_SLAY;
3555 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3556 o_ptr->name2 = EGO_RING_WIZARD;
3559 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3560 o_ptr->name2 = EGO_RING_HERO;
3563 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3564 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3565 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3566 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3569 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3570 if (!(have_flag(k_ptr->flags, TR_RES_FIRE)) && (have_flag(k_ptr->flags, TR_RES_COLD) || have_flag(k_ptr->flags, TR_RES_ELEC) || have_flag(k_ptr->flags, TR_RES_ACID))) break;
3571 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3572 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3573 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3576 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3577 if (!(have_flag(k_ptr->flags, TR_RES_COLD)) && (have_flag(k_ptr->flags, TR_RES_FIRE) || have_flag(k_ptr->flags, TR_RES_ELEC) || have_flag(k_ptr->flags, TR_RES_ACID))) break;
3578 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3579 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3580 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3583 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3584 if (!(have_flag(k_ptr->flags, TR_RES_ELEC)) && (have_flag(k_ptr->flags, TR_RES_COLD) || have_flag(k_ptr->flags, TR_RES_FIRE) || have_flag(k_ptr->flags, TR_RES_ACID))) break;
3585 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3586 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3589 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3590 if (!(have_flag(k_ptr->flags, TR_RES_ACID)) && (have_flag(k_ptr->flags, TR_RES_COLD) || have_flag(k_ptr->flags, TR_RES_ELEC) || have_flag(k_ptr->flags, TR_RES_FIRE))) break;
3591 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3592 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3594 case 21: case 22: case 23: case 24: case 25: case 26:
3595 switch (o_ptr->sval)
3598 if (!one_in_(3)) break;
3599 o_ptr->name2 = EGO_RING_D_SPEED;
3601 case SV_RING_DAMAGE:
3602 case SV_RING_ACCURACY:
3603 case SV_RING_SLAYING:
3604 if (one_in_(2)) break;
3605 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3608 o_ptr->name2 = EGO_RING_BERSERKER;
3609 o_ptr->to_h -= 2+randint1(4);
3610 o_ptr->to_d += 2+randint1(4);
3613 case SV_RING_PROTECTION:
3614 o_ptr->name2 = EGO_RING_SUPER_AC;
3615 o_ptr->to_a += 7 + m_bonus(5, level);
3617 case SV_RING_RES_FEAR:
3618 o_ptr->name2 = EGO_RING_HERO;
3621 if (one_in_(2)) break;
3622 o_ptr->name2 = EGO_RING_HUNTER;
3624 case SV_RING_SEARCHING:
3625 o_ptr->name2 = EGO_RING_STEALTH;
3627 case SV_RING_TELEPORTATION:
3628 o_ptr->name2 = EGO_RING_TELE_AWAY;
3630 case SV_RING_RES_BLINDNESS:
3632 o_ptr->name2 = EGO_RING_RES_LITE;
3634 o_ptr->name2 = EGO_RING_RES_DARK;
3636 case SV_RING_LORDLY:
3637 if (!one_in_(20)) break;
3638 one_lordly_high_resistance(o_ptr);
3639 one_lordly_high_resistance(o_ptr);
3640 o_ptr->name2 = EGO_RING_TRUE;
3642 case SV_RING_SUSTAIN:
3643 if (!one_in_(4)) break;
3644 o_ptr->name2 = EGO_RING_RES_TIME;
3646 case SV_RING_FLAMES:
3647 if (!one_in_(2)) break;
3648 o_ptr->name2 = EGO_RING_DRAGON_F;
3651 if (!one_in_(2)) break;
3652 o_ptr->name2 = EGO_RING_DRAGON_C;
3654 case SV_RING_WARNING:
3655 if (!one_in_(2)) break;
3656 o_ptr->name2 = EGO_RING_M_DETECT;
3665 o_ptr->curse_flags = 0L;
3667 else if ((power == -2) && one_in_(2))
3669 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3670 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3671 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3672 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3673 o_ptr->art_flags[0] = 0;
3674 o_ptr->art_flags[1] = 0;
3675 while(!o_ptr->name2)
3677 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3681 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3682 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3685 o_ptr->name2 = EGO_RING_NO_MELEE;
3688 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3689 o_ptr->name2 = EGO_RING_AGGRAVATE;
3692 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3693 o_ptr->name2 = EGO_RING_TY_CURSE;
3696 o_ptr->name2 = EGO_RING_ALBINO;
3701 o_ptr->ident |= (IDENT_BROKEN);
3704 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3712 switch (o_ptr->sval)
3714 /* Amulet of wisdom/charisma */
3715 case SV_AMULET_INTELLIGENCE:
3716 case SV_AMULET_WISDOM:
3717 case SV_AMULET_CHARISMA:
3719 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3725 o_ptr->ident |= (IDENT_BROKEN);
3728 o_ptr->curse_flags |= (TRC_CURSED);
3730 /* Reverse bonuses */
3731 o_ptr->pval = 0 - o_ptr->pval;
3737 /* Amulet of brilliance */
3738 case SV_AMULET_BRILLIANCE:
3740 o_ptr->pval = 1 + m_bonus(3, level);
3741 if (one_in_(4)) o_ptr->pval++;
3747 o_ptr->ident |= (IDENT_BROKEN);
3750 o_ptr->curse_flags |= (TRC_CURSED);
3752 /* Reverse bonuses */
3753 o_ptr->pval = 0 - o_ptr->pval;
3759 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3763 o_ptr->curse_flags |= (TRC_CURSED);
3768 case SV_AMULET_RESISTANCE:
3770 if (one_in_(5)) one_high_resistance(o_ptr);
3771 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3775 /* Amulet of searching */
3776 case SV_AMULET_SEARCHING:
3778 o_ptr->pval = randint1(2) + (PARAMETER_VALUE)m_bonus(4, level);
3784 o_ptr->ident |= (IDENT_BROKEN);
3787 o_ptr->curse_flags |= (TRC_CURSED);
3789 /* Reverse bonuses */
3790 o_ptr->pval = 0 - (o_ptr->pval);
3796 /* Amulet of the Magi -- never cursed */
3797 case SV_AMULET_THE_MAGI:
3799 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3800 o_ptr->to_a = randint1(5) + (ARMOUR_CLASS)m_bonus(5, level);
3802 /* gain one low ESP */
3803 add_esp_weak(o_ptr, FALSE);
3808 /* Amulet of Doom -- always cursed */
3809 case SV_AMULET_DOOM:
3812 o_ptr->ident |= (IDENT_BROKEN);
3815 o_ptr->curse_flags |= (TRC_CURSED);
3818 o_ptr->pval = 0 - (randint1(5) + (PARAMETER_VALUE)m_bonus(5, level));
3819 o_ptr->to_a = 0 - (randint1(5) + (ARMOUR_CLASS)m_bonus(5, level));
3820 if (power > 0) power = 0 - power;
3825 case SV_AMULET_MAGIC_MASTERY:
3827 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(4, level);
3833 o_ptr->ident |= (IDENT_BROKEN);
3836 o_ptr->curse_flags |= (TRC_CURSED);
3838 /* Reverse bonuses */
3839 o_ptr->pval = 0 - o_ptr->pval;
3845 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3846 || (power > 2)) /* power > 2 is debug only */
3848 o_ptr->pval = MIN(o_ptr->pval, 4);
3849 /* Randart amulet */
3850 create_artifact(o_ptr, FALSE);
3852 else if ((power == 2) && one_in_(2))
3854 while(!o_ptr->name2)
3856 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3857 switch(randint1(21))
3860 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3861 o_ptr->name2 = EGO_AMU_SLOW_D;
3864 if (o_ptr->pval) break;
3865 o_ptr->name2 = EGO_AMU_INFRA;
3868 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3869 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3872 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3873 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3876 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3877 o_ptr->name2 = EGO_AMU_LEVITATION;
3879 case 10: case 11: case 21:
3880 o_ptr->name2 = EGO_AMU_AC;
3883 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3884 if (m_bonus(10, level) > 8)
3885 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3887 o_ptr->name2 = EGO_AMU_RES_FIRE;
3890 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3891 if (m_bonus(10, level) > 8)
3892 o_ptr->name2 = EGO_AMU_RES_COLD_;
3894 o_ptr->name2 = EGO_AMU_RES_COLD;
3897 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3898 if (m_bonus(10, level) > 8)
3899 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3901 o_ptr->name2 = EGO_AMU_RES_ELEC;
3904 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3905 if (m_bonus(10, level) > 8)
3906 o_ptr->name2 = EGO_AMU_RES_ACID_;
3908 o_ptr->name2 = EGO_AMU_RES_ACID;
3910 case 16: case 17: case 18: case 19: case 20:
3911 switch (o_ptr->sval)
3913 case SV_AMULET_TELEPORT:
3914 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3915 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3916 else o_ptr->name2 = EGO_AMU_TELEPORT;
3918 case SV_AMULET_RESIST_ACID:
3919 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3921 case SV_AMULET_SEARCHING:
3922 o_ptr->name2 = EGO_AMU_STEALTH;
3924 case SV_AMULET_BRILLIANCE:
3925 if (!one_in_(3)) break;
3926 o_ptr->name2 = EGO_AMU_IDENT;
3928 case SV_AMULET_CHARISMA:
3929 if (!one_in_(3)) break;
3930 o_ptr->name2 = EGO_AMU_CHARM;
3932 case SV_AMULET_THE_MAGI:
3933 if (one_in_(2)) break;
3934 o_ptr->name2 = EGO_AMU_GREAT;
3936 case SV_AMULET_RESISTANCE:
3937 if (!one_in_(5)) break;
3938 o_ptr->name2 = EGO_AMU_DEFENDER;
3940 case SV_AMULET_TELEPATHY:
3941 if (!one_in_(3)) break;
3942 o_ptr->name2 = EGO_AMU_DETECTION;
3948 o_ptr->curse_flags = 0L;
3950 else if ((power == -2) && one_in_(2))
3952 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3953 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3954 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3955 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3956 o_ptr->art_flags[0] = 0;
3957 o_ptr->art_flags[1] = 0;
3958 while(!o_ptr->name2)
3960 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3964 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3965 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3968 o_ptr->name2 = EGO_AMU_FOOL;
3971 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3972 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3975 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3976 o_ptr->name2 = EGO_AMU_TY_CURSE;
3979 o_ptr->name2 = EGO_AMU_NAIVETY;
3984 o_ptr->ident |= (IDENT_BROKEN);
3987 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3995 * @brief モンスターが人形のベースにできるかを返す
3996 * @param r_idx チェックしたいモンスター種族のID
3997 * @return 人形にできるならTRUEを返す
3999 static bool item_monster_okay(MONRACE_IDX r_idx)
4001 monster_race *r_ptr = &r_info[r_idx];
4004 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
4005 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
4006 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
4007 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
4008 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
4009 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
4017 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
4018 * Apply magic to an item known to be "boring"
4019 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4020 * @param level 生成基準階
4021 * @param power 生成ランク
4024 * Hack -- note the special code for various items
4026 static void a_m_aux_4(object_type *o_ptr, DEPTH level, int power)
4028 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4033 /* Apply magic (good or bad) according to type */
4034 switch (o_ptr->tval)
4043 o_ptr->ident |= (IDENT_BROKEN);
4046 o_ptr->curse_flags |= (TRC_CURSED);
4053 o_ptr->xtra4 = o_ptr->pval;
4059 /* Hack -- Torches -- random fuel */
4060 if (o_ptr->sval == SV_LITE_TORCH)
4062 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4066 /* Hack -- Lanterns -- random fuel */
4067 if (o_ptr->sval == SV_LITE_LANTERN)
4069 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4073 if (power > 2) /* power > 2 is debug only */
4075 create_artifact(o_ptr, FALSE);
4077 else if ((power == 2) || ((power == 1) && one_in_(3)))
4079 while (!o_ptr->name2)
4083 bool okay_flag = TRUE;
4085 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4087 switch (o_ptr->name2)
4090 if (o_ptr->sval == SV_LITE_FEANOR)
4098 else if (power == -2)
4100 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4102 switch (o_ptr->name2)
4104 case EGO_LITE_DARKNESS:
4107 if (o_ptr->sval == SV_LITE_TORCH)
4109 add_flag(o_ptr->art_flags, TR_LITE_M1);
4111 else if (o_ptr->sval == SV_LITE_LANTERN)
4113 add_flag(o_ptr->art_flags, TR_LITE_M2);
4115 else if (o_ptr->sval == SV_LITE_FEANOR)
4117 add_flag(o_ptr->art_flags, TR_LITE_M3);
4129 /* The wand or staff gets a number of initial charges equal
4130 * to between 1/2 (+1) and the full object kind's pval. -LM-
4132 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4138 /* Transfer the pval. -LM- */
4139 o_ptr->pval = k_ptr->pval;
4146 object_aware(o_ptr);
4147 object_known(o_ptr);
4153 PARAMETER_VALUE i = 1;
4156 monster_race *r_ptr;
4158 /* Pick a random non-unique monster race */
4161 i = randint1(max_r_idx - 1);
4163 if (!item_monster_okay(i)) continue;
4164 if (i == MON_TSUCHINOKO) continue;
4168 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4170 /* Ignore dead monsters */
4171 if (!r_ptr->rarity) continue;
4173 /* Ignore uncommon monsters */
4174 if (r_ptr->rarity > 100) continue;
4176 /* Prefer less out-of-depth monsters */
4177 if (randint0(check)) continue;
4184 /* Some figurines are cursed */
4185 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4192 PARAMETER_VALUE i = 1;
4197 monster_race *r_ptr;
4199 if (o_ptr->sval == SV_SKELETON)
4201 match = RF9_DROP_SKELETON;
4203 else if (o_ptr->sval == SV_CORPSE)
4205 match = RF9_DROP_CORPSE;
4208 /* Hack -- Remove the monster restriction */
4209 get_mon_num_prep(item_monster_okay, NULL);
4211 /* Pick a random non-unique monster race */
4214 i = get_mon_num(dun_level);
4218 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4220 /* Ignore dead monsters */
4221 if (!r_ptr->rarity) continue;
4223 /* Ignore corpseless monsters */
4224 if (!(r_ptr->flags9 & match)) continue;
4226 /* Prefer less out-of-depth monsters */
4227 if (randint0(check)) continue;
4235 object_aware(o_ptr);
4236 object_known(o_ptr);
4242 PARAMETER_VALUE i = 1;
4244 monster_race *r_ptr;
4246 /* Pick a random monster race */
4249 i = randint1(max_r_idx - 1);
4253 /* Ignore dead monsters */
4254 if (!r_ptr->rarity) continue;
4263 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4265 object_aware(o_ptr);
4266 object_known(o_ptr);
4273 DEPTH obj_level = k_info[o_ptr->k_idx].level;
4275 /* Hack -- skip ruined chests */
4276 if (obj_level <= 0) break;
4278 /* Hack -- pick a "difficulty" */
4279 o_ptr->pval = randint1(obj_level);
4280 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4282 o_ptr->xtra3 = dun_level + 5;
4284 /* Never exceed "difficulty" of 55 to 59 */
4285 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4293 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4294 * Complete the "creation" of an object by applying "magic" to the item
4295 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4297 * @param mode 生成オプション
4300 * This includes not only rolling for random bonuses, but also putting the\n
4301 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4302 * staffs, giving fuel to lites, and placing traps on chests.\n
4304 * In particular, note that "Instant Artifacts", if "created" by an external\n
4305 * routine, must pass through this function to complete the actual creation.\n
4307 * The base "chance" of the item being "good" increases with the "level"\n
4308 * parameter, which is usually derived from the dungeon level, being equal\n
4309 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4310 * the object is guaranteed to be "good". If an object is "good", then\n
4311 * the chance that the object will be "great" (ego-item or artifact), also\n
4312 * increases with the "level", being equal to half the level, plus 5, up to\n
4313 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4314 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4316 * If the object is not "good", there is a chance it will be "cursed", and\n
4317 * if it is "cursed", there is a chance it will be "broken". These chances\n
4318 * are related to the "good" / "great" chances above.\n
4320 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4321 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4323 * If "okay" is true, and the object is going to be "great", then there is\n
4324 * a chance that an artifact will be created. This is true even if both the\n
4325 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4326 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4328 void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
4330 int i, rolls, f1, f2, power;
4332 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4334 /* Maximum "level" for various things */
4335 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4337 /* Base chance of being "good" */
4340 /* Maximal chance of being "good" */
4341 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4343 /* Base chance of being "great" */
4346 /* Maximal chance of being "great" */
4347 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4348 f2 = d_info[dungeon_type].obj_great;
4350 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4355 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4364 /* Roll for "good" */
4365 if ((mode & AM_GOOD) || magik(f1))
4370 /* Roll for "great" */
4371 if ((mode & AM_GREAT) || magik(f2))
4375 /* Roll for "special" */
4376 if (mode & AM_SPECIAL) power = 3;
4380 /* Roll for "cursed" */
4383 /* Assume "cursed" */
4386 /* Roll for "broken" */
4387 if (magik(f2)) power = -2;
4391 if (mode & AM_CURSED)
4393 /* Assume 'cursed' */
4398 /* Everything else gets more badly cursed */
4405 /* Assume no rolls */
4408 /* Get one roll if excellent */
4409 if (power >= 2) rolls = 1;
4411 /* Hack -- Get four rolls if forced great or special */
4412 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4414 /* Hack -- Get no rolls if not allowed */
4415 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4417 /* Roll for artifacts if allowed */
4418 for (i = 0; i < rolls; i++)
4420 /* Roll for an artifact */
4421 if (make_artifact(o_ptr)) break;
4422 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4424 if (make_artifact(o_ptr)) break;
4429 /* Hack -- analyze artifacts */
4430 if (object_is_fixed_artifact(o_ptr))
4432 artifact_type *a_ptr = &a_info[o_ptr->name1];
4434 /* Hack -- Mark the artifact as "created" */
4437 /* Hack -- Memorize location of artifact in saved floors */
4438 if (character_dungeon)
4439 a_ptr->floor_id = p_ptr->floor_id;
4441 /* Extract the other fields */
4442 o_ptr->pval = a_ptr->pval;
4443 o_ptr->ac = a_ptr->ac;
4444 o_ptr->dd = a_ptr->dd;
4445 o_ptr->ds = a_ptr->ds;
4446 o_ptr->to_a = a_ptr->to_a;
4447 o_ptr->to_h = a_ptr->to_h;
4448 o_ptr->to_d = a_ptr->to_d;
4449 o_ptr->weight = a_ptr->weight;
4450 o_ptr->xtra2 = a_ptr->act_idx;
4452 if (o_ptr->name1 == ART_MILIM)
4454 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4460 /* Hack -- extract the "broken" flag */
4461 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4463 /* Hack -- extract the "cursed" flag */
4464 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4465 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4466 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4467 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4468 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4469 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4476 switch (o_ptr->tval)
4485 if (power) a_m_aux_1(o_ptr, lev, power);
4491 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4497 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4511 /* Elven Cloak and Black Clothes ... */
4512 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4513 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4514 o_ptr->pval = randint1(4);
4518 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4519 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4520 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4521 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4522 a_m_aux_2(o_ptr, lev, power);
4524 if (power) a_m_aux_2(o_ptr, lev, power);
4532 if (!power && (randint0(100) < 50)) power = -1;
4533 a_m_aux_3(o_ptr, lev, power);
4539 a_m_aux_4(o_ptr, lev, power);
4544 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4545 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4546 (p_ptr->pseikaku == SEIKAKU_SEXY))
4549 add_flag(o_ptr->art_flags, TR_STR);
4550 add_flag(o_ptr->art_flags, TR_INT);
4551 add_flag(o_ptr->art_flags, TR_WIS);
4552 add_flag(o_ptr->art_flags, TR_DEX);
4553 add_flag(o_ptr->art_flags, TR_CON);
4554 add_flag(o_ptr->art_flags, TR_CHR);
4557 /* Hack -- analyze ego-items */
4558 if (object_is_ego(o_ptr))
4560 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4562 /* Hack -- acquire "broken" flag */
4563 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4565 /* Hack -- acquire "cursed" flag */
4566 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4567 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4568 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4569 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4570 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4571 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4573 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4574 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4575 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4576 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4577 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4578 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4579 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4580 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4586 while (one_in_(o_ptr->dd));
4588 if (o_ptr->dd > 9) o_ptr->dd = 9;
4591 /* Hack -- apply activatin index if needed */
4592 if (e_ptr->act_idx) o_ptr->xtra2 = (XTRA8)e_ptr->act_idx;
4594 /* Hack -- apply extra penalties if needed */
4595 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4597 /* Hack -- obtain bonuses */
4598 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4599 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4600 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4602 /* Hack -- obtain pval */
4603 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4606 /* Hack -- apply extra bonuses if needed */
4609 /* Hack -- obtain bonuses */
4610 if (e_ptr->max_to_h)
4612 if (e_ptr->max_to_h > 127)
4613 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4614 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4616 if (e_ptr->max_to_d)
4618 if (e_ptr->max_to_d > 127)
4619 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4620 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4622 if (e_ptr->max_to_a)
4624 if (e_ptr->max_to_a > 127)
4625 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4626 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4629 /* Accuracy ego must have high to_h */
4630 if(o_ptr->name2 == EGO_ACCURACY)
4632 while(o_ptr->to_h < o_ptr->to_d + 10)
4637 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4640 /* Accuracy ego must have high to_h */
4641 if(o_ptr->name2 == EGO_VELOCITY)
4643 while(o_ptr->to_d < o_ptr->to_h + 10)
4648 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4651 /* Protection ego must have high to_a */
4652 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4654 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4657 /* Hack -- obtain pval */
4658 if (e_ptr->max_pval)
4660 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4663 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4665 else if (o_ptr->name2 == EGO_DEMON)
4667 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4669 o_ptr->pval += randint1(2);
4673 o_ptr->pval += randint1(e_ptr->max_pval);
4676 else if (o_ptr->name2 == EGO_ATTACKS)
4678 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4679 if (o_ptr->pval > 3) o_ptr->pval = 3;
4680 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4681 o_ptr->pval += randint1(2);
4683 else if (o_ptr->name2 == EGO_BAT)
4685 o_ptr->pval = randint1(e_ptr->max_pval);
4686 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4688 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4690 o_ptr->pval = randint1(e_ptr->max_pval);
4694 o_ptr->pval += randint1(e_ptr->max_pval);
4699 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4701 o_ptr->pval = randint1(o_ptr->pval);
4703 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4710 /* Examine real objects */
4713 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4715 /* Hack -- acquire "broken" flag */
4716 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4718 /* Hack -- acquire "cursed" flag */
4719 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4720 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4721 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4722 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4723 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4724 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4732 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4733 * Hack -- determine if a template is "good"
4734 * @param k_idx 判定したいベースアイテムのID
4735 * @return ベースアイテムが上質ならばTRUEを返す。
4737 static bool kind_is_good(KIND_OBJECT_IDX k_idx)
4739 object_kind *k_ptr = &k_info[k_idx];
4741 /* Analyze the item type */
4742 switch (k_ptr->tval)
4744 /* Armor -- Good unless damaged */
4755 if (k_ptr->to_a < 0) return (FALSE);
4759 /* Weapons -- Good unless damaged */
4766 if (k_ptr->to_h < 0) return (FALSE);
4767 if (k_ptr->to_d < 0) return (FALSE);
4771 /* Ammo -- Arrows/Bolts are good */
4778 /* Books -- High level books are good (except Arcane books) */
4780 case TV_SORCERY_BOOK:
4781 case TV_NATURE_BOOK:
4786 case TV_DAEMON_BOOK:
4787 case TV_CRUSADE_BOOK:
4789 case TV_HISSATSU_BOOK:
4792 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4796 /* Rings -- Rings of Speed are good */
4799 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4800 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4804 /* Amulets -- Amulets of the Magi and Resistance are good */
4807 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4808 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4813 /* Assume not good */
4818 * @brief 生成階に応じたベースアイテムの生成を行う。
4819 * Attempt to make an object (normal or good/great)
4820 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4821 * @param mode オプションフラグ
4822 * @return 生成に成功したらTRUEを返す。
4824 * This routine plays nasty games to generate the "special artifacts".\n
4825 * This routine uses "object_level" for the "generation level".\n
4826 * We assume that the given object has been "wiped".\n
4828 bool make_object(object_type *j_ptr, BIT_FLAGS mode)
4834 /* Chance of "special object" */
4835 prob = ((mode & AM_GOOD) ? 10 : 1000);
4837 /* Base level for the object */
4838 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4841 /* Generate a special object, or a normal object */
4842 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4844 KIND_OBJECT_IDX k_idx;
4847 if ((mode & AM_GOOD) && !get_obj_num_hook)
4849 /* Activate restriction (if already specified, use that) */
4850 get_obj_num_hook = kind_is_good;
4853 /* Restricted objects - prepare allocation table */
4854 if (get_obj_num_hook) get_obj_num_prep();
4856 /* Pick a random object */
4857 k_idx = get_obj_num(base);
4859 /* Restricted objects */
4860 if (get_obj_num_hook)
4862 /* Clear restriction */
4863 get_obj_num_hook = NULL;
4865 /* Reset allocation table to default */
4869 /* Handle failure */
4870 if (!k_idx) return (FALSE);
4872 /* Prepare the object */
4873 object_prep(j_ptr, k_idx);
4876 /* Apply magic (allow artifacts) */
4877 apply_magic(j_ptr, object_level, mode);
4879 /* Hack -- generate multiple spikes/missiles */
4880 switch (j_ptr->tval)
4888 j_ptr->number = (byte)damroll(6, 7);
4892 if (cheat_peek) object_mention(j_ptr);
4900 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4901 * Attempt to place an object (normal or good/great) at the given location.
4902 * @param y 配置したいフロアのY座標
4903 * @param x 配置したいフロアのX座標
4904 * @param mode オプションフラグ
4905 * @return 生成に成功したらTRUEを返す。
4907 * This routine plays nasty games to generate the "special artifacts".\n
4908 * This routine uses "object_level" for the "generation level".\n
4909 * This routine requires a clean floor grid destination.\n
4911 void place_object(POSITION y, POSITION x, BIT_FLAGS mode)
4916 cave_type *c_ptr = &cave[y][x];
4922 /* Paranoia -- check bounds */
4923 if (!in_bounds(y, x)) return;
4925 /* Require floor space */
4926 if (!cave_drop_bold(y, x)) return;
4928 /* Avoid stacking on other objects */
4929 if (c_ptr->o_idx) return;
4932 /* Get local object */
4935 /* Wipe the object */
4938 /* Make an object (if possible) */
4939 if (!make_object(q_ptr, mode)) return;
4942 /* Make an object */
4950 /* Acquire object */
4951 o_ptr = &o_list[o_idx];
4953 /* Structure Copy */
4954 object_copy(o_ptr, q_ptr);
4960 o_ptr->next_o_idx = c_ptr->o_idx;
4962 /* Place the object */
4963 c_ptr->o_idx = o_idx;
4973 /* Hack -- Preserve artifacts */
4974 if (object_is_fixed_artifact(q_ptr))
4976 a_info[q_ptr->name1].cur_num = 0;
4983 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4984 * Make a treasure object
4985 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4986 * @return 生成に成功したらTRUEを返す。
4988 * The location must be a legal, clean, floor grid.
4990 bool make_gold(object_type *j_ptr)
4995 /* Hack -- Pick a Treasure variety */
4996 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4998 /* Apply "extra" magic */
4999 if (one_in_(GREAT_OBJ))
5001 i += randint1(object_level + 1);
5004 /* Hack -- Creeping Coins only generate "themselves" */
5005 if (coin_type) i = coin_type;
5007 /* Do not create "illegal" Treasure Types */
5008 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
5010 /* Prepare a gold object */
5011 object_prep(j_ptr, OBJ_GOLD_LIST + i);
5013 /* Hack -- Base coin cost */
5014 base = k_info[OBJ_GOLD_LIST + i].cost;
5016 /* Determine how much the treasure is "worth" */
5017 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
5025 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
5026 * Places a treasure (Gold or Gems) at given location
5027 * @param y 配置したいフロアのY座標
5028 * @param x 配置したいフロアのX座標
5029 * @return 生成に成功したらTRUEを返す。
5031 * The location must be a legal, clean, floor grid.
5033 void place_gold(POSITION y, POSITION x)
5038 cave_type *c_ptr = &cave[y][x];
5044 /* Paranoia -- check bounds */
5045 if (!in_bounds(y, x)) return;
5047 /* Require floor space */
5048 if (!cave_drop_bold(y, x)) return;
5050 /* Avoid stacking on other objects */
5051 if (c_ptr->o_idx) return;
5054 /* Get local object */
5057 /* Wipe the object */
5060 /* Make some gold */
5061 if (!make_gold(q_ptr)) return;
5063 /* Make an object */
5071 /* Acquire object */
5072 o_ptr = &o_list[o_idx];
5074 /* Copy the object */
5075 object_copy(o_ptr, q_ptr);
5082 o_ptr->next_o_idx = c_ptr->o_idx;
5084 /* Place the object */
5085 c_ptr->o_idx = o_idx;
5097 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5098 * Let an object fall to the ground at or near a location.
5099 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5100 * @param chance ドロップの成功率(%)
5101 * @param y 配置したいフロアのY座標
5102 * @param x 配置したいフロアのX座標
5103 * @return 生成に成功したらオブジェクトのIDを返す。
5105 * The initial location is assumed to be "in_bounds()".\n
5107 * This function takes a parameter "chance". This is the percentage\n
5108 * chance that the item will "disappear" instead of drop. If the object\n
5109 * has been thrown, then this is the chance of disappearance on contact.\n
5111 * Hack -- this function uses "chance" to determine if it should produce\n
5112 * some form of "description" of the drop event (under the player).\n
5114 * We check several locations to see if we can find a location at which\n
5115 * the object can combine, stack, or be placed. Artifacts will try very\n
5116 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5118 OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION x)
5125 POSITION ty, tx = 0;
5127 OBJECT_IDX o_idx = 0;
5128 OBJECT_IDX this_o_idx, next_o_idx = 0;
5132 char o_name[MAX_NLEN];
5138 /* Extract plural */
5139 bool plural = (j_ptr->number != 1);
5142 /* Describe object */
5143 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5146 /* Handle normal "breakage" */
5147 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5150 msg_format("%sは消えた。", o_name);
5152 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5155 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5172 /* Scan local grids */
5173 for (dy = -3; dy <= 3; dy++)
5175 /* Scan local grids */
5176 for (dx = -3; dx <= 3; dx++)
5180 /* Calculate actual distance */
5181 d = (dy * dy) + (dx * dx);
5183 /* Ignore distant grids */
5184 if (d > 10) continue;
5189 /* Skip illegal grids */
5190 if (!in_bounds(ty, tx)) continue;
5192 /* Require line of projection */
5193 if (!projectable(y, x, ty, tx)) continue;
5196 c_ptr = &cave[ty][tx];
5198 /* Require floor space */
5199 if (!cave_drop_bold(ty, tx)) continue;
5204 /* Scan objects in that grid */
5205 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5209 /* Acquire object */
5210 o_ptr = &o_list[this_o_idx];
5212 /* Acquire next object */
5213 next_o_idx = o_ptr->next_o_idx;
5215 /* Check for possible combination */
5216 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5222 /* Add new object */
5226 if (k > 99) continue;
5228 /* Calculate score */
5229 s = 1000 - (d + k * 5);
5231 /* Skip bad values */
5232 if (s < bs) continue;
5234 /* New best value */
5237 /* Apply the randomizer to equivalent values */
5238 if ((++bn >= 2) && !one_in_(bn)) continue;
5253 /* Handle lack of space */
5254 if (!flag && !object_is_artifact(j_ptr))
5257 msg_format("%sは消えた。", o_name);
5259 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5264 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5272 for (i = 0; !flag && (i < 1000); i++)
5275 ty = rand_spread(by, 1);
5276 tx = rand_spread(bx, 1);
5278 /* Verify location */
5279 if (!in_bounds(ty, tx)) continue;
5281 /* Bounce to that location */
5285 /* Require floor space */
5286 if (!cave_drop_bold(by, bx)) continue;
5295 int candidates = 0, pick;
5297 for (ty = 1; ty < cur_hgt - 1; ty++)
5299 for (tx = 1; tx < cur_wid - 1; tx++)
5301 /* A valid space found */
5302 if (cave_drop_bold(ty, tx)) candidates++;
5306 /* No valid place! */
5310 msg_format("%sは消えた。", o_name);
5312 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5316 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5318 /* Mega-Hack -- preserve artifacts */
5321 /* Hack -- Preserve unknown artifacts */
5322 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5324 /* Mega-Hack -- Preserve the artifact */
5325 a_info[j_ptr->name1].cur_num = 0;
5333 /* Choose a random one */
5334 pick = randint1(candidates);
5336 for (ty = 1; ty < cur_hgt - 1; ty++)
5338 for (tx = 1; tx < cur_wid - 1; tx++)
5340 if (cave_drop_bold(ty, tx))
5344 /* Is this a picked one? */
5358 c_ptr = &cave[by][bx];
5360 /* Scan objects in that grid for combination */
5361 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5365 /* Acquire object */
5366 o_ptr = &o_list[this_o_idx];
5368 /* Acquire next object */
5369 next_o_idx = o_ptr->next_o_idx;
5371 /* Check for combination */
5372 if (object_similar(o_ptr, j_ptr))
5374 /* Combine the items */
5375 object_absorb(o_ptr, j_ptr);
5384 /* Get new object */
5385 if (!done) o_idx = o_pop();
5388 if (!done && !o_idx)
5391 msg_format("%sは消えた。", o_name);
5393 msg_format("The %s disappear%s.",
5394 o_name, (plural ? "" : "s"));
5399 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5401 /* Hack -- Preserve artifacts */
5402 if (object_is_fixed_artifact(j_ptr))
5404 a_info[j_ptr->name1].cur_num = 0;
5414 /* Structure copy */
5415 object_copy(&o_list[o_idx], j_ptr);
5417 /* Access new object */
5418 j_ptr = &o_list[o_idx];
5425 j_ptr->held_m_idx = 0;
5428 j_ptr->next_o_idx = c_ptr->o_idx;
5430 /* Place the object */
5431 c_ptr->o_idx = o_idx;
5445 /* Mega-Hack -- no message if "dropped" by player */
5446 /* Message when an object falls under the player */
5447 if (chance && player_bold(by, bx))
5449 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5460 * Scatter some "great" objects near the player
5461 * @param y1 配置したいフロアのY座標
5462 * @param x1 配置したいフロアのX座標
5463 * @param num 獲得の処理回数
5464 * @param great TRUEならば必ず高級品以上を落とす
5465 * @param special TRUEならば必ず特別品を落とす
5466 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5469 void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
5472 object_type object_type_body;
5473 BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5478 /* Get local object */
5479 i_ptr = &object_type_body;
5481 /* Wipe the object */
5484 /* Make a good (or great) object (if possible) */
5485 if (!make_object(i_ptr, mode)) continue;
5489 object_aware(i_ptr);
5490 object_known(i_ptr);
5493 /* Drop the object */
5494 (void)drop_near(i_ptr, -1, y1, x1);
5499 * Scatter some "amusing" objects near the player
5502 #define AMS_NOTHING 0x00 /* No restriction */
5503 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5504 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5505 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5506 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5510 OBJECT_TYPE_VALUE tval;
5511 OBJECT_SUBTYPE_VALUE sval;
5516 amuse_type amuse_info[] =
5518 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5519 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5520 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5521 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5522 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5523 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5524 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5525 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5526 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5527 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5528 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5529 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5530 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5537 * @param y1 配置したいフロアのY座標
5538 * @param x1 配置したいフロアのX座標
5539 * @param num 誰得の処理回数
5540 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5543 void amusement(POSITION y1, POSITION x1, int num, bool known)
5546 object_type object_type_body;
5549 for (n = 0; amuse_info[n].tval != 0; n++)
5551 t += amuse_info[n].prob;
5558 KIND_OBJECT_IDX k_idx;
5559 ARTIFACT_IDX a_idx = 0;
5560 int r = randint0(t);
5561 bool insta_art, fixed_art;
5565 r -= amuse_info[i].prob;
5569 /* Get local object */
5570 i_ptr = &object_type_body;
5572 /* Wipe the object */
5575 /* Wipe the object */
5576 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5578 /* Paranoia - reroll if nothing */
5579 if (!k_idx) continue;
5581 /* Search an artifact index if need */
5582 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5583 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5585 if (insta_art || fixed_art)
5587 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5589 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5590 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5591 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5592 if (a_info[a_idx].cur_num > 0) continue;
5596 if (a_idx >= max_a_idx) continue;
5599 /* Make an object (if possible) */
5600 object_prep(i_ptr, k_idx);
5601 if (a_idx) i_ptr->name1 = a_idx;
5602 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5604 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5606 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5609 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5610 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5614 object_aware(i_ptr);
5615 object_known(i_ptr);
5618 /* Paranoia - reroll if nothing */
5619 if (!(i_ptr->k_idx)) continue;
5621 /* Drop the object */
5622 (void)drop_near(i_ptr, -1, y1, x1);
5630 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5631 * Describe the charges on an item in the inventory.
5632 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5635 void inven_item_charges(INVENTORY_IDX item)
5637 object_type *o_ptr = &inventory[item];
5639 /* Require staff/wand */
5640 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5642 /* Require known item */
5643 if (!object_is_known(o_ptr)) return;
5646 if (o_ptr->pval <= 0)
5648 msg_print("もう魔力が残っていない。");
5652 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5655 /* Multiple charges */
5656 if (o_ptr->pval != 1)
5658 /* Print a message */
5659 msg_format("You have %d charges remaining.", o_ptr->pval);
5665 /* Print a message */
5666 msg_format("You have %d charge remaining.", o_ptr->pval);
5673 * @brief アイテムの残り所持数メッセージを表示する /
5674 * Describe an item in the inventory.
5675 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5678 void inven_item_describe(INVENTORY_IDX item)
5680 object_type *o_ptr = &inventory[item];
5681 char o_name[MAX_NLEN];
5683 /* Get a description */
5684 object_desc(o_name, o_ptr, 0);
5686 /* Print a message */
5688 /* "no more" の場合はこちらで表示する */
5689 if (o_ptr->number <= 0)
5691 /*FIRST*//*ここはもう通らないかも */
5692 msg_format("もう%sを持っていない。", o_name);
5696 /* アイテム名を英日切り替え機能対応 */
5697 msg_format("まだ %sを持っている。", o_name);
5700 msg_format("You have %s.", o_name);
5706 * @brief アイテムの残り所持数メッセージを表示する /
5707 * Increase the "number" of an item in the inventory
5708 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5712 void inven_item_increase(INVENTORY_IDX item, int num)
5714 object_type *o_ptr = &inventory[item];
5717 num += o_ptr->number;
5720 if (num > 255) num = 255;
5721 else if (num < 0) num = 0;
5724 num -= (ITEM_NUMBER)o_ptr->number;
5726 /* Change the number and weight */
5729 /* Add the number */
5730 o_ptr->number += num;
5732 /* Add the weight */
5733 p_ptr->total_weight += (num * o_ptr->weight);
5735 /* Recalculate bonuses */
5736 p_ptr->update |= (PU_BONUS);
5738 /* Recalculate mana XXX */
5739 p_ptr->update |= (PU_MANA);
5741 /* Combine the pack */
5742 p_ptr->notice |= (PN_COMBINE);
5744 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5746 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5747 if (!o_ptr->number && p_ptr->ele_attack)
5749 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5751 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5753 /* Clear all temporary elemental brands */
5754 set_ele_attack(0, 0);
5762 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5763 * Erase an inventory slot if it has no more items
5764 * @param item 消去したいプレイヤーのアイテム所持スロット
5767 void inven_item_optimize(INVENTORY_IDX item)
5769 object_type *o_ptr = &inventory[item];
5771 /* Only optimize real items */
5772 if (!o_ptr->k_idx) return;
5774 /* Only optimize empty items */
5775 if (o_ptr->number) return;
5777 /* The item is in the pack */
5778 if (item < INVEN_RARM)
5785 /* Slide everything down */
5786 for (i = item; i < INVEN_PACK; i++)
5788 /* Structure copy */
5789 inventory[i] = inventory[i+1];
5792 /* Erase the "final" slot */
5793 object_wipe(&inventory[i]);
5795 p_ptr->window |= (PW_INVEN);
5798 /* The item is being wielded */
5804 /* Erase the empty slot */
5805 object_wipe(&inventory[item]);
5807 /* Recalculate bonuses */
5808 p_ptr->update |= (PU_BONUS);
5810 /* Recalculate torch */
5811 p_ptr->update |= (PU_TORCH);
5813 /* Recalculate mana XXX */
5814 p_ptr->update |= (PU_MANA);
5816 p_ptr->window |= (PW_EQUIP);
5819 p_ptr->window |= (PW_SPELL);
5823 * @brief 床上の魔道具の残り残量メッセージを表示する /
5824 * Describe the charges on an item on the floor.
5825 * @param item メッセージの対象にしたいアイテム所持スロット
5828 void floor_item_charges(INVENTORY_IDX item)
5830 object_type *o_ptr = &o_list[item];
5832 /* Require staff/wand */
5833 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5835 /* Require known item */
5836 if (!object_is_known(o_ptr)) return;
5839 if (o_ptr->pval <= 0)
5841 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5845 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5848 /* Multiple charges */
5849 if (o_ptr->pval != 1)
5851 /* Print a message */
5852 msg_format("There are %d charges remaining.", o_ptr->pval);
5858 /* Print a message */
5859 msg_format("There is %d charge remaining.", o_ptr->pval);
5866 * @brief 床上のアイテムの残り数メッセージを表示する /
5867 * Describe the charges on an item on the floor.
5868 * @param item メッセージの対象にしたいアイテム所持スロット
5871 void floor_item_describe(INVENTORY_IDX item)
5873 object_type *o_ptr = &o_list[item];
5874 char o_name[MAX_NLEN];
5876 /* Get a description */
5877 object_desc(o_name, o_ptr, 0);
5879 /* Print a message */
5881 /* "no more" の場合はこちらで表示を分ける */
5882 if (o_ptr->number <= 0)
5884 msg_format("床上には、もう%sはない。", o_name);
5888 msg_format("床上には、まだ %sがある。", o_name);
5891 msg_format("You see %s.", o_name);
5898 * @brief 床上のアイテムの数を増やす /
5899 * Increase the "number" of an item on the floor
5900 * @param item 増やしたいアイテムの所持スロット
5901 * @param num 増やしたいアイテムの数
5904 void floor_item_increase(INVENTORY_IDX item, int num)
5906 object_type *o_ptr = &o_list[item];
5909 num += o_ptr->number;
5912 if (num > 255) num = 255;
5913 else if (num < 0) num = 0;
5916 num -= (int)o_ptr->number;
5918 /* Change the number */
5919 o_ptr->number += (ITEM_NUMBER)num;
5924 * @brief 床上の数の無くなったアイテムスロットを消去する /
5925 * Optimize an item on the floor (destroy "empty" items)
5926 * @param item 消去したいアイテムの所持スロット
5929 void floor_item_optimize(INVENTORY_IDX item)
5931 object_type *o_ptr = &o_list[item];
5933 /* Paranoia -- be sure it exists */
5934 if (!o_ptr->k_idx) return;
5936 /* Only optimize empty items */
5937 if (o_ptr->number) return;
5939 /* Delete the object */
5940 delete_object_idx(item);
5945 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
5946 * Check if we have space for an item in the pack without overflow
5947 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
5948 * @return 溢れずに済むならTRUEを返す
5950 bool inven_carry_okay(object_type *o_ptr)
5955 if (inven_cnt < INVEN_PACK) return (TRUE);
5958 for (j = 0; j < INVEN_PACK; j++)
5960 object_type *j_ptr = &inventory[j];
5962 /* Skip non-objects */
5963 if (!j_ptr->k_idx) continue;
5965 /* Check if the two items can be combined */
5966 if (object_similar(j_ptr, o_ptr)) return (TRUE);
5974 * @brief オブジェクトを定義された基準に従いソートするための関数 /
5975 * Check if we have space for an item in the pack without overflow
5976 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
5977 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
5978 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
5979 * @return o_ptrの方が上位ならばTRUEを返す。
5981 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
5985 /* Use empty slots */
5986 if (!j_ptr->k_idx) return TRUE;
5988 /* Hack -- readable books always come first */
5989 if ((o_ptr->tval == REALM1_BOOK) &&
5990 (j_ptr->tval != REALM1_BOOK)) return TRUE;
5991 if ((j_ptr->tval == REALM1_BOOK) &&
5992 (o_ptr->tval != REALM1_BOOK)) return FALSE;
5994 if ((o_ptr->tval == REALM2_BOOK) &&
5995 (j_ptr->tval != REALM2_BOOK)) return TRUE;
5996 if ((j_ptr->tval == REALM2_BOOK) &&
5997 (o_ptr->tval != REALM2_BOOK)) return FALSE;
5999 /* Objects sort by decreasing type */
6000 if (o_ptr->tval > j_ptr->tval) return TRUE;
6001 if (o_ptr->tval < j_ptr->tval) return FALSE;
6003 /* Non-aware (flavored) items always come last */
6004 /* Can happen in the home */
6005 if (!object_is_aware(o_ptr)) return FALSE;
6006 if (!object_is_aware(j_ptr)) return TRUE;
6008 /* Objects sort by increasing sval */
6009 if (o_ptr->sval < j_ptr->sval) return TRUE;
6010 if (o_ptr->sval > j_ptr->sval) return FALSE;
6012 /* Unidentified objects always come last */
6013 /* Objects in the home can be unknown */
6014 if (!object_is_known(o_ptr)) return FALSE;
6015 if (!object_is_known(j_ptr)) return TRUE;
6017 /* Fixed artifacts, random artifacts and ego items */
6018 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6019 else if (o_ptr->art_name) o_type = 2;
6020 else if (object_is_ego(o_ptr)) o_type = 1;
6023 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6024 else if (j_ptr->art_name) j_type = 2;
6025 else if (object_is_ego(j_ptr)) j_type = 1;
6028 if (o_type < j_type) return TRUE;
6029 if (o_type > j_type) return FALSE;
6031 switch (o_ptr->tval)
6037 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6038 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6044 /* Objects sort by increasing hit/damage bonuses */
6045 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6046 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6049 /* Hack: otherwise identical rods sort by
6050 increasing recharge time --dsb */
6052 if (o_ptr->pval < j_ptr->pval) return TRUE;
6053 if (o_ptr->pval > j_ptr->pval) return FALSE;
6057 /* Objects sort by decreasing value */
6058 return o_value > object_value(j_ptr);
6063 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6064 * Add an item to the players inventory, and return the slot used.
6065 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6066 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6068 * If the new item can combine with an existing item in the inventory,\n
6069 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6070 * the item will be placed into the "proper" location in the inventory.\n
6072 * This function can be used to "over-fill" the player's pack, but only\n
6073 * once, and such an action must trigger the "overflow" code immediately.\n
6074 * Note that when the pack is being "over-filled", the new item must be\n
6075 * placed into the "overflow" slot, and the "overflow" must take place\n
6076 * before the pack is reordered, but (optionally) after the pack is\n
6077 * combined. This may be tricky. See "dungeon.c" for info.\n
6079 * Note that this code must remove any location/stack information\n
6080 * from the object once it is placed into the inventory.\n
6082 s16b inven_carry(object_type *o_ptr)
6084 INVENTORY_IDX i, j, k;
6085 INVENTORY_IDX n = -1;
6090 /* Check for combining */
6091 for (j = 0; j < INVEN_PACK; j++)
6093 j_ptr = &inventory[j];
6095 /* Skip non-objects */
6096 if (!j_ptr->k_idx) continue;
6098 /* Hack -- track last item */
6101 /* Check if the two items can be combined */
6102 if (object_similar(j_ptr, o_ptr))
6104 /* Combine the items */
6105 object_absorb(j_ptr, o_ptr);
6107 /* Increase the weight */
6108 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6110 /* Recalculate bonuses */
6111 p_ptr->update |= (PU_BONUS);
6113 p_ptr->window |= (PW_INVEN);
6122 if (inven_cnt > INVEN_PACK) return (-1);
6124 /* Find an empty slot */
6125 for (j = 0; j <= INVEN_PACK; j++)
6127 j_ptr = &inventory[j];
6129 /* Use it if found */
6130 if (!j_ptr->k_idx) break;
6137 /* Reorder the pack */
6140 /* Get the "value" of the item */
6141 s32b o_value = object_value(o_ptr);
6143 /* Scan every occupied slot */
6144 for (j = 0; j < INVEN_PACK; j++)
6146 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6153 for (k = n; k >= i; k--)
6155 /* Hack -- Slide the item */
6156 object_copy(&inventory[k+1], &inventory[k]);
6159 /* Wipe the empty slot */
6160 object_wipe(&inventory[i]);
6165 object_copy(&inventory[i], o_ptr);
6167 /* Access new object */
6168 j_ptr = &inventory[i];
6171 j_ptr->next_o_idx = 0;
6173 /* Forget monster */
6174 j_ptr->held_m_idx = 0;
6176 /* Forget location */
6177 j_ptr->iy = j_ptr->ix = 0;
6179 /* Player touches it, and no longer marked */
6180 j_ptr->marked = OM_TOUCHED;
6182 /* Increase the weight */
6183 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6185 /* Count the items */
6188 /* Recalculate bonuses */
6189 p_ptr->update |= (PU_BONUS);
6191 /* Combine and Reorder pack */
6192 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6194 p_ptr->window |= (PW_INVEN);
6196 /* Return the slot */
6202 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6203 * Take off (some of) a non-cursed equipment item
6204 * @param item オブジェクトを外したい所持テーブルのID
6206 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6208 * Note that only one item at a time can be wielded per slot.\n
6209 * Note that taking off an item when "full" may cause that item\n
6210 * to fall to the ground.\n
6211 * Return the inventory slot into which the item is placed.\n
6213 INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt)
6224 char o_name[MAX_NLEN];
6227 /* Get the item to take off */
6228 o_ptr = &inventory[item];
6231 if (amt <= 0) return (-1);
6234 if (amt > o_ptr->number) amt = o_ptr->number;
6236 /* Get local object */
6239 /* Obtain a local object */
6240 object_copy(q_ptr, o_ptr);
6242 /* Modify quantity */
6243 q_ptr->number = amt;
6245 /* Describe the object */
6246 object_desc(o_name, q_ptr, 0);
6248 /* Took off weapon */
6249 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6250 object_is_melee_weapon(o_ptr))
6252 act = _("を装備からはずした", "You were wielding");
6256 else if (item == INVEN_BOW)
6258 act = _("を装備からはずした", "You were holding");
6261 /* Took off light */
6262 else if (item == INVEN_LITE)
6264 act = _("を光源からはずした", "You were holding");
6267 /* Took off something */
6270 act = _("を装備からはずした", "You were wearing");
6273 /* Modify, Optimize */
6274 inven_item_increase(item, -amt);
6275 inven_item_optimize(item);
6277 /* Carry the object */
6278 slot = inven_carry(q_ptr);
6281 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6283 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6293 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6294 * Drop (some of) a non-cursed inventory/equipment item
6295 * @param item 所持テーブルのID
6296 * @param amt 落としたい個数
6299 * The object will be dropped "near" the current location
6301 void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
6307 char o_name[MAX_NLEN];
6310 /* Access original object */
6311 o_ptr = &inventory[item];
6314 if (amt <= 0) return;
6317 if (amt > o_ptr->number) amt = o_ptr->number;
6320 /* Take off equipment */
6321 if (item >= INVEN_RARM)
6323 /* Take off first */
6324 item = inven_takeoff(item, amt);
6326 /* Access original object */
6327 o_ptr = &inventory[item];
6331 /* Get local object */
6334 /* Obtain local object */
6335 object_copy(q_ptr, o_ptr);
6337 /* Distribute charges of wands or rods */
6338 distribute_charges(o_ptr, q_ptr, amt);
6340 /* Modify quantity */
6341 q_ptr->number = amt;
6343 /* Describe local object */
6344 object_desc(o_name, q_ptr, 0);
6346 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6348 /* Drop it near the player */
6349 (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x);
6351 /* Modify, Describe, Optimize */
6352 inven_item_increase(item, -amt);
6353 inven_item_describe(item);
6354 inven_item_optimize(item);
6359 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6360 * Combine items in the pack
6363 * Note special handling of the "overflow" slot
6365 void combine_pack(void)
6370 bool flag = FALSE, combined;
6376 /* Combine the pack (backwards) */
6377 for (i = INVEN_PACK; i > 0; i--)
6380 o_ptr = &inventory[i];
6382 /* Skip empty items */
6383 if (!o_ptr->k_idx) continue;
6385 /* Scan the items above that item */
6386 for (j = 0; j < i; j++)
6391 j_ptr = &inventory[j];
6393 /* Skip empty items */
6394 if (!j_ptr->k_idx) continue;
6397 * Get maximum number of the stack if these
6398 * are similar, get zero otherwise.
6400 max_num = object_similar_part(j_ptr, o_ptr);
6402 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6403 if (max_num && j_ptr->number < max_num)
6405 if (o_ptr->number + j_ptr->number <= max_num)
6410 /* Add together the item counts */
6411 object_absorb(j_ptr, o_ptr);
6413 /* One object is gone */
6416 /* Slide everything down */
6417 for (k = i; k < INVEN_PACK; k++)
6419 /* Structure copy */
6420 inventory[k] = inventory[k+1];
6423 /* Erase the "final" slot */
6424 object_wipe(&inventory[k]);
6428 int old_num = o_ptr->number;
6429 int remain = j_ptr->number + o_ptr->number - max_num;
6431 o_ptr->number -= remain;
6433 /* Add together the item counts */
6434 object_absorb(j_ptr, o_ptr);
6436 o_ptr->number = remain;
6438 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6439 if (o_ptr->tval == TV_ROD)
6441 o_ptr->pval = o_ptr->pval * remain / old_num;
6442 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6445 /* Hack -- if wands are stacking, combine the charges. -LM- */
6446 if (o_ptr->tval == TV_WAND)
6448 o_ptr->pval = o_ptr->pval * remain / old_num;
6452 p_ptr->window |= (PW_INVEN);
6464 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6468 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6469 * Reorder items in the pack
6472 * Note special handling of the "overflow" slot
6474 void reorder_pack(void)
6484 /* Re-order the pack (forwards) */
6485 for (i = 0; i < INVEN_PACK; i++)
6487 /* Mega-Hack -- allow "proper" over-flow */
6488 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6491 o_ptr = &inventory[i];
6493 /* Skip empty slots */
6494 if (!o_ptr->k_idx) continue;
6496 /* Get the "value" of the item */
6497 o_value = object_value(o_ptr);
6499 /* Scan every occupied slot */
6500 for (j = 0; j < INVEN_PACK; j++)
6502 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6505 /* Never move down */
6506 if (j >= i) continue;
6511 /* Get local object */
6514 /* Save a copy of the moving item */
6515 object_copy(q_ptr, &inventory[i]);
6517 /* Slide the objects */
6518 for (k = i; k > j; k--)
6520 /* Slide the item */
6521 object_copy(&inventory[k], &inventory[k-1]);
6524 /* Insert the moving item */
6525 object_copy(&inventory[j], q_ptr);
6527 p_ptr->window |= (PW_INVEN);
6530 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6534 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6535 * Hack -- display an object kind in the current window
6536 * @param k_idx ベースアイテムの参照ID
6539 * Include list of usable spells for readible books
6541 void display_koff(KIND_OBJECT_IDX k_idx)
6548 REALM_IDX use_realm;
6550 char o_name[MAX_NLEN];
6553 /* Erase the window */
6554 for (y = 0; y < Term->hgt; y++)
6556 /* Erase the line */
6557 Term_erase(0, y, 255);
6563 /* Get local object */
6566 /* Prepare the object */
6567 object_prep(q_ptr, k_idx);
6570 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6572 /* Mention the object name */
6573 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6575 /* Access the item's sval */
6577 use_realm = tval2realm(q_ptr->tval);
6579 /* Warriors are illiterate */
6580 if (p_ptr->realm1 || p_ptr->realm2)
6582 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6586 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6587 if (!is_magic(use_realm)) return;
6588 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6591 /* Display spells in readible books */
6595 SPELL_IDX spells[64];
6597 /* Extract spells */
6598 for (spell = 0; spell < 32; spell++)
6600 /* Check for this spell */
6601 if (fake_spell_flags[sval] & (1L << spell))
6603 /* Collect this spell */
6604 spells[num++] = spell;
6609 print_spells(0, spells, num, 2, 0, use_realm);
6614 * @brief 警告を放つアイテムを選択する /
6615 * Choose one of items that have warning flag
6616 * Calculate spell damages
6619 object_type *choose_warning_item(void)
6622 int choices[INVEN_TOTAL - INVEN_RARM];
6625 /* Paranoia -- Player has no warning ability */
6626 if (!p_ptr->warning) return NULL;
6628 /* Search Inventory */
6629 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6631 BIT_FLAGS flgs[TR_FLAG_SIZE];
6632 object_type *o_ptr = &inventory[i];
6634 object_flags(o_ptr, flgs);
6635 if (have_flag(flgs, TR_WARNING))
6637 choices[number] = i;
6642 /* Choice one of them */
6643 return number ? &inventory[choices[randint0(number)]] : NULL;
6647 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6648 * Calculate spell damages
6649 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6650 * @param typ 効果属性のID
6652 * @param max 算出した最大ダメージを返すポインタ
6655 static void spell_damcalc(monster_type *m_ptr, EFFECT_ID typ, HIT_POINT dam, int *max)
6657 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6658 int rlev = r_ptr->level;
6659 bool ignore_wraith_form = FALSE;
6661 /* Vulnerability, resistance and immunity */
6665 if (p_ptr->immune_elec)
6668 ignore_wraith_form = TRUE;
6672 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6673 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6674 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6675 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6676 if (IS_OPPOSE_ELEC())
6677 dam = (dam + 2) / 3;
6682 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6683 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6687 if (p_ptr->immune_acid)
6690 ignore_wraith_form = TRUE;
6694 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6695 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6696 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6697 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6703 if (p_ptr->immune_cold)
6706 ignore_wraith_form = TRUE;
6710 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6711 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6712 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6713 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6718 if (p_ptr->immune_fire)
6721 ignore_wraith_form = TRUE;
6725 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6726 if (prace_is_(RACE_ENT)) dam += dam / 3;
6727 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6728 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6729 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6734 ignore_wraith_form = TRUE;
6738 if (!p_ptr->blind &&
6739 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6740 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6743 ignore_wraith_form = TRUE;
6748 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6749 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6750 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6753 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6754 * "dam *= 2;" for later "dam /= 2"
6756 if (p_ptr->wraith_form) dam *= 2;
6760 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6763 ignore_wraith_form = TRUE;
6765 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6769 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6773 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6777 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6781 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6785 if (prace_is_(RACE_SPECTRE))
6788 ignore_wraith_form = TRUE;
6790 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6794 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6798 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6802 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6806 if (p_ptr->levitation) dam = (dam * 2) / 3;
6810 if (p_ptr->resist_shard) dam /= 2;
6814 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6815 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6819 if (p_ptr->mimic_form)
6821 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6824 ignore_wraith_form = TRUE;
6829 switch (p_ptr->prace)
6838 ignore_wraith_form = TRUE;
6845 if (p_ptr->align > 10) dam /= 2;
6846 else if (p_ptr->align < -10) dam *= 2;
6850 if (p_ptr->align > 10) dam *= 2;
6854 case GF_BRAIN_SMASH:
6855 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6858 ignore_wraith_form = TRUE;
6866 if (100 + rlev / 2 <= p_ptr->skill_sav)
6869 ignore_wraith_form = TRUE;
6874 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
6877 ignore_wraith_form = TRUE;
6882 if (p_ptr->wraith_form && !ignore_wraith_form)
6888 if (dam > *max) *max = dam;
6892 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
6893 * Calculate spell damages
6894 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
6895 * @param typ 効果属性のID
6896 * @param m_idx 魔法を行使するモンスターのID
6897 * @param max 算出した最大ダメージを返すポインタ
6900 void spell_damcalc_by_spellnum(int spell_num, EFFECT_ID typ, MONSTER_IDX m_idx, int *max)
6902 monster_type *m_ptr = &m_list[m_idx];
6903 HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
6904 spell_damcalc(m_ptr, typ, dam, max);
6908 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
6909 * Calculate blow damages
6910 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
6911 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
6912 * @return 算出された最大ダメージを返す。
6914 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
6916 int dam = blow_ptr->d_dice * blow_ptr->d_side;
6918 bool check_wraith_form = TRUE;
6920 if (blow_ptr->method != RBM_EXPLODE)
6922 ARMOUR_CLASS ac = p_ptr->ac + p_ptr->to_a;
6924 switch (blow_ptr->effect)
6928 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
6929 dam = MAX(dam, tmp_dam * 2);
6935 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
6939 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
6941 check_wraith_form = FALSE;
6945 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
6947 check_wraith_form = FALSE;
6951 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
6953 check_wraith_form = FALSE;
6957 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
6959 check_wraith_form = FALSE;
6964 check_wraith_form = FALSE;
6968 if (check_wraith_form && p_ptr->wraith_form)
6976 dam = (dam + 1) / 2;
6977 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
6985 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
6986 * Examine the grid (xx,yy) and warn the player if there are any danger
6987 * @param xx 危険性を調査するマスのX座標
6988 * @param yy 危険性を調査するマスのY座標
6989 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
6991 bool process_warning(POSITION xx, POSITION yy)
6995 char o_name[MAX_NLEN];
6997 #define WARNING_AWARE_RANGE 12
6999 static int old_damage = 0;
7001 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7003 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7006 monster_type *m_ptr;
7007 monster_race *r_ptr;
7009 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7011 c_ptr = &cave[my][mx];
7013 if (!c_ptr->m_idx) continue;
7015 m_ptr = &m_list[c_ptr->m_idx];
7017 if (MON_CSLEEP(m_ptr)) continue;
7018 if (!is_hostile(m_ptr)) continue;
7020 r_ptr = &r_info[m_ptr->r_idx];
7022 /* Monster spells (only powerful ones)*/
7023 if (projectable(my, mx, yy, xx))
7025 BIT_FLAGS f4 = r_ptr->flags4;
7026 BIT_FLAGS f5 = r_ptr->a_ability_flags1;
7027 BIT_FLAGS f6 = r_ptr->a_ability_flags2;
7029 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7031 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7032 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7033 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7034 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7035 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7036 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7038 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7039 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7040 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7041 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7042 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7043 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7044 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7045 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7046 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7047 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7048 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7049 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7050 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7051 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7052 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7053 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, c_ptr->m_idx, &dam_max0);
7054 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7055 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7056 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7057 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7058 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7059 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7060 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7063 /* Monster melee attacks */
7064 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7066 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7070 for (m = 0; m < 4; m++)
7072 /* Skip non-attacks */
7073 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7075 /* Extract the attack info */
7076 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7077 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7079 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7083 /* Contribution from this monster */
7084 dam_max += dam_max0;
7088 /* Prevent excessive warning */
7089 if (dam_max > old_damage)
7091 old_damage = dam_max * 3 / 2;
7093 if (dam_max > p_ptr->chp / 2)
7095 object_type *o_ptr = choose_warning_item();
7098 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7100 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7101 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7104 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7107 else old_damage = old_damage / 2;
7109 c_ptr = &cave[yy][xx];
7110 if (((!easy_disarm && is_trap(c_ptr->feat))
7111 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7113 object_type *o_ptr = choose_warning_item();
7116 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7118 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7119 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7121 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7128 * エッセンス情報の構造体 / A structure for smithing
7131 int add; /* TR flag number or special essence id */
7132 cptr add_name; /* Name of this ability */
7133 ESSENCE_IDX type; /* Menu number */
7134 int essence; /* Index for carrying essences */
7135 int value; /* Needed value to add this ability */
7140 * エッセンス情報テーブル Smithing type data for Weapon smith
7143 static essence_type essence_info[] =
7145 {TR_STR, "腕力", 4, TR_STR, 20},
7146 {TR_INT, "知能", 4, TR_INT, 20},
7147 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7148 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7149 {TR_CON, "耐久力", 4, TR_CON, 20},
7150 {TR_CHR, "魅力", 4, TR_CHR, 20},
7151 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7152 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7153 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7154 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7155 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7156 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7157 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7158 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7159 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7160 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7161 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7162 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7163 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7164 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7165 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7166 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7167 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7168 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7169 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7170 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7171 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7172 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7173 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7174 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7175 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7176 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7177 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7178 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7179 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7180 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7181 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7182 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7183 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7184 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7185 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7186 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7187 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7188 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7189 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7190 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7191 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7192 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7193 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7194 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7195 {TR_SH_FIRE, "", 0, -2, 0},
7196 {TR_SH_ELEC, "", 0, -2, 0},
7197 {TR_SH_COLD, "", 0, -2, 0},
7198 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7199 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7200 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7201 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7202 {TR_LITE_2, "", 0, -2, 0},
7203 {TR_LITE_3, "", 0, -2, 0},
7204 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7205 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7206 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7207 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7208 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7210 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7211 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7212 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7213 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7214 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7215 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7216 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7217 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7218 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7219 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7220 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7221 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7222 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7223 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7224 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7225 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7226 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7227 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7229 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7230 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7231 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7232 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7233 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7234 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7235 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7236 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7238 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7239 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7240 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7241 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7242 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7243 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7244 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7245 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7246 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7247 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7248 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7249 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7251 {-1, NULL, 0, -1, 0}
7254 static essence_type essence_info[] =
7256 {TR_STR, "strength", 4, TR_STR, 20},
7257 {TR_INT, "intelligence", 4, TR_INT, 20},
7258 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7259 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7260 {TR_CON, "constitution", 4, TR_CON, 20},
7261 {TR_CHR, "charisma", 4, TR_CHR, 20},
7262 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7263 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7264 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7265 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7266 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7267 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7268 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7269 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7270 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7271 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7272 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7273 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7274 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7275 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7276 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7277 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7278 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7279 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7280 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7281 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7282 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7283 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7284 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7285 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7286 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7287 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7288 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7289 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7290 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7291 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7292 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7293 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7294 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7295 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7296 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7297 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7298 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7299 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7300 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7301 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7302 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7303 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7304 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7305 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7306 {TR_SH_FIRE, "", 0, -2, 0},
7307 {TR_SH_ELEC, "", 0, -2, 0},
7308 {TR_SH_COLD, "", 0, -2, 0},
7309 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7310 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7311 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7312 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7313 {TR_LITE_2, "", 0, -2, 0},
7314 {TR_LITE_3, "", 0, -2, 0},
7315 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7316 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7317 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7318 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7319 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7321 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7322 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7323 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7324 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7325 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7326 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7327 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7328 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7329 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7330 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7331 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7332 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7333 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7334 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7335 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7336 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7337 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7338 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7340 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7341 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7342 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7343 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7344 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7345 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7346 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7347 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7349 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7350 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7351 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7352 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7353 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7354 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7355 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7356 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7357 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7358 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7359 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7360 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7362 {-1, NULL, 0, -1, 0}
7368 * エッセンス名テーブル / Essense names for Weapon smith
7371 cptr essence_name[] =
7474 cptr essence_name[] =
7577 * @brief 所持しているエッセンス一覧を表示する
7580 static void display_essence(void)
7585 for (i = 1; i < 22; i++)
7589 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7590 "Essence Num Essence Num Essence Num "), 1, 8);
7591 for (i = 0; essence_name[i]; i++)
7593 if (!essence_name[i][0]) continue;
7594 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7597 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7607 static void drain_essence(void)
7609 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7613 bool observe = FALSE;
7614 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
7615 TIME_EFFECT old_timeout;
7616 BIT_FLAGS old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7622 OBJECT_IDX next_o_idx;
7625 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7628 item_tester_hook = object_is_weapon_armour_ammo;
7629 item_tester_no_ryoute = TRUE;
7632 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7633 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7635 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7637 /* Get the item (in the pack) */
7640 o_ptr = &inventory[item];
7643 /* Get the item (on the floor) */
7646 o_ptr = &o_list[0 - item];
7649 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7651 char o_name[MAX_NLEN];
7652 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7653 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7656 p_ptr->energy_use = 100;
7658 object_flags(o_ptr, old_flgs);
7659 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7660 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7661 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7662 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7663 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7664 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7665 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7666 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7667 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7669 old_to_a = o_ptr->to_a;
7671 old_to_h = o_ptr->to_h;
7672 old_to_d = o_ptr->to_d;
7675 old_pval = o_ptr->pval;
7676 old_name2 = o_ptr->name2;
7677 old_timeout = o_ptr->timeout;
7678 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7679 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7680 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7681 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7682 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7683 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7684 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7685 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7686 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7687 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7688 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7689 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7690 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7691 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7692 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7693 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7694 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7695 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7696 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7700 next_o_idx = o_ptr->next_o_idx;
7701 marked = o_ptr->marked;
7702 weight = o_ptr->weight;
7703 number = o_ptr->number;
7705 object_prep(o_ptr, o_ptr->k_idx);
7709 o_ptr->next_o_idx=next_o_idx;
7710 o_ptr->marked=marked;
7711 o_ptr->number = number;
7712 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7713 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7714 o_ptr->ident |= (IDENT_MENTAL);
7715 object_aware(o_ptr);
7716 object_known(o_ptr);
7718 object_flags(o_ptr, new_flgs);
7720 for (i = 0; essence_info[i].add_name; i++)
7722 essence_type *es_ptr = &essence_info[i];
7723 PARAMETER_VALUE pval = 0;
7725 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7726 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7728 if (es_ptr->add < TR_FLAG_MAX &&
7729 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7730 have_flag(old_flgs, es_ptr->add))
7734 drain_value[es_ptr->essence] += 10 * pval;
7736 else if (es_ptr->essence != -2)
7738 drain_value[es_ptr->essence] += 10;
7740 else if (es_ptr->add == TR_SH_FIRE)
7742 drain_value[TR_BRAND_FIRE] += 10;
7743 drain_value[TR_RES_FIRE] += 10;
7745 else if (es_ptr->add == TR_SH_ELEC)
7747 drain_value[TR_BRAND_ELEC] += 10;
7748 drain_value[TR_RES_ELEC] += 10;
7750 else if (es_ptr->add == TR_SH_COLD)
7752 drain_value[TR_BRAND_COLD] += 10;
7753 drain_value[TR_RES_COLD] += 10;
7755 else if (es_ptr->add == TR_LITE_2)
7757 drain_value[TR_LITE_1] += 20;
7759 else if (es_ptr->add == TR_LITE_3)
7761 drain_value[TR_LITE_1] += 30;
7766 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7768 drain_value[TR_INT] += 5;
7769 drain_value[TR_WIS] += 5;
7771 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7773 drain_value[TR_BRAND_POIS] += 5;
7774 drain_value[TR_BRAND_ACID] += 5;
7775 drain_value[TR_BRAND_ELEC] += 5;
7776 drain_value[TR_BRAND_FIRE] += 5;
7777 drain_value[TR_BRAND_COLD] += 5;
7779 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7781 drain_value[TR_INT] += 10;
7783 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7785 drain_value[TR_STR] += 10;
7787 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7789 drain_value[TR_DEX] += 10;
7791 if (old_name2 == EGO_2WEAPON)
7793 drain_value[TR_DEX] += 20;
7795 if (object_is_weapon_ammo(o_ptr))
7797 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7799 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7801 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7802 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7803 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7804 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7806 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7808 drain_value[i] *= number;
7809 drain_value[i] = drain_value[i] * dec / 4;
7810 drain_value[i] = MAX(drain_value[i], 0);
7811 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7819 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7823 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7825 for (i = 0; essence_name[i]; i++)
7827 if (!essence_name[i][0]) continue;
7828 if (!drain_value[i]) continue;
7830 p_ptr->magic_num1[i] += drain_value[i];
7831 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7833 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7837 /* Apply autodestroy/inscription to the drained item */
7838 autopick_alter_item(item, TRUE);
7840 /* Combine the pack */
7841 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7843 p_ptr->window |= (PW_INVEN);
7847 * @brief 付加するエッセンスの大別を選択する
7848 * @return 選んだエッセンスの大別ID
7850 static COMMAND_CODE choose_essence(void)
7852 COMMAND_CODE mode = 0;
7854 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
7857 cptr menu_name[] = {
7867 cptr menu_name[] = {
7877 const COMMAND_CODE mode_max = 7;
7880 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
7883 #endif /* ALLOW_REPEAT */
7892 for (i = 0; i < mode_max; i++)
7894 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
7895 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
7897 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
7898 prt("Choose from menu.", 0, 0);
7917 menu_line += mode_max - 1;
7926 if (menu_line > mode_max) menu_line -= mode_max;
7937 for (i = 0; i < mode_max; i++)
7938 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
7940 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
7946 if (isupper(choice)) choice = (char)tolower(choice);
7948 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
7949 mode = (int)choice - 'a' + 1;
7956 #endif /* ALLOW_REPEAT */
7961 * @brief エッセンスを実際に付加する
7962 * @param mode エッセンスの大別ID
7965 static void add_essence(ESSENCE_IDX mode)
7977 char o_name[MAX_NLEN];
7979 essence_type *es_ptr;
7980 bool able[22] = { 0 };
7982 int menu_line = (use_menu ? 1 : 0);
7984 for (i = 0; essence_info[i].add_name; i++)
7986 es_ptr = &essence_info[i];
7988 if (es_ptr->type != mode) continue;
7993 if (!repeat_pull(&i) || i<0 || i>=max_num)
7995 #endif /* ALLOW_REPEAT */
7998 /* Nothing chosen yet */
8004 /* Build a prompt */
8005 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8006 if (use_menu) screen_save();
8008 /* Get a spell from the user */
8010 choice = (always_show_list || use_menu) ? ESCAPE:1;
8013 if( choice==ESCAPE ) choice = ' ';
8014 else if( !get_com(out_val, &choice, FALSE) )break;
8016 if (use_menu && choice != ' ')
8030 menu_line += (max_num-1);
8053 menu_line = max_num;
8067 if (menu_line > max_num) menu_line -= max_num;
8069 /* Request redraw */
8070 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8073 if (!redraw || use_menu)
8077 char dummy[80], dummy2[80];
8085 /* Save the screen */
8086 if (!use_menu) screen_save();
8088 for (y = 1; y < 24; y++)
8091 /* Print header(s) */
8093 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8096 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8099 for (ctr = 0; ctr < max_num; ctr++)
8101 es_ptr = &essence_info[num[ctr]];
8105 if (ctr == (menu_line-1))
8106 strcpy(dummy, _("》 ", "> "));
8107 else strcpy(dummy, " ");
8110 /* letter/number for power selection */
8113 sprintf(dummy, "%c) ",I2A(ctr));
8116 strcat(dummy, es_ptr->add_name);
8121 if (es_ptr->essence != -1)
8123 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8124 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8130 case ESSENCE_SH_FIRE:
8131 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8132 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8133 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8135 case ESSENCE_SH_ELEC:
8136 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8137 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8138 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8140 case ESSENCE_SH_COLD:
8141 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8142 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8143 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8145 case ESSENCE_RESISTANCE:
8146 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8147 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8148 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8149 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8150 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8152 case ESSENCE_SUSTAIN:
8153 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8154 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8155 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8156 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8157 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8162 if (!able[ctr]) col = TERM_RED;
8164 if (es_ptr->essence != -1)
8166 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8170 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8173 c_prt(col, dummy2, ctr+2, x);
8183 /* Restore the screen */
8194 ask = (isupper(choice));
8197 if (ask) choice = (char)tolower(choice);
8199 /* Extract request */
8200 i = (islower(choice) ? A2I(choice) : -1);
8203 /* Totally Illegal */
8204 if ((i < 0) || (i >= max_num) || !able[i])
8216 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8218 /* Belay that order */
8219 if (!get_check(tmp_val)) continue;
8226 /* Restore the screen */
8227 if (redraw) screen_load();
8234 #endif /* ALLOW_REPEAT */
8236 es_ptr = &essence_info[num[i]];
8238 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8239 item_tester_tval = TV_GLOVES;
8240 else if (mode == 1 || mode == 5)
8241 item_tester_hook = item_tester_hook_melee_ammo;
8242 else if (es_ptr->add == ESSENCE_ATTACK)
8243 item_tester_hook = object_allow_enchant_weapon;
8244 else if (es_ptr->add == ESSENCE_AC)
8245 item_tester_hook = object_is_armour;
8247 item_tester_hook = object_is_weapon_armour_ammo;
8248 item_tester_no_ryoute = TRUE;
8251 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8252 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8254 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8256 /* Get the item (in the pack) */
8259 o_ptr = &inventory[item];
8262 /* Get the item (on the floor) */
8265 o_ptr = &o_list[0 - item];
8268 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8270 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8274 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8276 use_essence = es_ptr->value;
8277 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8278 if (o_ptr->number > 1)
8280 use_essence *= o_ptr->number;
8281 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8284 if (es_ptr->essence != -1)
8286 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8288 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8291 if (is_pval_flag(es_ptr->add))
8293 if (o_ptr->pval < 0)
8295 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8298 else if (es_ptr->add == TR_BLOWS)
8300 if (o_ptr->pval > 1)
8302 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8306 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8308 else if (o_ptr->pval > 0)
8310 use_essence *= o_ptr->pval;
8311 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8317 PARAMETER_VALUE pval;
8318 PARAMETER_VALUE limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8320 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8321 strcpy(tmp_val, "1");
8323 if (!get_string(tmp, tmp_val, 1)) return;
8324 pval = (PARAMETER_VALUE)atoi(tmp_val);
8325 if (pval > limit) pval = limit;
8326 else if (pval < 1) pval = 1;
8327 o_ptr->pval += pval;
8328 use_essence *= pval;
8329 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8332 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8334 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8338 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8345 strcpy(tmp_val, "1");
8346 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8347 val = atoi(tmp_val);
8348 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8349 else if (val < 1) val = 1;
8351 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8352 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8354 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8357 get_to_h = ((val+1)/2+randint0(val/2+1));
8358 get_to_d = ((val+1)/2+randint0(val/2+1));
8359 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8360 o_ptr->to_h += get_to_h;
8361 o_ptr->to_d += get_to_d;
8363 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8364 if (es_ptr->add == ESSENCE_ATTACK)
8366 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8368 msg_print(_("改良に失敗した。", "You failed to enchant."));
8369 p_ptr->energy_use = 100;
8374 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8375 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8378 else if (es_ptr->add == ESSENCE_AC)
8380 if (o_ptr->to_a >= p_ptr->lev/5+5)
8382 msg_print(_("改良に失敗した。", "You failed to enchant."));
8383 p_ptr->energy_use = 100;
8388 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8393 o_ptr->xtra3 = es_ptr->add + 1;
8398 bool success = TRUE;
8402 case ESSENCE_SH_FIRE:
8403 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8408 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8409 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8411 case ESSENCE_SH_ELEC:
8412 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8417 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8418 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8420 case ESSENCE_SH_COLD:
8421 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8426 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8427 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8429 case ESSENCE_RESISTANCE:
8430 case ESSENCE_SUSTAIN:
8431 if ((p_ptr->magic_num1[TR_RES_ACID] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8436 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8437 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8438 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8439 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8444 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8447 if (es_ptr->add == ESSENCE_SUSTAIN)
8449 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8450 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8451 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8452 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8456 o_ptr->xtra3 = es_ptr->add + 1;
8460 p_ptr->energy_use = 100;
8463 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8465 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8468 /* Combine the pack */
8469 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8471 p_ptr->window |= (PW_INVEN);
8478 static void erase_essence(void)
8483 char o_name[MAX_NLEN];
8484 BIT_FLAGS flgs[TR_FLAG_SIZE];
8486 item_tester_hook = object_is_smith;
8489 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8490 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8492 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8494 /* Get the item (in the pack) */
8497 o_ptr = &inventory[item];
8500 /* Get the item (on the floor) */
8503 o_ptr = &o_list[0 - item];
8506 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8507 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8509 p_ptr->energy_use = 100;
8511 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8513 o_ptr->to_h -= (o_ptr->xtra4>>8);
8514 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8516 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8517 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8520 object_flags(o_ptr, flgs);
8521 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8522 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8524 /* Combine the pack */
8525 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8527 p_ptr->window |= (PW_INVEN);
8531 * @brief 鍛冶コマンドのメインルーチン
8532 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8535 void do_cmd_kaji(bool only_browse)
8537 COMMAND_CODE mode = 0;
8540 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
8544 if (p_ptr->confused)
8546 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8551 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8556 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8562 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8564 #endif /* ALLOW_REPEAT */
8566 if (only_browse) screen_save();
8568 if (!only_browse) screen_save();
8574 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8575 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8576 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8577 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8578 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8579 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8581 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8582 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8583 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8584 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8585 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8586 prt(format("Choose command from menu."), 0, 0);
8613 if (menu_line > 5) menu_line -= 5;
8621 prt(_(" a) エッセンス一覧", " a) List essences"), 2, 14);
8622 prt(_(" b) エッセンス抽出", " b) Extract essence"), 3, 14);
8623 prt(_(" c) エッセンス消去", " c) Remove essence"), 4, 14);
8624 prt(_(" d) エッセンス付加", " d) Add essence"), 5, 14);
8625 prt(_(" e) 武器/防具強化", " e) Enchant weapon/armor"), 6, 14);
8627 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8629 if (!get_com("Command :", &choice, TRUE))
8666 /* Clear lines, position cursor (really should use strlen here) */
8667 Term_erase(14, 21, 255);
8668 Term_erase(14, 20, 255);
8669 Term_erase(14, 19, 255);
8670 Term_erase(14, 18, 255);
8671 Term_erase(14, 17, 255);
8672 Term_erase(14, 16, 255);
8674 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8675 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8677 prt(&temp[j], line, 15);
8682 if (!only_browse) screen_load();
8683 } while (only_browse);
8687 #endif /* ALLOW_REPEAT */
8691 case 1: display_essence();break;
8692 case 2: drain_essence();break;
8693 case 3: erase_essence();break;
8695 mode = choose_essence();
8700 case 5: add_essence(10);break;
8706 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8707 * Torches have special abilities when they are flaming.
8708 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8709 * @param flgs 特別に追加するフラグを返す参照ポインタ
8712 void torch_flags(object_type *o_ptr, BIT_FLAGS *flgs)
8714 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8716 if (o_ptr->xtra4 > 0)
8718 add_flag(flgs, TR_BRAND_FIRE);
8719 add_flag(flgs, TR_KILL_UNDEAD);
8720 add_flag(flgs, TR_THROW);
8726 * @brief 投擲時たいまつにダイスを与える。
8727 * Torches have special abilities when they are flaming.
8728 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8729 * @param dd 特別なダイス数を返す参照ポインタ
8730 * @param ds 特別なダイス面数を返す参照ポインタ
8733 void torch_dice(object_type *o_ptr, DICE_NUMBER *dd, DICE_SID *ds)
8735 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8737 if (o_ptr->xtra4 > 0)
8746 * @brief 投擲時命中したたいまつの寿命を縮める。
8747 * Torches have special abilities when they are flaming.
8748 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8751 void torch_lost_fuel(object_type *o_ptr)
8753 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8755 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8756 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;