4 #include "player-race.h"
5 #include "spells-summon.h"
7 #include "player-status.h"
8 #include "player-effects.h"
10 #include "spells-status.h"
11 #include "spells-floor.h"
12 #include "object-hook.h"
13 #include "cmd-basic.h"
15 #include "objectkind.h"
16 #include "view-mainwindow.h"
22 * @param sval オブジェクトのsval
23 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
24 * @param powerful 強力発動上の処理ならばTRUE
25 * @param magic 魔道具術上の処理ならばTRUE
26 * @param known 判明済ならばTRUE
27 * @return 発動により効果内容が確定したならばTRUEを返す
29 int staff_effect(OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
33 PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
34 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
36 /* Analyze the staff */
39 case SV_STAFF_DARKNESS:
41 if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
43 if (set_blind(p_ptr->blind + 3 + randint1(5))) ident = TRUE;
45 if (unlite_area(10, (powerful ? 6 : 3))) ident = TRUE;
49 case SV_STAFF_SLOWNESS:
51 if (set_slow(p_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
55 case SV_STAFF_HASTE_MONSTERS:
57 if (speed_monsters()) ident = TRUE;
61 case SV_STAFF_SUMMONING:
63 const int times = randint1(powerful ? 8 : 4);
64 for (k = 0; k < times; k++)
66 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)))
74 case SV_STAFF_TELEPORTATION:
76 teleport_player((powerful ? 150 : 100), 0L);
81 case SV_STAFF_IDENTIFY:
84 if (!identify_fully(FALSE)) *use_charge = FALSE;
87 if (!ident_spell(FALSE)) *use_charge = FALSE;
93 case SV_STAFF_REMOVE_CURSE:
95 bool result = powerful ? remove_all_curse() : remove_curse();
103 case SV_STAFF_STARLITE:
104 ident = starlight(magic);
109 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
113 case SV_STAFF_MAPPING:
115 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
120 case SV_STAFF_DETECT_GOLD:
122 if (detect_treasure(detect_rad)) ident = TRUE;
123 if (detect_objects_gold(detect_rad)) ident = TRUE;
127 case SV_STAFF_DETECT_ITEM:
129 if (detect_objects_normal(detect_rad)) ident = TRUE;
133 case SV_STAFF_DETECT_TRAP:
135 if (detect_traps(detect_rad, known)) ident = TRUE;
139 case SV_STAFF_DETECT_DOOR:
141 if (detect_doors(detect_rad)) ident = TRUE;
142 if (detect_stairs(detect_rad)) ident = TRUE;
146 case SV_STAFF_DETECT_INVIS:
148 if (detect_monsters_invis(detect_rad)) ident = TRUE;
152 case SV_STAFF_DETECT_EVIL:
154 if (detect_monsters_evil(detect_rad)) ident = TRUE;
158 case SV_STAFF_CURE_LIGHT:
160 ident = cure_light_wounds((powerful ? 4 : 2), 8);
164 case SV_STAFF_CURING:
166 ident = true_healing(0);
167 if (set_shero(0, TRUE)) ident = TRUE;
171 case SV_STAFF_HEALING:
173 if (cure_critical_wounds(powerful ? 500 : 300)) ident = TRUE;
177 case SV_STAFF_THE_MAGI:
179 if (do_res_stat(A_INT)) ident = TRUE;
180 ident |= restore_mana(FALSE);
181 if (set_shero(0, TRUE)) ident = TRUE;
185 case SV_STAFF_SLEEP_MONSTERS:
187 if (sleep_monsters(lev)) ident = TRUE;
191 case SV_STAFF_SLOW_MONSTERS:
193 if (slow_monsters(lev)) ident = TRUE;
199 if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
203 case SV_STAFF_PROBING:
209 case SV_STAFF_DISPEL_EVIL:
211 ident = dispel_evil(powerful ? 120 : 80);
217 ident = dispel_monsters(powerful ? 225 : 150) ;
221 case SV_STAFF_HOLINESS:
223 ident = cleansing_nova(p_ptr, magic, powerful);
227 case SV_STAFF_GENOCIDE:
229 ident = symbol_genocide((magic ? lev + 50 : 200), TRUE);
233 case SV_STAFF_EARTHQUAKES:
235 if (earthquake(p_ptr->y, p_ptr->x, (powerful ? 15 : 10)))
238 msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
243 case SV_STAFF_DESTRUCTION:
245 ident = destroy_area(p_ptr->y, p_ptr->x, (powerful ? 18 : 13) + randint0(5), FALSE);
249 case SV_STAFF_ANIMATE_DEAD:
251 ident = animate_dead(0, p_ptr->y, p_ptr->x);
255 case SV_STAFF_MSTORM:
257 ident = unleash_mana_storm(p_ptr, powerful);
261 case SV_STAFF_NOTHING:
263 msg_print(_("何も起らなかった。", "Nothing happen."));
264 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_GOLEM) ||
265 prace_is_(RACE_ZOMBIE) || prace_is_(RACE_SPECTRE))
266 msg_print(_("もったいない事をしたような気がする。食べ物は大切にしなくては。", "What a waste. It's your food!"));
274 * @brief 杖を使うコマンドのサブルーチン /
276 * @param item 使うオブジェクトの所持品ID
279 * One charge of one staff disappears.
280 * Hack -- staffs of identify can be "cancelled".
282 void do_cmd_use_staff_aux(INVENTORY_IDX item)
284 int ident, chance, lev;
288 /* Hack -- let staffs of identify get aborted */
289 bool use_charge = TRUE;
292 /* Get the item (in the pack) */
295 o_ptr = &p_ptr->inventory_list[item];
298 /* Get the item (on the floor) */
301 o_ptr = ¤t_floor_ptr->o_list[0 - item];
305 /* Mega-Hack -- refuse to use a pile from the ground */
306 if ((item < 0) && (o_ptr->number > 1))
308 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
313 take_turn(p_ptr, 100);
315 /* Extract the item level */
316 lev = k_info[o_ptr->k_idx].level;
317 if (lev > 50) lev = 50 + (lev - 50) / 2;
319 /* Base chance of success */
320 chance = p_ptr->skill_dev;
322 /* Confusion hurts skill */
323 if (p_ptr->confused) chance = chance / 2;
325 /* Hight level objects are harder */
326 chance = chance - lev;
328 /* Give everyone a (slight) chance */
329 if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
334 if (cmd_limit_time_walk(p_ptr)) return;
337 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
339 if (flush_failure) flush();
340 msg_print(_("杖をうまく使えなかった。", "You failed to use the staff properly."));
345 /* Notice empty staffs */
346 if (o_ptr->pval <= 0)
348 if (flush_failure) flush();
349 msg_print(_("この杖にはもう魔力が残っていない。", "The staff has no charges left."));
350 o_ptr->ident |= (IDENT_EMPTY);
351 p_ptr->update |= (PU_COMBINE | PU_REORDER);
352 p_ptr->window |= (PW_INVEN);
360 ident = staff_effect(o_ptr->sval, &use_charge, FALSE, FALSE, object_is_aware(o_ptr));
362 if (!(object_is_aware(o_ptr)))
364 chg_virtue(V_PATIENCE, -1);
365 chg_virtue(V_CHANCE, 1);
366 chg_virtue(V_KNOWLEDGE, -1);
368 p_ptr->update |= (PU_COMBINE | PU_REORDER);
373 /* An identification was made */
374 if (ident && !object_is_aware(o_ptr))
377 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
380 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
383 /* Hack -- some uses are "free" */
384 if (!use_charge) return;
387 /* Use a single charge */
390 /* XXX Hack -- unstack if necessary */
391 if ((item >= 0) && (o_ptr->number > 1))
397 /* Obtain a local object */
398 object_copy(q_ptr, o_ptr);
400 /* Modify quantity */
403 /* Restore the charges */
406 /* Unstack the used item */
408 p_ptr->total_weight -= q_ptr->weight;
409 item = inven_carry(q_ptr);
411 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
414 /* Describe charges in the pack */
417 inven_item_charges(item);
420 /* Describe charges on the floor */
423 floor_item_charges(0 - item);
428 * @brief 杖を使うコマンドのメインルーチン /
431 void do_cmd_use_staff(void)
436 if (p_ptr->wild_mode)
441 if (cmd_limit_arena(p_ptr)) return;
443 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
445 set_action(ACTION_NONE);
448 /* Restrict choices to wands */
449 item_tester_tval = TV_STAFF;
451 q = _("どの杖を使いますか? ", "Use which staff? ");
452 s = _("使える杖がない。", "You have no staff to use.");
454 if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
456 do_cmd_use_staff_aux(item);