#include "player-status/player-energy.h"
#include "player/player-status-table.h"
#include "spell/spell-info.h"
-#include "sv-definition/sv-other-types.h"
-#include "sv-definition/sv-rod-types.h"
#include "system/baseitem-info.h"
#include "system/player-type-definition.h"
#include "target/target-getter.h"
return false;
}
- const auto sval = opt_sval.value();
- if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC) && (sval != SV_ROD_AGGRAVATE) && (sval != SV_ROD_PESTICIDE)) {
- if (!get_aim_dir(player_ptr, &dir)) {
- return false;
- }
+ if (baseitem.is_aiming_rod() && !get_aim_dir(player_ptr, &dir)) {
+ return false;
}
- (void)rod_effect(player_ptr, sval, dir, &use_charge, powerful);
+ (void)rod_effect(player_ptr, opt_sval.value(), dir, &use_charge, powerful);
if (!use_charge) {
return false;
}
return;
}
- if (((o_ptr->sval >= SV_ROD_MIN_DIRECTION) && (o_ptr->sval != SV_ROD_HAVOC) && (o_ptr->sval != SV_ROD_AGGRAVATE) && (o_ptr->sval != SV_ROD_PESTICIDE)) || !o_ptr->is_aware()) {
+ if (o_ptr->is_aiming_rod() || !o_ptr->is_aware()) {
if (!get_aim_dir(this->player_ptr, &dir)) {
return;
}
#include "sv-definition/sv-bow-types.h"
#include "sv-definition/sv-food-types.h"
#include "sv-definition/sv-protector-types.h"
+#include "sv-definition/sv-rod-types.h"
#include "sv-definition/sv-weapon-types.h"
#include <set>
#include <unordered_map>
namespace {
constexpr auto ITEM_NOT_BOW = "This item is not a bow!";
+constexpr auto ITEM_NOT_ROD = "This item is not a rod!";
}
BaseitemKey::BaseitemKey(const ItemKindType type_value, const std::optional<int> &subtype_value)
}
}
+bool BaseitemKey::is_aiming_rod() const
+{
+ if ((this->type_value != ItemKindType::ROD) || !this->subtype_value.has_value()) {
+ throw std::logic_error(ITEM_NOT_ROD);
+ }
+
+ switch (this->subtype_value.value()) {
+ case SV_ROD_TELEPORT_AWAY:
+ case SV_ROD_DISARMING:
+ case SV_ROD_LITE:
+ case SV_ROD_SLEEP_MONSTER:
+ case SV_ROD_SLOW_MONSTER:
+ case SV_ROD_HYPODYNAMIA:
+ case SV_ROD_POLYMORPH:
+ case SV_ROD_ACID_BOLT:
+ case SV_ROD_ELEC_BOLT:
+ case SV_ROD_FIRE_BOLT:
+ case SV_ROD_COLD_BOLT:
+ case SV_ROD_ACID_BALL:
+ case SV_ROD_ELEC_BALL:
+ case SV_ROD_FIRE_BALL:
+ case SV_ROD_COLD_BALL:
+ case SV_ROD_STONE_TO_MUD:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool BaseitemKey::is_mushrooms() const
{
if (!this->subtype_value.has_value()) {
bool is_rare() const;
short get_bow_energy() const;
int get_arrow_magnification() const;
+ bool is_aiming_rod() const;
private:
ItemKindType type_value;
{
return BaseitemKey(this->tval, this->sval).get_arrow_magnification();
}
+
+bool ItemEntity::is_aiming_rod() const
+{
+ return BaseitemKey(this->tval, this->sval).is_aiming_rod();
+}
bool is_wand_staff() const;
short get_bow_energy() const;
int get_arrow_magnification() const;
+ bool is_aiming_rod() const;
private:
int get_baseitem_price() const;