2 * todo 300行以上の凶悪関数なので後で分割しておく
3 * @brief 床のアイテムが自動拾いに一致するかどうかを調べる関数だけを格納したファイル
9 #include "autopick/autopick-key-flag-process.h"
10 #include "autopick/autopick-flags-table.h"
11 #include "autopick/autopick-matcher.h"
12 #include "object/object-kind.h"
13 #include "object-hook.h"
16 * A function for Auto-picker/destroyer
17 * Examine whether the object matches to the entry
19 bool is_autopick_match(player_type *player_ptr, object_type *o_ptr, autopick_type *entry, concptr o_name)
21 concptr ptr = entry->name;
22 if (IS_FLG(FLG_UNAWARE) && object_is_aware(o_ptr))
25 if (IS_FLG(FLG_UNIDENTIFIED)
26 && (object_is_known(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
29 if (IS_FLG(FLG_IDENTIFIED) && !object_is_known(o_ptr))
32 if (IS_FLG(FLG_STAR_IDENTIFIED) &&
33 (!object_is_known(o_ptr) || !OBJECT_IS_FULL_KNOWN(o_ptr)))
36 if (IS_FLG(FLG_BOOSTED))
38 object_kind *k_ptr = &k_info[o_ptr->k_idx];
39 if (!object_is_melee_weapon(o_ptr))
42 if ((o_ptr->dd == k_ptr->dd) && (o_ptr->ds == k_ptr->ds))
45 if (!object_is_known(o_ptr) && object_is_quest_target(o_ptr))
51 if (IS_FLG(FLG_MORE_DICE))
53 if (o_ptr->dd * o_ptr->ds < entry->dice)
57 if (IS_FLG(FLG_MORE_BONUS))
59 if (!object_is_known(o_ptr)) return FALSE;
63 if (o_ptr->pval < entry->bonus) return FALSE;
67 if (o_ptr->to_h < entry->bonus &&
68 o_ptr->to_d < entry->bonus &&
69 o_ptr->to_a < entry->bonus &&
70 o_ptr->pval < entry->bonus)
75 if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0)
78 if (IS_FLG(FLG_ARTIFACT))
80 if (!object_is_known(o_ptr) || !object_is_artifact(o_ptr))
86 if (!object_is_ego(o_ptr)) return FALSE;
87 if (!object_is_known(o_ptr) &&
88 !((o_ptr->ident & IDENT_SENSE) && o_ptr->feeling == FEEL_EXCELLENT))
94 if (!object_is_equipment(o_ptr)) return FALSE;
95 if (object_is_known(o_ptr))
97 if (!object_is_nameless(o_ptr))
100 if (o_ptr->to_a <= 0 && (o_ptr->to_h + o_ptr->to_d) <= 0)
103 else if (o_ptr->ident & IDENT_SENSE)
105 switch (o_ptr->feeling)
120 if (IS_FLG(FLG_NAMELESS))
122 if (!object_is_equipment(o_ptr)) return FALSE;
123 if (object_is_known(o_ptr))
125 if (!object_is_nameless(o_ptr))
128 else if (o_ptr->ident & IDENT_SENSE)
130 switch (o_ptr->feeling)
148 if (IS_FLG(FLG_AVERAGE))
150 if (!object_is_equipment(o_ptr)) return FALSE;
151 if (object_is_known(o_ptr))
153 if (!object_is_nameless(o_ptr))
156 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
159 if (o_ptr->to_a > 0 || (o_ptr->to_h + o_ptr->to_d) > 0)
162 else if (o_ptr->ident & IDENT_SENSE)
164 switch (o_ptr->feeling)
179 if (IS_FLG(FLG_RARE) && !object_is_rare(o_ptr))
182 if (IS_FLG(FLG_COMMON) && object_is_rare(o_ptr))
185 if (IS_FLG(FLG_WANTED) && !object_is_bounty(o_ptr))
188 if (IS_FLG(FLG_UNIQUE) &&
189 ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
190 !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
193 if (IS_FLG(FLG_HUMAN) &&
194 (o_ptr->tval != TV_CORPSE ||
195 !my_strchr("pht", r_info[o_ptr->pval].d_char)))
198 if (IS_FLG(FLG_UNREADABLE) &&
199 (o_ptr->tval < TV_LIFE_BOOK ||
200 check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval)))
203 if (IS_FLG(FLG_REALM1) &&
204 (REALM1_BOOK != o_ptr->tval ||
205 player_ptr->pclass == CLASS_SORCERER ||
206 player_ptr->pclass == CLASS_RED_MAGE))
209 if (IS_FLG(FLG_REALM2) &&
210 (REALM2_BOOK != o_ptr->tval ||
211 player_ptr->pclass == CLASS_SORCERER ||
212 player_ptr->pclass == CLASS_RED_MAGE))
215 if (IS_FLG(FLG_FIRST) &&
216 (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
219 if (IS_FLG(FLG_SECOND) &&
220 (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
223 if (IS_FLG(FLG_THIRD) &&
224 (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
227 if (IS_FLG(FLG_FOURTH) &&
228 (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
231 if (IS_FLG(FLG_WEAPONS))
233 if (!object_is_weapon(o_ptr))
236 else if (IS_FLG(FLG_FAVORITE_WEAPONS))
238 if (!object_is_favorite(o_ptr))
241 else if (IS_FLG(FLG_ARMORS))
243 if (!object_is_armour(o_ptr))
246 else if (IS_FLG(FLG_MISSILES))
248 if (!object_is_ammo(o_ptr)) return FALSE;
250 else if (IS_FLG(FLG_DEVICES))
254 case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
256 default: return FALSE;
259 else if (IS_FLG(FLG_LIGHTS))
261 if (!(o_ptr->tval == TV_LITE))
264 else if (IS_FLG(FLG_JUNKS))
268 case TV_SKELETON: case TV_BOTTLE:
269 case TV_JUNK: case TV_STATUE:
271 default: return FALSE;
274 else if (IS_FLG(FLG_CORPSES))
276 if (o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_SKELETON)
279 else if (IS_FLG(FLG_SPELLBOOKS))
281 if (!(o_ptr->tval >= TV_LIFE_BOOK))
284 else if (IS_FLG(FLG_HAFTED))
286 if (!(o_ptr->tval == TV_HAFTED))
289 else if (IS_FLG(FLG_SHIELDS))
291 if (!(o_ptr->tval == TV_SHIELD))
294 else if (IS_FLG(FLG_BOWS))
296 if (!(o_ptr->tval == TV_BOW))
299 else if (IS_FLG(FLG_RINGS))
301 if (!(o_ptr->tval == TV_RING))
304 else if (IS_FLG(FLG_AMULETS))
306 if (!(o_ptr->tval == TV_AMULET))
309 else if (IS_FLG(FLG_SUITS))
311 if (!(o_ptr->tval == TV_DRAG_ARMOR ||
312 o_ptr->tval == TV_HARD_ARMOR ||
313 o_ptr->tval == TV_SOFT_ARMOR))
316 else if (IS_FLG(FLG_CLOAKS))
318 if (!(o_ptr->tval == TV_CLOAK))
321 else if (IS_FLG(FLG_HELMS))
323 if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
326 else if (IS_FLG(FLG_GLOVES))
328 if (!(o_ptr->tval == TV_GLOVES))
331 else if (IS_FLG(FLG_BOOTS))
333 if (!(o_ptr->tval == TV_BOOTS))
340 if (strncmp(o_name, ptr, strlen(ptr))) return FALSE;
344 if (!my_strstr(o_name, ptr)) return FALSE;
347 if (!IS_FLG(FLG_COLLECTING)) return TRUE;
349 for (int j = 0; j < INVEN_PACK; j++)
352 * 'Collecting' means the item must be absorbed
353 * into an inventory slot.
354 * But an item can not be absorbed into itself!
356 if ((&player_ptr->inventory_list[j] != o_ptr) &&
357 object_similar(&player_ptr->inventory_list[j], o_ptr))