OSDN Git Service

Reword English message for giant eagle teleport self effect: original had subject...
[hengband/hengband.git] / src / perception / object-perception.c
1 #include "perception/object-perception.h"
2 #include "flavor/flavor-describer.h"
3 #include "flavor/object-flavor-types.h"
4 #include "game-option/play-record-options.h"
5 #include "io/write-diary.h"
6 #include "object-enchant/item-feeling.h"
7 #include "object-enchant/special-object-flags.h"
8 #include "object-enchant/trg-types.h"
9 #include "object/item-tester-hooker.h" // 暫定、このファイルへ引っ越す.
10 #include "object/object-generator.h"
11 #include "object/object-kind.h"
12
13 /*!
14  * @brief オブジェクトを鑑定済にする /
15  * Known is true when the "attributes" of an object are "known".
16  * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
17  * @return なし
18  * These include tohit, todam, toac, cost, and pval (charges).\n
19  *\n
20  * Note that "knowing" an object gives you everything that an "awareness"\n
21  * gives you, and much more.  In fact, the player is always "aware" of any\n
22  * item of which he has full "knowledge".\n
23  *\n
24  * But having full knowledge of, say, one "wand of wonder", does not, by\n
25  * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
26  * It happens that most "identify" routines (including "buying from a shop")\n
27  * will make the player "aware" of the object as well as fully "know" it.\n
28  *\n
29  * This routine also removes any inscriptions generated by "feelings".\n
30  */
31 void object_known(object_type *o_ptr)
32 {
33     o_ptr->feeling = FEEL_NONE;
34     o_ptr->ident &= ~(IDENT_SENSE);
35     o_ptr->ident &= ~(IDENT_EMPTY);
36     o_ptr->ident |= (IDENT_KNOWN);
37 }
38
39 /*!
40  * @brief オブジェクトを*鑑定*済にする /
41  * The player is now aware of the effects of the given object.
42  * @param owner_ptr プレーヤーへの参照ポインタ
43  * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
44  * @return なし
45  */
46 void object_aware(player_type *owner_ptr, object_type *o_ptr)
47 {
48     k_info[o_ptr->k_idx].aware = TRUE;
49
50     bool mihanmei = !object_is_aware(o_ptr);
51     bool is_undefined = mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident && !owner_ptr->is_dead
52         && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD));
53     if (!is_undefined)
54         return;
55
56     object_type forge;
57     object_type *q_ptr;
58     GAME_TEXT o_name[MAX_NLEN];
59
60     q_ptr = &forge;
61     object_copy(q_ptr, o_ptr);
62
63     q_ptr->number = 1;
64     describe_flavor(owner_ptr, o_name, q_ptr, OD_NAME_ONLY);
65
66     exe_write_diary(owner_ptr, DIARY_FOUND, 0, o_name);
67 }
68
69 /*!
70  * @brief オブジェクトを試行済にする /
71  * Something has been "sampled"
72  * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
73  * @return なし
74  */
75 void object_tried(object_type *o_ptr) { k_info[o_ptr->k_idx].tried = TRUE; }
76
77 /*
78  * @brief 与えられたオブジェクトのベースアイテムが鑑定済かを返す / Determine if a given inventory item is "aware"
79  * @param o_ptr オブジェクトへの参照ポインタ
80  * @return 鑑定済ならTRUE
81  */
82 bool object_is_aware(object_type *o_ptr) { return k_info[(o_ptr)->k_idx].aware; }
83
84 /*
85  * Determine if a given inventory item is "tried"
86  */
87 bool object_is_tried(object_type *o_ptr) { return k_info[(o_ptr)->k_idx].tried; }
88
89 /*
90  * Determine if a given inventory item is "known"
91  * Test One -- Check for special "known" tag
92  * Test Two -- Check for "Easy Know" + "Aware"
93  */
94 bool object_is_known(object_type *o_ptr) { return ((o_ptr->ident & IDENT_KNOWN) != 0) || (k_info[(o_ptr)->k_idx].easy_know && k_info[(o_ptr)->k_idx].aware); }
95
96 bool object_is_fully_known(object_type *o_ptr) { return (o_ptr->ident & IDENT_FULL_KNOWN) != 0; }