OSDN Git Service

Merge pull request #765 from sikabane-works/release/3.0.0Alpha17
[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-flags2.h"
4 #include "system/floor-type-definition.h"
5 #include "system/monster-type-definition.h"
6
7 msr_type *initialize_msr_type(player_type *target_ptr, msr_type *msr_ptr, MONSTER_IDX m_idx, const FlagGroup<RF_ABILITY>& ability_flags)
8 {
9     monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
10     msr_ptr->r_ptr = &r_info[m_ptr->r_idx];
11     msr_ptr->ability_flags = ability_flags;
12     msr_ptr->smart.clear();
13     return msr_ptr;
14 }
15
16 /*!
17  * @brief モンスターがプレイヤーの弱点をついた選択を取るかどうかの判定 /
18  * Internal probability routine
19  * @param r_ptr モンスター種族の構造体参照ポインタ
20  * @param prob 基本確率(%)
21  * @return 適した選択を取るならばTRUEを返す。
22  */
23 bool int_outof(monster_race *r_ptr, PERCENTAGE prob)
24 {
25     if (!(r_ptr->flags2 & RF2_SMART))
26         prob = prob / 2;
27
28     return (randint0(100) < prob);
29 }