#include "spell-kind/spells-random.h"
#include "spell-kind/spells-sight.h"
#include "spell-kind/spells-teleport.h"
-#include "spell/spell-types.h"
+#include "effect/attribute-types.h"
#include "spell/summon-types.h"
#include "status/bad-status-setter.h"
#include "status/base-status.h"
#include "target/projection-path-calculator.h"
#include "timed-effect/player-cut.h"
#include "timed-effect/timed-effects.h"
-#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
#include "world/world.h"
-static int16_t normal_traps[MAX_NORMAL_TRAPS];
+static std::vector<int16_t> normal_traps;
/*!
* @brief 箱のトラップテーブル
* Note that disarming a trap on a chest also removes the lock.
* </pre>
*/
-const int chest_traps[64] = {
- 0, /* 0 == empty */
- (CHEST_POISON),
- (CHEST_LOSE_STR),
- (CHEST_LOSE_CON),
- (CHEST_LOSE_STR),
- (CHEST_LOSE_CON), /* 5 == best small wooden */
- 0,
- (CHEST_ALARM),
- (CHEST_ALARM),
- (CHEST_LOSE_STR),
- (CHEST_LOSE_CON),
- (CHEST_POISON),
- (CHEST_SCATTER),
- (CHEST_LOSE_STR | CHEST_LOSE_CON),
- (CHEST_LOSE_STR | CHEST_LOSE_CON),
- (CHEST_SUMMON), /* 15 == best large wooden */
- 0,
- (CHEST_ALARM),
- (CHEST_SCATTER),
- (CHEST_PARALYZE),
- (CHEST_LOSE_STR | CHEST_LOSE_CON),
- (CHEST_SUMMON),
- (CHEST_PARALYZE),
- (CHEST_LOSE_STR),
- (CHEST_LOSE_CON),
- (CHEST_EXPLODE), /* 25 == best small iron */
- 0,
- (CHEST_E_SUMMON),
- (CHEST_POISON | CHEST_LOSE_CON),
- (CHEST_LOSE_STR | CHEST_LOSE_CON),
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_BIRD_STORM),
- (CHEST_POISON | CHEST_SUMMON),
- (CHEST_E_SUMMON | CHEST_ALARM),
- (CHEST_EXPLODE),
- (CHEST_EXPLODE | CHEST_SUMMON), /* 35 == best large iron */
- 0,
- (CHEST_SUMMON | CHEST_ALARM),
- (CHEST_EXPLODE),
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_POISON | CHEST_PARALYZE),
- (CHEST_EXPLODE),
- (CHEST_BIRD_STORM),
- (CHEST_EXPLODE | CHEST_E_SUMMON | CHEST_ALARM),
- (CHEST_H_SUMMON), /* 45 == best small steel */
- 0,
- (CHEST_EXPLODE | CHEST_SUMMON | CHEST_ALARM),
- (CHEST_BIRD_STORM),
- (CHEST_RUNES_OF_EVIL),
- (CHEST_EXPLODE | CHEST_SUMMON | CHEST_ALARM),
- (CHEST_BIRD_STORM | CHEST_ALARM),
- (CHEST_H_SUMMON | CHEST_ALARM),
- (CHEST_RUNES_OF_EVIL),
- (CHEST_H_SUMMON | CHEST_SCATTER | CHEST_ALARM),
- (CHEST_RUNES_OF_EVIL | CHEST_EXPLODE), /* 55 == best large steel */
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_EXPLODE | CHEST_SUMMON),
- (CHEST_EXPLODE | CHEST_SUMMON),
+const std::vector<EnumClassFlagGroup<ChestTrapType>> chest_traps = {
+ { }, /* empty */
+ { ChestTrapType::POISON },
+ { ChestTrapType::LOSE_STR },
+ { ChestTrapType::LOSE_CON },
+ { ChestTrapType::LOSE_STR },
+ { ChestTrapType::LOSE_CON }, /* 5 == best small wooden */
+ { },
+ { ChestTrapType::ALARM },
+ { ChestTrapType::ALARM },
+ { ChestTrapType::LOSE_STR },
+ { ChestTrapType::LOSE_CON },
+ { ChestTrapType::POISON },
+ { ChestTrapType::SCATTER },
+ { ChestTrapType::LOSE_STR, ChestTrapType::LOSE_CON },
+ { ChestTrapType::LOSE_STR, ChestTrapType::LOSE_CON },
+ { ChestTrapType::SUMMON }, /* 15 == best large wooden */
+ { },
+ { ChestTrapType::ALARM },
+ { ChestTrapType::SCATTER },
+ { ChestTrapType::PARALYZE },
+ { ChestTrapType::LOSE_STR, ChestTrapType::LOSE_CON },
+ { ChestTrapType::SUMMON },
+ { ChestTrapType::PARALYZE },
+ { ChestTrapType::LOSE_STR },
+ { ChestTrapType::LOSE_CON },
+ { ChestTrapType::EXPLODE }, /* 25 == best small iron */
+ { },
+ { ChestTrapType::E_SUMMON },
+ { ChestTrapType::POISON, ChestTrapType::LOSE_CON },
+ { ChestTrapType::LOSE_STR, ChestTrapType::LOSE_CON },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::BIRD_STORM },
+ { ChestTrapType::POISON, ChestTrapType::SUMMON },
+ { ChestTrapType::E_SUMMON, ChestTrapType::ALARM },
+ { ChestTrapType::EXPLODE },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON }, /* 35 == best large iron */
+ { },
+ { ChestTrapType::SUMMON, ChestTrapType::ALARM },
+ { ChestTrapType::EXPLODE },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::POISON, ChestTrapType::PARALYZE },
+ { ChestTrapType::EXPLODE },
+ { ChestTrapType::BIRD_STORM },
+ { ChestTrapType::EXPLODE, ChestTrapType::E_SUMMON, ChestTrapType::ALARM },
+ { ChestTrapType::H_SUMMON }, /* 45 == best small steel */
+ { },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON, ChestTrapType::ALARM },
+ { ChestTrapType::BIRD_STORM },
+ { ChestTrapType::RUNES_OF_EVIL },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON, ChestTrapType::ALARM },
+ { ChestTrapType::BIRD_STORM, ChestTrapType::ALARM },
+ { ChestTrapType::H_SUMMON, ChestTrapType::ALARM },
+ { ChestTrapType::RUNES_OF_EVIL },
+ { ChestTrapType::H_SUMMON, ChestTrapType::SCATTER, ChestTrapType::ALARM },
+ { ChestTrapType::RUNES_OF_EVIL, ChestTrapType::EXPLODE }, /* 55 == best large steel */
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
+ { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
};
/*!
*/
void init_normal_traps(void)
{
- int cur_trap = 0;
-
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
- normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_TRAPDOOR"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_PIT"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_SPIKED_PIT"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_POISON_PIT"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_TY_CURSE"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_TELEPORT"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_FIRE"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_ACID"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_SLOW"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_LOSE_STR"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_LOSE_DEX"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_LOSE_CON"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_BLIND"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_CONFUSE"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_POISON"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_SLEEP"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_TRAPS"));
+ normal_traps.push_back(f_tag_to_index_in_init("TRAP_ALARM"));
}
/*!
* Actually, it is not this routine, but the "trap instantiation"\n
* code, which should also check for "trap doors" on quest levels.\n
*/
-FEAT_IDX choose_random_trap(player_type *player_ptr)
+FEAT_IDX choose_random_trap(PlayerType *player_ptr)
{
FEAT_IDX feat;
/* Pick a trap */
floor_type *floor_ptr = player_ptr->current_floor_ptr;
while (true) {
- /* Hack -- pick a trap */
- feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
+ feat = normal_traps[randint0(normal_traps.size())];
/* Accept non-trapdoors */
- if (f_info[feat].flags.has_not(FF::MORE))
+ if (f_info[feat].flags.has_not(FloorFeatureType::MORE))
break;
/* Hack -- no trap doors on special levels */
* @param y 秘匿したいマスのY座標
* @param x 秘匿したいマスのX座標
*/
-void disclose_grid(player_type *player_ptr, POSITION y, POSITION x)
+void disclose_grid(PlayerType *player_ptr, POSITION y, POSITION x)
{
grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
- if (g_ptr->cave_has_flag(FF::SECRET)) {
+ if (g_ptr->cave_has_flag(FloorFeatureType::SECRET)) {
/* No longer hidden */
- cave_alter_feat(player_ptr, y, x, FF::SECRET);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::SECRET);
} else if (g_ptr->mimic) {
/* No longer hidden */
g_ptr->mimic = 0;
* 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(player_type *player_ptr, POSITION y, POSITION x)
+void place_trap(PlayerType *player_ptr, POSITION y, POSITION x)
{
floor_type *floor_ptr = player_ptr->current_floor_ptr;
grid_type *g_ptr = &floor_ptr->grid_array[y][x];
* Always miss 5% of the time, Always hit 5% of the time.
* Otherwise, match trap power against player armor.
*/
-static int check_hit_from_monster_to_player(player_type *player_ptr, int power)
+static int check_hit_from_monster_to_player(PlayerType *player_ptr, int power)
{
int k;
ARMOUR_CLASS ac;
* @brief 落とし穴系トラップの判定とプレイヤーの被害処理
* @param trap_feat_type トラップの種別ID
*/
-static void hit_trap_pit(player_type *player_ptr, enum trap_type trap_feat_type)
+static void hit_trap_pit(PlayerType *player_ptr, enum trap_type trap_feat_type)
{
HIT_POINT dam;
concptr trap_name = "";
* @brief ダーツ系トラップ(通常ダメージ)の判定とプレイヤーの被害処理
* @return ダーツが命中した場合TRUEを返す
*/
-static bool hit_trap_dart(player_type *player_ptr)
+static bool hit_trap_dart(PlayerType *player_ptr)
{
bool hit = false;
* @brief ダーツ系トラップ(通常ダメージ+能力値減少)の判定とプレイヤーの被害処理
* @param stat 低下する能力値ID
*/
-static void hit_trap_lose_stat(player_type *player_ptr, int stat)
+static void hit_trap_lose_stat(PlayerType *player_ptr, int stat)
{
if (hit_trap_dart(player_ptr)) {
do_dec_stat(player_ptr, stat);
/*!
* @brief ダーツ系トラップ(通常ダメージ+減速)の判定とプレイヤーの被害処理
*/
-static void hit_trap_slow(player_type *player_ptr)
+static void hit_trap_slow(PlayerType *player_ptr)
{
if (hit_trap_dart(player_ptr)) {
(void)BadStatusSetter(player_ptr).mod_slowness(randint0(20) + 20, false);
* @param break_trap 作動後のトラップ破壊が確定しているならばTRUE
* @todo cmd-save.h への依存あり。コールバックで何とかしたい
*/
-void hit_trap(player_type *player_ptr, bool break_trap)
+void hit_trap(PlayerType *player_ptr, bool break_trap)
{
int i, num, dam;
POSITION x = player_ptr->x, y = player_ptr->y;
grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
feature_type *f_ptr = &f_info[g_ptr->feat];
- enum trap_type trap_feat_type = f_ptr->flags.has(FF::TRAP) ? (enum trap_type)f_ptr->subtype : NOT_TRAP;
+ enum trap_type trap_feat_type = f_ptr->flags.has(FloorFeatureType::TRAP) ? (enum trap_type)f_ptr->subtype : NOT_TRAP;
concptr name = _("トラップ", "a trap");
disturb(player_ptr, false, true);
- cave_alter_feat(player_ptr, y, x, FF::HIT_TRAP);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::HIT_TRAP);
/* Analyze */
switch (trap_feat_type) {
case TRAP_TRAPS: {
msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
/* Make some new traps */
- project(player_ptr, 0, 1, y, x, 0, GF_MAKE_TRAP, PROJECT_HIDE | PROJECT_JUMP | PROJECT_GRID);
+ project(player_ptr, 0, 1, y, x, 0, AttributeType::MAKE_TRAP, PROJECT_HIDE | PROJECT_JUMP | PROJECT_GRID);
break;
}
case TRAP_OPEN: {
msg_print(_("大音響と共にまわりの壁が崩れた!", "Suddenly, surrounding walls are opened!"));
- (void)project(player_ptr, 0, 3, y, x, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE);
- (void)project(player_ptr, 0, 3, y, x - 4, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE);
- (void)project(player_ptr, 0, 3, y, x + 4, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE);
+ (void)project(player_ptr, 0, 3, y, x, 0, AttributeType::DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE);
+ (void)project(player_ptr, 0, 3, y, x - 4, 0, AttributeType::DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE);
+ (void)project(player_ptr, 0, 3, y, x + 4, 0, AttributeType::DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE);
aggravate_monsters(player_ptr, 0);
break;
/* Summon Demons and Angels */
for (lev = player_ptr->current_floor_ptr->dun_level; lev >= 20; lev -= 1 + lev / 16) {
- num = levs[MIN(lev / 10, 9)];
+ num = levs[std::min(lev / 10, 9)];
for (i = 0; i < num; i++) {
POSITION x1 = rand_spread(x, 7);
POSITION y1 = rand_spread(y, 5);
msg_print(_("突然壁から水が溢れ出した!ピラニアがいる!", "Suddenly, the room is filled with water with piranhas!"));
/* Water fills room */
- fire_ball_hide(player_ptr, GF_WATER_FLOW, 0, 1, 10);
+ fire_ball_hide(player_ptr, AttributeType::WATER_FLOW, 0, 1, 10);
/* Summon Piranhas */
num = 1 + player_ptr->current_floor_ptr->dun_level / 20;
}
if (break_trap && is_trap(player_ptr, g_ptr->feat)) {
- cave_alter_feat(player_ptr, y, x, FF::DISARM);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::DISARM);
msg_print(_("トラップを粉砕した。", "You destroyed the trap."));
}
}