2 * todo 300行以上の凶悪関数なので後で分割しておく
3 * @brief 床のアイテムが自動拾いに一致するかどうかを調べる関数だけを格納したファイル
8 #include "autopick/autopick-matcher.h"
9 #include "autopick/autopick-flags-table.h"
10 #include "autopick/autopick-key-flag-process.h"
11 #include "monster-race/monster-race.h"
12 #include "monster-race/race-flags1.h"
13 #include "perception/object-perception.h"
14 #include "object-enchant/item-feeling.h"
15 #include "object-hook/hook-armor.h"
16 #include "object-hook/hook-bow.h"
17 #include "object-hook/hook-checker.h"
18 #include "object-hook/hook-enchant.h"
19 #include "object-hook/hook-quest.h"
20 #include "object-hook/hook-weapon.h"
21 #include "object/object-kind.h"
22 #include "object/object-stack.h"
23 #include "object/object-value.h"
24 #include "object/object-info.h"
25 #include "object-enchant/special-object-flags.h"
26 #include "util/string-processor.h"
29 * A function for Auto-picker/destroyer
30 * Examine whether the object matches to the entry
32 bool is_autopick_match(player_type *player_ptr, object_type *o_ptr, autopick_type *entry, concptr o_name)
34 concptr ptr = entry->name;
35 if (IS_FLG(FLG_UNAWARE) && object_is_aware(o_ptr))
38 if (IS_FLG(FLG_UNIDENTIFIED)
39 && (object_is_known(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
42 if (IS_FLG(FLG_IDENTIFIED) && !object_is_known(o_ptr))
45 if (IS_FLG(FLG_STAR_IDENTIFIED) &&
46 (!object_is_known(o_ptr) || !object_is_fully_known(o_ptr)))
49 if (IS_FLG(FLG_BOOSTED))
51 object_kind *k_ptr = &k_info[o_ptr->k_idx];
52 if (!object_is_melee_weapon(o_ptr))
55 if ((o_ptr->dd == k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
58 if (!object_is_known(o_ptr) && object_is_quest_target(player_ptr, o_ptr))
64 if (IS_FLG(FLG_MORE_DICE))
66 if (o_ptr->dd * o_ptr->ds < entry->dice)
70 if (IS_FLG(FLG_MORE_BONUS))
72 if (!object_is_known(o_ptr)) return FALSE;
76 if (o_ptr->pval < entry->bonus) return FALSE;
80 if (o_ptr->to_h < entry->bonus &&
81 o_ptr->to_d < entry->bonus &&
82 o_ptr->to_a < entry->bonus &&
83 o_ptr->pval < entry->bonus)
88 if (IS_FLG(FLG_WORTHLESS) && object_value(player_ptr, o_ptr) > 0)
91 if (IS_FLG(FLG_ARTIFACT))
93 if (!object_is_known(o_ptr) || !object_is_artifact(o_ptr))
99 if (!object_is_ego(o_ptr)) return FALSE;
100 if (!object_is_known(o_ptr) &&
101 !((o_ptr->ident & IDENT_SENSE) && o_ptr->feeling == FEEL_EXCELLENT))
105 if (IS_FLG(FLG_GOOD))
107 if (!object_is_equipment(o_ptr)) return FALSE;
108 if (object_is_known(o_ptr))
110 if (!object_is_nameless(player_ptr, o_ptr))
113 if (o_ptr->to_a <= 0 && (o_ptr->to_h + o_ptr->to_d) <= 0)
116 else if (o_ptr->ident & IDENT_SENSE)
118 switch (o_ptr->feeling)
133 if (IS_FLG(FLG_NAMELESS))
135 if (!object_is_equipment(o_ptr)) return FALSE;
136 if (object_is_known(o_ptr))
138 if (!object_is_nameless(player_ptr, o_ptr))
141 else if (o_ptr->ident & IDENT_SENSE)
143 switch (o_ptr->feeling)
161 if (IS_FLG(FLG_AVERAGE))
163 if (!object_is_equipment(o_ptr)) return FALSE;
164 if (object_is_known(o_ptr))
166 if (!object_is_nameless(player_ptr, o_ptr))
169 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
172 if (o_ptr->to_a > 0 || (o_ptr->to_h + o_ptr->to_d) > 0)
175 else if (o_ptr->ident & IDENT_SENSE)
177 switch (o_ptr->feeling)
192 if (IS_FLG(FLG_RARE) && !object_is_rare(o_ptr))
195 if (IS_FLG(FLG_COMMON) && object_is_rare(o_ptr))
198 if (IS_FLG(FLG_WANTED) && !object_is_bounty(player_ptr, o_ptr))
201 if (IS_FLG(FLG_UNIQUE) &&
202 ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
203 !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
206 if (IS_FLG(FLG_HUMAN) &&
207 (o_ptr->tval != TV_CORPSE ||
208 !angband_strchr("pht", r_info[o_ptr->pval].d_char)))
211 if (IS_FLG(FLG_UNREADABLE) &&
212 (o_ptr->tval < TV_LIFE_BOOK ||
213 check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval)))
216 if (IS_FLG(FLG_REALM1) &&
217 (REALM1_BOOK != o_ptr->tval ||
218 player_ptr->pclass == CLASS_SORCERER ||
219 player_ptr->pclass == CLASS_RED_MAGE))
222 if (IS_FLG(FLG_REALM2) &&
223 (REALM2_BOOK != o_ptr->tval ||
224 player_ptr->pclass == CLASS_SORCERER ||
225 player_ptr->pclass == CLASS_RED_MAGE))
228 if (IS_FLG(FLG_FIRST) &&
229 (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
232 if (IS_FLG(FLG_SECOND) &&
233 (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
236 if (IS_FLG(FLG_THIRD) &&
237 (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
240 if (IS_FLG(FLG_FOURTH) &&
241 (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
244 if (IS_FLG(FLG_WEAPONS))
246 if (!object_is_weapon(player_ptr, o_ptr))
249 else if (IS_FLG(FLG_FAVORITE_WEAPONS))
251 if (!object_is_favorite(player_ptr, o_ptr))
254 else if (IS_FLG(FLG_ARMORS))
256 if (!object_is_armour(player_ptr, o_ptr))
259 else if (IS_FLG(FLG_MISSILES))
261 if (!object_is_ammo(o_ptr)) return FALSE;
263 else if (IS_FLG(FLG_DEVICES))
267 case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
269 default: return FALSE;
272 else if (IS_FLG(FLG_LIGHTS))
274 if (!(o_ptr->tval == TV_LITE))
277 else if (IS_FLG(FLG_JUNKS))
281 case TV_SKELETON: case TV_BOTTLE:
282 case TV_JUNK: case TV_STATUE:
284 default: return FALSE;
287 else if (IS_FLG(FLG_CORPSES))
289 if (o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_SKELETON)
292 else if (IS_FLG(FLG_SPELLBOOKS))
294 if (!(o_ptr->tval >= TV_LIFE_BOOK))
297 else if (IS_FLG(FLG_HAFTED))
299 if (!(o_ptr->tval == TV_HAFTED))
302 else if (IS_FLG(FLG_SHIELDS))
304 if (!(o_ptr->tval == TV_SHIELD))
307 else if (IS_FLG(FLG_BOWS))
309 if (!(o_ptr->tval == TV_BOW))
312 else if (IS_FLG(FLG_RINGS))
314 if (!(o_ptr->tval == TV_RING))
317 else if (IS_FLG(FLG_AMULETS))
319 if (!(o_ptr->tval == TV_AMULET))
322 else if (IS_FLG(FLG_SUITS))
324 if (!(o_ptr->tval == TV_DRAG_ARMOR ||
325 o_ptr->tval == TV_HARD_ARMOR ||
326 o_ptr->tval == TV_SOFT_ARMOR))
329 else if (IS_FLG(FLG_CLOAKS))
331 if (!(o_ptr->tval == TV_CLOAK))
334 else if (IS_FLG(FLG_HELMS))
336 if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
339 else if (IS_FLG(FLG_GLOVES))
341 if (!(o_ptr->tval == TV_GLOVES))
344 else if (IS_FLG(FLG_BOOTS))
346 if (!(o_ptr->tval == TV_BOOTS))
353 if (strncmp(o_name, ptr, strlen(ptr))) return FALSE;
357 if (!angband_strstr(o_name, ptr)) return FALSE;
360 if (!IS_FLG(FLG_COLLECTING)) return TRUE;
362 for (int j = 0; j < INVEN_PACK; j++)
365 * 'Collecting' means the item must be absorbed
366 * into an inventory slot.
367 * But an item can not be absorbed into itself!
369 if ((&player_ptr->inventory_list[j] != o_ptr) &&
370 object_similar(&player_ptr->inventory_list[j], o_ptr))