#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
#include "system/item-entity.h"
+#include "system/monster-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
#include "system/terrain-type-definition.h"
int dir;
if (get_rep_dir(player_ptr, &dir, true)) {
+ auto &floor = *player_ptr->current_floor_ptr;
const auto pos = player_ptr->get_neighbor(dir);
- const auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
- const auto o_idx = chest_check(player_ptr->current_floor_ptr, pos, false);
+ const auto &grid = floor.get_grid(pos);
+ const auto o_idx = chest_check(&floor, pos, false);
if (grid.get_terrain_mimic().flags.has_not(TerrainCharacteristics::OPEN) && !o_idx) {
msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
- } else if (grid.has_monster() && player_ptr->riding != grid.m_idx) {
+ } else if (grid.has_monster() && !floor.m_list[grid.m_idx].is_riding()) {
PlayerEnergy(player_ptr).set_player_turn_energy(100);
msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
do_cmd_attack(player_ptr, pos.y, pos.x, HISSATSU_NONE);
int dir;
auto more = false;
if (get_rep_dir(player_ptr, &dir, true)) {
+ auto &floor = *player_ptr->current_floor_ptr;
const auto pos = player_ptr->get_neighbor(dir);
- const auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
+ const auto &grid = floor.get_grid(pos);
const auto feat = grid.get_feat_mimic();
- const auto o_idx = chest_check(player_ptr->current_floor_ptr, pos, true);
+ const auto o_idx = chest_check(&floor, pos, true);
if (!is_trap(player_ptr, feat) && !o_idx) {
msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
- } else if (grid.has_monster() && player_ptr->riding != grid.m_idx) {
+ } else if (grid.has_monster() && !floor.m_list[grid.m_idx].is_riding()) {
msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
do_cmd_attack(player_ptr, pos.y, pos.x, HISSATSU_NONE);
} else if (o_idx) {
exe_write_diary(floor, DiaryKind::NAMED_PET, RECORD_NAMED_PET_DISMISS, m_name);
}
- if (pet_ctr == player_ptr->riding) {
+ if (monster.is_riding()) {
msg_format(_("%sから降りた。", "You dismount from %s. "), friend_name.data());
player_ptr->ride_monster(0);
rfu.set_flag(StatusRecalculatingFlag::MONSTER_STATUSES);
#include "core/stuff-handler.h"
#include "core/window-redrawer.h"
#include "player/player-status.h"
+#include "system/floor-type-definition.h"
+#include "system/monster-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
#include "tracking/baseitem-tracker.h"
*/
void health_track(PlayerType *player_ptr, short m_idx)
{
- if (m_idx && m_idx == player_ptr->riding) {
+ const auto &floor = *player_ptr->current_floor_ptr;
+ const auto &monster = floor.m_list[m_idx];
+ if (monster.is_riding()) {
return;
}
cap_mon_ptr->current_hp = static_cast<short>(em_ptr->m_ptr->hp);
cap_mon_ptr->max_hp = static_cast<short>(em_ptr->m_ptr->max_maxhp);
cap_mon_ptr->nickname = em_ptr->m_ptr->nickname;
- if ((em_ptr->g_ptr->m_idx == player_ptr->riding) && process_fall_off_horse(player_ptr, -1, false)) {
+ if (em_ptr->m_ptr->is_riding() && process_fall_off_horse(player_ptr, -1, false)) {
msg_print(_("地面に落とされた。", format("You have fallen from %s.", em_ptr->m_name)));
}
* @details
* 朦朧+ショートテレポートアウェイ
*/
-ProcessResult effect_monster_telekinesis(PlayerType *player_ptr, EffectMonster *em_ptr)
+ProcessResult effect_monster_telekinesis(EffectMonster *em_ptr)
{
if (em_ptr->seen) {
em_ptr->obvious = true;
}
if (one_in_(4)) {
- if (player_ptr->riding && (em_ptr->g_ptr->m_idx == player_ptr->riding)) {
+ if (em_ptr->m_ptr->is_riding()) {
em_ptr->do_dist = 0;
} else {
em_ptr->do_dist = 7;
class PlayerType;
ProcessResult effect_monster_psi(PlayerType *player_ptr, EffectMonster *em_ptr);
ProcessResult effect_monster_psi_drain(PlayerType *player_ptr, EffectMonster *em_ptr);
-ProcessResult effect_monster_telekinesis(PlayerType *player_ptr, EffectMonster *em_ptr);
+ProcessResult effect_monster_telekinesis(EffectMonster *em_ptr);
ProcessResult effect_monster_gravity(PlayerType *player_ptr, EffectMonster *em_ptr)
{
em_ptr->do_dist = effect_monster_gravity_resist_teleport(player_ptr, em_ptr) ? 0 : 10;
- if (player_ptr->riding && (em_ptr->g_ptr->m_idx == player_ptr->riding)) {
+ if (em_ptr->m_ptr->is_riding()) {
em_ptr->do_dist = 0;
}
case AttributeType::PSI_DRAIN:
return effect_monster_psi_drain(player_ptr, em_ptr);
case AttributeType::TELEKINESIS:
- return effect_monster_telekinesis(player_ptr, em_ptr);
+ return effect_monster_telekinesis(em_ptr);
case AttributeType::DOMINATION:
return effect_monster_domination(player_ptr, em_ptr);
case AttributeType::ICE:
* @param em_ptr モンスター効果構造体への参照ポインタ
* @return 効果が何もないならFALSE、何かあるならTRUE
*/
-static ProcessResult is_affective(PlayerType *player_ptr, EffectMonster *em_ptr)
+static ProcessResult is_affective(EffectMonster *em_ptr)
{
if (!em_ptr->g_ptr->has_monster()) {
return ProcessResult::PROCESS_FALSE;
if (em_ptr->m_ptr->hp < 0) {
return ProcessResult::PROCESS_FALSE;
}
- if (is_monster(em_ptr->src_idx) || em_ptr->g_ptr->m_idx != player_ptr->riding) {
+ if (is_monster(em_ptr->src_idx) || !em_ptr->m_ptr->is_riding()) {
return ProcessResult::PROCESS_TRUE;
}
return em_ptr->attribute == attribute;
};
- ProcessResult result = is_affective(player_ptr, em_ptr);
+ ProcessResult result = is_affective(em_ptr);
if (result != ProcessResult::PROCESS_TRUE) {
if (result == ProcessResult::PROCESS_CONTINUE) {
em_ptr->note = _("には効果がなかった。", " is unaffected.");
* @param player_ptr プレイヤーへの参照ポインタ
* @param em_ptr モンスター効果構造体への参照ポインタ
*/
-static void affected_monster_prevents_bad_status(PlayerType *player_ptr, EffectMonster *em_ptr)
+static void affected_monster_prevents_bad_status(EffectMonster *em_ptr)
{
const auto *r_ptr = em_ptr->r_ptr;
auto can_avoid_polymorph = r_ptr->kind_flags.has(MonsterKindType::UNIQUE);
can_avoid_polymorph |= r_ptr->misc_flags.has(MonsterMiscType::QUESTOR);
- can_avoid_polymorph |= (player_ptr->riding != 0) && (em_ptr->g_ptr->m_idx == player_ptr->riding);
+ can_avoid_polymorph |= em_ptr->m_ptr->is_riding();
if (can_avoid_polymorph) {
em_ptr->do_polymorph = false;
}
static void exe_affect_monster_by_damage(PlayerType *player_ptr, EffectMonster *em_ptr)
{
effect_makes_change_virtues(player_ptr, em_ptr);
- affected_monster_prevents_bad_status(player_ptr, em_ptr);
+ affected_monster_prevents_bad_status(em_ptr);
effect_damage_gives_bad_status(player_ptr, em_ptr);
deal_effect_damage_to_monster(player_ptr, em_ptr);
if ((em_ptr->attribute == AttributeType::BLOOD_CURSE) && one_in_(4)) {
* @param player_ptr プレイヤーへの参照ポインタ
* @param em_ptr モンスター効果構造体への参照ポインタ
*/
-static void postprocess_by_riding_pet_effected(PlayerType *player_ptr, EffectMonster *em_ptr, FallOffHorseEffect *fall_off_horse_effect)
+static void postprocess_by_riding_pet_effected(EffectMonster *em_ptr, FallOffHorseEffect *fall_off_horse_effect)
{
- if (!player_ptr->riding || (player_ptr->riding != em_ptr->g_ptr->m_idx) || (em_ptr->dam <= 0)) {
+ if (!em_ptr->m_ptr->is_riding() || (em_ptr->dam <= 0)) {
return;
}
static void exe_affect_monster_postprocess(PlayerType *player_ptr, EffectMonster *em_ptr, FallOffHorseEffect *fall_off_horse_effect)
{
postprocess_by_effected_pet(player_ptr, em_ptr);
- postprocess_by_riding_pet_effected(player_ptr, em_ptr, fall_off_horse_effect);
+ postprocess_by_riding_pet_effected(em_ptr, fall_off_horse_effect);
postprocess_by_taking_photo(player_ptr, em_ptr);
project_m_n++;
project_m_x = em_ptr->x;
make_description_of_affecred_monster(player_ptr, em_ptr);
- if (player_ptr->riding && (target_m_idx == player_ptr->riding)) {
+ if (is_monster(target_m_idx) && em_ptr->m_ptr->is_riding()) {
disturb(player_ptr, true, true);
}
auto is_effective = ep_ptr->dam > 0;
is_effective &= randint0(55) < (player_ptr->lev * 3 / 5 + 20);
is_effective &= is_monster(ep_ptr->src_idx);
- is_effective &= ep_ptr->src_idx != player_ptr->riding;
+ is_effective &= !ep_ptr->src_ptr || !ep_ptr->src_ptr->is_riding();
if (is_effective && kawarimi(player_ptr, true)) {
return ProcessResult::PROCESS_FALSE;
}
- if (is_player(ep_ptr->src_idx) || (ep_ptr->src_idx == player_ptr->riding)) {
+ if (is_player(ep_ptr->src_idx) || (ep_ptr->src_ptr && ep_ptr->src_ptr->is_riding())) {
return ProcessResult::PROCESS_FALSE;
}
}
disturb(player_ptr, true, true);
- if (ep_ptr->dam && ep_ptr->src_idx && (ep_ptr->src_idx != player_ptr->riding)) {
+ if (ep_ptr->dam && ep_ptr->src_idx && (!ep_ptr->src_ptr || !ep_ptr->src_ptr->is_riding())) {
(void)kawarimi(player_ptr, false);
}
if (grids <= 1) {
auto *m_ptr = &floor.m_list[grid.m_idx];
MonsterRaceInfo *ref_ptr = &m_ptr->get_monrace();
- if ((flag & PROJECT_REFLECTABLE) && grid.m_idx && ref_ptr->misc_flags.has(MonsterMiscType::REFLECTING) && ((grid.m_idx != player_ptr->riding) || !(flag & PROJECT_PLAYER)) && (!src_idx || path_n > 1) && !one_in_(10)) {
+ if ((flag & PROJECT_REFLECTABLE) && grid.m_idx && ref_ptr->misc_flags.has(MonsterMiscType::REFLECTING) && (!m_ptr->is_riding() || !(flag & PROJECT_PLAYER)) && (!src_idx || path_n > 1) && !one_in_(10)) {
POSITION t_y, t_x;
int max_attempts = 10;
for (MONSTER_IDX i = player_ptr->current_floor_ptr->m_max - 1, party_monster_num = 1; (i >= 1) && (party_monster_num < MAX_PARTY_MON); i--) {
auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
- if (!m_ptr->is_valid() || !m_ptr->is_pet() || (i == player_ptr->riding) || check_pet_preservation_conditions(player_ptr, m_ptr)) {
+ if (!m_ptr->is_valid() || !m_ptr->is_pet() || m_ptr->is_riding() || check_pet_preservation_conditions(player_ptr, m_ptr)) {
continue;
}
continue;
}
- if (m_ptr->is_pet() && i != player_ptr->riding) {
+ if (m_ptr->is_pet() && !m_ptr->is_riding()) {
has_pet = true;
}
if (!(mode & TELEPORT_NONMAGICAL) && grid.is_icky()) {
return false;
}
-
- if (grid.has_monster() && (grid.m_idx != player_ptr->riding)) {
+ const auto &floor = *player_ptr->current_floor_ptr;
+ if (grid.has_monster() && !floor.m_list[grid.m_idx].is_riding()) {
return false;
}
continue;
}
pet_settings = true;
- if (!m_ptr->is_named() && (player_ptr->riding != i)) {
+ if (!m_ptr->is_named() && !m_ptr->is_riding()) {
continue;
}
if (!pet) {
*/
static void fall_off_horse_by_melee(PlayerType *player_ptr, mam_pp_type *mam_pp_ptr)
{
- if (!player_ptr->riding || (player_ptr->riding != mam_pp_ptr->m_idx) || (mam_pp_ptr->dam <= 0)) {
+ if (!mam_pp_ptr->m_ptr->is_riding() || (mam_pp_ptr->dam <= 0)) {
return;
}
prepare_redraw(mam_pp_ptr);
(void)set_monster_csleep(player_ptr, m_idx, 0);
- if (player_ptr->riding && (m_idx == player_ptr->riding)) {
+ if (m_ptr->is_riding()) {
disturb(player_ptr, true, true);
}
ms_ptr->ability_flags.reset(MonsterAbilityType::SPECIAL);
}
-static void check_riding(PlayerType *player_ptr, melee_spell_type *ms_ptr)
+static void check_riding(melee_spell_type *ms_ptr)
{
- if (ms_ptr->m_idx != player_ptr->riding) {
+ if (!ms_ptr->m_ptr->is_riding()) {
return;
}
ms_ptr->ability_flags.reset(RF_ABILITY_SUMMON_MASK);
}
- if (!(player_ptr->pet_extra_flags & PF_BALL_SPELL) && (ms_ptr->m_idx != player_ptr->riding)) {
+ if (!(player_ptr->pet_extra_flags & PF_BALL_SPELL) && !ms_ptr->m_ptr->is_riding()) {
check_melee_spell_distance(player_ptr, ms_ptr);
check_melee_spell_rocket(player_ptr, ms_ptr);
check_melee_spell_beam(player_ptr, ms_ptr);
}
const auto &floor = *player_ptr->current_floor_ptr;
- if (ms_ptr->ability_flags.has(MonsterAbilityType::TELE_LEVEL) && floor.can_teleport_level((ms_ptr->target_idx != player_ptr->riding) ? ms_ptr->target_idx != 0 : false)) {
+ if (ms_ptr->ability_flags.has(MonsterAbilityType::TELE_LEVEL) && floor.can_teleport_level(!ms_ptr->t_ptr->is_riding() ? ms_ptr->target_idx != 0 : false)) {
ms_ptr->ability_flags.reset(MonsterAbilityType::TELE_LEVEL);
}
}
ms_ptr->ability_flags.reset(MonsterAbilityType::HEAL);
}
- check_riding(player_ptr, ms_ptr);
+ check_riding(ms_ptr);
check_pet(player_ptr, ms_ptr);
check_non_stupid(player_ptr, ms_ptr);
check_smart(player_ptr, ms_ptr);
ms_ptr->m_name = monster_desc(player_ptr, ms_ptr->m_ptr, 0x00);
ms_ptr->thrown_spell = rand_choice(ms_ptr->spells);
- if (player_ptr->riding && (m_idx == player_ptr->riding)) {
+ if (ms_ptr->m_ptr->is_riding()) {
disturb(player_ptr, true, true);
}
break;
case RaceBlowEffectType::EAT_ITEM:
case RaceBlowEffectType::EAT_GOLD:
- if ((player_ptr->riding != mam_ptr->m_idx) && one_in_(2)) {
+ if (!mam_ptr->m_ptr->is_riding() && one_in_(2)) {
mam_ptr->blinked = true;
}
player_ptr->current_floor_ptr->monster_noise = true;
}
- if (player_ptr->riding && (m_idx == player_ptr->riding)) {
+ if (mam_ptr->m_ptr->is_riding()) {
disturb(player_ptr, true, true);
}
const auto &monrace_to = monster_to.get_monrace();
auto do_kill_body = monrace_from.behavior_flags.has(MonsterBehaviorType::KILL_BODY) && monrace_from.behavior_flags.has_not(MonsterBehaviorType::NEVER_BLOW);
do_kill_body &= (monrace_from.mexp * monrace_from.level > monrace_to.mexp * monrace_to.level);
- do_kill_body &= (g_ptr->m_idx != player_ptr->riding);
+ do_kill_body &= !monster_to.is_riding();
if (do_kill_body || monster_from.is_hostile_to_melee(monster_to) || monster_from.is_confused()) {
return exe_monster_attack_to_monster(player_ptr, m_idx, g_ptr);
}
auto do_move_body = monrace_from.behavior_flags.has(MonsterBehaviorType::MOVE_BODY) && monrace_from.behavior_flags.has_not(MonsterBehaviorType::NEVER_MOVE);
do_move_body &= (monrace_from.mexp > monrace_to.mexp);
do_move_body &= can_cross;
- do_move_body &= (g_ptr->m_idx != player_ptr->riding);
+ do_move_body &= !monster_to.is_riding();
do_move_body &= monster_can_cross_terrain(player_ptr, player_ptr->current_floor_ptr->grid_array[monster_from.fy][monster_from.fx].feat, &monrace_to, 0);
if (do_move_body) {
turn_flags_ptr->do_move = true;
QuestCompletionChecker(player_ptr, md_ptr->m_ptr).complete();
on_defeat_arena_monster(player_ptr, md_ptr);
- if (m_idx == player_ptr->riding && process_fall_off_horse(player_ptr, -1, false)) {
+ if (md_ptr->m_ptr->is_riding() && process_fall_off_horse(player_ptr, -1, false)) {
msg_print(_("地面に落とされた。", "You have fallen from the pet you were riding."));
}
continue;
}
- const auto can_pass_wall = r_ptr->feature_flags.has(MonsterFeatureType::PASS_WALL) && ((m_idx != player_ptr->riding) || has_pass_wall(player_ptr));
- const auto can_kill_wall = r_ptr->feature_flags.has(MonsterFeatureType::KILL_WALL) && (m_idx != player_ptr->riding);
+ const auto can_pass_wall = r_ptr->feature_flags.has(MonsterFeatureType::PASS_WALL) && (!m_ptr->is_riding() || has_pass_wall(player_ptr));
+ const auto can_kill_wall = r_ptr->feature_flags.has(MonsterFeatureType::KILL_WALL) && !m_ptr->is_riding();
if (can_pass_wall || can_kill_wall) {
if (!in_disintegration_range(floor_ptr, m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) {
continue;
Grid *g_ptr;
g_ptr = &floor_ptr->grid_array[y][x];
- BIT_FLAGS16 riding_mode = (m_idx == player_ptr->riding) ? CEM_RIDING : 0;
+ BIT_FLAGS16 riding_mode = m_ptr->is_riding() ? CEM_RIDING : 0;
if (!monster_can_cross_terrain(player_ptr, g_ptr->feat, r_ptr, riding_mode)) {
continue;
}
this->will_run = this->mon_will_run();
Pos2D pos_monster_from(monster_from.fy, monster_from.fx);
const auto no_flow = monster_from.mflag2.has(MonsterConstantFlagType::NOFLOW) && (floor.get_grid(pos_monster_from).get_cost(&monrace) > 2);
- this->can_pass_wall = monrace.feature_flags.has(MonsterFeatureType::PASS_WALL) && ((this->m_idx != this->player_ptr->riding) || has_pass_wall(this->player_ptr));
+ this->can_pass_wall = monrace.feature_flags.has(MonsterFeatureType::PASS_WALL) && (!monster_from.is_riding() || has_pass_wall(this->player_ptr));
if (!this->will_run && monster_from.target_y) {
Pos2D pos_target(monster_from.target_y, monster_from.target_x);
int t_m_idx = floor.get_grid(pos_target).m_idx;
bool MonsterSweepGrid::check_movable_grid(POSITION *yp, POSITION *xp, const bool no_flow)
{
- const auto &monrace = this->player_ptr->current_floor_ptr->m_list[this->m_idx].get_monrace();
+ const auto &monster = this->player_ptr->current_floor_ptr->m_list[this->m_idx];
+ const auto &monrace = monster.get_monrace();
if ((monrace.ability_flags.has_any_of(RF_ABILITY_ATTACK_MASK)) && (sweep_ranged_attack_grid(yp, xp))) {
return false;
}
return false;
}
- if (monrace.feature_flags.has(MonsterFeatureType::PASS_WALL) && ((this->m_idx != this->player_ptr->riding) || has_pass_wall(this->player_ptr))) {
+ if (monrace.feature_flags.has(MonsterFeatureType::PASS_WALL) && (!monster.is_riding() || has_pass_wall(this->player_ptr))) {
return false;
}
- if (monrace.feature_flags.has(MonsterFeatureType::KILL_WALL) && (this->m_idx != this->player_ptr->riding)) {
+ if (monrace.feature_flags.has(MonsterFeatureType::KILL_WALL) && !monster.is_riding()) {
return false;
}
bool MonsterSweepGrid::is_best_cost(const POSITION y, const POSITION x, const int now_cost)
{
auto *floor_ptr = this->player_ptr->current_floor_ptr;
- const auto &monrace = floor_ptr->m_list[this->m_idx].get_monrace();
- auto is_riding = this->m_idx == this->player_ptr->riding;
+ const auto &monster = floor_ptr->m_list[this->m_idx];
+ const auto &monrace = monster.get_monrace();
+ auto is_riding = monster.is_riding();
if ((monrace.feature_flags.has_not(MonsterFeatureType::PASS_WALL) || (is_riding && !has_pass_wall(this->player_ptr))) && (monrace.feature_flags.has_not(MonsterFeatureType::KILL_WALL) || is_riding)) {
if (this->cost == 0) {
return false;
if (monrace.level > cur_lev) {
continue;
}
- if (i == player_ptr->riding) {
+ if (monster.is_riding()) {
continue;
}
if ((cur_dis > 0) && (monster.cdis < cur_dis)) {
return _(replace_monster_name_undefined(name), format("%s?", name.data()));
}
- if (AngbandSystem::get_instance().is_phase_out() && !(player.riding && (&player.current_floor_ptr->m_list[player.riding] == &monster))) {
+ if (AngbandSystem::get_instance().is_phase_out() && !monster.is_riding()) {
return format(_("%sもどき", "fake %s"), name.data());
}
ss << _("「", " called ") << m_ptr->nickname << _("」", "");
}
- if (player_ptr->riding && (&player_ptr->current_floor_ptr->m_list[player_ptr->riding] == m_ptr)) {
+ if (m_ptr->is_riding()) {
ss << _("(乗馬中)", "(riding)");
}
* @param m_idx モンスターID
* @return 初期化済のターン経過フラグ
*/
-turn_flags *init_turn_flags(MONSTER_IDX riding_idx, MONSTER_IDX m_idx, turn_flags *turn_flags_ptr)
+turn_flags *init_turn_flags(bool is_riding, turn_flags *turn_flags_ptr)
{
- turn_flags_ptr->is_riding_mon = (m_idx == riding_idx);
+ turn_flags_ptr->is_riding_mon = is_riding;
turn_flags_ptr->do_turn = false;
turn_flags_ptr->do_move = false;
turn_flags_ptr->do_view = false;
int gdis = 0;
};
-class MonsterEntity;
-turn_flags *init_turn_flags(MONSTER_IDX riding_idx, MONSTER_IDX m_idx, turn_flags *turn_flags_ptr);
+turn_flags *init_turn_flags(bool is_riding, turn_flags *turn_flags_ptr);
void store_enemy_approch_direction(int *mm, POSITION y, POSITION x);
void store_moves_val(int *mm, int y, int x);
{
auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
turn_flags tmp_flags;
- turn_flags *turn_flags_ptr = init_turn_flags(player_ptr->riding, m_idx, &tmp_flags);
+ turn_flags *turn_flags_ptr = init_turn_flags(m_ptr->is_riding(), &tmp_flags);
turn_flags_ptr->see_m = is_seen(player_ptr, m_ptr);
decide_drop_from_monster(player_ptr, m_idx, turn_flags_ptr->is_riding_mon);
RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::MONSTER_LITE);
}
- if (m_idx == player_ptr->riding) {
+ if (turn_flags_ptr->is_riding_mon) {
msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name.data());
if (new_monrace.misc_flags.has_not(MonsterMiscType::RIDING)) {
if (process_fall_off_horse(player_ptr, 0, true)) {
}
auto new_exp = s_ptr->mexp * s_ptr->level / (r_ptr->level + 2);
- if (m_idx == player_ptr->riding) {
+ if (m_ptr->is_riding()) {
new_exp = (new_exp + 1) / 2;
}
auto &rfu = RedrawingFlagsUpdater::get_instance();
if (m_ptr->exp < r_ptr->next_exp) {
- if (m_idx == player_ptr->riding) {
+ if (m_ptr->is_riding()) {
rfu.set_flag(StatusRecalculatingFlag::BONUS);
}
update_monster(player_ptr, m_idx, false);
lite_spot(player_ptr, m_ptr->fy, m_ptr->fx);
- if (m_idx == player_ptr->riding) {
+ if (m_ptr->is_riding()) {
rfu.set_flag(StatusRecalculatingFlag::BONUS);
}
}
#include "status/shape-changer.h"
#include "status/sight-setter.h"
#include "status/temporary-resistance.h"
+#include "system/floor-type-definition.h"
+#include "system/monster-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
#include "view/display-messages.h"
return res;
}
-
+ const auto &floor = *player_ptr->current_floor_ptr;
+ const auto &target = floor.m_list[t_idx];
if (target_type == MONSTER_TO_MONSTER) {
- if (t_idx == player_ptr->riding) {
+ if (target.is_riding()) {
dispel_player(player_ptr);
}
return res;
}
- if (t_idx == player_ptr->riding) {
+ if (t_ptr->is_riding()) {
teleport_player_to(player_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
} else {
teleport_monster_to(player_ptr, t_idx, m_ptr->fy, m_ptr->fx, 100, TELEPORT_PASSIVE);
return res;
}
- if (t_idx == player_ptr->riding) {
+ if (t_ptr->is_riding()) {
teleport_player_away(m_idx, player_ptr, MAX_PLAYER_SIGHT * 2 + 5, false);
} else {
teleport_away(player_ptr, t_idx, MAX_PLAYER_SIGHT * 2 + 5, TELEPORT_PASSIVE);
spell_badstatus_message_to_mons(player_ptr, m_idx, t_idx, msg, resist, saving_throw);
if (!resist && !saving_throw) {
- teleport_level(player_ptr, (t_idx == player_ptr->riding) ? 0 : t_idx);
+ teleport_level(player_ptr, t_ptr->is_riding() ? 0 : t_idx);
}
return res;
bool fear, dead; /* dummy */
int dam = Dice::roll(4, 8);
- if (monster_to_player || t_idx == player_ptr->riding) {
+ if (monster_to_player || t_ptr->is_riding()) {
teleport_player_to(player_ptr, m_ptr->fy, m_ptr->fx, i2enum<teleport_flags>(TELEPORT_NONMAGICAL | TELEPORT_PASSIVE));
} else {
teleport_monster_to(player_ptr, t_idx, m_ptr->fy, m_ptr->fx, 100, i2enum<teleport_flags>(TELEPORT_NONMAGICAL | TELEPORT_PASSIVE));
std::vector<short> pet_index;
for (short pet_indice = floor.m_max - 1; pet_indice >= 1; pet_indice--) {
const auto &monster = floor.m_list[pet_indice];
- if (monster.is_pet() && (player_ptr->riding != pet_indice)) {
+ if (monster.is_pet() && !monster.is_riding()) {
pet_index.push_back(pet_indice);
}
}
}
auto &grid = floor.get_grid(pos);
- if (grid.m_idx == player_ptr->riding) {
- continue;
- }
if (!grid.has_monster()) {
continue;
}
auto *m_ptr = &floor.m_list[grid.m_idx];
+
+ if (m_ptr->is_riding()) {
+ continue;
+ }
+
auto *r_ptr = &m_ptr->get_monrace();
if (r_ptr->misc_flags.has(MonsterMiscType::QUESTOR)) {
map[16 + pos.y - cy][16 + pos.x - cx] = false;
#include "monster/monster-describer.h"
#include "monster/monster-status-setter.h"
#include "monster/monster-update.h"
+#include "monster/monster-util.h"
#include "system/angband-system.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
auto &floor = *player_ptr->current_floor_ptr;
const Pos2D pos(target_row, target_col);
auto m_idx = floor.get_grid(pos).m_idx;
- if (!m_idx) {
+ if (!is_monster(m_idx)) {
return false;
}
- if (m_idx == player_ptr->riding) {
+ auto &monster = floor.m_list[m_idx];
+ if (monster.is_riding()) {
return false;
}
if (!floor.has_los(pos)) {
return false;
}
- auto &monster = floor.m_list[m_idx];
const auto m_name = monster_desc(player_ptr, &monster, 0);
msg_format(_("%sを引き戻した。", "You pull back %s."), m_name.data());
ProjectionPath path_g(player_ptr, AngbandSystem::get_instance().get_max_range(), { target_row, target_col }, player_ptr->get_position(), 0);
} else if (monrace.resistance_flags.has(MonsterResistanceType::NO_INSTANTLY_DEATH)) {
monrace.r_resistance_flags.set(MonsterResistanceType::NO_INSTANTLY_DEATH);
resist = true;
- } else if (m_idx == player_ptr->riding) {
+ } else if (monster.is_riding()) {
resist = true;
} else if (floor.is_special()) {
resist = true;
#include "monster/monster-status-setter.h"
#include "monster/monster-status.h"
#include "monster/monster-update.h"
+#include "monster/monster-util.h"
#include "mutation/mutation-flag-types.h"
#include "object-enchant/tr-types.h"
#include "player-base/player-class.h"
}
const auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
- if (!grid.has_monster() || (grid.m_idx == player_ptr->riding)) {
+ if (!grid.has_monster() || player_ptr->current_floor_ptr->m_list[grid.m_idx].is_riding()) {
msg_print(_("それとは場所を交換できません。", "You can't trade places with that!"));
return false;
}
for (POSITION xx = -1; xx < 2; xx++) {
for (POSITION yy = -1; yy < 2; yy++) {
MONSTER_IDX tmp_m_idx = player_ptr->current_floor_ptr->grid_array[oy + yy][ox + xx].m_idx;
- if (tmp_m_idx && (player_ptr->riding != tmp_m_idx)) {
- auto *m_ptr = &player_ptr->current_floor_ptr->m_list[tmp_m_idx];
+ if (!is_monster(tmp_m_idx)) {
+ continue;
+ }
+ auto *m_ptr = &player_ptr->current_floor_ptr->m_list[tmp_m_idx];
+ if (!m_ptr->is_riding()) {
auto *r_ptr = &m_ptr->get_monrace();
bool can_follow = r_ptr->ability_flags.has(MonsterAbilityType::TPORT);
if (!teleport_player_aux(player_ptr, dis, is_quantum_effect, TELEPORT_PASSIVE)) {
return;
}
+ const auto &floor = *player_ptr->current_floor_ptr;
/* Monsters with teleport ability may follow the player */
for (POSITION xx = -1; xx < 2; xx++) {
for (POSITION yy = -1; yy < 2; yy++) {
- MONSTER_IDX tmp_m_idx = player_ptr->current_floor_ptr->grid_array[oy + yy][ox + xx].m_idx;
- bool is_teleportable = tmp_m_idx > 0;
- is_teleportable &= player_ptr->riding != tmp_m_idx;
+ const auto tmp_m_idx = floor.grid_array[oy + yy][ox + xx].m_idx;
+ auto is_teleportable = is_monster(tmp_m_idx) && !floor.m_list[tmp_m_idx].is_riding();
is_teleportable &= m_idx != tmp_m_idx;
if (!is_teleportable) {
continue;
}
}
- auto comp_importance = [riding_idx = player_ptr->riding, &floor](MONSTER_IDX idx1, MONSTER_IDX idx2) {
+ auto comp_importance = [&floor](MONSTER_IDX idx1, MONSTER_IDX idx2) {
const auto &monster1 = floor.m_list[idx1];
const auto &monster2 = floor.m_list[idx2];
const auto &ap_monrace1 = monster1.get_appearance_monrace();
const auto &ap_monrace2 = monster2.get_appearance_monrace();
- if ((riding_idx == idx1) != (riding_idx == idx2)) {
- return riding_idx == idx1;
+ if (monster1.is_riding() != monster2.is_riding()) {
+ return monster1.is_riding();
}
if (monster1.is_named_pet() != monster2.is_named_pet()) {
const auto &floor = *player_ptr->current_floor_ptr;
for (MONSTER_IDX i = 1; i < floor.m_max; i++) {
const auto &monster = floor.m_list[i];
- if (!monster.is_valid() || (i == player_ptr->riding)) {
+ if (!monster.is_valid() || monster.is_riding()) {
continue;
}
for (auto x = 0; x < floor_ptr->width; ++x) {
for (auto y = 0; y < floor_ptr->height; y++) {
auto *g_ptr = &floor_ptr->grid_array[y][x];
- if (g_ptr->has_monster() && (g_ptr->m_idx != this->player_ptr->riding)) {
+ if (g_ptr->has_monster() && !floor_ptr->m_list[g_ptr->m_idx].is_riding()) {
number_mon++;
win_m_idx = g_ptr->m_idx;
}