From 6297cdb61fa1080b2422156cc1433ff2539e04a8 Mon Sep 17 00:00:00 2001 From: Hourier Date: Fri, 5 Jun 2020 19:11:47 +0900 Subject: [PATCH] [Refactor] #40414 Moved activate_hi_summon() and cast_invoke_spirits() from spells2.c/h to spells-summon.c/h --- src/spell/spells-summon.c | 203 +++++++++++++++++++++++++++++++++++++++ src/spell/spells-summon.h | 25 ++--- src/spell/spells2.c | 239 ---------------------------------------------- src/spell/spells2.h | 2 - 4 files changed, 216 insertions(+), 253 deletions(-) diff --git a/src/spell/spells-summon.c b/src/spell/spells-summon.c index dbbab42ca..f78dd3fe8 100644 --- a/src/spell/spells-summon.c +++ b/src/spell/spells-summon.c @@ -6,7 +6,17 @@ #include "monster/monster-status.h" #include "object/item-use-flags.h" #include "object/object-hook.h" +#include "player/avatar.h" +#include "player/player-effects.h" +#include "spell/spells-diceroll.h" +#include "spell/spells-floor.h" +#include "spell/spells-genocide.h" +#include "spell/spells-launcher.h" +#include "spell/spells-lite.h" #include "spell/spells-sight.h" +#include "spell/spells2.h" // todo 後で消す. +#include "spell/spells-status.h" +#include "spell/spells-type.h" #include "sv-definition/sv-other-types.h" /*! @@ -318,3 +328,196 @@ void mitokohmon(player_type *kohmon_ptr) stasis_monsters(kohmon_ptr, 120); sukekaku = FALSE; } + +/*! + * todo 引数にPOSITION x/yは必要か? 要調査 + * @brief HI_SUMMON(上級召喚)処理発動 + * @param caster_ptr プレーヤーへの参照ポインタ + * @param y 召喚位置Y座標 + * @param x 召喚位置X座標 + * @param can_pet プレイヤーのペットとなる可能性があるならばTRUEにする + * @return 作用が実際にあった場合TRUEを返す + */ +int activate_hi_summon(player_type *caster_ptr, POSITION y, POSITION x, bool can_pet) +{ + BIT_FLAGS mode = PM_ALLOW_GROUP; + bool pet = FALSE; + if (can_pet) { + if (one_in_(4)) { + mode |= PM_FORCE_FRIENDLY; + } else { + mode |= PM_FORCE_PET; + pet = TRUE; + } + } + + if (!pet) + mode |= PM_NO_PET; + + DEPTH dungeon_level = caster_ptr->current_floor_ptr->dun_level; + DEPTH summon_lev = (pet ? caster_ptr->lev * 2 / 3 + randint1(caster_ptr->lev / 2) : dungeon_level); + int count = 0; + for (int i = 0; i < (randint1(7) + (dungeon_level / 40)); i++) { + switch (randint1(25) + (dungeon_level / 20)) { + case 1: + case 2: + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_ANT, mode); + break; + case 3: + case 4: + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_SPIDER, mode); + break; + case 5: + case 6: + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_HOUND, mode); + break; + case 7: + case 8: + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_HYDRA, mode); + break; + case 9: + case 10: + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_ANGEL, mode); + break; + case 11: + case 12: + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_UNDEAD, mode); + break; + case 13: + case 14: + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_DRAGON, mode); + break; + case 15: + case 16: + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_DEMON, mode); + break; + case 17: + if (can_pet) + break; + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE)); + break; + case 18: + case 19: + if (can_pet) + break; + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE)); + break; + case 20: + case 21: + if (!can_pet) + mode |= PM_ALLOW_UNIQUE; + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_UNDEAD, mode); + break; + case 22: + case 23: + if (!can_pet) + mode |= PM_ALLOW_UNIQUE; + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_DRAGON, mode); + break; + case 24: + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, 100, SUMMON_CYBER, mode); + break; + default: + if (!can_pet) + mode |= PM_ALLOW_UNIQUE; + count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, pet ? summon_lev : (((summon_lev * 3) / 2) + 5), 0, mode); + } + } + + return count; +} + +/*! + * @brief 「悪霊召喚」のランダムな効果を決定して処理する。 + * @param caster_ptr プレーヤーへの参照ポインタ + * @param dir 方向ID + * @return なし + */ +void cast_invoke_spirits(player_type *caster_ptr, DIRECTION dir) +{ + PLAYER_LEVEL plev = caster_ptr->lev; + int die = randint1(100) + plev / 5; + int vir = virtue_number(caster_ptr, V_CHANCE); + + if (vir != 0) { + if (caster_ptr->virtues[vir - 1] > 0) { + while (randint1(400) < caster_ptr->virtues[vir - 1]) + die++; + } else { + while (randint1(400) < (0 - caster_ptr->virtues[vir - 1])) + die--; + } + } + + msg_print(_("あなたは死者たちの力を招集した...", "You call on the power of the dead...")); + if (die < 26) + chg_virtue(caster_ptr, V_CHANCE, 1); + + if (die > 100) { + msg_print(_("あなたはおどろおどろしい力のうねりを感じた!", "You feel a surge of eldritch force!")); + } + + if (die < 8) { + msg_print(_("なんてこった!あなたの周りの地面から朽ちた人影が立ち上がってきた!", "Oh no! Mouldering forms rise from the earth around you!")); + + (void)summon_specific(caster_ptr, 0, caster_ptr->y, caster_ptr->x, caster_ptr->current_floor_ptr->dun_level, SUMMON_UNDEAD, + (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)); + chg_virtue(caster_ptr, V_UNLIFE, 1); + } else if (die < 14) { + msg_print(_("名状し難い邪悪な存在があなたの心を通り過ぎて行った...", "An unnamable evil brushes against your mind...")); + + set_afraid(caster_ptr, caster_ptr->afraid + randint1(4) + 4); + } else if (die < 26) { + msg_print(_("あなたの頭に大量の幽霊たちの騒々しい声が押し寄せてきた...", "Your head is invaded by a horde of gibbering spectral voices...")); + + set_confused(caster_ptr, caster_ptr->confused + randint1(4) + 4); + } else if (die < 31) { + poly_monster(caster_ptr, dir, plev); + } else if (die < 36) { + fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_MISSILE, dir, damroll(3 + ((plev - 1) / 5), 4)); + } else if (die < 41) { + confuse_monster(caster_ptr, dir, plev); + } else if (die < 46) { + fire_ball(caster_ptr, GF_POIS, dir, 20 + (plev / 2), 3); + } else if (die < 51) { + (void)lite_line(caster_ptr, dir, damroll(6, 8)); + } else if (die < 56) { + fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_ELEC, dir, damroll(3 + ((plev - 5) / 4), 8)); + } else if (die < 61) { + fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_COLD, dir, damroll(5 + ((plev - 5) / 4), 8)); + } else if (die < 66) { + fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_ACID, dir, damroll(6 + ((plev - 5) / 4), 8)); + } else if (die < 71) { + fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_FIRE, dir, damroll(8 + ((plev - 5) / 4), 8)); + } else if (die < 76) { + hypodynamic_bolt(caster_ptr, dir, 75); + } else if (die < 81) { + fire_ball(caster_ptr, GF_ELEC, dir, 30 + plev / 2, 2); + } else if (die < 86) { + fire_ball(caster_ptr, GF_ACID, dir, 40 + plev, 2); + } else if (die < 91) { + fire_ball(caster_ptr, GF_ICE, dir, 70 + plev, 3); + } else if (die < 96) { + fire_ball(caster_ptr, GF_FIRE, dir, 80 + plev, 3); + } else if (die < 101) { + hypodynamic_bolt(caster_ptr, dir, 100 + plev); + } else if (die < 104) { + earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, 12, 0); + } else if (die < 106) { + (void)destroy_area(caster_ptr, caster_ptr->y, caster_ptr->x, 13 + randint0(5), FALSE); + } else if (die < 108) { + symbol_genocide(caster_ptr, plev + 50, TRUE); + } else if (die < 110) { + dispel_monsters(caster_ptr, 120); + } else { + dispel_monsters(caster_ptr, 150); + slow_monsters(caster_ptr, plev); + sleep_monsters(caster_ptr, plev); + hp_player(caster_ptr, 300); + } + + if (die < 31) { + msg_print( + _("陰欝な声がクスクス笑う。「もうすぐおまえは我々の仲間になるだろう。弱き者よ。」", "Sepulchral voices chuckle. 'Soon you will join us, mortal.'")); + } +} diff --git a/src/spell/spells-summon.h b/src/spell/spells-summon.h index e0bbc2987..c1e1474ca 100644 --- a/src/spell/spells-summon.h +++ b/src/spell/spells-summon.h @@ -54,15 +54,16 @@ #define SUMMON_ARMAGE_GOOD 66 /*!< 召喚タイプ: ハルマゲドン・トラップ用天使陣営 */ #define SUMMON_ARMAGE_EVIL 67 /*!< 召喚タイプ: ハルマゲドン・トラップ用悪魔陣営 */ -extern bool trump_summoning(player_type *caster_ptr, int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode); -extern bool cast_summon_demon(player_type *creature_ptr, int power); -extern bool cast_summon_undead(player_type *creature_ptr, int power); -extern bool cast_summon_hound(player_type *creature_ptr, int power); -extern bool cast_summon_elemental(player_type *creature_ptr, int power); -extern bool cast_summon_octopus(player_type *creature_ptr); -extern bool item_tester_offer(object_type *o_ptr); -extern bool cast_summon_greater_demon(player_type *caster_ptr); -extern bool summon_kin_player(player_type *creature_ptr, DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode); -extern int summon_cyber(player_type *creature_ptr, MONSTER_IDX who, POSITION y, POSITION x); - -extern void mitokohmon(player_type *kohmon_ptr); +bool trump_summoning(player_type *caster_ptr, int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode); +bool cast_summon_demon(player_type *creature_ptr, int power); +bool cast_summon_undead(player_type *creature_ptr, int power); +bool cast_summon_hound(player_type *creature_ptr, int power); +bool cast_summon_elemental(player_type *creature_ptr, int power); +bool cast_summon_octopus(player_type *creature_ptr); +bool item_tester_offer(object_type *o_ptr); +bool cast_summon_greater_demon(player_type *caster_ptr); +bool summon_kin_player(player_type *creature_ptr, DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode); +void mitokohmon(player_type *kohmon_ptr); +int summon_cyber(player_type *creature_ptr, MONSTER_IDX who, POSITION y, POSITION x); +int activate_hi_summon(player_type *caster_ptr, POSITION y, POSITION x, bool can_pet); +void cast_invoke_spirits(player_type *caster_ptr, DIRECTION dir); diff --git a/src/spell/spells2.c b/src/spell/spells2.c index a43a8be35..db2dbe497 100644 --- a/src/spell/spells2.c +++ b/src/spell/spells2.c @@ -283,94 +283,6 @@ bool activate_ty_curse(player_type *target_ptr, bool stop_ty, int *count) /*! - * todo 引数にPOSITION x/yは必要か? 要調査 - * @brief HI_SUMMON(上級召喚)処理発動 - * @param caster_ptr プレーヤーへの参照ポインタ - * @param y 召喚位置Y座標 - * @param x 召喚位置X座標 - * @param can_pet プレイヤーのペットとなる可能性があるならばTRUEにする - * @return 作用が実際にあった場合TRUEを返す - */ -int activate_hi_summon(player_type *caster_ptr, POSITION y, POSITION x, bool can_pet) -{ - BIT_FLAGS mode = PM_ALLOW_GROUP; - bool pet = FALSE; - if (can_pet) - { - if (one_in_(4)) - { - mode |= PM_FORCE_FRIENDLY; - } - else - { - mode |= PM_FORCE_PET; - pet = TRUE; - } - } - - if (!pet) mode |= PM_NO_PET; - - DEPTH dungeon_level = caster_ptr->current_floor_ptr->dun_level; - DEPTH summon_lev = (pet ? caster_ptr->lev * 2 / 3 + randint1(caster_ptr->lev / 2) : dungeon_level); - int count = 0; - for (int i = 0; i < (randint1(7) + (dungeon_level / 40)); i++) - { - switch (randint1(25) + (dungeon_level / 20)) - { - case 1: case 2: - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_ANT, mode); - break; - case 3: case 4: - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_SPIDER, mode); - break; - case 5: case 6: - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_HOUND, mode); - break; - case 7: case 8: - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_HYDRA, mode); - break; - case 9: case 10: - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_ANGEL, mode); - break; - case 11: case 12: - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_UNDEAD, mode); - break; - case 13: case 14: - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_DRAGON, mode); - break; - case 15: case 16: - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_DEMON, mode); - break; - case 17: - if (can_pet) break; - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE)); - break; - case 18: case 19: - if (can_pet) break; - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE)); - break; - case 20: case 21: - if (!can_pet) mode |= PM_ALLOW_UNIQUE; - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_UNDEAD, mode); - break; - case 22: case 23: - if (!can_pet) mode |= PM_ALLOW_UNIQUE; - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_DRAGON, mode); - break; - case 24: - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, 100, SUMMON_CYBER, mode); - break; - default: - if (!can_pet) mode |= PM_ALLOW_UNIQUE; - count += summon_specific(caster_ptr, (pet ? -1 : 0), y, x, pet ? summon_lev : (((summon_lev * 3) / 2) + 5), 0, mode); - } - } - - return count; -} - - -/*! * @brief 周辺破壊効果(プレイヤー中心) * @param caster_ptr プレーヤーへの参照ポインタ * @return 作用が実際にあった場合TRUEを返す @@ -939,157 +851,6 @@ void cast_wonder(player_type *caster_ptr, DIRECTION dir) /*! -* @brief 「悪霊召喚」のランダムな効果を決定して処理する。 -* @param caster_ptr プレーヤーへの参照ポインタ -* @param dir 方向ID -* @return なし -*/ -void cast_invoke_spirits(player_type *caster_ptr, DIRECTION dir) -{ - PLAYER_LEVEL plev = caster_ptr->lev; - int die = randint1(100) + plev / 5; - int vir = virtue_number(caster_ptr, V_CHANCE); - - if (vir != 0) - { - if (caster_ptr->virtues[vir - 1] > 0) - { - while (randint1(400) < caster_ptr->virtues[vir - 1]) die++; - } - else - { - while (randint1(400) < (0 - caster_ptr->virtues[vir - 1])) die--; - } - } - - msg_print(_("あなたは死者たちの力を招集した...", "You call on the power of the dead...")); - if (die < 26) - chg_virtue(caster_ptr, V_CHANCE, 1); - - if (die > 100) - { - msg_print(_("あなたはおどろおどろしい力のうねりを感じた!", "You feel a surge of eldritch force!")); - } - - if (die < 8) - { - msg_print(_("なんてこった!あなたの周りの地面から朽ちた人影が立ち上がってきた!", - "Oh no! Mouldering forms rise from the earth around you!")); - - (void)summon_specific(caster_ptr, 0, caster_ptr->y, caster_ptr->x, caster_ptr->current_floor_ptr->dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)); - chg_virtue(caster_ptr, V_UNLIFE, 1); - } - else if (die < 14) - { - msg_print(_("名状し難い邪悪な存在があなたの心を通り過ぎて行った...", "An unnamable evil brushes against your mind...")); - - set_afraid(caster_ptr, caster_ptr->afraid + randint1(4) + 4); - } - else if (die < 26) - { - msg_print(_("あなたの頭に大量の幽霊たちの騒々しい声が押し寄せてきた...", - "Your head is invaded by a horde of gibbering spectral voices...")); - - set_confused(caster_ptr, caster_ptr->confused + randint1(4) + 4); - } - else if (die < 31) - { - poly_monster(caster_ptr, dir, plev); - } - else if (die < 36) - { - fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_MISSILE, dir, - damroll(3 + ((plev - 1) / 5), 4)); - } - else if (die < 41) - { - confuse_monster(caster_ptr, dir, plev); - } - else if (die < 46) - { - fire_ball(caster_ptr, GF_POIS, dir, 20 + (plev / 2), 3); - } - else if (die < 51) - { - (void)lite_line(caster_ptr, dir, damroll(6, 8)); - } - else if (die < 56) - { - fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_ELEC, dir, - damroll(3 + ((plev - 5) / 4), 8)); - } - else if (die < 61) - { - fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_COLD, dir, - damroll(5 + ((plev - 5) / 4), 8)); - } - else if (die < 66) - { - fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_ACID, dir, - damroll(6 + ((plev - 5) / 4), 8)); - } - else if (die < 71) - { - fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_FIRE, dir, - damroll(8 + ((plev - 5) / 4), 8)); - } - else if (die < 76) - { - hypodynamic_bolt(caster_ptr, dir, 75); - } - else if (die < 81) - { - fire_ball(caster_ptr, GF_ELEC, dir, 30 + plev / 2, 2); - } - else if (die < 86) - { - fire_ball(caster_ptr, GF_ACID, dir, 40 + plev, 2); - } - else if (die < 91) - { - fire_ball(caster_ptr, GF_ICE, dir, 70 + plev, 3); - } - else if (die < 96) - { - fire_ball(caster_ptr, GF_FIRE, dir, 80 + plev, 3); - } - else if (die < 101) - { - hypodynamic_bolt(caster_ptr, dir, 100 + plev); - } - else if (die < 104) - { - earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, 12, 0); - } - else if (die < 106) - { - (void)destroy_area(caster_ptr, caster_ptr->y, caster_ptr->x, 13 + randint0(5), FALSE); - } - else if (die < 108) - { - symbol_genocide(caster_ptr, plev + 50, TRUE); - } - else if (die < 110) - { - dispel_monsters(caster_ptr, 120); - } - else - { - dispel_monsters(caster_ptr, 150); - slow_monsters(caster_ptr, plev); - sleep_monsters(caster_ptr, plev); - hp_player(caster_ptr, 300); - } - - if (die < 31) - { - msg_print(_("陰欝な声がクスクス笑う。「もうすぐおまえは我々の仲間になるだろう。弱き者よ。」", - "Sepulchral voices chuckle. 'Soon you will join us, mortal.'")); - } -} - - -/*! * @brief トランプ領域の「シャッフル」の効果をランダムに決めて処理する。 * @param caster_ptr プレーヤーへの参照ポインタ * @return なし diff --git a/src/spell/spells2.h b/src/spell/spells2.h index f73148bb2..c5f61ac21 100644 --- a/src/spell/spells2.h +++ b/src/spell/spells2.h @@ -6,7 +6,6 @@ void call_chaos(player_type* caster_ptr); bool hypodynamic_bolt(player_type* caster_ptr, DIRECTION dir, HIT_POINT dam); bool death_ray(player_type* caster_ptr, DIRECTION dir, PLAYER_LEVEL plev); bool activate_ty_curse(player_type* target_ptr, bool stop_ty, int* count); -int activate_hi_summon(player_type* caster_ptr, POSITION y, POSITION x, bool can_pet); void wall_breaker(player_type* caster_ptr); bool charm_monster(player_type* caster_ptr, DIRECTION dir, PLAYER_LEVEL plev); bool control_one_undead(player_type* caster_ptr, DIRECTION dir, PLAYER_LEVEL plev); @@ -18,7 +17,6 @@ void wild_magic(player_type* caster_ptr, int spell); void cast_meteor(player_type* caster_ptr, HIT_POINT dam, POSITION rad); bool cast_wrath_of_the_god(player_type* caster_ptr, HIT_POINT dam, POSITION rad); void cast_wonder(player_type* caster_ptr, DIRECTION dir); -void cast_invoke_spirits(player_type* caster_ptr, DIRECTION dir); void cast_shuffle(player_type* caster_ptr); bool vampirism(player_type* caster_ptr); bool hit_and_away(player_type* caster_ptr); -- 2.11.0