1 #include "object-hook/hook-weapon.h"
2 #include "object-enchant/tr-types.h"
3 #include "object-hook/hook-armor.h"
4 #include "object/object-flags.h"
5 #include "player/player-skill.h"
6 #include "sv-definition/sv-weapon-types.h"
7 #include "system/object-type-definition.h"
8 #include "system/player-type-definition.h"
9 #include "util/bit-flags-calculator.h"
12 * @brief 武器匠の「武器」鑑定対象になるかを判定する。/ Hook to specify "weapon"
13 * @param o_ptr オブジェクトの構造体の参照ポインタ。
14 * @return 対象になるならTRUEを返す。
16 bool object_is_orthodox_melee_weapons(const object_type *o_ptr)
18 switch (o_ptr->tval) {
25 if (o_ptr->sval != SV_POISON_NEEDLE)
37 * @brief 修復対象となる壊れた武器かを判定する。 / Hook to specify "broken weapon"
38 * @param o_ptr オブジェクトの構造体の参照ポインタ。
39 * @return 修復対象になるならTRUEを返す。
41 bool object_is_broken_weapon(const object_type *o_ptr)
43 if (o_ptr->tval != TV_SWORD)
46 switch (o_ptr->sval) {
47 case SV_BROKEN_DAGGER:
56 * @brief オブジェクトが投射可能な武器かどうかを返す。
57 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
58 * @return 投射可能な武器ならばTRUE
60 bool object_is_boomerang(const object_type *o_ptr)
62 if ((o_ptr->tval == TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED))
69 * @brief オブジェクトがどちらの手にも装備できる武器かどうかの判定
70 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
71 * @return 左右両方の手で装備できるならばTRUEを返す。
73 bool object_is_mochikae(const object_type *o_ptr)
75 /* Check for a usable slot */
76 if (((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD)) || (o_ptr->tval == TV_SHIELD) || (o_ptr->tval == TV_CAPTURE) || (o_ptr->tval == TV_CARD))
83 * @brief オブジェクトがプレイヤーの職業に応じた適正武器か否かを返す / Favorite weapons
84 * @param o_ptr 対象のオブジェクト構造体ポインタ
85 * @return オブジェクトが適正武器ならばTRUEを返す
87 bool object_is_favorite(player_type *player_ptr, const object_type *o_ptr)
89 /* Only melee weapons match */
90 if (!(o_ptr->tval == TV_POLEARM || o_ptr->tval == TV_SWORD || o_ptr->tval == TV_DIGGING || o_ptr->tval == TV_HAFTED)) {
94 /* Favorite weapons are varied depend on the class */
95 switch (player_ptr->pclass) {
98 object_flags_known(o_ptr, flgs);
100 if (!has_flag(flgs, TR_BLESSED) && !(o_ptr->tval == TV_HAFTED))
106 case CLASS_FORCETRAINER:
108 if (!(s_info[player_ptr->pclass].w_max[o_ptr->tval - TV_WEAPON_BEGIN][o_ptr->sval]))
112 case CLASS_BEASTMASTER:
113 case CLASS_CAVALRY: {
115 object_flags_known(o_ptr, flgs);
117 /* Is it known to be suitable to using while riding? */
118 if (!(has_flag(flgs, TR_RIDING)))
125 if (s_info[player_ptr->pclass].w_max[o_ptr->tval - TV_WEAPON_BEGIN][o_ptr->sval] < WEAPON_EXP_MASTER)
131 if (s_info[player_ptr->pclass].w_max[o_ptr->tval - TV_WEAPON_BEGIN][o_ptr->sval] <= WEAPON_EXP_BEGINNER)
136 /* All weapons are okay for non-special classes */
144 * @brief オブジェクトが武器として装備できるかどうかを返す / Check if an object is weapon (including bows and ammo)
145 * @param o_ptr 対象のオブジェクト構造体ポインタ
146 * @return 武器として使えるならばTRUEを返す
148 bool object_is_weapon(const object_type *o_ptr)
150 if (TV_WEAPON_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_WEAPON_END)
157 * @brief オブジェクトが武器や矢弾として使用できるかを返す / Check if an object is weapon (including bows and ammo)
158 * Rare weapons/aromors including Blade of Chaos, Dragon armors, etc.
159 * @param o_ptr 対象のオブジェクト構造体ポインタ
160 * @return 武器や矢弾として使えるならばTRUEを返す
162 bool object_is_weapon_ammo(const object_type *o_ptr)
164 if (TV_MISSILE_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_WEAPON_END)
171 * @brief オブジェクトが武器、防具、矢弾として使用できるかを返す / Check if an object is weapon, armour or ammo
172 * @param o_ptr 対象のオブジェクト構造体ポインタ
173 * @return 武器、防具、矢弾として使えるならばTRUEを返す
175 bool object_is_weapon_armour_ammo(const object_type *o_ptr)
177 if (object_is_weapon_ammo(o_ptr) || object_is_armour(o_ptr))
184 * @brief オブジェクトが近接武器として装備できるかを返す / Melee weapons
185 * @param o_ptr 対象のオブジェクト構造体ポインタ
186 * @return 近接武器として使えるならばTRUEを返す
188 bool object_is_melee_weapon(const object_type *o_ptr)
190 if (TV_DIGGING <= o_ptr->tval && o_ptr->tval <= TV_SWORD)
197 * @brief オブジェクトが装備可能であるかを返す / Wearable including all weapon, all armour, bow, light source, amulet, and ring
198 * @param o_ptr 対象のオブジェクト構造体ポインタ
199 * @return 装備可能ならばTRUEを返す
201 bool object_is_wearable(const object_type *o_ptr)
203 if (TV_WEARABLE_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_WEARABLE_END)
210 * @brief オブジェクトが装備品であるかを返す(object_is_wearableに矢弾を含む) / Equipment including all wearable objects and ammo
211 * @param o_ptr 対象のオブジェクト構造体ポインタ
212 * @return 装備品ならばTRUEを返す
214 bool object_is_equipment(const object_type *o_ptr)
216 if (TV_EQUIP_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_EQUIP_END)
223 * @brief オブジェクトが強化不能武器であるかを返す / Poison needle can not be enchanted
224 * @param o_ptr 対象のオブジェクト構造体ポインタ
225 * @return 強化不能ならばTRUEを返す
227 bool object_refuse_enchant_weapon(const object_type *o_ptr)
229 if (o_ptr->tval == TV_SWORD && o_ptr->sval == SV_POISON_NEEDLE)
236 * @brief オブジェクトが強化可能武器であるかを返す /
237 * Check if an object is weapon (including bows and ammo) and allows enchantment
238 * @param o_ptr 対象のオブジェクト構造体ポインタ
239 * @return 強化可能ならばTRUEを返す
241 bool object_allow_enchant_weapon(const object_type *o_ptr)
243 if (object_is_weapon_ammo(o_ptr) && !object_refuse_enchant_weapon(o_ptr))
250 * @brief オブジェクトが強化可能な近接武器であるかを返す /
251 * Check if an object is melee weapon and allows enchantment
252 * @param o_ptr 対象のオブジェクト構造体ポインタ
253 * @return 強化可能な近接武器ならばTRUEを返す
255 bool object_allow_enchant_melee_weapon(const object_type *o_ptr)
257 if (object_is_melee_weapon(o_ptr) && !object_refuse_enchant_weapon(o_ptr))
264 * @brief オブジェクトが両手持ち可能な武器かを返す /
265 * Check if an object is melee weapon and allows wielding with two-hands
266 * @param o_ptr 対象のオブジェクト構造体ポインタ
267 * @return 両手持ち可能ならばTRUEを返す
269 bool object_allow_two_hands_wielding(const object_type *o_ptr)
271 if (object_is_melee_weapon(o_ptr) && ((o_ptr->weight > 99) || (o_ptr->tval == TV_POLEARM)))