4 #include "player-race.h"
5 #include "spells-summon.h"
7 #include "player-status.h"
8 #include "player-effects.h"
9 #include "player-class.h"
10 #include "player-inventory.h"
12 #include "spells-status.h"
13 #include "spells-floor.h"
14 #include "object-hook.h"
15 #include "cmd-basic.h"
17 #include "objectkind.h"
18 #include "view-mainwindow.h"
24 * @param sval オブジェクトのsval
25 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
26 * @param powerful 強力発動上の処理ならばTRUE
27 * @param magic 魔道具術上の処理ならばTRUE
28 * @param known 判明済ならばTRUE
29 * @return 発動により効果内容が確定したならばTRUEを返す
31 int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
35 PLAYER_LEVEL lev = powerful ? creature_ptr->lev * 2 : creature_ptr->lev;
36 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
38 /* Analyze the staff */
41 case SV_STAFF_DARKNESS:
43 if (!(creature_ptr->resist_blind) && !(creature_ptr->resist_dark))
45 if (set_blind(creature_ptr, creature_ptr->blind + 3 + randint1(5))) ident = TRUE;
47 if (unlite_area(10, (powerful ? 6 : 3))) ident = TRUE;
51 case SV_STAFF_SLOWNESS:
53 if (set_slow(creature_ptr, creature_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
57 case SV_STAFF_HASTE_MONSTERS:
59 if (speed_monsters()) ident = TRUE;
63 case SV_STAFF_SUMMONING:
65 const int times = randint1(powerful ? 8 : 4);
66 for (k = 0; k < times; k++)
68 if (summon_specific(0, creature_ptr->y, creature_ptr->x, current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
76 case SV_STAFF_TELEPORTATION:
78 teleport_player((powerful ? 150 : 100), 0L);
83 case SV_STAFF_IDENTIFY:
86 if (!identify_fully(FALSE)) *use_charge = FALSE;
89 if (!ident_spell(FALSE)) *use_charge = FALSE;
95 case SV_STAFF_REMOVE_CURSE:
97 bool result = powerful ? remove_all_curse() : remove_curse();
105 case SV_STAFF_STARLITE:
106 ident = starlight(magic);
111 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
115 case SV_STAFF_MAPPING:
117 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
122 case SV_STAFF_DETECT_GOLD:
124 if (detect_treasure(detect_rad)) ident = TRUE;
125 if (detect_objects_gold(detect_rad)) ident = TRUE;
129 case SV_STAFF_DETECT_ITEM:
131 if (detect_objects_normal(detect_rad)) ident = TRUE;
135 case SV_STAFF_DETECT_TRAP:
137 if (detect_traps(detect_rad, known)) ident = TRUE;
141 case SV_STAFF_DETECT_DOOR:
143 if (detect_doors(detect_rad)) ident = TRUE;
144 if (detect_stairs(detect_rad)) ident = TRUE;
148 case SV_STAFF_DETECT_INVIS:
150 if (detect_monsters_invis(detect_rad)) ident = TRUE;
154 case SV_STAFF_DETECT_EVIL:
156 if (detect_monsters_evil(detect_rad)) ident = TRUE;
160 case SV_STAFF_CURE_LIGHT:
162 ident = cure_light_wounds((powerful ? 4 : 2), 8);
166 case SV_STAFF_CURING:
168 ident = true_healing(0);
169 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
173 case SV_STAFF_HEALING:
175 if (cure_critical_wounds(powerful ? 500 : 300)) ident = TRUE;
179 case SV_STAFF_THE_MAGI:
181 if (do_res_stat(creature_ptr, A_INT)) ident = TRUE;
182 ident |= restore_mana(creature_ptr, FALSE);
183 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
187 case SV_STAFF_SLEEP_MONSTERS:
189 if (sleep_monsters(lev)) ident = TRUE;
193 case SV_STAFF_SLOW_MONSTERS:
195 if (slow_monsters(lev)) ident = TRUE;
201 if (set_fast(creature_ptr, randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
205 case SV_STAFF_PROBING:
211 case SV_STAFF_DISPEL_EVIL:
213 ident = dispel_evil(powerful ? 120 : 80);
219 ident = dispel_monsters(powerful ? 225 : 150) ;
223 case SV_STAFF_HOLINESS:
225 ident = cleansing_nova(creature_ptr, magic, powerful);
229 case SV_STAFF_GENOCIDE:
231 ident = symbol_genocide((magic ? lev + 50 : 200), TRUE);
235 case SV_STAFF_EARTHQUAKES:
237 if (earthquake(creature_ptr->y, creature_ptr->x, (powerful ? 15 : 10), 0))
240 msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
245 case SV_STAFF_DESTRUCTION:
247 ident = destroy_area(creature_ptr->y, creature_ptr->x, (powerful ? 18 : 13) + randint0(5), FALSE);
251 case SV_STAFF_ANIMATE_DEAD:
253 ident = animate_dead(0, creature_ptr->y, creature_ptr->x);
257 case SV_STAFF_MSTORM:
259 ident = unleash_mana_storm(creature_ptr, powerful);
263 case SV_STAFF_NOTHING:
265 msg_print(_("何も起らなかった。", "Nothing happen."));
266 if (PRACE_IS_(creature_ptr, RACE_SKELETON) || PRACE_IS_(creature_ptr, RACE_GOLEM) ||
267 PRACE_IS_(creature_ptr, RACE_ZOMBIE) || PRACE_IS_(creature_ptr, RACE_SPECTRE))
268 msg_print(_("もったいない事をしたような気がする。食べ物は大切にしなくては。", "What a waste. It's your food!"));
276 * @brief 杖を使うコマンドのサブルーチン /
278 * @param item 使うオブジェクトの所持品ID
281 * One charge of one staff disappears.
282 * Hack -- staffs of identify can be "cancelled".
284 void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
286 int ident, chance, lev;
290 /* Hack -- let staffs of identify get aborted */
291 bool use_charge = TRUE;
293 o_ptr = REF_ITEM(creature_ptr, current_floor_ptr, item);
295 /* Mega-Hack -- refuse to use a pile from the ground */
296 if ((item < 0) && (o_ptr->number > 1))
298 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
303 take_turn(creature_ptr, 100);
305 lev = k_info[o_ptr->k_idx].level;
306 if (lev > 50) lev = 50 + (lev - 50) / 2;
308 /* Base chance of success */
309 chance = creature_ptr->skill_dev;
311 /* Confusion hurts skill */
312 if (creature_ptr->confused) chance = chance / 2;
314 /* Hight level objects are harder */
315 chance = chance - lev;
317 /* Give everyone a (slight) chance */
318 if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
323 if (cmd_limit_time_walk(creature_ptr)) return;
326 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (creature_ptr->pclass == CLASS_BERSERKER))
328 if (flush_failure) flush();
329 msg_print(_("杖をうまく使えなかった。", "You failed to use the staff properly."));
334 /* Notice empty staffs */
335 if (o_ptr->pval <= 0)
337 if (flush_failure) flush();
338 msg_print(_("この杖にはもう魔力が残っていない。", "The staff has no charges left."));
339 o_ptr->ident |= (IDENT_EMPTY);
340 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
341 creature_ptr->window |= (PW_INVEN);
349 ident = staff_effect(creature_ptr, o_ptr->sval, &use_charge, FALSE, FALSE, object_is_aware(o_ptr));
351 if (!(object_is_aware(o_ptr)))
353 chg_virtue(creature_ptr, V_PATIENCE, -1);
354 chg_virtue(creature_ptr, V_CHANCE, 1);
355 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
357 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
362 /* An identification was made */
363 if (ident && !object_is_aware(o_ptr))
366 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
369 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
372 /* Hack -- some uses are "free" */
373 if (!use_charge) return;
376 /* Use a single charge */
379 /* XXX Hack -- unstack if necessary */
380 if ((item >= 0) && (o_ptr->number > 1))
385 object_copy(q_ptr, o_ptr);
387 /* Modify quantity */
390 /* Restore the charges */
393 /* Unstack the used item */
395 creature_ptr->total_weight -= q_ptr->weight;
396 item = inven_carry(q_ptr);
398 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
401 /* Describe charges in the pack */
404 inven_item_charges(item);
407 /* Describe charges on the floor */
410 floor_item_charges(0 - item);
415 * @brief 杖を使うコマンドのメインルーチン /
418 void do_cmd_use_staff(player_type *creature_ptr)
423 if (creature_ptr->wild_mode)
428 if (cmd_limit_arena(creature_ptr)) return;
430 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
432 set_action(creature_ptr, ACTION_NONE);
435 q = _("どの杖を使いますか? ", "Use which staff? ");
436 s = _("使える杖がない。", "You have no staff to use.");
437 if (!choose_object(p_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_STAFF)) return;
439 exe_use_staff(creature_ptr, item);