OSDN Git Service

725a0290903cb8cebd58ea11f66ac9f605872a91
[hengbandforosx/hengbandosx.git] / src / object-hook / hook-quest.cpp
1 #include "object-hook/hook-quest.h"
2 #include "cmd-building/cmd-building.h"
3 #include "dungeon/quest.h"
4 #include "game-option/birth-options.h"
5 #include "monster-race/monster-race.h"
6 #include "monster-race/race-indice-types.h"
7 #include "object-enchant/trg-types.h"
8 #include "system/artifact-type-definition.h"
9 #include "system/floor-type-definition.h"
10 #include "system/monster-race-definition.h"
11 #include "system/object-type-definition.h"
12 #include "system/player-type-definition.h"
13 #include "world/world.h"
14
15 /*!
16  * @brief オブジェクトが賞金首の報酬対象になるかを返す
17  * @param o_ptr 対象のオブジェクト構造体ポインタ
18  * @return オブジェクトが報酬対象になるならTRUEを返す
19  */
20 bool object_is_bounty(PlayerType *player_ptr, ObjectType *o_ptr)
21 {
22     if (o_ptr->tval != ItemKindType::CORPSE) {
23         return false;
24     }
25
26     if (vanilla_town) {
27         return false;
28     }
29
30     auto corpse_r_idx = i2enum<MonsterRaceId>(o_ptr->pval);
31     if (player_ptr->knows_daily_bounty && (streq(r_info[corpse_r_idx].name.c_str(), r_info[w_ptr->today_mon].name.c_str()))) {
32         return true;
33     }
34
35     if (corpse_r_idx == MonsterRaceId::TSUCHINOKO) {
36         return true;
37     }
38
39     return MonsterRace(corpse_r_idx).is_bounty(true);
40 }
41
42 /*!
43  * @brief オブジェクトがクエストの達成目的か否かを返す。
44  * @param o_ptr 特性短縮表記を得たいオブジェクト構造体の参照ポインタ
45  * @return 現在クエスト達成目的のアイテムならばTRUEを返す。
46  */
47 bool object_is_quest_target(QuestId quest_idx, ObjectType *o_ptr)
48 {
49     if (!inside_quest(quest_idx)) {
50         return false;
51     }
52
53     const auto &quest_list = QuestList::get_instance();
54     auto a_idx = quest_list[quest_idx].k_idx;
55     if (a_idx == 0) {
56         return false;
57     }
58
59     auto *a_ptr = &a_info[a_idx];
60     if (a_ptr->gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
61         return false;
62     }
63
64     return (o_ptr->tval == a_ptr->tval) && (o_ptr->sval == a_ptr->sval);
65 }