X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fartifact.c;h=94c675bce13269da5b4f2e8d8178e754b9e4d1a8;hb=83ddbd710a776ef17838a4233e998017a2cc5076;hp=75b4ff9658c4b6e032953a5618da7d54560bbb59;hpb=937427f71135d6ddb019ff9fffdcc87584cf4c46;p=hengband%2Fhengband.git diff --git a/src/artifact.c b/src/artifact.c index 75b4ff965..94c675bce 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -12,6 +12,7 @@ /* Chance of using syllables to form the name instead of the "template" files */ +#define SINDARIN_NAME 10 #define TABLE_NAME 20 #define A_CURSED 13 #define WEIRD_LUCK 12 @@ -26,18 +27,24 @@ /* + * Use for biased artifact creation + */ +static int artifact_bias; + + +/* * Choose one random sustain */ void one_sustain(object_type *o_ptr) { switch (randint0(6)) { - case 0: o_ptr->art_flags2 |= (TR2_SUST_STR); break; - case 1: o_ptr->art_flags2 |= (TR2_SUST_INT); break; - case 2: o_ptr->art_flags2 |= (TR2_SUST_WIS); break; - case 3: o_ptr->art_flags2 |= (TR2_SUST_DEX); break; - case 4: o_ptr->art_flags2 |= (TR2_SUST_CON); break; - case 5: o_ptr->art_flags2 |= (TR2_SUST_CHR); break; + case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break; + case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break; + case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break; + case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break; + case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break; + case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break; } } @@ -49,18 +56,18 @@ void one_high_resistance(object_type *o_ptr) { switch (randint0(12)) { - case 0: o_ptr->art_flags2 |= (TR2_RES_POIS); break; - case 1: o_ptr->art_flags2 |= (TR2_RES_LITE); break; - case 2: o_ptr->art_flags2 |= (TR2_RES_DARK); break; - case 3: o_ptr->art_flags2 |= (TR2_RES_SHARDS); break; - case 4: o_ptr->art_flags2 |= (TR2_RES_BLIND); break; - case 5: o_ptr->art_flags2 |= (TR2_RES_CONF); break; - case 6: o_ptr->art_flags2 |= (TR2_RES_SOUND); break; - case 7: o_ptr->art_flags2 |= (TR2_RES_NETHER); break; - case 8: o_ptr->art_flags2 |= (TR2_RES_NEXUS); break; - case 9: o_ptr->art_flags2 |= (TR2_RES_CHAOS); break; - case 10: o_ptr->art_flags2 |= (TR2_RES_DISEN); break; - case 11: o_ptr->art_flags2 |= (TR2_RES_FEAR); break; + case 0: add_flag(o_ptr->art_flags, TR_RES_POIS); break; + case 1: add_flag(o_ptr->art_flags, TR_RES_LITE); break; + case 2: add_flag(o_ptr->art_flags, TR_RES_DARK); break; + case 3: add_flag(o_ptr->art_flags, TR_RES_SHARDS); break; + case 4: add_flag(o_ptr->art_flags, TR_RES_BLIND); break; + case 5: add_flag(o_ptr->art_flags, TR_RES_CONF); break; + case 6: add_flag(o_ptr->art_flags, TR_RES_SOUND); break; + case 7: add_flag(o_ptr->art_flags, TR_RES_NETHER); break; + case 8: add_flag(o_ptr->art_flags, TR_RES_NEXUS); break; + case 9: add_flag(o_ptr->art_flags, TR_RES_CHAOS); break; + case 10: add_flag(o_ptr->art_flags, TR_RES_DISEN); break; + case 11: add_flag(o_ptr->art_flags, TR_RES_FEAR); break; } } @@ -68,20 +75,20 @@ void one_high_resistance(object_type *o_ptr) /* * Choose one random high resistance ( except poison and disenchantment ) */ -void one_loadly_high_resistance(object_type *o_ptr) +void one_lordly_high_resistance(object_type *o_ptr) { switch (randint0(10)) { - case 0: o_ptr->art_flags2 |= (TR2_RES_LITE); break; - case 1: o_ptr->art_flags2 |= (TR2_RES_DARK); break; - case 2: o_ptr->art_flags2 |= (TR2_RES_SHARDS); break; - case 3: o_ptr->art_flags2 |= (TR2_RES_BLIND); break; - case 4: o_ptr->art_flags2 |= (TR2_RES_CONF); break; - case 5: o_ptr->art_flags2 |= (TR2_RES_SOUND); break; - case 6: o_ptr->art_flags2 |= (TR2_RES_NETHER); break; - case 7: o_ptr->art_flags2 |= (TR2_RES_NEXUS); break; - case 8: o_ptr->art_flags2 |= (TR2_RES_CHAOS); break; - case 9: o_ptr->art_flags2 |= (TR2_RES_FEAR); break; + case 0: add_flag(o_ptr->art_flags, TR_RES_LITE); break; + case 1: add_flag(o_ptr->art_flags, TR_RES_DARK); break; + case 2: add_flag(o_ptr->art_flags, TR_RES_SHARDS); break; + case 3: add_flag(o_ptr->art_flags, TR_RES_BLIND); break; + case 4: add_flag(o_ptr->art_flags, TR_RES_CONF); break; + case 5: add_flag(o_ptr->art_flags, TR_RES_SOUND); break; + case 6: add_flag(o_ptr->art_flags, TR_RES_NETHER); break; + case 7: add_flag(o_ptr->art_flags, TR_RES_NEXUS); break; + case 8: add_flag(o_ptr->art_flags, TR_RES_CHAOS); break; + case 9: add_flag(o_ptr->art_flags, TR_RES_FEAR); break; } } @@ -93,10 +100,10 @@ void one_ele_resistance(object_type *o_ptr) { switch (randint0(4)) { - case 0: o_ptr->art_flags2 |= (TR2_RES_ACID); break; - case 1: o_ptr->art_flags2 |= (TR2_RES_ELEC); break; - case 2: o_ptr->art_flags2 |= (TR2_RES_COLD); break; - case 3: o_ptr->art_flags2 |= (TR2_RES_FIRE); break; + case 0: add_flag(o_ptr->art_flags, TR_RES_ACID); break; + case 1: add_flag(o_ptr->art_flags, TR_RES_ELEC); break; + case 2: add_flag(o_ptr->art_flags, TR_RES_COLD); break; + case 3: add_flag(o_ptr->art_flags, TR_RES_FIRE); break; } } @@ -108,7 +115,7 @@ void one_dragon_ele_resistance(object_type *o_ptr) { if (one_in_(7)) { - o_ptr->art_flags2 |= (TR2_RES_POIS); + add_flag(o_ptr->art_flags, TR_RES_POIS); } else { @@ -118,6 +125,28 @@ void one_dragon_ele_resistance(object_type *o_ptr) /* + * Choose one lower rank esp + */ +void one_low_esp(object_type *o_ptr) +{ + switch (randint1(10)) + { + case 1: add_flag(o_ptr->art_flags, TR_ESP_ANIMAL); break; + case 2: add_flag(o_ptr->art_flags, TR_ESP_UNDEAD); break; + case 3: add_flag(o_ptr->art_flags, TR_ESP_DEMON); break; + case 4: add_flag(o_ptr->art_flags, TR_ESP_ORC); break; + case 5: add_flag(o_ptr->art_flags, TR_ESP_TROLL); break; + case 6: add_flag(o_ptr->art_flags, TR_ESP_GIANT); break; + case 7: add_flag(o_ptr->art_flags, TR_ESP_DRAGON); break; + case 8: add_flag(o_ptr->art_flags, TR_ESP_HUMAN); break; + case 9: add_flag(o_ptr->art_flags, TR_ESP_GOOD); break; + case 10: add_flag(o_ptr->art_flags, TR_ESP_UNIQUE); break; + } +} + + + +/* * Choose one random resistance */ void one_resistance(object_type *o_ptr) @@ -138,16 +167,20 @@ void one_resistance(object_type *o_ptr) */ void one_ability(object_type *o_ptr) { - switch (randint0(8)) + switch (randint0(10)) { - case 0: o_ptr->art_flags3 |= (TR3_FEATHER); break; - case 1: o_ptr->art_flags3 |= (TR3_LITE); break; - case 2: o_ptr->art_flags3 |= (TR3_SEE_INVIS); break; - case 3: o_ptr->art_flags3 |= (TR3_WARNING); break; - case 4: o_ptr->art_flags3 |= (TR3_SLOW_DIGEST); break; - case 5: o_ptr->art_flags3 |= (TR3_REGEN); break; - case 6: o_ptr->art_flags2 |= (TR2_FREE_ACT); break; - case 7: o_ptr->art_flags2 |= (TR2_HOLD_LIFE); break; + case 0: add_flag(o_ptr->art_flags, TR_LEVITATION); break; + case 1: add_flag(o_ptr->art_flags, TR_LITE); break; + case 2: add_flag(o_ptr->art_flags, TR_SEE_INVIS); break; + case 3: add_flag(o_ptr->art_flags, TR_WARNING); break; + case 4: add_flag(o_ptr->art_flags, TR_SLOW_DIGEST); break; + case 5: add_flag(o_ptr->art_flags, TR_REGEN); break; + case 6: add_flag(o_ptr->art_flags, TR_FREE_ACT); break; + case 7: add_flag(o_ptr->art_flags, TR_HOLD_LIFE); break; + case 8: + case 9: + one_low_esp(o_ptr); + break; } } @@ -159,154 +192,155 @@ static void curse_artifact(object_type * o_ptr) if (o_ptr->to_h > 0) o_ptr->to_h = 0 - (o_ptr->to_h + randint1(4)); if (o_ptr->to_d > 0) o_ptr->to_d = 0 - (o_ptr->to_d + randint1(4)); - o_ptr->art_flags3 |= (TR3_HEAVY_CURSE | TR3_CURSED); + o_ptr->curse_flags |= (TRC_HEAVY_CURSE | TRC_CURSED); + remove_flag(o_ptr->art_flags, TR_BLESSED); - if (one_in_(4)) o_ptr->art_flags3 |= TR3_PERMA_CURSE; - if (one_in_(3)) o_ptr->art_flags3 |= TR3_TY_CURSE; - if (one_in_(2)) o_ptr->art_flags3 |= TR3_AGGRAVATE; - if (one_in_(3)) o_ptr->art_flags3 |= TR3_DRAIN_EXP; - if (one_in_(2)) o_ptr->art_flags3 |= TR3_TELEPORT; - else if (one_in_(3)) o_ptr->art_flags3 |= TR3_NO_TELE; + if (one_in_(4)) o_ptr->curse_flags |= TRC_PERMA_CURSE; + if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE); + if (one_in_(2)) add_flag(o_ptr->art_flags, TR_AGGRAVATE); + if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP); + if (one_in_(2)) add_flag(o_ptr->art_flags, TR_TELEPORT); + else if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE); if ((p_ptr->pclass != CLASS_WARRIOR) && (p_ptr->pclass != CLASS_ARCHER) && (p_ptr->pclass != CLASS_CAVALRY) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH) && one_in_(3)) - o_ptr->art_flags3 |= TR3_NO_MAGIC; - - o_ptr->ident |= IDENT_CURSED; + add_flag(o_ptr->art_flags, TR_NO_MAGIC); } -static void random_plus(object_type * o_ptr, bool is_scroll) +static void random_plus(object_type * o_ptr) { - int this_type = (o_ptr->tval < TV_BOOTS ? 23 : 19); + int this_type = (object_is_weapon_ammo(o_ptr) ? 23 : 19); - if (artifact_bias == BIAS_WARRIOR) + switch (artifact_bias) { - if (!(o_ptr->art_flags1 & TR1_STR)) + case BIAS_WARRIOR: + if (!(have_flag(o_ptr->art_flags, TR_STR))) { - o_ptr->art_flags1 |= TR1_STR; - if (one_in_(2)) return; /* 50% chance of being a "free" power */ + add_flag(o_ptr->art_flags, TR_STR); + if (one_in_(2)) return; } - if (!(o_ptr->art_flags1 & TR1_CON)) + if (!(have_flag(o_ptr->art_flags, TR_CON))) { - o_ptr->art_flags1 |= TR1_CON; + add_flag(o_ptr->art_flags, TR_CON); if (one_in_(2)) return; } - if (!(o_ptr->art_flags1 & TR1_DEX)) + if (!(have_flag(o_ptr->art_flags, TR_DEX))) { - o_ptr->art_flags1 |= TR1_DEX; + add_flag(o_ptr->art_flags, TR_DEX); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_MAGE) - { - if (!(o_ptr->art_flags1 & TR1_INT)) + break; + + case BIAS_MAGE: + if (!(have_flag(o_ptr->art_flags, TR_INT))) { - o_ptr->art_flags1 |= TR1_INT; + add_flag(o_ptr->art_flags, TR_INT); if (one_in_(2)) return; } - if ((o_ptr->tval == TV_GLOVES) && !(o_ptr->art_flags1 & TR1_MAGIC_MASTERY)) + if ((o_ptr->tval == TV_GLOVES) && !(have_flag(o_ptr->art_flags, TR_MAGIC_MASTERY))) { - o_ptr->art_flags1 |= TR1_MAGIC_MASTERY; + add_flag(o_ptr->art_flags, TR_MAGIC_MASTERY); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_PRIESTLY) - { - if (!(o_ptr->art_flags1 & TR1_WIS)) + break; + + case BIAS_PRIESTLY: + if (!(have_flag(o_ptr->art_flags, TR_WIS))) { - o_ptr->art_flags1 |= TR1_WIS; + add_flag(o_ptr->art_flags, TR_WIS); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_RANGER) - { - if (!(o_ptr->art_flags1 & TR1_DEX)) + break; + + case BIAS_RANGER: + if (!(have_flag(o_ptr->art_flags, TR_DEX))) { - o_ptr->art_flags1 |= TR1_DEX; + add_flag(o_ptr->art_flags, TR_DEX); if (one_in_(2)) return; } - if (!(o_ptr->art_flags1 & TR1_CON)) + if (!(have_flag(o_ptr->art_flags, TR_CON))) { - o_ptr->art_flags1 |= TR1_CON; - if (one_in_(2)) return; /* 50% chance of being a "free" power */ + add_flag(o_ptr->art_flags, TR_CON); + if (one_in_(2)) return; } - if (!(o_ptr->art_flags1 & TR1_STR)) + if (!(have_flag(o_ptr->art_flags, TR_STR))) { - o_ptr->art_flags1 |= TR1_STR; + add_flag(o_ptr->art_flags, TR_STR); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_ROGUE) - { - if (!(o_ptr->art_flags1 & TR1_STEALTH)) + break; + + case BIAS_ROGUE: + if (!(have_flag(o_ptr->art_flags, TR_STEALTH))) { - o_ptr->art_flags1 |= TR1_STEALTH; + add_flag(o_ptr->art_flags, TR_STEALTH); if (one_in_(2)) return; } - if (!(o_ptr->art_flags1 & TR1_SEARCH)) + if (!(have_flag(o_ptr->art_flags, TR_SEARCH))) { - o_ptr->art_flags1 |= TR1_SEARCH; + add_flag(o_ptr->art_flags, TR_SEARCH); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_STR) - { - if (!(o_ptr->art_flags1 & TR1_STR)) + break; + + case BIAS_STR: + if (!(have_flag(o_ptr->art_flags, TR_STR))) { - o_ptr->art_flags1 |= TR1_STR; + add_flag(o_ptr->art_flags, TR_STR); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_WIS) - { - if (!(o_ptr->art_flags1 & TR1_WIS)) + break; + + case BIAS_WIS: + if (!(have_flag(o_ptr->art_flags, TR_WIS))) { - o_ptr->art_flags1 |= TR1_WIS; + add_flag(o_ptr->art_flags, TR_WIS); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_INT) - { - if (!(o_ptr->art_flags1 & TR1_INT)) + break; + + case BIAS_INT: + if (!(have_flag(o_ptr->art_flags, TR_INT))) { - o_ptr->art_flags1 |= TR1_INT; + add_flag(o_ptr->art_flags, TR_INT); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_DEX) - { - if (!(o_ptr->art_flags1 & TR1_DEX)) + break; + + case BIAS_DEX: + if (!(have_flag(o_ptr->art_flags, TR_DEX))) { - o_ptr->art_flags1 |= TR1_DEX; + add_flag(o_ptr->art_flags, TR_DEX); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_CON) - { - if (!(o_ptr->art_flags1 & TR1_CON)) + break; + + case BIAS_CON: + if (!(have_flag(o_ptr->art_flags, TR_CON))) { - o_ptr->art_flags1 |= TR1_CON; + add_flag(o_ptr->art_flags, TR_CON); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_CHR) - { - if (!(o_ptr->art_flags1 & TR1_CHR)) + break; + + case BIAS_CHR: + if (!(have_flag(o_ptr->art_flags, TR_CHR))) { - o_ptr->art_flags1 |= TR1_CHR; + add_flag(o_ptr->art_flags, TR_CHR); if (one_in_(2)) return; } + break; } if ((artifact_bias == BIAS_MAGE || artifact_bias == BIAS_PRIESTLY) && (o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ROBE)) { - if (!(o_ptr->art_flags3 & TR3_DEC_MANA) && one_in_(3)) + if (!(have_flag(o_ptr->art_flags, TR_DEC_MANA)) && one_in_(3)) { - o_ptr->art_flags3 |= TR3_DEC_MANA; + add_flag(o_ptr->art_flags, TR_DEC_MANA); if (one_in_(2)) return; } } @@ -314,71 +348,71 @@ static void random_plus(object_type * o_ptr, bool is_scroll) switch (randint1(this_type)) { case 1: case 2: - o_ptr->art_flags1 |= TR1_STR; + add_flag(o_ptr->art_flags, TR_STR); if (!artifact_bias && !one_in_(13)) artifact_bias = BIAS_STR; else if (!artifact_bias && one_in_(7)) artifact_bias = BIAS_WARRIOR; break; case 3: case 4: - o_ptr->art_flags1 |= TR1_INT; + add_flag(o_ptr->art_flags, TR_INT); if (!artifact_bias && !one_in_(13)) artifact_bias = BIAS_INT; else if (!artifact_bias && one_in_(7)) artifact_bias = BIAS_MAGE; break; case 5: case 6: - o_ptr->art_flags1 |= TR1_WIS; + add_flag(o_ptr->art_flags, TR_WIS); if (!artifact_bias && !one_in_(13)) artifact_bias = BIAS_WIS; else if (!artifact_bias && one_in_(7)) artifact_bias = BIAS_PRIESTLY; break; case 7: case 8: - o_ptr->art_flags1 |= TR1_DEX; + add_flag(o_ptr->art_flags, TR_DEX); if (!artifact_bias && !one_in_(13)) artifact_bias = BIAS_DEX; else if (!artifact_bias && one_in_(7)) artifact_bias = BIAS_ROGUE; break; case 9: case 10: - o_ptr->art_flags1 |= TR1_CON; + add_flag(o_ptr->art_flags, TR_CON); if (!artifact_bias && !one_in_(13)) artifact_bias = BIAS_CON; else if (!artifact_bias && one_in_(9)) artifact_bias = BIAS_RANGER; break; case 11: case 12: - o_ptr->art_flags1 |= TR1_CHR; + add_flag(o_ptr->art_flags, TR_CHR); if (!artifact_bias && !one_in_(13)) artifact_bias = BIAS_CHR; break; case 13: case 14: - o_ptr->art_flags1 |= TR1_STEALTH; + add_flag(o_ptr->art_flags, TR_STEALTH); if (!artifact_bias && one_in_(3)) artifact_bias = BIAS_ROGUE; break; case 15: case 16: - o_ptr->art_flags1 |= TR1_SEARCH; + add_flag(o_ptr->art_flags, TR_SEARCH); if (!artifact_bias && one_in_(9)) artifact_bias = BIAS_RANGER; break; case 17: case 18: - o_ptr->art_flags1 |= TR1_INFRA; + add_flag(o_ptr->art_flags, TR_INFRA); break; case 19: - o_ptr->art_flags1 |= TR1_SPEED; + add_flag(o_ptr->art_flags, TR_SPEED); if (!artifact_bias && one_in_(11)) artifact_bias = BIAS_ROGUE; break; case 20: case 21: - o_ptr->art_flags1 |= TR1_TUNNEL; + add_flag(o_ptr->art_flags, TR_TUNNEL); break; case 22: case 23: - if (o_ptr->tval == TV_BOW) random_plus(o_ptr, is_scroll); + if (o_ptr->tval == TV_BOW) random_plus(o_ptr); else { - o_ptr->art_flags1 |= TR1_BLOWS; + add_flag(o_ptr->art_flags, TR_BLOWS); if (!artifact_bias && one_in_(11)) artifact_bias = BIAS_WARRIOR; } @@ -387,181 +421,204 @@ static void random_plus(object_type * o_ptr, bool is_scroll) } -static void random_resistance(object_type * o_ptr, bool is_scroll) +static void random_resistance(object_type * o_ptr) { - if (artifact_bias == BIAS_ACID) + switch (artifact_bias) { - if (!(o_ptr->art_flags2 & TR2_RES_ACID)) + case BIAS_ACID: + if (!(have_flag(o_ptr->art_flags, TR_RES_ACID))) { - o_ptr->art_flags2 |= TR2_RES_ACID; + add_flag(o_ptr->art_flags, TR_RES_ACID); if (one_in_(2)) return; } - if (one_in_(BIAS_LUCK) && !(o_ptr->art_flags2 & TR2_IM_ACID)) + if (one_in_(BIAS_LUCK) && !(have_flag(o_ptr->art_flags, TR_IM_ACID))) { - o_ptr->art_flags2 |= TR2_IM_ACID; - if (!one_in_(IM_LUCK)) o_ptr->art_flags2 &= ~(TR2_IM_ELEC | TR2_IM_COLD | TR2_IM_FIRE); + add_flag(o_ptr->art_flags, TR_IM_ACID); + if (!one_in_(IM_LUCK)) + { + remove_flag(o_ptr->art_flags, TR_IM_ELEC); + remove_flag(o_ptr->art_flags, TR_IM_COLD); + remove_flag(o_ptr->art_flags, TR_IM_FIRE); + } if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_ELEC) - { - if (!(o_ptr->art_flags2 & TR2_RES_ELEC)) + break; + + case BIAS_ELEC: + if (!(have_flag(o_ptr->art_flags, TR_RES_ELEC))) { - o_ptr->art_flags2 |= TR2_RES_ELEC; + add_flag(o_ptr->art_flags, TR_RES_ELEC); if (one_in_(2)) return; } if ((o_ptr->tval >= TV_CLOAK) && (o_ptr->tval <= TV_HARD_ARMOR) && - !(o_ptr->art_flags3 & TR3_SH_ELEC)) + !(have_flag(o_ptr->art_flags, TR_SH_ELEC))) { - o_ptr->art_flags3 |= TR3_SH_ELEC; + add_flag(o_ptr->art_flags, TR_SH_ELEC); if (one_in_(2)) return; } - if (one_in_(BIAS_LUCK) && !(o_ptr->art_flags2 & TR2_IM_ELEC)) + if (one_in_(BIAS_LUCK) && !(have_flag(o_ptr->art_flags, TR_IM_ELEC))) { - o_ptr->art_flags2 |= TR2_IM_ELEC; - if (!one_in_(IM_LUCK)) o_ptr->art_flags2 &= ~(TR2_IM_ACID | TR2_IM_COLD | TR2_IM_FIRE); + add_flag(o_ptr->art_flags, TR_IM_ELEC); + if (!one_in_(IM_LUCK)) + { + remove_flag(o_ptr->art_flags, TR_IM_ACID); + remove_flag(o_ptr->art_flags, TR_IM_COLD); + remove_flag(o_ptr->art_flags, TR_IM_FIRE); + } + if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_FIRE) - { - if (!(o_ptr->art_flags2 & TR2_RES_FIRE)) + break; + + case BIAS_FIRE: + if (!(have_flag(o_ptr->art_flags, TR_RES_FIRE))) { - o_ptr->art_flags2 |= TR2_RES_FIRE; + add_flag(o_ptr->art_flags, TR_RES_FIRE); if (one_in_(2)) return; } if ((o_ptr->tval >= TV_CLOAK) && (o_ptr->tval <= TV_HARD_ARMOR) && - !(o_ptr->art_flags3 & TR3_SH_FIRE)) + !(have_flag(o_ptr->art_flags, TR_SH_FIRE))) { - o_ptr->art_flags3 |= TR3_SH_FIRE; + add_flag(o_ptr->art_flags, TR_SH_FIRE); if (one_in_(2)) return; } if (one_in_(BIAS_LUCK) && - !(o_ptr->art_flags2 & TR2_IM_FIRE)) + !(have_flag(o_ptr->art_flags, TR_IM_FIRE))) { - o_ptr->art_flags2 |= TR2_IM_FIRE; - if (!one_in_(IM_LUCK)) o_ptr->art_flags2 &= ~(TR2_IM_ELEC | TR2_IM_COLD | TR2_IM_ACID); + add_flag(o_ptr->art_flags, TR_IM_FIRE); + if (!one_in_(IM_LUCK)) + { + remove_flag(o_ptr->art_flags, TR_IM_ELEC); + remove_flag(o_ptr->art_flags, TR_IM_COLD); + remove_flag(o_ptr->art_flags, TR_IM_ACID); + } if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_COLD) - { - if (!(o_ptr->art_flags2 & TR2_RES_COLD)) + break; + + case BIAS_COLD: + if (!(have_flag(o_ptr->art_flags, TR_RES_COLD))) { - o_ptr->art_flags2 |= TR2_RES_COLD; + add_flag(o_ptr->art_flags, TR_RES_COLD); if (one_in_(2)) return; } if ((o_ptr->tval >= TV_CLOAK) && (o_ptr->tval <= TV_HARD_ARMOR) && - !(o_ptr->art_flags3 & TR3_SH_COLD)) + !(have_flag(o_ptr->art_flags, TR_SH_COLD))) { - o_ptr->art_flags3 |= TR3_SH_COLD; + add_flag(o_ptr->art_flags, TR_SH_COLD); if (one_in_(2)) return; } - if (one_in_(BIAS_LUCK) && !(o_ptr->art_flags2 & TR2_IM_COLD)) + if (one_in_(BIAS_LUCK) && !(have_flag(o_ptr->art_flags, TR_IM_COLD))) { - o_ptr->art_flags2 |= TR2_IM_COLD; - if (!one_in_(IM_LUCK)) o_ptr->art_flags2 &= ~(TR2_IM_ELEC | TR2_IM_ACID | TR2_IM_FIRE); + add_flag(o_ptr->art_flags, TR_IM_COLD); + if (!one_in_(IM_LUCK)) + { + remove_flag(o_ptr->art_flags, TR_IM_ELEC); + remove_flag(o_ptr->art_flags, TR_IM_ACID); + remove_flag(o_ptr->art_flags, TR_IM_FIRE); + } if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_POIS) - { - if (!(o_ptr->art_flags2 & TR2_RES_POIS)) + break; + + case BIAS_POIS: + if (!(have_flag(o_ptr->art_flags, TR_RES_POIS))) { - o_ptr->art_flags2 |= TR2_RES_POIS; + add_flag(o_ptr->art_flags, TR_RES_POIS); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_WARRIOR) - { - if (!one_in_(3) && (!(o_ptr->art_flags2 & TR2_RES_FEAR))) + break; + + case BIAS_WARRIOR: + if (!one_in_(3) && (!(have_flag(o_ptr->art_flags, TR_RES_FEAR)))) { - o_ptr->art_flags2 |= TR2_RES_FEAR; + add_flag(o_ptr->art_flags, TR_RES_FEAR); if (one_in_(2)) return; } - if (one_in_(3) && (!(o_ptr->art_flags3 & TR3_NO_MAGIC))) + if (one_in_(3) && (!(have_flag(o_ptr->art_flags, TR_NO_MAGIC)))) { - o_ptr->art_flags3 |= TR3_NO_MAGIC; + add_flag(o_ptr->art_flags, TR_NO_MAGIC); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_NECROMANTIC) - { - if (!(o_ptr->art_flags2 & TR2_RES_NETHER)) + break; + + case BIAS_NECROMANTIC: + if (!(have_flag(o_ptr->art_flags, TR_RES_NETHER))) { - o_ptr->art_flags2 |= TR2_RES_NETHER; + add_flag(o_ptr->art_flags, TR_RES_NETHER); if (one_in_(2)) return; } - if (!(o_ptr->art_flags2 & TR2_RES_POIS)) + if (!(have_flag(o_ptr->art_flags, TR_RES_POIS))) { - o_ptr->art_flags2 |= TR2_RES_POIS; + add_flag(o_ptr->art_flags, TR_RES_POIS); if (one_in_(2)) return; } - if (!(o_ptr->art_flags2 & TR2_RES_DARK)) + if (!(have_flag(o_ptr->art_flags, TR_RES_DARK))) { - o_ptr->art_flags2 |= TR2_RES_DARK; + add_flag(o_ptr->art_flags, TR_RES_DARK); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_CHAOS) - { - if (!(o_ptr->art_flags2 & TR2_RES_CHAOS)) + break; + + case BIAS_CHAOS: + if (!(have_flag(o_ptr->art_flags, TR_RES_CHAOS))) { - o_ptr->art_flags2 |= TR2_RES_CHAOS; + add_flag(o_ptr->art_flags, TR_RES_CHAOS); if (one_in_(2)) return; } - if (!(o_ptr->art_flags2 & TR2_RES_CONF)) + if (!(have_flag(o_ptr->art_flags, TR_RES_CONF))) { - o_ptr->art_flags2 |= TR2_RES_CONF; + add_flag(o_ptr->art_flags, TR_RES_CONF); if (one_in_(2)) return; } - if (!(o_ptr->art_flags2 & TR2_RES_DISEN)) + if (!(have_flag(o_ptr->art_flags, TR_RES_DISEN))) { - o_ptr->art_flags2 |= TR2_RES_DISEN; + add_flag(o_ptr->art_flags, TR_RES_DISEN); if (one_in_(2)) return; } + break; } switch (randint1(42)) { case 1: if (!one_in_(WEIRD_LUCK)) - random_resistance(o_ptr, is_scroll); + random_resistance(o_ptr); else { - o_ptr->art_flags2 |= TR2_IM_ACID; + add_flag(o_ptr->art_flags, TR_IM_ACID); if (!artifact_bias) artifact_bias = BIAS_ACID; } break; case 2: if (!one_in_(WEIRD_LUCK)) - random_resistance(o_ptr, is_scroll); + random_resistance(o_ptr); else { - o_ptr->art_flags2 |= TR2_IM_ELEC; + add_flag(o_ptr->art_flags, TR_IM_ELEC); if (!artifact_bias) artifact_bias = BIAS_ELEC; } break; case 3: if (!one_in_(WEIRD_LUCK)) - random_resistance(o_ptr, is_scroll); + random_resistance(o_ptr); else { - o_ptr->art_flags2 |= TR2_IM_COLD; + add_flag(o_ptr->art_flags, TR_IM_COLD); if (!artifact_bias) artifact_bias = BIAS_COLD; } break; case 4: if (!one_in_(WEIRD_LUCK)) - random_resistance(o_ptr, is_scroll); + random_resistance(o_ptr); else { - o_ptr->art_flags2 |= TR2_IM_FIRE; + add_flag(o_ptr->art_flags, TR_IM_FIRE); if (!artifact_bias) artifact_bias = BIAS_FIRE; } @@ -569,34 +626,34 @@ static void random_resistance(object_type * o_ptr, bool is_scroll) case 5: case 6: case 13: - o_ptr->art_flags2 |= TR2_RES_ACID; + add_flag(o_ptr->art_flags, TR_RES_ACID); if (!artifact_bias) artifact_bias = BIAS_ACID; break; case 7: case 8: case 14: - o_ptr->art_flags2 |= TR2_RES_ELEC; + add_flag(o_ptr->art_flags, TR_RES_ELEC); if (!artifact_bias) artifact_bias = BIAS_ELEC; break; case 9: case 10: case 15: - o_ptr->art_flags2 |= TR2_RES_FIRE; + add_flag(o_ptr->art_flags, TR_RES_FIRE); if (!artifact_bias) artifact_bias = BIAS_FIRE; break; case 11: case 12: case 16: - o_ptr->art_flags2 |= TR2_RES_COLD; + add_flag(o_ptr->art_flags, TR_RES_COLD); if (!artifact_bias) artifact_bias = BIAS_COLD; break; case 17: case 18: - o_ptr->art_flags2 |= TR2_RES_POIS; + add_flag(o_ptr->art_flags, TR_RES_POIS); if (!artifact_bias && !one_in_(4)) artifact_bias = BIAS_POIS; else if (!artifact_bias && one_in_(2)) @@ -606,82 +663,82 @@ static void random_resistance(object_type * o_ptr, bool is_scroll) break; case 19: case 20: - o_ptr->art_flags2 |= TR2_RES_FEAR; + add_flag(o_ptr->art_flags, TR_RES_FEAR); if (!artifact_bias && one_in_(3)) artifact_bias = BIAS_WARRIOR; break; case 21: - o_ptr->art_flags2 |= TR2_RES_LITE; + add_flag(o_ptr->art_flags, TR_RES_LITE); break; case 22: - o_ptr->art_flags2 |= TR2_RES_DARK; + add_flag(o_ptr->art_flags, TR_RES_DARK); break; case 23: case 24: - o_ptr->art_flags2 |= TR2_RES_BLIND; + add_flag(o_ptr->art_flags, TR_RES_BLIND); break; case 25: case 26: - o_ptr->art_flags2 |= TR2_RES_CONF; + add_flag(o_ptr->art_flags, TR_RES_CONF); if (!artifact_bias && one_in_(6)) artifact_bias = BIAS_CHAOS; break; case 27: case 28: - o_ptr->art_flags2 |= TR2_RES_SOUND; + add_flag(o_ptr->art_flags, TR_RES_SOUND); break; case 29: case 30: - o_ptr->art_flags2 |= TR2_RES_SHARDS; + add_flag(o_ptr->art_flags, TR_RES_SHARDS); break; case 31: case 32: - o_ptr->art_flags2 |= TR2_RES_NETHER; + add_flag(o_ptr->art_flags, TR_RES_NETHER); if (!artifact_bias && one_in_(3)) artifact_bias = BIAS_NECROMANTIC; break; case 33: case 34: - o_ptr->art_flags2 |= TR2_RES_NEXUS; + add_flag(o_ptr->art_flags, TR_RES_NEXUS); break; case 35: case 36: - o_ptr->art_flags2 |= TR2_RES_CHAOS; + add_flag(o_ptr->art_flags, TR_RES_CHAOS); if (!artifact_bias && one_in_(2)) artifact_bias = BIAS_CHAOS; break; case 37: case 38: - o_ptr->art_flags2 |= TR2_RES_DISEN; + add_flag(o_ptr->art_flags, TR_RES_DISEN); break; case 39: if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR) - o_ptr->art_flags3 |= TR3_SH_ELEC; + add_flag(o_ptr->art_flags, TR_SH_ELEC); else - random_resistance(o_ptr, is_scroll); + random_resistance(o_ptr); if (!artifact_bias) artifact_bias = BIAS_ELEC; break; case 40: if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR) - o_ptr->art_flags3 |= TR3_SH_FIRE; + add_flag(o_ptr->art_flags, TR_SH_FIRE); else - random_resistance(o_ptr, is_scroll); + random_resistance(o_ptr); if (!artifact_bias) artifact_bias = BIAS_FIRE; break; case 41: if (o_ptr->tval == TV_SHIELD || o_ptr->tval == TV_CLOAK || o_ptr->tval == TV_HELM || o_ptr->tval == TV_HARD_ARMOR) - o_ptr->art_flags2 |= TR2_REFLECT; + add_flag(o_ptr->art_flags, TR_REFLECT); else - random_resistance(o_ptr, is_scroll); + random_resistance(o_ptr); break; case 42: if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR) - o_ptr->art_flags3 |= TR3_SH_COLD; + add_flag(o_ptr->art_flags, TR_SH_COLD); else - random_resistance(o_ptr, is_scroll); + random_resistance(o_ptr); if (!artifact_bias) artifact_bias = BIAS_COLD; break; @@ -690,119 +747,121 @@ static void random_resistance(object_type * o_ptr, bool is_scroll) -static void random_misc(object_type * o_ptr, bool is_scroll) +static void random_misc(object_type * o_ptr) { - if (artifact_bias == BIAS_RANGER) + switch (artifact_bias) { - if (!(o_ptr->art_flags2 & TR2_SUST_CON)) + case BIAS_RANGER: + if (!(have_flag(o_ptr->art_flags, TR_SUST_CON))) { - o_ptr->art_flags2 |= TR2_SUST_CON; + add_flag(o_ptr->art_flags, TR_SUST_CON); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_STR) - { - if (!(o_ptr->art_flags2 & TR2_SUST_STR)) + break; + + case BIAS_STR: + if (!(have_flag(o_ptr->art_flags, TR_SUST_STR))) { - o_ptr->art_flags2 |= TR2_SUST_STR; + add_flag(o_ptr->art_flags, TR_SUST_STR); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_WIS) - { - if (!(o_ptr->art_flags2 & TR2_SUST_WIS)) + break; + + case BIAS_WIS: + if (!(have_flag(o_ptr->art_flags, TR_SUST_WIS))) { - o_ptr->art_flags2 |= TR2_SUST_WIS; + add_flag(o_ptr->art_flags, TR_SUST_WIS); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_INT) - { - if (!(o_ptr->art_flags2 & TR2_SUST_INT)) + break; + + case BIAS_INT: + if (!(have_flag(o_ptr->art_flags, TR_SUST_INT))) { - o_ptr->art_flags2 |= TR2_SUST_INT; + add_flag(o_ptr->art_flags, TR_SUST_INT); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_DEX) - { - if (!(o_ptr->art_flags2 & TR2_SUST_DEX)) + break; + + case BIAS_DEX: + if (!(have_flag(o_ptr->art_flags, TR_SUST_DEX))) { - o_ptr->art_flags2 |= TR2_SUST_DEX; + add_flag(o_ptr->art_flags, TR_SUST_DEX); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_CON) - { - if (!(o_ptr->art_flags2 & TR2_SUST_CON)) + break; + + case BIAS_CON: + if (!(have_flag(o_ptr->art_flags, TR_SUST_CON))) { - o_ptr->art_flags2 |= TR2_SUST_CON; + add_flag(o_ptr->art_flags, TR_SUST_CON); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_CHR) - { - if (!(o_ptr->art_flags2 & TR2_SUST_CHR)) + break; + + case BIAS_CHR: + if (!(have_flag(o_ptr->art_flags, TR_SUST_CHR))) { - o_ptr->art_flags2 |= TR2_SUST_CHR; + add_flag(o_ptr->art_flags, TR_SUST_CHR); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_CHAOS) - { - if (!(o_ptr->art_flags3 & TR3_TELEPORT)) + break; + + case BIAS_CHAOS: + if (!(have_flag(o_ptr->art_flags, TR_TELEPORT))) { - o_ptr->art_flags3 |= TR3_TELEPORT; + add_flag(o_ptr->art_flags, TR_TELEPORT); if (one_in_(2)) return; } - } - else if (artifact_bias == BIAS_FIRE) - { - if (!(o_ptr->art_flags3 & TR3_LITE)) + break; + + case BIAS_FIRE: + if (!(have_flag(o_ptr->art_flags, TR_LITE))) { - o_ptr->art_flags3 |= TR3_LITE; /* Freebie */ + add_flag(o_ptr->art_flags, TR_LITE); /* Freebie */ } + break; } - switch (randint1(31)) + switch (randint1(33)) { case 1: - o_ptr->art_flags2 |= TR2_SUST_STR; + add_flag(o_ptr->art_flags, TR_SUST_STR); if (!artifact_bias) artifact_bias = BIAS_STR; break; case 2: - o_ptr->art_flags2 |= TR2_SUST_INT; + add_flag(o_ptr->art_flags, TR_SUST_INT); if (!artifact_bias) artifact_bias = BIAS_INT; break; case 3: - o_ptr->art_flags2 |= TR2_SUST_WIS; + add_flag(o_ptr->art_flags, TR_SUST_WIS); if (!artifact_bias) artifact_bias = BIAS_WIS; break; case 4: - o_ptr->art_flags2 |= TR2_SUST_DEX; + add_flag(o_ptr->art_flags, TR_SUST_DEX); if (!artifact_bias) artifact_bias = BIAS_DEX; break; case 5: - o_ptr->art_flags2 |= TR2_SUST_CON; + add_flag(o_ptr->art_flags, TR_SUST_CON); if (!artifact_bias) artifact_bias = BIAS_CON; break; case 6: - o_ptr->art_flags2 |= TR2_SUST_CHR; + add_flag(o_ptr->art_flags, TR_SUST_CHR); if (!artifact_bias) artifact_bias = BIAS_CHR; break; case 7: case 8: case 14: - o_ptr->art_flags2 |= TR2_FREE_ACT; + add_flag(o_ptr->art_flags, TR_FREE_ACT); break; case 9: - o_ptr->art_flags2 |= TR2_HOLD_LIFE; + add_flag(o_ptr->art_flags, TR_HOLD_LIFE); if (!artifact_bias && one_in_(5)) artifact_bias = BIAS_PRIESTLY; else if (!artifact_bias && one_in_(6)) @@ -810,39 +869,33 @@ static void random_misc(object_type * o_ptr, bool is_scroll) break; case 10: case 11: - o_ptr->art_flags3 |= TR3_LITE; + add_flag(o_ptr->art_flags, TR_LITE); break; case 12: case 13: - o_ptr->art_flags3 |= TR3_FEATHER; + add_flag(o_ptr->art_flags, TR_LEVITATION); break; case 15: case 16: case 17: - o_ptr->art_flags3 |= TR3_SEE_INVIS; - break; - case 18: - if (one_in_(3)) break; - o_ptr->art_flags3 |= TR3_TELEPATHY; - if (!artifact_bias && one_in_(9)) - artifact_bias = BIAS_MAGE; + add_flag(o_ptr->art_flags, TR_SEE_INVIS); break; case 19: case 20: - o_ptr->art_flags3 |= TR3_SLOW_DIGEST; + add_flag(o_ptr->art_flags, TR_SLOW_DIGEST); break; case 21: case 22: - o_ptr->art_flags3 |= TR3_REGEN; + add_flag(o_ptr->art_flags, TR_REGEN); break; case 23: - o_ptr->art_flags3 |= TR3_TELEPORT; + add_flag(o_ptr->art_flags, TR_TELEPORT); break; case 24: case 25: case 26: - if (o_ptr->tval >= TV_BOOTS && o_ptr->tval <= TV_DRAG_ARMOR) - random_misc(o_ptr, is_scroll); + if (object_is_armour(o_ptr)) + random_misc(o_ptr); else { o_ptr->to_a = 4 + randint1(11); @@ -853,7 +906,7 @@ static void random_misc(object_type * o_ptr, bool is_scroll) case 29: { int bonus_h, bonus_d; - o_ptr->art_flags3 |= TR3_SHOW_MODS; + add_flag(o_ptr->art_flags, TR_SHOW_MODS); bonus_h = 4 + (randint1(11)); bonus_d = 4 + (randint1(11)); if ((o_ptr->tval != TV_SWORD) && (o_ptr->tval != TV_POLEARM) && (o_ptr->tval != TV_HAFTED) && (o_ptr->tval != TV_DIGGING) && (o_ptr->tval != TV_GLOVES) && (o_ptr->tval != TV_RING)) @@ -866,268 +919,349 @@ static void random_misc(object_type * o_ptr, bool is_scroll) break; } case 30: - o_ptr->art_flags3 |= TR3_NO_MAGIC; + add_flag(o_ptr->art_flags, TR_NO_MAGIC); break; case 31: - o_ptr->art_flags3 |= TR3_NO_TELE; + add_flag(o_ptr->art_flags, TR_NO_TELE); + break; + case 32: + add_flag(o_ptr->art_flags, TR_WARNING); break; - } -} + case 18: + switch (randint1(3)) + { + case 1: + add_flag(o_ptr->art_flags, TR_ESP_EVIL); + if (!artifact_bias && one_in_(3)) + artifact_bias = BIAS_LAW; + break; + case 2: + add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); + if (!artifact_bias && one_in_(3)) + artifact_bias = BIAS_MAGE; + break; + case 3: + add_flag(o_ptr->art_flags, TR_TELEPATHY); + if (!artifact_bias && one_in_(9)) + artifact_bias = BIAS_MAGE; + break; + } + break; -static void random_slay(object_type *o_ptr, bool is_scroll) -{ - if (artifact_bias == BIAS_CHAOS && (o_ptr->tval != TV_BOW)) - { - if (!(o_ptr->art_flags1 & TR1_CHAOTIC)) + case 33: { - o_ptr->art_flags1 |= TR1_CHAOTIC; - if (one_in_(2)) return; - } - } + int idx[3]; + int n = randint1(3); - else if (artifact_bias == BIAS_PRIESTLY && - (o_ptr->tval == TV_SWORD || o_ptr->tval == TV_POLEARM) && - !(o_ptr->art_flags3 & TR3_BLESSED)) - { - /* A free power for "priestly" random artifacts */ - o_ptr->art_flags3 |= TR3_BLESSED; - } + idx[0] = randint1(8); - else if (artifact_bias == BIAS_NECROMANTIC && (o_ptr->tval != TV_BOW)) - { - if (!(o_ptr->art_flags1 & TR1_VAMPIRIC)) - { - o_ptr->art_flags1 |= TR1_VAMPIRIC; - if (one_in_(2)) return; - } - if (!(o_ptr->art_flags1 & TR1_BRAND_POIS) && one_in_(2)) - { - o_ptr->art_flags1 |= TR1_BRAND_POIS; - if (one_in_(2)) return; - } - } + idx[1] = randint1(7); + if (idx[1] >= idx[0]) idx[1]++; - else if (artifact_bias == BIAS_RANGER && (o_ptr->tval != TV_BOW)) - { - if (!(o_ptr->art_flags1 & TR1_SLAY_ANIMAL)) - { - o_ptr->art_flags1 |= TR1_SLAY_ANIMAL; - if (one_in_(2)) return; + idx[2] = randint1(6); + if (idx[2] >= idx[0]) idx[2]++; + if (idx[2] >= idx[1]) idx[2]++; + + while (n--) switch (idx[n]) + { + case 1: + add_flag(o_ptr->art_flags, TR_ESP_ANIMAL); + if (!artifact_bias && one_in_(4)) + artifact_bias = BIAS_RANGER; + break; + case 2: + add_flag(o_ptr->art_flags, TR_ESP_UNDEAD); + if (!artifact_bias && one_in_(3)) + artifact_bias = BIAS_PRIESTLY; + else if (!artifact_bias && one_in_(6)) + artifact_bias = BIAS_NECROMANTIC; + break; + case 3: + add_flag(o_ptr->art_flags, TR_ESP_DEMON); + break; + case 4: + add_flag(o_ptr->art_flags, TR_ESP_ORC); + break; + case 5: + add_flag(o_ptr->art_flags, TR_ESP_TROLL); + break; + case 6: + add_flag(o_ptr->art_flags, TR_ESP_GIANT); + break; + case 7: + add_flag(o_ptr->art_flags, TR_ESP_HUMAN); + if (!artifact_bias && one_in_(6)) + artifact_bias = BIAS_ROGUE; + break; + case 8: + add_flag(o_ptr->art_flags, TR_ESP_GOOD); + if (!artifact_bias && one_in_(3)) + artifact_bias = BIAS_LAW; + break; + case 9: + add_flag(o_ptr->art_flags, TR_ESP_UNIQUE); + if (!artifact_bias && one_in_(3)) + artifact_bias = BIAS_LAW; + break; + } + break; } } +} + - else if (artifact_bias == BIAS_ROGUE && (o_ptr->tval != TV_BOW)) +static void random_slay(object_type *o_ptr) +{ + if (o_ptr->tval == TV_BOW) { - if ((((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DAGGER)) || - ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_SPEAR))) && - !(o_ptr->art_flags2 & TR2_THROW)) - { - /* Free power for rogues... */ - o_ptr->art_flags2 |= TR2_THROW; - } - if (!(o_ptr->art_flags1 & TR1_BRAND_POIS)) + switch (randint1(6)) { - o_ptr->art_flags1 |= TR1_BRAND_POIS; - if (one_in_(2)) return; + case 1: + case 2: + case 3: + add_flag(o_ptr->art_flags, TR_XTRA_MIGHT); + if (!one_in_(7)) remove_flag(o_ptr->art_flags, TR_XTRA_SHOTS); + if (!artifact_bias && one_in_(9)) + artifact_bias = BIAS_RANGER; + break; + default: + add_flag(o_ptr->art_flags, TR_XTRA_SHOTS); + if (!one_in_(7)) remove_flag(o_ptr->art_flags, TR_XTRA_MIGHT); + if (!artifact_bias && one_in_(9)) + artifact_bias = BIAS_RANGER; + break; } + + return; } - else if (artifact_bias == BIAS_POIS && (o_ptr->tval != TV_BOW)) + switch (artifact_bias) { - if (!(o_ptr->art_flags1 & TR1_BRAND_POIS)) + case BIAS_CHAOS: + if (!(have_flag(o_ptr->art_flags, TR_CHAOTIC))) { - o_ptr->art_flags1 |= TR1_BRAND_POIS; + add_flag(o_ptr->art_flags, TR_CHAOTIC); if (one_in_(2)) return; } - } + break; - else if (artifact_bias == BIAS_FIRE && (o_ptr->tval != TV_BOW)) - { - if (!(o_ptr->art_flags1 & TR1_BRAND_FIRE)) + case BIAS_PRIESTLY: + if((o_ptr->tval == TV_SWORD || o_ptr->tval == TV_POLEARM) && + !(have_flag(o_ptr->art_flags, TR_BLESSED))) { - o_ptr->art_flags1 |= TR1_BRAND_FIRE; - if (one_in_(2)) return; + /* A free power for "priestly" random artifacts */ + add_flag(o_ptr->art_flags, TR_BLESSED); } - } + break; - else if (artifact_bias == BIAS_COLD && (o_ptr->tval != TV_BOW)) - { - if (!(o_ptr->art_flags1 & TR1_BRAND_COLD)) + case BIAS_NECROMANTIC: + if (!(have_flag(o_ptr->art_flags, TR_VAMPIRIC))) { - o_ptr->art_flags1 |= TR1_BRAND_COLD; + add_flag(o_ptr->art_flags, TR_VAMPIRIC); if (one_in_(2)) return; } - } - - else if (artifact_bias == BIAS_ELEC && (o_ptr->tval != TV_BOW)) - { - if (!(o_ptr->art_flags1 & TR1_BRAND_ELEC)) + if (!(have_flag(o_ptr->art_flags, TR_BRAND_POIS)) && one_in_(2)) { - o_ptr->art_flags1 |= TR1_BRAND_ELEC; + add_flag(o_ptr->art_flags, TR_BRAND_POIS); if (one_in_(2)) return; } - } + break; - else if (artifact_bias == BIAS_ACID && (o_ptr->tval != TV_BOW)) - { - if (!(o_ptr->art_flags1 & TR1_BRAND_ACID)) + case BIAS_RANGER: + if (!(have_flag(o_ptr->art_flags, TR_SLAY_ANIMAL))) { - o_ptr->art_flags1 |= TR1_BRAND_ACID; + add_flag(o_ptr->art_flags, TR_SLAY_ANIMAL); if (one_in_(2)) return; } - } + break; - else if (artifact_bias == BIAS_LAW && (o_ptr->tval != TV_BOW)) - { - if (!(o_ptr->art_flags1 & TR1_SLAY_EVIL)) + case BIAS_ROGUE: + if ((((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DAGGER)) || + ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_SPEAR))) && + !(have_flag(o_ptr->art_flags, TR_THROW))) { - o_ptr->art_flags1 |= TR1_SLAY_EVIL; - if (one_in_(2)) return; + /* Free power for rogues... */ + add_flag(o_ptr->art_flags, TR_THROW); } - if (!(o_ptr->art_flags1 & TR1_SLAY_UNDEAD)) + if (!(have_flag(o_ptr->art_flags, TR_BRAND_POIS))) { - o_ptr->art_flags1 |= TR1_SLAY_UNDEAD; + add_flag(o_ptr->art_flags, TR_BRAND_POIS); if (one_in_(2)) return; } - if (!(o_ptr->art_flags1 & TR1_SLAY_DEMON)) + break; + + case BIAS_POIS: + if (!(have_flag(o_ptr->art_flags, TR_BRAND_POIS))) { - o_ptr->art_flags1 |= TR1_SLAY_DEMON; + add_flag(o_ptr->art_flags, TR_BRAND_POIS); if (one_in_(2)) return; } - } - - if (o_ptr->tval != TV_BOW) - { - switch (randint1(34)) - { - case 1: - case 2: - o_ptr->art_flags1 |= TR1_SLAY_ANIMAL; - break; - case 3: - case 4: - o_ptr->art_flags1 |= TR1_SLAY_EVIL; - if (!artifact_bias && one_in_(2)) - artifact_bias = BIAS_LAW; - else if (!artifact_bias && one_in_(9)) - artifact_bias = BIAS_PRIESTLY; - break; - case 5: - case 6: - o_ptr->art_flags1 |= TR1_SLAY_UNDEAD; - if (!artifact_bias && one_in_(9)) - artifact_bias = BIAS_PRIESTLY; - break; - case 7: - case 8: - o_ptr->art_flags1 |= TR1_SLAY_DEMON; - if (!artifact_bias && one_in_(9)) - artifact_bias = BIAS_PRIESTLY; - break; - case 9: - case 10: - o_ptr->art_flags1 |= TR1_SLAY_ORC; - break; - case 11: - case 12: - o_ptr->art_flags1 |= TR1_SLAY_TROLL; - break; - case 13: - case 14: - o_ptr->art_flags1 |= TR1_SLAY_GIANT; - break; - case 15: - case 16: - o_ptr->art_flags1 |= TR1_SLAY_DRAGON; - break; - case 17: - o_ptr->art_flags1 |= TR1_KILL_DRAGON; - break; - case 18: - case 19: - if (o_ptr->tval == TV_SWORD) - { - o_ptr->art_flags1 |= TR1_VORPAL; - if (!artifact_bias && one_in_(9)) - artifact_bias = BIAS_WARRIOR; - } - else - random_slay(o_ptr, is_scroll); - break; - case 20: - o_ptr->art_flags1 |= TR1_IMPACT; - break; - case 21: - case 22: - o_ptr->art_flags1 |= TR1_BRAND_FIRE; - if (!artifact_bias) - artifact_bias = BIAS_FIRE; - break; - case 23: - case 24: - o_ptr->art_flags1 |= TR1_BRAND_COLD; - if (!artifact_bias) - artifact_bias = BIAS_COLD; - break; - case 25: - case 26: - o_ptr->art_flags1 |= TR1_BRAND_ELEC; - if (!artifact_bias) - artifact_bias = BIAS_ELEC; - break; - case 27: - case 28: - o_ptr->art_flags1 |= TR1_BRAND_ACID; - if (!artifact_bias) - artifact_bias = BIAS_ACID; - break; - case 29: - case 30: - o_ptr->art_flags1 |= TR1_BRAND_POIS; - if (!artifact_bias && !one_in_(3)) - artifact_bias = BIAS_POIS; - else if (!artifact_bias && one_in_(6)) - artifact_bias = BIAS_NECROMANTIC; - else if (!artifact_bias) - artifact_bias = BIAS_ROGUE; - break; - case 31: - o_ptr->art_flags1 |= TR1_VAMPIRIC; - if (!artifact_bias) - artifact_bias = BIAS_NECROMANTIC; - break; - case 32: - o_ptr->art_flags1 |= TR1_FORCE_WEAPON; - if (!artifact_bias) - artifact_bias = (one_in_(2) ? BIAS_MAGE : BIAS_PRIESTLY); - break; - default: - o_ptr->art_flags1 |= TR1_CHAOTIC; - if (!artifact_bias) - artifact_bias = BIAS_CHAOS; - break; + break; + + case BIAS_FIRE: + if (!(have_flag(o_ptr->art_flags, TR_BRAND_FIRE))) + { + add_flag(o_ptr->art_flags, TR_BRAND_FIRE); + if (one_in_(2)) return; + } + break; + + case BIAS_COLD: + if (!(have_flag(o_ptr->art_flags, TR_BRAND_COLD))) + { + add_flag(o_ptr->art_flags, TR_BRAND_COLD); + if (one_in_(2)) return; + } + break; + + case BIAS_ELEC: + if (!(have_flag(o_ptr->art_flags, TR_BRAND_ELEC))) + { + add_flag(o_ptr->art_flags, TR_BRAND_ELEC); + if (one_in_(2)) return; + } + break; + + case BIAS_ACID: + if (!(have_flag(o_ptr->art_flags, TR_BRAND_ACID))) + { + add_flag(o_ptr->art_flags, TR_BRAND_ACID); + if (one_in_(2)) return; + } + break; + + case BIAS_LAW: + if (!(have_flag(o_ptr->art_flags, TR_SLAY_EVIL))) + { + add_flag(o_ptr->art_flags, TR_SLAY_EVIL); + if (one_in_(2)) return; } + if (!(have_flag(o_ptr->art_flags, TR_SLAY_UNDEAD))) + { + add_flag(o_ptr->art_flags, TR_SLAY_UNDEAD); + if (one_in_(2)) return; + } + if (!(have_flag(o_ptr->art_flags, TR_SLAY_DEMON))) + { + add_flag(o_ptr->art_flags, TR_SLAY_DEMON); + if (one_in_(2)) return; + } + break; } - else + + switch (randint1(36)) { - switch (randint1(6)) - { - case 1: - case 2: - case 3: - o_ptr->art_flags3 |= TR3_XTRA_MIGHT; - if (!one_in_(7)) o_ptr->art_flags3 &= ~(TR3_XTRA_SHOTS); - if (!artifact_bias && one_in_(9)) - artifact_bias = BIAS_RANGER; - break; - default: - o_ptr->art_flags3 |= TR3_XTRA_SHOTS; - if (!one_in_(7)) o_ptr->art_flags3 &= ~(TR3_XTRA_MIGHT); + case 1: + case 2: + add_flag(o_ptr->art_flags, TR_SLAY_ANIMAL); + break; + case 3: + case 4: + add_flag(o_ptr->art_flags, TR_SLAY_EVIL); + if (!artifact_bias && one_in_(2)) + artifact_bias = BIAS_LAW; + else if (!artifact_bias && one_in_(9)) + artifact_bias = BIAS_PRIESTLY; + break; + case 5: + case 6: + add_flag(o_ptr->art_flags, TR_SLAY_UNDEAD); + if (!artifact_bias && one_in_(9)) + artifact_bias = BIAS_PRIESTLY; + break; + case 7: + case 8: + add_flag(o_ptr->art_flags, TR_SLAY_DEMON); + if (!artifact_bias && one_in_(9)) + artifact_bias = BIAS_PRIESTLY; + break; + case 9: + case 10: + add_flag(o_ptr->art_flags, TR_SLAY_ORC); + break; + case 11: + case 12: + add_flag(o_ptr->art_flags, TR_SLAY_TROLL); + break; + case 13: + case 14: + add_flag(o_ptr->art_flags, TR_SLAY_GIANT); + break; + case 15: + case 16: + add_flag(o_ptr->art_flags, TR_SLAY_DRAGON); + break; + case 17: + add_flag(o_ptr->art_flags, TR_KILL_DRAGON); + break; + case 18: + case 19: + if (o_ptr->tval == TV_SWORD) + { + add_flag(o_ptr->art_flags, TR_VORPAL); if (!artifact_bias && one_in_(9)) - artifact_bias = BIAS_RANGER; + artifact_bias = BIAS_WARRIOR; + } + else + random_slay(o_ptr); + break; + case 20: + add_flag(o_ptr->art_flags, TR_IMPACT); + break; + case 21: + case 22: + add_flag(o_ptr->art_flags, TR_BRAND_FIRE); + if (!artifact_bias) + artifact_bias = BIAS_FIRE; + break; + case 23: + case 24: + add_flag(o_ptr->art_flags, TR_BRAND_COLD); + if (!artifact_bias) + artifact_bias = BIAS_COLD; + break; + case 25: + case 26: + add_flag(o_ptr->art_flags, TR_BRAND_ELEC); + if (!artifact_bias) + artifact_bias = BIAS_ELEC; + break; + case 27: + case 28: + add_flag(o_ptr->art_flags, TR_BRAND_ACID); + if (!artifact_bias) + artifact_bias = BIAS_ACID; + break; + case 29: + case 30: + add_flag(o_ptr->art_flags, TR_BRAND_POIS); + if (!artifact_bias && !one_in_(3)) + artifact_bias = BIAS_POIS; + else if (!artifact_bias && one_in_(6)) + artifact_bias = BIAS_NECROMANTIC; + else if (!artifact_bias) + artifact_bias = BIAS_ROGUE; + break; + case 31: + add_flag(o_ptr->art_flags, TR_VAMPIRIC); + if (!artifact_bias) + artifact_bias = BIAS_NECROMANTIC; + break; + case 32: + add_flag(o_ptr->art_flags, TR_FORCE_WEAPON); + if (!artifact_bias) + artifact_bias = (one_in_(2) ? BIAS_MAGE : BIAS_PRIESTLY); + break; + case 33: + case 34: + add_flag(o_ptr->art_flags, TR_SLAY_HUMAN); + break; + default: + add_flag(o_ptr->art_flags, TR_CHAOTIC); + if (!artifact_bias) + artifact_bias = BIAS_CHAOS; break; - } } } @@ -1136,10 +1270,9 @@ static void give_activation_power(object_type *o_ptr) { int type = 0, chance = 0; - if (artifact_bias) + switch (artifact_bias) { - if (artifact_bias == BIAS_ELEC) - { + case BIAS_ELEC: if (!one_in_(3)) { type = ACT_BO_ELEC_1; @@ -1153,14 +1286,14 @@ static void give_activation_power(object_type *o_ptr) type = ACT_BA_ELEC_3; } chance = 101; - } - else if (artifact_bias == BIAS_POIS) - { + break; + + case BIAS_POIS: type = ACT_BA_POIS_1; chance = 101; - } - else if (artifact_bias == BIAS_FIRE) - { + break; + + case BIAS_FIRE: if (!one_in_(3)) { type = ACT_BO_FIRE_1; @@ -1174,9 +1307,9 @@ static void give_activation_power(object_type *o_ptr) type = ACT_BA_FIRE_2; } chance = 101; - } - else if (artifact_bias == BIAS_COLD) - { + break; + + case BIAS_COLD: chance = 101; if (!one_in_(3)) type = ACT_BO_COLD_1; @@ -1186,17 +1319,17 @@ static void give_activation_power(object_type *o_ptr) type = ACT_BA_COLD_2; else type = ACT_BA_COLD_3; - } - else if (artifact_bias == BIAS_CHAOS) - { + break; + + case BIAS_CHAOS: chance = 50; if (one_in_(6)) type = ACT_SUMMON_DEMON; else type = ACT_CALL_CHAOS; - } - else if (artifact_bias == BIAS_PRIESTLY) - { + break; + + case BIAS_PRIESTLY: chance = 101; if (one_in_(13)) @@ -1217,9 +1350,9 @@ static void give_activation_power(object_type *o_ptr) type = ACT_REST_LIFE; else type = ACT_CURE_MW; - } - else if (artifact_bias == BIAS_NECROMANTIC) - { + break; + + case BIAS_NECROMANTIC: chance = 101; if (one_in_(66)) type = ACT_WRAITH; @@ -1237,9 +1370,9 @@ static void give_activation_power(object_type *o_ptr) type = ACT_CHARM_UNDEAD; else type = ACT_VAMPIRE_1; - } - else if (artifact_bias == BIAS_LAW) - { + break; + + case BIAS_LAW: chance = 101; if (one_in_(8)) type = ACT_BANISH_EVIL; @@ -1247,9 +1380,9 @@ static void give_activation_power(object_type *o_ptr) type = ACT_DISP_EVIL; else type = ACT_PROT_EVIL; - } - else if (artifact_bias == BIAS_ROGUE) - { + break; + + case BIAS_ROGUE: chance = 101; if (one_in_(50)) type = ACT_SPEED; @@ -1261,9 +1394,9 @@ static void give_activation_power(object_type *o_ptr) type = ACT_ID_FULL; else type = ACT_ID_PLAIN; - } - else if (artifact_bias == BIAS_MAGE) - { + break; + + case BIAS_MAGE: chance = 66; if (one_in_(20)) type = ACT_SUMMON_ELEMENTAL; @@ -1273,17 +1406,17 @@ static void give_activation_power(object_type *o_ptr) type = ACT_RUNE_EXPLO; else type = ACT_ESP; - } - else if (artifact_bias == BIAS_WARRIOR) - { + break; + + case BIAS_WARRIOR: chance = 80; if (one_in_(100)) type = ACT_INVULN; else type = ACT_BERSERK; - } - else if (artifact_bias == BIAS_RANGER) - { + break; + + case BIAS_RANGER: chance = 101; if (one_in_(20)) type = ACT_CHARM_ANIMALS; @@ -1297,7 +1430,7 @@ static void give_activation_power(object_type *o_ptr) type = ACT_SATIATE; else type = ACT_CURE_POISON; - } + break; } while (!type || (randint1(100) >= chance)) @@ -1404,14 +1537,20 @@ static void give_activation_power(object_type *o_ptr) /* A type was chosen... */ o_ptr->xtra2 = type; - o_ptr->art_flags3 |= TR3_ACTIVATE; + add_flag(o_ptr->art_flags, TR_ACTIVATE); o_ptr->timeout = 0; } static void get_random_name(char *return_name, bool armour, int power) { - if (randint1(100) <= TABLE_NAME) + int prob = randint1(100); + + if (prob <= SINDARIN_NAME) + { + get_table_sindarin(return_name); + } + else if (prob <= TABLE_NAME) { get_table_name(return_name); } @@ -1426,35 +1565,31 @@ static void get_random_name(char *return_name, bool armour, int power) { case 0: #ifdef JP -filename = "a_cursed_j.txt"; + filename = "a_cursed_j.txt"; #else filename = "a_cursed.txt"; #endif - break; case 1: #ifdef JP -filename = "a_low_j.txt"; + filename = "a_low_j.txt"; #else filename = "a_low.txt"; #endif - break; case 2: #ifdef JP -filename = "a_med_j.txt"; + filename = "a_med_j.txt"; #else filename = "a_med.txt"; #endif - break; default: #ifdef JP -filename = "a_high_j.txt"; + filename = "a_high_j.txt"; #else filename = "a_high.txt"; #endif - } break; default: @@ -1462,41 +1597,37 @@ filename = "a_high_j.txt"; { case 0: #ifdef JP -filename = "w_cursed_j.txt"; + filename = "w_cursed_j.txt"; #else filename = "w_cursed.txt"; #endif - break; case 1: #ifdef JP -filename = "w_low_j.txt"; + filename = "w_low_j.txt"; #else filename = "w_low.txt"; #endif - break; case 2: #ifdef JP -filename = "w_med_j.txt"; + filename = "w_med_j.txt"; #else filename = "w_med.txt"; #endif - break; default: #ifdef JP -filename = "w_high_j.txt"; + filename = "w_high_j.txt"; #else filename = "w_high.txt"; #endif - } } (void)get_rnd_line(filename, artifact_bias, return_name); #ifdef JP - if(return_name[0]==0)get_table_name(return_name); + if (return_name[0] == 0) get_table_name(return_name); #endif } } @@ -1507,22 +1638,23 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) char new_name[1024]; int has_pval = 0; int powers = randint1(5) + 1; - int max_type = (o_ptr->tval < TV_BOOTS ? 7 : 5); + int max_type = (object_is_weapon_ammo(o_ptr) ? 7 : 5); int power_level; s32b total_flags; bool a_cursed = FALSE; int warrior_artifact_bias = 0; + int i; - + /* Reset artifact bias */ artifact_bias = 0; /* Nuke enchantments */ o_ptr->name1 = 0; o_ptr->name2 = 0; - o_ptr->art_flags1 |= k_info[o_ptr->k_idx].flags1; - o_ptr->art_flags2 |= k_info[o_ptr->k_idx].flags2; - o_ptr->art_flags3 |= k_info[o_ptr->k_idx].flags3; + for (i = 0; i < TR_FLAG_SIZE; i++) + o_ptr->art_flags[i] |= k_info[o_ptr->k_idx].flags[i]; + if (o_ptr->pval) has_pval = TRUE; if (a_scroll && one_in_(4)) @@ -1553,6 +1685,7 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) warrior_artifact_bias = 25; break; case CLASS_RANGER: + case CLASS_SNIPER: artifact_bias = BIAS_RANGER; warrior_artifact_bias = 30; break; @@ -1607,7 +1740,7 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) if (!a_scroll && one_in_(A_CURSED)) a_cursed = TRUE; - if (((o_ptr->tval == TV_AMULET) || (o_ptr->tval == TV_RING)) && cursed_p(o_ptr)) + if (((o_ptr->tval == TV_AMULET) || (o_ptr->tval == TV_RING)) && object_is_cursed(o_ptr)) a_cursed = TRUE; while (one_in_(powers) || one_in_(7) || one_in_(10)) @@ -1624,11 +1757,11 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) switch (randint1(max_type)) { case 1: case 2: - random_plus(o_ptr, a_scroll); + random_plus(o_ptr); has_pval = TRUE; break; case 3: case 4: - if (one_in_(2) && (o_ptr->tval < TV_BOOTS) && (o_ptr->tval != TV_BOW)) + if (one_in_(2) && object_is_weapon_ammo(o_ptr) && (o_ptr->tval != TV_BOW)) { if (a_cursed && !one_in_(13)) break; if (one_in_(13)) @@ -1641,16 +1774,16 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) } } else - random_resistance(o_ptr, a_scroll); + random_resistance(o_ptr); break; case 5: - random_misc(o_ptr, a_scroll); + random_misc(o_ptr); break; case 6: case 7: - random_slay(o_ptr, a_scroll); + random_slay(o_ptr); break; default: - if (wizard) msg_print("Switch error in create_artifact!"); + if (p_ptr->wizard) msg_print("Switch error in create_artifact!"); powers++; } }; @@ -1658,14 +1791,14 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) if (has_pval) { #if 0 - o_ptr->art_flags3 |= TR3_SHOW_MODS; + add_flag(o_ptr->art_flags, TR_SHOW_MODS); /* This one commented out by gw's request... */ if (!a_scroll) - o_ptr->art_flags3 |= TR3_HIDE_TYPE; + add_flag(o_ptr->art_flags, TR_HIDE_TYPE); #endif - if (o_ptr->art_flags1 & TR1_BLOWS) + if (have_flag(o_ptr->art_flags, TR_BLOWS)) { o_ptr->pval = randint1(2); if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA)) @@ -1685,18 +1818,20 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) } /* give it some plusses... */ - if (o_ptr->tval >= TV_BOOTS && o_ptr->tval <= TV_DRAG_ARMOR) + if (object_is_armour(o_ptr)) o_ptr->to_a += randint1(o_ptr->to_a > 19 ? 1 : 20 - o_ptr->to_a); - else if (o_ptr->tval <= TV_SWORD) + else if (object_is_weapon_ammo(o_ptr)) { o_ptr->to_h += randint1(o_ptr->to_h > 19 ? 1 : 20 - o_ptr->to_h); o_ptr->to_d += randint1(o_ptr->to_d > 19 ? 1 : 20 - o_ptr->to_d); - if ((o_ptr->art_flags1 & TR1_WIS) && (o_ptr->pval > 0)) o_ptr->art_flags3 |= TR3_BLESSED; + if ((have_flag(o_ptr->art_flags, TR_WIS)) && (o_ptr->pval > 0)) add_flag(o_ptr->art_flags, TR_BLESSED); } /* Just to be sure */ - o_ptr->art_flags3 |= (TR3_IGNORE_ACID | TR3_IGNORE_ELEC | - TR3_IGNORE_FIRE | TR3_IGNORE_COLD); + add_flag(o_ptr->art_flags, TR_IGNORE_ACID); + add_flag(o_ptr->art_flags, TR_IGNORE_ELEC); + add_flag(o_ptr->art_flags, TR_IGNORE_FIRE); + add_flag(o_ptr->art_flags, TR_IGNORE_COLD); total_flags = flag_cost(o_ptr, o_ptr->pval); if (cheat_peek) msg_format("%ld", total_flags); @@ -1704,14 +1839,13 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) if (a_cursed) curse_artifact(o_ptr); if (!a_cursed && - (randint1((o_ptr->tval >= TV_BOOTS) - ? ACTIVATION_CHANCE * 2 : ACTIVATION_CHANCE) == 1)) + one_in_(object_is_armour(o_ptr) ? ACTIVATION_CHANCE * 2 : ACTIVATION_CHANCE)) { o_ptr->xtra2 = 0; give_activation_power(o_ptr); } - if ((o_ptr->tval >= TV_BOOTS) && (o_ptr->tval <= TV_DRAG_ARMOR)) + if (object_is_armour(o_ptr)) { while ((o_ptr->to_d+o_ptr->to_h) > 20) { @@ -1727,50 +1861,59 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) } } - if (((artifact_bias == BIAS_MAGE) || (artifact_bias == BIAS_INT)) && (o_ptr->tval == TV_GLOVES)) o_ptr->art_flags2 |= TR2_FREE_ACT; + if (((artifact_bias == BIAS_MAGE) || (artifact_bias == BIAS_INT)) && (o_ptr->tval == TV_GLOVES)) add_flag(o_ptr->art_flags, TR_FREE_ACT); if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) { o_ptr->to_h = 0; o_ptr->to_d = 0; - o_ptr->art_flags1 &= ~(TR1_BLOWS); - o_ptr->art_flags1 &= ~(TR1_FORCE_WEAPON); - o_ptr->art_flags1 &= ~(TR1_SLAY_ANIMAL); - o_ptr->art_flags1 &= ~(TR1_SLAY_EVIL); - o_ptr->art_flags1 &= ~(TR1_SLAY_UNDEAD); - o_ptr->art_flags1 &= ~(TR1_SLAY_DEMON); - o_ptr->art_flags1 &= ~(TR1_SLAY_ORC); - o_ptr->art_flags1 &= ~(TR1_SLAY_TROLL); - o_ptr->art_flags1 &= ~(TR1_SLAY_GIANT); - o_ptr->art_flags1 &= ~(TR1_SLAY_DRAGON); - o_ptr->art_flags1 &= ~(TR1_KILL_DRAGON); - o_ptr->art_flags1 &= ~(TR1_VORPAL); - o_ptr->art_flags1 &= ~(TR1_BRAND_POIS); - o_ptr->art_flags1 &= ~(TR1_BRAND_ACID); - o_ptr->art_flags1 &= ~(TR1_BRAND_ELEC); - o_ptr->art_flags1 &= ~(TR1_BRAND_FIRE); - o_ptr->art_flags1 &= ~(TR1_BRAND_COLD); - } - - if (o_ptr->tval >= TV_BOOTS) - { + remove_flag(o_ptr->art_flags, TR_BLOWS); + remove_flag(o_ptr->art_flags, TR_FORCE_WEAPON); + remove_flag(o_ptr->art_flags, TR_SLAY_ANIMAL); + remove_flag(o_ptr->art_flags, TR_SLAY_EVIL); + remove_flag(o_ptr->art_flags, TR_SLAY_UNDEAD); + remove_flag(o_ptr->art_flags, TR_SLAY_DEMON); + remove_flag(o_ptr->art_flags, TR_SLAY_ORC); + remove_flag(o_ptr->art_flags, TR_SLAY_TROLL); + remove_flag(o_ptr->art_flags, TR_SLAY_GIANT); + remove_flag(o_ptr->art_flags, TR_SLAY_DRAGON); + remove_flag(o_ptr->art_flags, TR_KILL_DRAGON); + remove_flag(o_ptr->art_flags, TR_SLAY_HUMAN); + remove_flag(o_ptr->art_flags, TR_VORPAL); + remove_flag(o_ptr->art_flags, TR_BRAND_POIS); + remove_flag(o_ptr->art_flags, TR_BRAND_ACID); + remove_flag(o_ptr->art_flags, TR_BRAND_ELEC); + remove_flag(o_ptr->art_flags, TR_BRAND_FIRE); + remove_flag(o_ptr->art_flags, TR_BRAND_COLD); + } + + if (!object_is_weapon_ammo(o_ptr)) + { + /* For armors */ if (a_cursed) power_level = 0; else if (total_flags < 15000) power_level = 1; - else if (total_flags < 25000) power_level = 2; + else if (total_flags < 35000) power_level = 2; else power_level = 3; } else { + /* For weapons */ if (a_cursed) power_level = 0; else if (total_flags < 20000) power_level = 1; - else if (total_flags < 35000) power_level = 2; + else if (total_flags < 45000) power_level = 2; else power_level = 3; } if (a_scroll) { - char dummy_name[80]; + char dummy_name[80] = ""; +#ifdef JP + cptr ask_msg = "¤³¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ò²¿¤È̾ÉÕ¤±¤Þ¤¹¤«¡©"; +#else + cptr ask_msg = "What do you want to call the artifact? "; +#endif + /* Identify it fully */ object_aware(o_ptr); object_known(o_ptr); @@ -1778,60 +1921,45 @@ bool create_artifact(object_type *o_ptr, bool a_scroll) /* Mark the item as fully known */ o_ptr->ident |= (IDENT_MENTAL); - strcpy(dummy_name, ""); - (void)identify_fully_aux(o_ptr); - -#ifdef JP - if (!(get_string("¤³¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ò²¿¤È̾ÉÕ¤±¤Þ¤¹¤«¡©", dummy_name, 80))) -#else - if (!(get_string("What do you want to call the artifact? ", dummy_name, 80))) -#endif + (void)screen_object(o_ptr, 0L); + if (!get_string(ask_msg, dummy_name, sizeof dummy_name) + || !dummy_name[0]) { - get_random_name(new_name, (bool)(o_ptr->tval >= TV_BOOTS), power_level); + /* Cancelled */ + if (one_in_(2)) + { + get_table_sindarin_aux(dummy_name); + } + else + { + get_table_name_aux(dummy_name); + } } - else - { -#ifdef JP - strcpy(new_name, "¡Ô"); -#else - strcpy(new_name, "'"); -#endif - strcat(new_name, dummy_name); #ifdef JP - strcat(new_name, "¡Õ¤È¤¤¤¦Ì¾¤Î"); + sprintf(new_name, "¡Ô%s¡Õ", dummy_name); #else - strcat(new_name, "'"); + sprintf(new_name, "'%s'", dummy_name); #endif - } - chg_virtue(V_INDIVIDUALISM, 2); chg_virtue(V_ENCHANT, 5); - } else { - get_random_name(new_name, (bool)(o_ptr->tval >= TV_BOOTS), power_level); + get_random_name(new_name, object_is_armour(o_ptr), power_level); } if (cheat_xtra) { - if (artifact_bias) -#ifdef JP -msg_format("±¿¤ÎÊФä¿¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È: %d¡£", artifact_bias); -#else - msg_format("Biased artifact: %d.", artifact_bias); -#endif - - else #ifdef JP -msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ë±¿¤ÎÊФê¤Ê¤·¡£"); + if (artifact_bias) msg_format("±¿¤ÎÊФä¿¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È: %d¡£", artifact_bias); + else msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ë±¿¤ÎÊФê¤Ê¤·¡£"); #else - msg_print("No bias in artifact."); + if (artifact_bias) msg_format("Biased artifact: %d.", artifact_bias); + else msg_print("No bias in artifact."); #endif - } /* Save the inscription */ @@ -1844,12 +1972,14 @@ msg_print(" } -bool activate_random_artifact(object_type * o_ptr) +bool activate_random_artifact(object_type *o_ptr) { int plev = p_ptr->lev; int k, dir, dummy = 0; - if (!o_ptr->art_name) return FALSE; /* oops? */ + /* Paranoia */ + if (!have_flag(o_ptr->art_flags, TR_ACTIVATE)) return FALSE; + if (!o_ptr->xtra2) return FALSE; /* Activate for attack */ switch (o_ptr->xtra2) @@ -2121,7 +2251,7 @@ bool activate_random_artifact(object_type * o_ptr) m_ptr = &m_list[c_ptr->m_idx]; /* Hack -- attack monsters */ - if (c_ptr->m_idx && (m_ptr->ml || cave_floor_bold(y, x))) + if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT))) py_attack(y, x, 0); } } @@ -2266,7 +2396,7 @@ bool activate_random_artifact(object_type * o_ptr) if (banish_evil(100)) { #ifdef JP - msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÎÎϤ¬¼Ù°­¤òÂǤÁÅݤ·¤¿¡ª"); + msg_print("¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÎÎϤ¬¼Ù°­¤òÂǤÁʧ¤Ã¤¿¡ª"); #else msg_print("The power of the artifact banishes evil!"); #endif @@ -2344,7 +2474,7 @@ bool activate_random_artifact(object_type * o_ptr) case ACT_SUMMON_ANIMAL: { - (void)summon_specific(-1, py, px, plev, SUMMON_ANIMAL_RANGER, TRUE, TRUE, TRUE, FALSE, FALSE); + (void)summon_specific(-1, py, px, plev, SUMMON_ANIMAL_RANGER, (PM_ALLOW_GROUP | PM_FORCE_PET)); o_ptr->timeout = 200 + randint1(300); break; } @@ -2357,7 +2487,7 @@ bool activate_random_artifact(object_type * o_ptr) msg_print("You summon a phantasmal servant."); #endif - (void)summon_specific(-1, py, px, dun_level, SUMMON_PHANTOM, TRUE, TRUE, TRUE, FALSE, FALSE); + (void)summon_specific(-1, py, px, dun_level, SUMMON_PHANTOM, (PM_ALLOW_GROUP | PM_FORCE_PET)); o_ptr->timeout = 200 + randint1(200); break; } @@ -2365,9 +2495,13 @@ bool activate_random_artifact(object_type * o_ptr) case ACT_SUMMON_ELEMENTAL: { bool pet = one_in_(3); - bool group = !(pet && (plev < 50)); + u32b mode = 0L; + + if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP; + if (pet) mode |= PM_FORCE_PET; + else mode |= PM_NO_PET; - if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_ELEMENTAL, group, FALSE, pet, FALSE, (bool)(!pet))) + if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_ELEMENTAL, mode)) { #ifdef JP msg_print("¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿..."); @@ -2399,9 +2533,13 @@ bool activate_random_artifact(object_type * o_ptr) case ACT_SUMMON_DEMON: { bool pet = one_in_(3); - bool group = !(pet && (plev < 50)); + u32b mode = 0L; - if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_DEMON, group, FALSE, pet, FALSE, (bool)(!pet))) + if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP; + if (pet) mode |= PM_FORCE_PET; + else mode |= PM_NO_PET; + + if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), SUMMON_DEMON, mode)) { #ifdef JP msg_print("ⲫ¤Î°­½­¤¬½¼Ëþ¤·¤¿¡£"); @@ -2432,24 +2570,16 @@ bool activate_random_artifact(object_type * o_ptr) case ACT_SUMMON_UNDEAD: { bool pet = one_in_(3); - bool group; - bool unique_okay; int type; + u32b mode = 0L; type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD); - if (pet) - { - group = (((plev > 24) && one_in_(3)) ? TRUE : FALSE); - unique_okay = FALSE; - } - else - { - group = TRUE; - unique_okay = TRUE; - } - if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), type, - group, FALSE, pet, unique_okay, (bool)(!pet))) + if (!pet || ((plev > 24) && one_in_(3))) mode |= PM_ALLOW_GROUP; + if (pet) mode |= PM_FORCE_PET; + else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET); + + if (summon_specific((pet ? -1 : 0), py, px, ((plev * 3) / 2), type, mode)) { #ifdef JP msg_print("Î䤿¤¤É÷¤¬¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¿á¤­»Ï¤á¤¿¡£¤½¤ì¤ÏÉåÇÔ½­¤ò±¿¤ó¤Ç¤¤¤ë..."); @@ -2598,6 +2728,7 @@ bool activate_random_artifact(object_type * o_ptr) case ACT_BERSERK: { + (void)set_afraid(0); (void)set_hero(randint1(50) + 50, FALSE); (void)set_blessed(randint1(50) + 50, FALSE); o_ptr->timeout = 100 + randint1(100); @@ -2860,7 +2991,7 @@ bool activate_random_artifact(object_type * o_ptr) msg_print("It twists space around you..."); #endif - teleport_player(100); + teleport_player(100, 0L); o_ptr->timeout = 45; break; } @@ -2893,7 +3024,36 @@ bool activate_random_artifact(object_type * o_ptr) } -void random_artifact_resistance(object_type * o_ptr) +void get_bloody_moon_flags(object_type *o_ptr) +{ + int dummy, i; + + for (i = 0; i < TR_FLAG_SIZE; i++) + o_ptr->art_flags[i] = a_info[ART_BLOOD].flags[i]; + + dummy = randint1(2) + randint1(2); + for (i = 0; i < dummy; i++) + { + int flag = randint0(26); + if (flag >= 20) add_flag(o_ptr->art_flags, TR_KILL_UNDEAD + flag - 20); + else if (flag == 19) add_flag(o_ptr->art_flags, TR_KILL_ANIMAL); + else if (flag == 18) add_flag(o_ptr->art_flags, TR_SLAY_HUMAN); + else add_flag(o_ptr->art_flags, TR_CHAOTIC + flag); + } + + dummy = randint1(2); + for (i = 0; i < dummy; i++) one_resistance(o_ptr); + + for (i = 0; i < 2; i++) + { + int tmp = randint0(11); + if (tmp < 6) add_flag(o_ptr->art_flags, TR_STR + tmp); + else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6); + } +} + + +void random_artifact_resistance(object_type * o_ptr, artifact_type *a_ptr) { bool give_resistance = FALSE, give_power = FALSE; @@ -2906,108 +3066,50 @@ void random_artifact_resistance(object_type * o_ptr) } else { - o_ptr->art_flags3 |= - (TR3_CURSED | TR3_HEAVY_CURSE | TR3_AGGRAVATE | TR3_TY_CURSE); - o_ptr->ident |= IDENT_CURSED; + add_flag(o_ptr->art_flags, TR_AGGRAVATE); + add_flag(o_ptr->art_flags, TR_TY_CURSE); + o_ptr->curse_flags |= + (TRC_CURSED | TRC_HEAVY_CURSE); + o_ptr->curse_flags |= get_curse(2, o_ptr); return; } } + if (o_ptr->name1 == ART_MURAMASA) { if (p_ptr->pclass != CLASS_SAMURAI) { - o_ptr->art_flags3 |= (TR3_NO_TELE | TR3_NO_MAGIC | TR3_HEAVY_CURSE); - o_ptr->ident |= IDENT_CURSED; + add_flag(o_ptr->art_flags, TR_NO_MAGIC); + o_ptr->curse_flags |= (TRC_HEAVY_CURSE); } } if (o_ptr->name1 == ART_XIAOLONG) { if (p_ptr->pclass == CLASS_MONK) - o_ptr->art_flags1 |= TR1_BLOWS; + add_flag(o_ptr->art_flags, TR_BLOWS); } if (o_ptr->name1 == ART_BLOOD) { - int dummy, i; - dummy = randint1(2)+randint1(2); - for (i = 0; i < dummy; i++) - o_ptr->art_flags1 |= (TR1_CHAOTIC << randint0(18)); - dummy = randint1(2); - for (i = 0; i < dummy; i++) - one_resistance(o_ptr); - dummy = 2; - for (i = 0; i < dummy; i++) - { - int tmp = randint0(11); - if (tmp < 6) o_ptr->art_flags1 |= (TR1_STR << tmp); - else o_ptr->art_flags1 |= (TR1_STEALTH << (tmp - 6)); + get_bloody_moon_flags(o_ptr); + } + + if (o_ptr->name1 == ART_HEAVENLY_MAIDEN) + { + if (p_ptr->psex != SEX_FEMALE) + { + add_flag(o_ptr->art_flags, TR_AGGRAVATE); } } - switch (o_ptr->name1) + if (a_ptr->gen_flags & (TRG_XTRA_POWER)) give_power = TRUE; + if (a_ptr->gen_flags & (TRG_XTRA_H_RES)) give_resistance = TRUE; + if (a_ptr->gen_flags & (TRG_XTRA_RES_OR_POWER)) { - case ART_JULIAN: - case ART_ARVEDUI: - case ART_CASPANION: - case ART_HITHLOMIR: - case ART_ROHIRRIM: - case ART_CELEGORM: - case ART_ANARION: - case ART_THRANDUIL: - case ART_LUTHIEN: - case ART_THROR: - case ART_THORIN: - case ART_NIMTHANC: - case ART_DETHANC: - case ART_NARTHANC: - case ART_STING: - case ART_TURMIL: - case ART_THALKETTOTH: - case ART_JIZO: - { - /* Give a resistance */ - give_resistance = TRUE; - } - break; - case ART_MAEDHROS: - case ART_GLAMDRING: - case ART_ORCRIST: - case ART_ANDURIL: - case ART_ZARCUTHRA: - case ART_GURTHANG: - case ART_SOULSWORD: - case ART_BRAND: - case ART_DAWN: - case ART_BUCKLAND: - case ART_AZAGHAL: - { - /* Give a resistance OR a power */ - if (one_in_(2)) give_resistance = TRUE; - else give_power = TRUE; - } - break; - case ART_NENYA: - case ART_VILYA: - case ART_BERUTHIEL: - case ART_THINGOL: - case ART_ULMO: - case ART_GANDALF: - { - /* Give a power */ - give_power = TRUE; - } - break; - case ART_CRIMSON: - case ART_POWER: - case ART_AMBER: - case ART_AULE: - { - /* Give both */ - give_power = TRUE; - give_resistance = TRUE; - } - break; + /* Give a resistance OR a power */ + if (one_in_(2)) give_resistance = TRUE; + else give_power = TRUE; } if (give_power) @@ -3025,7 +3127,7 @@ void random_artifact_resistance(object_type * o_ptr) /* * Create the artifact of the specified number */ -void create_named_art(int a_idx, int y, int x) +bool create_named_art(int a_idx, int y, int x) { object_type forge; object_type *q_ptr; @@ -3037,13 +3139,13 @@ void create_named_art(int a_idx, int y, int x) q_ptr = &forge; /* Ignore "empty" artifacts */ - if (!a_ptr->name) return; + if (!a_ptr->name) return FALSE; /* Acquire the "kind" index */ i = lookup_kind(a_ptr->tval, a_ptr->sval); /* Oops */ - if (!i) return; + if (!i) return FALSE; /* Create the artifact */ object_prep(q_ptr, i); @@ -3061,11 +3163,22 @@ void create_named_art(int a_idx, int y, int x) q_ptr->to_d = a_ptr->to_d; q_ptr->weight = a_ptr->weight; - /* Hack -- acquire "cursed" flag */ - if (a_ptr->flags3 & TR3_CURSED) q_ptr->ident |= (IDENT_CURSED); + /* Hack -- extract the "cursed" flag */ + if (a_ptr->gen_flags & TRG_CURSED) q_ptr->curse_flags |= (TRC_CURSED); + if (a_ptr->gen_flags & TRG_HEAVY_CURSE) q_ptr->curse_flags |= (TRC_HEAVY_CURSE); + if (a_ptr->gen_flags & TRG_PERMA_CURSE) q_ptr->curse_flags |= (TRC_PERMA_CURSE); + if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) q_ptr->curse_flags |= get_curse(0, q_ptr); + if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) q_ptr->curse_flags |= get_curse(1, q_ptr); + if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) q_ptr->curse_flags |= get_curse(2, q_ptr); + + random_artifact_resistance(q_ptr, a_ptr); - random_artifact_resistance(q_ptr); + /* + * drop_near()Æâ¤ÇÉáÄ̤θÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤¬½Å¤Ê¤é¤Ê¤¤À­¼Á¤Ë°Í¸¤¹¤ë. + * ²¾¤Ë2¸Ä°Ê¾å¸ºß²Äǽ¤«¤ÄÁõÈ÷Éʰʳ°¤Î¸ÇÄꥢ¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤¬ºîÀ®¤µ¤ì¤ì¤Ð + * ¤³¤Î´Ø¿ô¤ÎÊÖ¤êÃͤϿ®ÍѤǤ­¤Ê¤¯¤Ê¤ë. + */ /* Drop the artifact from heaven */ - (void)drop_near(q_ptr, -1, y, x); + return drop_near(q_ptr, -1, y, x) ? TRUE : FALSE; }