1 #include "pet/pet-util.h"
2 #include "core/player-update-types.h"
3 #include "core/stuff-handler.h"
5 #include "monster-race/monster-race.h"
6 #include "monster-race/race-flags1.h"
7 #include "monster-race/race-flags7.h"
8 #include "monster/monster-info.h"
9 #include "monster/monster-status.h"
10 #include "player/player-class.h"
11 #include "system/floor-type-definition.h"
12 #include "system/grid-type-definition.h"
13 #include "system/monster-race-definition.h"
14 #include "system/monster-type-definition.h"
15 #include "system/player-type-definition.h"
16 #include "util/bit-flags-calculator.h"
17 #include "world/world.h"
19 int total_friends = 0;
22 * @brief プレイヤーの騎乗/下馬処理判定
23 * @param g_ptr プレイヤーの移動先マスの構造体参照ポインタ
24 * @param now_riding trueなら下馬処理、falseならば騎乗処理
25 * @return 可能ならばtrueを返す
27 bool can_player_ride_pet(player_type *creature_ptr, grid_type *g_ptr, bool now_riding)
29 bool old_character_xtra = current_world_ptr->character_xtra;
30 MONSTER_IDX old_riding = creature_ptr->riding;
31 bool old_riding_two_hands = creature_ptr->riding_ryoute;
32 bool old_old_riding_two_hands = creature_ptr->old_riding_ryoute;
33 bool old_pf_two_hands = (creature_ptr->pet_extra_flags & PF_TWO_HANDS) ? true : false;
34 current_world_ptr->character_xtra = true;
37 creature_ptr->riding = g_ptr->m_idx;
39 creature_ptr->riding = 0;
40 creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
41 creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = false;
44 creature_ptr->update |= PU_BONUS;
45 handle_stuff(creature_ptr);
47 bool p_can_enter = player_can_enter(creature_ptr, g_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
48 creature_ptr->riding = old_riding;
50 creature_ptr->pet_extra_flags |= (PF_TWO_HANDS);
52 creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
54 creature_ptr->riding_ryoute = old_riding_two_hands;
55 creature_ptr->old_riding_ryoute = old_old_riding_two_hands;
56 creature_ptr->update |= PU_BONUS;
57 handle_stuff(creature_ptr);
59 current_world_ptr->character_xtra = old_character_xtra;
67 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
69 bool has_a_unique = false;
70 DEPTH total_friend_levels = 0;
72 for (auto m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
73 auto *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
74 if (!monster_is_valid(m_ptr))
76 auto *r_ptr = &r_info[m_ptr->r_idx];
83 if (none_bits(r_ptr->flags1, RF1_UNIQUE)) {
84 total_friend_levels += r_ptr->level;
88 if (creature_ptr->pclass != CLASS_CAVALRY) {
89 total_friend_levels += (r_ptr->level + 5) * 10;
93 if (creature_ptr->riding == m_idx)
94 total_friend_levels += (r_ptr->level + 5) * 2;
95 else if (!has_a_unique && any_bits(r_info[m_ptr->r_idx].flags7, RF7_RIDING))
96 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
98 total_friend_levels += (r_ptr->level + 5) * 10;
103 if (total_friends == 0) {
107 int upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
108 if (upkeep_factor < 0) {
112 if (upkeep_factor > 1000) {
113 upkeep_factor = 1000;
116 return upkeep_factor;