OSDN Git Service

Merge pull request #2122 from sikabane-works/release/3.0.0Alpha52
[hengbandforosx/hengbandosx.git] / src / mspell / smart-mspell-util.cpp
1 #include "mspell/smart-mspell-util.h"
2 #include "monster-race/monster-race.h"
3 #include "monster-race/race-ability-flags.h"
4 #include "monster-race/race-flags2.h"
5 #include "monster/smart-learn-types.h"
6 #include "system/floor-type-definition.h"
7 #include "system/monster-race-definition.h"
8 #include "system/monster-type-definition.h"
9 #include "system/player-type-definition.h"
10
11 msr_type *initialize_msr_type(PlayerType *player_ptr, msr_type *msr_ptr, MONSTER_IDX m_idx, const EnumClassFlagGroup<MonsterAbilityType> &ability_flags)
12 {
13     monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
14     msr_ptr->r_ptr = &r_info[m_ptr->r_idx];
15     msr_ptr->ability_flags = ability_flags;
16     msr_ptr->smart.clear();
17     return msr_ptr;
18 }
19
20 /*!
21  * @brief モンスターがプレイヤーの弱点をついた選択を取るかどうかの判定 /
22  * Internal probability routine
23  * @param r_ptr モンスター種族の構造体参照ポインタ
24  * @param prob 基本確率(%)
25  * @return 適した選択を取るならばTRUEを返す。
26  */
27 bool int_outof(monster_race *r_ptr, PERCENTAGE prob)
28 {
29     if (r_ptr->behavior_flags.has_not(MonsterBehaviorType::SMART))
30         prob = prob / 2;
31
32     return (randint0(100) < prob);
33 }