2 #include "projection.h"
3 #include "spells-summon.h"
5 #include "player-status.h"
6 #include "spells-status.h"
12 * @param sval オブジェクトのsval
13 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
14 * @param powerful 強力発動上の処理ならばTRUE
15 * @param magic 魔道具術上の処理ならばTRUE
16 * @param known 判明済ならばTRUE
17 * @return 発動により効果内容が確定したならばTRUEを返す
19 int staff_effect(OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
23 PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
24 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
26 /* Analyze the staff */
29 case SV_STAFF_DARKNESS:
31 if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
33 if (set_blind(p_ptr->blind + 3 + randint1(5))) ident = TRUE;
35 if (unlite_area(10, (powerful ? 6 : 3))) ident = TRUE;
39 case SV_STAFF_SLOWNESS:
41 if (set_slow(p_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
45 case SV_STAFF_HASTE_MONSTERS:
47 if (speed_monsters()) ident = TRUE;
51 case SV_STAFF_SUMMONING:
53 const int times = randint1(powerful ? 8 : 4);
54 for (k = 0; k < times; k++)
56 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0'))
64 case SV_STAFF_TELEPORTATION:
66 teleport_player((powerful ? 150 : 100), 0L);
71 case SV_STAFF_IDENTIFY:
74 if (!identify_fully(FALSE)) *use_charge = FALSE;
77 if (!ident_spell(FALSE)) *use_charge = FALSE;
83 case SV_STAFF_REMOVE_CURSE:
85 bool result = powerful ? remove_all_curse() : remove_curse();
93 case SV_STAFF_STARLITE:
94 ident = starlight(magic);
99 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
103 case SV_STAFF_MAPPING:
105 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
110 case SV_STAFF_DETECT_GOLD:
112 if (detect_treasure(detect_rad)) ident = TRUE;
113 if (detect_objects_gold(detect_rad)) ident = TRUE;
117 case SV_STAFF_DETECT_ITEM:
119 if (detect_objects_normal(detect_rad)) ident = TRUE;
123 case SV_STAFF_DETECT_TRAP:
125 if (detect_traps(detect_rad, known)) ident = TRUE;
129 case SV_STAFF_DETECT_DOOR:
131 if (detect_doors(detect_rad)) ident = TRUE;
132 if (detect_stairs(detect_rad)) ident = TRUE;
136 case SV_STAFF_DETECT_INVIS:
138 if (detect_monsters_invis(detect_rad)) ident = TRUE;
142 case SV_STAFF_DETECT_EVIL:
144 if (detect_monsters_evil(detect_rad)) ident = TRUE;
148 case SV_STAFF_CURE_LIGHT:
150 ident = cure_light_wounds((powerful ? 4 : 2), 8);
154 case SV_STAFF_CURING:
156 ident = true_healing(0);
157 if (set_shero(0, TRUE)) ident = TRUE;
161 case SV_STAFF_HEALING:
163 if (cure_critical_wounds(powerful ? 500 : 300)) ident = TRUE;
167 case SV_STAFF_THE_MAGI:
169 if (do_res_stat(A_INT)) ident = TRUE;
170 ident |= restore_mana(FALSE);
171 if (set_shero(0, TRUE)) ident = TRUE;
175 case SV_STAFF_SLEEP_MONSTERS:
177 if (sleep_monsters(lev)) ident = TRUE;
181 case SV_STAFF_SLOW_MONSTERS:
183 if (slow_monsters(lev)) ident = TRUE;
189 if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
193 case SV_STAFF_PROBING:
199 case SV_STAFF_DISPEL_EVIL:
201 ident = dispel_evil(powerful ? 120 : 80);
207 ident = dispel_monsters(powerful ? 225 : 150) ;
211 case SV_STAFF_HOLINESS:
213 ident = cleansing_nova(p_ptr, magic, powerful);
217 case SV_STAFF_GENOCIDE:
219 ident = symbol_genocide((magic ? lev + 50 : 200), TRUE);
223 case SV_STAFF_EARTHQUAKES:
225 if (earthquake(p_ptr->y, p_ptr->x, (powerful ? 15 : 10)))
228 msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
233 case SV_STAFF_DESTRUCTION:
235 ident = destroy_area(p_ptr->y, p_ptr->x, (powerful ? 18 : 13) + randint0(5), FALSE);
239 case SV_STAFF_ANIMATE_DEAD:
241 ident = animate_dead(0, p_ptr->y, p_ptr->x);
245 case SV_STAFF_MSTORM:
247 ident = unleash_mana_storm(p_ptr, powerful);
251 case SV_STAFF_NOTHING:
253 msg_print(_("何も起らなかった。", "Nothing happen."));
254 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_GOLEM) ||
255 prace_is_(RACE_ZOMBIE) || prace_is_(RACE_SPECTRE))
256 msg_print(_("もったいない事をしたような気がする。食べ物は大切にしなくては。", "What a waste. It's your food!"));
264 * @brief 杖を使うコマンドのサブルーチン /
266 * @param item 使うオブジェクトの所持品ID
269 * One charge of one staff disappears.
270 * Hack -- staffs of identify can be "cancelled".
272 void do_cmd_use_staff_aux(INVENTORY_IDX item)
274 int ident, chance, lev;
275 BIT_FLAGS inventory_flags;
279 /* Hack -- let staffs of identify get aborted */
280 bool use_charge = TRUE;
283 /* Get the item (in the pack) */
286 o_ptr = &inventory[item];
289 /* Get the item (on the floor) */
292 o_ptr = ¤t_floor_ptr->o_list[0 - item];
296 /* Mega-Hack -- refuse to use a pile from the ground */
297 if ((item < 0) && (o_ptr->number > 1))
299 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
304 take_turn(p_ptr, 100);
306 /* Extract the item level */
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 = p_ptr->skill_dev;
313 /* Confusion hurts skill */
314 if (p_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(p_ptr)) return;
328 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_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 p_ptr->update |= (PU_COMBINE | PU_REORDER);
343 p_ptr->window |= (PW_INVEN);
351 ident = staff_effect(o_ptr->sval, &use_charge, FALSE, FALSE, object_is_aware(o_ptr));
353 if (!(object_is_aware(o_ptr)))
355 chg_virtue(V_PATIENCE, -1);
356 chg_virtue(V_CHANCE, 1);
357 chg_virtue(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 inventory_flags = (PU_COMBINE | PU_REORDER |
365 (p_ptr->update & PU_AUTODESTROY));
366 p_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
371 /* An identification was made */
372 if (ident && !object_is_aware(o_ptr))
375 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
378 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
379 p_ptr->update |= inventory_flags;
381 /* Hack -- some uses are "free" */
382 if (!use_charge) return;
385 /* Use a single charge */
388 /* XXX Hack -- unstack if necessary */
389 if ((item >= 0) && (o_ptr->number > 1))
395 /* Obtain a local object */
396 object_copy(q_ptr, o_ptr);
398 /* Modify quantity */
401 /* Restore the charges */
404 /* Unstack the used item */
406 p_ptr->total_weight -= q_ptr->weight;
407 item = inven_carry(q_ptr);
409 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
412 /* Describe charges in the pack */
415 inven_item_charges(item);
418 /* Describe charges on the floor */
421 floor_item_charges(0 - item);
426 * @brief 杖を使うコマンドのメインルーチン /
429 void do_cmd_use_staff(void)
434 if (p_ptr->wild_mode)
439 if (cmd_limit_arena(p_ptr)) return;
441 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
443 set_action(ACTION_NONE);
446 /* Restrict choices to wands */
447 item_tester_tval = TV_STAFF;
449 q = _("どの杖を使いますか? ", "Use which staff? ");
450 s = _("使える杖がない。", "You have no staff to use.");
452 if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
454 do_cmd_use_staff_aux(item);