OSDN Git Service

[Refactor] #39963 Separated several effect_player_*() functions from switch_effects_p...
authorHourier <hourier@users.sourceforge.jp>
Sun, 3 May 2020 07:02:10 +0000 (16:02 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 3 May 2020 07:02:10 +0000 (16:02 +0900)
src/effect/effect-player-switcher.c

index 133db3d..1617727 100644 (file)
@@ -78,7 +78,7 @@ void effect_player_missile(player_type *target_ptr, effect_player_type *ep_ptr)
 }
 
 
-void effect_player_holy_file(player_type *target_ptr, effect_player_type *ep_ptr)
+void effect_player_holy_fire(player_type *target_ptr, effect_player_type *ep_ptr)
 {
        if (target_ptr->blind) msg_print(_("\89½\82©\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by something!"));
 
@@ -161,6 +161,116 @@ void effect_player_nether(player_type *target_ptr, effect_player_type *ep_ptr)
 }
 
 
+void effect_player_water(player_type *target_ptr, effect_player_type *ep_ptr)
+{
+       if (target_ptr->blind) msg_print(_("\89½\82©\8e¼\82Á\82½\82à\82Ì\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by something wet!"));
+       if (CHECK_MULTISHADOW(target_ptr))
+       {
+               ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
+               return;
+       }
+
+       if (!target_ptr->resist_sound && !target_ptr->resist_water)
+       {
+               set_stun(target_ptr, target_ptr->stun + randint1(40));
+       }
+       if (!target_ptr->resist_conf && !target_ptr->resist_water)
+       {
+               set_confused(target_ptr, target_ptr->confused + randint1(5) + 5);
+       }
+
+       if (one_in_(5) && !target_ptr->resist_water)
+       {
+               inventory_damage(target_ptr, set_cold_destroy, 3);
+       }
+
+       if (target_ptr->resist_water) ep_ptr->get_damage /= 4;
+
+       ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
+}
+
+
+void effect_player_chaos(player_type *target_ptr, effect_player_type *ep_ptr)
+{
+       if (target_ptr->blind) msg_print(_("\96³\92\81\8f\98\82Ì\94g\93®\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by a wave of anarchy!"));
+       if (target_ptr->resist_chaos)
+       {
+               ep_ptr->dam *= 6; ep_ptr->dam /= (randint1(4) + 7);
+       }
+
+       if (CHECK_MULTISHADOW(target_ptr))
+       {
+               ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
+               return;
+       }
+
+       if (!target_ptr->resist_conf)
+       {
+               (void)set_confused(target_ptr, target_ptr->confused + randint0(20) + 10);
+       }
+       if (!target_ptr->resist_chaos)
+       {
+               (void)set_image(target_ptr, target_ptr->image + randint1(10));
+               if (one_in_(3))
+               {
+                       msg_print(_("\82 \82È\82½\82Ì\90g\91Ì\82Í\83J\83I\83X\82Ì\97Í\82Å\94P\82\8bÈ\82°\82ç\82ê\82½\81I", "Your body is twisted by chaos!"));
+                       (void)gain_mutation(target_ptr, 0);
+               }
+       }
+       if (!target_ptr->resist_neth && !target_ptr->resist_chaos)
+       {
+               drain_exp(target_ptr, 5000 + (target_ptr->exp / 100), 500 + (target_ptr->exp / 1000), 75);
+       }
+
+       if (!target_ptr->resist_chaos || one_in_(9))
+       {
+               inventory_damage(target_ptr, set_elec_destroy, 2);
+               inventory_damage(target_ptr, set_fire_destroy, 2);
+       }
+
+       ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
+}
+
+
+void effect_player_shards(player_type *target_ptr, effect_player_type *ep_ptr)
+{
+       if (target_ptr->blind) msg_print(_("\89½\82©\89s\82¢\82à\82Ì\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by something sharp!"));
+       if (target_ptr->resist_shard)
+       {
+               ep_ptr->dam *= 6; ep_ptr->dam /= (randint1(4) + 7);
+       }
+       else if (!CHECK_MULTISHADOW(target_ptr))
+       {
+               (void)set_cut(target_ptr, target_ptr->cut + ep_ptr->dam);
+       }
+
+       if (!target_ptr->resist_shard || one_in_(13))
+               inventory_damage(target_ptr, set_cold_destroy, 2);
+
+       ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
+}
+
+
+void effect_player_sound(player_type *target_ptr, effect_player_type *ep_ptr)
+{
+       if (target_ptr->blind) msg_print(_("\8d\8c\89¹\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by a loud noise!"));
+       if (target_ptr->resist_sound)
+       {
+               ep_ptr->dam *= 5; ep_ptr->dam /= (randint1(4) + 7);
+       }
+       else if (!CHECK_MULTISHADOW(target_ptr))
+       {
+               int plus_stun = (randint1((ep_ptr->dam > 90) ? 35 : (ep_ptr->dam / 3 + 5)));
+               (void)set_stun(target_ptr, target_ptr->stun + plus_stun);
+       }
+
+       if (!target_ptr->resist_sound || one_in_(13))
+               inventory_damage(target_ptr, set_cold_destroy, 2);
+
+       ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
+}
+
+
 /*!
  * @brief \96\82\96@\82Ì\8cø\89Ê\82É\82æ\82Á\82Ä\97l\81X\82È\83\81\83b\83Z\81[\82ð\8fo\97Í\82µ\82½\82è\97^\82¦\82é\83_\83\81\81[\83W\82Ì\91\9d\8c¸\82ð\8ds\82Á\82½\82è\82·\82é
  * @param target_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
@@ -193,126 +303,32 @@ void switch_effects_player(player_type *target_ptr, effect_player_type *ep_ptr)
                effect_player_missile(target_ptr, ep_ptr);
                return;
        case GF_HOLY_FIRE:
-               effect_player_holy_file(target_ptr, ep_ptr);
+               effect_player_holy_fire(target_ptr, ep_ptr);
                return;
        case GF_HELL_FIRE:
-               effect_plyaer_hell_fire(target_ptr, ep_ptr);
+               effect_player_hell_fire(target_ptr, ep_ptr);
+               return;
        case GF_ARROW:
                effect_player_arrow(target_ptr, ep_ptr);
+               return;
        case GF_PLASMA:
                effect_player_plasma(target_ptr, ep_ptr);
+               return;
        case GF_NETHER:
                effect_player_nether(target_ptr, ep_ptr);
+               return;
        case GF_WATER:
-       {
-               if (target_ptr->blind) msg_print(_("\89½\82©\8e¼\82Á\82½\82à\82Ì\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by something wet!"));
-               if (CHECK_MULTISHADOW(target_ptr))
-               {
-                       ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
-                       break;
-               }
-
-               if (!target_ptr->resist_sound && !target_ptr->resist_water)
-               {
-                       set_stun(target_ptr, target_ptr->stun + randint1(40));
-               }
-               if (!target_ptr->resist_conf && !target_ptr->resist_water)
-               {
-                       set_confused(target_ptr, target_ptr->confused + randint1(5) + 5);
-               }
-
-               if (one_in_(5) && !target_ptr->resist_water)
-               {
-                       inventory_damage(target_ptr, set_cold_destroy, 3);
-               }
-
-               if (target_ptr->resist_water) ep_ptr->get_damage /= 4;
-
-               ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
-               break;
-       }
+               effect_player_water(target_ptr, ep_ptr);
+               return;
        case GF_CHAOS:
-       {
-               if (target_ptr->blind) msg_print(_("\96³\92\81\8f\98\82Ì\94g\93®\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by a wave of anarchy!"));
-               if (target_ptr->resist_chaos)
-               {
-                       ep_ptr->dam *= 6; ep_ptr->dam /= (randint1(4) + 7);
-               }
-
-               if (CHECK_MULTISHADOW(target_ptr))
-               {
-                       ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
-                       break;
-               }
-
-               if (!target_ptr->resist_conf)
-               {
-                       (void)set_confused(target_ptr, target_ptr->confused + randint0(20) + 10);
-               }
-               if (!target_ptr->resist_chaos)
-               {
-                       (void)set_image(target_ptr, target_ptr->image + randint1(10));
-                       if (one_in_(3))
-                       {
-                               msg_print(_("\82 \82È\82½\82Ì\90g\91Ì\82Í\83J\83I\83X\82Ì\97Í\82Å\94P\82\8bÈ\82°\82ç\82ê\82½\81I", "Your body is twisted by chaos!"));
-                               (void)gain_mutation(target_ptr, 0);
-                       }
-               }
-               if (!target_ptr->resist_neth && !target_ptr->resist_chaos)
-               {
-                       drain_exp(target_ptr, 5000 + (target_ptr->exp / 100), 500 + (target_ptr->exp / 1000), 75);
-               }
-
-               if (!target_ptr->resist_chaos || one_in_(9))
-               {
-                       inventory_damage(target_ptr, set_elec_destroy, 2);
-                       inventory_damage(target_ptr, set_fire_destroy, 2);
-               }
-
-               ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
-               break;
-       }
+               effect_player_chaos(target_ptr, ep_ptr);
+               return;
        case GF_SHARDS:
-       {
-               if (target_ptr->blind) msg_print(_("\89½\82©\89s\82¢\82à\82Ì\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by something sharp!"));
-               if (target_ptr->resist_shard)
-               {
-                       ep_ptr->dam *= 6; ep_ptr->dam /= (randint1(4) + 7);
-               }
-               else if (!CHECK_MULTISHADOW(target_ptr))
-               {
-                       (void)set_cut(target_ptr, target_ptr->cut + ep_ptr->dam);
-               }
-
-               if (!target_ptr->resist_shard || one_in_(13))
-               {
-                       inventory_damage(target_ptr, set_cold_destroy, 2);
-               }
-
-               ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
-               break;
-       }
+               effect_player_shards(target_ptr, ep_ptr);
+               return;
        case GF_SOUND:
-       {
-               if (target_ptr->blind) msg_print(_("\8d\8c\89¹\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by a loud noise!"));
-               if (target_ptr->resist_sound)
-               {
-                       ep_ptr->dam *= 5; ep_ptr->dam /= (randint1(4) + 7);
-               }
-               else if (!CHECK_MULTISHADOW(target_ptr))
-               {
-                       int plus_stun = (randint1((ep_ptr->dam > 90) ? 35 : (ep_ptr->dam / 3 + 5)));
-                       (void)set_stun(target_ptr, target_ptr->stun + plus_stun);
-               }
-
-               if (!target_ptr->resist_sound || one_in_(13))
-               {
-                       inventory_damage(target_ptr, set_cold_destroy, 2);
-               }
-
-               ep_ptr->get_damage = take_hit(target_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer, ep_ptr->monspell);
-               break;
-       }
+               effect_player_sound(target_ptr, ep_ptr);
+               return;
        case GF_CONFUSION:
        {
                if (target_ptr->blind) msg_print(_("\89½\82©\8d¬\97\90\82·\82é\82à\82Ì\82Å\8dU\8c\82\82³\82ê\82½\81I", "You are hit by something puzzling!"));