2 * @file random-art-slay.cpp
3 * @brief ランダムアーティファクトのスレイ付加処理実装
6 #include "artifact/random-art-slay.h"
7 #include "artifact/random-art-bias-types.h"
8 #include "object-enchant/tr-types.h"
9 #include "object/tval-types.h"
10 #include "sv-definition/sv-weapon-types.h"
11 #include "system/item-entity.h"
12 #include "util/bit-flags-calculator.h"
14 static bool random_art_slay_bow(ItemEntity *o_ptr)
16 if (o_ptr->bi_key.tval() != ItemKindType::BOW) {
20 switch (randint1(6)) {
24 o_ptr->art_flags.set(TR_XTRA_MIGHT);
26 o_ptr->art_flags.reset(TR_XTRA_SHOTS);
29 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
30 o_ptr->artifact_bias = BIAS_RANGER;
35 o_ptr->art_flags.set(TR_XTRA_SHOTS);
37 o_ptr->art_flags.reset(TR_XTRA_MIGHT);
40 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
41 o_ptr->artifact_bias = BIAS_RANGER;
48 static bool random_art_slay_chaos(ItemEntity *o_ptr)
50 if (o_ptr->art_flags.has(TR_CHAOTIC)) {
54 o_ptr->art_flags.set(TR_CHAOTIC);
58 static bool random_art_brand_magical(ItemEntity *o_ptr)
60 if (o_ptr->art_flags.has(TR_BRAND_MAGIC)) {
64 o_ptr->art_flags.set(TR_BRAND_MAGIC);
68 static bool random_art_slay_vampiric(ItemEntity *o_ptr)
70 if (o_ptr->art_flags.has(TR_VAMPIRIC)) {
74 o_ptr->art_flags.set(TR_VAMPIRIC);
78 static bool random_art_slay_brand_acid(ItemEntity *o_ptr)
80 if (o_ptr->art_flags.has(TR_BRAND_ACID)) {
84 o_ptr->art_flags.set(TR_BRAND_ACID);
88 static bool random_art_slay_brand_elec(ItemEntity *o_ptr)
90 if (o_ptr->art_flags.has(TR_BRAND_ELEC)) {
94 o_ptr->art_flags.set(TR_BRAND_ELEC);
98 static bool random_art_slay_brand_fire(ItemEntity *o_ptr)
100 if (o_ptr->art_flags.has(TR_BRAND_FIRE)) {
104 o_ptr->art_flags.set(TR_BRAND_FIRE);
108 static bool random_art_slay_brand_cold(ItemEntity *o_ptr)
110 if (o_ptr->art_flags.has(TR_BRAND_COLD)) {
114 o_ptr->art_flags.set(TR_BRAND_COLD);
118 static bool random_art_slay_brand_pois(ItemEntity *o_ptr)
120 if (o_ptr->art_flags.has(TR_BRAND_POIS) || one_in_(2)) {
124 o_ptr->art_flags.set(TR_BRAND_POIS);
128 static bool random_art_slay_animal(ItemEntity *o_ptr)
130 if (o_ptr->art_flags.has(TR_SLAY_ANIMAL)) {
134 o_ptr->art_flags.set(TR_SLAY_ANIMAL);
138 static bool random_art_slay_evil(ItemEntity *o_ptr)
140 if (o_ptr->art_flags.has(TR_SLAY_EVIL)) {
144 o_ptr->art_flags.set(TR_SLAY_EVIL);
148 static bool random_art_slay_undead(ItemEntity *o_ptr)
150 if (o_ptr->art_flags.has(TR_SLAY_UNDEAD)) {
154 o_ptr->art_flags.set(TR_SLAY_UNDEAD);
158 static bool random_art_slay_demon(ItemEntity *o_ptr)
160 if (o_ptr->art_flags.has(TR_SLAY_DEMON)) {
164 o_ptr->art_flags.set(TR_SLAY_DEMON);
168 static bool switch_random_art_slay(ItemEntity *o_ptr)
170 switch (o_ptr->artifact_bias) {
172 return random_art_slay_chaos(o_ptr);
175 return random_art_brand_magical(o_ptr);
176 case BIAS_PRIESTLY: {
177 const auto tval = o_ptr->bi_key.tval();
178 if (((tval == ItemKindType::SWORD) || (tval == ItemKindType::POLEARM)) && o_ptr->art_flags.has_not(TR_BLESSED)) {
179 o_ptr->art_flags.set(TR_BLESSED);
184 case BIAS_NECROMANTIC:
185 return random_art_slay_vampiric(o_ptr) || random_art_slay_brand_pois(o_ptr);
187 return random_art_slay_animal(o_ptr);
189 auto is_throwable = o_ptr->bi_key == BaseitemKey(ItemKindType::SWORD, SV_DAGGER);
190 is_throwable |= o_ptr->bi_key == BaseitemKey(ItemKindType::POLEARM, SV_SPEAR);
191 if (is_throwable && o_ptr->art_flags.has_not(TR_THROW)) {
192 o_ptr->art_flags.set(TR_THROW);
195 return random_art_slay_brand_pois(o_ptr);
198 return random_art_slay_brand_pois(o_ptr);
200 return random_art_slay_brand_acid(o_ptr);
202 return random_art_slay_brand_elec(o_ptr);
204 return random_art_slay_brand_fire(o_ptr);
206 return random_art_slay_brand_cold(o_ptr);
208 return random_art_slay_evil(o_ptr) || random_art_slay_undead(o_ptr) || random_art_slay_demon(o_ptr);
215 * @brief ランダムアーティファクト生成中、対象のオブジェクトにスレイ効果を付加する。/ Add one slaying on generation of randam artifact.
216 * @details 優先的に付加される耐性がランダムアーティファクトバイアスに依存して存在する。
217 * 原則的候補は強力射、高速射、混沌効果、吸血効果、祝福、投擲しやすい、焼棄、凍結、電撃、溶解、毒殺、
218 * 動物スレイ、邪悪スレイ、悪魔スレイ、不死スレイ、オークスレイ、トロルスレイ、巨人スレイ、ドラゴンスレイ、
219 * *ドラゴンスレイ*、人間スレイ、切れ味、地震、理力。
220 * @attention オブジェクトのtval、svalに依存したハードコーディング処理がある。
221 * @param o_ptr 対象のオブジェクト構造体ポインタ
223 void random_slay(ItemEntity *o_ptr)
225 if (random_art_slay_bow(o_ptr) || switch_random_art_slay(o_ptr)) {
229 switch (randint1(39)) {
233 o_ptr->art_flags.set(TR_KILL_ANIMAL);
235 o_ptr->art_flags.set(TR_SLAY_ANIMAL);
242 o_ptr->art_flags.set(TR_KILL_EVIL);
244 o_ptr->art_flags.set(TR_SLAY_EVIL);
247 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(2)) {
248 o_ptr->artifact_bias = BIAS_LAW;
252 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
253 o_ptr->artifact_bias = BIAS_PRIESTLY;
260 o_ptr->art_flags.set(TR_KILL_UNDEAD);
262 o_ptr->art_flags.set(TR_SLAY_UNDEAD);
265 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
266 o_ptr->artifact_bias = BIAS_PRIESTLY;
273 o_ptr->art_flags.set(TR_KILL_DEMON);
275 o_ptr->art_flags.set(TR_SLAY_DEMON);
278 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
279 o_ptr->artifact_bias = BIAS_PRIESTLY;
286 o_ptr->art_flags.set(TR_KILL_ORC);
288 o_ptr->art_flags.set(TR_SLAY_ORC);
295 o_ptr->art_flags.set(TR_KILL_TROLL);
297 o_ptr->art_flags.set(TR_SLAY_TROLL);
304 o_ptr->art_flags.set(TR_KILL_GIANT);
306 o_ptr->art_flags.set(TR_SLAY_GIANT);
312 o_ptr->art_flags.set(TR_SLAY_DRAGON);
315 o_ptr->art_flags.set(TR_KILL_DRAGON);
319 if (o_ptr->bi_key.tval() != ItemKindType::SWORD) {
324 o_ptr->art_flags.set(TR_VORPAL);
325 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
326 o_ptr->artifact_bias = BIAS_WARRIOR;
331 o_ptr->art_flags.set(TR_EARTHQUAKE);
335 o_ptr->art_flags.set(TR_BRAND_FIRE);
336 if (o_ptr->artifact_bias == BIAS_NONE) {
337 o_ptr->artifact_bias = BIAS_FIRE;
343 o_ptr->art_flags.set(TR_BRAND_COLD);
344 if (o_ptr->artifact_bias == BIAS_NONE) {
345 o_ptr->artifact_bias = BIAS_COLD;
351 o_ptr->art_flags.set(TR_BRAND_ELEC);
352 if (o_ptr->artifact_bias == BIAS_NONE) {
353 o_ptr->artifact_bias = BIAS_ELEC;
359 o_ptr->art_flags.set(TR_BRAND_ACID);
360 if (!o_ptr->artifact_bias) {
361 o_ptr->artifact_bias = BIAS_ACID;
367 o_ptr->art_flags.set(TR_BRAND_POIS);
368 if ((o_ptr->artifact_bias == BIAS_NONE) && !one_in_(3)) {
369 o_ptr->artifact_bias = BIAS_POIS;
373 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(6)) {
374 o_ptr->artifact_bias = BIAS_NECROMANTIC;
378 if (o_ptr->artifact_bias == BIAS_NONE) {
379 o_ptr->artifact_bias = BIAS_ROGUE;
384 o_ptr->art_flags.set(TR_VAMPIRIC);
385 if (o_ptr->artifact_bias == BIAS_NONE) {
386 o_ptr->artifact_bias = BIAS_NECROMANTIC;
391 o_ptr->art_flags.set(TR_FORCE_WEAPON);
392 if (o_ptr->artifact_bias == BIAS_NONE) {
393 o_ptr->artifact_bias = (one_in_(2) ? BIAS_MAGE : BIAS_PRIESTLY);
400 o_ptr->art_flags.set(TR_KILL_HUMAN);
402 o_ptr->art_flags.set(TR_SLAY_HUMAN);
407 o_ptr->art_flags.set(TR_BRAND_MAGIC);
408 if (o_ptr->artifact_bias == BIAS_NONE) {
409 o_ptr->artifact_bias = BIAS_MAGE;
414 o_ptr->art_flags.set(TR_CHAOTIC);
415 if (o_ptr->artifact_bias == BIAS_NONE) {
416 o_ptr->artifact_bias = BIAS_CHAOS;
422 o_ptr->art_flags.set(TR_KILL_GOOD);
424 o_ptr->art_flags.set(TR_SLAY_GOOD);
427 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(2)) {
428 o_ptr->artifact_bias = BIAS_POIS;
432 if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
433 o_ptr->artifact_bias = BIAS_ROGUE;