4 #include "spells-summon.h"
6 #include "player-status.h"
7 #include "player-effects.h"
9 #include "spells-status.h"
10 #include "spells-floor.h"
11 #include "object-hook.h"
12 #include "cmd-basic.h"
14 #include "objectkind.h"
20 * @param sval オブジェクトのsval
21 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
22 * @param powerful 強力発動上の処理ならばTRUE
23 * @param magic 魔道具術上の処理ならばTRUE
24 * @param known 判明済ならばTRUE
25 * @return 発動により効果内容が確定したならばTRUEを返す
27 int staff_effect(OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
31 PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
32 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
34 /* Analyze the staff */
37 case SV_STAFF_DARKNESS:
39 if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
41 if (set_blind(p_ptr->blind + 3 + randint1(5))) ident = TRUE;
43 if (unlite_area(10, (powerful ? 6 : 3))) ident = TRUE;
47 case SV_STAFF_SLOWNESS:
49 if (set_slow(p_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
53 case SV_STAFF_HASTE_MONSTERS:
55 if (speed_monsters()) ident = TRUE;
59 case SV_STAFF_SUMMONING:
61 const int times = randint1(powerful ? 8 : 4);
62 for (k = 0; k < times; k++)
64 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)))
72 case SV_STAFF_TELEPORTATION:
74 teleport_player((powerful ? 150 : 100), 0L);
79 case SV_STAFF_IDENTIFY:
82 if (!identify_fully(FALSE)) *use_charge = FALSE;
85 if (!ident_spell(FALSE)) *use_charge = FALSE;
91 case SV_STAFF_REMOVE_CURSE:
93 bool result = powerful ? remove_all_curse() : remove_curse();
101 case SV_STAFF_STARLITE:
102 ident = starlight(magic);
107 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
111 case SV_STAFF_MAPPING:
113 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
118 case SV_STAFF_DETECT_GOLD:
120 if (detect_treasure(detect_rad)) ident = TRUE;
121 if (detect_objects_gold(detect_rad)) ident = TRUE;
125 case SV_STAFF_DETECT_ITEM:
127 if (detect_objects_normal(detect_rad)) ident = TRUE;
131 case SV_STAFF_DETECT_TRAP:
133 if (detect_traps(detect_rad, known)) ident = TRUE;
137 case SV_STAFF_DETECT_DOOR:
139 if (detect_doors(detect_rad)) ident = TRUE;
140 if (detect_stairs(detect_rad)) ident = TRUE;
144 case SV_STAFF_DETECT_INVIS:
146 if (detect_monsters_invis(detect_rad)) ident = TRUE;
150 case SV_STAFF_DETECT_EVIL:
152 if (detect_monsters_evil(detect_rad)) ident = TRUE;
156 case SV_STAFF_CURE_LIGHT:
158 ident = cure_light_wounds((powerful ? 4 : 2), 8);
162 case SV_STAFF_CURING:
164 ident = true_healing(0);
165 if (set_shero(0, TRUE)) ident = TRUE;
169 case SV_STAFF_HEALING:
171 if (cure_critical_wounds(powerful ? 500 : 300)) ident = TRUE;
175 case SV_STAFF_THE_MAGI:
177 if (do_res_stat(A_INT)) ident = TRUE;
178 ident |= restore_mana(FALSE);
179 if (set_shero(0, TRUE)) ident = TRUE;
183 case SV_STAFF_SLEEP_MONSTERS:
185 if (sleep_monsters(lev)) ident = TRUE;
189 case SV_STAFF_SLOW_MONSTERS:
191 if (slow_monsters(lev)) ident = TRUE;
197 if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
201 case SV_STAFF_PROBING:
207 case SV_STAFF_DISPEL_EVIL:
209 ident = dispel_evil(powerful ? 120 : 80);
215 ident = dispel_monsters(powerful ? 225 : 150) ;
219 case SV_STAFF_HOLINESS:
221 ident = cleansing_nova(p_ptr, magic, powerful);
225 case SV_STAFF_GENOCIDE:
227 ident = symbol_genocide((magic ? lev + 50 : 200), TRUE);
231 case SV_STAFF_EARTHQUAKES:
233 if (earthquake(p_ptr->y, p_ptr->x, (powerful ? 15 : 10)))
236 msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
241 case SV_STAFF_DESTRUCTION:
243 ident = destroy_area(p_ptr->y, p_ptr->x, (powerful ? 18 : 13) + randint0(5), FALSE);
247 case SV_STAFF_ANIMATE_DEAD:
249 ident = animate_dead(0, p_ptr->y, p_ptr->x);
253 case SV_STAFF_MSTORM:
255 ident = unleash_mana_storm(p_ptr, powerful);
259 case SV_STAFF_NOTHING:
261 msg_print(_("何も起らなかった。", "Nothing happen."));
262 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_GOLEM) ||
263 prace_is_(RACE_ZOMBIE) || prace_is_(RACE_SPECTRE))
264 msg_print(_("もったいない事をしたような気がする。食べ物は大切にしなくては。", "What a waste. It's your food!"));
272 * @brief 杖を使うコマンドのサブルーチン /
274 * @param item 使うオブジェクトの所持品ID
277 * One charge of one staff disappears.
278 * Hack -- staffs of identify can be "cancelled".
280 void do_cmd_use_staff_aux(INVENTORY_IDX item)
282 int ident, chance, lev;
286 /* Hack -- let staffs of identify get aborted */
287 bool use_charge = TRUE;
290 /* Get the item (in the pack) */
293 o_ptr = &p_ptr->inventory_list[item];
296 /* Get the item (on the floor) */
299 o_ptr = ¤t_floor_ptr->o_list[0 - item];
303 /* Mega-Hack -- refuse to use a pile from the ground */
304 if ((item < 0) && (o_ptr->number > 1))
306 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
311 take_turn(p_ptr, 100);
313 /* Extract the item level */
314 lev = k_info[o_ptr->k_idx].level;
315 if (lev > 50) lev = 50 + (lev - 50) / 2;
317 /* Base chance of success */
318 chance = p_ptr->skill_dev;
320 /* Confusion hurts skill */
321 if (p_ptr->confused) chance = chance / 2;
323 /* Hight level objects are harder */
324 chance = chance - lev;
326 /* Give everyone a (slight) chance */
327 if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
332 if (cmd_limit_time_walk(p_ptr)) return;
335 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
337 if (flush_failure) flush();
338 msg_print(_("杖をうまく使えなかった。", "You failed to use the staff properly."));
343 /* Notice empty staffs */
344 if (o_ptr->pval <= 0)
346 if (flush_failure) flush();
347 msg_print(_("この杖にはもう魔力が残っていない。", "The staff has no charges left."));
348 o_ptr->ident |= (IDENT_EMPTY);
349 p_ptr->update |= (PU_COMBINE | PU_REORDER);
350 p_ptr->window |= (PW_INVEN);
358 ident = staff_effect(o_ptr->sval, &use_charge, FALSE, FALSE, object_is_aware(o_ptr));
360 if (!(object_is_aware(o_ptr)))
362 chg_virtue(V_PATIENCE, -1);
363 chg_virtue(V_CHANCE, 1);
364 chg_virtue(V_KNOWLEDGE, -1);
366 p_ptr->update |= (PU_COMBINE | PU_REORDER);
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);
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);