OSDN Git Service

[Refactor] #40466 Separated shape-changer.c/h from player-effects.c/h
authorHourier <hourier@users.sourceforge.jp>
Wed, 1 Jul 2020 13:09:26 +0000 (22:09 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 1 Jul 2020 13:09:26 +0000 (22:09 +0900)
13 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-item/cmd-item.c
src/effect/effect-player-resist-hurt.c
src/mutation/mutation-processor.c
src/mutation/mutation.c
src/player/patron.c
src/player/player-effects.c
src/player/player-effects.h
src/realm/realm-chaos.c
src/status/shape-changer.c [new file with mode: 0644]
src/status/shape-changer.h [new file with mode: 0644]

index 989a40c..85d38f3 100644 (file)
     <ClCompile Include="..\..\src\spell\spell-info.c" />\r
     <ClCompile Include="..\..\src\status\element-resistance.c" />\r
     <ClCompile Include="..\..\src\status\form-changer.c" />\r
+    <ClCompile Include="..\..\src\status\shape-changer.c" />\r
     <ClCompile Include="..\..\src\status\sight-setter.c" />\r
     <ClCompile Include="..\..\src\status\experience.c" />\r
     <ClCompile Include="..\..\src\status\temporary-resistance.c" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-chaos.h" />\r
     <ClInclude Include="..\..\src\spell\spell-info.h" />\r
     <ClInclude Include="..\..\src\status\element-resistance.h" />\r
+    <ClInclude Include="..\..\src\status\shape-changer.h" />\r
     <ClInclude Include="..\..\src\status\sight-setter.h" />\r
     <ClInclude Include="..\..\src\status\form-changer.h" />\r
     <ClInclude Include="..\..\src\status\experience.h" />\r
index 0bd0e17..0cb5434 100644 (file)
     <ClCompile Include="..\..\src\mspell\mspell-dispel.c">
       <Filter>mspell</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\status\shape-changer.c">
+      <Filter>status</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\mspell\mspell-dispel.h">
       <Filter>mspell</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\status\shape-changer.h">
+      <Filter>status</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index c14c080..a3f1e7d 100644 (file)
@@ -564,6 +564,7 @@ hengband_SOURCES = \
        status/element-resistance.c status/element-resistance.h \
        status/experience.c status/experience.h \
        status/form-changer.c status/form-changer.h \
+       status/shape-changer.c status/shape-changer.h \
        status/sight-setter.c status/sight-setter.h \
        status/temporary-resistance.c status/temporary-resistance.h \
        \
index 09ce932..9db8db9 100644 (file)
@@ -72,6 +72,7 @@
 #include "realm/realm-types.h"
 #include "spell-kind/spells-perception.h"
 #include "status/experience.h"
+#include "status/shape-changer.h"
 #include "sv-definition/sv-lite-types.h"
 #include "term/screen-processor.h"
 #include "util/int-char-converter.h"
index bceb9b7..98a589d 100644 (file)
@@ -8,7 +8,6 @@
 #include "mutation/mutation.h"
 #include "object/object-broken.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
 #include "player/player-race-types.h"
 #include "player/player-race.h"
 #include "spell-kind/spells-teleport.h"
@@ -18,6 +17,7 @@
 #include "status/base-status.h"
 #include "status/element-resistance.h"
 #include "status/experience.h"
+#include "status/shape-changer.h"
 #include "system/object-type-definition.h"
 #include "view/display-messages.h"
 #include "world/world.h"
index 21f9ab6..02aad11 100644 (file)
@@ -13,7 +13,6 @@
 #include "object/lite-processor.h"
 #include "player/digestion-processor.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
 #include "player/player-move.h"
 #include "realm/realm-types.h"
 #include "spell-kind/spells-floor.h"
@@ -30,6 +29,7 @@
 #include "status/body-improvement.h"
 #include "status/buff-setter.h"
 #include "status/form-changer.h"
+#include "status/shape-changer.h"
 #include "status/sight-setter.h"
 #include "store/store-owners.h"
 #include "store/store-util.h"
index b468ca0..72cf76c 100644 (file)
@@ -42,7 +42,6 @@
 #include "player/avatar.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
 #include "player/player-personalities-types.h"
 #include "player/player-race-types.h"
 #include "player/selfinfo.h"
@@ -59,6 +58,7 @@
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
 #include "status/element-resistance.h"
+#include "status/shape-changer.h"
 #include "system/object-type-definition.h"
 #include "view/display-messages.h"
 
index c51030c..a13c8aa 100644 (file)
@@ -12,7 +12,6 @@
 #include "object/object-kind-hook.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
 #include "player/player-race-types.h"
 #include "player/player-status.h"
 #include "spell-kind/spells-floor.h"
@@ -26,6 +25,7 @@
 #include "spell/spell-types.h"
 #include "status/base-status.h"
 #include "status/experience.h"
+#include "status/shape-changer.h"
 #include "view/display-messages.h"
 
 #ifdef JP
index 5efdb6f..c42a9c5 100644 (file)
@@ -175,175 +175,3 @@ void set_action(player_type *creature_ptr, ACTION_IDX typ)
     creature_ptr->update |= (PU_BONUS);
     creature_ptr->redraw |= (PR_STATE);
 }
