-
Notifications
You must be signed in to change notification settings - Fork 22
/
random-art-misc.cpp
394 lines (347 loc) · 9.49 KB
/
random-art-misc.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
/*!
* @file random-art-misc.cpp
* @brief ランダムアーティファクト生成のその他特性バイアス付け実装 / Artifact code
*/
#include "artifact/random-art-misc.h"
#include "artifact/random-art-bias-types.h"
#include "object-enchant/tr-types.h"
#include "object-hook/hook-armor.h"
#include "object/tval-types.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
static bool invest_misc_ranger(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SUST_CON)) {
return false;
}
o_ptr->art_flags.set(TR_SUST_CON);
return one_in_(2);
}
static bool invest_misc_strength(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SUST_STR)) {
return false;
}
o_ptr->art_flags.set(TR_SUST_STR);
return one_in_(2);
}
static bool invest_misc_wisdom(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SUST_WIS)) {
return false;
}
o_ptr->art_flags.set(TR_SUST_WIS);
return one_in_(2);
}
static bool invest_misc_intelligence(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SUST_INT)) {
return false;
}
o_ptr->art_flags.set(TR_SUST_INT);
return one_in_(2);
}
static bool invest_misc_dexterity(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SUST_DEX)) {
return false;
}
o_ptr->art_flags.set(TR_SUST_DEX);
return one_in_(2);
}
static bool invest_misc_constitution(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SUST_CON)) {
return false;
}
o_ptr->art_flags.set(TR_SUST_CON);
return one_in_(2);
}
static bool invest_misc_charisma(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_SUST_CHR)) {
return false;
}
o_ptr->art_flags.set(TR_SUST_CHR);
return one_in_(2);
}
static bool invest_misc_chaos(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_TELEPORT)) {
return false;
}
o_ptr->art_flags.set(TR_TELEPORT);
return one_in_(2);
}
static bool invest_misc_res_curse(ItemEntity *o_ptr)
{
if (o_ptr->art_flags.has(TR_RES_CURSE)) {
return false;
}
o_ptr->art_flags.set(TR_RES_CURSE);
return one_in_(2);
}
/*!
* @brief アーティファクトのバイアス値に基づいて特性を付与する
* @param o_ptr 対象のオブジェクト構造体への参照ポインタ
* @return 処理続行ならFALSE、打ち切るならTRUE
*/
static bool switch_misc_bias(ItemEntity *o_ptr)
{
switch (o_ptr->artifact_bias) {
case BIAS_RANGER:
return invest_misc_ranger(o_ptr);
case BIAS_STR:
return invest_misc_strength(o_ptr);
case BIAS_INT:
return invest_misc_intelligence(o_ptr);
case BIAS_WIS:
return invest_misc_wisdom(o_ptr);
case BIAS_DEX:
return invest_misc_dexterity(o_ptr);
case BIAS_CON:
return invest_misc_constitution(o_ptr);
case BIAS_CHR:
return invest_misc_charisma(o_ptr);
case BIAS_CHAOS:
return invest_misc_chaos(o_ptr);
case BIAS_FIRE:
if (o_ptr->art_flags.has_not(TR_LITE_1)) {
o_ptr->art_flags.set(TR_LITE_1);
}
return false;
default:
return false;
}
}
static void invest_misc_hit_dice(ItemEntity *o_ptr)
{
o_ptr->art_flags.set(TR_SHOW_MODS);
HIT_PROB bonus_h = 4 + (HIT_PROB)randint1(11);
int bonus_d = 4 + (int)randint1(11);
const auto is_weapon = o_ptr->is_melee_weapon();
const auto tval = o_ptr->bi_key.tval();
if (!is_weapon && (tval != ItemKindType::GLOVES) && (tval != ItemKindType::RING)) {
bonus_h /= 2;
bonus_d /= 2;
}
o_ptr->to_h += bonus_h;
o_ptr->to_d += bonus_d;
}
static void invest_misc_string_esp(ItemEntity *o_ptr)
{
switch (randint1(3)) {
case 1:
o_ptr->art_flags.set(TR_ESP_EVIL);
if (!o_ptr->artifact_bias && one_in_(3)) {
o_ptr->artifact_bias = BIAS_LAW;
}
return;
case 2:
o_ptr->art_flags.set(TR_ESP_NONLIVING);
if (!o_ptr->artifact_bias && one_in_(3)) {
o_ptr->artifact_bias = BIAS_MAGE;
}
return;
case 3:
o_ptr->art_flags.set(TR_TELEPATHY);
if (!o_ptr->artifact_bias && one_in_(9)) {
o_ptr->artifact_bias = BIAS_MAGE;
}
return;
}
}
static void switch_investment_weak_esps(ItemEntity *o_ptr, const int *idx, const int n)
{
switch (idx[n]) {
case 1:
o_ptr->art_flags.set(TR_ESP_ANIMAL);
if (!o_ptr->artifact_bias && one_in_(4)) {
o_ptr->artifact_bias = BIAS_RANGER;
}
break;
case 2:
o_ptr->art_flags.set(TR_ESP_UNDEAD);
if (!o_ptr->artifact_bias && one_in_(3)) {
o_ptr->artifact_bias = BIAS_PRIESTLY;
} else if (!o_ptr->artifact_bias && one_in_(6)) {
o_ptr->artifact_bias = BIAS_NECROMANTIC;
}
break;
case 3:
o_ptr->art_flags.set(TR_ESP_DEMON);
break;
case 4:
o_ptr->art_flags.set(TR_ESP_ORC);
break;
case 5:
o_ptr->art_flags.set(TR_ESP_TROLL);
break;
case 6:
o_ptr->art_flags.set(TR_ESP_GIANT);
break;
case 7:
o_ptr->art_flags.set(TR_ESP_DRAGON);
break;
case 8:
o_ptr->art_flags.set(TR_ESP_HUMAN);
if (!o_ptr->artifact_bias && one_in_(6)) {
o_ptr->artifact_bias = BIAS_ROGUE;
}
break;
case 9:
o_ptr->art_flags.set(TR_ESP_GOOD);
if (!o_ptr->artifact_bias && one_in_(3)) {
o_ptr->artifact_bias = BIAS_LAW;
}
break;
case 10:
o_ptr->art_flags.set(TR_ESP_UNIQUE);
if (!o_ptr->artifact_bias && one_in_(3)) {
o_ptr->artifact_bias = BIAS_LAW;
}
break;
}
}
static void invest_misc_weak_esps(ItemEntity *o_ptr)
{
int idx[3];
idx[0] = randint1(10);
idx[1] = randint1(9);
if (idx[1] >= idx[0]) {
idx[1]++;
}
idx[2] = randint1(8);
if (idx[2] >= idx[0]) {
idx[2]++;
}
if (idx[2] >= idx[1]) {
idx[2]++;
}
int n = randint1(3);
while (n--) {
switch_investment_weak_esps(o_ptr, idx, n);
}
}
/*!
* @brief ランダムアーティファクト生成中、対象のオブジェクトにその他特性を付加する。/ Add one misc flag on generation of randam artifact.
* @details 優先的に付加される耐性がランダムアーティファクトバイアスに依存して存在する。
* 原則的候補は各種能力維持、永久光源+1、麻痺知らず、経験値維持、浮遊、透明視、急回復、遅消化、
* 乱テレポート、反魔法、反テレポート、警告、テレパシー、各種ESP、一部装備に殺戮修正。
* @attention オブジェクトのtval、svalに依存したハードコーディング処理がある。
* @param o_ptr 対象のオブジェクト構造体ポインタ
*/
void random_misc(PlayerType *player_ptr, ItemEntity *o_ptr)
{
if (switch_misc_bias(o_ptr)) {
return;
}
switch (randint1(34)) {
case 1:
o_ptr->art_flags.set(TR_SUST_STR);
if (!o_ptr->artifact_bias) {
o_ptr->artifact_bias = BIAS_STR;
}
break;
case 2:
o_ptr->art_flags.set(TR_SUST_INT);
if (!o_ptr->artifact_bias) {
o_ptr->artifact_bias = BIAS_INT;
}
break;
case 3:
o_ptr->art_flags.set(TR_SUST_WIS);
if (!o_ptr->artifact_bias) {
o_ptr->artifact_bias = BIAS_WIS;
}
break;
case 4:
o_ptr->art_flags.set(TR_SUST_DEX);
if (!o_ptr->artifact_bias) {
o_ptr->artifact_bias = BIAS_DEX;
}
break;
case 5:
o_ptr->art_flags.set(TR_SUST_CON);
if (!o_ptr->artifact_bias) {
o_ptr->artifact_bias = BIAS_CON;
}
break;
case 6:
o_ptr->art_flags.set(TR_SUST_CHR);
if (!o_ptr->artifact_bias) {
o_ptr->artifact_bias = BIAS_CHR;
}
break;
case 7:
case 8:
case 14:
o_ptr->art_flags.set(TR_FREE_ACT);
break;
case 9:
o_ptr->art_flags.set(TR_HOLD_EXP);
if (!o_ptr->artifact_bias && one_in_(5)) {
o_ptr->artifact_bias = BIAS_PRIESTLY;
} else if (!o_ptr->artifact_bias && one_in_(6)) {
o_ptr->artifact_bias = BIAS_NECROMANTIC;
}
break;
case 10:
case 11:
o_ptr->art_flags.set(TR_LITE_1);
break;
case 12:
case 13:
o_ptr->art_flags.set(TR_LEVITATION);
break;
case 15:
case 16:
case 17:
o_ptr->art_flags.set(TR_SEE_INVIS);
break;
case 19:
case 20:
o_ptr->art_flags.set(TR_SLOW_DIGEST);
break;
case 21:
case 22:
o_ptr->art_flags.set(TR_REGEN);
break;
case 23:
o_ptr->art_flags.set(TR_TELEPORT);
break;
case 24:
case 25:
case 26:
if (o_ptr->is_protector()) {
random_misc(player_ptr, o_ptr);
} else {
o_ptr->to_a = 4 + randint1(11);
}
break;
case 27:
case 28:
case 29:
invest_misc_hit_dice(o_ptr);
break;
case 30:
o_ptr->art_flags.set(TR_NO_MAGIC);
break;
case 31:
o_ptr->art_flags.set(TR_NO_TELE);
break;
case 32:
o_ptr->art_flags.set(TR_WARNING);
break;
case 18:
invest_misc_string_esp(o_ptr);
break;
case 33:
invest_misc_weak_esps(o_ptr);
break;
case 34:
invest_misc_res_curse(o_ptr);
break;
}
}