Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

player_type から時限ステータスを分離した (朦朧のみ) #1548

Merged
merged 15 commits into from Sep 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Hengband/Hengband/Hengband.vcxproj
Expand Up @@ -566,6 +566,8 @@
<ClCompile Include="..\..\src\target\target-getter.cpp" />
<ClCompile Include="..\..\src\target\target-preparation.cpp" />
<ClCompile Include="..\..\src\target\target-setter.cpp" />
<ClCompile Include="..\..\src\timed-effect\player-stun.cpp" />
<ClCompile Include="..\..\src\timed-effect\timed-effects.cpp" />
<ClCompile Include="..\..\src\view\display-inventory.cpp" />
<ClCompile Include="..\..\src\view\display-map.cpp" />
<ClCompile Include="..\..\src\view\display-self-info.cpp" />
Expand Down Expand Up @@ -1291,6 +1293,8 @@
<ClInclude Include="..\..\src\target\target-setter.h" />
<ClInclude Include="..\..\src\target\target-types.h" />
<ClInclude Include="..\..\src\term\screen-processor.h" />
<ClInclude Include="..\..\src\timed-effect\player-stun.h" />
<ClInclude Include="..\..\src\timed-effect\timed-effects.h" />
<ClInclude Include="..\..\src\util\bit-flags-calculator.h" />
<ClInclude Include="..\..\src\util\buffer-shaper.h" />
<ClInclude Include="..\..\src\util\enum-converter.h" />
Expand Down
15 changes: 15 additions & 0 deletions Hengband/Hengband/Hengband.vcxproj.filters
Expand Up @@ -2331,6 +2331,12 @@
<ClCompile Include="..\..\src\object-enchant\smith-info.cpp">
<Filter>object-enchant</Filter>
</ClCompile>
<ClCompile Include="..\..\src\timed-effect\timed-effects.cpp">
<Filter>timed-effect</Filter>
</ClCompile>
<ClCompile Include="..\..\src\timed-effect\player-stun.cpp">
<Filter>timed-effect</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\combat\shoot.h">
Expand Down Expand Up @@ -5016,6 +5022,12 @@
<ClInclude Include="..\..\src\object-enchant\smith-info.h">
<Filter>object-enchant</Filter>
</ClInclude>
<ClInclude Include="..\..\src\timed-effect\timed-effects.h">
<Filter>timed-effect</Filter>
</ClInclude>
<ClInclude Include="..\..\src\timed-effect\player-stun.h">
<Filter>timed-effect</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\wall.bmp" />
Expand Down Expand Up @@ -5235,6 +5247,9 @@
<Filter Include="player-base">
<UniqueIdentifier>{0bd4660d-028e-44be-a5fe-c7cc7d3d00c2}</UniqueIdentifier>
</Filter>
<Filter Include="timed-effect">
<UniqueIdentifier>{b9e618e1-f780-4f5f-9413-d0270ac53660}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\angband.rc" />
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.am
Expand Up @@ -872,6 +872,9 @@ hengband_SOURCES = \
term/z-term.cpp term/z-term.h term/z-util.cpp term/z-util.h \
term/z-virt.cpp term/z-virt.h \
\
timed-effect/player-stun.cpp timed-effect/player-stun.h \
timed-effect/timed-effects.cpp timed-effect/timed-effects.h \
\
util/angband-files.cpp util/angband-files.h \
util/buffer-shaper.cpp util/buffer-shaper.h \
util/bit-flags-calculator.h \
Expand Down
4 changes: 3 additions & 1 deletion src/action/action-limited.cpp
Expand Up @@ -14,6 +14,8 @@
#include "system/floor-type-definition.h"
#include "system/player-type-definition.h"
#include "term/screen-processor.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "view/display-messages.h"

