#include "angband.h"
+#include "util.h"
+
#include "avatar.h"
-#include "spells-status.h"
#include "player-status.h"
+#include "player-effects.h"
+#include "player-class.h"
+#include "player-inventory.h"
+#include "objectkind.h"
#include "object-hook.h"
+#include "spells.h"
+#include "spells-status.h"
+#include "spells-floor.h"
+#include "cmd-basic.h"
+#include "floor.h"
+#include "targeting.h"
+#include "view-mainwindow.h"
/*!
* @brief ロッドの効果を発動する
* @param magic 魔道具術上の処理ならばTRUE
* @return 発動により効果内容が確定したならばTRUEを返す
*/
-int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
+int rod_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
{
int ident = FALSE;
- PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
+ PLAYER_LEVEL lev = powerful ? creature_ptr->lev * 2 : creature_ptr->lev;
POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
POSITION rad = powerful ? 3 : 2;
case SV_ROD_RECALL:
{
- if (!recall_player(p_ptr, randint0(21) + 15)) *use_charge = FALSE;
+ if (!recall_player(creature_ptr, randint0(21) + 15)) *use_charge = FALSE;
ident = TRUE;
break;
}
case SV_ROD_CURING:
{
if (true_healing(0)) ident = TRUE;
- if (set_shero(0, TRUE)) ident = TRUE;
+ if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
break;
}
case SV_ROD_RESTORATION:
{
- if(restore_level()) ident = TRUE;
+ if(restore_level(creature_ptr)) ident = TRUE;
if(restore_all_status()) ident = TRUE;
break;
}
case SV_ROD_SPEED:
{
- if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
+ if (set_fast(creature_ptr, randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
break;
}
* pvals are defined for each rod in k_info. -LM-
* </pre>
*/
-void do_cmd_zap_rod_aux(INVENTORY_IDX item)
+void exe_zap_rod(player_type *creature_ptr, INVENTORY_IDX item)
{
int ident, chance, lev, fail;
DIRECTION dir = 0;
object_kind *k_ptr;
- /* Get the item (in the pack) */
- if (item >= 0)
- {
- o_ptr = &inventory[item];
- }
-
- /* Get the item (on the floor) */
- else
- {
- o_ptr = ¤t_floor_ptr->o_list[0 - item];
- }
-
+ o_ptr = REF_ITEM(creature_ptr, current_floor_ptr, item);
/* Mega-Hack -- refuse to zap a pile from the ground */
if ((item < 0) && (o_ptr->number > 1))
}
- take_turn(p_ptr, 100);
+ take_turn(creature_ptr, 100);
- /* Extract the item level */
lev = k_info[o_ptr->k_idx].level;
/* Base chance of success */
- chance = p_ptr->skill_dev;
+ chance = creature_ptr->skill_dev;
/* Confusion hurts skill */
- if (p_ptr->confused) chance = chance / 2;
+ if (creature_ptr->confused) chance = chance / 2;
fail = lev + 5;
if (chance > fail) fail -= (chance - fail) * 2;
if (fail < USE_DEVICE) fail = USE_DEVICE;
if (chance < USE_DEVICE) chance = USE_DEVICE;
- if (cmd_limit_time_walk(p_ptr)) return;
+ if (cmd_limit_time_walk(creature_ptr)) return;
- if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
+ if (creature_ptr->pclass == CLASS_BERSERKER) success = FALSE;
else if (chance > fail)
{
if (randint0(chance * 2) < fail) success = FALSE;
sound(SOUND_ZAP);
- ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE, FALSE);
+ ident = rod_effect(creature_ptr, o_ptr->sval, dir, &use_charge, FALSE, FALSE);
/* Increase the timeout by the rod kind's pval. -LM- */
if (use_charge) o_ptr->timeout += k_ptr->pval;
- p_ptr->update |= (PU_COMBINE | PU_REORDER);
+ creature_ptr->update |= (PU_COMBINE | PU_REORDER);
if (!(object_is_aware(o_ptr)))
{
- chg_virtue(V_PATIENCE, -1);
- chg_virtue(V_CHANCE, 1);
- chg_virtue(V_KNOWLEDGE, -1);
+ chg_virtue(creature_ptr, V_PATIENCE, -1);
+ chg_virtue(creature_ptr, V_CHANCE, 1);
+ chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
}
/* Tried the object */
if (ident && !object_is_aware(o_ptr))
{
object_aware(o_ptr);
- gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
+ gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
}
- p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
+ creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
}
/*!
* @brief ロッドを使うコマンドのメインルーチン /
* @return なし
*/
-void do_cmd_zap_rod(void)
+void do_cmd_zap_rod(player_type *creature_ptr)
{
OBJECT_IDX item;
concptr q, s;
- if (p_ptr->wild_mode)
+ if (creature_ptr->wild_mode)
{
return;
}
- if (cmd_limit_arena(p_ptr)) return;
+ if (cmd_limit_arena(creature_ptr)) return;
- if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
+ if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
{
- set_action(ACTION_NONE);
+ set_action(creature_ptr, ACTION_NONE);
}
- /* Restrict choices to rods */
- item_tester_tval = TV_ROD;
-
q = _("どのロッドを振りますか? ", "Zap which rod? ");
s = _("使えるロッドがない。", "You have no rod to zap.");
- if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
+ if (!choose_object(p_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_ROD)) return;
/* Zap the rod */
- do_cmd_zap_rod_aux(item);
+ exe_zap_rod(creature_ptr, item);
}