#include "action/activation-execution.h"
#include "action/action-limited.h"
-#include "artifact/random-art-effects.h"
#include "artifact/artifact-info.h"
+#include "artifact/random-art-effects.h"
#include "core/window-redrawer.h"
+#include "effect/attribute-types.h"
#include "effect/spells-effect-util.h"
+#include "flavor/flavor-describer.h"
+#include "flavor/object-flavor-types.h"
#include "floor/geometry.h"
#include "game-option/disturbance-options.h"
#include "game-option/input-options.h"
#include "object-enchant/object-ego.h"
#include "object/object-info.h"
#include "object/object-kind.h"
+#include "player-base/player-class.h"
#include "player-status/player-energy.h"
#include "racial/racial-android.h"
#include "specific-object/monster-ball.h"
#include "spell-kind/spells-teleport.h"
#include "spell-realm/spells-hex.h"
#include "spell-realm/spells-song.h"
-#include "spell/spell-types.h"
#include "sv-definition/sv-lite-types.h"
#include "sv-definition/sv-ring-types.h"
#include "system/artifact-type-definition.h"
#include "system/player-type-definition.h"
#include "target/target-getter.h"
#include "term/screen-processor.h"
+#include "timed-effect/player-confusion.h"
+#include "timed-effect/timed-effects.h"
#include "util/quarks.h"
#include "util/sort.h"
#include "view/display-messages.h"
static void decide_activation_level(ae_type *ae_ptr)
{
if (ae_ptr->o_ptr->is_fixed_artifact()) {
- ae_ptr->lev = a_info[ae_ptr->o_ptr->name1].level;
+ ae_ptr->lev = a_info.at(ae_ptr->o_ptr->fixed_artifact_idx).level;
return;
}
if (ae_ptr->o_ptr->is_random_artifact()) {
- const activation_type *const act_ptr = find_activation_info(ae_ptr->o_ptr);
- if (act_ptr != nullptr)
- ae_ptr->lev = act_ptr->level;
+ auto act_ptr = find_activation_info(ae_ptr->o_ptr);
+ if (act_ptr.has_value()) {
+ ae_ptr->lev = act_ptr.value()->level;
+ }
return;
}
- if (((ae_ptr->o_ptr->tval == TV_RING) || (ae_ptr->o_ptr->tval == TV_AMULET)) && ae_ptr->o_ptr->name2)
- ae_ptr->lev = e_info[ae_ptr->o_ptr->name2].level;
+ if (((ae_ptr->o_ptr->tval == ItemKindType::RING) || (ae_ptr->o_ptr->tval == ItemKindType::AMULET)) && ae_ptr->o_ptr->is_ego()) {
+ ae_ptr->lev = e_info[ae_ptr->o_ptr->ego_idx].level;
+ }
}
-static void decide_chance_fail(player_type *player_ptr, ae_type *ae_ptr)
+static void decide_chance_fail(PlayerType *player_ptr, ae_type *ae_ptr)
{
ae_ptr->chance = player_ptr->skill_dev;
- if (player_ptr->confused)
+ if (player_ptr->effects()->confusion()->is_confused()) {
ae_ptr->chance = ae_ptr->chance / 2;
+ }
ae_ptr->fail = ae_ptr->lev + 5;
- if (ae_ptr->chance > ae_ptr->fail)
+ if (ae_ptr->chance > ae_ptr->fail) {
ae_ptr->fail -= (ae_ptr->chance - ae_ptr->fail) * 2;
- else
+ } else {
ae_ptr->chance -= (ae_ptr->fail - ae_ptr->chance) * 2;
+ }
- if (ae_ptr->fail < USE_DEVICE)
+ if (ae_ptr->fail < USE_DEVICE) {
ae_ptr->fail = USE_DEVICE;
+ }
- if (ae_ptr->chance < USE_DEVICE)
+ if (ae_ptr->chance < USE_DEVICE) {
ae_ptr->chance = USE_DEVICE;
+ }
}
-static void decide_activation_success(player_type *player_ptr, ae_type *ae_ptr)
+static void decide_activation_success(PlayerType *player_ptr, ae_type *ae_ptr)
{
- if (player_ptr->pclass == CLASS_BERSERKER) {
+ if (PlayerClass(player_ptr).equals(PlayerClassType::BERSERKER)) {
ae_ptr->success = false;
return;
}
static bool check_activation_success(ae_type *ae_ptr)
{
- if (ae_ptr->success)
+ if (ae_ptr->success) {
return true;
+ }
- if (flush_failure)
+ if (flush_failure) {
flush();
+ }
msg_print(_("うまく始動させることができなかった。", "You failed to activate it properly."));
sound(SOUND_FAIL);
return false;
}
-static bool check_activation_conditions(player_type *player_ptr, ae_type *ae_ptr)
+static bool check_activation_conditions(PlayerType *player_ptr, ae_type *ae_ptr)
{
- if (!check_activation_success(ae_ptr))
+ if (!check_activation_success(ae_ptr)) {
return false;
+ }
if (ae_ptr->o_ptr->timeout) {
msg_print(_("それは微かに音を立て、輝き、消えた...", "It whines, glows and fades..."));
return false;
}
- if (!ae_ptr->o_ptr->xtra4 && (ae_ptr->o_ptr->tval == TV_FLASK) && ((ae_ptr->o_ptr->sval == SV_LITE_TORCH) || (ae_ptr->o_ptr->sval == SV_LITE_LANTERN))) {
+ if (ae_ptr->o_ptr->is_fuel() && (ae_ptr->o_ptr->fuel == 0)) {
msg_print(_("燃料がない。", "It has no fuel."));
PlayerEnergy(player_ptr).reset_player_turn();
return false;
* @param o_ptr 対象のオブジェクト構造体ポインタ
* @return 発動実行の是非を返す。
*/
-static bool activate_artifact(player_type *player_ptr, object_type *o_ptr)
+static bool activate_artifact(PlayerType *player_ptr, ObjectType *o_ptr)
{
- concptr name = k_info[o_ptr->k_idx].name.c_str();
- const activation_type *const act_ptr = find_activation_info(o_ptr);
- if (!act_ptr) {
+ auto tmp_act_ptr = find_activation_info(o_ptr);
+ if (!tmp_act_ptr.has_value()) {
msg_print("Activation information is not found.");
return false;
}
- if (!switch_activation(player_ptr, &o_ptr, act_ptr, name))
+ auto *act_ptr = tmp_act_ptr.value();
+ GAME_TEXT name[MAX_NLEN];
+ describe_flavor(player_ptr, name, o_ptr, OD_NAME_ONLY | OD_OMIT_PREFIX | OD_BASE_NAME);
+ if (!switch_activation(player_ptr, &o_ptr, act_ptr, name)) {
return false;
+ }
if (act_ptr->timeout.constant >= 0) {
o_ptr->timeout = (int16_t)act_ptr->timeout.constant;
- if (act_ptr->timeout.dice > 0)
+ if (act_ptr->timeout.dice > 0) {
o_ptr->timeout += randint1(act_ptr->timeout.dice);
+ }
return true;
}
switch (act_ptr->index) {
- case ACT_BR_FIRE:
- o_ptr->timeout = ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250;
+ case RandomArtActType::BR_FIRE:
+ o_ptr->timeout = ((o_ptr->tval == ItemKindType::RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250;
return true;
- case ACT_BR_COLD:
- o_ptr->timeout = ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) ? 200 : 250;
+ case RandomArtActType::BR_COLD:
+ o_ptr->timeout = ((o_ptr->tval == ItemKindType::RING) && (o_ptr->sval == SV_RING_ICE)) ? 200 : 250;
return true;
- case ACT_TERROR:
+ case RandomArtActType::TERROR:
o_ptr->timeout = 3 * (player_ptr->lev + 10);
return true;
- case ACT_MURAMASA:
+ case RandomArtActType::MURAMASA:
return true;
default:
msg_format("Special timeout is not implemented: %d.", act_ptr->index);
}
}
-static bool activate_whistle(player_type *player_ptr, ae_type *ae_ptr)
+static bool activate_whistle(PlayerType *player_ptr, ae_type *ae_ptr)
{
- if (ae_ptr->o_ptr->tval != TV_WHISTLE)
+ if (ae_ptr->o_ptr->tval != ItemKindType::WHISTLE) {
return false;
+ }
- if (music_singing_any(player_ptr))
+ if (music_singing_any(player_ptr)) {
stop_singing(player_ptr);
+ }
if (SpellHex(player_ptr).is_spelling_any()) {
(void)SpellHex(player_ptr).stop_all_spells();
}
- MONSTER_IDX pet_ctr;
- MONSTER_IDX *who;
- int max_pet = 0;
- C_MAKE(who, w_ptr->max_m_idx, MONSTER_IDX);
- for (pet_ctr = player_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
- if (is_pet(&player_ptr->current_floor_ptr->m_list[pet_ctr]) && (player_ptr->riding != pet_ctr))
- who[max_pet++] = pet_ctr;
+ std::vector<MONSTER_IDX> who;
+ for (MONSTER_IDX pet_ctr = player_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--) {
+ if (is_pet(&player_ptr->current_floor_ptr->m_list[pet_ctr]) && (player_ptr->riding != pet_ctr)) {
+ who.push_back(pet_ctr);
+ }
+ }
uint16_t dummy_why;
- ang_sort(player_ptr, who, &dummy_why, max_pet, ang_sort_comp_pet, ang_sort_swap_hook);
- for (MONSTER_IDX i = 0; i < max_pet; i++) {
- pet_ctr = who[i];
+ ang_sort(player_ptr, who.data(), &dummy_why, who.size(), ang_sort_comp_pet, ang_sort_swap_hook);
+ for (auto pet_ctr : who) {
teleport_monster_to(player_ptr, pet_ctr, player_ptr->y, player_ptr->x, 100, TELEPORT_PASSIVE);
}
- C_KILL(who, w_ptr->max_m_idx, MONSTER_IDX);
ae_ptr->o_ptr->timeout = 100 + randint1(100);
return true;
}
* the user hits "escape" at the "direction" prompt.
* </pre>
*/
-void exe_activate(player_type *player_ptr, INVENTORY_IDX item)
+void exe_activate(PlayerType *player_ptr, INVENTORY_IDX item)
{
PlayerEnergy(player_ptr).set_player_turn_energy(100);
ae_type tmp_ae;
ae_type *ae_ptr = initialize_ae_type(player_ptr, &tmp_ae, item);
decide_activation_level(ae_ptr);
decide_chance_fail(player_ptr, ae_ptr);
- if (cmd_limit_time_walk(player_ptr))
+ if (cmd_limit_time_walk(player_ptr)) {
return;
+ }
decide_activation_success(player_ptr, ae_ptr);
- if (!check_activation_conditions(player_ptr, ae_ptr))
+ if (!check_activation_conditions(player_ptr, ae_ptr)) {
return;
+ }
msg_print(_("始動させた...", "You activate it..."));
sound(SOUND_ZAP);
- if (activation_index(ae_ptr->o_ptr)) {
+ if (activation_index(ae_ptr->o_ptr) > RandomArtActType::NONE) {
(void)activate_artifact(player_ptr, ae_ptr->o_ptr);
player_ptr->window_flags |= PW_INVEN | PW_EQUIP;
return;
}
- if (activate_whistle(player_ptr, ae_ptr))
+ if (activate_whistle(player_ptr, ae_ptr)) {
return;
+ }
- if (exe_monster_capture(player_ptr, ae_ptr))
+ if (exe_monster_capture(player_ptr, ae_ptr)) {
return;
+ }
msg_print(_("おっと、このアイテムは始動できない。", "Oops. That object cannot be activated."));
}