OSDN Git Service

[Refactor] #40514 has_immune_acid() を BIT_FLAGS 返り値持ちに仕様変更. / has_immune_acid() was...
[hengband/hengband.git] / src / player / player-status-flags.c
1 #include "player/player-status-flags.h"
2 #include "art-definition/art-sword-types.h"
3 #include "grid/grid.h"
4 #include "inventory/inventory-slot-types.h"
5 #include "monster-race/monster-race.h"
6 #include "monster-race/race-flags2.h"
7 #include "monster-race/race-flags7.h"
8 #include "mutation/mutation-flag-types.h"
9 #include "object-enchant/object-ego.h"
10 #include "object-enchant/tr-types.h"
11 #include "object-enchant/trc-types.h"
12 #include "object-hook/hook-checker.h"
13 #include "object-hook/hook-weapon.h"
14 #include "object/object-flags.h"
15 #include "player/player-class.h"
16 #include "player/player-race-types.h"
17 #include "player/player-race.h"
18 #include "player/player-skill.h"
19 #include "player/player-status.h"
20 #include "player/special-defense-types.h"
21 #include "realm/realm-hex-numbers.h"
22 #include "realm/realm-song-numbers.h"
23 #include "realm/realm-types.h"
24 #include "spell-realm/spells-hex.h"
25 #include "sv-definition/sv-weapon-types.h"
26 #include "system/floor-type-definition.h"
27 #include "system/monster-type-definition.h"
28 #include "system/object-type-definition.h"
29 #include "util/bit-flags-calculator.h"
30 #include "util/quarks.h"
31 #include "util/string-processor.h"
32
33 static BIT_FLAGS check_equipment_flags(player_type *creature_ptr, tr_type tr_flag);
34
35 static BIT_FLAGS check_equipment_flags(player_type *creature_ptr, tr_type tr_flag)
36 {
37     object_type *o_ptr;
38     BIT_FLAGS flgs[TR_FLAG_SIZE];
39     BIT_FLAGS result = 0L;
40     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
41         o_ptr = &creature_ptr->inventory_list[i];
42         if (!o_ptr->k_idx)
43             continue;
44
45         object_flags(creature_ptr, o_ptr, flgs);
46
47         if (has_flag(flgs, tr_flag))
48             result |= 0x01 << (i - INVEN_RARM);
49     }
50     return result;
51 }
52
53 bool has_kill_wall(player_type *creature_ptr)
54 {
55     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || music_singing(creature_ptr, MUSIC_WALL)) {
56         return TRUE;
57     }
58
59     if (creature_ptr->riding) {
60         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
61         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
62         if (riding_r_ptr->flags2 & RF2_KILL_WALL)
63             return TRUE;
64     }
65
66     return FALSE;
67 }
68
69 bool has_pass_wall(player_type *creature_ptr)
70 {
71     bool pow = FALSE;
72
73     if (creature_ptr->wraith_form || creature_ptr->tim_pass_wall || (!creature_ptr->mimic_form && creature_ptr->prace == RACE_SPECTRE)) {
74         pow = TRUE;
75     }
76
77     if (creature_ptr->riding) {
78         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
79         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
80         if (!(riding_r_ptr->flags2 & RF2_PASS_WALL))
81             pow = FALSE;
82     }
83
84     return pow;
85 }
86
87 BIT_FLAGS has_xtra_might(player_type *creature_ptr)
88 {
89     BIT_FLAGS result = 0L;
90     result |= check_equipment_flags(creature_ptr, TR_XTRA_MIGHT);
91     return result;
92 }
93
94 BIT_FLAGS has_esp_evil(player_type *creature_ptr)
95 {
96     BIT_FLAGS result = 0L;
97     if (creature_ptr->realm1 == REALM_HEX) {
98         if (hex_spelling(creature_ptr, HEX_DETECT_EVIL))
99             result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
100     }
101     result |= check_equipment_flags(creature_ptr, TR_ESP_EVIL);
102     return result;
103 }
104
105 BIT_FLAGS has_esp_animal(player_type *creature_ptr)
106 {
107     BIT_FLAGS result = 0L;
108     result |= check_equipment_flags(creature_ptr, TR_ESP_ANIMAL);
109     return result;
110 }
111
112 BIT_FLAGS has_esp_undead(player_type *creature_ptr)
113 {
114     BIT_FLAGS result = 0L;
115     result |= check_equipment_flags(creature_ptr, TR_ESP_UNDEAD);
116     return result;
117 }
118
119 BIT_FLAGS has_esp_demon(player_type *creature_ptr)
120 {
121     BIT_FLAGS result = 0L;
122     result |= check_equipment_flags(creature_ptr, TR_ESP_DEMON);
123     return result;
124 }
125
126 BIT_FLAGS has_esp_orc(player_type *creature_ptr)
127 {
128     BIT_FLAGS result = 0L;
129     result |= check_equipment_flags(creature_ptr, TR_ESP_ORC);
130     return result;
131 }
132
133 BIT_FLAGS has_esp_troll(player_type *creature_ptr)
134 {
135     BIT_FLAGS result = 0L;
136     result |= check_equipment_flags(creature_ptr, TR_ESP_TROLL);
137     return result;
138 }
139
140 BIT_FLAGS has_esp_giant(player_type *creature_ptr)
141 {
142     BIT_FLAGS result = 0L;
143     result |= check_equipment_flags(creature_ptr, TR_ESP_GIANT);
144     return result;
145 }
146
147 BIT_FLAGS has_esp_dragon(player_type *creature_ptr)
148 {
149     BIT_FLAGS result = 0L;
150     result |= check_equipment_flags(creature_ptr, TR_ESP_DRAGON);
151     return result;
152 }
153
154 BIT_FLAGS has_esp_human(player_type *creature_ptr)
155 {
156     BIT_FLAGS result = 0L;
157     result |= check_equipment_flags(creature_ptr, TR_ESP_HUMAN);
158     return result;
159 }
160
161 BIT_FLAGS has_esp_good(player_type *creature_ptr)
162 {
163     BIT_FLAGS result = 0L;
164     result |= check_equipment_flags(creature_ptr, TR_ESP_GOOD);
165     return result;
166 }
167
168 BIT_FLAGS has_esp_nonliving(player_type *creature_ptr)
169 {
170     BIT_FLAGS result = 0L;
171     result |= check_equipment_flags(creature_ptr, TR_ESP_GOOD);
172     return result;
173 }
174
175 BIT_FLAGS has_esp_unique(player_type *creature_ptr)
176 {
177     BIT_FLAGS result = 0L;
178     result |= check_equipment_flags(creature_ptr, TR_ESP_UNIQUE);
179     return result;
180 }
181
182 BIT_FLAGS has_esp_telepathy(player_type *creature_ptr)
183 {
184     BIT_FLAGS result = 0L;
185
186     if (is_time_limit_esp(creature_ptr) || creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
187         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
188     }
189
190     if (creature_ptr->muta3 & MUT3_ESP) {
191         result |= FLAG_CAUSE_MUTATION;
192     }
193
194     if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER) && creature_ptr->lev > 29)
195         result |= FLAG_CAUSE_RACE;
196
197     if (is_specific_player_race(creature_ptr, RACE_SPECTRE) && creature_ptr->lev > 34)
198         result |= FLAG_CAUSE_RACE;
199
200     if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 39)
201         result |= FLAG_CAUSE_CLASS;
202
203     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
204         result |= FLAG_CAUSE_RACE;
205     }
206
207     result |= check_equipment_flags(creature_ptr, TR_TELEPATHY);
208     return result;
209 }
210
211 BIT_FLAGS has_bless_blade(player_type *creature_ptr)
212 {
213     BIT_FLAGS result = 0L;
214     result |= check_equipment_flags(creature_ptr, TR_BLESSED);
215     return result;
216 }
217
218 BIT_FLAGS has_easy2_weapon(player_type *creature_ptr)
219 {
220     BIT_FLAGS result = 0L;
221     result |= check_equipment_flags(creature_ptr, TR_EASY2_WEAPON);
222     return result;
223 }
224
225 BIT_FLAGS has_down_saving(player_type *creature_ptr)
226 {
227     BIT_FLAGS result = 0L;
228     result |= check_equipment_flags(creature_ptr, TR_DOWN_SAVING);
229     return result;
230 }
231
232 BIT_FLAGS has_no_ac(player_type *creature_ptr)
233 {
234     BIT_FLAGS result = 0L;
235     result |= check_equipment_flags(creature_ptr, TR_NO_AC);
236     return result;
237 }
238
239 void has_no_flowed(player_type *creature_ptr)
240 {
241     object_type *o_ptr;
242     bool has_sw = FALSE, has_kabe = FALSE;
243     OBJECT_IDX this_o_idx, next_o_idx = 0;
244
245     creature_ptr->no_flowed = FALSE;
246
247     if (creature_ptr->pass_wall && !creature_ptr->kill_wall)
248         creature_ptr->no_flowed = TRUE;
249
250     for (int i = 0; i < INVEN_PACK; i++) {
251         if ((creature_ptr->inventory_list[i].tval == TV_NATURE_BOOK) && (creature_ptr->inventory_list[i].sval == 2))
252             has_sw = TRUE;
253         if ((creature_ptr->inventory_list[i].tval == TV_CRAFT_BOOK) && (creature_ptr->inventory_list[i].sval == 2))
254             has_kabe = TRUE;
255     }
256
257     for (this_o_idx = creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx) {
258         o_ptr = &creature_ptr->current_floor_ptr->o_list[this_o_idx];
259         next_o_idx = o_ptr->next_o_idx;
260
261         if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2))
262             has_sw = TRUE;
263         if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2))
264             has_kabe = TRUE;
265     }
266
267     if (has_sw && ((creature_ptr->realm1 == REALM_NATURE) || (creature_ptr->realm2 == REALM_NATURE) || (creature_ptr->pclass == CLASS_SORCERER))) {
268         const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
269         if (creature_ptr->lev >= s_ptr->slevel)
270             creature_ptr->no_flowed = TRUE;
271     }
272
273     if (has_kabe && ((creature_ptr->realm1 == REALM_CRAFT) || (creature_ptr->realm2 == REALM_CRAFT) || (creature_ptr->pclass == CLASS_SORCERER))) {
274         const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_WALL];
275         if (creature_ptr->lev >= s_ptr->slevel)
276             creature_ptr->no_flowed = TRUE;
277     }
278 }
279
280 BIT_FLAGS has_mighty_throw(player_type *creature_ptr)
281 {
282     BIT_FLAGS result = 0L;
283     result |= check_equipment_flags(creature_ptr, TR_MIGHTY_THROW);
284     return result;
285 }
286
287 BIT_FLAGS has_dec_mana(player_type *creature_ptr)
288 {
289     BIT_FLAGS result = 0L;
290     result |= check_equipment_flags(creature_ptr, TR_DEC_MANA);
291     return result;
292 }
293
294 BIT_FLAGS has_reflect(player_type *creature_ptr)
295 {
296     BIT_FLAGS result = 0L;
297
298     if (creature_ptr->pclass == CLASS_BERSERKER && creature_ptr->lev > 39)
299         result |= FLAG_CAUSE_CLASS;
300
301     if (creature_ptr->pclass == CLASS_MIRROR_MASTER && creature_ptr->lev > 39)
302         result |= FLAG_CAUSE_CLASS;
303
304     if (creature_ptr->special_defense & KAMAE_GENBU || creature_ptr->special_defense & KATA_MUSOU) {
305         result |= FLAG_CAUSE_BATTLE_FORM;
306     }
307
308     if (creature_ptr->ult_res || creature_ptr->wraith_form || creature_ptr->magicdef || creature_ptr->tim_reflect) {
309         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
310     }
311
312     result |= check_equipment_flags(creature_ptr, TR_REFLECT);
313     return result;
314 }
315
316 BIT_FLAGS has_see_nocto(player_type *creature_ptr) { return creature_ptr->pclass == CLASS_NINJA ? FLAG_CAUSE_CLASS : 0L; }
317
318 void has_warning(player_type *creature_ptr)
319 {
320     object_type *o_ptr;
321     BIT_FLAGS flgs[TR_FLAG_SIZE];
322
323     creature_ptr->warning = FALSE;
324
325     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
326         o_ptr = &creature_ptr->inventory_list[i];
327         if (!o_ptr->k_idx)
328             continue;
329
330         object_flags(creature_ptr, o_ptr, flgs);
331
332         if (has_flag(flgs, TR_WARNING)) {
333             if (!o_ptr->inscription || !(angband_strchr(quark_str(o_ptr->inscription), '$')))
334                 creature_ptr->warning = TRUE;
335         }
336     }
337 }
338
339 BIT_FLAGS has_anti_magic(player_type *creature_ptr)
340 {
341     BIT_FLAGS result = 0L;
342     result |= check_equipment_flags(creature_ptr, TR_NO_MAGIC);
343     return result;
344 }
345
346 BIT_FLAGS has_anti_tele(player_type *creature_ptr)
347 {
348     BIT_FLAGS result = 0L;
349     result |= check_equipment_flags(creature_ptr, TR_NO_TELE);
350     return result;
351 }
352
353 BIT_FLAGS has_sh_fire(player_type *creature_ptr)
354 {
355     BIT_FLAGS result = 0L;
356
357     if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
358         result |= FLAG_CAUSE_MUTATION;
359     }
360
361     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
362         result |= FLAG_CAUSE_RACE;
363     }
364
365     if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
366         result |= FLAG_CAUSE_BATTLE_FORM;
367     }
368
369     if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_sh_fire) {
370         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
371     }
372
373     result |= check_equipment_flags(creature_ptr, TR_SH_FIRE);
374     return result;
375 }
376
377 BIT_FLAGS has_sh_elec(player_type *creature_ptr)
378 {
379     BIT_FLAGS result = 0L;
380
381     if (creature_ptr->muta3 & MUT3_ELEC_TOUC)
382         result |= FLAG_CAUSE_MUTATION;
383
384     if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK) || creature_ptr->ult_res) {
385         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
386     }
387
388     if (creature_ptr->special_defense & KAMAE_SEIRYU || (creature_ptr->special_defense & KATA_MUSOU)) {
389         result |= FLAG_CAUSE_BATTLE_FORM;
390     }
391
392     result |= check_equipment_flags(creature_ptr, TR_SH_ELEC);
393     return result;
394 }
395
396 BIT_FLAGS has_sh_cold(player_type *creature_ptr)
397 {
398     BIT_FLAGS result = 0L;
399
400     if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KATA_MUSOU) {
401         result |= FLAG_CAUSE_BATTLE_FORM;
402     }
403
404     if (creature_ptr->ult_res || hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
405         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
406     }
407
408     result |= check_equipment_flags(creature_ptr, TR_SH_COLD);
409     return result;
410 }
411
412 BIT_FLAGS has_easy_spell(player_type *creature_ptr)
413 {
414     BIT_FLAGS result = 0L;
415     result |= check_equipment_flags(creature_ptr, TR_EASY_SPELL);
416     return result;
417 }
418
419 BIT_FLAGS has_heavy_spell(player_type *creature_ptr)
420 {
421     BIT_FLAGS result = 0L;
422     result |= check_equipment_flags(creature_ptr, TR_HEAVY_SPELL);
423     return result;
424 }
425
426 BIT_FLAGS has_hold_exp(player_type *creature_ptr)
427 {
428     BIT_FLAGS result = 0L;
429
430     if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
431         result |= FLAG_CAUSE_PERSONALITY;
432     }
433
434     if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
435         result |= FLAG_CAUSE_RACE;
436     }
437
438     if (is_specific_player_race(creature_ptr, RACE_HOBBIT) || is_specific_player_race(creature_ptr, RACE_SKELETON)
439         || is_specific_player_race(creature_ptr, RACE_ZOMBIE) || is_specific_player_race(creature_ptr, RACE_VAMPIRE)
440         || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_BALROG)
441         || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
442         result |= FLAG_CAUSE_RACE;
443     }
444
445     if (is_specific_player_race(creature_ptr, RACE_GOLEM)) {
446         if (creature_ptr->lev > 34)
447             result |= FLAG_CAUSE_RACE;
448     }
449
450     if (creature_ptr->special_defense & KATA_MUSOU) {
451         result |= FLAG_CAUSE_BATTLE_FORM;
452     }
453
454     if (creature_ptr->ult_res) {
455         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
456     }
457
458     result |= check_equipment_flags(creature_ptr, TR_HOLD_EXP);
459     return result;
460 }
461
462 BIT_FLAGS has_see_inv(player_type *creature_ptr)
463 {
464     BIT_FLAGS result = 0L;
465
466     if (creature_ptr->pclass == CLASS_NINJA || creature_ptr->lev > 29)
467         result |= FLAG_CAUSE_CLASS;
468
469     if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
470         result |= FLAG_CAUSE_RACE;
471     }
472
473     if (!creature_ptr->mimic_form
474         && (creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
475             || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ARCHON)) {
476         result |= FLAG_CAUSE_RACE;
477     }
478
479     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DARK_ELF) {
480         if (creature_ptr->lev > 19)
481             result |= FLAG_CAUSE_RACE;
482     }
483
484     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MIND_FLAYER) {
485         if (creature_ptr->lev > 14)
486             result |= FLAG_CAUSE_RACE;
487     }
488
489     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
490         if (creature_ptr->lev > 9)
491             result |= FLAG_CAUSE_RACE;
492     }
493
494     if (creature_ptr->special_defense & KATA_MUSOU) {
495         result |= FLAG_CAUSE_BATTLE_FORM;
496     }
497
498     if (creature_ptr->ult_res || creature_ptr->tim_invis) {
499         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
500     }
501
502         result |= check_equipment_flags(creature_ptr, TR_SEE_INVIS);
503     return result;
504
505 }
506
507 BIT_FLAGS has_free_act(player_type *creature_ptr)
508 {
509     BIT_FLAGS result = 0L;
510
511     if (creature_ptr->muta3 & MUT3_MOTION)
512         result |= FLAG_CAUSE_MUTATION;
513
514     if (is_specific_player_race(creature_ptr, RACE_GNOME) || is_specific_player_race(creature_ptr, RACE_GOLEM)
515         || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
516         result |= FLAG_CAUSE_RACE;
517     }
518
519     if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
520         && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
521         if (creature_ptr->lev > 24)
522             result |= FLAG_CAUSE_CLASS;
523     }
524
525     if (creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) {
526         if (!(heavy_armor(creature_ptr))) {
527             if (creature_ptr->lev > 24)
528                 result |= FLAG_CAUSE_CLASS;
529         }
530     }
531
532     if (creature_ptr->pclass == CLASS_BERSERKER) {
533         result |= FLAG_CAUSE_CLASS;
534     }
535
536     if (creature_ptr->ult_res || creature_ptr->magicdef) {
537         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
538     }
539
540     if (creature_ptr->special_defense & KATA_MUSOU) {
541         result |= FLAG_CAUSE_BATTLE_FORM;
542     }
543
544     result |= check_equipment_flags(creature_ptr, TR_FREE_ACT);
545     return result;
546 }
547
548 BIT_FLAGS has_sustain_str(player_type *creature_ptr)
549 {
550     BIT_FLAGS result = 0L;
551
552     if (creature_ptr->pclass == CLASS_BERSERKER) {
553         result |= FLAG_CAUSE_CLASS;
554     }
555     if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) || is_specific_player_race(creature_ptr, RACE_HALF_OGRE)
556         || is_specific_player_race(creature_ptr, RACE_HALF_GIANT)) {
557         result |= FLAG_CAUSE_RACE;
558     }
559
560     if (creature_ptr->ult_res) {
561         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
562     }
563
564     if (creature_ptr->special_defense & KATA_MUSOU) {
565         result |= FLAG_CAUSE_BATTLE_FORM;
566     }
567
568     result |= check_equipment_flags(creature_ptr, TR_SUST_STR);
569     return result;
570 }
571
572 BIT_FLAGS has_sustain_int(player_type *creature_ptr)
573 {
574     BIT_FLAGS result = 0L;
575
576     if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER)) {
577         result |= FLAG_CAUSE_RACE;
578     }
579
580     if (creature_ptr->ult_res) {
581         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
582     }
583
584     if (creature_ptr->special_defense & KATA_MUSOU) {
585         result |= FLAG_CAUSE_BATTLE_FORM;
586     }
587
588     result |= check_equipment_flags(creature_ptr, TR_SUST_INT);
589     return result;
590 }
591
592 BIT_FLAGS has_sustain_wis(player_type *creature_ptr)
593 {
594     BIT_FLAGS result = 0L;
595
596     result = FALSE;
597     if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 19)
598         result |= FLAG_CAUSE_CLASS;
599
600     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
601         result |= FLAG_CAUSE_RACE;
602     }
603
604     if (creature_ptr->ult_res) {
605         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
606     }
607
608     if (creature_ptr->special_defense & KATA_MUSOU) {
609         result |= FLAG_CAUSE_BATTLE_FORM;
610     }
611
612     result |= check_equipment_flags(creature_ptr, TR_SUST_WIS);
613     return result;
614 }
615
616 BIT_FLAGS has_sustain_dex(player_type *creature_ptr)
617 {
618     BIT_FLAGS result = 0L;
619     if (creature_ptr->pclass == CLASS_BERSERKER) {
620         result |= FLAG_CAUSE_CLASS;
621     }
622
623     if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 24)
624         result |= FLAG_CAUSE_CLASS;
625
626     if (creature_ptr->ult_res) {
627         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
628     }
629
630     if (creature_ptr->special_defense & KATA_MUSOU) {
631         result |= FLAG_CAUSE_BATTLE_FORM;
632     }
633
634     result |= check_equipment_flags(creature_ptr, TR_SUST_DEX);
635     return result;
636 }
637
638 BIT_FLAGS has_sustain_con(player_type *creature_ptr)
639 {
640     BIT_FLAGS result = 0L;
641     if (creature_ptr->pclass == CLASS_BERSERKER) {
642         result |= FLAG_CAUSE_CLASS;
643     }
644
645     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
646         result |= FLAG_CAUSE_RACE;
647     }
648
649     if (creature_ptr->ult_res) {
650         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
651     }
652
653     if (creature_ptr->special_defense & KATA_MUSOU) {
654         result |= FLAG_CAUSE_BATTLE_FORM;
655     }
656
657     result |= check_equipment_flags(creature_ptr, TR_SUST_CON);
658     return result;
659 }
660
661 BIT_FLAGS has_sustain_chr(player_type *creature_ptr)
662 {
663     BIT_FLAGS result = 0L;
664
665     if (creature_ptr->ult_res) {
666         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
667     }
668
669     if (creature_ptr->special_defense & KATA_MUSOU) {
670         result |= FLAG_CAUSE_BATTLE_FORM;
671     }
672
673     result |= check_equipment_flags(creature_ptr, TR_SUST_CHR);
674     return result;
675 }
676
677 BIT_FLAGS has_levitation(player_type *creature_ptr)
678 {
679     BIT_FLAGS result = 0L;
680
681     if (creature_ptr->muta3 & MUT3_WINGS)
682         result = FLAG_CAUSE_MUTATION;
683
684     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
685         result = FLAG_CAUSE_RACE;
686     }
687
688     if (is_specific_player_race(creature_ptr, RACE_DRACONIAN) || is_specific_player_race(creature_ptr, RACE_SPECTRE)
689         || is_specific_player_race(creature_ptr, RACE_SPRITE) || is_specific_player_race(creature_ptr, RACE_ARCHON)
690         || is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
691         result = FLAG_CAUSE_RACE;
692     }
693
694     if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KAMAE_SUZAKU || (creature_ptr->special_defense & KATA_MUSOU)) {
695         result = FLAG_CAUSE_BATTLE_FORM;
696     }
697
698     if (creature_ptr->ult_res) {
699         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
700     }
701
702     if (creature_ptr->riding) {
703         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
704         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
705         result = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? result : 0;
706     }
707
708     if (creature_ptr->tim_levitation) {
709         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
710     }
711
712     result |= check_equipment_flags(creature_ptr, TR_LEVITATION);
713     return result;
714 }
715
716 void has_can_swim(player_type *creature_ptr)
717 {
718     creature_ptr->can_swim = FALSE;
719     if (creature_ptr->riding) {
720         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
721         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
722         if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC))
723             creature_ptr->can_swim = TRUE;
724     }
725 }
726
727 void has_slow_digest(player_type *creature_ptr)
728 {
729     object_type *o_ptr;
730     BIT_FLAGS flgs[TR_FLAG_SIZE];
731     creature_ptr->slow_digest = FALSE;
732
733     if (creature_ptr->pclass == CLASS_NINJA) {
734         creature_ptr->slow_digest = TRUE;
735     }
736
737     if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
738         if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) {
739             creature_ptr->slow_digest = TRUE;
740             /* Let's not make Regeneration
741              * a disadvantage for the poor warriors who can
742              * never learn a spell that satisfies hunger (actually
743              * neither can rogues, but half-trolls are not
744              * supposed to play rogues) */
745         }
746     }
747
748     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
749         creature_ptr->slow_digest = TRUE;
750     }
751
752     if (!creature_ptr->mimic_form
753         && (creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE
754             || creature_ptr->prace == RACE_ANDROID)) {
755         creature_ptr->slow_digest = TRUE;
756     }
757
758     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
759         o_ptr = &creature_ptr->inventory_list[i];
760         if (!o_ptr->k_idx)
761             continue;
762         object_flags(creature_ptr, o_ptr, flgs);
763         if (has_flag(flgs, TR_SLOW_DIGEST))
764             creature_ptr->slow_digest = TRUE;
765     }
766 }
767
768 BIT_FLAGS has_regenerate(player_type *creature_ptr)
769 {
770     BIT_FLAGS result = 0L;
771
772     if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) && creature_ptr->lev > 14) {
773         result |= FLAG_CAUSE_RACE;
774     }
775
776     if (is_specific_player_race(creature_ptr, RACE_AMBERITE)) {
777         result |= FLAG_CAUSE_RACE;
778     }
779
780     if (creature_ptr->pclass == CLASS_WARRIOR && creature_ptr->lev > 44) {
781         result |= FLAG_CAUSE_RACE;    
782         }
783
784         if (creature_ptr->pclass == CLASS_BERSERKER) {
785         result |= FLAG_CAUSE_RACE;
786     }
787
788     if (creature_ptr->muta3 & MUT3_REGEN)
789         result |= FLAG_CAUSE_MUTATION;
790
791     if (creature_ptr->special_defense & KATA_MUSOU) {
792         result |= FLAG_CAUSE_MUTATION;
793     }
794
795     if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_regen) {
796         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
797     }
798
799     result |= check_equipment_flags(creature_ptr, TR_REGEN);
800
801     if (creature_ptr->muta3 & MUT3_FLESH_ROT)
802         result = 0L;
803
804     return result;
805 }
806
807 void has_curses(player_type *creature_ptr)
808 {
809     object_type *o_ptr;
810     BIT_FLAGS flgs[TR_FLAG_SIZE];
811     creature_ptr->cursed = 0L;
812
813     if (creature_ptr->pseikaku == PERSONALITY_SEXY)
814         creature_ptr->cursed |= (TRC_AGGRAVATE);
815
816     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
817         o_ptr = &creature_ptr->inventory_list[i];
818         if (!o_ptr->k_idx)
819             continue;
820         object_flags(creature_ptr, o_ptr, flgs);
821         if (has_flag(flgs, TR_AGGRAVATE))
822             creature_ptr->cursed |= TRC_AGGRAVATE;
823         if (has_flag(flgs, TR_DRAIN_EXP))
824             creature_ptr->cursed |= TRC_DRAIN_EXP;
825         if (has_flag(flgs, TR_TY_CURSE))
826             creature_ptr->cursed |= TRC_TY_CURSE;
827         if (has_flag(flgs, TR_ADD_L_CURSE))
828             creature_ptr->cursed |= TRC_ADD_L_CURSE;
829         if (has_flag(flgs, TR_ADD_H_CURSE))
830             creature_ptr->cursed |= TRC_ADD_H_CURSE;
831         if (has_flag(flgs, TR_DRAIN_HP))
832             creature_ptr->cursed |= TRC_DRAIN_HP;
833         if (has_flag(flgs, TR_DRAIN_MANA))
834             creature_ptr->cursed |= TRC_DRAIN_MANA;
835         if (has_flag(flgs, TR_CALL_ANIMAL))
836             creature_ptr->cursed |= TRC_CALL_ANIMAL;
837         if (has_flag(flgs, TR_CALL_DEMON))
838             creature_ptr->cursed |= TRC_CALL_DEMON;
839         if (has_flag(flgs, TR_CALL_DRAGON))
840             creature_ptr->cursed |= TRC_CALL_DRAGON;
841         if (has_flag(flgs, TR_CALL_UNDEAD))
842             creature_ptr->cursed |= TRC_CALL_UNDEAD;
843         if (has_flag(flgs, TR_COWARDICE))
844             creature_ptr->cursed |= TRC_COWARDICE;
845         if (has_flag(flgs, TR_LOW_MELEE))
846             creature_ptr->cursed |= TRC_LOW_MELEE;
847         if (has_flag(flgs, TR_LOW_AC))
848             creature_ptr->cursed |= TRC_LOW_AC;
849         if (has_flag(flgs, TR_LOW_MAGIC))
850             creature_ptr->cursed |= TRC_LOW_MAGIC;
851         if (has_flag(flgs, TR_FAST_DIGEST))
852             creature_ptr->cursed |= TRC_FAST_DIGEST;
853         if (has_flag(flgs, TR_SLOW_REGEN))
854             creature_ptr->cursed |= TRC_SLOW_REGEN;
855
856         creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
857         if (o_ptr->name1 == ART_CHAINSWORD)
858             creature_ptr->cursed |= TRC_CHAINSWORD;
859
860         if (has_flag(flgs, TR_TELEPORT)) {
861             if (object_is_cursed(o_ptr))
862                 creature_ptr->cursed |= TRC_TELEPORT;
863             else {
864                 concptr insc = quark_str(o_ptr->inscription);
865
866                 /* {.} will stop random teleportation. */
867                 if (o_ptr->inscription && angband_strchr(insc, '.')) {
868                 } else {
869                     creature_ptr->cursed |= TRC_TELEPORT_SELF;
870                 }
871             }
872         }
873     }
874
875     if (creature_ptr->cursed & TRC_TELEPORT)
876         creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
877
878     if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
879         creature_ptr->cursed &= ~(TRC_AGGRAVATE);
880     }
881 }
882
883 BIT_FLAGS has_impact(player_type *creature_ptr)
884 {
885     BIT_FLAGS result = 0L;
886     result |= check_equipment_flags(creature_ptr, TR_IMPACT);
887     return result;
888 }
889
890 void has_extra_blow(player_type *creature_ptr)
891 {
892     object_type *o_ptr;
893     BIT_FLAGS flgs[TR_FLAG_SIZE];
894     creature_ptr->extra_blows[0] = creature_ptr->extra_blows[1] = 0;
895
896     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
897         o_ptr = &creature_ptr->inventory_list[i];
898         if (!o_ptr->k_idx)
899             continue;
900
901         object_flags(creature_ptr, o_ptr, flgs);
902
903         if (has_flag(flgs, TR_INFRA))
904             creature_ptr->see_infra += o_ptr->pval;
905         if (has_flag(flgs, TR_BLOWS)) {
906             if ((i == INVEN_RARM || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr))
907                 creature_ptr->extra_blows[0] += o_ptr->pval;
908             else if ((i == INVEN_LARM || i == INVEN_LEFT) && !has_two_handed_weapons(creature_ptr))
909                 creature_ptr->extra_blows[1] += o_ptr->pval;
910             else {
911                 creature_ptr->extra_blows[0] += o_ptr->pval;
912                 creature_ptr->extra_blows[1] += o_ptr->pval;
913             }
914         }
915     }
916 }
917
918 void has_resist_acid(player_type *creature_ptr)
919 {
920     object_type *o_ptr;
921     BIT_FLAGS flgs[TR_FLAG_SIZE];
922     creature_ptr->resist_acid = FALSE;
923
924     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
925         creature_ptr->resist_acid = TRUE;
926     }
927
928     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_YEEK || creature_ptr->prace == RACE_KLACKON)) {
929         creature_ptr->resist_acid = TRUE;
930     }
931
932     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
933         creature_ptr->resist_acid = TRUE;
934     }
935
936     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
937         creature_ptr->resist_acid = TRUE;
938     }
939
940     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
941         creature_ptr->resist_acid = TRUE;
942     }
943
944     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
945         o_ptr = &creature_ptr->inventory_list[i];
946         if (!o_ptr->k_idx)
947             continue;
948
949         object_flags(creature_ptr, o_ptr, flgs);
950         if (has_flag(flgs, TR_RES_ACID))
951             creature_ptr->resist_acid = TRUE;
952     }
953
954     if (creature_ptr->immune_acid)
955         creature_ptr->resist_acid = TRUE;
956 }
957
958 void has_resist_elec(player_type *creature_ptr)
959 {
960     object_type *o_ptr;
961     BIT_FLAGS flgs[TR_FLAG_SIZE];
962     creature_ptr->resist_elec = FALSE;
963
964     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
965         creature_ptr->resist_elec = TRUE;
966     }
967
968     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 19) {
969         creature_ptr->resist_elec = TRUE;
970     }
971
972     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
973         creature_ptr->resist_elec = TRUE;
974     }
975
976     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
977         creature_ptr->resist_elec = TRUE;
978     }
979
980     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
981         o_ptr = &creature_ptr->inventory_list[i];
982         if (!o_ptr->k_idx)
983             continue;
984
985         object_flags(creature_ptr, o_ptr, flgs);
986         if (has_flag(flgs, TR_RES_ELEC))
987             creature_ptr->resist_elec = TRUE;
988     }
989
990     if (creature_ptr->immune_elec)
991         creature_ptr->resist_elec = TRUE;
992 }
993
994 void has_resist_fire(player_type *creature_ptr)
995 {
996     object_type *o_ptr;
997     BIT_FLAGS flgs[TR_FLAG_SIZE];
998     creature_ptr->resist_fire = FALSE;
999
1000     if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1001         creature_ptr->resist_fire = TRUE;
1002     }
1003
1004     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 4) {
1005         creature_ptr->resist_fire = TRUE;
1006     }
1007
1008     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
1009         creature_ptr->resist_fire = TRUE;
1010     }
1011
1012     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1013         creature_ptr->resist_fire = TRUE;
1014     }
1015
1016     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1017         creature_ptr->resist_fire = TRUE;
1018     }
1019
1020     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1021         o_ptr = &creature_ptr->inventory_list[i];
1022         if (!o_ptr->k_idx)
1023             continue;
1024
1025         object_flags(creature_ptr, o_ptr, flgs);
1026
1027         if (has_flag(flgs, TR_RES_FIRE))
1028             creature_ptr->resist_fire = TRUE;
1029     }
1030
1031     if (creature_ptr->immune_fire)
1032         creature_ptr->resist_fire = TRUE;
1033 }
1034
1035 void has_resist_cold(player_type *creature_ptr)
1036 {
1037     object_type *o_ptr;
1038     BIT_FLAGS flgs[TR_FLAG_SIZE];
1039     creature_ptr->resist_cold = FALSE;
1040
1041     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1042         creature_ptr->resist_cold = TRUE;
1043     }
1044
1045     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ZOMBIE) && creature_ptr->lev > 4) {
1046         creature_ptr->resist_cold = TRUE;
1047     }
1048
1049     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SKELETON) && creature_ptr->lev > 9) {
1050         creature_ptr->resist_cold = TRUE;
1051     }
1052
1053     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
1054         creature_ptr->resist_fire = TRUE;
1055     }
1056
1057     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1058         creature_ptr->resist_cold = TRUE;
1059     }
1060
1061     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1062         creature_ptr->resist_cold = TRUE;
1063     }
1064
1065     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1066         o_ptr = &creature_ptr->inventory_list[i];
1067         if (!o_ptr->k_idx)
1068             continue;
1069
1070         object_flags(creature_ptr, o_ptr, flgs);
1071
1072         if (has_flag(flgs, TR_RES_COLD))
1073             creature_ptr->resist_cold = TRUE;
1074     }
1075
1076     if (creature_ptr->immune_cold)
1077         creature_ptr->resist_cold = TRUE;
1078 }
1079
1080 void has_resist_pois(player_type *creature_ptr)
1081 {
1082     object_type *o_ptr;
1083     BIT_FLAGS flgs[TR_FLAG_SIZE];
1084     creature_ptr->resist_pois = FALSE;
1085
1086     if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 19)
1087         creature_ptr->resist_pois = TRUE;
1088
1089     if (creature_ptr->mimic_form == MIMIC_VAMPIRE || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1090         creature_ptr->resist_pois = TRUE;
1091     }
1092
1093     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 34) {
1094         creature_ptr->resist_pois = TRUE;
1095     }
1096
1097     if (!creature_ptr->mimic_form
1098         && (creature_ptr->prace == RACE_KOBOLD || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
1099             || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ANDROID)) {
1100         creature_ptr->resist_pois = TRUE;
1101     }
1102
1103     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1104         creature_ptr->resist_pois = TRUE;
1105     }
1106
1107     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1108         creature_ptr->resist_pois = TRUE;
1109     }
1110
1111     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1112         o_ptr = &creature_ptr->inventory_list[i];
1113         if (!o_ptr->k_idx)
1114             continue;
1115
1116         object_flags(creature_ptr, o_ptr, flgs);
1117
1118         if (has_flag(flgs, TR_RES_POIS))
1119             creature_ptr->resist_pois = TRUE;
1120     }
1121 }
1122
1123 void has_resist_conf(player_type *creature_ptr)
1124 {
1125     object_type *o_ptr;
1126     BIT_FLAGS flgs[TR_FLAG_SIZE];
1127     creature_ptr->resist_conf = FALSE;
1128
1129     if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 29)
1130         creature_ptr->resist_conf = TRUE;
1131
1132     if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN || creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1133         creature_ptr->resist_conf = TRUE;
1134     }
1135
1136     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_KLACKON || creature_ptr->prace == RACE_BEASTMAN || creature_ptr->prace == RACE_KUTAR)) {
1137         creature_ptr->resist_conf = TRUE;
1138     }
1139
1140     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1141         creature_ptr->resist_conf = TRUE;
1142     }
1143
1144     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1145         creature_ptr->resist_conf = TRUE;
1146     }
1147
1148     if (creature_ptr->magicdef) {
1149         creature_ptr->resist_conf = TRUE;
1150     }
1151
1152     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1153         o_ptr = &creature_ptr->inventory_list[i];
1154         if (!o_ptr->k_idx)
1155             continue;
1156
1157         object_flags(creature_ptr, o_ptr, flgs);
1158
1159         if (has_flag(flgs, TR_RES_CONF))
1160             creature_ptr->resist_conf = TRUE;
1161     }
1162 }
1163
1164 void has_resist_sound(player_type *creature_ptr)
1165 {
1166     object_type *o_ptr;
1167     BIT_FLAGS flgs[TR_FLAG_SIZE];
1168     creature_ptr->resist_sound = FALSE;
1169
1170     if (creature_ptr->pclass == CLASS_BARD) {
1171         creature_ptr->resist_sound = TRUE;
1172     }
1173
1174     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_CYCLOPS || creature_ptr->prace == RACE_BEASTMAN)) {
1175         creature_ptr->resist_sound = TRUE;
1176     }
1177
1178     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1179         creature_ptr->resist_sound = TRUE;
1180     }
1181
1182     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1183         o_ptr = &creature_ptr->inventory_list[i];
1184         if (!o_ptr->k_idx)
1185             continue;
1186
1187         object_flags(creature_ptr, o_ptr, flgs);
1188
1189         if (has_flag(flgs, TR_RES_SOUND))
1190             creature_ptr->resist_sound = TRUE;
1191     }
1192 }
1193
1194 void has_resist_lite(player_type *creature_ptr)
1195 {
1196     object_type *o_ptr;
1197     BIT_FLAGS flgs[TR_FLAG_SIZE];
1198     creature_ptr->resist_lite = FALSE;
1199
1200     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ELF || creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_SPRITE)) {
1201         creature_ptr->resist_lite = TRUE;
1202     }
1203
1204     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1205         creature_ptr->resist_lite = TRUE;
1206     }
1207
1208     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1209         o_ptr = &creature_ptr->inventory_list[i];
1210         if (!o_ptr->k_idx)
1211             continue;
1212
1213         object_flags(creature_ptr, o_ptr, flgs);
1214
1215         if (has_flag(flgs, TR_RES_LITE))
1216             creature_ptr->resist_lite = TRUE;
1217     }
1218 }
1219
1220 void has_resist_dark(player_type *creature_ptr)
1221 {
1222     object_type *o_ptr;
1223     BIT_FLAGS flgs[TR_FLAG_SIZE];
1224     creature_ptr->resist_dark = FALSE;
1225
1226     if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1227         creature_ptr->resist_dark = TRUE;
1228     }
1229
1230     if (!creature_ptr->mimic_form
1231         && (creature_ptr->prace == RACE_HALF_ORC || creature_ptr->prace == RACE_HALF_OGRE || creature_ptr->prace == RACE_NIBELUNG
1232             || creature_ptr->prace == RACE_DARK_ELF || creature_ptr->prace == RACE_VAMPIRE)) {
1233         creature_ptr->resist_lite = TRUE;
1234     }
1235
1236     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1237         creature_ptr->resist_dark = TRUE;
1238     }
1239
1240     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1241         o_ptr = &creature_ptr->inventory_list[i];
1242         if (!o_ptr->k_idx)
1243             continue;
1244
1245         object_flags(creature_ptr, o_ptr, flgs);
1246
1247         if (has_flag(flgs, TR_RES_DARK))
1248             creature_ptr->resist_dark = TRUE;
1249     }
1250 }
1251
1252 void has_resist_chaos(player_type *creature_ptr)
1253 {
1254     object_type *o_ptr;
1255     BIT_FLAGS flgs[TR_FLAG_SIZE];
1256     creature_ptr->resist_chaos = FALSE;
1257
1258     if (creature_ptr->pclass == CLASS_CHAOS_WARRIOR && creature_ptr->lev > 29)
1259         creature_ptr->resist_chaos = TRUE;
1260
1261     if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1262         creature_ptr->resist_chaos = TRUE;
1263     }
1264
1265     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TITAN)
1266         creature_ptr->resist_chaos = TRUE;
1267
1268     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1269         creature_ptr->resist_chaos = TRUE;
1270     }
1271
1272     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1273         o_ptr = &creature_ptr->inventory_list[i];
1274         if (!o_ptr->k_idx)
1275             continue;
1276
1277         object_flags(creature_ptr, o_ptr, flgs);
1278
1279         if (has_flag(flgs, TR_RES_CHAOS))
1280             creature_ptr->resist_chaos = TRUE;
1281     }
1282 }
1283
1284 void has_resist_disen(player_type *creature_ptr)
1285 {
1286     object_type *o_ptr;
1287     BIT_FLAGS flgs[TR_FLAG_SIZE];
1288     creature_ptr->resist_disen = FALSE;
1289
1290     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1291         creature_ptr->resist_disen = TRUE;
1292     }
1293
1294     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_NIBELUNG)
1295         creature_ptr->resist_disen = TRUE;
1296
1297     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1298         creature_ptr->resist_disen = TRUE;
1299     }
1300
1301     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1302         o_ptr = &creature_ptr->inventory_list[i];
1303         if (!o_ptr->k_idx)
1304             continue;
1305
1306         object_flags(creature_ptr, o_ptr, flgs);
1307
1308         if (has_flag(flgs, TR_RES_DISEN))
1309             creature_ptr->resist_disen = TRUE;
1310     }
1311 }
1312
1313 void has_resist_shard(player_type *creature_ptr)
1314 {
1315     object_type *o_ptr;
1316     BIT_FLAGS flgs[TR_FLAG_SIZE];
1317     creature_ptr->resist_shard = FALSE;
1318
1319     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_HALF_TITAN || creature_ptr->prace == RACE_SKELETON))
1320         creature_ptr->resist_shard = TRUE;
1321
1322     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1323         creature_ptr->resist_shard = TRUE;
1324     }
1325
1326     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1327         o_ptr = &creature_ptr->inventory_list[i];
1328         if (!o_ptr->k_idx)
1329             continue;
1330
1331         object_flags(creature_ptr, o_ptr, flgs);
1332
1333         if (has_flag(flgs, TR_RES_DISEN))
1334             creature_ptr->resist_shard = TRUE;
1335     }
1336 }
1337
1338 void has_resist_nexus(player_type *creature_ptr)
1339 {
1340     object_type *o_ptr;
1341     BIT_FLAGS flgs[TR_FLAG_SIZE];
1342     creature_ptr->resist_nexus = FALSE;
1343
1344     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1345         creature_ptr->resist_nexus = TRUE;
1346     }
1347
1348     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1349         creature_ptr->resist_nexus = TRUE;
1350     }
1351
1352     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1353         o_ptr = &creature_ptr->inventory_list[i];
1354         if (!o_ptr->k_idx)
1355             continue;
1356
1357         object_flags(creature_ptr, o_ptr, flgs);
1358
1359         if (has_flag(flgs, TR_RES_NEXUS))
1360             creature_ptr->resist_nexus = TRUE;
1361     }
1362 }
1363
1364 void has_resist_blind(player_type *creature_ptr)
1365 {
1366     object_type *o_ptr;
1367     BIT_FLAGS flgs[TR_FLAG_SIZE];
1368     creature_ptr->resist_blind = FALSE;
1369
1370     if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1371         creature_ptr->resist_blind = TRUE;
1372     }
1373
1374     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DWARF)
1375         creature_ptr->resist_blind = TRUE;
1376
1377     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1378         creature_ptr->resist_blind = TRUE;
1379     }
1380
1381     if (creature_ptr->magicdef) {
1382         creature_ptr->resist_blind = TRUE;
1383     }
1384
1385     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1386         o_ptr = &creature_ptr->inventory_list[i];
1387         if (!o_ptr->k_idx)
1388             continue;
1389
1390         object_flags(creature_ptr, o_ptr, flgs);
1391
1392         if (has_flag(flgs, TR_RES_BLIND))
1393             creature_ptr->resist_blind = TRUE;
1394     }
1395 }
1396
1397 void has_resist_neth(player_type *creature_ptr)
1398 {
1399     object_type *o_ptr;
1400     BIT_FLAGS flgs[TR_FLAG_SIZE];
1401
1402     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1403         creature_ptr->resist_neth = TRUE;
1404     }
1405
1406     if (!creature_ptr->mimic_form
1407         && (creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE
1408             || creature_ptr->prace == RACE_BALROG))
1409         creature_ptr->resist_neth = TRUE;
1410
1411     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1412         creature_ptr->resist_neth = TRUE;
1413     }
1414
1415     if (creature_ptr->tim_res_nether) {
1416         creature_ptr->resist_neth = TRUE;
1417     }
1418
1419     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1420         o_ptr = &creature_ptr->inventory_list[i];
1421         if (!o_ptr->k_idx)
1422             continue;
1423
1424         object_flags(creature_ptr, o_ptr, flgs);
1425
1426         if (has_flag(flgs, TR_RES_NETHER))
1427             creature_ptr->resist_neth = TRUE;
1428     }
1429 }
1430
1431 void has_resist_time(player_type *creature_ptr)
1432 {
1433     object_type *o_ptr;
1434     BIT_FLAGS flgs[TR_FLAG_SIZE];
1435     creature_ptr->resist_time = FALSE;
1436
1437     if (creature_ptr->tim_res_time) {
1438         creature_ptr->resist_time = TRUE;
1439     }
1440
1441     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1442         o_ptr = &creature_ptr->inventory_list[i];
1443         if (!o_ptr->k_idx)
1444             continue;
1445
1446         object_flags(creature_ptr, o_ptr, flgs);
1447         if (o_ptr->name2 == EGO_RING_RES_TIME)
1448             creature_ptr->resist_time = TRUE;
1449     }
1450 }
1451
1452 void has_resist_water(player_type *creature_ptr)
1453 {
1454     creature_ptr->resist_water = FALSE;
1455
1456     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MERFOLK)
1457         creature_ptr->resist_water = TRUE;
1458 }
1459
1460 void has_resist_fear(player_type *creature_ptr)
1461 {
1462     object_type *o_ptr;
1463     BIT_FLAGS flgs[TR_FLAG_SIZE];
1464     creature_ptr->resist_fear = FALSE;
1465
1466     if (creature_ptr->muta3 & MUT3_FEARLESS)
1467         creature_ptr->resist_fear = TRUE;
1468
1469     switch (creature_ptr->pclass) {
1470     case CLASS_WARRIOR:
1471         if (creature_ptr->lev > 29)
1472             creature_ptr->resist_fear = TRUE;
1473         break;
1474     case CLASS_PALADIN:
1475         if (creature_ptr->lev > 39)
1476             creature_ptr->resist_fear = TRUE;
1477         break;
1478     case CLASS_CHAOS_WARRIOR:
1479         if (creature_ptr->lev > 39)
1480             creature_ptr->resist_fear = TRUE;
1481         break;
1482     case CLASS_MINDCRAFTER:
1483         if (creature_ptr->lev > 9)
1484             creature_ptr->resist_fear = TRUE;
1485         break;
1486     case CLASS_SAMURAI:
1487         if (creature_ptr->lev > 29)
1488             creature_ptr->resist_fear = TRUE;
1489         break;
1490     case CLASS_NINJA:
1491         creature_ptr->resist_fear = TRUE;
1492         break;
1493     }
1494
1495     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1496         creature_ptr->resist_fear = TRUE;
1497     }
1498
1499     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_BARBARIAN)
1500         creature_ptr->resist_fear = TRUE;
1501
1502     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1503         creature_ptr->resist_fear = TRUE;
1504     }
1505
1506     if (is_hero(creature_ptr) || creature_ptr->shero) {
1507         creature_ptr->resist_fear = TRUE;
1508     }
1509
1510     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1511         o_ptr = &creature_ptr->inventory_list[i];
1512         if (!o_ptr->k_idx)
1513             continue;
1514
1515         object_flags(creature_ptr, o_ptr, flgs);
1516         if (has_flag(flgs, TR_RES_FEAR))
1517             creature_ptr->resist_fear = TRUE;
1518     }
1519 }
1520
1521 BIT_FLAGS has_immune_acid(player_type *creature_ptr)
1522 {
1523     BIT_FLAGS result = 0L;
1524     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_YEEK && creature_ptr->lev > 19)
1525         result |= FLAG_CAUSE_RACE;
1526
1527     if (creature_ptr->ele_immune) {
1528         if (creature_ptr->special_defense & DEFENSE_ACID)
1529             result = FLAG_CAUSE_MAGIC_TIME_EFFECT;
1530     }
1531
1532     result |= check_equipment_flags(creature_ptr, TR_IM_ACID);
1533     return result;
1534 }
1535
1536 void has_immune_elec(player_type *creature_ptr)
1537 {
1538     object_type *o_ptr;
1539     BIT_FLAGS flgs[TR_FLAG_SIZE];
1540     creature_ptr->immune_elec = FALSE;
1541     if (creature_ptr->ele_immune) {
1542         if (creature_ptr->special_defense & DEFENSE_ELEC)
1543             creature_ptr->immune_elec = TRUE;
1544     }
1545
1546     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1547         o_ptr = &creature_ptr->inventory_list[i];
1548         if (!o_ptr->k_idx)
1549             continue;
1550
1551         object_flags(creature_ptr, o_ptr, flgs);
1552         if (has_flag(flgs, TR_IM_ELEC))
1553             creature_ptr->immune_elec = TRUE;
1554     }
1555 }
1556
1557 void has_immune_fire(player_type *creature_ptr)
1558 {
1559     object_type *o_ptr;
1560     BIT_FLAGS flgs[TR_FLAG_SIZE];
1561     creature_ptr->immune_fire = FALSE;
1562     if (creature_ptr->ele_immune) {
1563         if (creature_ptr->special_defense & DEFENSE_FIRE)
1564             creature_ptr->immune_fire = TRUE;
1565     }
1566
1567     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1568         o_ptr = &creature_ptr->inventory_list[i];
1569         if (!o_ptr->k_idx)
1570             continue;
1571
1572         object_flags(creature_ptr, o_ptr, flgs);
1573         if (has_flag(flgs, TR_IM_FIRE))
1574             creature_ptr->immune_fire = TRUE;
1575     }
1576 }
1577
1578 void has_immune_cold(player_type *creature_ptr)
1579 {
1580     object_type *o_ptr;
1581     BIT_FLAGS flgs[TR_FLAG_SIZE];
1582     creature_ptr->immune_cold = FALSE;
1583     if (creature_ptr->ele_immune) {
1584         if (creature_ptr->special_defense & DEFENSE_COLD)
1585             creature_ptr->immune_cold = TRUE;
1586     }
1587
1588     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1589         o_ptr = &creature_ptr->inventory_list[i];
1590         if (!o_ptr->k_idx)
1591             continue;
1592
1593         object_flags(creature_ptr, o_ptr, flgs);
1594         if (has_flag(flgs, TR_IM_COLD))
1595             creature_ptr->immune_cold = TRUE;
1596     }
1597 }
1598
1599 bool has_right_hand_weapon(player_type *creature_ptr)
1600 {
1601     if (has_melee_weapon(creature_ptr, INVEN_RARM))
1602         return TRUE;
1603
1604     if (can_two_hands_wielding(creature_ptr)) {
1605         switch (creature_ptr->pclass) {
1606         case CLASS_MONK:
1607         case CLASS_FORCETRAINER:
1608         case CLASS_BERSERKER:
1609             if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
1610                 return TRUE;
1611             }
1612             break;
1613         }
1614     }
1615
1616     return FALSE;
1617 }
1618
1619 bool has_left_hand_weapon(player_type *creature_ptr) { return has_melee_weapon(creature_ptr, INVEN_LARM); }
1620
1621 bool has_two_handed_weapons(player_type *creature_ptr)
1622 {
1623     if (can_two_hands_wielding(creature_ptr)) {
1624         if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
1625             && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
1626             return TRUE;
1627         } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
1628             && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
1629             return TRUE;
1630         }
1631     }
1632     return FALSE;
1633 }
1634
1635 void has_lite(player_type *creature_ptr)
1636 {
1637     creature_ptr->lite = FALSE;
1638     if (creature_ptr->pclass == CLASS_NINJA)
1639         return;
1640
1641     if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1642         creature_ptr->lite = TRUE;
1643     }
1644
1645     if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1646         creature_ptr->lite = TRUE;
1647     }
1648
1649     if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
1650         creature_ptr->lite = TRUE;
1651     }
1652
1653     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_VAMPIRE)
1654         creature_ptr->lite = TRUE;
1655
1656     if (creature_ptr->sh_fire)
1657         creature_ptr->lite = TRUE;
1658
1659     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1660         creature_ptr->lite = TRUE;
1661     }
1662 }
1663
1664 bool is_disable_two_handed_bonus(player_type *creature_ptr, int i)
1665 {
1666     object_type *o_ptr;
1667     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1668     if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
1669         if (calc_weapon_weight_limit(creature_ptr) * 2 >= o_ptr->weight / 10 && has_two_handed_weapons(creature_ptr)
1670             && (calc_weapon_weight_limit(creature_ptr) * 2 < o_ptr->weight / 5))
1671             return TRUE;
1672     }
1673     return FALSE;
1674 }
1675
1676 bool is_icky_wield_weapon(player_type *creature_ptr, int i)
1677 {
1678     object_type *o_ptr;
1679     BIT_FLAGS flgs[TR_FLAG_SIZE];
1680     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1681     object_flags(creature_ptr, o_ptr, flgs);
1682
1683     if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
1684         return TRUE;
1685     } else if (creature_ptr->pclass == CLASS_SORCERER) {
1686         if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
1687             return TRUE;
1688         }
1689     }
1690     if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
1691         return TRUE;
1692     }
1693     return FALSE;
1694 }
1695
1696 bool is_riding_wield_weapon(player_type *creature_ptr, int i)
1697 {
1698     object_type *o_ptr;
1699     BIT_FLAGS flgs[TR_FLAG_SIZE];
1700     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1701     object_flags(creature_ptr, o_ptr, flgs);
1702     if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
1703         && !has_flag(flgs, TR_RIDING)) {
1704         return TRUE;
1705     }
1706     return FALSE;
1707 }
1708
1709 bool is_not_ninja_weapon(player_type *creature_ptr, int i)
1710 {
1711     tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1712     OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1713     return creature_ptr->pclass == CLASS_NINJA
1714         && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD));
1715 }
1716
1717 bool is_not_monk_weapon(player_type *creature_ptr, int i)
1718 {
1719     tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1720     OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1721     return (creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) && (!s_info[creature_ptr->pclass].w_max[tval][sval]);
1722 }
1723
1724 bool has_good_luck(player_type *creature_ptr) { return (creature_ptr->pseikaku == PERSONALITY_LUCKY) || (creature_ptr->muta3 |= MUT3_GOOD_LUCK); };