1 #include "cmd-item/cmd-usestaff.h"
2 #include "action/action-limited.h"
3 #include "core/player-update-types.h"
4 #include "core/window-redrawer.h"
5 #include "floor/floor-object.h"
6 #include "game-option/disturbance-options.h"
7 #include "inventory/inventory-object.h"
8 #include "inventory/player-inventory.h"
9 #include "main/sound-definitions-table.h"
10 #include "main/sound-of-music.h"
11 #include "monster-floor/monster-summon.h"
12 #include "monster-floor/place-monster-types.h"
13 #include "object-enchant/special-object-flags.h"
14 #include "object/item-use-flags.h"
15 #include "object/object-info.h"
16 #include "object/object-kind.h"
17 #include "perception/object-perception.h"
18 #include "player/attack-defense-types.h"
19 #include "player-info/avatar.h"
20 #include "player-status/player-energy.h"
21 #include "player/player-class.h"
22 #include "player/player-race-types.h"
23 #include "player/player-race.h"
24 #include "player/player-status-flags.h"
25 #include "player/special-defense-types.h"
26 #include "spell-kind/earthquake.h"
27 #include "spell-kind/spells-curse-removal.h"
28 #include "spell-kind/spells-detection.h"
29 #include "spell-kind/spells-floor.h"
30 #include "spell-kind/spells-genocide.h"
31 #include "spell-kind/spells-lite.h"
32 #include "spell-kind/spells-neighbor.h"
33 #include "spell-kind/spells-perception.h"
34 #include "spell-kind/spells-sight.h"
35 #include "spell-kind/spells-teleport.h"
36 #include "spell/spells-staff-only.h"
37 #include "spell/spells-status.h"
38 #include "spell/spells-summon.h"
39 #include "spell/summon-types.h"
40 #include "status/action-setter.h"
41 #include "status/bad-status-setter.h"
42 #include "status/base-status.h"
43 #include "status/buff-setter.h"
44 #include "status/experience.h"
45 #include "status/shape-changer.h"
46 #include "status/sight-setter.h"
47 #include "sv-definition/sv-staff-types.h"
48 #include "system/floor-type-definition.h"
49 #include "system/object-type-definition.h"
50 #include "system/player-type-definition.h"
51 #include "util/bit-flags-calculator.h"
52 #include "term/screen-processor.h"
53 #include "view/display-messages.h"
54 #include "view/object-describer.h"
58 * @param creature_ptr プレーヤーへの参照ポインタ
59 * @param sval オブジェクトのsval
60 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
61 * @param powerful 強力発動上の処理ならばTRUE
62 * @param magic 魔道具術上の処理ならばTRUE
63 * @param known 判明済ならばTRUE
64 * @return 発動により効果内容が確定したならばTRUEを返す
66 int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
70 PLAYER_LEVEL lev = powerful ? creature_ptr->lev * 2 : creature_ptr->lev;
71 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
73 /* Analyze the staff */
75 case SV_STAFF_DARKNESS: {
76 if (!has_resist_blind(creature_ptr) && !has_resist_dark(creature_ptr)) {
77 if (set_blind(creature_ptr, creature_ptr->blind + 3 + randint1(5)))
80 if (unlite_area(creature_ptr, 10, (powerful ? 6 : 3)))
85 case SV_STAFF_SLOWNESS: {
86 if (set_slow(creature_ptr, creature_ptr->slow + randint1(30) + 15, false))
91 case SV_STAFF_HASTE_MONSTERS: {
92 if (speed_monsters(creature_ptr))
97 case SV_STAFF_SUMMONING: {
98 const int times = randint1(powerful ? 8 : 4);
99 for (k = 0; k < times; k++) {
100 if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_NONE,
101 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET))) {
108 case SV_STAFF_TELEPORTATION: {
109 teleport_player(creature_ptr, (powerful ? 150 : 100), 0L);
114 case SV_STAFF_IDENTIFY: {
116 if (!identify_fully(creature_ptr, false, TV_NONE))
119 if (!ident_spell(creature_ptr, false, TV_NONE))
126 case SV_STAFF_REMOVE_CURSE: {
127 bool result = (powerful ? remove_all_curse(creature_ptr) : remove_curse(creature_ptr)) != 0;
134 case SV_STAFF_STARLITE:
135 ident = starlight(creature_ptr, magic);
138 case SV_STAFF_LITE: {
139 if (lite_area(creature_ptr, damroll(2, 8), (powerful ? 4 : 2)))
144 case SV_STAFF_MAPPING: {
145 map_area(creature_ptr, powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
150 case SV_STAFF_DETECT_GOLD: {
151 if (detect_treasure(creature_ptr, detect_rad))
153 if (detect_objects_gold(creature_ptr, detect_rad))
158 case SV_STAFF_DETECT_ITEM: {
159 if (detect_objects_normal(creature_ptr, detect_rad))
164 case SV_STAFF_DETECT_TRAP: {
165 if (detect_traps(creature_ptr, detect_rad, known))
170 case SV_STAFF_DETECT_DOOR: {
171 if (detect_doors(creature_ptr, detect_rad))
173 if (detect_stairs(creature_ptr, detect_rad))
178 case SV_STAFF_DETECT_INVIS: {
179 if (set_tim_invis(creature_ptr, creature_ptr->tim_invis + 12 + randint1(12), false))
184 case SV_STAFF_DETECT_EVIL: {
185 if (detect_monsters_evil(creature_ptr, detect_rad))
190 case SV_STAFF_CURE_LIGHT: {
191 ident = cure_light_wounds(creature_ptr, (powerful ? 4 : 2), 8);
195 case SV_STAFF_CURING: {
196 ident = true_healing(creature_ptr, 0);
197 if (set_shero(creature_ptr, 0, true))
202 case SV_STAFF_HEALING: {
203 if (cure_critical_wounds(creature_ptr, powerful ? 500 : 300))
208 case SV_STAFF_THE_MAGI: {
209 if (do_res_stat(creature_ptr, A_INT))
211 ident |= restore_mana(creature_ptr, false);
212 if (set_shero(creature_ptr, 0, true))
217 case SV_STAFF_SLEEP_MONSTERS: {
218 if (sleep_monsters(creature_ptr, lev))
223 case SV_STAFF_SLOW_MONSTERS: {
224 if (slow_monsters(creature_ptr, lev))
229 case SV_STAFF_SPEED: {
230 if (set_fast(creature_ptr, randint1(30) + (powerful ? 30 : 15), false))
235 case SV_STAFF_PROBING: {
236 ident = probing(creature_ptr);
240 case SV_STAFF_DISPEL_EVIL: {
241 ident = dispel_evil(creature_ptr, powerful ? 120 : 80);
245 case SV_STAFF_POWER: {
246 ident = dispel_monsters(creature_ptr, powerful ? 225 : 150);
250 case SV_STAFF_HOLINESS: {
251 ident = cleansing_nova(creature_ptr, magic, powerful);
255 case SV_STAFF_GENOCIDE: {
256 ident = symbol_genocide(creature_ptr, (magic ? lev + 50 : 200), true);
260 case SV_STAFF_EARTHQUAKES: {
261 if (earthquake(creature_ptr, creature_ptr->y, creature_ptr->x, (powerful ? 15 : 10), 0))
264 msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
269 case SV_STAFF_DESTRUCTION: {
270 ident = destroy_area(creature_ptr, creature_ptr->y, creature_ptr->x, (powerful ? 18 : 13) + randint0(5), false);
274 case SV_STAFF_ANIMATE_DEAD: {
275 ident = animate_dead(creature_ptr, 0, creature_ptr->y, creature_ptr->x);
279 case SV_STAFF_MSTORM: {
280 ident = unleash_mana_storm(creature_ptr, powerful);
284 case SV_STAFF_NOTHING: {
285 msg_print(_("何も起らなかった。", "Nothing happens."));
286 if (player_race_food(creature_ptr) == PlayerRaceFood::MANA)
287 msg_print(_("もったいない事をしたような気がする。食べ物は大切にしなくては。", "What a waste. It's your food!"));
295 * @brief 杖を使うコマンドのサブルーチン /
297 * @param item 使うオブジェクトの所持品ID
299 * One charge of one staff disappears.
300 * Hack -- staffs of identify can be "cancelled".
302 void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
304 int ident, chance, lev;
307 /* Hack -- let staffs of identify get aborted */
308 bool use_charge = true;
310 o_ptr = ref_item(creature_ptr, item);
312 /* Mega-Hack -- refuse to use a pile from the ground */
313 if ((item < 0) && (o_ptr->number > 1)) {
314 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
318 PlayerEnergy(creature_ptr).set_player_turn_energy(100);
320 lev = k_info[o_ptr->k_idx].level;
322 lev = 50 + (lev - 50) / 2;
324 /* Base chance of success */
325 chance = creature_ptr->skill_dev;
327 /* Confusion hurts skill */
328 if (creature_ptr->confused)
331 /* Hight level objects are harder */
332 chance = chance - lev;
334 /* Give everyone a (slight) chance */
335 if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1)) {
339 if (cmd_limit_time_walk(creature_ptr))
343 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (creature_ptr->pclass == CLASS_BERSERKER)) {
346 msg_print(_("杖をうまく使えなかった。", "You failed to use the staff properly."));
351 /* Notice empty staffs */
352 if (o_ptr->pval <= 0) {
355 msg_print(_("この杖にはもう魔力が残っていない。", "The staff has no charges left."));
356 o_ptr->ident |= (IDENT_EMPTY);
357 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
358 creature_ptr->window_flags |= (PW_INVEN);
365 ident = staff_effect(creature_ptr, o_ptr->sval, &use_charge, false, false, object_is_aware(o_ptr));
367 if (!(object_is_aware(o_ptr))) {
368 chg_virtue(creature_ptr, V_PATIENCE, -1);
369 chg_virtue(creature_ptr, V_CHANCE, 1);
370 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
374 * Temporarily remove the flags for updating the inventory so
375 * gain_exp() does not reorder the inventory before the charge
376 * is deducted from the staff.
378 BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
379 reset_bits(creature_ptr->update, PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
384 /* An identification was made */
385 if (ident && !object_is_aware(o_ptr)) {
386 object_aware(creature_ptr, o_ptr);
387 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
390 set_bits(creature_ptr->window_flags, PW_INVEN | PW_EQUIP | PW_PLAYER | PW_FLOOR_ITEM_LIST);
391 set_bits(creature_ptr->update, inventory_flags);
393 /* Hack -- some uses are "free" */
397 /* Use a single charge */
400 /* XXX Hack -- unstack if necessary */
401 if ((item >= 0) && (o_ptr->number > 1)) {
405 q_ptr->copy_from(o_ptr);
407 /* Modify quantity */
410 /* Restore the charges */
413 /* Unstack the used item */
415 item = store_item_to_inventory(creature_ptr, q_ptr);
417 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
420 /* Describe charges in the pack */
422 inven_item_charges(creature_ptr, item);
425 /* Describe charges on the floor */
427 floor_item_charges(creature_ptr->current_floor_ptr, 0 - item);
432 * @brief 杖を使うコマンドのメインルーチン /
434 void do_cmd_use_staff(player_type *creature_ptr)
439 if (creature_ptr->wild_mode) {
443 if (cmd_limit_arena(creature_ptr))
446 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN)) {
447 set_action(creature_ptr, ACTION_NONE);
450 q = _("どの杖を使いますか? ", "Use which staff? ");
451 s = _("使える杖がない。", "You have no staff to use.");
452 if (!choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_STAFF))
455 exe_use_staff(creature_ptr, item);