2 #include "core/stuff-handler.h"
5 #include "io/write-diary.h"
6 #include "cmd/cmd-dump.h"
11 #include "player-move.h"
12 #include "player-status.h"
13 #include "player-effects.h"
14 #include "player-skill.h"
15 #include "player-class.h"
16 #include "player-damage.h"
17 #include "object-hook.h"
19 #include "monster-status.h"
21 #include "cmd-basic.h"
22 #include "view/display-main-window.h"
23 #include "targeting.h"
24 #include "world/world.h"
25 #include "effect/spells-effect-util.h"
27 int total_friends = 0;
30 * @brief プレイヤーの騎乗/下馬処理判定
31 * @param g_ptr プレイヤーの移動先マスの構造体参照ポインタ
32 * @param now_riding TRUEなら下馬処理、FALSEならば騎乗処理
33 * @return 可能ならばTRUEを返す
35 bool player_can_ride_aux(player_type *creature_ptr, grid_type *g_ptr, bool now_riding)
38 bool old_character_xtra = current_world_ptr->character_xtra;
39 MONSTER_IDX old_riding = creature_ptr->riding;
40 bool old_riding_ryoute = creature_ptr->riding_ryoute;
41 bool old_old_riding_ryoute = creature_ptr->old_riding_ryoute;
42 bool old_pf_ryoute = (creature_ptr->pet_extra_flags & PF_TWO_HANDS) ? TRUE : FALSE;
44 /* Hack -- prevent "icky" message */
45 current_world_ptr->character_xtra = TRUE;
47 if (now_riding) creature_ptr->riding = g_ptr->m_idx;
50 creature_ptr->riding = 0;
51 creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
52 creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
55 creature_ptr->update |= PU_BONUS;
56 handle_stuff(creature_ptr);
58 p_can_enter = player_can_enter(creature_ptr, g_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
60 creature_ptr->riding = old_riding;
61 if (old_pf_ryoute) creature_ptr->pet_extra_flags |= (PF_TWO_HANDS);
62 else creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
63 creature_ptr->riding_ryoute = old_riding_ryoute;
64 creature_ptr->old_riding_ryoute = old_old_riding_ryoute;
66 creature_ptr->update |= PU_BONUS;
67 handle_stuff(creature_ptr);
69 current_world_ptr->character_xtra = old_character_xtra;
75 * @brief ペットを開放するコマンドのメインルーチン
78 void do_cmd_pet_dismiss(player_type *creature_ptr)
81 bool all_pets = FALSE;
96 /* Allocate the "who" array */
97 C_MAKE(who, current_world_ptr->max_m_idx, MONSTER_IDX);
99 /* Process the monsters (backwards) */
100 for (pet_ctr = creature_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
102 if (is_pet(&creature_ptr->current_floor_ptr->m_list[pet_ctr]))
103 who[max_pet++] = pet_ctr;
106 ang_sort(who, &dummy_why, max_pet, ang_sort_comp_pet_dismiss, ang_sort_swap_hook);
108 /* Process the monsters (backwards) */
109 for (i = 0; i < max_pet; i++)
112 GAME_TEXT friend_name[MAX_NLEN];
116 m_ptr = &creature_ptr->current_floor_ptr->m_list[pet_ctr];
119 kakunin = ((pet_ctr == creature_ptr->riding) || (m_ptr->nickname));
120 monster_desc(creature_ptr, friend_name, m_ptr, MD_ASSUME_VISIBLE);
124 /* Hack -- health bar for this monster */
125 health_track(creature_ptr, pet_ctr);
126 handle_stuff(creature_ptr);
128 msg_format(_("%sを放しますか? [Yes/No/Unnamed (%d体)]", "Dismiss %s? [Yes/No/Unnamed (%d remain)]"), friend_name, max_pet - i);
131 move_cursor_relative(m_ptr->fy, m_ptr->fx);
137 if (ch == 'Y' || ch == 'y')
143 msg_format(_("本当によろしいですか? (%s) ", "Are you sure? (%s) "), friend_name);
145 if (ch != 'Y' && ch != 'y')
151 if (ch == 'U' || ch == 'u')
157 if (ch == ESCAPE || ch == 'N' || ch == 'n')
164 if ((all_pets && !kakunin) || (!all_pets && delete_this))
166 if (record_named_pet && m_ptr->nickname)
168 GAME_TEXT m_name[MAX_NLEN];
170 monster_desc(creature_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
171 exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_DISMISS, m_name);
174 if (pet_ctr == creature_ptr->riding)
176 msg_format(_("%sから降りた。", "You have got off %s. "), friend_name);
178 creature_ptr->riding = 0;
180 creature_ptr->update |= (PU_MONSTERS);
181 creature_ptr->redraw |= (PR_EXTRA | PR_UHEALTH);
184 /* HACK : Add the line to message buffer */
185 msg_format(_("%s を放した。", "Dismissed %s."), friend_name);
186 creature_ptr->update |= (PU_BONUS);
187 creature_ptr->window |= (PW_MESSAGE);
189 delete_monster_idx(creature_ptr, pet_ctr);
198 C_KILL(who, current_world_ptr->max_m_idx, MONSTER_IDX);
201 msg_format("%d 体のペットを放しました。", Dismissed);
203 msg_format("You have dismissed %d pet%s.", Dismissed,
204 (Dismissed == 1 ? "" : "s"));
206 if (Dismissed == 0 && all_pets)
207 msg_print(_("'U'nnamed は、乗馬以外の名前のないペットだけを全て解放します。", "'U'nnamed means all your pets except named pets and your mount."));
209 handle_stuff(creature_ptr);
215 * @brief ペットから騎乗/下馬するコマンドのメインルーチン /
216 * @param force 強制的に騎乗/下馬するならばTRUE
217 * @return 騎乗/下馬できたらTRUE
219 bool do_cmd_riding(player_type *creature_ptr, bool force)
226 if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
227 y = creature_ptr->y + ddy[dir];
228 x = creature_ptr->x + ddx[dir];
229 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
231 if (creature_ptr->special_defense & KATA_MUSOU) set_action(creature_ptr, ACTION_NONE);
233 if (creature_ptr->riding)
235 /* Skip non-empty grids */
236 if (!player_can_ride_aux(creature_ptr, g_ptr, FALSE))
238 msg_print(_("そちらには降りられません。", "You cannot go that direction."));
242 if (!pattern_seq(creature_ptr, creature_ptr->y, creature_ptr->x, y, x)) return FALSE;
246 take_turn(creature_ptr, 100);
248 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
250 py_attack(creature_ptr, y, x, 0);
254 creature_ptr->riding = 0;
255 creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
256 creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
260 if (cmd_limit_confused(creature_ptr)) return FALSE;
262 m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
264 if (!g_ptr->m_idx || !m_ptr->ml)
266 msg_print(_("その場所にはモンスターはいません。", "There is no monster here."));
269 if (!is_pet(m_ptr) && !force)
271 msg_print(_("そのモンスターはペットではありません。", "That monster is not a pet."));
274 if (!(r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
276 msg_print(_("そのモンスターには乗れなさそうだ。", "This monster doesn't seem suitable for riding."));
280 if (!pattern_seq(creature_ptr, creature_ptr->y, creature_ptr->x, y, x)) return FALSE;
282 if (!player_can_ride_aux(creature_ptr, g_ptr, TRUE))
284 /* Feature code (applying "mimic" field) */
285 feature_type *f_ptr = &f_info[get_feat_mimic(g_ptr)];
287 msg_format("そのモンスターは%sの%sにいる。", f_name + f_ptr->name,
288 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
289 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
292 msg_format("This monster is %s the %s.",
293 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
294 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
295 "in" : "on", f_name + f_ptr->name);
300 if (r_info[m_ptr->r_idx].level > randint1((creature_ptr->skill_exp[GINOU_RIDING] / 50 + creature_ptr->lev / 2 + 20)))
302 msg_print(_("うまく乗れなかった。", "You failed to ride."));
303 take_turn(creature_ptr, 100);
307 if (MON_CSLEEP(m_ptr))
309 GAME_TEXT m_name[MAX_NLEN];
310 monster_desc(creature_ptr, m_name, m_ptr, 0);
311 (void)set_monster_csleep(creature_ptr, g_ptr->m_idx, 0);
312 msg_format(_("%sを起こした。", "You have woken %s up."), m_name);
315 if (creature_ptr->action == ACTION_KAMAE) set_action(creature_ptr, ACTION_NONE);
317 creature_ptr->riding = g_ptr->m_idx;
319 /* Hack -- remove tracked monster */
320 if (creature_ptr->riding == creature_ptr->health_who) health_track(creature_ptr, 0);
323 take_turn(creature_ptr, 100);
325 /* Mega-Hack -- Forget the view and lite */
326 creature_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
327 creature_ptr->update |= (PU_BONUS);
328 creature_ptr->redraw |= (PR_MAP | PR_EXTRA);
329 creature_ptr->redraw |= (PR_UHEALTH);
331 (void)move_player_effect(creature_ptr, y, x, MPE_HANDLE_STUFF | MPE_ENERGY_USE | MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
337 * @brief ペットに名前をつけるコマンドのメインルーチン
340 static void do_name_pet(player_type *creature_ptr)
344 GAME_TEXT m_name[MAX_NLEN];
345 bool old_name = FALSE;
346 bool old_target_pet = target_pet;
349 if (!target_set(creature_ptr, TARGET_KILL))
351 target_pet = old_target_pet;
355 target_pet = old_target_pet;
357 if (creature_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx)
359 m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx];
363 msg_print(_("そのモンスターはペットではない。", "This monster is not a pet."));
366 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
368 msg_print(_("そのモンスターの名前は変えられない!", "You cannot change name of this monster!"));
371 monster_desc(creature_ptr, m_name, m_ptr, 0);
373 msg_format(_("%sに名前をつける。", "Name %s."), m_name);
376 /* Start with nothing */
379 /* Use old inscription */
382 /* Start with the old inscription */
383 strcpy(out_val, quark_str(m_ptr->nickname));
387 /* Get a new inscription (possibly empty) */
388 if (get_string(_("名前: ", "Name: "), out_val, 15))
392 /* Save the inscription */
393 m_ptr->nickname = quark_add(out_val);
394 if (record_named_pet)
396 monster_desc(creature_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
397 exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_NAME, m_name);
402 if (record_named_pet && old_name)
404 monster_desc(creature_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
405 exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_UNNAME, m_name);
415 * @brief ペットに関するコマンドリストのメインルーチン /
416 * Issue a pet command
419 void do_cmd_pet(player_type *creature_ptr)
424 concptr power_desc[36];
431 PET_COMMAND_IDX mode = 0;
434 char target_buf[160];
436 int menu_line = use_menu ? 1 : 0;
440 if (creature_ptr->wild_mode) return;
442 power_desc[num] = _("ペットを放す", "dismiss pets");
443 powers[num++] = PET_DISMISS;
446 sprintf(target_buf, "ペットのターゲットを指定 (現在:%s)",
447 (creature_ptr->pet_t_m_idx ? (creature_ptr->image ? "何か奇妙な物" : (r_name + r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->pet_t_m_idx].ap_r_idx].name)) : "指定なし"));
449 sprintf(target_buf, "specify a target of pet (now:%s)",
450 (creature_ptr->pet_t_m_idx ? (creature_ptr->image ? "something strange" : (r_name + r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->pet_t_m_idx].ap_r_idx].name)) : "nothing"));
452 power_desc[num] = target_buf;
453 powers[num++] = PET_TARGET;
454 power_desc[num] = _("近くにいろ", "stay close");
456 if (creature_ptr->pet_follow_distance == PET_CLOSE_DIST) mode = num;
457 powers[num++] = PET_STAY_CLOSE;
458 power_desc[num] = _("ついて来い", "follow me");
460 if (creature_ptr->pet_follow_distance == PET_FOLLOW_DIST) mode = num;
461 powers[num++] = PET_FOLLOW_ME;
462 power_desc[num] = _("敵を見つけて倒せ", "seek and destroy");
464 if (creature_ptr->pet_follow_distance == PET_DESTROY_DIST) mode = num;
465 powers[num++] = PET_SEEK_AND_DESTROY;
466 power_desc[num] = _("少し離れていろ", "give me space");
468 if (creature_ptr->pet_follow_distance == PET_SPACE_DIST) mode = num;
469 powers[num++] = PET_ALLOW_SPACE;
470 power_desc[num] = _("離れていろ", "stay away");
472 if (creature_ptr->pet_follow_distance == PET_AWAY_DIST) mode = num;
473 powers[num++] = PET_STAY_AWAY;
475 if (creature_ptr->pet_extra_flags & PF_OPEN_DOORS)
477 power_desc[num] = _("ドアを開ける (現在:ON)", "pets open doors (now On)");
481 power_desc[num] = _("ドアを開ける (現在:OFF)", "pets open doors (now Off)");
483 powers[num++] = PET_OPEN_DOORS;
485 if (creature_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
487 power_desc[num] = _("アイテムを拾う (現在:ON)", "pets pick up items (now On)");
491 power_desc[num] = _("アイテムを拾う (現在:OFF)", "pets pick up items (now Off)");
493 powers[num++] = PET_TAKE_ITEMS;
495 if (creature_ptr->pet_extra_flags & PF_TELEPORT)
497 power_desc[num] = _("テレポート系魔法を使う (現在:ON)", "allow teleport (now On)");
501 power_desc[num] = _("テレポート系魔法を使う (現在:OFF)", "allow teleport (now Off)");
503 powers[num++] = PET_TELEPORT;
505 if (creature_ptr->pet_extra_flags & PF_ATTACK_SPELL)
507 power_desc[num] = _("攻撃魔法を使う (現在:ON)", "allow cast attack spell (now On)");
511 power_desc[num] = _("攻撃魔法を使う (現在:OFF)", "allow cast attack spell (now Off)");
513 powers[num++] = PET_ATTACK_SPELL;
515 if (creature_ptr->pet_extra_flags & PF_SUMMON_SPELL)
517 power_desc[num] = _("召喚魔法を使う (現在:ON)", "allow cast summon spell (now On)");
521 power_desc[num] = _("召喚魔法を使う (現在:OFF)", "allow cast summon spell (now Off)");
523 powers[num++] = PET_SUMMON_SPELL;
525 if (creature_ptr->pet_extra_flags & PF_BALL_SPELL)
527 power_desc[num] = _("プレイヤーを巻き込む範囲魔法を使う (現在:ON)", "allow involve player in area spell (now On)");
531 power_desc[num] = _("プレイヤーを巻き込む範囲魔法を使う (現在:OFF)", "allow involve player in area spell (now Off)");
533 powers[num++] = PET_BALL_SPELL;
535 if (creature_ptr->riding)
537 power_desc[num] = _("ペットから降りる", "get off a pet");
541 power_desc[num] = _("ペットに乗る", "ride a pet");
543 powers[num++] = PET_RIDING;
544 power_desc[num] = _("ペットに名前をつける", "name pets");
545 powers[num++] = PET_NAME;
547 if (creature_ptr->riding)
549 if ((creature_ptr->migite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) &&
550 object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) ||
551 (creature_ptr->hidarite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) &&
552 object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])))
554 if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
556 power_desc[num] = _("武器を片手で持つ", "use one hand to control the pet you are riding");
560 power_desc[num] = _("武器を両手で持つ", "use both hands for a weapon");
563 powers[num++] = PET_TWO_HANDS;
567 switch (creature_ptr->pclass)
570 case CLASS_FORCETRAINER:
571 case CLASS_BERSERKER:
572 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
574 if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
576 power_desc[num] = _("片手で格闘する", "use one hand to control the pet you are riding");
580 power_desc[num] = _("両手で格闘する", "use both hands for melee");
583 powers[num++] = PET_TWO_HANDS;
585 else if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
587 if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
589 power_desc[num] = _("格闘を行わない", "use one hand to control the pet you are riding");
593 power_desc[num] = _("格闘を行う", "use one hand for melee");
596 powers[num++] = PET_TWO_HANDS;
603 if (!(repeat_pull(&i) && (i >= 0) && (i < num)))
611 strnfmt(out_val, 78, _("(コマンド、ESC=終了) コマンドを選んでください:", "(Command, ESC=exit) Choose command from menu."));
616 _("(コマンド %c-%c、'*'=一覧、ESC=終了) コマンドを選んでください:", "(Command %c-%c, *=List, ESC=exit) Select a command: "),
617 I2A(0), I2A(num - 1));
620 choice = (always_show_list || use_menu) ? ESCAPE : 1;
622 /* Get a command from the user */
627 if (choice == ESCAPE) choice = ' ';
628 else if (!get_com(out_val, &choice, TRUE)) break;
630 if (use_menu && (choice != ' '))
641 menu_line += (num - 1);
670 if (menu_line > num) menu_line -= num;
674 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
677 if (!redraw || use_menu)
680 PET_COMMAND_IDX ctr = 0;
682 if (!use_menu) screen_save();
687 for (ctr = 0; ctr < num; ctr++)
689 /* Letter/number for power selection */
691 sprintf(buf, "%c%s ", (ctr == mode) ? '*' : ' ', (ctr == (menu_line - 1)) ? _("》", "> ") : " ");
693 sprintf(buf, "%c%c) ", (ctr == mode) ? '*' : ' ', I2A(ctr));
695 strcat(buf, power_desc[ctr]);
697 prt(buf, y + ctr, x);
700 prt("", y + MIN(ctr, 17), x);
718 ask = (isupper(choice));
721 if (ask) choice = (char)tolower(choice);
723 /* Extract request */
724 i = (islower(choice) ? A2I(choice) : -1);
727 /* Totally Illegal */
728 if ((i < 0) || (i >= num))
738 strnfmt(buf, 78, _("%sを使いますか? ", "Use %s? "), power_desc[i]);
740 /* Belay that order */
741 if (!get_check(buf)) continue;
747 if (redraw) screen_load();
749 /* Abort if needed */
752 free_turn(creature_ptr);
760 case PET_DISMISS: /* Dismiss pets */
762 /* Check pets (backwards) */
763 for (pet_ctr = creature_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
766 if (is_pet(&creature_ptr->current_floor_ptr->m_list[pet_ctr])) break;
771 msg_print(_("ペットがいない!", "You have no pets!"));
774 do_cmd_pet_dismiss(creature_ptr);
775 (void)calculate_upkeep(creature_ptr);
781 if (!target_set(creature_ptr, TARGET_KILL)) creature_ptr->pet_t_m_idx = 0;
784 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[target_row][target_col];
785 if (g_ptr->m_idx && (creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml))
787 creature_ptr->pet_t_m_idx = creature_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
788 creature_ptr->pet_follow_distance = PET_DESTROY_DIST;
790 else creature_ptr->pet_t_m_idx = 0;
799 creature_ptr->pet_follow_distance = PET_CLOSE_DIST;
800 creature_ptr->pet_t_m_idx = 0;
806 creature_ptr->pet_follow_distance = PET_FOLLOW_DIST;
807 creature_ptr->pet_t_m_idx = 0;
810 /* "Seek and destoy" */
811 case PET_SEEK_AND_DESTROY:
813 creature_ptr->pet_follow_distance = PET_DESTROY_DIST;
816 /* "Give me space" */
817 case PET_ALLOW_SPACE:
819 creature_ptr->pet_follow_distance = PET_SPACE_DIST;
825 creature_ptr->pet_follow_distance = PET_AWAY_DIST;
828 /* flag - allow pets to open doors */
831 if (creature_ptr->pet_extra_flags & PF_OPEN_DOORS) creature_ptr->pet_extra_flags &= ~(PF_OPEN_DOORS);
832 else creature_ptr->pet_extra_flags |= (PF_OPEN_DOORS);
835 /* flag - allow pets to pickup items */
838 if (creature_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
840 creature_ptr->pet_extra_flags &= ~(PF_PICKUP_ITEMS);
841 for (pet_ctr = creature_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
843 m_ptr = &creature_ptr->current_floor_ptr->m_list[pet_ctr];
847 monster_drop_carried_objects(creature_ptr, m_ptr);
851 else creature_ptr->pet_extra_flags |= (PF_PICKUP_ITEMS);
855 /* flag - allow pets to teleport */
858 if (creature_ptr->pet_extra_flags & PF_TELEPORT) creature_ptr->pet_extra_flags &= ~(PF_TELEPORT);
859 else creature_ptr->pet_extra_flags |= (PF_TELEPORT);
862 /* flag - allow pets to cast attack spell */
863 case PET_ATTACK_SPELL:
865 if (creature_ptr->pet_extra_flags & PF_ATTACK_SPELL) creature_ptr->pet_extra_flags &= ~(PF_ATTACK_SPELL);
866 else creature_ptr->pet_extra_flags |= (PF_ATTACK_SPELL);
869 /* flag - allow pets to cast attack spell */
870 case PET_SUMMON_SPELL:
872 if (creature_ptr->pet_extra_flags & PF_SUMMON_SPELL) creature_ptr->pet_extra_flags &= ~(PF_SUMMON_SPELL);
873 else creature_ptr->pet_extra_flags |= (PF_SUMMON_SPELL);
876 /* flag - allow pets to cast attack spell */
879 if (creature_ptr->pet_extra_flags & PF_BALL_SPELL) creature_ptr->pet_extra_flags &= ~(PF_BALL_SPELL);
880 else creature_ptr->pet_extra_flags |= (PF_BALL_SPELL);
886 (void)do_cmd_riding(creature_ptr, FALSE);
892 do_name_pet(creature_ptr);
898 if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
899 else creature_ptr->pet_extra_flags |= (PF_TWO_HANDS);
900 creature_ptr->update |= (PU_BONUS);
901 handle_stuff(creature_ptr);
909 * @brief プレイヤーの落馬判定処理
910 * @param dam 落馬判定を発した際に受けたダメージ量
911 * @param force TRUEならば強制的に落馬する
912 * @return 実際に落馬したらTRUEを返す
914 bool rakuba(player_type *creature_ptr, HIT_POINT dam, bool force)
917 POSITION y, x, oy, ox, sy = 0, sx = 0;
919 GAME_TEXT m_name[MAX_NLEN];
920 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
921 monster_race *r_ptr = &r_info[m_ptr->r_idx];
922 bool fall_dam = FALSE;
924 if (!creature_ptr->riding) return FALSE;
925 if (creature_ptr->wild_mode) return FALSE;
927 if (dam >= 0 || force)
931 int cur = creature_ptr->skill_exp[GINOU_RIDING];
932 int max = s_info[creature_ptr->pclass].s_max[GINOU_RIDING];
933 int ridinglevel = r_ptr->level;
936 int rakubalevel = r_ptr->level;
937 if (creature_ptr->riding_ryoute) rakubalevel += 20;
939 if ((cur < max) && (max > 1000) &&
940 (dam / 2 + ridinglevel) > (cur / 30 + 10))
944 if (ridinglevel > (cur / 100 + 15))
945 inc += 1 + (ridinglevel - cur / 100 - 15);
949 creature_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
952 /* レベルの低い乗馬からは落馬しにくい */
953 if (randint0(dam / 2 + rakubalevel * 2) < cur / 30 + 10)
955 if ((((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) && !creature_ptr->riding_ryoute) || !one_in_(creature_ptr->lev*(creature_ptr->riding_ryoute ? 2 : 3) + 30))
962 /* Check around the player */
963 for (i = 0; i < 8; i++)
967 y = creature_ptr->y + ddy_ddd[i];
968 x = creature_ptr->x + ddx_ddd[i];
970 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
972 if (g_ptr->m_idx) continue;
974 /* Skip non-empty grids */
975 if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !cave_have_flag_grid(g_ptr, FF_CAN_FLY))
977 if (!player_can_ride_aux(creature_ptr, g_ptr, FALSE)) continue;
980 if (cave_have_flag_grid(g_ptr, FF_PATTERN)) continue;
982 /* Count "safe" grids */
985 /* Randomize choice */
986 if (randint0(sn) > 0) continue;
988 /* Save the safe location */
993 monster_desc(creature_ptr, m_name, m_ptr, 0);
994 msg_format(_("%sから振り落とされそうになって、壁にぶつかった。", "You have nearly fallen from %s, but bumped into wall."), m_name);
995 take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("壁への衝突", "bumping into wall"), -1);
999 oy = creature_ptr->y;
1000 ox = creature_ptr->x;
1002 creature_ptr->y = sy;
1003 creature_ptr->x = sx;
1005 /* Redraw the old spot */
1006 lite_spot(creature_ptr, oy, ox);
1008 /* Redraw the new spot */
1009 lite_spot(creature_ptr, creature_ptr->y, creature_ptr->x);
1011 /* Check for new panel */
1012 verify_panel(creature_ptr);
1015 creature_ptr->riding = 0;
1016 creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
1017 creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
1019 creature_ptr->update |= (PU_BONUS | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1020 handle_stuff(creature_ptr);
1023 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1024 creature_ptr->redraw |= (PR_EXTRA);
1026 /* Update health track of mount */
1027 creature_ptr->redraw |= (PR_UHEALTH);
1029 if (creature_ptr->levitation && !force)
1031 monster_desc(creature_ptr, m_name, m_ptr, 0);
1032 msg_format(_("%sから落ちたが、空中でうまく体勢を立て直して着地した。", "You are thrown from %s, but make a good landing."), m_name);
1036 take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("落馬", "Falling from riding"), -1);
1040 if (sy && !creature_ptr->is_dead)
1041 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);