#include "effect/effect-player.h"
#include "core/disturbance.h"
+#include "effect/attribute-types.h"
#include "effect/effect-characteristics.h"
#include "effect/effect-player-switcher.h"
-#include "effect/effect-player-util.h"
+#include "effect/effect-player.h"
#include "effect/effect-processor.h"
#include "effect/spells-effect-util.h"
#include "floor/cave.h"
#include "realm/realm-hex-numbers.h"
#include "spell-realm/spells-crusade.h"
#include "spell-realm/spells-hex.h"
-#include "spell/spell-types.h"
#include "spell/spells-util.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 "target/projection-path-calculator.h"
+#include "timed-effect/player-blindness.h"
+#include "timed-effect/timed-effects.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
#include <string>
/*!
- * @brief effect_player_type構造体を初期化する
+ * @brief EffectPlayerType構造体を初期化する
* @param ep_ptr 初期化前の構造体
* @param who 魔法を唱えたモンスター (0ならプレイヤー自身)
* @param dam 基本威力
- * @param effect_type 効果属性
+ * @param attribute 効果属性
* @param flag 効果フラグ
* @param monspell 効果元のモンスター魔法ID
* @return 初期化後の構造体ポインタ
*/
-static effect_player_type *initialize_effect_player(effect_player_type *ep_ptr, MONSTER_IDX who, HIT_POINT dam, EFFECT_ID effect_type, BIT_FLAGS flag)
+EffectPlayerType::EffectPlayerType(MONSTER_IDX who, int dam, AttributeType attribute, BIT_FLAGS flag)
+ : rlev(0)
+ , m_ptr(nullptr)
+ , killer("")
+ , m_name("")
+ , get_damage(0)
+ , who(who)
+ , dam(dam)
+ , attribute(attribute)
+ , flag(flag)
{
- ep_ptr->rlev = 0;
- ep_ptr->m_ptr = nullptr;
- ep_ptr->get_damage = 0;
- ep_ptr->who = who;
- ep_ptr->dam = dam;
- ep_ptr->effect_type = effect_type;
- ep_ptr->flag = flag;
- return ep_ptr;
}
/*!
* @param ep_ptr プレイヤー効果構造体への参照ポインタ
* @return 当たったらFALSE、反射したらTRUE
*/
-static bool process_bolt_reflection(player_type *player_ptr, effect_player_type *ep_ptr, project_func project)
+static bool process_bolt_reflection(PlayerType *player_ptr, EffectPlayerType *ep_ptr, project_func project)
{
auto can_reflect = (has_reflect(player_ptr) != 0);
can_reflect &= any_bits(ep_ptr->flag, PROJECT_REFLECTABLE);
sound(SOUND_REFLECT);
std::string mes;
- if (player_ptr->blind) {
+ if (player_ptr->effects()->blindness()->is_blind()) {
mes = _("何かが跳ね返った!", "Something bounces!");
- } else if (PlayerClass(player_ptr).kata_is(SamuraiKata::FUUJIN)) {
+ } else if (PlayerClass(player_ptr).samurai_stance_is(SamuraiStanceType::FUUJIN)) {
mes = _("風の如く武器を振るって弾き返した!", "The attack bounces!");
} else {
mes = _("攻撃が跳ね返った!", "The attack bounces!");
}
- msg_print(mes.data());
+ msg_print(mes);
POSITION t_y;
POSITION t_x;
if (ep_ptr->who > 0) {
t_x = player_ptr->x - 1 + randint1(3);
}
- (*project)(player_ptr, 0, 0, t_y, t_x, ep_ptr->dam, ep_ptr->effect_type, (PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE));
+ (*project)(player_ptr, 0, 0, t_y, t_x, ep_ptr->dam, ep_ptr->attribute, (PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE), std::nullopt);
disturb(player_ptr, true, true);
return true;
}
* @param x 目標X座標
* @return 当たらなかったらFALSE、反射したらTRUE、当たったらCONTINUE
*/
-static process_result check_continue_player_effect(player_type *player_ptr, effect_player_type *ep_ptr, POSITION y, POSITION x, project_func project)
+static ProcessResult check_continue_player_effect(PlayerType *player_ptr, EffectPlayerType *ep_ptr, POSITION y, POSITION x, project_func project)
{
if (!player_bold(player_ptr, y, x)) {
- return PROCESS_FALSE;
+ return ProcessResult::PROCESS_FALSE;
}
- auto is_kawarimi = kawarimi(player_ptr, true);
auto is_effective = ep_ptr->dam > 0;
is_effective &= randint0(55) < (player_ptr->lev * 3 / 5 + 20);
is_effective &= ep_ptr->who > 0;
is_effective &= ep_ptr->who != player_ptr->riding;
- if (is_kawarimi && is_effective) {
- return PROCESS_FALSE;
+ if (is_effective && kawarimi(player_ptr, true)) {
+ return ProcessResult::PROCESS_FALSE;
}
if ((ep_ptr->who == 0) || (ep_ptr->who == player_ptr->riding)) {
- return PROCESS_FALSE;
+ return ProcessResult::PROCESS_FALSE;
}
if (process_bolt_reflection(player_ptr, ep_ptr, project)) {
- return PROCESS_TRUE;
+ return ProcessResult::PROCESS_TRUE;
}
- return PROCESS_CONTINUE;
+ return ProcessResult::PROCESS_CONTINUE;
}
/*!
* @param ep_ptr プレイヤー効果構造体への参照ポインタ
* @param who_name モンスター名
*/
-static void describe_effect_source(player_type *player_ptr, effect_player_type *ep_ptr, concptr who_name)
+static void describe_effect_source(PlayerType *player_ptr, EffectPlayerType *ep_ptr, concptr who_name)
{
if (ep_ptr->who > 0) {
ep_ptr->m_ptr = &player_ptr->current_floor_ptr->m_list[ep_ptr->who];
- ep_ptr->rlev = (&r_info[ep_ptr->m_ptr->r_idx])->level >= 1 ? (&r_info[ep_ptr->m_ptr->r_idx])->level : 1;
- monster_desc(player_ptr, ep_ptr->m_name, ep_ptr->m_ptr, 0);
- strcpy(ep_ptr->killer, who_name);
+ ep_ptr->rlev = (&monraces_info[ep_ptr->m_ptr->r_idx])->level >= 1 ? (&monraces_info[ep_ptr->m_ptr->r_idx])->level : 1;
+ angband_strcpy(ep_ptr->m_name, monster_desc(player_ptr, ep_ptr->m_ptr, 0).data(), sizeof(ep_ptr->m_name));
+ angband_strcpy(ep_ptr->killer, who_name, sizeof(ep_ptr->killer));
return;
}
* @param y 目標Y座標 / Target y location (or location to travel "towards")
* @param x 目標X座標 / Target x location (or location to travel "towards")
* @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
- * @param effect_type 効果属性 / Type of damage to apply to monsters (and objects)
+ * @param attribute 効果属性 / Type of damage to apply to monsters (and objects)
* @param flag 効果フラグ
* @param monspell 効果元のモンスター魔法ID
* @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
*/
-bool affect_player(MONSTER_IDX who, player_type *player_ptr, concptr who_name, int r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID effect_type,
+bool affect_player(MONSTER_IDX who, PlayerType *player_ptr, concptr who_name, int r, POSITION y, POSITION x, int dam, AttributeType attribute,
BIT_FLAGS flag, project_func project)
{
- effect_player_type tmp_effect;
- auto *ep_ptr = initialize_effect_player(&tmp_effect, who, dam, effect_type, flag);
+ EffectPlayerType tmp_effect(who, dam, attribute, flag);
+ auto *ep_ptr = &tmp_effect;
auto check_result = check_continue_player_effect(player_ptr, ep_ptr, y, x, project);
- if (check_result != PROCESS_CONTINUE) {
- return check_result == PROCESS_TRUE;
+ if (check_result != ProcessResult::PROCESS_CONTINUE) {
+ return check_result == ProcessResult::PROCESS_TRUE;
}
if (ep_ptr->dam > 1600) {
SpellHex(player_ptr).store_vengeful_damage(ep_ptr->get_damage);
if ((player_ptr->tim_eyeeye || SpellHex(player_ptr).is_spelling_specific(HEX_EYE_FOR_EYE)) && (ep_ptr->get_damage > 0) && !player_ptr->is_dead && (ep_ptr->who > 0)) {
- GAME_TEXT m_name_self[MAX_MONSTER_NAME];
- monster_desc(player_ptr, m_name_self, ep_ptr->m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
- msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), ep_ptr->m_name, m_name_self);
- (*project)(player_ptr, 0, 0, ep_ptr->m_ptr->fy, ep_ptr->m_ptr->fx, ep_ptr->get_damage, GF_MISSILE, PROJECT_KILL);
+ const auto m_name_self = monster_desc(player_ptr, ep_ptr->m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
+ msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), ep_ptr->m_name, m_name_self.data());
+ (*project)(player_ptr, 0, 0, ep_ptr->m_ptr->fy, ep_ptr->m_ptr->fx, ep_ptr->get_damage, AttributeType::MISSILE, PROJECT_KILL, std::nullopt);
if (player_ptr->tim_eyeeye) {
set_tim_eyeeye(player_ptr, player_ptr->tim_eyeeye - 5, true);
}