OSDN Git Service

Merge pull request #462 from habu1010/feature/flag-group
[hengbandforosx/hengbandosx.git] / src / mspell / improper-mspell-remover.cpp
1 #include "mspell/improper-mspell-remover.h"
2 #include "game-option/birth-options.h"
3 #include "monster-race/monster-race.h"
4 #include "monster-race/race-flags2.h"
5 #include "monster/smart-learn-types.h"
6 #include "mspell/element-resistance-checker.h"
7 #include "mspell/high-resistance-checker.h"
8 #include "mspell/smart-mspell-util.h"
9 #include "system/floor-type-definition.h"
10 #include "system/monster-type-definition.h"
11
12 static void add_cheat_remove_flags(player_type *target_ptr, msr_type *msr_ptr)
13 {
14     if (!smart_cheat)
15         return;
16
17     add_cheat_remove_flags_element(target_ptr, msr_ptr);
18     add_cheat_remove_flags_others(target_ptr, msr_ptr);
19 }
20
21 /*!
22  * @brief モンスターの魔法一覧から戦術的に適さない魔法を除外する /
23  * Remove the "bad" spells from a spell list
24  * @param m_idx モンスターの構造体参照ポインタ
25  * @param f4p モンスター魔法のフラグリスト1
26  * @param f5p モンスター魔法のフラグリスト2
27  * @param f6p モンスター魔法のフラグリスト3
28  * @return なし
29  */
30 void remove_bad_spells(MONSTER_IDX m_idx, player_type *target_ptr, u32b *f4p, u32b *f5p, u32b *f6p)
31 {
32     msr_type tmp_msr;
33     msr_type *msr_ptr = initialize_msr_type(target_ptr, &tmp_msr, m_idx, *f4p, *f5p, *f6p);
34     if (msr_ptr->r_ptr->flags2 & RF2_STUPID)
35         return;
36
37     if (!smart_cheat && !smart_learn)
38         return;
39
40     monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
41     if (smart_learn) {
42         /* 時々学習情報を忘れる */
43         if (randint0(100) < 1)
44             m_ptr->smart.clear();
45
46         msr_ptr->smart = m_ptr->smart;
47     }
48
49     add_cheat_remove_flags(target_ptr, msr_ptr);
50     if (msr_ptr->smart.none())
51         return;
52
53     check_element_resistance(msr_ptr);
54     check_high_resistances(target_ptr, msr_ptr);
55     *f4p = msr_ptr->f4;
56     *f5p = msr_ptr->f5;
57     *f6p = msr_ptr->f6;
58 }