-
-void do_poly_wounds(player_type *creature_ptr)
-{
-    s16b wounds = creature_ptr->cut;
-    s16b hit_p = (creature_ptr->mhp - creature_ptr->chp);
-    s16b change = damroll(creature_ptr->lev, 5);
-    bool Nasty_effect = one_in_(5);
-    if (!(wounds || hit_p || Nasty_effect))
-        return;
-
-    msg_print(_("傷がより軽いものに変化した。", "Your wounds are polymorphed into less serious ones."));
-    hp_player(creature_ptr, change);
-    if (Nasty_effect) {
-        msg_print(_("新たな傷ができた!", "A new wound was created!"));
-        take_hit(creature_ptr, DAMAGE_LOSELIFE, change / 2, _("変化した傷", "a polymorphed wound"), -1);
-        set_cut(creature_ptr, change);
-    } else {
-        set_cut(creature_ptr, creature_ptr->cut - (change / 2));
-    }
-}
-
-/*
- * Change player race
- */
-void change_race(player_type *creature_ptr, player_race_type new_race, concptr effect_msg)
-{
-    concptr title = race_info[new_race].title;
-    int old_race = creature_ptr->prace;
-#ifdef JP
-    msg_format("あなたは%s%sに変化した!", effect_msg, title);
-#else
-    msg_format("You turn into %s %s%s!", (!effect_msg[0] && is_a_vowel(title[0]) ? "an" : "a"), effect_msg, title);
-#endif
-
-    chg_virtue(creature_ptr, V_CHANCE, 2);
-    if (creature_ptr->prace < 32) {
-        creature_ptr->old_race1 |= 1L << creature_ptr->prace;
-    } else {
-        creature_ptr->old_race2 |= 1L << (creature_ptr->prace - 32);
-    }
-
-    creature_ptr->prace = new_race;
-    rp_ptr = &race_info[creature_ptr->prace];
-    creature_ptr->expfact = rp_ptr->r_exp + cp_ptr->c_exp;
-
-    bool is_special_class = creature_ptr->pclass == CLASS_MONK;
-    is_special_class |= creature_ptr->pclass == CLASS_FORCETRAINER;
-    is_special_class |= creature_ptr->pclass == CLASS_NINJA;
-    bool is_special_race = creature_ptr->prace == RACE_KLACKON;
-    is_special_race |= creature_ptr->prace == RACE_SPRITE;
-    if (is_special_class && is_special_race)
-        creature_ptr->expfact -= 15;
-
-    get_height_weight(creature_ptr);
-
-    if (creature_ptr->pclass == CLASS_SORCERER)
-        creature_ptr->hitdie = rp_ptr->r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
-    else
-        creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-
-    roll_hitdice(creature_ptr, 0L);
-    check_experience(creature_ptr);
-    creature_ptr->redraw |= (PR_BASIC);
-    creature_ptr->update |= (PU_BONUS);
-    handle_stuff(creature_ptr);
-
-    if (old_race != creature_ptr->prace)
-        autopick_load_pref(creature_ptr, FALSE);
-
-    lite_spot(creature_ptr, creature_ptr->y, creature_ptr->x);
-}
-
-void do_poly_self(player_type *creature_ptr)
-{
-    int power = creature_ptr->lev;
-
-    msg_print(_("あなたは変化の訪れを感じた...", "You feel a change coming over you..."));
-    chg_virtue(creature_ptr, V_CHANCE, 1);
-
-    if ((power > randint0(20)) && one_in_(3) && (creature_ptr->prace != RACE_ANDROID)) {
-        char effect_msg[80] = "";
-        player_race_type new_race;
-
-        power -= 10;
-        if ((power > randint0(5)) && one_in_(4)) {
-            power -= 2;
-            if (creature_ptr->psex == SEX_MALE) {
-                creature_ptr->psex = SEX_FEMALE;
-                sp_ptr = &sex_info[creature_ptr->psex];
-                sprintf(effect_msg, _("女性の", "female "));
-            } else {
-                creature_ptr->psex = SEX_MALE;
-                sp_ptr = &sex_info[creature_ptr->psex];
-                sprintf(effect_msg, _("男性の", "male "));
-            }
-        }
-
-        if ((power > randint0(30)) && one_in_(5)) {
-            int tmp = 0;
-            power -= 15;
-            while (tmp < A_MAX) {
-                if (one_in_(2)) {
-                    (void)dec_stat(creature_ptr, tmp, randint1(6) + 6, one_in_(3));
-                    power -= 1;
-                }
-                tmp++;
-            }
-
-            (void)dec_stat(creature_ptr, A_CHR, randint1(6), TRUE);
-
-            if (effect_msg[0]) {
-                char tmp_msg[10];
-                sprintf(tmp_msg, _("%s", "%s "), effect_msg);
-                sprintf(effect_msg, _("奇形の%s", "deformed %s "), tmp_msg);
-            } else {
-                sprintf(effect_msg, _("奇形の", "deformed "));
-            }
-        }
-
-        while ((power > randint0(20)) && one_in_(10)) {
-            power -= 10;
-
-            if (!lose_mutation(creature_ptr, 0))
-                msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
-        }
-
-        do {
-            new_race = (player_race_type)randint0(MAX_RACES);
-        } while ((new_race == creature_ptr->prace) || (new_race == RACE_ANDROID));
-
-        change_race(creature_ptr, new_race, effect_msg);
-    }
-
-    if ((power > randint0(30)) && one_in_(6)) {
-        int tmp = 0;
-        power -= 20;
-        msg_format(_("%sの構成が変化した!", "Your internal organs are rearranged!"), creature_ptr->prace == RACE_ANDROID ? "機械" : "内臓");
-
-        while (tmp < A_MAX) {
-            (void)dec_stat(creature_ptr, tmp, randint1(6) + 6, one_in_(3));
-            tmp++;
-        }
-        if (one_in_(6)) {
-            msg_print(_("現在の姿で生きていくのは困難なようだ!", "You find living difficult in your present form!"));
-            take_hit(creature_ptr, DAMAGE_LOSELIFE, damroll(randint1(10), creature_ptr->lev), _("致命的な突然変異", "a lethal mutation"), -1);
-
-            power -= 10;
-        }
-    }
-
-    if ((power > randint0(20)) && one_in_(4)) {
-        power -= 10;
-
-        get_max_stats(creature_ptr);
-        roll_hitdice(creature_ptr, 0L);
-    }
-
-    while ((power > randint0(15)) && one_in_(3)) {
-        power -= 7;
-        (void)gain_mutation(creature_ptr, 0);
-    }
-
-    if (power > randint0(5)) {
-        power -= 5;
-        do_poly_wounds(creature_ptr);
-    }
-
-    while (power > 0) {
-        status_shuffle(creature_ptr);
-        power--;
-    }
-}
index 1b947fe..67a36ca 100644 (file)
@@ -3,6 +3,3 @@
 #include "system/angband.h"
 
 void set_action(player_type *creature_ptr, ACTION_IDX typ);
