#include "player/eldritch-horror.h"
#include "core/player-update-types.h"
#include "core/stuff-handler.h"
+#include "locale/english.h"
#include "monster-race/monster-race-hook.h"
#include "monster-race/monster-race.h"
#include "monster-race/race-flags1.h"
#include "monster/monster-util.h"
#include "monster/smart-learn-types.h"
#include "mutation/mutation-flag-types.h"
-#include "player/mimic-info-table.h"
+#include "player-base/player-race.h"
+#include "player-info/mimic-info-table.h"
#include "player/player-status-flags.h"
#include "player/player-status.h"
#include "status/bad-status-setter.h"
#include "status/base-status.h"
#include "system/floor-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 "timed-effect/player-hallucination.h"
+#include "timed-effect/timed-effects.h"
#include "view/display-messages.h"
#include "world/world.h"
-#ifdef JP
-#else
-#include "locale/english.h"
-#endif
/*!
* @brief エルドリッチホラーの形容詞種別を決める
* @param r_ptr モンスター情報への参照ポインタ
* @return
*/
-static concptr decide_horror_message(monster_race *r_ptr)
+static concptr decide_horror_message(MonsterRaceInfo *r_ptr)
{
int horror_num = randint0(MAX_SAN_HORROR_SUM);
if (horror_num < MAX_SAN_HORROR_COMMON) {
return horror_desc_common[horror_num];
}
- if ((r_ptr->flags3 & RF3_EVIL) != 0) {
+ if (r_ptr->kind_flags.has(MonsterKindType::EVIL)) {
return horror_desc_evil[horror_num - MAX_SAN_HORROR_COMMON];
}
* @brief エルドリッチホラー持ちのモンスターを見た時の反応 (モンスター名版)
* @param m_name モンスター名
* @param r_ptr モンスター情報への参照ポインタ
- * @return なし
* @todo m_nameとdescで何が違うのかは良く分からない
*/
-static void see_eldritch_horror(GAME_TEXT *m_name, monster_race *r_ptr)
+static void see_eldritch_horror(concptr m_name, MonsterRaceInfo *r_ptr)
{
concptr horror_message = decide_horror_message(r_ptr);
msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), horror_message, m_name);
* @brief エルドリッチホラー持ちのモンスターを見た時の反応 (モンスター名版)
* @param desc モンスター名 (エルドリッチホラー持ちの全モンスターからランダム…のはず)
* @param r_ptr モンスターへの参照ポインタ
- * @return なし
*/
-static void feel_eldritch_horror(concptr desc, monster_race *r_ptr)
+static void feel_eldritch_horror(concptr desc, MonsterRaceInfo *r_ptr)
{
concptr horror_message = decide_horror_message(r_ptr);
msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), horror_message, desc);
/*!
* @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
- * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ。薬・罠・魔法の影響ならNULL
+ * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ。薬・罠・魔法の影響ならnullptr
* @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
- * @return なし
*/
-void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
+void sanity_blast(PlayerType *player_ptr, MonsterEntity *m_ptr, bool necro)
{
- if (creature_ptr->phase_out || !current_world_ptr->character_dungeon)
+ if (player_ptr->phase_out || !w_ptr->character_dungeon) {
return;
+ }
int power = 100;
if (!necro && m_ptr) {
- GAME_TEXT m_name[MAX_NLEN];
- monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
+ auto *r_ptr = &monraces_info[m_ptr->ap_r_idx];
+ const auto m_name = monster_desc(player_ptr, m_ptr, 0);
power = r_ptr->level / 2;
- monster_desc(creature_ptr, m_name, m_ptr, 0);
- if (!(r_ptr->flags1 & RF1_UNIQUE)) {
- if (r_ptr->flags1 & RF1_FRIENDS)
+ if (r_ptr->kind_flags.has_not(MonsterKindType::UNIQUE)) {
+ if (r_ptr->flags1 & RF1_FRIENDS) {
power /= 2;
- } else
+ }
+ } else {
power *= 2;
+ }
- if (!current_world_ptr->is_loading_now)
+ if (!w_ptr->is_loading_now) {
return;
+ }
- if (!m_ptr->ml)
+ if (!m_ptr->ml) {
return;
+ }
- if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
+ if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR)) {
return;
+ }
- if (is_pet(m_ptr))
+ if (m_ptr->is_pet()) {
return;
+ }
- if (randint1(100) > power)
+ if (randint1(100) > power) {
return;
+ }
- if (saving_throw(creature_ptr->skill_sav - power))
+ if (saving_throw(player_ptr->skill_sav - power)) {
return;
+ }
- if (creature_ptr->image) {
- msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
-
+ if (player_ptr->effects()->hallucination()->is_hallucinated()) {
+ msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), funny_desc[randint0(MAX_SAN_FUNNY)], m_name.data());
if (one_in_(3)) {
msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
- creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
+ BadStatusSetter(player_ptr).mod_hallucination(randint1(r_ptr->level));
}
return;
}
- see_eldritch_horror(m_name, r_ptr);
- switch (player_race_life(creature_ptr)) {
- case PlayerRaceLife::DEMON:
+ see_eldritch_horror(m_name.data(), r_ptr);
+ switch (PlayerRace(player_ptr).life()) {
+ case PlayerRaceLifeType::DEMON:
return;
- case PlayerRaceLife::UNDEAD:
- if (saving_throw(25 + creature_ptr->lev))
+ case PlayerRaceLifeType::UNDEAD:
+ if (saving_throw(25 + player_ptr->lev)) {
return;
+ }
break;
default:
break;
}
} else if (!necro) {
- monster_race *r_ptr;
- GAME_TEXT m_name[MAX_NLEN];
+ MonsterRaceInfo *r_ptr;
+ std::string m_name;
concptr desc;
- get_mon_num_prep(creature_ptr, get_nightmare, NULL);
- r_ptr = &r_info[get_mon_num(creature_ptr, 0, MAX_DEPTH, 0)];
+ get_mon_num_prep(player_ptr, get_nightmare, nullptr);
+ r_ptr = &monraces_info[get_mon_num(player_ptr, 0, MAX_DEPTH, 0)];
power = r_ptr->level + 10;
- desc = r_ptr->name.c_str();
- get_mon_num_prep(creature_ptr, NULL, NULL);
+ desc = r_ptr->name.data();
+ get_mon_num_prep(player_ptr, nullptr, nullptr);
#ifdef JP
#else
- if (!(r_ptr->flags1 & RF1_UNIQUE))
- sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
- else
+ if (r_ptr->kind_flags.has_not(MonsterKindType::UNIQUE)) {
+ m_name = (is_a_vowel(desc[0])) ? "an " : "a ";
+ }
#endif
- sprintf(m_name, "%s", desc);
+ m_name.append(desc);
- if (!(r_ptr->flags1 & RF1_UNIQUE)) {
- if (r_ptr->flags1 & RF1_FRIENDS)
+ if (r_ptr->kind_flags.has_not(MonsterKindType::UNIQUE)) {
+ if (r_ptr->flags1 & RF1_FRIENDS) {
power /= 2;
- } else
+ }
+ } else {
power *= 2;
+ }
- if (saving_throw(creature_ptr->skill_sav * 100 / power)) {
- msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
+ if (saving_throw(player_ptr->skill_sav * 100 / power)) {
+ msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name.data());
return;
}
- if (creature_ptr->image) {
- msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
-
+ if (player_ptr->effects()->hallucination()->is_hallucinated()) {
+ msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), funny_desc[randint0(MAX_SAN_FUNNY)], m_name.data());
if (one_in_(3)) {
msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
- creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
+ BadStatusSetter(player_ptr).mod_hallucination(randint1(r_ptr->level));
}
return;
}
feel_eldritch_horror(desc, r_ptr);
- switch (player_race_life(creature_ptr)) {
- case PlayerRaceLife::DEMON:
- if (saving_throw(20 + creature_ptr->lev))
+ switch (PlayerRace(player_ptr).life()) {
+ case PlayerRaceLifeType::DEMON:
+ if (saving_throw(20 + player_ptr->lev)) {
return;
+ }
break;
- case PlayerRaceLife::UNDEAD:
- if (saving_throw(10 + creature_ptr->lev))
+ case PlayerRaceLifeType::UNDEAD:
+ if (saving_throw(10 + player_ptr->lev)) {
return;
+ }
break;
default:
break;
}
/* 過去の効果無効率再現のため5回saving_throw 実行 */
- if (saving_throw(creature_ptr->skill_sav - power) && saving_throw(creature_ptr->skill_sav - power) && saving_throw(creature_ptr->skill_sav - power)
- && saving_throw(creature_ptr->skill_sav - power) && saving_throw(creature_ptr->skill_sav - power)) {
+ if (saving_throw(player_ptr->skill_sav - power) && saving_throw(player_ptr->skill_sav - power) && saving_throw(player_ptr->skill_sav - power) && saving_throw(player_ptr->skill_sav - power) && saving_throw(player_ptr->skill_sav - power)) {
return;
}
switch (randint1(22)) {
case 1: {
- if (creature_ptr->muta.has_not(MUTA::MORONIC)) {
- if ((creature_ptr->stat_use[A_INT] < 4) && (creature_ptr->stat_use[A_WIS] < 4)) {
+ if (player_ptr->muta.has_not(PlayerMutationType::MORONIC)) {
+ if ((player_ptr->stat_use[A_INT] < 4) && (player_ptr->stat_use[A_WIS] < 4)) {
msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
} else {
msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
}
- if (creature_ptr->muta.has(MUTA::HYPER_INT)) {
+ if (player_ptr->muta.has(PlayerMutationType::HYPER_INT)) {
msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
- creature_ptr->muta.reset(MUTA::HYPER_INT);
+ player_ptr->muta.reset(PlayerMutationType::HYPER_INT);
}
- creature_ptr->muta.set(MUTA::MORONIC);
+ player_ptr->muta.set(PlayerMutationType::MORONIC);
}
break;
}
case 2: {
- if (creature_ptr->muta.has_not(MUTA::COWARDICE) && !has_resist_fear(creature_ptr)) {
+ if (player_ptr->muta.has_not(PlayerMutationType::COWARDICE) && !has_resist_fear(player_ptr)) {
msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
- if (creature_ptr->muta.has(MUTA::FEARLESS)) {
+ if (player_ptr->muta.has(PlayerMutationType::FEARLESS)) {
msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
- creature_ptr->muta.reset(MUTA::FEARLESS);
+ player_ptr->muta.reset(PlayerMutationType::FEARLESS);
}
- creature_ptr->muta.set(MUTA::COWARDICE);
+ player_ptr->muta.set(PlayerMutationType::COWARDICE);
}
break;
}
case 3: {
- if (creature_ptr->muta.has_not(MUTA::HALLU) && !has_resist_chaos(creature_ptr)) {
+ if (player_ptr->muta.has_not(PlayerMutationType::HALLU) && !has_resist_chaos(player_ptr)) {
msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
- creature_ptr->muta.set(MUTA::HALLU);
+ player_ptr->muta.set(PlayerMutationType::HALLU);
}
break;
}
case 4: {
- if (creature_ptr->muta.has_not(MUTA::BERS_RAGE) && !has_resist_conf(creature_ptr)) {
+ if (player_ptr->muta.has_not(PlayerMutationType::BERS_RAGE) && !has_resist_conf(player_ptr)) {
msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
- creature_ptr->muta.set(MUTA::BERS_RAGE);
+ player_ptr->muta.set(PlayerMutationType::BERS_RAGE);
}
break;
case 10:
case 11:
case 12: {
- if (!has_resist_conf(creature_ptr)) {
- (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
+ BadStatusSetter bss(player_ptr);
+ if (!has_resist_conf(player_ptr)) {
+ (void)bss.mod_confusion(randint0(4) + 4);
}
- if (!has_resist_chaos(creature_ptr) && one_in_(3)) {
- (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
+ if (!has_resist_chaos(player_ptr) && one_in_(3)) {
+ (void)bss.mod_hallucination(randint0(250) + 150);
}
/*!< @todo いつからかは不明だがreturnとbreakが同時に存在している。どちらがデッドコードか不明瞭なので保留 */
case 13:
case 14:
case 15: {
- if (!has_resist_conf(creature_ptr)) {
- (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
+ BadStatusSetter bss(player_ptr);
+ if (!has_resist_conf(player_ptr)) {
+ (void)bss.mod_confusion(randint0(4) + 4);
}
- if (!creature_ptr->free_act) {
- (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + randint0(4) + 4);
+ if (!player_ptr->free_act) {
+ (void)bss.mod_paralysis(randint0(4) + 4);
}
- if (!has_resist_chaos(creature_ptr)) {
- (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
+ if (!has_resist_chaos(player_ptr)) {
+ (void)bss.mod_hallucination(randint0(250) + 150);
}
do {
- (void)do_dec_stat(creature_ptr, A_INT);
- } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
+ (void)do_dec_stat(player_ptr, A_INT);
+ } while (randint0(100) > player_ptr->skill_sav && one_in_(2));
do {
- (void)do_dec_stat(creature_ptr, A_WIS);
- } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
+ (void)do_dec_stat(player_ptr, A_WIS);
+ } while (randint0(100) > player_ptr->skill_sav && one_in_(2));
break;
}
case 16:
case 17: {
- if (lose_all_info(creature_ptr))
+ if (lose_all_info(player_ptr)) {
msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
+ }
break;
}
case 18:
case 20:
case 21:
case 22: {
- do_dec_stat(creature_ptr, A_INT);
- do_dec_stat(creature_ptr, A_WIS);
+ do_dec_stat(player_ptr, A_INT);
+ do_dec_stat(player_ptr, A_WIS);
break;
}
default:
break;
}
- creature_ptr->update |= PU_BONUS;
- handle_stuff(creature_ptr);
+ player_ptr->update |= PU_BONUS;
+ handle_stuff(player_ptr);
}