OSDN Git Service

[Refactor] #2204 HIT_POINTエイリアスをintに揃えた
[hengbandforosx/hengbandosx.git] / src / effect / effect-monster-util.cpp
1 /*!
2  * @brief effect_monster_type構造体の初期化処理
3  * @date 2020/04/29
4  * @author Hourier
5  */
6
7 #include "effect/effect-monster-util.h"
8 #include "floor/geometry.h"
9 #include "monster-floor/monster-death.h"
10 #include "monster-race/monster-race.h"
11 #include "monster/monster-info.h"
12 #include "monster/monster-status.h"
13 #include "system/floor-type-definition.h"
14 #include "system/grid-type-definition.h"
15 #include "system/monster-race-definition.h"
16 #include "system/monster-type-definition.h"
17 #include "system/player-type-definition.h"
18
19 /*!
20  * @brief affect_monster() に亘ってきた引数をeffect_monster_type構造体に代入する
21  * @param em_ptr モンスター効果構造体への参照ポインタ
22  * @param who 魔法を発動したモンスター (0ならばプレイヤー)
23  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
24  * @param y 目標y座標 / Target y location (or location to travel "towards")
25  * @param x 目標x座標 / Target x location (or location to travel "towards")
26  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
27  * @param attribute 効果属性 / Type of damage to apply to monsters (and objects)
28  * @param flag 効果フラグ
29  * @param see_s_msg TRUEならばメッセージを表示する
30  */
31 static void substitute_effect_monster(effect_monster_type *em_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, int dam, AttributeType attribute, BIT_FLAGS flag, bool see_s_msg)
32 {
33         em_ptr->who = who;
34         em_ptr->r = r;
35         em_ptr->y = y;
36         em_ptr->x = x;
37         em_ptr->dam = dam;
38         em_ptr->attribute = attribute;
39         em_ptr->flag = flag;
40         em_ptr->see_s_msg = see_s_msg;
41 }
42
43
44 /*!
45  * @brief effect_monster_type構造体を初期化する
46  * @param player_ptr プレイヤーへの参照ポインタ
47  * @param em_ptr モンスター効果構造体への参照ポインタ
48  * @param who 魔法を発動したモンスター (0ならばプレイヤー)
49  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
50  * @param y 目標y座標 / Target y location (or location to travel "towards")
51  * @param x 目標x座標 / Target x location (or location to travel "towards")
52  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
53  * @param attribute 効果属性 / Type of damage to apply to monsters (and objects)
54  * @param flag 効果フラグ
55  * @param see_s_msg TRUEならばメッセージを表示する
56  */
57 effect_monster_type *initialize_effect_monster(PlayerType *player_ptr, effect_monster_type *em_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, int dam, AttributeType attribute, BIT_FLAGS flag, bool see_s_msg)
58 {
59         substitute_effect_monster(em_ptr, who, r, y, x, dam, attribute, flag, see_s_msg);
60
61         auto *floor_ptr = player_ptr->current_floor_ptr;
62         em_ptr->g_ptr = &floor_ptr->grid_array[em_ptr->y][em_ptr->x];
63         em_ptr->m_ptr = &floor_ptr->m_list[em_ptr->g_ptr->m_idx];
64         em_ptr->m_caster_ptr = (em_ptr->who > 0) ? &floor_ptr->m_list[em_ptr->who] : nullptr;
65         em_ptr->r_ptr = &r_info[em_ptr->m_ptr->r_idx];
66         em_ptr->seen = em_ptr->m_ptr->ml;
67         em_ptr->seen_msg = is_seen(player_ptr, em_ptr->m_ptr);
68         em_ptr->slept = (bool)monster_csleep_remaining(em_ptr->m_ptr);
69         em_ptr->obvious = false;
70         em_ptr->known = ((em_ptr->m_ptr->cdis <= MAX_SIGHT) || player_ptr->phase_out);
71         em_ptr->skipped = false;
72         em_ptr->get_angry = false;
73         em_ptr->do_polymorph = false;
74         em_ptr->do_dist = 0;
75         em_ptr->do_conf = 0;
76         em_ptr->do_stun = 0;
77         em_ptr->do_sleep = 0;
78         em_ptr->do_fear = 0;
79         em_ptr->do_time = 0;
80         em_ptr->heal_leper = false;
81         em_ptr->photo = 0;
82         em_ptr->note = nullptr;
83         em_ptr->note_dies = extract_note_dies(real_r_idx(em_ptr->m_ptr));
84         em_ptr->caster_lev = (em_ptr->who > 0) ? r_info[em_ptr->m_caster_ptr->r_idx].level : (player_ptr->lev * 2);
85         return em_ptr;
86 }