1 #include "cmd-item/cmd-usestaff.h"
2 #include "action/action-limited.h"
3 #include "floor/floor-object.h"
4 #include "monster-floor/monster-summon.h"
5 #include "monster-floor/place-monster-types.h"
6 #include "object-use/use-execution.h"
7 #include "object/item-tester-hooker.h"
8 #include "object/item-use-flags.h"
9 #include "player-base/player-class.h"
10 #include "player-base/player-race.h"
11 #include "player-info/class-info.h"
12 #include "player-info/race-info.h"
13 #include "player-info/race-types.h"
14 #include "player-info/samurai-data-type.h"
15 #include "player/attack-defense-types.h"
16 #include "player/player-status-flags.h"
17 #include "player/special-defense-types.h"
18 #include "spell-kind/earthquake.h"
19 #include "spell-kind/spells-curse-removal.h"
20 #include "spell-kind/spells-detection.h"
21 #include "spell-kind/spells-floor.h"
22 #include "spell-kind/spells-genocide.h"
23 #include "spell-kind/spells-lite.h"
24 #include "spell-kind/spells-neighbor.h"
25 #include "spell-kind/spells-perception.h"
26 #include "spell-kind/spells-sight.h"
27 #include "spell-kind/spells-teleport.h"
28 #include "spell/spells-staff-only.h"
29 #include "spell/spells-status.h"
30 #include "spell/spells-summon.h"
31 #include "spell/summon-types.h"
32 #include "status/action-setter.h"
33 #include "status/bad-status-setter.h"
34 #include "status/base-status.h"
35 #include "status/buff-setter.h"
36 #include "status/shape-changer.h"
37 #include "status/sight-setter.h"
38 #include "sv-definition/sv-staff-types.h"
39 #include "system/floor-type-definition.h"
40 #include "system/player-type-definition.h"
41 #include "view/display-messages.h"
45 * @param player_ptr プレイヤーへの参照ポインタ
46 * @param sval オブジェクトのsval
47 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
48 * @param powerful 強力発動上の処理ならばTRUE
49 * @param magic 魔道具術上の処理ならばTRUE
50 * @param known 判明済ならばTRUE
51 * @return 発動により効果内容が確定したならばTRUEを返す
53 int staff_effect(player_type *player_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
57 PLAYER_LEVEL lev = powerful ? player_ptr->lev * 2 : player_ptr->lev;
58 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
60 BadStatusSetter bss(player_ptr);
62 case SV_STAFF_DARKNESS:
63 if (!has_resist_blind(player_ptr) && !has_resist_dark(player_ptr)) {
64 if (bss.mod_blindness(3 + randint1(5))) {
69 if (unlite_area(player_ptr, 10, (powerful ? 6 : 3))) {
74 case SV_STAFF_SLOWNESS: {
75 if (bss.mod_slowness(randint1(30) + 15, false))
80 case SV_STAFF_HASTE_MONSTERS: {
81 if (speed_monsters(player_ptr))
86 case SV_STAFF_SUMMONING: {
87 const int times = randint1(powerful ? 8 : 4);
88 for (k = 0; k < times; k++) {
89 if (summon_specific(player_ptr, 0, player_ptr->y, player_ptr->x, player_ptr->current_floor_ptr->dun_level, SUMMON_NONE,
90 (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET))) {
97 case SV_STAFF_TELEPORTATION: {
98 teleport_player(player_ptr, (powerful ? 150 : 100), 0L);
103 case SV_STAFF_IDENTIFY: {
105 if (!identify_fully(player_ptr, false))
108 if (!ident_spell(player_ptr, false))
115 case SV_STAFF_REMOVE_CURSE: {
116 bool result = (powerful ? remove_all_curse(player_ptr) : remove_curse(player_ptr)) != 0;
123 case SV_STAFF_STARLITE:
124 ident = starlight(player_ptr, magic);
127 case SV_STAFF_LITE: {
128 if (lite_area(player_ptr, damroll(2, 8), (powerful ? 4 : 2)))
133 case SV_STAFF_MAPPING: {
134 map_area(player_ptr, powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
139 case SV_STAFF_DETECT_GOLD: {
140 if (detect_treasure(player_ptr, detect_rad))
142 if (detect_objects_gold(player_ptr, detect_rad))
147 case SV_STAFF_DETECT_ITEM: {
148 if (detect_objects_normal(player_ptr, detect_rad))
153 case SV_STAFF_DETECT_TRAP: {
154 if (detect_traps(player_ptr, detect_rad, known))
159 case SV_STAFF_DETECT_DOOR: {
160 if (detect_doors(player_ptr, detect_rad))
162 if (detect_stairs(player_ptr, detect_rad))
167 case SV_STAFF_DETECT_INVIS: {
168 if (set_tim_invis(player_ptr, player_ptr->tim_invis + 12 + randint1(12), false))
173 case SV_STAFF_DETECT_EVIL: {
174 if (detect_monsters_evil(player_ptr, detect_rad))
179 case SV_STAFF_CURE_LIGHT: {
180 ident = cure_light_wounds(player_ptr, (powerful ? 4 : 2), 8);
184 case SV_STAFF_CURING: {
185 ident = true_healing(player_ptr, 0);
186 if (set_shero(player_ptr, 0, true))
191 case SV_STAFF_HEALING: {
192 if (cure_critical_wounds(player_ptr, powerful ? 500 : 300))
197 case SV_STAFF_THE_MAGI: {
198 if (do_res_stat(player_ptr, A_INT))
200 ident |= restore_mana(player_ptr, false);
201 if (set_shero(player_ptr, 0, true))
206 case SV_STAFF_SLEEP_MONSTERS: {
207 if (sleep_monsters(player_ptr, lev))
212 case SV_STAFF_SLOW_MONSTERS: {
213 if (slow_monsters(player_ptr, lev))
218 case SV_STAFF_SPEED: {
219 if (set_fast(player_ptr, randint1(30) + (powerful ? 30 : 15), false))
224 case SV_STAFF_PROBING: {
225 ident = probing(player_ptr);
229 case SV_STAFF_DISPEL_EVIL: {
230 ident = dispel_evil(player_ptr, powerful ? 120 : 80);
234 case SV_STAFF_POWER: {
235 ident = dispel_monsters(player_ptr, powerful ? 225 : 150);
239 case SV_STAFF_HOLINESS: {
240 ident = cleansing_nova(player_ptr, magic, powerful);
244 case SV_STAFF_GENOCIDE: {
245 ident = symbol_genocide(player_ptr, (magic ? lev + 50 : 200), true);
249 case SV_STAFF_EARTHQUAKES: {
250 if (earthquake(player_ptr, player_ptr->y, player_ptr->x, (powerful ? 15 : 10), 0))
253 msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
258 case SV_STAFF_DESTRUCTION: {
259 ident = destroy_area(player_ptr, player_ptr->y, player_ptr->x, (powerful ? 18 : 13) + randint0(5), false);
263 case SV_STAFF_ANIMATE_DEAD: {
264 ident = animate_dead(player_ptr, 0, player_ptr->y, player_ptr->x);
268 case SV_STAFF_MSTORM: {
269 ident = unleash_mana_storm(player_ptr, powerful);
273 case SV_STAFF_NOTHING: {
274 msg_print(_("何も起らなかった。", "Nothing happens."));
275 if (PlayerRace(player_ptr).food() == PlayerRaceFoodType::MANA)
276 msg_print(_("もったいない事をしたような気がする。食べ物は大切にしなくては。", "What a waste. It's your food!"));
284 * @brief 杖を使うコマンドのメインルーチン /
286 void do_cmd_use_staff(player_type *player_ptr)
291 if (player_ptr->wild_mode) {
295 if (cmd_limit_arena(player_ptr))
298 PlayerClass(player_ptr).break_samurai_stance({ SamuraiStanceType::MUSOU, SamuraiStanceType::KOUKIJIN });
300 q = _("どの杖を使いますか? ", "Use which staff? ");
301 s = _("使える杖がない。", "You have no staff to use.");
302 if (!choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TvalItemTester(ItemKindType::STAFF)))
305 ObjectUseEntity(player_ptr, item).execute();