/*!
Expand Down Expand Up @@ -63,7 +65,7 @@ bool cmd_limit_image(player_type *player_ptr)

bool cmd_limit_stun(player_type *player_ptr)
{
if (player_ptr->stun) {
if (player_ptr->effects()->stun()->is_stunned()) {
msg_print(_("頭が朦朧としていて集中できない!", "You are too stunned!"));
return true;
}
Expand Down
18 changes: 14 additions & 4 deletions src/action/movement-execution.cpp
Expand Up @@ -40,6 +40,8 @@
#include "system/monster-type-definition.h"
#include "system/player-type-definition.h"
#include "system/object-type-definition.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
#ifdef JP
Expand Down Expand Up @@ -160,8 +162,10 @@ void exe_movement(player_type *player_ptr, DIRECTION dir, bool do_pickup, bool b
bool do_past = false;
if (g_ptr->m_idx && (m_ptr->ml || p_can_enter || p_can_kill_walls)) {
monster_race *r_ptr = &r_info[m_ptr->r_idx];
auto effects = player_ptr->effects();
auto is_stunned = effects->stun()->is_stunned();
if (!is_hostile(m_ptr)
&& !(player_ptr->confused || player_ptr->image || !m_ptr->ml || player_ptr->stun
&& !(player_ptr->confused || player_ptr->image || !m_ptr->ml || is_stunned
|| (player_ptr->muta.has(MUTA::BERS_RAGE) && is_shero(player_ptr)))
&& pattern_seq(player_ptr, player_ptr->y, player_ptr->x, y, x) && (p_can_enter || p_can_kill_walls)) {
(void)set_monster_csleep(player_ptr, g_ptr->m_idx, 0);
Expand Down Expand Up @@ -271,10 +275,13 @@ void exe_movement(player_type *player_ptr, DIRECTION dir, bool do_pickup, bool b
lite_spot(player_ptr, y, x);
}
} else {
auto effects = player_ptr->effects();
auto is_stunned = effects->stun()->is_stunned();
if (boundary_floor(g_ptr, f_ptr, mimic_f_ptr)) {
msg_print(_("それ以上先には進めない。", "You cannot go any more."));
if (!(player_ptr->confused || player_ptr->stun || player_ptr->image))
if (!(player_ptr->confused || is_stunned || player_ptr->image)) {
energy.reset_player_turn();
}
} else {
if (easy_open && is_closed_door(player_ptr, feat) && easy_open_door(player_ptr, y, x))
return;
Expand All @@ -284,7 +291,7 @@ void exe_movement(player_type *player_ptr, DIRECTION dir, bool do_pickup, bool b
#else
msg_format("There is %s %s blocking your way.", is_a_vowel(name[0]) ? "an" : "a", name);
#endif
if (!(player_ptr->confused || player_ptr->stun || player_ptr->image))
if (!(player_ptr->confused || is_stunned || player_ptr->image))
energy.reset_player_turn();
}
}
Expand All @@ -295,8 +302,11 @@ void exe_movement(player_type *player_ptr, DIRECTION dir, bool do_pickup, bool b
}

if (can_move && !pattern_seq(player_ptr, player_ptr->y, player_ptr->x, y, x)) {
if (!(player_ptr->confused || player_ptr->stun || player_ptr->image))
auto effects = player_ptr->effects();
auto is_stunned = effects->stun()->is_stunned();
if (!(player_ptr->confused || is_stunned || player_ptr->image)) {
energy.reset_player_turn();
}

disturb(player_ptr, false, true);
can_move = false;
Expand Down
12 changes: 8 additions & 4 deletions src/action/racial-execution.cpp
Expand Up @@ -15,6 +15,8 @@
#include "system/object-type-definition.h"
#include "system/player-type-definition.h"
#include "term/screen-processor.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "view/display-messages.h"

/*!
Expand Down Expand Up @@ -48,8 +50,9 @@ PERCENTAGE racial_chance(player_type *player_ptr, rpi_type *rpi_ptr)
if (difficulty == 0)
return 100;

if (player_ptr->stun) {
difficulty += (PERCENTAGE)player_ptr->stun;
auto player_stun = player_ptr->effects()->stun();
if (player_stun->is_stunned()) {
difficulty += player_stun->current();
} else if (player_ptr->lev > rpi_ptr->min_level) {
PERCENTAGE lev_adj = (PERCENTAGE)((player_ptr->lev - rpi_ptr->min_level) / 3);
if (lev_adj > 10)
Expand Down Expand Up @@ -88,8 +91,9 @@ static void adjust_racial_power_difficulty(player_type *player_ptr, rpi_type *rp
if (*difficulty == 0)
return;

if (player_ptr->stun) {
*difficulty += player_ptr->stun;
auto player_stun = player_ptr->effects()->stun();
if (player_stun->is_stunned()) {
*difficulty += player_stun->current();
} else if (player_ptr->lev > rpi_ptr->min_level) {
int lev_adj = ((player_ptr->lev - rpi_ptr->min_level) / 3);
if (lev_adj > 10)
Expand Down
7 changes: 6 additions & 1 deletion src/blue-magic/blue-magic-checker.cpp
Expand Up @@ -20,6 +20,8 @@
#include "status/experience.h"
#include "system/angband.h"
#include "system/player-type-definition.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "view/display-messages.h"

/*!
Expand All @@ -34,7 +36,10 @@ void learn_spell(player_type *player_ptr, int monspell)
return;
if (player_ptr->magic_num2[monspell])
return;
if (player_ptr->confused || player_ptr->blind || player_ptr->image || player_ptr->stun || player_ptr->paralyzed)

auto effects = player_ptr->effects();
auto is_stunned = effects->stun()->is_stunned();
if (player_ptr->confused || player_ptr->blind || player_ptr->image || is_stunned || player_ptr->paralyzed)
return;
if (randint1(player_ptr->lev + 70) > monster_powers[monspell].level + 40) {
player_ptr->magic_num2[monspell] = 1;
Expand Down
12 changes: 6 additions & 6 deletions src/blue-magic/learnt-power-getter.cpp
Expand Up @@ -22,6 +22,8 @@
#include "spell/spell-info.h"
#include "system/player-type-definition.h"
#include "term/screen-processor.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "util/enum-converter.h"
#include "util/flag-group.h"
#include "util/int-char-converter.h"
Expand Down Expand Up @@ -274,13 +276,11 @@ static void calculate_blue_magic_success_probability(player_type *player_ptr, le
if (lm_ptr->chance < minfail)
lm_ptr->chance = minfail;

if (player_ptr->stun > 50)
lm_ptr->chance += 25;
else if (player_ptr->stun)
lm_ptr->chance += 15;

if (lm_ptr->chance > 95)
auto player_stun = player_ptr->effects()->stun();
lm_ptr->chance += player_stun->get_chance_penalty();
if (lm_ptr->chance > 95) {
lm_ptr->chance = 95;
}

lm_ptr->chance = mod_spell_chance_2(player_ptr, lm_ptr->chance);
}
Expand Down
9 changes: 7 additions & 2 deletions src/cmd-action/cmd-attack.cpp
Expand Up @@ -50,6 +50,9 @@
#include "system/monster-type-definition.h"
#include "system/object-type-definition.h"
#include "system/player-type-definition.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
#include "wizard/wizard-messages.h"

Expand Down Expand Up @@ -189,7 +192,9 @@ bool do_cmd_attack(player_type *player_ptr, POSITION y, POSITION x, combat_optio
health_track(player_ptr, g_ptr->m_idx);
}

if ((r_ptr->flags1 & RF1_FEMALE) && !(player_ptr->stun || player_ptr->confused || player_ptr->image || !m_ptr->ml)) {
auto effects = player_ptr->effects();
auto is_stunned = effects->stun()->is_stunned();
if (any_bits(r_ptr->flags1, RF1_FEMALE) && !(is_stunned || player_ptr->confused || player_ptr->image || !m_ptr->ml)) {
if ((player_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ZANTETSU) || (player_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_ZANTETSU)) {
msg_print(_("拙者、おなごは斬れぬ!", "I can not attack women!"));
return false;
Expand All @@ -202,7 +207,7 @@ bool do_cmd_attack(player_type *player_ptr, POSITION y, POSITION x, combat_optio
}

bool stormbringer = false;
if (!is_hostile(m_ptr) && !(player_ptr->stun || player_ptr->confused || player_ptr->image || is_shero(player_ptr) || !m_ptr->ml)) {
if (!is_hostile(m_ptr) && !(is_stunned || player_ptr->confused || player_ptr->image || is_shero(player_ptr) || !m_ptr->ml)) {
if (player_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_STORMBRINGER)
stormbringer = true;
if (player_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_STORMBRINGER)
Expand Down
26 changes: 10 additions & 16 deletions src/cmd-action/cmd-mane.cpp
Expand Up @@ -64,6 +64,8 @@
#include "target/target-setter.h"
#include "target/target-types.h"
#include "term/screen-processor.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "util/enum-converter.h"
#include "util/int-char-converter.h"
#include "view/display-messages.h"
Expand Down Expand Up @@ -212,15 +214,11 @@ static int get_mane_power(player_type *player_ptr, int *sn, bool baigaesi)
if (chance < minfail)
chance = minfail;

/* Stunning makes spells harder */
if (player_ptr->stun > 50)
chance += 25;
else if (player_ptr->stun)
chance += 15;

