OSDN Git Service

[Refactor] #40514 has_regenerate() を BIT_FLAGS 返り値持ちに仕様変更. / has_regenerate() 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 void has_hold_exp(player_type *creature_ptr)
427 {
428     object_type *o_ptr;
429     BIT_FLAGS flgs[TR_FLAG_SIZE];
430
431     creature_ptr->hold_exp = FALSE;
432
433     if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
434         creature_ptr->hold_exp = TRUE;
435     }
436
437     if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
438         creature_ptr->hold_exp = TRUE;
439     }
440
441     if (is_specific_player_race(creature_ptr, RACE_HOBBIT) || is_specific_player_race(creature_ptr, RACE_SKELETON)
442         || is_specific_player_race(creature_ptr, RACE_ZOMBIE) || is_specific_player_race(creature_ptr, RACE_VAMPIRE)
443         || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_BALROG)
444         || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
445         creature_ptr->hold_exp = TRUE;
446     }
447
448     if (is_specific_player_race(creature_ptr, RACE_GOLEM)) {
449         if (creature_ptr->lev > 34)
450             creature_ptr->hold_exp = TRUE;
451     }
452
453     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
454         creature_ptr->hold_exp = TRUE;
455     }
456
457     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
458         o_ptr = &creature_ptr->inventory_list[i];
459         if (!o_ptr->k_idx)
460             continue;
461
462         object_flags(creature_ptr, o_ptr, flgs);
463         if (has_flag(flgs, TR_HOLD_EXP))
464             creature_ptr->hold_exp = TRUE;
465     }
466 }
467
468 void has_see_inv(player_type *creature_ptr)
469 {
470     object_type *o_ptr;
471     BIT_FLAGS flgs[TR_FLAG_SIZE];
472     creature_ptr->see_inv = FALSE;
473
474     if (creature_ptr->pclass == CLASS_NINJA || creature_ptr->lev > 29)
475         creature_ptr->see_inv = TRUE;
476
477     if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
478         creature_ptr->see_inv = TRUE;
479     }
480
481     if (!creature_ptr->mimic_form
482         && (creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
483             || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ARCHON)) {
484         creature_ptr->see_inv = TRUE;
485     }
486
487     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DARK_ELF) {
488         if (creature_ptr->lev > 19)
489             creature_ptr->see_inv = TRUE;
490     }
491
492     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MIND_FLAYER) {
493         if (creature_ptr->lev > 14)
494             creature_ptr->see_inv = TRUE;
495     }
496
497     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
498         if (creature_ptr->lev > 9)
499             creature_ptr->see_inv = TRUE;
500     }
501
502     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
503         creature_ptr->see_inv = TRUE;
504     }
505
506     if (creature_ptr->tim_invis) {
507         creature_ptr->see_inv = TRUE;
508     }
509
510     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
511         o_ptr = &creature_ptr->inventory_list[i];
512         if (!o_ptr->k_idx)
513             continue;
514
515         object_flags(creature_ptr, o_ptr, flgs);
516         if (has_flag(flgs, TR_SEE_INVIS))
517             creature_ptr->see_inv = TRUE;
518     }
519 }
520
521 BIT_FLAGS has_free_act(player_type *creature_ptr)
522 {
523     BIT_FLAGS result = 0L;
524
525     if (creature_ptr->muta3 & MUT3_MOTION)
526         result |= FLAG_CAUSE_MUTATION;
527
528     if (is_specific_player_race(creature_ptr, RACE_GNOME) || is_specific_player_race(creature_ptr, RACE_GOLEM)
529         || is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
530         result |= FLAG_CAUSE_RACE;
531     }
532
533     if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
534         && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
535         if (creature_ptr->lev > 24)
536             result |= FLAG_CAUSE_CLASS;
537     }
538
539     if (creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) {
540         if (!(heavy_armor(creature_ptr))) {
541             if (creature_ptr->lev > 24)
542                 result |= FLAG_CAUSE_CLASS;
543         }
544     }
545
546     if (creature_ptr->pclass == CLASS_BERSERKER) {
547         result |= FLAG_CAUSE_CLASS;
548     }
549
550     if (creature_ptr->ult_res || creature_ptr->magicdef) {
551         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
552     }
553
554     if (creature_ptr->special_defense & KATA_MUSOU) {
555         result |= FLAG_CAUSE_BATTLE_FORM;
556     }
557
558     result |= check_equipment_flags(creature_ptr, TR_FREE_ACT);
559     return result;
560 }
561
562 BIT_FLAGS has_sustain_str(player_type *creature_ptr)
563 {
564     BIT_FLAGS result = 0L;
565
566     if (creature_ptr->pclass == CLASS_BERSERKER) {
567         result |= FLAG_CAUSE_CLASS;
568     }
569     if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) || is_specific_player_race(creature_ptr, RACE_HALF_OGRE)
570         || is_specific_player_race(creature_ptr, RACE_HALF_GIANT)) {
571         result |= FLAG_CAUSE_RACE;
572     }
573
574     if (creature_ptr->ult_res) {
575         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
576     }
577
578     if (creature_ptr->special_defense & KATA_MUSOU) {
579         result |= FLAG_CAUSE_BATTLE_FORM;
580     }
581
582     result |= check_equipment_flags(creature_ptr, TR_SUST_STR);
583     return result;
584 }
585
586 BIT_FLAGS has_sustain_int(player_type *creature_ptr)
587 {
588     BIT_FLAGS result = 0L;
589
590     if (is_specific_player_race(creature_ptr, RACE_MIND_FLAYER)) {
591         result |= FLAG_CAUSE_RACE;
592     }
593
594     if (creature_ptr->ult_res) {
595         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
596     }
597
598     if (creature_ptr->special_defense & KATA_MUSOU) {
599         result |= FLAG_CAUSE_BATTLE_FORM;
600     }
601
602     result |= check_equipment_flags(creature_ptr, TR_SUST_INT);
603     return result;
604 }
605
606 BIT_FLAGS has_sustain_wis(player_type *creature_ptr)
607 {
608     BIT_FLAGS result = 0L;
609
610     result = FALSE;
611     if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 19)
612         result |= FLAG_CAUSE_CLASS;
613
614     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
615         result |= FLAG_CAUSE_RACE;
616     }
617
618     if (creature_ptr->ult_res) {
619         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
620     }
621
622     if (creature_ptr->special_defense & KATA_MUSOU) {
623         result |= FLAG_CAUSE_BATTLE_FORM;
624     }
625
626     result |= check_equipment_flags(creature_ptr, TR_SUST_WIS);
627     return result;
628 }
629
630 BIT_FLAGS has_sustain_dex(player_type *creature_ptr)
631 {
632     BIT_FLAGS result = 0L;
633     if (creature_ptr->pclass == CLASS_BERSERKER) {
634         result |= FLAG_CAUSE_CLASS;
635     }
636
637     if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 24)
638         result |= FLAG_CAUSE_CLASS;
639
640     if (creature_ptr->ult_res) {
641         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
642     }
643
644     if (creature_ptr->special_defense & KATA_MUSOU) {
645         result |= FLAG_CAUSE_BATTLE_FORM;
646     }
647
648     result |= check_equipment_flags(creature_ptr, TR_SUST_DEX);
649     return result;
650 }
651
652 BIT_FLAGS has_sustain_con(player_type *creature_ptr)
653 {
654     BIT_FLAGS result = 0L;
655     if (creature_ptr->pclass == CLASS_BERSERKER) {
656         result |= FLAG_CAUSE_CLASS;
657     }
658
659     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
660         result |= FLAG_CAUSE_RACE;
661     }
662
663     if (creature_ptr->ult_res) {
664         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
665     }
666
667     if (creature_ptr->special_defense & KATA_MUSOU) {
668         result |= FLAG_CAUSE_BATTLE_FORM;
669     }
670
671     result |= check_equipment_flags(creature_ptr, TR_SUST_CON);
672     return result;
673 }
674
675 BIT_FLAGS has_sustain_chr(player_type *creature_ptr)
676 {
677     BIT_FLAGS result = 0L;
678
679     if (creature_ptr->ult_res) {
680         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
681     }
682
683     if (creature_ptr->special_defense & KATA_MUSOU) {
684         result |= FLAG_CAUSE_BATTLE_FORM;
685     }
686
687     result |= check_equipment_flags(creature_ptr, TR_SUST_CHR);
688     return result;
689 }
690
691 BIT_FLAGS has_levitation(player_type *creature_ptr)
692 {
693     BIT_FLAGS result = 0L;
694
695     if (creature_ptr->muta3 & MUT3_WINGS)
696         result = FLAG_CAUSE_MUTATION;
697
698     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
699         result = FLAG_CAUSE_RACE;
700     }
701
702     if (is_specific_player_race(creature_ptr, RACE_DRACONIAN) || is_specific_player_race(creature_ptr, RACE_SPECTRE)
703         || is_specific_player_race(creature_ptr, RACE_SPRITE) || is_specific_player_race(creature_ptr, RACE_ARCHON)
704         || is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
705         result = FLAG_CAUSE_RACE;
706     }
707
708     if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KAMAE_SUZAKU || (creature_ptr->special_defense & KATA_MUSOU)) {
709         result = FLAG_CAUSE_BATTLE_FORM;
710     }
711
712     if (creature_ptr->ult_res) {
713         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
714     }
715
716     if (creature_ptr->riding) {
717         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
718         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
719         result = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? result : 0;
720     }
721
722     if (creature_ptr->tim_levitation) {
723         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
724     }
725
726     result |= check_equipment_flags(creature_ptr, TR_LEVITATION);
727     return result;
728 }
729
730 void has_can_swim(player_type *creature_ptr)
731 {
732     creature_ptr->can_swim = FALSE;
733     if (creature_ptr->riding) {
734         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
735         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
736         if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC))
737             creature_ptr->can_swim = TRUE;
738     }
739 }
740
741 void has_slow_digest(player_type *creature_ptr)
742 {
743     object_type *o_ptr;
744     BIT_FLAGS flgs[TR_FLAG_SIZE];
745     creature_ptr->slow_digest = FALSE;
746
747     if (creature_ptr->pclass == CLASS_NINJA) {
748         creature_ptr->slow_digest = TRUE;
749     }
750
751     if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
752         if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) {
753             creature_ptr->slow_digest = TRUE;
754             /* Let's not make Regeneration
755              * a disadvantage for the poor warriors who can
756              * never learn a spell that satisfies hunger (actually
757              * neither can rogues, but half-trolls are not
758              * supposed to play rogues) */
759         }
760     }
761
762     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
763         creature_ptr->slow_digest = TRUE;
764     }
765
766     if (!creature_ptr->mimic_form
767         && (creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_SPECTRE
768             || creature_ptr->prace == RACE_ANDROID)) {
769         creature_ptr->slow_digest = TRUE;
770     }
771
772     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
773         o_ptr = &creature_ptr->inventory_list[i];
774         if (!o_ptr->k_idx)
775             continue;
776         object_flags(creature_ptr, o_ptr, flgs);
777         if (has_flag(flgs, TR_SLOW_DIGEST))
778             creature_ptr->slow_digest = TRUE;
779     }
780 }
781
782 BIT_FLAGS has_regenerate(player_type *creature_ptr)
783 {
784     BIT_FLAGS result = 0L;
785
786     if (is_specific_player_race(creature_ptr, RACE_HALF_TROLL) && creature_ptr->lev > 14) {
787         result |= FLAG_CAUSE_RACE;
788     }
789
790     if (is_specific_player_race(creature_ptr, RACE_AMBERITE)) {
791         result |= FLAG_CAUSE_RACE;
792     }
793
794     if (creature_ptr->pclass == CLASS_WARRIOR && creature_ptr->lev > 44) {
795         result |= FLAG_CAUSE_RACE;    
796         }
797
798         if (creature_ptr->pclass == CLASS_BERSERKER) {
799         result |= FLAG_CAUSE_RACE;
800     }
801
802     if (creature_ptr->muta3 & MUT3_REGEN)
803         result |= FLAG_CAUSE_MUTATION;
804
805     if (creature_ptr->special_defense & KATA_MUSOU) {
806         result |= FLAG_CAUSE_MUTATION;
807     }
808
809     if (hex_spelling(creature_ptr, HEX_DEMON_AURA) || creature_ptr->ult_res || creature_ptr->tim_regen) {
810         result |= FLAG_CAUSE_MAGIC_TIME_EFFECT;
811     }
812
813     result |= check_equipment_flags(creature_ptr, TR_REGEN);
814
815     if (creature_ptr->muta3 & MUT3_FLESH_ROT)
816         result = 0L;
817
818     return result;
819 }
820
821 void has_curses(player_type *creature_ptr)
822 {
823     object_type *o_ptr;
824     BIT_FLAGS flgs[TR_FLAG_SIZE];
825     creature_ptr->cursed = 0L;
826
827     if (creature_ptr->pseikaku == PERSONALITY_SEXY)
828         creature_ptr->cursed |= (TRC_AGGRAVATE);
829
830     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
831         o_ptr = &creature_ptr->inventory_list[i];
832         if (!o_ptr->k_idx)
833             continue;
834         object_flags(creature_ptr, o_ptr, flgs);
835         if (has_flag(flgs, TR_AGGRAVATE))
836             creature_ptr->cursed |= TRC_AGGRAVATE;
837         if (has_flag(flgs, TR_DRAIN_EXP))
838             creature_ptr->cursed |= TRC_DRAIN_EXP;
839         if (has_flag(flgs, TR_TY_CURSE))
840             creature_ptr->cursed |= TRC_TY_CURSE;
841         if (has_flag(flgs, TR_ADD_L_CURSE))
842             creature_ptr->cursed |= TRC_ADD_L_CURSE;
843         if (has_flag(flgs, TR_ADD_H_CURSE))
844             creature_ptr->cursed |= TRC_ADD_H_CURSE;
845         if (has_flag(flgs, TR_DRAIN_HP))
846             creature_ptr->cursed |= TRC_DRAIN_HP;
847         if (has_flag(flgs, TR_DRAIN_MANA))
848             creature_ptr->cursed |= TRC_DRAIN_MANA;
849         if (has_flag(flgs, TR_CALL_ANIMAL))
850             creature_ptr->cursed |= TRC_CALL_ANIMAL;
851         if (has_flag(flgs, TR_CALL_DEMON))
852             creature_ptr->cursed |= TRC_CALL_DEMON;
853         if (has_flag(flgs, TR_CALL_DRAGON))
854             creature_ptr->cursed |= TRC_CALL_DRAGON;
855         if (has_flag(flgs, TR_CALL_UNDEAD))
856             creature_ptr->cursed |= TRC_CALL_UNDEAD;
857         if (has_flag(flgs, TR_COWARDICE))
858             creature_ptr->cursed |= TRC_COWARDICE;
859         if (has_flag(flgs, TR_LOW_MELEE))
860             creature_ptr->cursed |= TRC_LOW_MELEE;
861         if (has_flag(flgs, TR_LOW_AC))
862             creature_ptr->cursed |= TRC_LOW_AC;
863         if (has_flag(flgs, TR_LOW_MAGIC))
864             creature_ptr->cursed |= TRC_LOW_MAGIC;
865         if (has_flag(flgs, TR_FAST_DIGEST))
866             creature_ptr->cursed |= TRC_FAST_DIGEST;
867         if (has_flag(flgs, TR_SLOW_REGEN))
868             creature_ptr->cursed |= TRC_SLOW_REGEN;
869
870         creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
871         if (o_ptr->name1 == ART_CHAINSWORD)
872             creature_ptr->cursed |= TRC_CHAINSWORD;
873
874         if (has_flag(flgs, TR_TELEPORT)) {
875             if (object_is_cursed(o_ptr))
876                 creature_ptr->cursed |= TRC_TELEPORT;
877             else {
878                 concptr insc = quark_str(o_ptr->inscription);
879
880                 /* {.} will stop random teleportation. */
881                 if (o_ptr->inscription && angband_strchr(insc, '.')) {
882                 } else {
883                     creature_ptr->cursed |= TRC_TELEPORT_SELF;
884                 }
885             }
886         }
887     }
888
889     if (creature_ptr->cursed & TRC_TELEPORT)
890         creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
891
892     if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
893         creature_ptr->cursed &= ~(TRC_AGGRAVATE);
894     }
895 }
896
897 BIT_FLAGS has_impact(player_type *creature_ptr)
898 {
899     BIT_FLAGS result = 0L;
900     result |= check_equipment_flags(creature_ptr, TR_IMPACT);
901     return result;
902 }
903
904 void has_extra_blow(player_type *creature_ptr)
905 {
906     object_type *o_ptr;
907     BIT_FLAGS flgs[TR_FLAG_SIZE];
908     creature_ptr->extra_blows[0] = creature_ptr->extra_blows[1] = 0;
909
910     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
911         o_ptr = &creature_ptr->inventory_list[i];
912         if (!o_ptr->k_idx)
913             continue;
914
915         object_flags(creature_ptr, o_ptr, flgs);
916
917         if (has_flag(flgs, TR_INFRA))
918             creature_ptr->see_infra += o_ptr->pval;
919         if (has_flag(flgs, TR_BLOWS)) {
920             if ((i == INVEN_RARM || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr))
921                 creature_ptr->extra_blows[0] += o_ptr->pval;
922             else if ((i == INVEN_LARM || i == INVEN_LEFT) && !has_two_handed_weapons(creature_ptr))
923                 creature_ptr->extra_blows[1] += o_ptr->pval;
924             else {
925                 creature_ptr->extra_blows[0] += o_ptr->pval;
926                 creature_ptr->extra_blows[1] += o_ptr->pval;
927             }
928         }
929     }
930 }
931
932 void has_resist_acid(player_type *creature_ptr)
933 {
934     object_type *o_ptr;
935     BIT_FLAGS flgs[TR_FLAG_SIZE];
936     creature_ptr->resist_acid = FALSE;
937
938     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
939         creature_ptr->resist_acid = TRUE;
940     }
941
942     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_YEEK || creature_ptr->prace == RACE_KLACKON)) {
943         creature_ptr->resist_acid = TRUE;
944     }
945
946     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
947         creature_ptr->resist_acid = TRUE;
948     }
949
950     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
951         creature_ptr->resist_acid = TRUE;
952     }
953
954     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
955         creature_ptr->resist_acid = TRUE;
956     }
957
958     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
959         o_ptr = &creature_ptr->inventory_list[i];
960         if (!o_ptr->k_idx)
961             continue;
962
963         object_flags(creature_ptr, o_ptr, flgs);
964         if (has_flag(flgs, TR_RES_ACID))
965             creature_ptr->resist_acid = TRUE;
966     }
967
968     if (creature_ptr->immune_acid)
969         creature_ptr->resist_acid = TRUE;
970 }
971
972 void has_resist_elec(player_type *creature_ptr)
973 {
974     object_type *o_ptr;
975     BIT_FLAGS flgs[TR_FLAG_SIZE];
976     creature_ptr->resist_elec = FALSE;
977
978     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
979         creature_ptr->resist_elec = TRUE;
980     }
981
982     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 19) {
983         creature_ptr->resist_elec = TRUE;
984     }
985
986     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
987         creature_ptr->resist_elec = TRUE;
988     }
989
990     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
991         creature_ptr->resist_elec = TRUE;
992     }
993
994     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
995         o_ptr = &creature_ptr->inventory_list[i];
996         if (!o_ptr->k_idx)
997             continue;
998
999         object_flags(creature_ptr, o_ptr, flgs);
1000         if (has_flag(flgs, TR_RES_ELEC))
1001             creature_ptr->resist_elec = TRUE;
1002     }
1003
1004     if (creature_ptr->immune_elec)
1005         creature_ptr->resist_elec = TRUE;
1006 }
1007
1008 void has_resist_fire(player_type *creature_ptr)
1009 {
1010     object_type *o_ptr;
1011     BIT_FLAGS flgs[TR_FLAG_SIZE];
1012     creature_ptr->resist_fire = FALSE;
1013
1014     if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1015         creature_ptr->resist_fire = TRUE;
1016     }
1017
1018     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 4) {
1019         creature_ptr->resist_fire = TRUE;
1020     }
1021
1022     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
1023         creature_ptr->resist_fire = TRUE;
1024     }
1025
1026     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1027         creature_ptr->resist_fire = TRUE;
1028     }
1029
1030     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1031         creature_ptr->resist_fire = TRUE;
1032     }
1033
1034     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1035         o_ptr = &creature_ptr->inventory_list[i];
1036         if (!o_ptr->k_idx)
1037             continue;
1038
1039         object_flags(creature_ptr, o_ptr, flgs);
1040
1041         if (has_flag(flgs, TR_RES_FIRE))
1042             creature_ptr->resist_fire = TRUE;
1043     }
1044
1045     if (creature_ptr->immune_fire)
1046         creature_ptr->resist_fire = TRUE;
1047 }
1048
1049 void has_resist_cold(player_type *creature_ptr)
1050 {
1051     object_type *o_ptr;
1052     BIT_FLAGS flgs[TR_FLAG_SIZE];
1053     creature_ptr->resist_cold = FALSE;
1054
1055     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1056         creature_ptr->resist_cold = TRUE;
1057     }
1058
1059     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ZOMBIE) && creature_ptr->lev > 4) {
1060         creature_ptr->resist_cold = TRUE;
1061     }
1062
1063     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SKELETON) && creature_ptr->lev > 9) {
1064         creature_ptr->resist_cold = TRUE;
1065     }
1066
1067     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
1068         creature_ptr->resist_fire = TRUE;
1069     }
1070
1071     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1072         creature_ptr->resist_cold = TRUE;
1073     }
1074
1075     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1076         creature_ptr->resist_cold = TRUE;
1077     }
1078
1079     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1080         o_ptr = &creature_ptr->inventory_list[i];
1081         if (!o_ptr->k_idx)
1082             continue;
1083
1084         object_flags(creature_ptr, o_ptr, flgs);
1085
1086         if (has_flag(flgs, TR_RES_COLD))
1087             creature_ptr->resist_cold = TRUE;
1088     }
1089
1090     if (creature_ptr->immune_cold)
1091         creature_ptr->resist_cold = TRUE;
1092 }
1093
1094 void has_resist_pois(player_type *creature_ptr)
1095 {
1096     object_type *o_ptr;
1097     BIT_FLAGS flgs[TR_FLAG_SIZE];
1098     creature_ptr->resist_pois = FALSE;
1099
1100     if (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 19)
1101         creature_ptr->resist_pois = TRUE;
1102
1103     if (creature_ptr->mimic_form == MIMIC_VAMPIRE || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1104         creature_ptr->resist_pois = TRUE;
1105     }
1106
1107     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 34) {
1108         creature_ptr->resist_pois = TRUE;
1109     }
1110
1111     if (!creature_ptr->mimic_form
1112         && (creature_ptr->prace == RACE_KOBOLD || creature_ptr->prace == RACE_GOLEM || creature_ptr->prace == RACE_SKELETON
1113             || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_ANDROID)) {
1114         creature_ptr->resist_pois = TRUE;
1115     }
1116
1117     if (creature_ptr->special_defense & KAMAE_SEIRYU) {
1118         creature_ptr->resist_pois = TRUE;
1119     }
1120
1121     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1122         creature_ptr->resist_pois = TRUE;
1123     }
1124
1125     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1126         o_ptr = &creature_ptr->inventory_list[i];
1127         if (!o_ptr->k_idx)
1128             continue;
1129
1130         object_flags(creature_ptr, o_ptr, flgs);
1131
1132         if (has_flag(flgs, TR_RES_POIS))
1133             creature_ptr->resist_pois = TRUE;
1134     }
1135 }
1136
1137 void has_resist_conf(player_type *creature_ptr)
1138 {
1139     object_type *o_ptr;
1140     BIT_FLAGS flgs[TR_FLAG_SIZE];
1141     creature_ptr->resist_conf = FALSE;
1142
1143     if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 29)
1144         creature_ptr->resist_conf = TRUE;
1145
1146     if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN || creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1147         creature_ptr->resist_conf = TRUE;
1148     }
1149
1150     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_KLACKON || creature_ptr->prace == RACE_BEASTMAN || creature_ptr->prace == RACE_KUTAR)) {
1151         creature_ptr->resist_conf = TRUE;
1152     }
1153
1154     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1155         creature_ptr->resist_conf = TRUE;
1156     }
1157
1158     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1159         creature_ptr->resist_conf = TRUE;
1160     }
1161
1162     if (creature_ptr->magicdef) {
1163         creature_ptr->resist_conf = TRUE;
1164     }
1165
1166     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1167         o_ptr = &creature_ptr->inventory_list[i];
1168         if (!o_ptr->k_idx)
1169             continue;
1170
1171         object_flags(creature_ptr, o_ptr, flgs);
1172
1173         if (has_flag(flgs, TR_RES_CONF))
1174             creature_ptr->resist_conf = TRUE;
1175     }
1176 }
1177
1178 void has_resist_sound(player_type *creature_ptr)
1179 {
1180     object_type *o_ptr;
1181     BIT_FLAGS flgs[TR_FLAG_SIZE];
1182     creature_ptr->resist_sound = FALSE;
1183
1184     if (creature_ptr->pclass == CLASS_BARD) {
1185         creature_ptr->resist_sound = TRUE;
1186     }
1187
1188     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_CYCLOPS || creature_ptr->prace == RACE_BEASTMAN)) {
1189         creature_ptr->resist_sound = TRUE;
1190     }
1191
1192     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1193         creature_ptr->resist_sound = TRUE;
1194     }
1195
1196     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1197         o_ptr = &creature_ptr->inventory_list[i];
1198         if (!o_ptr->k_idx)
1199             continue;
1200
1201         object_flags(creature_ptr, o_ptr, flgs);
1202
1203         if (has_flag(flgs, TR_RES_SOUND))
1204             creature_ptr->resist_sound = TRUE;
1205     }
1206 }
1207
1208 void has_resist_lite(player_type *creature_ptr)
1209 {
1210     object_type *o_ptr;
1211     BIT_FLAGS flgs[TR_FLAG_SIZE];
1212     creature_ptr->resist_lite = FALSE;
1213
1214     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_ELF || creature_ptr->prace == RACE_HIGH_ELF || creature_ptr->prace == RACE_SPRITE)) {
1215         creature_ptr->resist_lite = TRUE;
1216     }
1217
1218     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1219         creature_ptr->resist_lite = TRUE;
1220     }
1221
1222     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1223         o_ptr = &creature_ptr->inventory_list[i];
1224         if (!o_ptr->k_idx)
1225             continue;
1226
1227         object_flags(creature_ptr, o_ptr, flgs);
1228
1229         if (has_flag(flgs, TR_RES_LITE))
1230             creature_ptr->resist_lite = TRUE;
1231     }
1232 }
1233
1234 void has_resist_dark(player_type *creature_ptr)
1235 {
1236     object_type *o_ptr;
1237     BIT_FLAGS flgs[TR_FLAG_SIZE];
1238     creature_ptr->resist_dark = FALSE;
1239
1240     if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1241         creature_ptr->resist_dark = TRUE;
1242     }
1243
1244     if (!creature_ptr->mimic_form
1245         && (creature_ptr->prace == RACE_HALF_ORC || creature_ptr->prace == RACE_HALF_OGRE || creature_ptr->prace == RACE_NIBELUNG
1246             || creature_ptr->prace == RACE_DARK_ELF || creature_ptr->prace == RACE_VAMPIRE)) {
1247         creature_ptr->resist_lite = TRUE;
1248     }
1249
1250     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1251         creature_ptr->resist_dark = TRUE;
1252     }
1253
1254     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1255         o_ptr = &creature_ptr->inventory_list[i];
1256         if (!o_ptr->k_idx)
1257             continue;
1258
1259         object_flags(creature_ptr, o_ptr, flgs);
1260
1261         if (has_flag(flgs, TR_RES_DARK))
1262             creature_ptr->resist_dark = TRUE;
1263     }
1264 }
1265
1266 void has_resist_chaos(player_type *creature_ptr)
1267 {
1268     object_type *o_ptr;
1269     BIT_FLAGS flgs[TR_FLAG_SIZE];
1270     creature_ptr->resist_chaos = FALSE;
1271
1272     if (creature_ptr->pclass == CLASS_CHAOS_WARRIOR && creature_ptr->lev > 29)
1273         creature_ptr->resist_chaos = TRUE;
1274
1275     if (creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1276         creature_ptr->resist_chaos = TRUE;
1277     }
1278
1279     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TITAN)
1280         creature_ptr->resist_chaos = TRUE;
1281
1282     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1283         creature_ptr->resist_chaos = TRUE;
1284     }
1285
1286     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1287         o_ptr = &creature_ptr->inventory_list[i];
1288         if (!o_ptr->k_idx)
1289             continue;
1290
1291         object_flags(creature_ptr, o_ptr, flgs);
1292
1293         if (has_flag(flgs, TR_RES_CHAOS))
1294             creature_ptr->resist_chaos = TRUE;
1295     }
1296 }
1297
1298 void has_resist_disen(player_type *creature_ptr)
1299 {
1300     object_type *o_ptr;
1301     BIT_FLAGS flgs[TR_FLAG_SIZE];
1302     creature_ptr->resist_disen = FALSE;
1303
1304     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1305         creature_ptr->resist_disen = TRUE;
1306     }
1307
1308     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_NIBELUNG)
1309         creature_ptr->resist_disen = TRUE;
1310
1311     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1312         creature_ptr->resist_disen = TRUE;
1313     }
1314
1315     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1316         o_ptr = &creature_ptr->inventory_list[i];
1317         if (!o_ptr->k_idx)
1318             continue;
1319
1320         object_flags(creature_ptr, o_ptr, flgs);
1321
1322         if (has_flag(flgs, TR_RES_DISEN))
1323             creature_ptr->resist_disen = TRUE;
1324     }
1325 }
1326
1327 void has_resist_shard(player_type *creature_ptr)
1328 {
1329     object_type *o_ptr;
1330     BIT_FLAGS flgs[TR_FLAG_SIZE];
1331     creature_ptr->resist_shard = FALSE;
1332
1333     if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_HALF_TITAN || creature_ptr->prace == RACE_SKELETON))
1334         creature_ptr->resist_shard = TRUE;
1335
1336     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1337         creature_ptr->resist_shard = TRUE;
1338     }
1339
1340     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1341         o_ptr = &creature_ptr->inventory_list[i];
1342         if (!o_ptr->k_idx)
1343             continue;
1344
1345         object_flags(creature_ptr, o_ptr, flgs);
1346
1347         if (has_flag(flgs, TR_RES_DISEN))
1348             creature_ptr->resist_shard = TRUE;
1349     }
1350 }
1351
1352 void has_resist_nexus(player_type *creature_ptr)
1353 {
1354     object_type *o_ptr;
1355     BIT_FLAGS flgs[TR_FLAG_SIZE];
1356     creature_ptr->resist_nexus = FALSE;
1357
1358     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1359         creature_ptr->resist_nexus = TRUE;
1360     }
1361
1362     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1363         creature_ptr->resist_nexus = TRUE;
1364     }
1365
1366     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1367         o_ptr = &creature_ptr->inventory_list[i];
1368         if (!o_ptr->k_idx)
1369             continue;
1370
1371         object_flags(creature_ptr, o_ptr, flgs);
1372
1373         if (has_flag(flgs, TR_RES_NEXUS))
1374             creature_ptr->resist_nexus = TRUE;
1375     }
1376 }
1377
1378 void has_resist_blind(player_type *creature_ptr)
1379 {
1380     object_type *o_ptr;
1381     BIT_FLAGS flgs[TR_FLAG_SIZE];
1382     creature_ptr->resist_blind = FALSE;
1383
1384     if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1385         creature_ptr->resist_blind = TRUE;
1386     }
1387
1388     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DWARF)
1389         creature_ptr->resist_blind = TRUE;
1390
1391     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1392         creature_ptr->resist_blind = TRUE;
1393     }
1394
1395     if (creature_ptr->magicdef) {
1396         creature_ptr->resist_blind = TRUE;
1397     }
1398
1399     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1400         o_ptr = &creature_ptr->inventory_list[i];
1401         if (!o_ptr->k_idx)
1402             continue;
1403
1404         object_flags(creature_ptr, o_ptr, flgs);
1405
1406         if (has_flag(flgs, TR_RES_BLIND))
1407             creature_ptr->resist_blind = TRUE;
1408     }
1409 }
1410
1411 void has_resist_neth(player_type *creature_ptr)
1412 {
1413     object_type *o_ptr;
1414     BIT_FLAGS flgs[TR_FLAG_SIZE];
1415
1416     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_DEMON || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1417         creature_ptr->resist_neth = TRUE;
1418     }
1419
1420     if (!creature_ptr->mimic_form
1421         && (creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE
1422             || creature_ptr->prace == RACE_BALROG))
1423         creature_ptr->resist_neth = TRUE;
1424
1425     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1426         creature_ptr->resist_neth = TRUE;
1427     }
1428
1429     if (creature_ptr->tim_res_nether) {
1430         creature_ptr->resist_neth = TRUE;
1431     }
1432
1433     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1434         o_ptr = &creature_ptr->inventory_list[i];
1435         if (!o_ptr->k_idx)
1436             continue;
1437
1438         object_flags(creature_ptr, o_ptr, flgs);
1439
1440         if (has_flag(flgs, TR_RES_NETHER))
1441             creature_ptr->resist_neth = TRUE;
1442     }
1443 }
1444
1445 void has_resist_time(player_type *creature_ptr)
1446 {
1447     object_type *o_ptr;
1448     BIT_FLAGS flgs[TR_FLAG_SIZE];
1449     creature_ptr->resist_time = FALSE;
1450
1451     if (creature_ptr->tim_res_time) {
1452         creature_ptr->resist_time = TRUE;
1453     }
1454
1455     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1456         o_ptr = &creature_ptr->inventory_list[i];
1457         if (!o_ptr->k_idx)
1458             continue;
1459
1460         object_flags(creature_ptr, o_ptr, flgs);
1461         if (o_ptr->name2 == EGO_RING_RES_TIME)
1462             creature_ptr->resist_time = TRUE;
1463     }
1464 }
1465
1466 void has_resist_water(player_type *creature_ptr)
1467 {
1468     creature_ptr->resist_water = FALSE;
1469
1470     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MERFOLK)
1471         creature_ptr->resist_water = TRUE;
1472 }
1473
1474 void has_resist_fear(player_type *creature_ptr)
1475 {
1476     object_type *o_ptr;
1477     BIT_FLAGS flgs[TR_FLAG_SIZE];
1478     creature_ptr->resist_fear = FALSE;
1479
1480     if (creature_ptr->muta3 & MUT3_FEARLESS)
1481         creature_ptr->resist_fear = TRUE;
1482
1483     switch (creature_ptr->pclass) {
1484     case CLASS_WARRIOR:
1485         if (creature_ptr->lev > 29)
1486             creature_ptr->resist_fear = TRUE;
1487         break;
1488     case CLASS_PALADIN:
1489         if (creature_ptr->lev > 39)
1490             creature_ptr->resist_fear = TRUE;
1491         break;
1492     case CLASS_CHAOS_WARRIOR:
1493         if (creature_ptr->lev > 39)
1494             creature_ptr->resist_fear = TRUE;
1495         break;
1496     case CLASS_MINDCRAFTER:
1497         if (creature_ptr->lev > 9)
1498             creature_ptr->resist_fear = TRUE;
1499         break;
1500     case CLASS_SAMURAI:
1501         if (creature_ptr->lev > 29)
1502             creature_ptr->resist_fear = TRUE;
1503         break;
1504     case CLASS_NINJA:
1505         creature_ptr->resist_fear = TRUE;
1506         break;
1507     }
1508
1509     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
1510         creature_ptr->resist_fear = TRUE;
1511     }
1512
1513     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_BARBARIAN)
1514         creature_ptr->resist_fear = TRUE;
1515
1516     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1517         creature_ptr->resist_fear = TRUE;
1518     }
1519
1520     if (is_hero(creature_ptr) || creature_ptr->shero) {
1521         creature_ptr->resist_fear = TRUE;
1522     }
1523
1524     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1525         o_ptr = &creature_ptr->inventory_list[i];
1526         if (!o_ptr->k_idx)
1527             continue;
1528
1529         object_flags(creature_ptr, o_ptr, flgs);
1530         if (has_flag(flgs, TR_RES_FEAR))
1531             creature_ptr->resist_fear = TRUE;
1532     }
1533 }
1534
1535 void has_immune_acid(player_type *creature_ptr)
1536 {
1537     object_type *o_ptr;
1538     BIT_FLAGS flgs[TR_FLAG_SIZE];
1539     creature_ptr->immune_acid = FALSE;
1540
1541     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_YEEK && creature_ptr->lev > 19)
1542         creature_ptr->immune_acid = TRUE;
1543
1544     if (creature_ptr->ele_immune) {
1545         if (creature_ptr->special_defense & DEFENSE_ACID)
1546             creature_ptr->immune_acid = TRUE;
1547     }
1548
1549     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1550         o_ptr = &creature_ptr->inventory_list[i];
1551         if (!o_ptr->k_idx)
1552             continue;
1553
1554         object_flags(creature_ptr, o_ptr, flgs);
1555         if (has_flag(flgs, TR_IM_ACID))
1556             creature_ptr->immune_acid = TRUE;
1557     }
1558 }
1559
1560 void has_immune_elec(player_type *creature_ptr)
1561 {
1562     object_type *o_ptr;
1563     BIT_FLAGS flgs[TR_FLAG_SIZE];
1564     creature_ptr->immune_elec = FALSE;
1565     if (creature_ptr->ele_immune) {
1566         if (creature_ptr->special_defense & DEFENSE_ELEC)
1567             creature_ptr->immune_elec = TRUE;
1568     }
1569
1570     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1571         o_ptr = &creature_ptr->inventory_list[i];
1572         if (!o_ptr->k_idx)
1573             continue;
1574
1575         object_flags(creature_ptr, o_ptr, flgs);
1576         if (has_flag(flgs, TR_IM_ELEC))
1577             creature_ptr->immune_elec = TRUE;
1578     }
1579 }
1580
1581 void has_immune_fire(player_type *creature_ptr)
1582 {
1583     object_type *o_ptr;
1584     BIT_FLAGS flgs[TR_FLAG_SIZE];
1585     creature_ptr->immune_fire = FALSE;
1586     if (creature_ptr->ele_immune) {
1587         if (creature_ptr->special_defense & DEFENSE_FIRE)
1588             creature_ptr->immune_fire = TRUE;
1589     }
1590
1591     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1592         o_ptr = &creature_ptr->inventory_list[i];
1593         if (!o_ptr->k_idx)
1594             continue;
1595
1596         object_flags(creature_ptr, o_ptr, flgs);
1597         if (has_flag(flgs, TR_IM_FIRE))
1598             creature_ptr->immune_fire = TRUE;
1599     }
1600 }
1601
1602 void has_immune_cold(player_type *creature_ptr)
1603 {
1604     object_type *o_ptr;
1605     BIT_FLAGS flgs[TR_FLAG_SIZE];
1606     creature_ptr->immune_cold = FALSE;
1607     if (creature_ptr->ele_immune) {
1608         if (creature_ptr->special_defense & DEFENSE_COLD)
1609             creature_ptr->immune_cold = TRUE;
1610     }
1611
1612     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
1613         o_ptr = &creature_ptr->inventory_list[i];
1614         if (!o_ptr->k_idx)
1615             continue;
1616
1617         object_flags(creature_ptr, o_ptr, flgs);
1618         if (has_flag(flgs, TR_IM_COLD))
1619             creature_ptr->immune_cold = TRUE;
1620     }
1621 }
1622
1623 bool has_right_hand_weapon(player_type *creature_ptr)
1624 {
1625     if (has_melee_weapon(creature_ptr, INVEN_RARM))
1626         return TRUE;
1627
1628     if (can_two_hands_wielding(creature_ptr)) {
1629         switch (creature_ptr->pclass) {
1630         case CLASS_MONK:
1631         case CLASS_FORCETRAINER:
1632         case CLASS_BERSERKER:
1633             if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
1634                 return TRUE;
1635             }
1636             break;
1637         }
1638     }
1639
1640     return FALSE;
1641 }
1642
1643 bool has_left_hand_weapon(player_type *creature_ptr) { return has_melee_weapon(creature_ptr, INVEN_LARM); }
1644
1645 bool has_two_handed_weapons(player_type *creature_ptr)
1646 {
1647     if (can_two_hands_wielding(creature_ptr)) {
1648         if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
1649             && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
1650             return TRUE;
1651         } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
1652             && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
1653             return TRUE;
1654         }
1655     }
1656     return FALSE;
1657 }
1658
1659 void has_lite(player_type *creature_ptr)
1660 {
1661     creature_ptr->lite = FALSE;
1662     if (creature_ptr->pclass == CLASS_NINJA)
1663         return;
1664
1665     if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
1666         creature_ptr->lite = TRUE;
1667     }
1668
1669     if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
1670         creature_ptr->lite = TRUE;
1671     }
1672
1673     if (creature_ptr->muta3 & MUT3_FIRE_BODY) {
1674         creature_ptr->lite = TRUE;
1675     }
1676
1677     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_VAMPIRE)
1678         creature_ptr->lite = TRUE;
1679
1680     if (creature_ptr->sh_fire)
1681         creature_ptr->lite = TRUE;
1682
1683     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
1684         creature_ptr->lite = TRUE;
1685     }
1686 }
1687
1688 bool is_disable_two_handed_bonus(player_type *creature_ptr, int i)
1689 {
1690     object_type *o_ptr;
1691     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1692     if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
1693         if (calc_weapon_weight_limit(creature_ptr) * 2 >= o_ptr->weight / 10 && has_two_handed_weapons(creature_ptr)
1694             && (calc_weapon_weight_limit(creature_ptr) * 2 < o_ptr->weight / 5))
1695             return TRUE;
1696     }
1697     return FALSE;
1698 }
1699
1700 bool is_icky_wield_weapon(player_type *creature_ptr, int i)
1701 {
1702     object_type *o_ptr;
1703     BIT_FLAGS flgs[TR_FLAG_SIZE];
1704     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1705     object_flags(creature_ptr, o_ptr, flgs);
1706
1707     if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
1708         return TRUE;
1709     } else if (creature_ptr->pclass == CLASS_SORCERER) {
1710         if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
1711             return TRUE;
1712         }
1713     }
1714     if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
1715         return TRUE;
1716     }
1717     return FALSE;
1718 }
1719
1720 bool is_riding_wield_weapon(player_type *creature_ptr, int i)
1721 {
1722     object_type *o_ptr;
1723     BIT_FLAGS flgs[TR_FLAG_SIZE];
1724     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
1725     object_flags(creature_ptr, o_ptr, flgs);
1726     if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
1727         && !has_flag(flgs, TR_RIDING)) {
1728         return TRUE;
1729     }
1730     return FALSE;
1731 }
1732
1733 bool is_not_ninja_weapon(player_type *creature_ptr, int i)
1734 {
1735     tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1736     OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1737     return creature_ptr->pclass == CLASS_NINJA
1738         && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD));
1739 }
1740
1741 bool is_not_monk_weapon(player_type *creature_ptr, int i)
1742 {
1743     tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
1744     OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
1745     return (creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) && (!s_info[creature_ptr->pclass].w_max[tval][sval]);
1746 }
1747
1748 bool has_good_luck(player_type *creature_ptr) { return (creature_ptr->pseikaku == PERSONALITY_LUCKY) || (creature_ptr->muta3 |= MUT3_GOOD_LUCK); };