From: Hourier Date: Wed, 20 May 2020 10:31:11 +0000 (+0900) Subject: [Refactor] Moved update_gambling_monsters() from building.c to arena.c X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c6a99f138a0c74c43c2e727137fd9897b8aa56d4;p=hengband%2Fhengband.git [Refactor] Moved update_gambling_monsters() from building.c to arena.c --- diff --git a/src/birth/game-play-initializer.c b/src/birth/game-play-initializer.c index ad896007b..fa038d3ed 100644 --- a/src/birth/game-play-initializer.c +++ b/src/birth/game-play-initializer.c @@ -9,6 +9,7 @@ #include "cmd/cmd-pet.h" #include "system/system-variables.h" #include "player/player-races-table.h" +#include "market/arena.h" /*! * @brief ベースアイテム構造体の鑑定済みフラグをリセットする。 diff --git a/src/dungeon/dungeon-processor.c b/src/dungeon/dungeon-processor.c index c947b242f..7eb150394 100644 --- a/src/dungeon/dungeon-processor.c +++ b/src/dungeon/dungeon-processor.c @@ -17,6 +17,7 @@ #include "monster/monster-status.h" #include "world/world-turn-processor.h" #include "core/turn-compensator.h" +#include "market/arena.h" /*! * process_player()、process_world() をcore.c から移設するのが先. diff --git a/src/io/load.c b/src/io/load.c index 31d83a8db..aa1965b6f 100644 --- a/src/io/load.c +++ b/src/io/load.c @@ -46,7 +46,7 @@ #include "system/angband-version.h" #include "io/load.h" -#include "market/building.h" +#include "market/arena.h" #include "io/report.h" #include "dungeon/dungeon.h" diff --git a/src/market/arena.c b/src/market/arena.c index 86a0d616d..57e3b5447 100644 --- a/src/market/arena.c +++ b/src/market/arena.c @@ -5,6 +5,9 @@ #include "player/player-effects.h" #include "core/stuff-handler.h" #include "core/show-file.h" +#include "monster/monsterrace-hook.h" +#include "world/world.h" +#include "dungeon/dungeon.h" /*! * @brief 優勝時のメッセージを表示し、賞金を与える @@ -140,3 +143,112 @@ void arena_comm(player_type *player_ptr, int cmd) break; } } + +/*! + * @brief モンスター闘技場に参加するモンスターを更新する。 + * @param player_ptr プレーヤーへの参照ポインタ + * @return なし + */ +void update_gambling_monsters(player_type *player_ptr) +{ + int total, i; + int max_dl = 0; + int mon_level; + int power[4]; + bool tekitou; + + for (i = 0; i < current_world_ptr->max_d_idx; i++) { + if (max_dl < max_dlv[i]) + max_dl = max_dlv[i]; + } + + mon_level = randint1(MIN(max_dl, 122)) + 5; + if (randint0(100) < 60) { + i = randint1(MIN(max_dl, 122)) + 5; + mon_level = MAX(i, mon_level); + } + + if (randint0(100) < 30) { + i = randint1(MIN(max_dl, 122)) + 5; + mon_level = MAX(i, mon_level); + } + + while (TRUE) { + total = 0; + tekitou = FALSE; + for (i = 0; i < 4; i++) { + MONRACE_IDX r_idx; + int j; + while (TRUE) { + get_mon_num_prep(player_ptr, monster_can_entry_arena, NULL); + r_idx = get_mon_num(player_ptr, mon_level, GMN_ARENA); + if (!r_idx) + continue; + + if ((r_info[r_idx].flags1 & RF1_UNIQUE) || (r_info[r_idx].flags7 & RF7_UNIQUE2)) { + if ((r_info[r_idx].level + 10) > mon_level) + continue; + } + + for (j = 0; j < i; j++) + if (r_idx == battle_mon[j]) + break; + if (j < i) + continue; + + break; + } + battle_mon[i] = r_idx; + if (r_info[r_idx].level < 45) + tekitou = TRUE; + } + + for (i = 0; i < 4; i++) { + monster_race *r_ptr = &r_info[battle_mon[i]]; + int num_taisei = count_bits(r_ptr->flagsr & (RFR_IM_ACID | RFR_IM_ELEC | RFR_IM_FIRE | RFR_IM_COLD | RFR_IM_POIS)); + + if (r_ptr->flags1 & RF1_FORCE_MAXHP) + power[i] = r_ptr->hdice * r_ptr->hside * 2; + else + power[i] = r_ptr->hdice * (r_ptr->hside + 1); + power[i] = power[i] * (100 + r_ptr->level) / 100; + if (r_ptr->speed > 110) + power[i] = power[i] * (r_ptr->speed * 2 - 110) / 100; + if (r_ptr->speed < 110) + power[i] = power[i] * (r_ptr->speed - 20) / 100; + if (num_taisei > 2) + power[i] = power[i] * (num_taisei * 2 + 5) / 10; + else if (r_ptr->a_ability_flags2 & RF6_INVULNER) + power[i] = power[i] * 4 / 3; + else if (r_ptr->a_ability_flags2 & RF6_HEAL) + power[i] = power[i] * 4 / 3; + else if (r_ptr->a_ability_flags1 & RF5_DRAIN_MANA) + power[i] = power[i] * 11 / 10; + if (r_ptr->flags1 & RF1_RAND_25) + power[i] = power[i] * 9 / 10; + if (r_ptr->flags1 & RF1_RAND_50) + power[i] = power[i] * 9 / 10; + if (r_ptr->flagsr & RFR_RES_ALL) + power[i] *= 100000; + if (r_ptr->arena_ratio) + power[i] = power[i] * r_ptr->arena_ratio / 100; + total += power[i]; + } + + for (i = 0; i < 4; i++) { + if (power[i] <= 0) + break; + power[i] = total * 60 / power[i]; + if (tekitou && ((power[i] < 160) || power[i] > 1500)) + break; + if ((power[i] < 160) && randint0(20)) + break; + if (power[i] < 101) + power[i] = 100 + randint1(5); + mon_odds[i] = power[i]; + } + + if (i == 4) + break; + } +} diff --git a/src/market/arena.h b/src/market/arena.h index a43987125..174582ac2 100644 --- a/src/market/arena.h +++ b/src/market/arena.h @@ -1,3 +1,4 @@ #pragma once void arena_comm(player_type *player_ptr, int cmd); +void update_gambling_monsters(player_type *player_ptr); diff --git a/src/market/building.c b/src/market/building.c index e3b71c039..c853b5ad1 100644 --- a/src/market/building.c +++ b/src/market/building.c @@ -265,117 +265,11 @@ static void show_building(player_type *player_ptr, building_type* bldg) /*! - * @brief モンスター闘技場に参加するモンスターを更新する。 - * @param player_ptr プレーヤーへの参照ポインタ - * @return なし - */ -void update_gambling_monsters(player_type *player_ptr) -{ - int total, i; - int max_dl = 0; - int mon_level; - int power[4]; - bool tekitou; - - for (i = 0; i < current_world_ptr->max_d_idx; i++) - { - if (max_dl < max_dlv[i]) max_dl = max_dlv[i]; - } - - mon_level = randint1(MIN(max_dl, 122)) + 5; - if (randint0(100) < 60) - { - i = randint1(MIN(max_dl, 122)) + 5; - mon_level = MAX(i, mon_level); - } - - if (randint0(100) < 30) - { - i = randint1(MIN(max_dl, 122)) + 5; - mon_level = MAX(i, mon_level); - } - - while (TRUE) - { - total = 0; - tekitou = FALSE; - for (i = 0; i < 4; i++) - { - MONRACE_IDX r_idx; - int j; - while (TRUE) - { - get_mon_num_prep(player_ptr, monster_can_entry_arena, NULL); - r_idx = get_mon_num(player_ptr, mon_level, GMN_ARENA); - if (!r_idx) continue; - - if ((r_info[r_idx].flags1 & RF1_UNIQUE) || (r_info[r_idx].flags7 & RF7_UNIQUE2)) - { - if ((r_info[r_idx].level + 10) > mon_level) continue; - } - - for (j = 0; j < i; j++) - if (r_idx == battle_mon[j]) break; - if (j < i) continue; - - break; - } - battle_mon[i] = r_idx; - if (r_info[r_idx].level < 45) tekitou = TRUE; - } - - for (i = 0; i < 4; i++) - { - monster_race *r_ptr = &r_info[battle_mon[i]]; - int num_taisei = count_bits(r_ptr->flagsr & (RFR_IM_ACID | RFR_IM_ELEC | RFR_IM_FIRE | RFR_IM_COLD | RFR_IM_POIS)); - - if (r_ptr->flags1 & RF1_FORCE_MAXHP) - power[i] = r_ptr->hdice * r_ptr->hside * 2; - else - power[i] = r_ptr->hdice * (r_ptr->hside + 1); - power[i] = power[i] * (100 + r_ptr->level) / 100; - if (r_ptr->speed > 110) - power[i] = power[i] * (r_ptr->speed * 2 - 110) / 100; - if (r_ptr->speed < 110) - power[i] = power[i] * (r_ptr->speed - 20) / 100; - if (num_taisei > 2) - power[i] = power[i] * (num_taisei * 2 + 5) / 10; - else if (r_ptr->a_ability_flags2 & RF6_INVULNER) - power[i] = power[i] * 4 / 3; - else if (r_ptr->a_ability_flags2 & RF6_HEAL) - power[i] = power[i] * 4 / 3; - else if (r_ptr->a_ability_flags1 & RF5_DRAIN_MANA) - power[i] = power[i] * 11 / 10; - if (r_ptr->flags1 & RF1_RAND_25) - power[i] = power[i] * 9 / 10; - if (r_ptr->flags1 & RF1_RAND_50) - power[i] = power[i] * 9 / 10; - if (r_ptr->flagsr & RFR_RES_ALL) power[i] *= 100000; - if (r_ptr->arena_ratio) power[i] = power[i] * r_ptr->arena_ratio / 100; - total += power[i]; - } - - for (i = 0; i < 4; i++) - { - if (power[i] <= 0) break; - power[i] = total * 60 / power[i]; - if (tekitou && ((power[i] < 160) || power[i] > 1500)) break; - if ((power[i] < 160) && randint0(20)) break; - if (power[i] < 101) power[i] = 100 + randint1(5); - mon_odds[i] = power[i]; - } - - if (i == 4) break; - } -} - - -/*! * @brief モンスター闘技場のメインルーチン * @param player_ptr プレーヤーへの参照ポインタ * @return 賭けを開始したか否か */ -static bool kakutoujou(player_type *player_ptr) +static bool monster_arena_comm(player_type *player_ptr) { PRICE maxbet; PRICE wager; @@ -2440,7 +2334,7 @@ static void bldg_process_command(player_type *player_ptr, building_type *bldg, i break; case BACT_BATTLE: - kakutoujou(player_ptr); + monster_arena_comm(player_ptr); break; case BACT_TSUCHINOKO: diff --git a/src/market/building.h b/src/market/building.h index 3558ccba7..7ca327066 100644 --- a/src/market/building.h +++ b/src/market/building.h @@ -116,7 +116,6 @@ typedef struct OBJECT_SUBTYPE_VALUE sval; /*!< モンスター打倒後に得られるアイテムの小カテゴリID / sval of prize */ } arena_type; -extern void update_gambling_monsters(player_type *player_ptr); extern void do_cmd_bldg(player_type *player_ptr); extern void determine_daily_bounty(player_type *player_ptr, bool conv_old); diff --git a/src/wizard/wizard-special-process.c b/src/wizard/wizard-special-process.c index 7acf8de8f..ade400936 100644 --- a/src/wizard/wizard-special-process.c +++ b/src/wizard/wizard-special-process.c @@ -53,7 +53,7 @@ #include "dungeon/dungeon-file.h" #include "io/files-util.h" #include "mspell/monster-spell.h" -#include "market/building.h" +#include "market/arena.h" #include "object/object-kind.h" #include "io/targeting.h" #include "view/display-main-window.h" diff --git a/src/world/world-turn-processor.c b/src/world/world-turn-processor.c index 8e3c2f9cb..a4abfd229 100644 --- a/src/world/world-turn-processor.c +++ b/src/world/world-turn-processor.c @@ -20,6 +20,7 @@ #include "inventory/recharge-processor.h" #include "inventory/simple-appraiser.h" #include "world/world-movement-processor.h" +#include "market/arena.h" /*! * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。