10 #include "player-move.h"
11 #include "player-status.h"
12 #include "player-effects.h"
13 #include "player-skill.h"
14 #include "player-class.h"
15 #include "player-damage.h"
16 #include "object-hook.h"
18 #include "monster-status.h"
20 #include "cmd-basic.h"
21 #include "view-mainwindow.h"
22 #include "targeting.h"
25 int total_friends = 0;
28 * @brief プレイヤーの騎乗/下馬処理判定
29 * @param g_ptr プレイヤーの移動先マスの構造体参照ポインタ
30 * @param now_riding TRUEなら下馬処理、FALSEならば騎乗処理
31 * @return 可能ならばTRUEを返す
33 bool player_can_ride_aux(player_type *creature_ptr, grid_type *g_ptr, bool now_riding)
36 bool old_character_xtra = current_world_ptr->character_xtra;
37 MONSTER_IDX old_riding = creature_ptr->riding;
38 bool old_riding_ryoute = creature_ptr->riding_ryoute;
39 bool old_old_riding_ryoute = creature_ptr->old_riding_ryoute;
40 bool old_pf_ryoute = (creature_ptr->pet_extra_flags & PF_TWO_HANDS) ? TRUE : FALSE;
42 /* Hack -- prevent "icky" message */
43 current_world_ptr->character_xtra = TRUE;
45 if (now_riding) creature_ptr->riding = g_ptr->m_idx;
48 creature_ptr->riding = 0;
49 creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
50 creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
53 creature_ptr->update |= PU_BONUS;
54 handle_stuff(creature_ptr);
56 p_can_enter = player_can_enter(creature_ptr, g_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
58 creature_ptr->riding = old_riding;
59 if (old_pf_ryoute) creature_ptr->pet_extra_flags |= (PF_TWO_HANDS);
60 else creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
61 creature_ptr->riding_ryoute = old_riding_ryoute;
62 creature_ptr->old_riding_ryoute = old_old_riding_ryoute;
64 creature_ptr->update |= PU_BONUS;
65 handle_stuff(creature_ptr);
67 current_world_ptr->character_xtra = old_character_xtra;
77 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
80 bool have_a_unique = FALSE;
81 DEPTH total_friend_levels = 0;
85 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
90 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
91 if (!monster_is_valid(m_ptr)) continue;
92 r_ptr = &r_info[m_ptr->r_idx];
97 if (r_ptr->flags1 & RF1_UNIQUE)
99 if (creature_ptr->pclass == CLASS_CAVALRY)
101 if (creature_ptr->riding == m_idx)
102 total_friend_levels += (r_ptr->level + 5) * 2;
103 else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
104 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
106 total_friend_levels += (r_ptr->level + 5) * 10;
107 have_a_unique = TRUE;
110 total_friend_levels += (r_ptr->level + 5) * 10;
113 total_friend_levels += r_ptr->level;
121 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
122 if (upkeep_factor < 0) upkeep_factor = 0;
123 if (upkeep_factor > 1000) upkeep_factor = 1000;
124 return upkeep_factor;
131 * @brief ペットを開放するコマンドのメインルーチン
134 void do_cmd_pet_dismiss(player_type *creature_ptr)
137 bool all_pets = FALSE;
152 /* Allocate the "who" array */
153 C_MAKE(who, current_world_ptr->max_m_idx, MONSTER_IDX);
155 /* Process the monsters (backwards) */
156 for (pet_ctr = creature_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
158 if (is_pet(&creature_ptr->current_floor_ptr->m_list[pet_ctr]))
159 who[max_pet++] = pet_ctr;
162 ang_sort(who, &dummy_why, max_pet, ang_sort_comp_pet_dismiss, ang_sort_swap_hook);
164 /* Process the monsters (backwards) */
165 for (i = 0; i < max_pet; i++)
168 GAME_TEXT friend_name[MAX_NLEN];
172 m_ptr = &creature_ptr->current_floor_ptr->m_list[pet_ctr];
175 kakunin = ((pet_ctr == creature_ptr->riding) || (m_ptr->nickname));
176 monster_desc(friend_name, m_ptr, MD_ASSUME_VISIBLE);
180 /* Hack -- health bar for this monster */
181 health_track(creature_ptr, pet_ctr);
182 handle_stuff(creature_ptr);
184 msg_format(_("%sを放しますか? [Yes/No/Unnamed (%d体)]", "Dismiss %s? [Yes/No/Unnamed (%d remain)]"), friend_name, max_pet - i);
187 move_cursor_relative(m_ptr->fy, m_ptr->fx);
193 if (ch == 'Y' || ch == 'y')
199 msg_format(_("本当によろしいですか? (%s) ", "Are you sure? (%s) "), friend_name);
201 if (ch != 'Y' && ch != 'y')
207 if (ch == 'U' || ch == 'u')
213 if (ch == ESCAPE || ch == 'N' || ch == 'n')
220 if ((all_pets && !kakunin) || (!all_pets && delete_this))
222 if (record_named_pet && m_ptr->nickname)
224 GAME_TEXT m_name[MAX_NLEN];
226 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
227 exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_DISMISS, m_name);
230 if (pet_ctr == creature_ptr->riding)
232 msg_format(_("%sから降りた。", "You have got off %s. "), friend_name);
234 creature_ptr->riding = 0;
236 creature_ptr->update |= (PU_MONSTERS);
237 creature_ptr->redraw |= (PR_EXTRA | PR_UHEALTH);
240 /* HACK : Add the line to message buffer */
241 msg_format(_("%s を放した。", "Dismissed %s."), friend_name);
242 creature_ptr->update |= (PU_BONUS);
243 creature_ptr->window |= (PW_MESSAGE);
245 delete_monster_idx(pet_ctr);
254 C_KILL(who, current_world_ptr->max_m_idx, MONSTER_IDX);
257 msg_format("%d 体のペットを放しました。", Dismissed);
259 msg_format("You have dismissed %d pet%s.", Dismissed,
260 (Dismissed == 1 ? "" : "s"));
262 if (Dismissed == 0 && all_pets)
263 msg_print(_("'U'nnamed は、乗馬以外の名前のないペットだけを全て解放します。", "'U'nnamed means all your pets except named pets and your mount."));
265 handle_stuff(creature_ptr);
271 * @brief ペットから騎乗/下馬するコマンドのメインルーチン /
272 * @param force 強制的に騎乗/下馬するならばTRUE
273 * @return 騎乗/下馬できたらTRUE
275 bool do_cmd_riding(player_type *creature_ptr, bool force)
282 if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
283 y = creature_ptr->y + ddy[dir];
284 x = creature_ptr->x + ddx[dir];
285 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
287 if (creature_ptr->special_defense & KATA_MUSOU) set_action(creature_ptr, ACTION_NONE);
289 if (creature_ptr->riding)
291 /* Skip non-empty grids */
292 if (!player_can_ride_aux(creature_ptr, g_ptr, FALSE))
294 msg_print(_("そちらには降りられません。", "You cannot go that direction."));
298 if (!pattern_seq(creature_ptr, creature_ptr->y, creature_ptr->x, y, x)) return FALSE;
302 take_turn(creature_ptr, 100);
304 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
306 py_attack(creature_ptr, y, x, 0);
310 creature_ptr->riding = 0;
311 creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
312 creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
316 if (cmd_limit_confused(creature_ptr)) return FALSE;
318 m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
320 if (!g_ptr->m_idx || !m_ptr->ml)
322 msg_print(_("その場所にはモンスターはいません。", "Here is no monster."));
325 if (!is_pet(m_ptr) && !force)
327 msg_print(_("そのモンスターはペットではありません。", "That monster is not a pet."));
330 if (!(r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
332 msg_print(_("そのモンスターには乗れなさそうだ。", "This monster doesn't seem suitable for riding."));
336 if (!pattern_seq(creature_ptr, creature_ptr->y, creature_ptr->x, y, x)) return FALSE;
338 if (!player_can_ride_aux(creature_ptr, g_ptr, TRUE))
340 /* Feature code (applying "mimic" field) */
341 feature_type *f_ptr = &f_info[get_feat_mimic(g_ptr)];
343 msg_format("そのモンスターは%sの%sにいる。", f_name + f_ptr->name,
344 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
345 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
348 msg_format("This monster is %s the %s.",
349 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
350 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
351 "in" : "on", f_name + f_ptr->name);
356 if (r_info[m_ptr->r_idx].level > randint1((creature_ptr->skill_exp[GINOU_RIDING] / 50 + creature_ptr->lev / 2 + 20)))
358 msg_print(_("うまく乗れなかった。", "You failed to ride."));
359 take_turn(creature_ptr, 100);
363 if (MON_CSLEEP(m_ptr))
365 GAME_TEXT m_name[MAX_NLEN];
366 monster_desc(m_name, m_ptr, 0);
367 (void)set_monster_csleep(creature_ptr, g_ptr->m_idx, 0);
368 msg_format(_("%sを起こした。", "You have woken %s up."), m_name);
371 if (creature_ptr->action == ACTION_KAMAE) set_action(creature_ptr, ACTION_NONE);
373 creature_ptr->riding = g_ptr->m_idx;
375 /* Hack -- remove tracked monster */
376 if (creature_ptr->riding == creature_ptr->health_who) health_track(creature_ptr, 0);
379 take_turn(creature_ptr, 100);
381 /* Mega-Hack -- Forget the view and lite */
382 creature_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
383 creature_ptr->update |= (PU_BONUS);
384 creature_ptr->redraw |= (PR_MAP | PR_EXTRA);
385 creature_ptr->redraw |= (PR_UHEALTH);
387 (void)move_player_effect(creature_ptr, y, x, MPE_HANDLE_STUFF | MPE_ENERGY_USE | MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
393 * @brief ペットに名前をつけるコマンドのメインルーチン
396 static void do_name_pet(player_type *creature_ptr)
400 GAME_TEXT m_name[MAX_NLEN];
401 bool old_name = FALSE;
402 bool old_target_pet = target_pet;
405 if (!target_set(creature_ptr, TARGET_KILL))
407 target_pet = old_target_pet;
411 target_pet = old_target_pet;
413 if (creature_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx)
415 m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx];
419 msg_print(_("そのモンスターはペットではない。", "This monster is not a pet."));
422 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
424 msg_print(_("そのモンスターの名前は変えられない!", "You cannot change name of this monster!"));
427 monster_desc(m_name, m_ptr, 0);
429 msg_format(_("%sに名前をつける。", "Name %s."), m_name);
432 /* Start with nothing */
435 /* Use old inscription */
438 /* Start with the old inscription */
439 strcpy(out_val, quark_str(m_ptr->nickname));
443 /* Get a new inscription (possibly empty) */
444 if (get_string(_("名前: ", "Name: "), out_val, 15))
448 /* Save the inscription */
449 m_ptr->nickname = quark_add(out_val);
450 if (record_named_pet)
452 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
453 exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_NAME, m_name);
458 if (record_named_pet && old_name)
460 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
461 exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_UNNAME, m_name);
471 * @brief ペットに関するコマンドリストのメインルーチン /
472 * Issue a pet command
475 void do_cmd_pet(player_type *creature_ptr)
480 concptr power_desc[36];
487 PET_COMMAND_IDX mode = 0;
490 char target_buf[160];
492 int menu_line = use_menu ? 1 : 0;
496 if (creature_ptr->wild_mode) return;
498 power_desc[num] = _("ペットを放す", "dismiss pets");
499 powers[num++] = PET_DISMISS;
502 sprintf(target_buf, "ペットのターゲットを指定 (現在:%s)",
503 (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)) : "指定なし"));
505 sprintf(target_buf, "specify a target of pet (now:%s)",
506 (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"));
508 power_desc[num] = target_buf;
509 powers[num++] = PET_TARGET;
510 power_desc[num] = _("近くにいろ", "stay close");
512 if (creature_ptr->pet_follow_distance == PET_CLOSE_DIST) mode = num;
513 powers[num++] = PET_STAY_CLOSE;
514 power_desc[num] = _("ついて来い", "follow me");
516 if (creature_ptr->pet_follow_distance == PET_FOLLOW_DIST) mode = num;
517 powers[num++] = PET_FOLLOW_ME;
518 power_desc[num] = _("敵を見つけて倒せ", "seek and destroy");
520 if (creature_ptr->pet_follow_distance == PET_DESTROY_DIST) mode = num;
521 powers[num++] = PET_SEEK_AND_DESTROY;
522 power_desc[num] = _("少し離れていろ", "give me space");
524 if (creature_ptr->pet_follow_distance == PET_SPACE_DIST) mode = num;
525 powers[num++] = PET_ALLOW_SPACE;
526 power_desc[num] = _("離れていろ", "stay away");
528 if (creature_ptr->pet_follow_distance == PET_AWAY_DIST) mode = num;
529 powers[num++] = PET_STAY_AWAY;
531 if (creature_ptr->pet_extra_flags & PF_OPEN_DOORS)
533 power_desc[num] = _("ドアを開ける (現在:ON)", "pets open doors (now On)");
537 power_desc[num] = _("ドアを開ける (現在:OFF)", "pets open doors (now Off)");
539 powers[num++] = PET_OPEN_DOORS;
541 if (creature_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
543 power_desc[num] = _("アイテムを拾う (現在:ON)", "pets pick up items (now On)");
547 power_desc[num] = _("アイテムを拾う (現在:OFF)", "pets pick up items (now Off)");
549 powers[num++] = PET_TAKE_ITEMS;
551 if (creature_ptr->pet_extra_flags & PF_TELEPORT)
553 power_desc[num] = _("テレポート系魔法を使う (現在:ON)", "allow teleport (now On)");
557 power_desc[num] = _("テレポート系魔法を使う (現在:OFF)", "allow teleport (now Off)");
559 powers[num++] = PET_TELEPORT;
561 if (creature_ptr->pet_extra_flags & PF_ATTACK_SPELL)
563 power_desc[num] = _("攻撃魔法を使う (現在:ON)", "allow cast attack spell (now On)");
567 power_desc[num] = _("攻撃魔法を使う (現在:OFF)", "allow cast attack spell (now Off)");
569 powers[num++] = PET_ATTACK_SPELL;
571 if (creature_ptr->pet_extra_flags & PF_SUMMON_SPELL)
573 power_desc[num] = _("召喚魔法を使う (現在:ON)", "allow cast summon spell (now On)");
577 power_desc[num] = _("召喚魔法を使う (現在:OFF)", "allow cast summon spell (now Off)");
579 powers[num++] = PET_SUMMON_SPELL;
581 if (creature_ptr->pet_extra_flags & PF_BALL_SPELL)
583 power_desc[num] = _("プレイヤーを巻き込む範囲魔法を使う (現在:ON)", "allow involve player in area spell (now On)");
587 power_desc[num] = _("プレイヤーを巻き込む範囲魔法を使う (現在:OFF)", "allow involve player in area spell (now Off)");
589 powers[num++] = PET_BALL_SPELL;
591 if (creature_ptr->riding)
593 power_desc[num] = _("ペットから降りる", "get off a pet");
597 power_desc[num] = _("ペットに乗る", "ride a pet");
599 powers[num++] = PET_RIDING;
600 power_desc[num] = _("ペットに名前をつける", "name pets");
601 powers[num++] = PET_NAME;
603 if (creature_ptr->riding)
605 if ((creature_ptr->migite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) &&
606 object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) ||
607 (creature_ptr->hidarite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) &&
608 object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])))
610 if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
612 power_desc[num] = _("武器を片手で持つ", "use one hand to control a riding pet");
616 power_desc[num] = _("武器を両手で持つ", "use both hands for a weapon");
619 powers[num++] = PET_TWO_HANDS;
623 switch (creature_ptr->pclass)
626 case CLASS_FORCETRAINER:
627 case CLASS_BERSERKER:
628 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
630 if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
632 power_desc[num] = _("片手で格闘する", "use one hand to control a riding pet");
636 power_desc[num] = _("両手で格闘する", "use both hands for melee");
639 powers[num++] = PET_TWO_HANDS;
641 else if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
643 if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
645 power_desc[num] = _("格闘を行わない", "use one hand to control a riding pet");
649 power_desc[num] = _("格闘を行う", "use one hand for melee");
652 powers[num++] = PET_TWO_HANDS;
659 if (!(repeat_pull(&i) && (i >= 0) && (i < num)))
667 strnfmt(out_val, 78, _("(コマンド、ESC=終了) コマンドを選んでください:", "(Command, ESC=exit) Choose command from menu."));
672 _("(コマンド %c-%c、'*'=一覧、ESC=終了) コマンドを選んでください:", "(Command %c-%c, *=List, ESC=exit) Select a command: "),
673 I2A(0), I2A(num - 1));
676 choice = (always_show_list || use_menu) ? ESCAPE : 1;
678 /* Get a command from the user */
683 if (choice == ESCAPE) choice = ' ';
684 else if (!get_com(out_val, &choice, TRUE)) break;
686 if (use_menu && (choice != ' '))
697 menu_line += (num - 1);
726 if (menu_line > num) menu_line -= num;
730 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
733 if (!redraw || use_menu)
736 PET_COMMAND_IDX ctr = 0;
738 if (!use_menu) screen_save();
743 for (ctr = 0; ctr < num; ctr++)
745 /* Letter/number for power selection */
747 sprintf(buf, "%c%s ", (ctr == mode) ? '*' : ' ', (ctr == (menu_line - 1)) ? _("》", "> ") : " ");
749 sprintf(buf, "%c%c) ", (ctr == mode) ? '*' : ' ', I2A(ctr));
751 strcat(buf, power_desc[ctr]);
753 prt(buf, y + ctr, x);
756 prt("", y + MIN(ctr, 17), x);
774 ask = (isupper(choice));
777 if (ask) choice = (char)tolower(choice);
779 /* Extract request */
780 i = (islower(choice) ? A2I(choice) : -1);
783 /* Totally Illegal */
784 if ((i < 0) || (i >= num))
794 strnfmt(buf, 78, _("%sを使いますか? ", "Use %s? "), power_desc[i]);
796 /* Belay that order */
797 if (!get_check(buf)) continue;
803 if (redraw) screen_load();
805 /* Abort if needed */
808 free_turn(creature_ptr);
816 case PET_DISMISS: /* Dismiss pets */
818 /* Check pets (backwards) */
819 for (pet_ctr = creature_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
822 if (is_pet(&creature_ptr->current_floor_ptr->m_list[pet_ctr])) break;
827 msg_print(_("ペットがいない!", "You have no pets!"));
830 do_cmd_pet_dismiss(creature_ptr);
831 (void)calculate_upkeep(creature_ptr);
837 if (!target_set(creature_ptr, TARGET_KILL)) creature_ptr->pet_t_m_idx = 0;
840 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[target_row][target_col];
841 if (g_ptr->m_idx && (creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml))
843 creature_ptr->pet_t_m_idx = creature_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
844 creature_ptr->pet_follow_distance = PET_DESTROY_DIST;
846 else creature_ptr->pet_t_m_idx = 0;
855 creature_ptr->pet_follow_distance = PET_CLOSE_DIST;
856 creature_ptr->pet_t_m_idx = 0;
862 creature_ptr->pet_follow_distance = PET_FOLLOW_DIST;
863 creature_ptr->pet_t_m_idx = 0;
866 /* "Seek and destoy" */
867 case PET_SEEK_AND_DESTROY:
869 creature_ptr->pet_follow_distance = PET_DESTROY_DIST;
872 /* "Give me space" */
873 case PET_ALLOW_SPACE:
875 creature_ptr->pet_follow_distance = PET_SPACE_DIST;
881 creature_ptr->pet_follow_distance = PET_AWAY_DIST;
884 /* flag - allow pets to open doors */
887 if (creature_ptr->pet_extra_flags & PF_OPEN_DOORS) creature_ptr->pet_extra_flags &= ~(PF_OPEN_DOORS);
888 else creature_ptr->pet_extra_flags |= (PF_OPEN_DOORS);
891 /* flag - allow pets to pickup items */
894 if (creature_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
896 creature_ptr->pet_extra_flags &= ~(PF_PICKUP_ITEMS);
897 for (pet_ctr = creature_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
899 m_ptr = &creature_ptr->current_floor_ptr->m_list[pet_ctr];
903 monster_drop_carried_objects(m_ptr);
907 else creature_ptr->pet_extra_flags |= (PF_PICKUP_ITEMS);
911 /* flag - allow pets to teleport */
914 if (creature_ptr->pet_extra_flags & PF_TELEPORT) creature_ptr->pet_extra_flags &= ~(PF_TELEPORT);
915 else creature_ptr->pet_extra_flags |= (PF_TELEPORT);
918 /* flag - allow pets to cast attack spell */
919 case PET_ATTACK_SPELL:
921 if (creature_ptr->pet_extra_flags & PF_ATTACK_SPELL) creature_ptr->pet_extra_flags &= ~(PF_ATTACK_SPELL);
922 else creature_ptr->pet_extra_flags |= (PF_ATTACK_SPELL);
925 /* flag - allow pets to cast attack spell */
926 case PET_SUMMON_SPELL:
928 if (creature_ptr->pet_extra_flags & PF_SUMMON_SPELL) creature_ptr->pet_extra_flags &= ~(PF_SUMMON_SPELL);
929 else creature_ptr->pet_extra_flags |= (PF_SUMMON_SPELL);
932 /* flag - allow pets to cast attack spell */
935 if (creature_ptr->pet_extra_flags & PF_BALL_SPELL) creature_ptr->pet_extra_flags &= ~(PF_BALL_SPELL);
936 else creature_ptr->pet_extra_flags |= (PF_BALL_SPELL);
942 (void)do_cmd_riding(creature_ptr, FALSE);
948 do_name_pet(creature_ptr);
954 if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
955 else creature_ptr->pet_extra_flags |= (PF_TWO_HANDS);
956 creature_ptr->update |= (PU_BONUS);
957 handle_stuff(creature_ptr);
965 * @brief プレイヤーの落馬判定処理
966 * @param dam 落馬判定を発した際に受けたダメージ量
967 * @param force TRUEならば強制的に落馬する
968 * @return 実際に落馬したらTRUEを返す
970 bool rakuba(player_type *creature_ptr, HIT_POINT dam, bool force)
973 POSITION y, x, oy, ox, sy = 0, sx = 0;
975 GAME_TEXT m_name[MAX_NLEN];
976 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
977 monster_race *r_ptr = &r_info[m_ptr->r_idx];
978 bool fall_dam = FALSE;
980 if (!creature_ptr->riding) return FALSE;
981 if (creature_ptr->wild_mode) return FALSE;
983 if (dam >= 0 || force)
987 int cur = creature_ptr->skill_exp[GINOU_RIDING];
988 int max = s_info[creature_ptr->pclass].s_max[GINOU_RIDING];
989 int ridinglevel = r_ptr->level;
992 int rakubalevel = r_ptr->level;
993 if (creature_ptr->riding_ryoute) rakubalevel += 20;
995 if ((cur < max) && (max > 1000) &&
996 (dam / 2 + ridinglevel) > (cur / 30 + 10))
1000 if (ridinglevel > (cur / 100 + 15))
1001 inc += 1 + (ridinglevel - cur / 100 - 15);
1005 creature_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
1008 /* レベルの低い乗馬からは落馬しにくい */
1009 if (randint0(dam / 2 + rakubalevel * 2) < cur / 30 + 10)
1011 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))
1018 /* Check around the player */
1019 for (i = 0; i < 8; i++)
1023 y = creature_ptr->y + ddy_ddd[i];
1024 x = creature_ptr->x + ddx_ddd[i];
1026 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1028 if (g_ptr->m_idx) continue;
1030 /* Skip non-empty grids */
1031 if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !cave_have_flag_grid(g_ptr, FF_CAN_FLY))
1033 if (!player_can_ride_aux(creature_ptr, g_ptr, FALSE)) continue;
1036 if (cave_have_flag_grid(g_ptr, FF_PATTERN)) continue;
1038 /* Count "safe" grids */
1041 /* Randomize choice */
1042 if (randint0(sn) > 0) continue;
1044 /* Save the safe location */
1049 monster_desc(m_name, m_ptr, 0);
1050 msg_format(_("%sから振り落とされそうになって、壁にぶつかった。", "You have nearly fallen from %s, but bumped into wall."), m_name);
1051 take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("壁への衝突", "bumping into wall"), -1);
1055 oy = creature_ptr->y;
1056 ox = creature_ptr->x;
1058 creature_ptr->y = sy;
1059 creature_ptr->x = sx;
1061 /* Redraw the old spot */
1064 /* Redraw the new spot */
1065 lite_spot(creature_ptr->y, creature_ptr->x);
1067 /* Check for new panel */
1068 verify_panel(creature_ptr);
1071 creature_ptr->riding = 0;
1072 creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
1073 creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
1075 creature_ptr->update |= (PU_BONUS | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1076 handle_stuff(creature_ptr);
1079 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1080 creature_ptr->redraw |= (PR_EXTRA);
1082 /* Update health track of mount */
1083 creature_ptr->redraw |= (PR_UHEALTH);
1085 if (creature_ptr->levitation && !force)
1087 monster_desc(m_name, m_ptr, 0);
1088 msg_format(_("%sから落ちたが、空中でうまく体勢を立て直して着地した。", "You are thrown from %s, but make a good landing."), m_name);
1092 take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("落馬", "Falling from riding"), -1);
1096 if (sy && !creature_ptr->is_dead)
1097 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);