#include "spell-kind/earthquake.h"
-#include "core/player-redraw-types.h"
-#include "core/player-update-types.h"
#include "core/window-redrawer.h"
#include "dungeon/dungeon-flag-types.h"
-#include "dungeon/dungeon.h"
#include "dungeon/quest.h"
#include "floor/cave.h"
#include "floor/floor-object.h"
#include "player/player-status-flags.h"
#include "player/special-defense-types.h"
#include "status/bad-status-setter.h"
+#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
-#include "system/monster-race-definition.h"
-#include "system/monster-type-definition.h"
+#include "system/monster-entity.h"
+#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
+#include "system/redrawing-flags-updater.h"
+#include "system/terrain-type-definition.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
* @param m_idx 地震を起こしたモンスターID(0ならばプレイヤー)
* @return 効力があった場合TRUEを返す
*/
-bool earthquake(player_type *player_ptr, POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
+bool earthquake(PlayerType *player_ptr, POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
{
- floor_type *floor_ptr = player_ptr->current_floor_ptr;
- if ((floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)) || !floor_ptr->dun_level) {
+ auto *floor_ptr = player_ptr->current_floor_ptr;
+ if ((inside_quest(floor_ptr->quest_number) && QuestType::is_fixed(floor_ptr->quest_number)) || !floor_ptr->dun_level) {
return false;
}
- if (r > 12)
+ if (r > 12) {
r = 12;
+ }
bool map[32][32];
for (POSITION y = 0; y < 32; y++) {
POSITION yy = cy + dy;
POSITION xx = cx + dx;
- if (!in_bounds(floor_ptr, yy, xx))
+ if (!in_bounds(floor_ptr, yy, xx)) {
continue;
+ }
- if (distance(cy, cx, yy, xx) > r)
+ if (distance(cy, cx, yy, xx) > r) {
continue;
+ }
grid_type *g_ptr;
g_ptr = &floor_ptr->grid_array[yy][xx];
g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY | CAVE_UNSAFE);
g_ptr->info &= ~(CAVE_GLOW | CAVE_MARK | CAVE_KNOWN);
- if (!dx && !dy)
+ if (!dx && !dy) {
continue;
+ }
- if (randint0(100) < 85)
+ if (randint0(100) < 85) {
continue;
+ }
map[16 + yy - cy][16 + xx - cx] = true;
- if (player_bold(player_ptr, yy, xx))
+ if (player_bold(player_ptr, yy, xx)) {
hurt = true;
+ }
}
}
for (DIRECTION i = 0; i < 8; i++) {
POSITION y = player_ptr->y + ddy_ddd[i];
POSITION x = player_ptr->x + ddx_ddd[i];
- if (!is_cave_empty_bold(player_ptr, y, x))
+ if (!is_cave_empty_bold(player_ptr, y, x)) {
continue;
+ }
- if (map[16 + y - cy][16 + x - cx])
+ if (map[16 + y - cy][16 + x - cx]) {
continue;
+ }
- if (floor_ptr->grid_array[y][x].m_idx)
+ if (floor_ptr->grid_array[y][x].m_idx) {
continue;
+ }
sn++;
- if (randint0(sn) > 0)
+ if (randint0(sn) > 0) {
continue;
+ }
sy = y;
sx = x;
}
- switch (randint1(3)) {
- case 1: {
- msg_print(_("ダンジョンの壁が崩れた!", "The dungeon's ceiling collapses!"));
- break;
- }
- case 2: {
- msg_print(_("ダンジョンの床が不自然にねじ曲がった!", "The dungeon's floor twists in an unnatural way!"));
- break;
- }
- default: {
- msg_print(_("ダンジョンが揺れた!崩れた岩が頭に降ってきた!", "The dungeon quakes! You are pummeled with debris!"));
- break;
- }
- }
+ constexpr static auto msgs = {
+ _("ダンジョンの壁が崩れた!", "The dungeon's ceiling collapses!"),
+ _("ダンジョンの床が不自然にねじ曲がった!", "The dungeon's floor twists in an unnatural way!"),
+ _("ダンジョンが揺れた!崩れた岩が頭に降ってきた!", "The dungeon quakes! You are pummeled with debris!"),
+ };
+ msg_print(rand_choice(msgs));
if (!sn) {
msg_print(_("あなたはひどい怪我を負った!", "You are severely crushed!"));
damage = 200;
} else {
- switch (randint1(3)) {
- case 1: {
- msg_print(_("降り注ぐ岩をうまく避けた!", "You nimbly dodge the blast!"));
- damage = 0;
- break;
- }
- case 2: {
- msg_print(_("岩石があなたに直撃した!", "You are bashed by rubble!"));
- damage = damroll(10, 4);
- (void)set_stun(player_ptr, player_ptr->stun + randint1(50));
- break;
- }
- case 3: {
- msg_print(_("あなたは床と壁との間に挟まれてしまった!", "You are crushed between the floor and ceiling!"));
+ constexpr std::array<std::pair<bool, std::string_view>, 3> candidates = { {
+ { false, _("降り注ぐ岩をうまく避けた!", "You nimbly dodge the blast!") },
+ { true, _("岩石があなたに直撃した!", "You are bashed by rubble!") },
+ { true, _("あなたは床と壁との間に挟まれてしまった!", "You are crushed between the floor and ceiling!") },
+ } };
+
+ const auto &[is_damaged, msg] = rand_choice(candidates);
+
+ msg_print(msg);
+ if (is_damaged) {
damage = damroll(10, 4);
- (void)set_stun(player_ptr, player_ptr->stun + randint1(50));
- break;
- }
+ BadStatusSetter(player_ptr).mod_stun(randint1(50));
}
(void)move_player_effect(player_ptr, sy, sx, MPE_DONT_PICKUP);
map[16 + player_ptr->y - cy][16 + player_ptr->x - cx] = false;
if (damage) {
- concptr killer;
+ std::string killer;
if (m_idx) {
- GAME_TEXT m_name[MAX_NLEN];
- monster_type *m_ptr = &floor_ptr->m_list[m_idx];
- monster_desc(player_ptr, m_name, m_ptr, MD_WRONGDOER_NAME);
- killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name);
+ auto *m_ptr = &floor_ptr->m_list[m_idx];
+ const auto m_name = monster_desc(player_ptr, m_ptr, MD_WRONGDOER_NAME);
+ killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name.data());
} else {
killer = _("地震", "an earthquake");
}
- take_hit(player_ptr, DAMAGE_ATTACK, damage, killer);
+ take_hit(player_ptr, DAMAGE_ATTACK, damage, killer.data());
}
}
for (POSITION dx = -r; dx <= r; dx++) {
POSITION yy = cy + dy;
POSITION xx = cx + dx;
- if (!map[16 + yy - cy][16 + xx - cx])
+ if (!map[16 + yy - cy][16 + xx - cx]) {
continue;
+ }
grid_type *gg_ptr;
gg_ptr = &floor_ptr->grid_array[yy][xx];
- if (gg_ptr->m_idx == player_ptr->riding)
+ if (gg_ptr->m_idx == player_ptr->riding) {
continue;
+ }
- if (!gg_ptr->m_idx)
+ if (!gg_ptr->m_idx) {
continue;
+ }
- monster_type *m_ptr = &floor_ptr->m_list[gg_ptr->m_idx];
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
+ auto *m_ptr = &floor_ptr->m_list[gg_ptr->m_idx];
+ auto *r_ptr = &monraces_info[m_ptr->r_idx];
if (r_ptr->flags1 & RF1_QUESTOR) {
map[16 + yy - cy][16 + xx - cx] = false;
continue;
}
- if ((r_ptr->flags2 & RF2_KILL_WALL) || (r_ptr->flags2 & RF2_PASS_WALL))
+ if (r_ptr->feature_flags.has(MonsterFeatureType::KILL_WALL) || r_ptr->feature_flags.has(MonsterFeatureType::PASS_WALL)) {
continue;
+ }
- GAME_TEXT m_name[MAX_NLEN];
sn = 0;
- if (none_bits(r_ptr->flags1, RF1_NEVER_MOVE)) {
+ if (r_ptr->behavior_flags.has_not(MonsterBehaviorType::NEVER_MOVE)) {
for (DIRECTION i = 0; i < 8; i++) {
POSITION y = yy + ddy_ddd[i];
POSITION x = xx + ddx_ddd[i];
- if (!is_cave_empty_bold(player_ptr, y, x))
+ if (!is_cave_empty_bold(player_ptr, y, x)) {
continue;
+ }
auto *g_ptr = &floor_ptr->grid_array[y][x];
- if (g_ptr->is_rune_protection())
+ if (g_ptr->is_rune_protection()) {
continue;
+ }
- if (g_ptr->is_rune_explosion())
+ if (g_ptr->is_rune_explosion()) {
continue;
+ }
- if (pattern_tile(floor_ptr, y, x))
+ if (pattern_tile(floor_ptr, y, x)) {
continue;
+ }
- if (map[16 + y - cy][16 + x - cx])
+ if (map[16 + y - cy][16 + x - cx]) {
continue;
+ }
- if (floor_ptr->grid_array[y][x].m_idx)
+ if (floor_ptr->grid_array[y][x].m_idx) {
continue;
+ }
- if (player_bold(player_ptr, y, x))
+ if (player_bold(player_ptr, y, x)) {
continue;
+ }
sn++;
- if (randint0(sn) > 0)
+ if (randint0(sn) > 0) {
continue;
+ }
sy = y;
sx = x;
}
}
- monster_desc(player_ptr, m_name, m_ptr, 0);
- if (!ignore_unview || is_seen(player_ptr, m_ptr))
- msg_format(_("%^sは苦痛で泣きわめいた!", "%^s wails out in pain!"), m_name);
+ const auto m_name = monster_desc(player_ptr, m_ptr, 0);
+ if (!ignore_unview || is_seen(player_ptr, m_ptr)) {
+ msg_format(_("%s^は苦痛で泣きわめいた!", "%s^ wails out in pain!"), m_name.data());
+ }
damage = (sn ? damroll(4, 8) : (m_ptr->hp + 1));
(void)set_monster_csleep(player_ptr, gg_ptr->m_idx, 0);
m_ptr->hp -= damage;
if (m_ptr->hp < 0) {
- if (!ignore_unview || is_seen(player_ptr, m_ptr))
- msg_format(_("%^sは岩石に埋もれてしまった!", "%^s is embedded in the rock!"), m_name);
+ if (!ignore_unview || is_seen(player_ptr, m_ptr)) {
+ msg_format(_("%s^は岩石に埋もれてしまった!", "%s^ is embedded in the rock!"), m_name.data());
+ }
if (gg_ptr->m_idx) {
- if (record_named_pet && is_pet(&floor_ptr->m_list[gg_ptr->m_idx]) && floor_ptr->m_list[gg_ptr->m_idx].nickname) {
- char m2_name[MAX_NLEN];
-
- monster_desc(player_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
- exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name);
+ const auto &m_ref = floor_ptr->m_list[gg_ptr->m_idx];
+ if (record_named_pet && m_ref.is_named_pet()) {
+ const auto m2_name = monster_desc(player_ptr, m_ptr, MD_INDEF_VISIBLE);
+ exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name.data());
}
}
sn = 0;
}
- if (sn == 0)
+ if (sn == 0) {
continue;
+ }
IDX m_idx_aux = floor_ptr->grid_array[yy][xx].m_idx;
floor_ptr->grid_array[yy][xx].m_idx = 0;
for (POSITION dx = -r; dx <= r; dx++) {
POSITION yy = cy + dy;
POSITION xx = cx + dx;
- if (!map[16 + yy - cy][16 + xx - cx])
+ if (!map[16 + yy - cy][16 + xx - cx]) {
continue;
+ }
- if (!cave_valid_bold(floor_ptr, yy, xx))
+ if (!cave_valid_bold(floor_ptr, yy, xx)) {
continue;
+ }
delete_all_items_from_floor(player_ptr, yy, xx);
- int t = cave_has_flag_bold(floor_ptr, yy, xx, FF::PROJECT) ? randint0(100) : 200;
+ int t = cave_has_flag_bold(floor_ptr, yy, xx, TerrainCharacteristics::PROJECT) ? randint0(100) : 200;
if (t < 20) {
cave_set_feat(player_ptr, yy, xx, feat_granite);
continue;
continue;
}
- cave_set_feat(player_ptr, yy, xx, feat_ground_type[randint0(100)]);
+ cave_set_feat(player_ptr, yy, xx, rand_choice(feat_ground_type));
}
}
for (POSITION dx = -r; dx <= r; dx++) {
POSITION yy = cy + dy;
POSITION xx = cx + dx;
- if (!in_bounds(floor_ptr, yy, xx))
+ if (!in_bounds(floor_ptr, yy, xx)) {
continue;
+ }
- if (distance(cy, cx, yy, xx) > r)
+ if (distance(cy, cx, yy, xx) > r) {
continue;
+ }
auto *g_ptr = &floor_ptr->grid_array[yy][xx];
if (g_ptr->is_mirror()) {
continue;
}
- if (d_info[player_ptr->dungeon_idx].flags.has(DF::DARKNESS))
+ if (dungeons_info[player_ptr->dungeon_idx].flags.has(DungeonFeatureType::DARKNESS)) {
continue;
+ }
grid_type *cc_ptr;
for (DIRECTION ii = 0; ii < 9; ii++) {
POSITION yyy = yy + ddy_ddd[ii];
POSITION xxx = xx + ddx_ddd[ii];
- if (!in_bounds2(floor_ptr, yyy, xxx))
+ if (!in_bounds2(floor_ptr, yyy, xxx)) {
continue;
+ }
cc_ptr = &floor_ptr->grid_array[yyy][xxx];
- if (f_info[cc_ptr->get_feat_mimic()].flags.has(FF::GLOW)) {
+ if (terrains_info[cc_ptr->get_feat_mimic()].flags.has(TerrainCharacteristics::GLOW)) {
g_ptr->info |= CAVE_GLOW;
break;
}
}
}
- player_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
- player_ptr->redraw |= (PR_HEALTH | PR_UHEALTH | PR_MAP);
+ auto &rfu = RedrawingFlagsUpdater::get_instance();
+ const auto flags_srf = {
+ StatusRedrawingFlag::UN_VIEW,
+ StatusRedrawingFlag::UN_LITE,
+ StatusRedrawingFlag::VIEW,
+ StatusRedrawingFlag::LITE,
+ StatusRedrawingFlag::FLOW,
+ StatusRedrawingFlag::MONSTER_LITE,
+ StatusRedrawingFlag::MONSTER_STATUSES,
+ };
+ rfu.set_flags(flags_srf);
+ const auto flags_mwrf = {
+ MainWindowRedrawingFlag::HEALTH,
+ MainWindowRedrawingFlag::UHEALTH,
+ MainWindowRedrawingFlag::MAP,
+ };
+ rfu.set_flags(flags_mwrf);
player_ptr->window_flags |= (PW_OVERHEAD | PW_DUNGEON);
- if (player_ptr->special_defense & NINJA_S_STEALTH) {
- if (floor_ptr->grid_array[player_ptr->y][player_ptr->x].info & CAVE_GLOW)
- set_superstealth(player_ptr, false);
+ if (floor_ptr->grid_array[player_ptr->y][player_ptr->x].info & CAVE_GLOW) {
+ set_superstealth(player_ptr, false);
}
return true;