1 #include "cmd-item/cmd-usestaff.h"
2 #include "action/action-limited.h"
3 #include "avatar/avatar.h"
4 #include "core/player-update-types.h"
5 #include "core/window-redrawer.h"
6 #include "floor/floor-object.h"
7 #include "game-option/disturbance-options.h"
8 #include "inventory/inventory-object.h"
9 #include "inventory/player-inventory.h"
10 #include "main/sound-definitions-table.h"
11 #include "main/sound-of-music.h"
12 #include "monster-floor/monster-summon.h"
13 #include "monster-floor/place-monster-types.h"
14 #include "object-enchant/special-object-flags.h"
15 #include "object/item-tester-hooker.h"
16 #include "object/item-use-flags.h"
17 #include "object/object-info.h"
18 #include "object/object-kind.h"
19 #include "perception/object-perception.h"
20 #include "player-info/class-info.h"
21 #include "player-info/race-info.h"
22 #include "player-info/race-types.h"
23 #include "player-status/player-energy.h"
24 #include "player/attack-defense-types.h"
25 #include "player/player-status-flags.h"
26 #include "player/special-defense-types.h"
27 #include "spell-kind/earthquake.h"
28 #include "spell-kind/spells-curse-removal.h"
29 #include "spell-kind/spells-detection.h"
30 #include "spell-kind/spells-floor.h"
31 #include "spell-kind/spells-genocide.h"
32 #include "spell-kind/spells-lite.h"
33 #include "spell-kind/spells-neighbor.h"
34 #include "spell-kind/spells-perception.h"
35 #include "spell-kind/spells-sight.h"
36 #include "spell-kind/spells-teleport.h"
37 #include "spell/spells-staff-only.h"
38 #include "spell/spells-status.h"
39 #include "spell/spells-summon.h"
40 #include "spell/summon-types.h"
41 #include "status/action-setter.h"
42 #include "status/bad-status-setter.h"
43 #include "status/base-status.h"
44 #include "status/buff-setter.h"
45 #include "status/experience.h"
46 #include "status/shape-changer.h"
47 #include "status/sight-setter.h"
48 #include "sv-definition/sv-staff-types.h"
49 #include "system/floor-type-definition.h"
50 #include "system/object-type-definition.h"
51 #include "system/player-type-definition.h"
52 #include "term/screen-processor.h"
53 #include "util/bit-flags-calculator.h"
54 #include "view/display-messages.h"
55 #include "view/object-describer.h"
59 * @param player_ptr プレイヤーへの参照ポインタ
60 * @param sval オブジェクトのsval
61 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
62 * @param powerful 強力発動上の処理ならばTRUE
63 * @param magic 魔道具術上の処理ならばTRUE
64 * @param known 判明済ならばTRUE
65 * @return 発動により効果内容が確定したならばTRUEを返す
67 int staff_effect(player_type *player_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
71 PLAYER_LEVEL lev = powerful ? player_ptr->lev * 2 : player_ptr->lev;
72 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
74 /* Analyze the staff */
76 case SV_STAFF_DARKNESS: {
77 if (!has_resist_blind(player_ptr) && !has_resist_dark(player_ptr)) {
78 if (set_blind(player_ptr, player_ptr->blind + 3 + randint1(5)))
81 if (unlite_area(player_ptr, 10, (powerful ? 6 : 3)))
86 case SV_STAFF_SLOWNESS: {
87 if (set_slow(player_ptr, player_ptr->slow + randint1(30) + 15, false))
92 case SV_STAFF_HASTE_MONSTERS: {
93 if (speed_monsters(player_ptr))
98 case SV_STAFF_SUMMONING: {
99 const int times = randint1(powerful ? 8 : 4);
100 for (k = 0; k < times; k++) {
101 if (summon_specific(player_ptr, 0, player_ptr->y, player_ptr->x, player_ptr->current_floor_ptr->dun_level, SUMMON_NONE,
102 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET))) {
109 case SV_STAFF_TELEPORTATION: {
110 teleport_player(player_ptr, (powerful ? 150 : 100), 0L);
115 case SV_STAFF_IDENTIFY: {
117 if (!identify_fully(player_ptr, false))
120 if (!ident_spell(player_ptr, false))
127 case SV_STAFF_REMOVE_CURSE: {
128 bool result = (powerful ? remove_all_curse(player_ptr) : remove_curse(player_ptr)) != 0;
135 case SV_STAFF_STARLITE:
136 ident = starlight(player_ptr, magic);
139 case SV_STAFF_LITE: {
140 if (lite_area(player_ptr, damroll(2, 8), (powerful ? 4 : 2)))
145 case SV_STAFF_MAPPING: {
146 map_area(player_ptr, powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
151 case SV_STAFF_DETECT_GOLD: {
152 if (detect_treasure(player_ptr, detect_rad))
154 if (detect_objects_gold(player_ptr, detect_rad))
159 case SV_STAFF_DETECT_ITEM: {
160 if (detect_objects_normal(player_ptr, detect_rad))
165 case SV_STAFF_DETECT_TRAP: {
166 if (detect_traps(player_ptr, detect_rad, known))
171 case SV_STAFF_DETECT_DOOR: {
172 if (detect_doors(player_ptr, detect_rad))
174 if (detect_stairs(player_ptr, detect_rad))
179 case SV_STAFF_DETECT_INVIS: {
180 if (set_tim_invis(player_ptr, player_ptr->tim_invis + 12 + randint1(12), false))
185 case SV_STAFF_DETECT_EVIL: {
186 if (detect_monsters_evil(player_ptr, detect_rad))
191 case SV_STAFF_CURE_LIGHT: {
192 ident = cure_light_wounds(player_ptr, (powerful ? 4 : 2), 8);
196 case SV_STAFF_CURING: {
197 ident = true_healing(player_ptr, 0);
198 if (set_shero(player_ptr, 0, true))
203 case SV_STAFF_HEALING: {
204 if (cure_critical_wounds(player_ptr, powerful ? 500 : 300))
209 case SV_STAFF_THE_MAGI: {
210 if (do_res_stat(player_ptr, A_INT))
212 ident |= restore_mana(player_ptr, false);
213 if (set_shero(player_ptr, 0, true))
218 case SV_STAFF_SLEEP_MONSTERS: {
219 if (sleep_monsters(player_ptr, lev))
224 case SV_STAFF_SLOW_MONSTERS: {
225 if (slow_monsters(player_ptr, lev))
230 case SV_STAFF_SPEED: {
231 if (set_fast(player_ptr, randint1(30) + (powerful ? 30 : 15), false))
236 case SV_STAFF_PROBING: {
237 ident = probing(player_ptr);
241 case SV_STAFF_DISPEL_EVIL: {
242 ident = dispel_evil(player_ptr, powerful ? 120 : 80);
246 case SV_STAFF_POWER: {
247 ident = dispel_monsters(player_ptr, powerful ? 225 : 150);
251 case SV_STAFF_HOLINESS: {
252 ident = cleansing_nova(player_ptr, magic, powerful);
256 case SV_STAFF_GENOCIDE: {
257 ident = symbol_genocide(player_ptr, (magic ? lev + 50 : 200), true);
261 case SV_STAFF_EARTHQUAKES: {
262 if (earthquake(player_ptr, player_ptr->y, player_ptr->x, (powerful ? 15 : 10), 0))
265 msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
270 case SV_STAFF_DESTRUCTION: {
271 ident = destroy_area(player_ptr, player_ptr->y, player_ptr->x, (powerful ? 18 : 13) + randint0(5), false);
275 case SV_STAFF_ANIMATE_DEAD: {
276 ident = animate_dead(player_ptr, 0, player_ptr->y, player_ptr->x);
280 case SV_STAFF_MSTORM: {
281 ident = unleash_mana_storm(player_ptr, powerful);
285 case SV_STAFF_NOTHING: {
286 msg_print(_("何も起らなかった。", "Nothing happens."));
287 if (player_race_food(player_ptr) == PlayerRaceFood::MANA)
288 msg_print(_("もったいない事をしたような気がする。食べ物は大切にしなくては。", "What a waste. It's your food!"));
296 * @brief 杖を使うコマンドのサブルーチン /
298 * @param item 使うオブジェクトの所持品ID
300 * One charge of one staff disappears.
301 * Hack -- staffs of identify can be "cancelled".
303 void exe_use_staff(player_type *player_ptr, INVENTORY_IDX item)
305 int ident, chance, lev;
308 /* Hack -- let staffs of identify get aborted */
309 bool use_charge = true;
311 o_ptr = ref_item(player_ptr, item);
313 /* Mega-Hack -- refuse to use a pile from the ground */
314 if ((item < 0) && (o_ptr->number > 1)) {
315 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
319 PlayerEnergy(player_ptr).set_player_turn_energy(100);
321 lev = k_info[o_ptr->k_idx].level;
323 lev = 50 + (lev - 50) / 2;
325 /* Base chance of success */
326 chance = player_ptr->skill_dev;
328 /* Confusion hurts skill */
329 if (player_ptr->confused)
332 /* Hight level objects are harder */
333 chance = chance - lev;
335 /* Give everyone a (slight) chance */
336 if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1)) {
340 if (cmd_limit_time_walk(player_ptr))
344 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (player_ptr->pclass == CLASS_BERSERKER)) {
347 msg_print(_("杖をうまく使えなかった。", "You failed to use the staff properly."));
352 /* Notice empty staffs */
353 if (o_ptr->pval <= 0) {
356 msg_print(_("この杖にはもう魔力が残っていない。", "The staff has no charges left."));
357 o_ptr->ident |= (IDENT_EMPTY);
358 player_ptr->update |= (PU_COMBINE | PU_REORDER);
359 player_ptr->window_flags |= (PW_INVEN);
366 ident = staff_effect(player_ptr, o_ptr->sval, &use_charge, false, false, o_ptr->is_aware());
368 if (!(o_ptr->is_aware())) {
369 chg_virtue(player_ptr, V_PATIENCE, -1);
370 chg_virtue(player_ptr, V_CHANCE, 1);
371 chg_virtue(player_ptr, V_KNOWLEDGE, -1);
375 * Temporarily remove the flags for updating the inventory so
376 * gain_exp() does not reorder the inventory before the charge
377 * is deducted from the staff.
379 BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (player_ptr->update & PU_AUTODESTROY));
380 reset_bits(player_ptr->update, PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
385 /* An identification was made */
386 if (ident && !o_ptr->is_aware()) {
387 object_aware(player_ptr, o_ptr);
388 gain_exp(player_ptr, (lev + (player_ptr->lev >> 1)) / player_ptr->lev);
391 set_bits(player_ptr->window_flags, PW_INVEN | PW_EQUIP | PW_PLAYER | PW_FLOOR_ITEM_LIST);
392 set_bits(player_ptr->update, inventory_flags);
394 /* Hack -- some uses are "free" */
398 /* Use a single charge */
401 /* XXX Hack -- unstack if necessary */
402 if ((item >= 0) && (o_ptr->number > 1)) {
406 q_ptr->copy_from(o_ptr);
408 /* Modify quantity */
411 /* Restore the charges */
414 /* Unstack the used item */
416 item = store_item_to_inventory(player_ptr, q_ptr);
418 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
421 /* Describe charges in the pack */
423 inven_item_charges(player_ptr, item);
426 /* Describe charges on the floor */
428 floor_item_charges(player_ptr->current_floor_ptr, 0 - item);
433 * @brief 杖を使うコマンドのメインルーチン /
435 void do_cmd_use_staff(player_type *player_ptr)
440 if (player_ptr->wild_mode) {
444 if (cmd_limit_arena(player_ptr))
447 if (player_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN)) {
448 set_action(player_ptr, ACTION_NONE);
451 q = _("どの杖を使いますか? ", "Use which staff? ");
452 s = _("使える杖がない。", "You have no staff to use.");
453 if (!choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TvalItemTester(TV_STAFF)))
456 exe_use_staff(player_ptr, item);