-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);
index 1ab9af6..87b33d5 100644 (file)
@@ -4,7 +4,6 @@
 #include "effect/effect-characteristics.h"
 #include "io/targeting.h"
 #include "player/player-class.h"
-#include "player/player-effects.h"
 #include "spell/process-effect.h"
 #include "spell/spells-diceroll.h"
 #include "spell-kind/spells-random.h"
@@ -19,6 +18,7 @@
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
+#include "status/shape-changer.h"
 #include "view/display-messages.h"
 
 /*!
diff --git a/src/status/shape-changer.c b/src/status/shape-changer.c
new file mode 100644 (file)
index 0000000..8d9d67f
--- /dev/null
@@ -0,0 +1,190 @@
+#include "status/shape-changer.h"
+#include "autopick/autopick-reader-writer.h"
+#include "birth/birth-body-spec.h"
+#include "birth/birth-stat.h"
+#include "core/hp-mp-processor.h"
+#include "core/stuff-handler.h"
+#include "grid/grid.h"
+#include "mutation/mutation.h"
+#include "player/avatar.h"
+#include "player/player-class.h"
+#include "player/player-damage.h"
+#include "player/player-personality.h"
+#include "player/player-sex.h"
+#include "player/race-info-table.h"
+#include "spell/spells-status.h"
+#include "status/bad-status-setter.h"
+#include "status/base-status.h"
+#include "view/display-messages.h"
+
+void do_poly_wounds(player_type *creature_ptr)
+{
+    s16b wounds = creature_ptr->cut;
+    s16b hit_p = (creature_ptr->mhp - creature_ptr->chp);
+    s16b change = damroll(creature_ptr->lev, 5);
+    bool Nasty_effect = one_in_(5);
+    if (!(wounds || hit_p || Nasty_effect))
+        return;
+
+    msg_print(_("傷がより軽いものに変化した。", "Your wounds are polymorphed into less serious ones."));
+    hp_player(creature_ptr, change);
+    if (Nasty_effect) {
+        msg_print(_("新たな傷ができた!", "A new wound was created!"));
+        take_hit(creature_ptr, DAMAGE_LOSELIFE, change / 2, _("変化した傷", "a polymorphed wound"), -1);
+        set_cut(creature_ptr, change);
+    } else {
+        set_cut(creature_ptr, creature_ptr->cut - (change / 2));
+    }
+}
+
+/*
+ * Change player race
+ */
+void change_race(player_type *creature_ptr, player_race_type new_race, concptr effect_msg)
+{
+    concptr title = race_info[new_race].title;
+    int old_race = creature_ptr->prace;
+#ifdef JP
+    msg_format("あなたは%s%sに変化した!", effect_msg, title);
+#else
+    msg_format("You turn into %s %s%s!", (!effect_msg[0] && is_a_vowel(title[0]) ? "an" : "a"), effect_msg, title);
+#endif
+
+    chg_virtue(creature_ptr, V_CHANCE, 2);
+    if (creature_ptr->prace < 32) {
+        creature_ptr->old_race1 |= 1L << creature_ptr->prace;
+    } else {
+        creature_ptr->old_race2 |= 1L << (creature_ptr->prace - 32);
+    }
+
+    creature_ptr->prace = new_race;
+    rp_ptr = &race_info[creature_ptr->prace];
+    creature_ptr->expfact = rp_ptr->r_exp + cp_ptr->c_exp;
+
+    bool is_special_class = creature_ptr->pclass == CLASS_MONK;
+    is_special_class |= creature_ptr->pclass == CLASS_FORCETRAINER;
+    is_special_class |= creature_ptr->pclass == CLASS_NINJA;
+    bool is_special_race = creature_ptr->prace == RACE_KLACKON;
+    is_special_race |= creature_ptr->prace == RACE_SPRITE;
+    if (is_special_class && is_special_race)
+        creature_ptr->expfact -= 15;
+
+    get_height_weight(creature_ptr);
+
+    if (creature_ptr->pclass == CLASS_SORCERER)
+        creature_ptr->hitdie = rp_ptr->r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
+    else
+        creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
+
+    roll_hitdice(creature_ptr, 0L);
+    check_experience(creature_ptr);
+    creature_ptr->redraw |= (PR_BASIC);
+    creature_ptr->update |= (PU_BONUS);
+    handle_stuff(creature_ptr);
+
+    if (old_race != creature_ptr->prace)
+        autopick_load_pref(creature_ptr, FALSE);
+
+    lite_spot(creature_ptr, creature_ptr->y, creature_ptr->x);
+}
+
+void do_poly_self(player_type *creature_ptr)
+{
+    int power = creature_ptr->lev;
+
+    msg_print(_("あなたは変化の訪れを感じた...", "You feel a change coming over you..."));
+    chg_virtue(creature_ptr, V_CHANCE, 1);
+
+    if ((power > randint0(20)) && one_in_(3) && (creature_ptr->prace != RACE_ANDROID)) {
+        char effect_msg[80] = "";
+        player_race_type new_race;
+
+        power -= 10;
+        if ((power > randint0(5)) && one_in_(4)) {
+            power -= 2;
+            if (creature_ptr->psex == SEX_MALE) {
+                creature_ptr->psex = SEX_FEMALE;
+                sp_ptr = &sex_info[creature_ptr->psex];
+                sprintf(effect_msg, _("女性の", "female "));
+            } else {
+                creature_ptr->psex = SEX_MALE;
+                sp_ptr = &sex_info[creature_ptr->psex];
+                sprintf(effect_msg, _("男性の", "male "));
+            }
+        }
+
+        if ((power > randint0(30)) && one_in_(5)) {
+            int tmp = 0;
+            power -= 15;
+            while (tmp < A_MAX) {
+                if (one_in_(2)) {
+                    (void)dec_stat(creature_ptr, tmp, randint1(6) + 6, one_in_(3));
+                    power -= 1;
+                }
+                tmp++;
+            }
+
+            (void)dec_stat(creature_ptr, A_CHR, randint1(6), TRUE);
+
+            if (effect_msg[0]) {
+                char tmp_msg[10];
+                sprintf(tmp_msg, _("%s", "%s "), effect_msg);
+                sprintf(effect_msg, _("奇形の%s", "deformed %s "), tmp_msg);
+            } else {
+                sprintf(effect_msg, _("奇形の", "deformed "));
+            }
+        }
+
+        while ((power > randint0(20)) && one_in_(10)) {
+            power -= 10;
+
+            if (!lose_mutation(creature_ptr, 0))
+                msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
+        }
+
+        do {
+            new_race = (player_race_type)randint0(MAX_RACES);
+        } while ((new_race == creature_ptr->prace) || (new_race == RACE_ANDROID));
+
+        change_race(creature_ptr, new_race, effect_msg);
+    }
+
+    if ((power > randint0(30)) && one_in_(6)) {
+        int tmp = 0;
+        power -= 20;
+        msg_format(_("%sの構成が変化した!", "Your internal organs are rearranged!"), creature_ptr->prace == RACE_ANDROID ? "機械" : "内臓");
+
+        while (tmp < A_MAX) {
+            (void)dec_stat(creature_ptr, tmp, randint1(6) + 6, one_in_(3));
+            tmp++;
+        }
+        if (one_in_(6)) {
+            msg_print(_("現在の姿で生きていくのは困難なようだ!", "You find living difficult in your present form!"));
+            take_hit(creature_ptr, DAMAGE_LOSELIFE, damroll(randint1(10), creature_ptr->lev), _("致命的な突然変異", "a lethal mutation"), -1);
+
+            power -= 10;
+        }
+    }
+
+    if ((power > randint0(20)) && one_in_(4)) {
+        power -= 10;
+
+        get_max_stats(creature_ptr);
+        roll_hitdice(creature_ptr, 0L);
+    }
+
+    while ((power > randint0(15)) && one_in_(3)) {
+        power -= 7;
+        (void)gain_mutation(creature_ptr, 0);
+    }
+
+    if (power > randint0(5)) {
+        power -= 5;
+        do_poly_wounds(creature_ptr);
+    }
+
+    while (power > 0) {
+        status_shuffle(creature_ptr);
+        power--;
+    }
+}
diff --git a/src/status/shape-changer.h b/src/status/shape-changer.h
new file mode 100644 (file)
index 0000000..46e49fb
--- /dev/null
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "system/angband.h"
+
+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);