From: Hourier Date: Tue, 30 Jun 2020 14:38:15 +0000 (+0900) Subject: [Refactor] #40466 Separated base-status.c/h from player-effects.c/h X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=266c646a0b1b68e4bbf2a603f2d617c94d96ff3e;p=hengband%2Fhengband.git [Refactor] #40466 Separated base-status.c/h from player-effects.c/h --- diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index d9aacd1e1..308f24c06 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -230,6 +230,7 @@ + @@ -664,6 +665,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 2a9ef541b..cc22f2e18 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1535,6 +1535,9 @@ mind + + status + @@ -3361,6 +3364,9 @@ mind + + status + diff --git a/src/Makefile.am b/src/Makefile.am index ee3379413..2e4e4f9b7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -557,6 +557,7 @@ hengband_SOURCES = \ spell-realm/spells-trump.c spell-realm/spells-trump.h \ \ status/bad-status-setter.c status/bad-status-setter.h \ + status/base-status.c status/base-status.h \ status/buff-setter.c status/buff-setter.h \ status/element-resistance.c status/element-resistance.h \ status/experience.c status/experience.h \ diff --git a/src/cmd-action/cmd-spell.c b/src/cmd-action/cmd-spell.c index 86f25dfc0..8ef59e905 100644 --- a/src/cmd-action/cmd-spell.c +++ b/src/cmd-action/cmd-spell.c @@ -50,6 +50,7 @@ #include "spell/spells-summon.h" #include "spell/spells-util.h" #include "spell/technic-info-table.h" +#include "status/base-status.h" #include "status/experience.h" #include "term/screen-processor.h" #include "util/buffer-shaper.h" diff --git a/src/cmd-item/cmd-activate.c b/src/cmd-item/cmd-activate.c index b47e066be..9b31f71a6 100644 --- a/src/cmd-item/cmd-activate.c +++ b/src/cmd-item/cmd-activate.c @@ -79,6 +79,7 @@ #include "spell/spells3.h" #include "status/bad-status-setter.h" #include "status/buff-setter.h" +#include "status/base-status.h" #include "status/element-resistance.h" #include "status/experience.h" #include "status/form-changer.h" diff --git a/src/cmd-item/cmd-eat.c b/src/cmd-item/cmd-eat.c index 7a400be95..a4952fe7c 100644 --- a/src/cmd-item/cmd-eat.c +++ b/src/cmd-item/cmd-eat.c @@ -33,6 +33,7 @@ #include "player/special-defense-types.h" #include "spell-realm/spells-hex.h" #include "spell/spells-status.h" +#include "status/base-status.h" #include "status/element-resistance.h" #include "status/experience.h" #include "sv-definition/sv-food-types.h" diff --git a/src/cmd-item/cmd-quaff.c b/src/cmd-item/cmd-quaff.c index 1bc35b326..c7fbecd5c 100644 --- a/src/cmd-item/cmd-quaff.c +++ b/src/cmd-item/cmd-quaff.c @@ -41,6 +41,7 @@ #include "spell/spells-status.h" #include "spell/spells3.h" #include "status/bad-status-setter.h" +#include "status/base-status.h" #include "status/buff-setter.h" #include "status/element-resistance.h" #include "status/experience.h" diff --git a/src/cmd-item/cmd-usestaff.c b/src/cmd-item/cmd-usestaff.c index eb08350a1..53d869b4a 100644 --- a/src/cmd-item/cmd-usestaff.c +++ b/src/cmd-item/cmd-usestaff.c @@ -37,6 +37,7 @@ #include "spell/spells-staff-only.h" #include "spell/spells-status.h" #include "spell/spells-summon.h" +#include "status/base-status.h" #include "status/experience.h" #include "status/form-changer.h" #include "sv-definition/sv-staff-types.h" diff --git a/src/effect/effect-player-resist-hurt.c b/src/effect/effect-player-resist-hurt.c index 35f320763..40034cebe 100644 --- a/src/effect/effect-player-resist-hurt.c +++ b/src/effect/effect-player-resist-hurt.c @@ -14,6 +14,7 @@ #include "spell-kind/spells-teleport.h" #include "spell/spells-status.h" #include "spell/spells3.h" +#include "status/base-status.h" #include "status/element-resistance.h" #include "status/experience.h" #include "system/object-type-definition.h" diff --git a/src/effect/effect-player-spirit.c b/src/effect/effect-player-spirit.c index a5992f592..837be82cc 100644 --- a/src/effect/effect-player-spirit.c +++ b/src/effect/effect-player-spirit.c @@ -3,7 +3,7 @@ #include "mspell/mspells3.h" #include "status/bad-status-setter.h" #include "player/player-damage.h" -#include "player/player-effects.h" +#include "status/base-status.h" #include "view/display-messages.h" #include "world/world.h" diff --git a/src/grid/trap.c b/src/grid/trap.c index 0910b6551..aed171c7b 100644 --- a/src/grid/trap.c +++ b/src/grid/trap.c @@ -22,7 +22,6 @@ #include "status/bad-status-setter.h" #include "player/player-class.h" #include "player/player-damage.h" -#include "player/player-effects.h" #include "player/player-move.h" #include "player/player-personalities-types.h" #include "player/player-status.h" @@ -33,6 +32,7 @@ #include "spell/process-effect.h" #include "spell/spells-summon.h" #include "spell/spell-types.h" +#include "status/base-status.h" #include "status/element-resistance.h" #include "util/bit-flags-calculator.h" #include "view/display-messages.h" diff --git a/src/mind/mind.c b/src/mind/mind.c index 275b51246..e9a66e36a 100644 --- a/src/mind/mind.c +++ b/src/mind/mind.c @@ -64,6 +64,7 @@ #include "spell/spell-types.h" #include "spell/spells3.h" #include "status/bad-status-setter.h" +#include "status/base-status.h" #include "status/buff-setter.h" #include "status/element-resistance.h" #include "status/sight-setter.h" diff --git a/src/monster-attack/monster-attack-status.c b/src/monster-attack/monster-attack-status.c index 3aca4f121..a56ff70e2 100644 --- a/src/monster-attack/monster-attack-status.c +++ b/src/monster-attack/monster-attack-status.c @@ -8,8 +8,8 @@ #include "mind/mind-mirror-master.h" #include "monster-race/monster-race.h" #include "monster-race/race-indice-types.h" -#include "player/player-effects.h" #include "status/bad-status-setter.h" +#include "status/base-status.h" #include "status/experience.h" #include "view/display-messages.h" diff --git a/src/monster-attack/monster-attack-switcher.c b/src/monster-attack/monster-attack-switcher.c index 592694ce6..bdd8b115e 100644 --- a/src/monster-attack/monster-attack-switcher.c +++ b/src/monster-attack/monster-attack-switcher.c @@ -13,10 +13,10 @@ #include "monster/monster-status.h" #include "monster/monster-update.h" #include "player/player-damage.h" -#include "player/player-effects.h" #include "spell-kind/earthquake.h" #include "spell/spells3.h" #include "status/bad-status-setter.h" +#include "status/base-status.h" #include "status/element-resistance.h" #include "status/experience.h" #include "system/object-type-definition.h" diff --git a/src/mspell/mspell-status.c b/src/mspell/mspell-status.c index 33db1acbe..1262e7821 100644 --- a/src/mspell/mspell-status.c +++ b/src/mspell/mspell-status.c @@ -20,6 +20,7 @@ #include "mspell/mspells1.h" #include "mspell/mspells3.h" #include "status/bad-status-setter.h" +#include "status/base-status.h" #include "player/player-effects.h" #include "player/player-move.h" #include "player/player-personalities-types.h" diff --git a/src/mspell/mspells3.c b/src/mspell/mspells3.c index cc459e20c..c648fc9a8 100644 --- a/src/mspell/mspells3.c +++ b/src/mspell/mspells3.c @@ -43,8 +43,6 @@ #include "mspell/mspell-mask-definitions.h" #include "mspell/mspell-type.h" #include "player/avatar.h" -#include "status/bad-status-setter.h" -#include "status/buff-setter.h" #include "player/player-effects.h" #include "player/player-status.h" #include "realm/realm-types.h" @@ -57,6 +55,9 @@ #include "spell/spell-types.h" #include "spell/spells-status.h" #include "spell/spells-summon.h" +#include "status/bad-status-setter.h" +#include "status/base-status.h" +#include "status/buff-setter.h" #include "status/experience.h" #include "term/screen-processor.h" #include "util/int-char-converter.h" diff --git a/src/mutation/mutation-processor.c b/src/mutation/mutation-processor.c index 170d12833..c44648150 100644 --- a/src/mutation/mutation-processor.c +++ b/src/mutation/mutation-processor.c @@ -25,6 +25,7 @@ #include "spell/spells-summon.h" #include "spell/spells3.h" #include "status/bad-status-setter.h" +#include "status/base-status.h" #include "status/buff-setter.h" #include "status/form-changer.h" #include "status/sight-setter.h" diff --git a/src/player/eldritch-horror.c b/src/player/eldritch-horror.c index 65bc88618..3a82e95b0 100644 --- a/src/player/eldritch-horror.c +++ b/src/player/eldritch-horror.c @@ -20,9 +20,9 @@ #include "monster/monster-util.h" #include "monster/smart-learn-types.h" #include "status/bad-status-setter.h" -#include "player/player-effects.h" #include "player/player-status.h" #include "player/mimic-info-table.h" +#include "status/base-status.h" #include "view/display-messages.h" #include "world/world.h" diff --git a/src/player/patron.c b/src/player/patron.c index 8d9e6a253..c51030c49 100644 --- a/src/player/patron.c +++ b/src/player/patron.c @@ -24,6 +24,7 @@ #include "spell/spells-status.h" #include "spell/spells-summon.h" #include "spell/spell-types.h" +#include "status/base-status.h" #include "status/experience.h" #include "view/display-messages.h" diff --git a/src/player/player-damage.c b/src/player/player-damage.c index 1ea302d14..9af541cdd 100644 --- a/src/player/player-damage.c +++ b/src/player/player-damage.c @@ -39,12 +39,12 @@ #include "object/item-tester-hooker.h" #include "player/avatar.h" #include "player/player-class.h" -#include "player/player-effects.h" #include "player/player-move.h" #include "player/player-personalities-types.h" #include "player/player-race-types.h" #include "player/race-info-table.h" #include "player/special-defense-types.h" +#include "status/base-status.h" #include "status/element-resistance.h" #include "term/screen-processor.h" #include "term/term-color-types.h" diff --git a/src/player/player-effects.c b/src/player/player-effects.c index 53aa5f5ac..4c30d7176 100644 --- a/src/player/player-effects.c +++ b/src/player/player-effects.c @@ -69,9 +69,10 @@ #include "spell-realm/spells-song.h" #include "spell/spells-status.h" #include "status/bad-status-setter.h" +#include "status/base-status.h" #include "status/buff-setter.h" #include "status/element-resistance.h" -#include "status/form-changer.h" // todo 相互依存. +#include "status/form-changer.h" #include "status/sight-setter.h" #include "status/temporary-resistance.h" #include "sv-definition/sv-armor-types.h" @@ -464,160 +465,6 @@ bool set_kabenuke(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) return TRUE; } -/*! - * @brief プレイヤーの基本能力値を増加させる / Increases a stat by one randomized level -RAK- - * @param stat 上昇させるステータスID - * @return 実際に上昇した場合TRUEを返す。 - * @details - * Note that this function (used by stat potions) now restores\n - * the stat BEFORE increasing it.\n - */ -bool inc_stat(player_type *creature_ptr, int stat) -{ - BASE_STATUS gain; - BASE_STATUS value = creature_ptr->stat_cur[stat]; - - if (value < creature_ptr->stat_max_max[stat]) { - if (value < 18) { - gain = ((randint0(100) < 75) ? 1 : 2); - value += gain; - } else if (value < (creature_ptr->stat_max_max[stat] - 2)) { - gain = (((creature_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2; - if (gain < 1) - gain = 1; - - value += randint1(gain) + gain / 2; - if (value > (creature_ptr->stat_max_max[stat] - 1)) - value = creature_ptr->stat_max_max[stat] - 1; - } else { - value++; - } - - creature_ptr->stat_cur[stat] = value; - if (value > creature_ptr->stat_max[stat]) { - creature_ptr->stat_max[stat] = value; - } - - creature_ptr->update |= (PU_BONUS); - return TRUE; - } - - return FALSE; -} - -/*! - * @brief プレイヤーの基本能力値を減少させる / Decreases a stat by an amount indended to vary from 0 to 100 percent. - * @param stat 減少させるステータスID - * @param amount 減少させる基本量 - * @param permanent TRUEならば現在の最大値を減少させる - * @return 実際に減少した場合TRUEを返す。 - * @details - *\n - * Amount could be a little higher in extreme cases to mangle very high\n - * stats from massive assaults. -CWS\n - *\n - * Note that "permanent" means that the *given* amount is permanent,\n - * not that the new value becomes permanent. This may not work exactly\n - * as expected, due to "weirdness" in the algorithm, but in general,\n - * if your stat is already drained, the "max" value will not drop all\n - * the way down to the "cur" value.\n - */ -bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent) -{ - int loss; - bool res = FALSE; - - BASE_STATUS cur = creature_ptr->stat_cur[stat]; - BASE_STATUS max = creature_ptr->stat_max[stat]; - int same = (cur == max); - if (cur > 3) { - if (cur <= 18) { - if (amount > 90) - cur--; - if (amount > 50) - cur--; - if (amount > 20) - cur--; - cur--; - } else { - loss = (((cur - 18) / 2 + 1) / 2 + 1); - if (loss < 1) - loss = 1; - - loss = ((randint1(loss) + loss) * amount) / 100; - if (loss < amount / 2) - loss = amount / 2; - - cur = cur - loss; - if (cur < 18) - cur = (amount <= 20) ? 18 : 17; - } - - if (cur < 3) - cur = 3; - - if (cur != creature_ptr->stat_cur[stat]) - res = TRUE; - } - - if (permanent && (max > 3)) { - chg_virtue(creature_ptr, V_SACRIFICE, 1); - if (stat == A_WIS || stat == A_INT) - chg_virtue(creature_ptr, V_ENLIGHTEN, -2); - - if (max <= 18) { - if (amount > 90) - max--; - if (amount > 50) - max--; - if (amount > 20) - max--; - max--; - } else { - loss = (((max - 18) / 2 + 1) / 2 + 1); - loss = ((randint1(loss) + loss) * amount) / 100; - if (loss < amount / 2) - loss = amount / 2; - - max = max - loss; - if (max < 18) - max = (amount <= 20) ? 18 : 17; - } - - if (same || (max < cur)) - max = cur; - - if (max != creature_ptr->stat_max[stat]) - res = TRUE; - } - - if (res) { - creature_ptr->stat_cur[stat] = cur; - creature_ptr->stat_max[stat] = max; - creature_ptr->redraw |= (PR_STATS); - creature_ptr->update |= (PU_BONUS); - } - - return (res); -} - -/*! - * @brief プレイヤーの基本能力値を回復させる / Restore a stat. Return TRUE only if this actually makes a difference. - * @param stat 回復ステータスID - * @return 実際に回復した場合TRUEを返す。 - */ -bool res_stat(player_type *creature_ptr, int stat) -{ - if (creature_ptr->stat_cur[stat] != creature_ptr->stat_max[stat]) { - creature_ptr->stat_cur[stat] = creature_ptr->stat_max[stat]; - creature_ptr->update |= (PU_BONUS); - creature_ptr->redraw |= (PR_STATS); - return TRUE; - } - - return FALSE; -} - /* * Increase players hit points, notice effects */ @@ -661,136 +508,6 @@ bool hp_player(player_type *creature_ptr, int num) return FALSE; } -/* - * Array of stat "descriptions" - */ -static concptr desc_stat_pos[] - = { _("強く", "stronger"), _("知的に", "smarter"), _("賢く", "wiser"), _("器用に", "more dextrous"), _("健康に", "healthier"), _("美しく", "cuter") }; - -/* - * Array of stat "descriptions" - */ -static concptr desc_stat_neg[] - = { _("弱く", "weaker"), _("無知に", "stupider"), _("愚かに", "more naive"), _("不器用に", "clumsier"), _("不健康に", "more sickly"), _("醜く", "uglier") }; - -/* - * Lose a "point" - */ -bool do_dec_stat(player_type *creature_ptr, int stat) -{ - bool sust = FALSE; - - /* Access the "sustain" */ - switch (stat) { - case A_STR: - if (creature_ptr->sustain_str) - sust = TRUE; - break; - case A_INT: - if (creature_ptr->sustain_int) - sust = TRUE; - break; - case A_WIS: - if (creature_ptr->sustain_wis) - sust = TRUE; - break; - case A_DEX: - if (creature_ptr->sustain_dex) - sust = TRUE; - break; - case A_CON: - if (creature_ptr->sustain_con) - sust = TRUE; - break; - case A_CHR: - if (creature_ptr->sustain_chr) - sust = TRUE; - break; - } - - if (sust && (!ironman_nightmare || randint0(13))) { - msg_format(_("%sなった気がしたが、すぐに元に戻った。", "You feel %s for a moment, but the feeling passes."), desc_stat_neg[stat]); - - return TRUE; - } - - if (dec_stat(creature_ptr, stat, 10, (ironman_nightmare && !randint0(13)))) { - msg_format(_("ひどく%sなった気がする。", "You feel %s."), desc_stat_neg[stat]); - - return TRUE; - } - - return FALSE; -} - -/* - * Restore lost "points" in a stat - */ -bool do_res_stat(player_type *creature_ptr, int stat) -{ - if (res_stat(creature_ptr, stat)) { - msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]); - return TRUE; - } - - return FALSE; -} - -/* - * Gain a "point" in a stat - */ -bool do_inc_stat(player_type *creature_ptr, int stat) -{ - bool res = res_stat(creature_ptr, stat); - if (inc_stat(creature_ptr, stat)) { - if (stat == A_WIS) { - chg_virtue(creature_ptr, V_ENLIGHTEN, 1); - chg_virtue(creature_ptr, V_FAITH, 1); - } else if (stat == A_INT) { - chg_virtue(creature_ptr, V_KNOWLEDGE, 1); - chg_virtue(creature_ptr, V_ENLIGHTEN, 1); - } else if (stat == A_CON) - chg_virtue(creature_ptr, V_VITALITY, 1); - - msg_format(_("ワーオ!とても%sなった!", "Wow! You feel %s!"), desc_stat_pos[stat]); - return TRUE; - } - - if (res) { - msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]); - return TRUE; - } - - return FALSE; -} - -/* - * Forget everything - */ -bool lose_all_info(player_type *creature_ptr) -{ - chg_virtue(creature_ptr, V_KNOWLEDGE, -5); - chg_virtue(creature_ptr, V_ENLIGHTEN, -5); - for (int i = 0; i < INVEN_TOTAL; i++) { - object_type *o_ptr = &creature_ptr->inventory_list[i]; - if (!o_ptr->k_idx) - continue; - if (object_is_fully_known(o_ptr)) - continue; - - o_ptr->feeling = FEEL_NONE; - o_ptr->ident &= ~(IDENT_EMPTY); - o_ptr->ident &= ~(IDENT_KNOWN); - o_ptr->ident &= ~(IDENT_SENSE); - } - - creature_ptr->update |= (PU_BONUS); - creature_ptr->update |= (PU_COMBINE | PU_REORDER); - creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER); - wiz_dark(creature_ptr); - return TRUE; -} - void do_poly_wounds(player_type *creature_ptr) { s16b wounds = creature_ptr->cut; diff --git a/src/player/player-effects.h b/src/player/player-effects.h index a090d871f..989f145ba 100644 --- a/src/player/player-effects.h +++ b/src/player/player-effects.h @@ -9,14 +9,7 @@ bool set_invuln(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_tim_regen(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_tim_reflect(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_kabenuke(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -bool inc_stat(player_type *creature_ptr, int stat); -bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent); -bool res_stat(player_type *creature_ptr, int stat); bool hp_player(player_type *creature_ptr, int num); -bool do_dec_stat(player_type *creature_ptr, int stat); -bool do_res_stat(player_type *creature_ptr, int stat); -bool do_inc_stat(player_type *creature_ptr, int stat); -bool lose_all_info(player_type *creature_ptr); void do_poly_self(player_type *creature_ptr); void do_poly_wounds(player_type *creature_ptr); void change_race(player_type *creature_ptr, player_race_type new_race, concptr effect_msg); diff --git a/src/player/player-status.c b/src/player/player-status.c index 5d92495d6..e7bb6401f 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -76,6 +76,7 @@ #include "spell/spells-status.h" #include "spell/spells-util.h" #include "spell/technic-info-table.h" +#include "status/base-status.h" #include "sv-definition/sv-lite-types.h" #include "sv-definition/sv-weapon-types.h" #include "term/screen-processor.h" diff --git a/src/specific-object/chest.c b/src/specific-object/chest.c index 4f6c1be52..17b34ade2 100644 --- a/src/specific-object/chest.c +++ b/src/specific-object/chest.c @@ -12,13 +12,13 @@ #include "perception/object-perception.h" #include "player/player-class.h" #include "player/player-damage.h" -#include "player/player-effects.h" #include "spell-kind/spells-launcher.h" #include "spell-kind/spells-sight.h" #include "spell/spells-summon.h" #include "spell/spell-types.h" #include "spell/spells3.h" #include "status/bad-status-setter.h" +#include "status/base-status.h" #include "status/element-resistance.h" #include "sv-definition/sv-other-types.h" #include "system/object-type-definition.h" diff --git a/src/spell-kind/spells-random.c b/src/spell-kind/spells-random.c index 5582ba298..166be76a4 100644 --- a/src/spell-kind/spells-random.c +++ b/src/spell-kind/spells-random.c @@ -32,6 +32,7 @@ #include "spell/spells-summon.h" #include "spell/spell-types.h" #include "spell/spells3.h" +#include "status/base-status.h" #include "status/experience.h" #include "view/display-messages.h" diff --git a/src/spell-realm/spells-trump.c b/src/spell-realm/spells-trump.c index a00cacf49..fee8b786b 100644 --- a/src/spell-realm/spells-trump.c +++ b/src/spell-realm/spells-trump.c @@ -6,7 +6,6 @@ #include "mutation/mutation.h" #include "player/avatar.h" #include "status/buff-setter.h" -#include "player/player-effects.h" #include "spell-kind/earthquake.h" #include "spell-kind/spells-charm.h" #include "spell-kind/spells-floor.h" @@ -17,6 +16,7 @@ #include "spell-kind/spells-teleport.h" #include "spell/spells-status.h" #include "spell/spells-summon.h" +#include "status/base-status.h" #include "status/experience.h" #include "view/display-messages.h" diff --git a/src/spell/spells-status.c b/src/spell/spells-status.c index e402edd4c..1f4ef86e9 100644 --- a/src/spell/spells-status.c +++ b/src/spell/spells-status.c @@ -29,6 +29,7 @@ #include "spell-kind/spells-launcher.h" #include "spell-kind/spells-teleport.h" #include "spell/spell-types.h" +#include "status/base-status.h" #include "status/experience.h" #include "status/form-changer.h" #include "status/sight-setter.h" diff --git a/src/spell/spells3.c b/src/spell/spells3.c index 10540cbb8..b72e3eaaf 100644 --- a/src/spell/spells3.c +++ b/src/spell/spells3.c @@ -86,7 +86,6 @@ #include "player/digestion-processor.h" #include "player/player-class.h" #include "player/player-damage.h" -#include "player/player-effects.h" #include "player/player-move.h" #include "player/player-personalities-types.h" #include "player/player-skill.h" @@ -103,6 +102,7 @@ #include "spell/spells-summon.h" #include "spell/technic-info-table.h" #include "status/bad-status-setter.h" +#include "status/base-status.h" #include "status/experience.h" #include "term/screen-processor.h" #include "term/term-color-types.h" diff --git a/src/status/bad-status-setter.c b/src/status/bad-status-setter.c index 53fe243ff..72b4f458f 100644 --- a/src/status/bad-status-setter.c +++ b/src/status/bad-status-setter.c @@ -3,12 +3,12 @@ #include "game-option/disturbance-options.h" #include "mind/mind-sniper.h" #include "player/avatar.h" -#include "player/player-effects.h" // todo do_dec_stat()、後で依存を消す. #include "player/player-move.h" #include "player/player-race.h" #include "player/special-defense-types.h" #include "realm/realm-types.h" #include "spell-realm/spells-hex.h" +#include "status/base-status.h" #include "status/form-changer.h" #include "view/display-messages.h" diff --git a/src/status/base-status.c b/src/status/base-status.c new file mode 100644 index 000000000..3b2bb8b6a --- /dev/null +++ b/src/status/base-status.c @@ -0,0 +1,289 @@ +#include "status/base-status.h" +#include "game-option/birth-options.h" +#include "object-enchant/item-feeling.h" +#include "object-enchant/special-object-flags.h" +#include "perception/object-perception.h" +#include "player/avatar.h" +#include "spell-kind/spells-floor.h" +#include "system/object-type-definition.h" +#include "view/display-messages.h" + +/* Array of stat "descriptions" */ +static concptr desc_stat_pos[] + = { _("強く", "stronger"), _("知的に", "smarter"), _("賢く", "wiser"), _("器用に", "more dextrous"), _("健康に", "healthier"), _("美しく", "cuter") }; + +/* Array of stat "descriptions" */ +static concptr desc_stat_neg[] + = { _("弱く", "weaker"), _("無知に", "stupider"), _("愚かに", "more naive"), _("不器用に", "clumsier"), _("不健康に", "more sickly"), _("醜く", "uglier") }; + +/*! + * @brief プレイヤーの基本能力値を増加させる / Increases a stat by one randomized level -RAK- + * @param stat 上昇させるステータスID + * @return 実際に上昇した場合TRUEを返す。 + * @details + * Note that this function (used by stat potions) now restores\n + * the stat BEFORE increasing it.\n + */ +bool inc_stat(player_type *creature_ptr, int stat) +{ + BASE_STATUS gain; + BASE_STATUS value = creature_ptr->stat_cur[stat]; + + if (value < creature_ptr->stat_max_max[stat]) { + if (value < 18) { + gain = ((randint0(100) < 75) ? 1 : 2); + value += gain; + } else if (value < (creature_ptr->stat_max_max[stat] - 2)) { + gain = (((creature_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2; + if (gain < 1) + gain = 1; + + value += randint1(gain) + gain / 2; + if (value > (creature_ptr->stat_max_max[stat] - 1)) + value = creature_ptr->stat_max_max[stat] - 1; + } else { + value++; + } + + creature_ptr->stat_cur[stat] = value; + if (value > creature_ptr->stat_max[stat]) { + creature_ptr->stat_max[stat] = value; + } + + creature_ptr->update |= (PU_BONUS); + return TRUE; + } + + return FALSE; +} + +/*! + * @brief プレイヤーの基本能力値を減少させる / Decreases a stat by an amount indended to vary from 0 to 100 percent. + * @param stat 減少させるステータスID + * @param amount 減少させる基本量 + * @param permanent TRUEならば現在の最大値を減少させる + * @return 実際に減少した場合TRUEを返す。 + * @details + *\n + * Amount could be a little higher in extreme cases to mangle very high\n + * stats from massive assaults. -CWS\n + *\n + * Note that "permanent" means that the *given* amount is permanent,\n + * not that the new value becomes permanent. This may not work exactly\n + * as expected, due to "weirdness" in the algorithm, but in general,\n + * if your stat is already drained, the "max" value will not drop all\n + * the way down to the "cur" value.\n + */ +bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent) +{ + int loss; + bool res = FALSE; + + BASE_STATUS cur = creature_ptr->stat_cur[stat]; + BASE_STATUS max = creature_ptr->stat_max[stat]; + int same = (cur == max); + if (cur > 3) { + if (cur <= 18) { + if (amount > 90) + cur--; + if (amount > 50) + cur--; + if (amount > 20) + cur--; + cur--; + } else { + loss = (((cur - 18) / 2 + 1) / 2 + 1); + if (loss < 1) + loss = 1; + + loss = ((randint1(loss) + loss) * amount) / 100; + if (loss < amount / 2) + loss = amount / 2; + + cur = cur - loss; + if (cur < 18) + cur = (amount <= 20) ? 18 : 17; + } + + if (cur < 3) + cur = 3; + + if (cur != creature_ptr->stat_cur[stat]) + res = TRUE; + } + + if (permanent && (max > 3)) { + chg_virtue(creature_ptr, V_SACRIFICE, 1); + if (stat == A_WIS || stat == A_INT) + chg_virtue(creature_ptr, V_ENLIGHTEN, -2); + + if (max <= 18) { + if (amount > 90) + max--; + if (amount > 50) + max--; + if (amount > 20) + max--; + max--; + } else { + loss = (((max - 18) / 2 + 1) / 2 + 1); + loss = ((randint1(loss) + loss) * amount) / 100; + if (loss < amount / 2) + loss = amount / 2; + + max = max - loss; + if (max < 18) + max = (amount <= 20) ? 18 : 17; + } + + if (same || (max < cur)) + max = cur; + + if (max != creature_ptr->stat_max[stat]) + res = TRUE; + } + + if (res) { + creature_ptr->stat_cur[stat] = cur; + creature_ptr->stat_max[stat] = max; + creature_ptr->redraw |= (PR_STATS); + creature_ptr->update |= (PU_BONUS); + } + + return (res); +} + +/*! + * @brief プレイヤーの基本能力値を回復させる / Restore a stat. Return TRUE only if this actually makes a difference. + * @param stat 回復ステータスID + * @return 実際に回復した場合TRUEを返す。 + */ +bool res_stat(player_type *creature_ptr, int stat) +{ + if (creature_ptr->stat_cur[stat] != creature_ptr->stat_max[stat]) { + creature_ptr->stat_cur[stat] = creature_ptr->stat_max[stat]; + creature_ptr->update |= (PU_BONUS); + creature_ptr->redraw |= (PR_STATS); + return TRUE; + } + + return FALSE; +} + +/* + * Lose a "point" + */ +bool do_dec_stat(player_type *creature_ptr, int stat) +{ + bool sust = FALSE; + + /* Access the "sustain" */ + switch (stat) { + case A_STR: + if (creature_ptr->sustain_str) + sust = TRUE; + break; + case A_INT: + if (creature_ptr->sustain_int) + sust = TRUE; + break; + case A_WIS: + if (creature_ptr->sustain_wis) + sust = TRUE; + break; + case A_DEX: + if (creature_ptr->sustain_dex) + sust = TRUE; + break; + case A_CON: + if (creature_ptr->sustain_con) + sust = TRUE; + break; + case A_CHR: + if (creature_ptr->sustain_chr) + sust = TRUE; + break; + } + + if (sust && (!ironman_nightmare || randint0(13))) { + msg_format(_("%sなった気がしたが、すぐに元に戻った。", "You feel %s for a moment, but the feeling passes."), desc_stat_neg[stat]); + + return TRUE; + } + + if (dec_stat(creature_ptr, stat, 10, (ironman_nightmare && !randint0(13)))) { + msg_format(_("ひどく%sなった気がする。", "You feel %s."), desc_stat_neg[stat]); + + return TRUE; + } + + return FALSE; +} + +/* + * Restore lost "points" in a stat + */ +bool do_res_stat(player_type *creature_ptr, int stat) +{ + if (res_stat(creature_ptr, stat)) { + msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]); + return TRUE; + } + + return FALSE; +} + +/* + * Gain a "point" in a stat + */ +bool do_inc_stat(player_type *creature_ptr, int stat) +{ + bool res = res_stat(creature_ptr, stat); + if (inc_stat(creature_ptr, stat)) { + if (stat == A_WIS) { + chg_virtue(creature_ptr, V_ENLIGHTEN, 1); + chg_virtue(creature_ptr, V_FAITH, 1); + } else if (stat == A_INT) { + chg_virtue(creature_ptr, V_KNOWLEDGE, 1); + chg_virtue(creature_ptr, V_ENLIGHTEN, 1); + } else if (stat == A_CON) + chg_virtue(creature_ptr, V_VITALITY, 1); + + msg_format(_("ワーオ!とても%sなった!", "Wow! You feel %s!"), desc_stat_pos[stat]); + return TRUE; + } + + if (res) { + msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]); + return TRUE; + } + + return FALSE; +} + +/* + * Forget everything + */ +bool lose_all_info(player_type *creature_ptr) +{ + chg_virtue(creature_ptr, V_KNOWLEDGE, -5); + chg_virtue(creature_ptr, V_ENLIGHTEN, -5); + for (int i = 0; i < INVEN_TOTAL; i++) { + object_type *o_ptr = &creature_ptr->inventory_list[i]; + if (!o_ptr->k_idx) + continue; + if (object_is_fully_known(o_ptr)) + continue; + + o_ptr->feeling = FEEL_NONE; + o_ptr->ident &= ~(IDENT_EMPTY); + o_ptr->ident &= ~(IDENT_KNOWN); + o_ptr->ident &= ~(IDENT_SENSE); + } + + creature_ptr->update |= (PU_BONUS); + creature_ptr->update |= (PU_COMBINE | PU_REORDER); + creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER); + wiz_dark(creature_ptr); + return TRUE; +} diff --git a/src/status/base-status.h b/src/status/base-status.h new file mode 100644 index 000000000..38cf65a6c --- /dev/null +++ b/src/status/base-status.h @@ -0,0 +1,11 @@ +#pragma once + +#include "system/angband.h" + +bool inc_stat(player_type *creature_ptr, int stat); +bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent); +bool res_stat(player_type *creature_ptr, int stat); +bool do_dec_stat(player_type *creature_ptr, int stat); +bool do_res_stat(player_type *creature_ptr, int stat); +bool do_inc_stat(player_type *creature_ptr, int stat); +bool lose_all_info(player_type *creature_ptr); diff --git a/src/status/form-changer.c b/src/status/form-changer.c index 983ab4542..bece2d038 100644 --- a/src/status/form-changer.c +++ b/src/status/form-changer.c @@ -3,8 +3,8 @@ #include "game-option/disturbance-options.h" #include "player/avatar.h" #include "player/player-move.h" -#include "player/player-effects.h" // todo 相互依存. #include "player/player-race.h" +#include "status/base-status.h" #include "status/element-resistance.h" #include "view/display-messages.h"