OSDN Git Service

Merge branch 'master' of https://github.com/hengband/hengband
[hengbandforosx/hengbandosx.git] / src / melee / melee-util.cpp
1 #include "melee/melee-util.h"
2 #include "floor/geometry.h"
3 #include "grid/grid.h"
4 #include "melee/melee-switcher.h"
5 #include "system/floor-type-definition.h"
6 #include "system/monster-entity.h"
7 #include "system/monster-race-info.h"
8 #include "system/player-type-definition.h"
9 #include "timed-effect/timed-effects.h"
10
11 mam_type *initialize_mam_type(PlayerType *player_ptr, mam_type *mam_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx)
12 {
13     mam_ptr->attribute = BlowEffectType::NONE;
14     mam_ptr->m_idx = m_idx;
15     mam_ptr->t_idx = t_idx;
16     mam_ptr->m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
17     mam_ptr->t_ptr = &player_ptr->current_floor_ptr->m_list[t_idx];
18     mam_ptr->damage = 0;
19     mam_ptr->see_m = is_seen(player_ptr, mam_ptr->m_ptr);
20     mam_ptr->see_t = is_seen(player_ptr, mam_ptr->t_ptr);
21     mam_ptr->see_either = mam_ptr->see_m || mam_ptr->see_t;
22     mam_ptr->y_saver = mam_ptr->t_ptr->fy;
23     mam_ptr->x_saver = mam_ptr->t_ptr->fx;
24     mam_ptr->explode = false;
25     mam_ptr->touched = false;
26
27     auto *r_ptr = &mam_ptr->m_ptr->get_monrace();
28     auto *tr_ptr = &mam_ptr->t_ptr->get_monrace();
29     mam_ptr->ac = tr_ptr->ac;
30     mam_ptr->rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
31     mam_ptr->blinked = false;
32     mam_ptr->do_silly_attack = (one_in_(2) && player_ptr->effects()->hallucination().is_hallucinated());
33     mam_ptr->power = 0;
34     mam_ptr->obvious = false;
35     mam_ptr->known = (mam_ptr->m_ptr->cdis <= MAX_PLAYER_SIGHT) || (mam_ptr->t_ptr->cdis <= MAX_PLAYER_SIGHT);
36     mam_ptr->fear = false;
37     mam_ptr->dead = false;
38     return mam_ptr;
39 }