2 * @brief 部屋にアイテム・モンスター・罠を配置する処理
7 #include "room/treasure-deployment.h"
8 #include "floor/cave.h"
9 #include "floor/geometry.h"
10 #include "grid/feature-flag-types.h"
11 #include "grid/object-placer.h"
12 #include "grid/trap.h"
13 #include "monster-floor/monster-generator.h"
14 #include "monster-floor/place-monster-types.h"
15 #include "object-enchant/item-apply-magic.h"
16 #include "system/floor-type-definition.h"
17 #include "system/grid-type-definition.h"
18 #include "system/player-type-definition.h"
21 * Routine that fills the empty areas of a room with treasure and monsters.
23 void fill_treasure(PlayerType *player_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty)
25 POSITION cx = (x1 + x2) / 2;
26 POSITION cy = (y1 + y2) / 2;
27 POSITION size = abs(x2 - x1) + abs(y2 - y1);
28 auto *floor_ptr = player_ptr->current_floor_ptr;
29 for (POSITION x = x1; x <= x2; x++) {
30 for (POSITION y = y1; y <= y2; y++) {
31 int32_t value = ((((int32_t)(distance(cx, cy, x, y))) * 100) / size) + randint1(10) - difficulty;
32 if ((randint1(100) - difficulty * 3) > 50) {
36 if (!floor_ptr->grid_array[y][x].is_floor() && (!cave_has_flag_bold(floor_ptr, y, x, FloorFeatureType::PLACE) || !cave_has_flag_bold(floor_ptr, y, x, FloorFeatureType::DROP))) {
41 floor_ptr->monster_level = floor_ptr->base_level + 40;
42 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
43 floor_ptr->monster_level = floor_ptr->base_level;
44 floor_ptr->object_level = floor_ptr->base_level + 20;
45 place_object(player_ptr, y, x, AM_GOOD);
46 floor_ptr->object_level = floor_ptr->base_level;
47 } else if (value < 5) {
48 floor_ptr->monster_level = floor_ptr->base_level + 20;
49 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
50 floor_ptr->monster_level = floor_ptr->base_level;
51 floor_ptr->object_level = floor_ptr->base_level + 10;
52 place_object(player_ptr, y, x, AM_GOOD);
53 floor_ptr->object_level = floor_ptr->base_level;
54 } else if (value < 10) {
55 floor_ptr->monster_level = floor_ptr->base_level + 9;
56 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
57 floor_ptr->monster_level = floor_ptr->base_level;
58 } else if (value < 17) {
59 } else if (value < 23) {
60 if (randint0(100) < 25) {
61 place_object(player_ptr, y, x, 0L);
63 place_trap(player_ptr, y, x);
65 } else if (value < 30) {
66 floor_ptr->monster_level = floor_ptr->base_level + 5;
67 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
68 floor_ptr->monster_level = floor_ptr->base_level;
69 place_trap(player_ptr, y, x);
70 } else if (value < 40) {
71 if (randint0(100) < 50) {
72 floor_ptr->monster_level = floor_ptr->base_level + 3;
73 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
74 floor_ptr->monster_level = floor_ptr->base_level;
77 if (randint0(100) < 50) {
78 floor_ptr->object_level = floor_ptr->base_level + 7;
79 place_object(player_ptr, y, x, 0L);
80 floor_ptr->object_level = floor_ptr->base_level;
82 } else if (value < 50) {
83 place_trap(player_ptr, y, x);
85 if (randint0(100) < 20) {
86 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
87 } else if (randint0(100) < 50) {
88 place_trap(player_ptr, y, x);
89 } else if (randint0(100) < 50) {
90 place_object(player_ptr, y, x, 0L);