1 #include "system/angband.h"
3 #include "main/sound-definitions-table.h"
5 #include "spell/spells-summon.h"
6 #include "player/avatar.h"
7 #include "player/player-status.h"
8 #include "player/player-effects.h"
9 #include "player/player-class.h"
10 #include "inventory/player-inventory.h"
11 #include "spell/spells2.h"
12 #include "spell/spells3.h"
13 #include "spell/spells-status.h"
14 #include "spell/spells-floor.h"
15 #include "object/object-hook.h"
16 #include "cmd-basic.h"
17 #include "floor/floor.h"
18 #include "object/object-kind.h"
19 #include "object/special-object-flags.h"
20 #include "view/display-main-window.h"
21 #include "spell/spells-detection.h"
22 #include "player/player-races-table.h"
26 * @param creature_ptr プレーヤーへの参照ポインタ
27 * @param sval オブジェクトのsval
28 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
29 * @param powerful 強力発動上の処理ならばTRUE
30 * @param magic 魔道具術上の処理ならばTRUE
31 * @param known 判明済ならばTRUE
32 * @return 発動により効果内容が確定したならばTRUEを返す
34 int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
38 PLAYER_LEVEL lev = powerful ? creature_ptr->lev * 2 : creature_ptr->lev;
39 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
41 /* Analyze the staff */
44 case SV_STAFF_DARKNESS:
46 if (!(creature_ptr->resist_blind) && !(creature_ptr->resist_dark))
48 if (set_blind(creature_ptr, creature_ptr->blind + 3 + randint1(5))) ident = TRUE;
50 if (unlite_area(creature_ptr, 10, (powerful ? 6 : 3))) ident = TRUE;
54 case SV_STAFF_SLOWNESS:
56 if (set_slow(creature_ptr, creature_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
60 case SV_STAFF_HASTE_MONSTERS:
62 if (speed_monsters(creature_ptr)) ident = TRUE;
66 case SV_STAFF_SUMMONING:
68 const int times = randint1(powerful ? 8 : 4);
69 for (k = 0; k < times; k++)
71 if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
79 case SV_STAFF_TELEPORTATION:
81 teleport_player(creature_ptr, (powerful ? 150 : 100), 0L);
86 case SV_STAFF_IDENTIFY:
89 if (!identify_fully(creature_ptr, FALSE, 0)) *use_charge = FALSE;
92 if (!ident_spell(creature_ptr, FALSE, 0)) *use_charge = FALSE;
98 case SV_STAFF_REMOVE_CURSE:
100 bool result = powerful ? remove_all_curse(creature_ptr) : remove_curse(creature_ptr);
108 case SV_STAFF_STARLITE:
109 ident = starlight(creature_ptr, magic);
114 if (lite_area(creature_ptr, damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
118 case SV_STAFF_MAPPING:
120 map_area(creature_ptr, powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
125 case SV_STAFF_DETECT_GOLD:
127 if (detect_treasure(creature_ptr, detect_rad)) ident = TRUE;
128 if (detect_objects_gold(creature_ptr, detect_rad)) ident = TRUE;
132 case SV_STAFF_DETECT_ITEM:
134 if (detect_objects_normal(creature_ptr, detect_rad)) ident = TRUE;
138 case SV_STAFF_DETECT_TRAP:
140 if (detect_traps(creature_ptr, detect_rad, known)) ident = TRUE;
144 case SV_STAFF_DETECT_DOOR:
146 if (detect_doors(creature_ptr, detect_rad)) ident = TRUE;
147 if (detect_stairs(creature_ptr, detect_rad)) ident = TRUE;
151 case SV_STAFF_DETECT_INVIS:
153 if (detect_monsters_invis(creature_ptr, detect_rad)) ident = TRUE;
157 case SV_STAFF_DETECT_EVIL:
159 if (detect_monsters_evil(creature_ptr, detect_rad)) ident = TRUE;
163 case SV_STAFF_CURE_LIGHT:
165 ident = cure_light_wounds(creature_ptr, (powerful ? 4 : 2), 8);
169 case SV_STAFF_CURING:
171 ident = true_healing(creature_ptr, 0);
172 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
176 case SV_STAFF_HEALING:
178 if (cure_critical_wounds(creature_ptr, powerful ? 500 : 300)) ident = TRUE;
182 case SV_STAFF_THE_MAGI:
184 if (do_res_stat(creature_ptr, A_INT)) ident = TRUE;
185 ident |= restore_mana(creature_ptr, FALSE);
186 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
190 case SV_STAFF_SLEEP_MONSTERS:
192 if (sleep_monsters(creature_ptr, lev)) ident = TRUE;
196 case SV_STAFF_SLOW_MONSTERS:
198 if (slow_monsters(creature_ptr, lev)) ident = TRUE;
204 if (set_fast(creature_ptr, randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
208 case SV_STAFF_PROBING:
210 ident = probing(creature_ptr);
214 case SV_STAFF_DISPEL_EVIL:
216 ident = dispel_evil(creature_ptr, powerful ? 120 : 80);
222 ident = dispel_monsters(creature_ptr, powerful ? 225 : 150) ;
226 case SV_STAFF_HOLINESS:
228 ident = cleansing_nova(creature_ptr, magic, powerful);
232 case SV_STAFF_GENOCIDE:
234 ident = symbol_genocide(creature_ptr, (magic ? lev + 50 : 200), TRUE);
238 case SV_STAFF_EARTHQUAKES:
240 if (earthquake(creature_ptr, creature_ptr->y, creature_ptr->x, (powerful ? 15 : 10), 0))
243 msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
248 case SV_STAFF_DESTRUCTION:
250 ident = destroy_area(creature_ptr, creature_ptr->y, creature_ptr->x, (powerful ? 18 : 13) + randint0(5), FALSE);
254 case SV_STAFF_ANIMATE_DEAD:
256 ident = animate_dead(creature_ptr, 0, creature_ptr->y, creature_ptr->x);
260 case SV_STAFF_MSTORM:
262 ident = unleash_mana_storm(creature_ptr, powerful);
266 case SV_STAFF_NOTHING:
268 msg_print(_("何も起らなかった。", "Nothing happen."));
269 if (PRACE_IS_(creature_ptr, RACE_SKELETON) || PRACE_IS_(creature_ptr, RACE_GOLEM) ||
270 PRACE_IS_(creature_ptr, RACE_ZOMBIE) || PRACE_IS_(creature_ptr, RACE_SPECTRE))
271 msg_print(_("もったいない事をしたような気がする。食べ物は大切にしなくては。", "What a waste. It's your food!"));
280 * @brief 杖を使うコマンドのサブルーチン /
282 * @param item 使うオブジェクトの所持品ID
285 * One charge of one staff disappears.
286 * Hack -- staffs of identify can be "cancelled".
288 void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
290 int ident, chance, lev;
293 /* Hack -- let staffs of identify get aborted */
294 bool use_charge = TRUE;
296 o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
298 /* Mega-Hack -- refuse to use a pile from the ground */
299 if ((item < 0) && (o_ptr->number > 1))
301 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
305 take_turn(creature_ptr, 100);
307 lev = k_info[o_ptr->k_idx].level;
308 if (lev > 50) lev = 50 + (lev - 50) / 2;
310 /* Base chance of success */
311 chance = creature_ptr->skill_dev;
313 /* Confusion hurts skill */
314 if (creature_ptr->confused) chance = chance / 2;
316 /* Hight level objects are harder */
317 chance = chance - lev;
319 /* Give everyone a (slight) chance */
320 if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
325 if (cmd_limit_time_walk(creature_ptr)) return;
328 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (creature_ptr->pclass == CLASS_BERSERKER))
330 if (flush_failure) flush();
331 msg_print(_("杖をうまく使えなかった。", "You failed to use the staff properly."));
336 /* Notice empty staffs */
337 if (o_ptr->pval <= 0)
339 if (flush_failure) flush();
340 msg_print(_("この杖にはもう魔力が残っていない。", "The staff has no charges left."));
341 o_ptr->ident |= (IDENT_EMPTY);
342 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
343 creature_ptr->window |= (PW_INVEN);
350 ident = staff_effect(creature_ptr, o_ptr->sval, &use_charge, FALSE, FALSE, object_is_aware(o_ptr));
352 if (!(object_is_aware(o_ptr)))
354 chg_virtue(creature_ptr, V_PATIENCE, -1);
355 chg_virtue(creature_ptr, V_CHANCE, 1);
356 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
360 * Temporarily remove the flags for updating the inventory so
361 * gain_exp() does not reorder the inventory before the charge
362 * is deducted from the staff.
364 BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
365 creature_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
370 /* An identification was made */
371 if (ident && !object_is_aware(o_ptr))
373 object_aware(creature_ptr, o_ptr);
374 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
377 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
378 creature_ptr->update |= inventory_flags;
380 /* Hack -- some uses are "free" */
381 if (!use_charge) return;
384 /* Use a single charge */
387 /* XXX Hack -- unstack if necessary */
388 if ((item >= 0) && (o_ptr->number > 1))
393 object_copy(q_ptr, o_ptr);
395 /* Modify quantity */
398 /* Restore the charges */
401 /* Unstack the used item */
403 creature_ptr->total_weight -= q_ptr->weight;
404 item = inven_carry(creature_ptr, q_ptr);
406 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
409 /* Describe charges in the pack */
412 inven_item_charges(creature_ptr, item);
415 /* Describe charges on the floor */
418 floor_item_charges(creature_ptr->current_floor_ptr, 0 - item);
424 * @brief 杖を使うコマンドのメインルーチン /
427 void do_cmd_use_staff(player_type *creature_ptr)
432 if (creature_ptr->wild_mode)
437 if (cmd_limit_arena(creature_ptr)) return;
439 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
441 set_action(creature_ptr, ACTION_NONE);
444 q = _("どの杖を使いますか? ", "Use which staff? ");
445 s = _("使える杖がない。", "You have no staff to use.");
446 if (!choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_STAFF)) return;
448 exe_use_staff(creature_ptr, item);