break;
}
case AttributeType::MAKE_TRAP: {
- place_trap(player_ptr, y, x);
+ place_trap(floor_ptr, y, x);
break;
}
case AttributeType::MAKE_TREE: {
if (randint0(100) < 75) {
place_object(player_ptr, *qtwg_ptr->y, *qtwg_ptr->x, 0L);
} else {
- place_trap(player_ptr, *qtwg_ptr->y, *qtwg_ptr->x);
+ place_trap(floor_ptr, *qtwg_ptr->y, *qtwg_ptr->x);
}
floor_ptr->object_level = floor_ptr->base_level;
floor_ptr->object_level = floor_ptr->base_level;
} else if (random & RANDOM_TRAP) {
- place_trap(player_ptr, *qtwg_ptr->y, *qtwg_ptr->x);
+ place_trap(floor_ptr, *qtwg_ptr->y, *qtwg_ptr->x);
} else if (letter[idx].trap) {
g_ptr->mimic = g_ptr->feat;
g_ptr->feat = conv_dungeon_feat(floor_ptr, letter[idx].trap);
floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
break;
case ALLOC_TYP_TRAP:
- place_trap(player_ptr, y, x);
+ place_trap(floor_ptr, y, x);
floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
break;
case ALLOC_TYP_GOLD:
}
/*!
- * @brief 基本トラップをランダムに選択する /
- * Get random trap
+ * @brief 基本トラップをランダムに選択する
+ * @param floor_ptr 現在フロアへの参照ポインタ
* @return 選択したトラップのID
- * @details
- * This routine should be redone to reflect trap "level".\n
- * That is, it does not make sense to have spiked pits at 50 feet.\n
- * Actually, it is not this routine, but the "trap instantiation"\n
- * code, which should also check for "trap doors" on quest levels.\n
- * @todo 引数はFloorType に差し替え可能
+ * @details トラップドアでないならばそのID.
+ * トラップドアは、アリーナ・クエスト・ダンジョンの最下層には設置しない.
*/
-FEAT_IDX choose_random_trap(PlayerType *player_ptr)
+short choose_random_trap(FloorType *floor_ptr)
{
- FEAT_IDX feat;
-
- /* Pick a trap */
const auto &terrains = TerrainList::get_instance();
- const auto &floor = *player_ptr->current_floor_ptr;
while (true) {
- feat = rand_choice(normal_traps);
-
- /* Accept non-trapdoors */
- if (terrains[feat].flags.has_not(TerrainCharacteristics::MORE)) {
- break;
+ const auto terrain_id = rand_choice(normal_traps);
+ if (terrains[terrain_id].flags.has_not(TerrainCharacteristics::MORE)) {
+ return terrain_id;
}
- /* Hack -- no trap doors on special levels */
- if (floor.inside_arena || inside_quest(floor.get_quest_id())) {
+ if (floor_ptr->inside_arena || inside_quest(floor_ptr->get_quest_id())) {
continue;
}
- /* Hack -- no trap doors on the deepest level */
- if (floor.dun_level >= floor.get_dungeon_definition().maxdepth) {
+ if (floor_ptr->dun_level >= floor_ptr->get_dungeon_definition().maxdepth) {
continue;
}
- break;
+ return terrain_id;
}
-
- return feat;
}
/*!
* when they are "discovered" (by detecting them or setting them off),\n
* the trap is "instantiated" as a visible, "typed", trap.\n
*/
-void place_trap(PlayerType *player_ptr, POSITION y, POSITION x)
+void place_trap(FloorType *floor_ptr, POSITION y, POSITION x)
{
- auto *floor_ptr = player_ptr->current_floor_ptr;
auto *g_ptr = &floor_ptr->grid_array[y][x];
/* Paranoia -- verify location */
/* Place an invisible trap */
g_ptr->mimic = g_ptr->feat;
- g_ptr->feat = choose_random_trap(player_ptr);
+ g_ptr->feat = choose_random_trap(floor_ptr);
}
/*!
extern const std::vector<EnumClassFlagGroup<ChestTrapType>> chest_traps;
+class FloorType;
class PlayerType;
void init_normal_traps(void);
-FEAT_IDX choose_random_trap(PlayerType *player_ptr);
+short choose_random_trap(FloorType *floor_ptr);
void disclose_grid(PlayerType *player_ptr, POSITION y, POSITION x);
-void place_trap(PlayerType *player_ptr, POSITION y, POSITION x);
+void place_trap(FloorType *floor_ptr, POSITION y, POSITION x);
void hit_trap(PlayerType *player_ptr, bool break_trap);
} else if (g_ptr->info & CAVE_TRAP) {
g_ptr->info &= ~CAVE_TRAP;
g_ptr->mimic = g_ptr->feat;
- g_ptr->feat = choose_random_trap(player_ptr);
+ g_ptr->feat = choose_random_trap(floor_ptr);
} else if (g_ptr->feat == OLD_FEAT_INVIS) {
g_ptr->mimic = feat_floor;
g_ptr->feat = feat_trap_open;
vault_monsters(player_ptr, yval, xval, randint0(2) + 3);
/* Traps naturally */
- vault_traps(player_ptr, yval, xval, 4, 4, randint0(3) + 2);
+ vault_traps(floor_ptr, yval, xval, 4, 4, randint0(3) + 2);
break;
}
}
/* Traps to protect the treasure */
- vault_traps(player_ptr, yval, xval, 4, 10, 2 + randint1(3));
+ vault_traps(floor_ptr, yval, xval, 4, 10, 2 + randint1(3));
break;
}
vault_monsters(player_ptr, yval, xval + 5, randint1(3));
/* Traps make them entertaining. */
- vault_traps(player_ptr, yval, xval - 3, 2, 8, randint1(3));
- vault_traps(player_ptr, yval, xval + 3, 2, 8, randint1(3));
+ vault_traps(floor_ptr, yval, xval - 3, 2, 8, randint1(3));
+ vault_traps(floor_ptr, yval, xval + 3, 2, 8, randint1(3));
/* Mazes should have some treasure too. */
vault_objects(player_ptr, yval, xval, 3);
vault_monsters(player_ptr, y0, x0, randint0(2) + 3);
/* Traps naturally */
- vault_traps(player_ptr, y0, x0, 4, 4, randint0(3) + 2);
+ vault_traps(floor_ptr, y0, x0, 4, 4, randint0(3) + 2);
}
return true;
if (randint0(100) < 75) {
place_object(player_ptr, y, x, 0L);
} else {
- place_trap(player_ptr, y, x);
+ place_trap(floor_ptr, y, x);
}
break;
/* Trap */
case '^':
- place_trap(player_ptr, y, x);
+ place_trap(floor_ptr, y, x);
break;
/* Black market in a dungeon */
if (randint0(100) < 25) {
place_object(player_ptr, y, x, 0L);
} else {
- place_trap(player_ptr, y, x);
+ place_trap(floor_ptr, y, x);
}
} else if (value < 30) {
floor_ptr->monster_level = floor_ptr->base_level + 5;
place_random_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
floor_ptr->monster_level = floor_ptr->base_level;
- place_trap(player_ptr, y, x);
+ place_trap(floor_ptr, y, x);
} else if (value < 40) {
if (randint0(100) < 50) {
floor_ptr->monster_level = floor_ptr->base_level + 3;
floor_ptr->object_level = floor_ptr->base_level;
}
} else if (value < 50) {
- place_trap(player_ptr, y, x);
+ place_trap(floor_ptr, y, x);
} else {
if (randint0(100) < 20) {
place_random_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
} else if (randint0(100) < 50) {
- place_trap(player_ptr, y, x);
+ place_trap(floor_ptr, y, x);
} else if (randint0(100) < 50) {
place_object(player_ptr, y, x, 0L);
}
* @details
* Only really called by some of the "vault" routines.
*/
-static void vault_trap_aux(PlayerType *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd)
+static void vault_trap_aux(FloorType *floor_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd)
{
grid_type *g_ptr;
- auto *floor_ptr = player_ptr->current_floor_ptr;
int y1 = y, x1 = x;
int dummy = 0;
for (int count = 0; count <= 5; count++) {
continue;
}
- place_trap(player_ptr, y1, x1);
+ place_trap(floor_ptr, y1, x1);
break;
}
}
* Only really called by some of the "vault" routines.
* @todo rooms-normal からしか呼ばれていない、要調整
*/
-void vault_traps(PlayerType *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num)
+void vault_traps(FloorType *floor_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num)
{
for (int i = 0; i < num; i++) {
- vault_trap_aux(player_ptr, y, x, yd, xd);
+ vault_trap_aux(floor_ptr, y, x, yd, xd);
}
}
#include "system/angband.h"
+class FloorType;
class PlayerType;
void vault_monsters(PlayerType *player_ptr, POSITION y1, POSITION x1, int num);
void vault_objects(PlayerType *player_ptr, POSITION y, POSITION x, int num);
-void vault_traps(PlayerType *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num);
+void vault_traps(FloorType *floor_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num);