1 #include "lore/lore-calculator.h"
2 #include "game-option/cheat-options.h"
3 #include "lore/lore-util.h"
4 #include "monster-race/monster-race.h"
5 #include "monster-race/race-ability-flags.h"
6 #include "monster-race/race-flags1.h"
7 #include "mspell/mspell-damage-calculator.h"
8 #include "system/monster-race-definition.h"
9 #include "system/player-type-definition.h"
12 * @brief ダイス目を文字列に変換する
13 * @param base_damage 固定値
14 * @param dice_num ダイス数
15 * @param dice_side ダイス面
16 * @param dice_mult ダイス倍率
17 * @param dice_div ダイス除数
18 * @param msg 文字列を格納するポインタ
20 void dice_to_string(int base_damage, int dice_num, int dice_side, int dice_mult, int dice_div, char *msg)
22 char base[80] = "", dice[80] = "", mult[80] = "";
25 sprintf(msg, "%d", base_damage);
30 sprintf(base, "%d+", base_damage);
33 sprintf(dice, "d%d", dice_side);
35 sprintf(dice, "%dd%d", dice_num, dice_side);
37 if (dice_mult != 1 || dice_div != 1) {
39 sprintf(mult, "*%d", dice_mult);
41 sprintf(mult, "*(%d/%d)", dice_mult, dice_div);
44 sprintf(msg, "%s%s%s", base, dice, mult);
48 * @brief モンスターのAC情報を得ることができるかを返す / Determine if the "armor" is known
49 * @param r_idx モンスターの種族ID
50 * @param know_everything 全知フラグ。TRUEを渡すとTRUEが返る。
51 * @return 敵のACを知る条件が満たされているならTRUEを返す
53 * The higher the level, the fewer kills needed.
55 bool know_armour(MONRACE_IDX r_idx, const bool know_everything)
57 auto *r_ptr = &r_info[r_idx];
58 DEPTH level = r_ptr->level;
59 MONSTER_NUMBER kills = r_ptr->r_tkills;
61 bool known = r_ptr->r_cast_spell == MAX_UCHAR;
63 if (know_everything || known)
65 if (kills > 304 / (4 + level))
67 if (r_ptr->kind_flags.has_not(MonsterKindType::UNIQUE))
69 if (kills > 304 / (38 + (5 * level) / 4))
75 * @brief モンスターの打撃威力を知ることができるかどうかを返す
76 * Determine if the "damage" of the given attack is known
77 * @param r_idx モンスターの種族ID
79 * @return 敵のダメージダイスを知る条件が満たされているならTRUEを返す
82 * the higher the level of the monster, the fewer the attacks you need,
83 * the more damage an attack does, the more attacks you need
86 bool know_damage(MONRACE_IDX r_idx, int i)
88 auto *r_ptr = &r_info[r_idx];
89 DEPTH level = r_ptr->level;
90 int32_t a = r_ptr->r_blows[i];
92 int32_t d1 = r_ptr->blow[i].d_dice;
93 int32_t d2 = r_ptr->blow[i].d_side;
96 if (d >= ((4 + level) * MAX_UCHAR) / 80)
97 d = ((4 + level) * MAX_UCHAR - 1) / 80;
98 if ((4 + level) * a > 80 * d)
100 if (r_ptr->kind_flags.has_not(MonsterKindType::UNIQUE))
102 if ((4 + level) * (2 * a) > 80 * d)
109 * @brief 文字列にモンスターの攻撃力を加える
110 * @param r_idx モンスターの種族ID
111 * @param SPELL_NUM 呪文番号
114 void set_damage(PlayerType *player_ptr, lore_type *lore_ptr, MonsterAbilityType ms_type, concptr msg)
116 MONRACE_IDX r_idx = lore_ptr->r_idx;
117 int base_damage = monspell_race_damage(player_ptr, ms_type, r_idx, BASE_DAM);
118 int dice_num = monspell_race_damage(player_ptr, ms_type, r_idx, DICE_NUM);
119 int dice_side = monspell_race_damage(player_ptr, ms_type, r_idx, DICE_SIDE);
120 int dice_mult = monspell_race_damage(player_ptr, ms_type, r_idx, DICE_MULT);
121 int dice_div = monspell_race_damage(player_ptr, ms_type, r_idx, DICE_DIV);
122 char dmg_str[80], dice_str[sizeof(dmg_str) + 10];
123 char *tmp = lore_ptr->tmp_msg[lore_ptr->vn];
124 dice_to_string(base_damage, dice_num, dice_side, dice_mult, dice_div, dmg_str);
125 sprintf(dice_str, "(%s)", dmg_str);
127 if (know_armour(r_idx, lore_ptr->know_everything))
128 sprintf(tmp, msg, dice_str);
130 sprintf(tmp, msg, "");
133 void set_drop_flags(lore_type *lore_ptr)
135 if (!lore_ptr->know_everything)
138 lore_ptr->drop_gold = lore_ptr->drop_item = (((lore_ptr->r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) + ((lore_ptr->r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) + ((lore_ptr->r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) + ((lore_ptr->r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) + ((lore_ptr->r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) + ((lore_ptr->r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
140 if (lore_ptr->r_ptr->flags1 & RF1_ONLY_GOLD)
141 lore_ptr->drop_item = 0;
143 if (lore_ptr->r_ptr->flags1 & RF1_ONLY_ITEM)
144 lore_ptr->drop_gold = 0;
146 lore_ptr->flags1 = lore_ptr->r_ptr->flags1;
147 lore_ptr->flags2 = lore_ptr->r_ptr->flags2;
148 lore_ptr->flags3 = lore_ptr->r_ptr->flags3;
149 lore_ptr->ability_flags = lore_ptr->r_ptr->ability_flags;
150 lore_ptr->aura_flags = lore_ptr->r_ptr->aura_flags;
151 lore_ptr->behavior_flags = lore_ptr->r_ptr->behavior_flags;
152 lore_ptr->flagsr = lore_ptr->r_ptr->flagsr;