/* Always a 5 percent chance of working */
if (chance > 95)
auto player_stun = player_ptr->effects()->stun();
chance += player_stun->get_chance_penalty();
if (chance > 95) {
chance = 95;
}

/* Get info */
mane_info(player_ptr, comment, player_ptr->mane_spell[i], (baigaesi ? player_ptr->mane_dam[i] * 2 : player_ptr->mane_dam[i]));
Expand Down Expand Up @@ -1116,15 +1114,11 @@ bool do_cmd_mane(player_type *player_ptr, bool baigaesi)
if (chance < minfail)
chance = minfail;

/* Stunning makes spells harder */
if (player_ptr->stun > 50)
chance += 25;
else if (player_ptr->stun)
chance += 15;

/* Always a 5 percent chance of working */
if (chance > 95)
auto player_stun = player_ptr->effects()->stun();
chance += player_stun->get_chance_penalty();
if (chance > 95) {
chance = 95;
}

/* Failed spell */
if (randint0(100) < chance) {
Expand Down
10 changes: 5 additions & 5 deletions src/cmd-action/cmd-mind.cpp
Expand Up @@ -47,6 +47,8 @@
#include "system/grid-type-definition.h"
#include "system/player-type-definition.h"
#include "term/screen-processor.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "util/buffer-shaper.h"
#include "util/enum-converter.h"
#include "view/display-messages.h"
Expand Down Expand Up @@ -175,10 +177,8 @@ static void decide_mind_chance(player_type *player_ptr, cm_type *cm_ptr)
if (cm_ptr->chance < cm_ptr->minfail)
cm_ptr->chance = cm_ptr->minfail;

if (player_ptr->stun > 50)
cm_ptr->chance += 25;
else if (player_ptr->stun)
cm_ptr->chance += 15;
auto player_stun = player_ptr->effects()->stun();
cm_ptr->chance += player_stun->get_chance_penalty();

if (cm_ptr->use_mind != mind_kind_type::KI)
return;
Expand Down Expand Up @@ -217,7 +217,7 @@ static void check_mind_mindcrafter(player_type *player_ptr, cm_type *cm_ptr)
}

