}
if (player_ptr->riding) {
- int cur = player_ptr->skill_exp[SKILL_RIDING];
- int max = s_info[enum2i(player_ptr->pclass)].s_max[SKILL_RIDING];
-
- if (cur < max) {
- DEPTH ridinglevel = r_info[player_ptr->current_floor_ptr->m_list[player_ptr->riding].r_idx].level;
- DEPTH targetlevel = r_ptr->level;
- int inc = 0;
-
- if ((cur / 200 - 5) < targetlevel)
- inc += 1;
-
- if ((cur / 100) < ridinglevel) {
- if ((cur / 100 + 15) < ridinglevel)
- inc += 1 + (ridinglevel - (cur / 100 + 15));
- else
- inc += 1;
- }
-
- player_ptr->skill_exp[SKILL_RIDING] = static_cast<short>(std::min(max, cur + inc));
- player_ptr->update |= (PU_BONUS);
- }
+ PlayerSkill(player_ptr).gain_riding_skill_exp_on_melee_attack(r_ptr);
}
player_ptr->riding_t_m_idx = g_ptr->m_idx;
}
if (player_ptr->riding) {
- if ((player_ptr->skill_exp[SKILL_RIDING] < s_info[enum2i(player_ptr->pclass)].s_max[SKILL_RIDING])
- && ((player_ptr->skill_exp[SKILL_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200
- < r_info[player_ptr->current_floor_ptr->m_list[player_ptr->riding].r_idx].level)
- && one_in_(2)) {
- player_ptr->skill_exp[SKILL_RIDING] += 1;
- set_bits(player_ptr->update, PU_BONUS);
- }
+ PlayerSkill(player_ptr).gain_riding_skill_exp_on_range_attack();
}
/* Did we hit it (penalize range) */
fprintf(fff, "!");
else
fprintf(fff, " ");
- fprintf(fff, "%s", exp_level_str[(i == SKILL_RIDING) ? riding_exp_level(skill_exp) : PlayerSkill::weapon_exp_level(skill_exp)]);
+ fprintf(fff, "%s", exp_level_str[(i == SKILL_RIDING) ? PlayerSkill::riding_exp_level(skill_exp) : PlayerSkill::weapon_exp_level(skill_exp)]);
if (cheat_xtra)
fprintf(fff, " %d", skill_exp);
fprintf(fff, "\n");
return true;
auto cur = player_ptr->skill_exp[SKILL_RIDING];
- auto max = s_info[enum2i(player_ptr->pclass)].s_max[SKILL_RIDING];
- auto ridinglevel = r_ptr->level;
int fall_off_level = r_ptr->level;
if (player_ptr->riding_ryoute)
fall_off_level += 20;
- if ((cur < max) && (max > 1000) && (dam / 2 + ridinglevel) > (cur / 30 + 10)) {
- short inc = 0;
- if (ridinglevel > (cur / 100 + 15))
- inc += 1 + (ridinglevel - cur / 100 - 15);
- else
- inc += 1;
-
- player_ptr->skill_exp[SKILL_RIDING] = std::min<short>(max, cur + inc);
- }
+ PlayerSkill(player_ptr).gain_riding_skill_exp_on_fall_off_check(dam);
if (randint0(dam / 2 + fall_off_level * 2) >= cur / 30 + 10)
return true;
#include "player/player-skill.h"
#include "core/player-update-types.h"
+#include "monster-race/monster-race.h"
+#include "system/floor-type-definition.h"
+#include "system/monster-race-definition.h"
+#include "system/monster-type-definition.h"
#include "system/object-type-definition.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
constexpr SUB_EXP WEAPON_EXP_EXPERT = 7000;
constexpr SUB_EXP WEAPON_EXP_MASTER = 8000;
+/* Proficiency of riding */
+constexpr SUB_EXP RIDING_EXP_UNSKILLED = 0;
+constexpr SUB_EXP RIDING_EXP_BEGINNER = 500;
+constexpr SUB_EXP RIDING_EXP_SKILLED = 2000;
+constexpr SUB_EXP RIDING_EXP_EXPERT = 5000;
+constexpr SUB_EXP RIDING_EXP_MASTER = 8000;
+
/*
* The skill table
*/
return (WEAPON_EXP_UNSKILLED <= weapon_exp) && (weapon_exp <= WEAPON_EXP_MASTER);
}
+/*!
+ * @brief 騎乗スキルの抽象的ランクを返す。 / Return proficiency level of riding
+ * @param riding_exp 経験値
+ * @return ランク値
+ */
+int PlayerSkill::riding_exp_level(int riding_exp)
+{
+ if (riding_exp < RIDING_EXP_BEGINNER)
+ return EXP_LEVEL_UNSKILLED;
+ else if (riding_exp < RIDING_EXP_SKILLED)
+ return EXP_LEVEL_BEGINNER;
+ else if (riding_exp < RIDING_EXP_EXPERT)
+ return EXP_LEVEL_SKILLED;
+ else if (riding_exp < RIDING_EXP_MASTER)
+ return EXP_LEVEL_EXPERT;
+ else
+ return EXP_LEVEL_MASTER;
+}
+
void PlayerSkill::gain_melee_weapon_exp(const object_type *o_ptr)
{
auto now_exp = this->player_ptr->weapon_exp[o_ptr->tval][o_ptr->sval];
this->player_ptr->skill_exp[SKILL_TWO_WEAPON] += amount;
set_bits(this->player_ptr->update, PU_BONUS);
}
+
+void PlayerSkill::gain_riding_skill_exp_on_melee_attack(const monster_race *r_ptr)
+{
+ auto now_exp = this->player_ptr->skill_exp[SKILL_RIDING];
+ auto max_exp = s_info[enum2i(this->player_ptr->pclass)].s_max[SKILL_RIDING];
+ if (now_exp >= max_exp)
+ return;
+
+ auto riding_level = r_info[this->player_ptr->current_floor_ptr->m_list[this->player_ptr->riding].r_idx].level;
+ int inc = 0;
+
+ if ((now_exp / 200 - 5) < r_ptr->level)
+ inc += 1;
+
+ if ((now_exp / 100) < riding_level) {
+ if ((now_exp / 100 + 15) < riding_level)
+ inc += 1 + (riding_level - (now_exp / 100 + 15));
+ else
+ inc += 1;
+ }
+
+ this->player_ptr->skill_exp[SKILL_RIDING] = std::min<SUB_EXP>(max_exp, now_exp + inc);
+ set_bits(this->player_ptr->update, PU_BONUS);
+}
+
+void PlayerSkill::gain_riding_skill_exp_on_range_attack()
+{
+ auto now_exp = this->player_ptr->skill_exp[SKILL_RIDING];
+ auto max_exp = s_info[enum2i(this->player_ptr->pclass)].s_max[SKILL_RIDING];
+ if (now_exp >= max_exp)
+ return;
+
+ if (((this->player_ptr->skill_exp[SKILL_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[this->player_ptr->current_floor_ptr->m_list[this->player_ptr->riding].r_idx].level) && one_in_(2)) {
+ this->player_ptr->skill_exp[SKILL_RIDING] += 1;
+ set_bits(this->player_ptr->update, PU_BONUS);
+ }
+}
+
+void PlayerSkill::gain_riding_skill_exp_on_fall_off_check(HIT_POINT dam)
+{
+ auto now_exp = this->player_ptr->skill_exp[SKILL_RIDING];
+ auto max_exp = s_info[enum2i(this->player_ptr->pclass)].s_max[SKILL_RIDING];
+ if (now_exp >= max_exp || max_exp <= 1000)
+ return;
+
+ auto riding_level = r_info[this->player_ptr->current_floor_ptr->m_list[this->player_ptr->riding].r_idx].level;
+
+ if ((dam / 2 + riding_level) <= (now_exp / 30 + 10))
+ return;
+
+ int inc = 0;
+ if ((now_exp / 100 + 15) < riding_level)
+ inc += 1 + (riding_level - (now_exp / 100 + 15));
+ else
+ inc += 1;
+
+ player_ptr->skill_exp[SKILL_RIDING] = std::min<SUB_EXP>(max_exp, now_exp + inc);
+ set_bits(this->player_ptr->update, PU_BONUS);
+}
#define EXP_LEVEL_EXPERT 3
#define EXP_LEVEL_MASTER 4
-/* Proficiency of riding */
-#define RIDING_EXP_UNSKILLED 0
-#define RIDING_EXP_BEGINNER 500
-#define RIDING_EXP_SKILLED 2000
-#define RIDING_EXP_EXPERT 5000
-#define RIDING_EXP_MASTER 8000
-
/* Proficiency of spells */
#define SPELL_EXP_UNSKILLED 0
#define SPELL_EXP_BEGINNER 900
extern std::vector<skill_table> s_info;
+struct monster_race;
struct object_type;
struct player_type;
static SUB_EXP weapon_exp_at(int level);
static bool valid_weapon_exp(int weapon_exp);
static int weapon_exp_level(int weapon_exp);
+ static int riding_exp_level(int riding_exp);
void gain_melee_weapon_exp(const object_type *o_ptr);
void gain_range_weapon_exp(const object_type *o_ptr);
void gain_martial_arts_skill_exp();
void gain_two_weapon_skill_exp();
+ void gain_riding_skill_exp_on_melee_attack(const monster_race *r_ptr);
+ void gain_riding_skill_exp_on_range_attack();
+ void gain_riding_skill_exp_on_fall_off_check(HIT_POINT dam);
private:
player_type *player_ptr;
/*** Player information ***/
/*!
- * @brief 騎乗スキルの抽象的ランクを返す。 / Return proficiency level of riding
- * @param weapon_exp 経験値
- * @return ランク値
- */
-int riding_exp_level(int riding_exp)
-{
- if (riding_exp < RIDING_EXP_BEGINNER)
- return EXP_LEVEL_UNSKILLED;
- else if (riding_exp < RIDING_EXP_SKILLED)
- return EXP_LEVEL_BEGINNER;
- else if (riding_exp < RIDING_EXP_EXPERT)
- return EXP_LEVEL_SKILLED;
- else if (riding_exp < RIDING_EXP_MASTER)
- return EXP_LEVEL_EXPERT;
- else
- return EXP_LEVEL_MASTER;
-}
-
-/*!
* @brief プレイヤーの呪文レベルの抽象的ランクを返す。 / Return proficiency level of spells
* @param spell_exp 経験値
* @return ランク値
struct object_type;;
struct player_type;
-int riding_exp_level(int riding_exp);
int spell_exp_level(int spell_exp);
WEIGHT calc_weapon_weight_limit(player_type *player_ptr);