2 * @brief 部屋にアイテム・モンスター・罠を配置する処理
7 #include "room/treasure-deployment.h"
8 #include "floor/cave.h"
9 #include "grid/feature-flag-types.h"
10 #include "grid/grid.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"
19 * Routine that fills the empty areas of a room with treasure and monsters.
21 void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty)
23 POSITION cx = (x1 + x2) / 2;
24 POSITION cy = (y1 + y2) / 2;
25 POSITION size = abs(x2 - x1) + abs(y2 - y1);
26 floor_type *floor_ptr = player_ptr->current_floor_ptr;
27 for (POSITION x = x1; x <= x2; x++) {
28 for (POSITION y = y1; y <= y2; y++) {
29 s32b value = ((((s32b)(distance(cx, cy, x, y))) * 100) / size) + randint1(10) - difficulty;
30 if ((randint1(100) - difficulty * 3) > 50)
33 if (!is_floor_bold(floor_ptr, y, x) && (!cave_has_flag_bold(floor_ptr, y, x, FF_PLACE) || !cave_has_flag_bold(floor_ptr, y, x, FF_DROP)))
37 floor_ptr->monster_level = floor_ptr->base_level + 40;
38 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
39 floor_ptr->monster_level = floor_ptr->base_level;
40 floor_ptr->object_level = floor_ptr->base_level + 20;
41 place_object(player_ptr, y, x, AM_GOOD);
42 floor_ptr->object_level = floor_ptr->base_level;
43 } else if (value < 5) {
44 floor_ptr->monster_level = floor_ptr->base_level + 20;
45 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
46 floor_ptr->monster_level = floor_ptr->base_level;
47 floor_ptr->object_level = floor_ptr->base_level + 10;
48 place_object(player_ptr, y, x, AM_GOOD);
49 floor_ptr->object_level = floor_ptr->base_level;
50 } else if (value < 10) {
51 floor_ptr->monster_level = floor_ptr->base_level + 9;
52 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
53 floor_ptr->monster_level = floor_ptr->base_level;
54 } else if (value < 17) {
55 } else if (value < 23) {
56 if (randint0(100) < 25) {
57 place_object(player_ptr, y, x, 0L);
59 place_trap(player_ptr, y, x);
61 } else if (value < 30) {
62 floor_ptr->monster_level = floor_ptr->base_level + 5;
63 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
64 floor_ptr->monster_level = floor_ptr->base_level;
65 place_trap(player_ptr, y, x);
66 } else if (value < 40) {
67 if (randint0(100) < 50) {
68 floor_ptr->monster_level = floor_ptr->base_level + 3;
69 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
70 floor_ptr->monster_level = floor_ptr->base_level;
73 if (randint0(100) < 50) {
74 floor_ptr->object_level = floor_ptr->base_level + 7;
75 place_object(player_ptr, y, x, 0L);
76 floor_ptr->object_level = floor_ptr->base_level;
78 } else if (value < 50) {
79 place_trap(player_ptr, y, x);
81 if (randint0(100) < 20) {
82 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
83 } else if (randint0(100) < 50) {
84 place_trap(player_ptr, y, x);
85 } else if (randint0(100) < 50) {
86 place_object(player_ptr, y, x, 0L);