-
Notifications
You must be signed in to change notification settings - Fork 22
/
random-art-slay.cpp
438 lines (375 loc) · 11 KB
/
random-art-slay.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
/*!
* @file random-art-slay.cpp
* @brief ランダムアーティファクトのスレイ付加処理実装
*/
#include "artifact/random-art-slay.h"
#include "artifact/random-art-bias-types.h"
#include "object-enchant/tr-types.h"
#include "object/tval-types.h"
#include "sv-definition/sv-weapon-types.h"
#include "system/item-entity.h"
#include "util/bit-flags-calculator.h"
static bool random_art_slay_bow(ItemEntity *o_ptr)
{
if (o_ptr->bi_key.tval() != ItemKindType::BOW) {
return false;
}
switch (randint1(6)) {
case 1:
case 2:
case 3:
o_ptr->art_flags.set(TR_XTRA_MIGHT);
if (!one_in_(7)) {
o_ptr->art_flags.reset(TR_XTRA_SHOTS);
}
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
o_ptr->artifact_bias = BIAS_RANGER;
}
return true;
default:
o_ptr->art_flags.set(TR_XTRA_SHOTS);
if (!one_in_(7)) {
o_ptr->art_flags.reset(TR_XTRA_MIGHT);
}
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
o_ptr->artifact_bias = BIAS_RANGER;
}
return true;
}
}
static bool random_art_slay_chaos(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_CHAOTIC)) {
return false;
}
o_ptr->art_flags.set(TR_CHAOTIC);
return one_in_(2);
}
static bool random_art_brand_magical(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_BRAND_MAGIC)) {
return false;
}
o_ptr->art_flags.set(TR_BRAND_MAGIC);
return one_in_(3);
}
static bool random_art_slay_vampiric(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_VAMPIRIC)) {
return false;
}
o_ptr->art_flags.set(TR_VAMPIRIC);
return one_in_(2);
}
static bool random_art_slay_brand_acid(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_BRAND_ACID)) {
return false;
}
o_ptr->art_flags.set(TR_BRAND_ACID);
return one_in_(2);
}
static bool random_art_slay_brand_elec(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_BRAND_ELEC)) {
return false;
}
o_ptr->art_flags.set(TR_BRAND_ELEC);
return one_in_(2);
}
static bool random_art_slay_brand_fire(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_BRAND_FIRE)) {
return false;
}
o_ptr->art_flags.set(TR_BRAND_FIRE);
return one_in_(2);
}
static bool random_art_slay_brand_cold(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_BRAND_COLD)) {
return false;
}
o_ptr->art_flags.set(TR_BRAND_COLD);
return one_in_(2);
}
static bool random_art_slay_brand_pois(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_BRAND_POIS) || one_in_(2)) {
return false;
}
o_ptr->art_flags.set(TR_BRAND_POIS);
return one_in_(2);
}
static bool random_art_slay_animal(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SLAY_ANIMAL)) {
return false;
}
o_ptr->art_flags.set(TR_SLAY_ANIMAL);
return one_in_(2);
}
static bool random_art_slay_evil(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SLAY_EVIL)) {
return false;
}
o_ptr->art_flags.set(TR_SLAY_EVIL);
return one_in_(2);
}
static bool random_art_slay_undead(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SLAY_UNDEAD)) {
return false;
}
o_ptr->art_flags.set(TR_SLAY_UNDEAD);
return one_in_(2);
}
static bool random_art_slay_demon(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SLAY_DEMON)) {
return false;
}
o_ptr->art_flags.set(TR_SLAY_DEMON);
return one_in_(2);
}
static bool switch_random_art_slay(ItemEntity *o_ptr)
{
switch (o_ptr->artifact_bias) {
case BIAS_CHAOS:
return random_art_slay_chaos(o_ptr);
case BIAS_MAGE:
case BIAS_INT:
return random_art_brand_magical(o_ptr);
case BIAS_PRIESTLY: {
const auto tval = o_ptr->bi_key.tval();
if (((tval == ItemKindType::SWORD) || (tval == ItemKindType::POLEARM)) && o_ptr->art_flags.has_not(TR_BLESSED)) {
o_ptr->art_flags.set(TR_BLESSED);
}
return false;
}
case BIAS_NECROMANTIC:
return random_art_slay_vampiric(o_ptr) || random_art_slay_brand_pois(o_ptr);
case BIAS_RANGER:
return random_art_slay_animal(o_ptr);
case BIAS_ROGUE: {
auto is_throwable = o_ptr->bi_key == BaseitemKey(ItemKindType::SWORD, SV_DAGGER);
is_throwable |= o_ptr->bi_key == BaseitemKey(ItemKindType::POLEARM, SV_SPEAR);
if (is_throwable && o_ptr->art_flags.has_not(TR_THROW)) {
o_ptr->art_flags.set(TR_THROW);
}
return random_art_slay_brand_pois(o_ptr);
}
case BIAS_POIS:
return random_art_slay_brand_pois(o_ptr);
case BIAS_ACID:
return random_art_slay_brand_acid(o_ptr);
case BIAS_ELEC:
return random_art_slay_brand_elec(o_ptr);
case BIAS_FIRE:
return random_art_slay_brand_fire(o_ptr);
case BIAS_COLD:
return random_art_slay_brand_cold(o_ptr);
case BIAS_LAW:
return random_art_slay_evil(o_ptr) || random_art_slay_undead(o_ptr) || random_art_slay_demon(o_ptr);
default:
return false;
}
}
/*!
* @brief ランダムアーティファクト生成中、対象のオブジェクトにスレイ効果を付加する。/ Add one slaying on generation of randam artifact.
* @details 優先的に付加される耐性がランダムアーティファクトバイアスに依存して存在する。
* 原則的候補は強力射、高速射、混沌効果、吸血効果、祝福、投擲しやすい、焼棄、凍結、電撃、溶解、毒殺、
* 動物スレイ、邪悪スレイ、悪魔スレイ、不死スレイ、オークスレイ、トロルスレイ、巨人スレイ、ドラゴンスレイ、
* *ドラゴンスレイ*、人間スレイ、切れ味、地震、理力。
* @attention オブジェクトのtval、svalに依存したハードコーディング処理がある。
* @param o_ptr 対象のオブジェクト構造体ポインタ
*/
void random_slay(ItemEntity *o_ptr)
{
if (random_art_slay_bow(o_ptr) || switch_random_art_slay(o_ptr)) {
return;
}
switch (randint1(39)) {
case 1:
case 2:
if (one_in_(4)) {
o_ptr->art_flags.set(TR_KILL_ANIMAL);
} else {
o_ptr->art_flags.set(TR_SLAY_ANIMAL);
}
break;
case 3:
case 4:
if (one_in_(8)) {
o_ptr->art_flags.set(TR_KILL_EVIL);
} else {
o_ptr->art_flags.set(TR_SLAY_EVIL);
}
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(2)) {
o_ptr->artifact_bias = BIAS_LAW;
break;
}
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
o_ptr->artifact_bias = BIAS_PRIESTLY;
}
break;
case 5:
case 6:
if (one_in_(4)) {
o_ptr->art_flags.set(TR_KILL_UNDEAD);
} else {
o_ptr->art_flags.set(TR_SLAY_UNDEAD);
}
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
o_ptr->artifact_bias = BIAS_PRIESTLY;
}
break;
case 7:
case 8:
if (one_in_(4)) {
o_ptr->art_flags.set(TR_KILL_DEMON);
} else {
o_ptr->art_flags.set(TR_SLAY_DEMON);
}
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
o_ptr->artifact_bias = BIAS_PRIESTLY;
}
break;
case 9:
case 10:
if (one_in_(4)) {
o_ptr->art_flags.set(TR_KILL_ORC);
} else {
o_ptr->art_flags.set(TR_SLAY_ORC);
}
break;
case 11:
case 12:
if (one_in_(4)) {
o_ptr->art_flags.set(TR_KILL_TROLL);
} else {
o_ptr->art_flags.set(TR_SLAY_TROLL);
}
break;
case 13:
case 14:
if (one_in_(4)) {
o_ptr->art_flags.set(TR_KILL_GIANT);
} else {
o_ptr->art_flags.set(TR_SLAY_GIANT);
}
break;
case 15:
case 16:
o_ptr->art_flags.set(TR_SLAY_DRAGON);
break;
case 17:
o_ptr->art_flags.set(TR_KILL_DRAGON);
break;
case 18:
case 19:
if (o_ptr->bi_key.tval() != ItemKindType::SWORD) {
random_slay(o_ptr);
break;
}
o_ptr->art_flags.set(TR_VORPAL);
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
o_ptr->artifact_bias = BIAS_WARRIOR;
}
break;
case 20:
o_ptr->art_flags.set(TR_EARTHQUAKE);
break;
case 21:
case 22:
o_ptr->art_flags.set(TR_BRAND_FIRE);
if (o_ptr->artifact_bias == BIAS_NONE) {
o_ptr->artifact_bias = BIAS_FIRE;
}
break;
case 23:
case 24:
o_ptr->art_flags.set(TR_BRAND_COLD);
if (o_ptr->artifact_bias == BIAS_NONE) {
o_ptr->artifact_bias = BIAS_COLD;
}
break;
case 25:
case 26:
o_ptr->art_flags.set(TR_BRAND_ELEC);
if (o_ptr->artifact_bias == BIAS_NONE) {
o_ptr->artifact_bias = BIAS_ELEC;
}
break;
case 27:
case 28:
o_ptr->art_flags.set(TR_BRAND_ACID);
if (!o_ptr->artifact_bias) {
o_ptr->artifact_bias = BIAS_ACID;
}
break;
case 29:
case 30:
o_ptr->art_flags.set(TR_BRAND_POIS);
if ((o_ptr->artifact_bias == BIAS_NONE) && !one_in_(3)) {
o_ptr->artifact_bias = BIAS_POIS;
break;
}
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(6)) {
o_ptr->artifact_bias = BIAS_NECROMANTIC;
break;
}
if (o_ptr->artifact_bias == BIAS_NONE) {
o_ptr->artifact_bias = BIAS_ROGUE;
}
break;
case 31:
o_ptr->art_flags.set(TR_VAMPIRIC);
if (o_ptr->artifact_bias == BIAS_NONE) {
o_ptr->artifact_bias = BIAS_NECROMANTIC;
}
break;
case 32:
o_ptr->art_flags.set(TR_FORCE_WEAPON);
if (o_ptr->artifact_bias == BIAS_NONE) {
o_ptr->artifact_bias = (one_in_(2) ? BIAS_MAGE : BIAS_PRIESTLY);
}
break;
case 33:
case 34:
if (one_in_(4)) {
o_ptr->art_flags.set(TR_KILL_HUMAN);
} else {
o_ptr->art_flags.set(TR_SLAY_HUMAN);
}
break;
case 35:
o_ptr->art_flags.set(TR_BRAND_MAGIC);
if (o_ptr->artifact_bias == BIAS_NONE) {
o_ptr->artifact_bias = BIAS_MAGE;
}
break;
case 36:
case 37:
o_ptr->art_flags.set(TR_CHAOTIC);
if (o_ptr->artifact_bias == BIAS_NONE) {
o_ptr->artifact_bias = BIAS_CHAOS;
}
break;
default:
if (one_in_(8)) {
o_ptr->art_flags.set(TR_KILL_GOOD);
} else {
o_ptr->art_flags.set(TR_SLAY_GOOD);
}
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(2)) {
o_ptr->artifact_bias = BIAS_POIS;
break;
}
if ((o_ptr->artifact_bias == BIAS_NONE) && one_in_(9)) {
o_ptr->artifact_bias = BIAS_ROGUE;
}
break;
}
}