/*!
* @brief ダンジョンの初期配置モンスターを生成1回生成する / Attempt to allocate a random monster in the dungeon.
- * @param dis プレイヤーから離れるべき最低距離
+ * @param dis プレイヤーから離れるべき最小距離
* @param mode 生成オプション
+ * @param summon_specific 特定モンスター種別を生成するための関数ポインタ
+ * @param max_dis プレイヤーから離れるべき最大距離 (デバッグ用)
* @return 生成に成功したらtrue
- * @details
- * Place the monster at least "dis" distance from the player.
- * Use "slp" to choose the initial "sleep" status
- * Use "floor_ptr->monster_level" for the monster level
*/
-bool alloc_monster(PlayerType *player_ptr, POSITION dis, BIT_FLAGS mode, summon_specific_pf summon_specific)
+bool alloc_monster(PlayerType *player_ptr, int min_dis, BIT_FLAGS mode, summon_specific_pf summon_specific, int max_dis)
{
if (alloc_guardian(player_ptr, false)) {
return true;
}
auto *floor_ptr = player_ptr->current_floor_ptr;
- POSITION y = 0, x = 0;
- int attempts_left = 10000;
+ auto y = 0;
+ auto x = 0;
+ auto attempts_left = 10000;
while (attempts_left--) {
y = randint0(floor_ptr->height);
x = randint0(floor_ptr->width);
}
}
- if (distance(y, x, player_ptr->y, player_ptr->x) > dis) {
+ const auto dist = distance(y, x, player_ptr->y, player_ptr->x);
+ if ((min_dis < dist) && (dist <= max_dis)) {
break;
}
}
bool place_random_monster(PlayerType *player_ptr, POSITION y, POSITION x, BIT_FLAGS mode);
bool alloc_horde(PlayerType *player_ptr, POSITION y, POSITION x, summon_specific_pf summon_specific);
bool alloc_guardian(PlayerType *player_ptr, bool def_val);
-bool alloc_monster(PlayerType *player_ptr, POSITION dis, BIT_FLAGS mode, summon_specific_pf summon_specific);
+bool alloc_monster(PlayerType *player_ptr, int min_dis, BIT_FLAGS mode, summon_specific_pf summon_specific, int max_dis = 65535);
#include "wizard/wizard-special-process.h"
#include "wizard/wizard-spells.h"
#include "wizard/wizard-spoiler.h"
+#include <algorithm>
#include <sstream>
#include <string>
#include <tuple>
std::make_tuple('p', _("ショート・テレポート", "Phase door")),
std::make_tuple('P', _("プレイヤー設定変更メニュー", "Modify player configurations")),
std::make_tuple('r', _("カオスパトロンの報酬", "Get reward of chaos patron")),
- std::make_tuple('s', _("フロア相当のモンスター召喚", "Summon monster which be in target depth")),
+ std::make_tuple('s', _("フロア相当のモンスター生成", "Generate monster which be in target depth")),
+ std::make_tuple('S', _("フロア相当のモンスター召喚", "Summon monster which be in target depth")),
std::make_tuple('t', _("テレポート", "Teleport self")),
std::make_tuple('u', _("啓蒙(忍者以外)", "Wiz-lite all floor except Ninja")),
std::make_tuple('w', _("啓蒙(忍者配慮)", "Wiz-lite all floor")),
patron_list[player_ptr->chaos_patron].gain_level_reward(player_ptr, command_arg);
return true;
case 's':
- if (command_arg <= 0) {
- command_arg = 1;
- }
-
+ command_arg = std::clamp<short>(command_arg, 1, 999);
+ wiz_generate_random_monster(player_ptr, command_arg);
+ return true;
+ case 'S':
+ command_arg = std::clamp<short>(command_arg, 1, 999);
wiz_summon_random_monster(player_ptr, command_arg);
return true;
case 't':
#include "util/enum-converter.h"
#include "util/flag-group.h"
#include "view/display-messages.h"
+#include "wizard/wizard-messages.h"
#include <string_view>
#include <vector>
}
/*!
- * @brief 現在のフロアに合ったモンスターをランダムに召喚する /
- * Summon some creatures
+ * @brief 現在のフロアに合ったモンスターをランダムに生成する
* @param player_ptr プレイヤーへの参照ポインタ
* @param num 生成処理回数
+ * @details 半径5マス以内に生成する。生成場所がなかったらキャンセル。
+ */
+void wiz_generate_random_monster(PlayerType *player_ptr, int num)
+{
+ constexpr auto flags = PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_QUEST;
+ for (auto i = 0; i < num; i++) {
+ if (!alloc_monster(player_ptr, 0, flags, summon_specific, 5)) {
+ msg_print_wizard(player_ptr, 1, "Monster isn't generated correctly...");
+ return;
+ }
+ }
+}
+
+/*!
+ * @brief 現在のフロアに合ったモンスターをランダムに召喚する
+ * @param player_ptr プレイヤーへの参照ポインタ
+ * @param num 生成処理回数
+ * @details 現在のレベル+5F からランダムに選定する。生成場所がなかったらキャンセル。
*/
void wiz_summon_random_monster(PlayerType *player_ptr, int num)
{
- for (int i = 0; i < num; i++) {
- (void)summon_specific(player_ptr, 0, player_ptr->y, player_ptr->x, player_ptr->current_floor_ptr->dun_level, SUMMON_NONE, PM_ALLOW_GROUP | PM_ALLOW_UNIQUE);
+ const auto level = player_ptr->current_floor_ptr->dun_level;
+ constexpr auto flags = PM_ALLOW_GROUP | PM_ALLOW_UNIQUE;
+ const auto y = player_ptr->y;
+ const auto x = player_ptr->x;
+ for (auto i = 0; i < num; i++) {
+ if (!summon_specific(player_ptr, 0, y, x, level, SUMMON_NONE, flags)) {
+ msg_print_wizard(player_ptr, 1, "Monster isn't summoned correctly...");
+ return;
+ }
}
}
void wiz_teleport_back(PlayerType *player_ptr);
void wiz_learn_blue_magic_all(PlayerType *player_ptr);
void wiz_fillup_all_smith_essences(PlayerType *player_ptr);
+void wiz_generate_random_monster(PlayerType *player_ptr, int num);
void wiz_summon_random_monster(PlayerType *player_ptr, int num);
void wiz_summon_specific_monster(PlayerType *player_ptr, MonsterRaceId r_idx);
void wiz_summon_pet(PlayerType *player_ptr, MonsterRaceId r_idx);