OSDN Git Service

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