if (cm_ptr->b < 90) {
set_stun(player_ptr, player_ptr->stun + randint1(8));
set_stun(player_ptr, player_ptr->effects()->stun()->current() + randint1(8));
return;
}

Expand Down
6 changes: 5 additions & 1 deletion src/cmd-action/cmd-move.cpp
Expand Up @@ -36,6 +36,8 @@
#include "system/grid-type-definition.h"
#include "system/player-type-definition.h"
#include "target/target-getter.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"

Expand Down Expand Up @@ -429,8 +431,10 @@ void do_cmd_rest(player_type *player_ptr)
if (command_arg > 100)
chg_virtue(player_ptr, V_DILIGENCE, -1);

auto effects = player_ptr->effects();
auto is_stunned = effects->stun()->is_stunned();
if ((player_ptr->chp == player_ptr->mhp) && (player_ptr->csp == player_ptr->msp) && !player_ptr->blind && !player_ptr->confused
&& !player_ptr->poisoned && !player_ptr->afraid && !player_ptr->stun && !player_ptr->cut && !player_ptr->slow && !player_ptr->paralyzed
&& !player_ptr->poisoned && !player_ptr->afraid && !is_stunned && !player_ptr->cut && !player_ptr->slow && !player_ptr->paralyzed
&& !player_ptr->image && !player_ptr->word_recall && !player_ptr->alter_reality)
chg_virtue(player_ptr, V_DILIGENCE, -1);

Expand Down
5 changes: 4 additions & 1 deletion src/cmd-action/cmd-shoot.cpp
Expand Up @@ -14,6 +14,8 @@
#include "system/object-type-definition.h"
#include "system/player-type-definition.h"
#include "term/screen-processor.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "view/display-messages.h"

/*!
Expand Down Expand Up @@ -67,9 +69,10 @@ void do_cmd_fire(player_type *player_ptr, SPELL_IDX snipe_type)
if (snipe_type == SP_AWAY)
teleport_player(player_ptr, 10 + (player_ptr->concent * 2), TELEPORT_SPONTANEOUS);

auto effects = player_ptr->effects();
if (snipe_type == SP_FINAL) {
msg_print(_("射撃の反動が体を襲った。", "The weapon's recoil stuns you. "));
(void)set_slow(player_ptr, player_ptr->slow + randint0(7) + 7, false);
(void)set_stun(player_ptr, player_ptr->stun + randint1(25));
(void)set_stun(player_ptr, effects->stun()->current() + randint1(25));
}
}
5 changes: 4 additions & 1 deletion src/cmd-building/cmd-inn.cpp
Expand Up @@ -12,6 +12,8 @@
#include "status/bad-status-setter.h"
#include "store/rumor.h"
#include "system/player-type-definition.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
#include "view/display-messages.h"
#include "world/world.h"

Expand Down Expand Up @@ -117,9 +119,10 @@ static bool has_a_nightmare(player_type *player_ptr)
*/
static void back_to_health(player_type *player_ptr)
{
auto effects = player_ptr->effects();
set_blind(player_ptr, 0);
set_confused(player_ptr, 0);
player_ptr->stun = 0;
effects->stun()->reset();
player_ptr->chp = player_ptr->mhp;
player_ptr->csp = player_ptr->msp;
}
Expand Down