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/object-hook.h"
19 #include "object/object-kind.h"
20 #include "object/object-stack.h"
21 #include "object/object-value.h"
22 #include "object/object-info.h"
23 #include "object-enchant/special-object-flags.h"
24 #include "util/string-processor.h"
27 * A function for Auto-picker/destroyer
28 * Examine whether the object matches to the entry
30 bool is_autopick_match(player_type *player_ptr, object_type *o_ptr, autopick_type *entry, concptr o_name)
32 concptr ptr = entry->name;
33 if (IS_FLG(FLG_UNAWARE) && object_is_aware(o_ptr))
36 if (IS_FLG(FLG_UNIDENTIFIED)
37 && (object_is_known(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
40 if (IS_FLG(FLG_IDENTIFIED) && !object_is_known(o_ptr))
43 if (IS_FLG(FLG_STAR_IDENTIFIED) &&
44 (!object_is_known(o_ptr) || !object_is_fully_known(o_ptr)))
47 if (IS_FLG(FLG_BOOSTED))
49 object_kind *k_ptr = &k_info[o_ptr->k_idx];
50 if (!object_is_melee_weapon(o_ptr))
53 if ((o_ptr->dd == k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
56 if (!object_is_known(o_ptr) && object_is_quest_target(player_ptr, o_ptr))
62 if (IS_FLG(FLG_MORE_DICE))
64 if (o_ptr->dd * o_ptr->ds < entry->dice)
68 if (IS_FLG(FLG_MORE_BONUS))
70 if (!object_is_known(o_ptr)) return FALSE;
74 if (o_ptr->pval < entry->bonus) return FALSE;
78 if (o_ptr->to_h < entry->bonus &&
79 o_ptr->to_d < entry->bonus &&
80 o_ptr->to_a < entry->bonus &&
81 o_ptr->pval < entry->bonus)
86 if (IS_FLG(FLG_WORTHLESS) && object_value(player_ptr, o_ptr) > 0)
89 if (IS_FLG(FLG_ARTIFACT))
91 if (!object_is_known(o_ptr) || !object_is_artifact(o_ptr))
97 if (!object_is_ego(o_ptr)) return FALSE;
98 if (!object_is_known(o_ptr) &&
99 !((o_ptr->ident & IDENT_SENSE) && o_ptr->feeling == FEEL_EXCELLENT))
103 if (IS_FLG(FLG_GOOD))
105 if (!object_is_equipment(o_ptr)) return FALSE;
106 if (object_is_known(o_ptr))
108 if (!object_is_nameless(player_ptr, o_ptr))
111 if (o_ptr->to_a <= 0 && (o_ptr->to_h + o_ptr->to_d) <= 0)
114 else if (o_ptr->ident & IDENT_SENSE)
116 switch (o_ptr->feeling)
131 if (IS_FLG(FLG_NAMELESS))
133 if (!object_is_equipment(o_ptr)) return FALSE;
134 if (object_is_known(o_ptr))
136 if (!object_is_nameless(player_ptr, o_ptr))
139 else if (o_ptr->ident & IDENT_SENSE)
141 switch (o_ptr->feeling)
159 if (IS_FLG(FLG_AVERAGE))
161 if (!object_is_equipment(o_ptr)) return FALSE;
162 if (object_is_known(o_ptr))
164 if (!object_is_nameless(player_ptr, o_ptr))
167 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
170 if (o_ptr->to_a > 0 || (o_ptr->to_h + o_ptr->to_d) > 0)
173 else if (o_ptr->ident & IDENT_SENSE)
175 switch (o_ptr->feeling)
190 if (IS_FLG(FLG_RARE) && !object_is_rare(o_ptr))
193 if (IS_FLG(FLG_COMMON) && object_is_rare(o_ptr))
196 if (IS_FLG(FLG_WANTED) && !object_is_bounty(player_ptr, o_ptr))
199 if (IS_FLG(FLG_UNIQUE) &&
200 ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
201 !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
204 if (IS_FLG(FLG_HUMAN) &&
205 (o_ptr->tval != TV_CORPSE ||
206 !angband_strchr("pht", r_info[o_ptr->pval].d_char)))
209 if (IS_FLG(FLG_UNREADABLE) &&
210 (o_ptr->tval < TV_LIFE_BOOK ||
211 check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval)))
214 if (IS_FLG(FLG_REALM1) &&
215 (REALM1_BOOK != o_ptr->tval ||
216 player_ptr->pclass == CLASS_SORCERER ||
217 player_ptr->pclass == CLASS_RED_MAGE))
220 if (IS_FLG(FLG_REALM2) &&
221 (REALM2_BOOK != o_ptr->tval ||
222 player_ptr->pclass == CLASS_SORCERER ||
223 player_ptr->pclass == CLASS_RED_MAGE))
226 if (IS_FLG(FLG_FIRST) &&
227 (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
230 if (IS_FLG(FLG_SECOND) &&
231 (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
234 if (IS_FLG(FLG_THIRD) &&
235 (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
238 if (IS_FLG(FLG_FOURTH) &&
239 (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
242 if (IS_FLG(FLG_WEAPONS))
244 if (!object_is_weapon(player_ptr, o_ptr))
247 else if (IS_FLG(FLG_FAVORITE_WEAPONS))
249 if (!object_is_favorite(player_ptr, o_ptr))
252 else if (IS_FLG(FLG_ARMORS))
254 if (!object_is_armour(player_ptr, o_ptr))
257 else if (IS_FLG(FLG_MISSILES))
259 if (!object_is_ammo(o_ptr)) return FALSE;
261 else if (IS_FLG(FLG_DEVICES))
265 case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
267 default: return FALSE;
270 else if (IS_FLG(FLG_LIGHTS))
272 if (!(o_ptr->tval == TV_LITE))
275 else if (IS_FLG(FLG_JUNKS))
279 case TV_SKELETON: case TV_BOTTLE:
280 case TV_JUNK: case TV_STATUE:
282 default: return FALSE;
285 else if (IS_FLG(FLG_CORPSES))
287 if (o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_SKELETON)
290 else if (IS_FLG(FLG_SPELLBOOKS))
292 if (!(o_ptr->tval >= TV_LIFE_BOOK))
295 else if (IS_FLG(FLG_HAFTED))
297 if (!(o_ptr->tval == TV_HAFTED))
300 else if (IS_FLG(FLG_SHIELDS))
302 if (!(o_ptr->tval == TV_SHIELD))
305 else if (IS_FLG(FLG_BOWS))
307 if (!(o_ptr->tval == TV_BOW))
310 else if (IS_FLG(FLG_RINGS))
312 if (!(o_ptr->tval == TV_RING))
315 else if (IS_FLG(FLG_AMULETS))
317 if (!(o_ptr->tval == TV_AMULET))
320 else if (IS_FLG(FLG_SUITS))
322 if (!(o_ptr->tval == TV_DRAG_ARMOR ||
323 o_ptr->tval == TV_HARD_ARMOR ||
324 o_ptr->tval == TV_SOFT_ARMOR))
327 else if (IS_FLG(FLG_CLOAKS))
329 if (!(o_ptr->tval == TV_CLOAK))
332 else if (IS_FLG(FLG_HELMS))
334 if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
337 else if (IS_FLG(FLG_GLOVES))
339 if (!(o_ptr->tval == TV_GLOVES))
342 else if (IS_FLG(FLG_BOOTS))
344 if (!(o_ptr->tval == TV_BOOTS))
351 if (strncmp(o_name, ptr, strlen(ptr))) return FALSE;
355 if (!angband_strstr(o_name, ptr)) return FALSE;
358 if (!IS_FLG(FLG_COLLECTING)) return TRUE;
360 for (int j = 0; j < INVEN_PACK; j++)
363 * 'Collecting' means the item must be absorbed
364 * into an inventory slot.
365 * But an item can not be absorbed into itself!
367 if ((&player_ptr->inventory_list[j] != o_ptr) &&
368 object_similar(&player_ptr->inventory_list[j], o_ptr))