OSDN Git Service

Add new armor ego -- of Demonic. Cursed, but powerful.
[hengband/hengband.git] / src / object2.c
index 52f0bb9..e5cbb3e 100644 (file)
@@ -1018,6 +1018,8 @@ s32b flag_cost(object_type *o_ptr, int plusses)
        if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
        if (have_flag(flgs, TR_ACTIVATE)) total += 100;
        if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
+       if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
+       if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
        if (have_flag(flgs, TR_TELEPORT))
        {
                if (object_is_cursed(o_ptr))
@@ -1036,14 +1038,9 @@ s32b flag_cost(object_type *o_ptr, int plusses)
        /* Also, give some extra for activatable powers... */
        if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
        {
-               int i;
-               for (i = 0; activation_info[i].flag != NULL; i++)
-               {
-                       if (activation_info[i].index == o_ptr->xtra2)
-                       {
-                               total += activation_info[i].value;
-                               break;
-                       }
+               const activation_type* const act_ptr = find_activation_info(o_ptr);
+               if (act_ptr) {
+                       total += act_ptr->value;
                }
        }
 
@@ -1833,7 +1830,7 @@ void object_wipe(object_type *o_ptr)
 void object_copy(object_type *o_ptr, object_type *j_ptr)
 {
        /* Copy the structure */
-       COPY(o_ptr, j_ptr, object_type);
+       (void)COPY(o_ptr, j_ptr, object_type);
 }
 
 
@@ -1873,6 +1870,9 @@ void object_prep(object_type *o_ptr, int k_idx)
        o_ptr->dd = k_ptr->dd;
        o_ptr->ds = k_ptr->ds;
 
+       /* Default activation */
+       if (k_ptr->act_idx > 0) o_ptr->xtra2 = k_ptr->act_idx;
+
        /* Hack -- worthless items are always "broken" */
        if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
 
@@ -2320,6 +2320,8 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                                continue;
                                        if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
                                                continue;
+                                       if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
+                                               continue;
                                        break;
                                }
 
@@ -2397,6 +2399,20 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                        if (one_in_(5))
                                                add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
                                        break;
+                               case EGO_DEMON:
+                                       
+                                       if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
+                                       one_in_(3) ? 
+                                               add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
+                                               one_in_(2) ?
+                                                       add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
+                                                       add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
+                                               
+                                       
+                                       if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
+                                       if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
+                                       if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
+                                       break;
                                }
 
                                if (!o_ptr->art_name)
@@ -2415,11 +2431,27 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
                                /* Roll for ego-item */
                                if (randint0(MAX_DEPTH) < level)
                                {
-                                       o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
+                                       while(1)
+                                       {
+                                               o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
+                                               if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
+                                               {
+                                                       continue;
+                                               }
+                                               break;
+                                       }
                                        switch (o_ptr->name2)
                                        {
                                        case EGO_MORGUL:
                                                if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
+                                               if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
+                                       case EGO_WEIRD:
+                                               if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
+                                               if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
+                                               if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
+                                               if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
+                                               if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
+                                               if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
                                        }
                                }
                        }
@@ -2645,31 +2677,63 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
 
                                        switch (o_ptr->name2)
                                        {
-                                       case EGO_RESISTANCE:
-                                               if (one_in_(4))
-                                                       add_flag(o_ptr->art_flags, TR_RES_POIS);
-                                               break;
-                                       case EGO_ELVENKIND:
-                                               break;
-                                       case EGO_DWARVEN:
+                                         case EGO_DWARVEN:
                                                if (o_ptr->tval != TV_HARD_ARMOR)
                                                {
                                                        okay_flag = FALSE;
                                                        break;
                                                }
-                                               else
+                                         case EGO_DRUID:
+                                               if (o_ptr->tval != TV_SOFT_ARMOR)
                                                {
-                                                       o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
-                                                       o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
-                                                       if (one_in_(4))
-                                                               add_flag(o_ptr->art_flags, TR_CON);
+                                                       okay_flag = FALSE;
                                                        break;
                                                }
+                                         case EGO_A_DEMON:
+                                               if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
+                                               one_in_(3) ? 
+                                                       add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
+                                                       one_in_(2) ?
+                                                               add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
+                                                               add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
+                                               
+                                               if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
+                                               if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
+                                               if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
+                                               if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
+                                               if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
+                                               if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
+                                               if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
+                                               
+                                               break;
+                                         default:
+                                               break;
                                        }
 
                                        if (okay_flag)
                                                break;
                                }
+                               switch (o_ptr->name2)
+                               {
+                                 case EGO_RESISTANCE:
+                                       if (one_in_(4))
+                                               add_flag(o_ptr->art_flags, TR_RES_POIS);
+                                               break;
+                                 case EGO_DWARVEN:
+                                       o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
+                                       o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
+                                       break;
+                                 case EGO_A_MORGUL:
+                                       if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
+                                       if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
+                                       if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
+                                       if (one_in_(4)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
+                                       if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
+                                       if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
+                                       break;
+                                 default:
+                                       break;
+                               }
                        }
 
                        break;
@@ -2694,7 +2758,17 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                        create_artifact(o_ptr, FALSE);
                                        break;
                                }
-                               o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
+                               
+                               while(1)
+                               {
+                                       o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
+                                       if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD 
+                                                               && o_ptr->name2 == EGO_S_DWARVEN)
+                                       {
+                                               continue;
+                                       }
+                                       break;
+                               }
                                
                                switch (o_ptr->name2)
                                {
@@ -2706,6 +2780,11 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                        if (o_ptr->sval == SV_MIRROR_SHIELD)
                                                o_ptr->name2 = 0;
                                        break;
+                                       
+                               case EGO_S_DWARVEN:
+                                       o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
+                                       o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
+                                       break;
                                }
                        }
                        break;
@@ -4310,7 +4389,7 @@ void apply_magic(object_type *o_ptr, int lev, u32b mode)
                if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
 
                /* Hack -- apply extra penalties if needed */
-               if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
+               if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
                {
                        /* Hack -- obtain bonuses */
                        if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
@@ -4343,6 +4422,34 @@ void apply_magic(object_type *o_ptr, int lev, u32b mode)
                                        o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
                                else o_ptr->to_a += randint1(e_ptr->max_to_a);
                        }
+                       
+                       /* Accuracy ego must have high to_h */
+                       if(o_ptr->name2 == EGO_ACCURACY)
+                       {
+                               while(o_ptr->to_h < o_ptr->to_d + 10)
+                               {
+                                       o_ptr->to_h += 5;
+                                       o_ptr->to_d -= 5;
+                               }
+                               o_ptr->to_h = MAX(o_ptr->to_h, 15);
+                       }
+                       
+                       /* Accuracy ego must have high to_h */
+                       if(o_ptr->name2 == EGO_VELOCITY)
+                       {
+                               while(o_ptr->to_d < o_ptr->to_h + 10)
+                               {
+                                       o_ptr->to_d += 5;
+                                       o_ptr->to_h -= 5;
+                               }
+                               o_ptr->to_d = MAX(o_ptr->to_d, 15);
+                       }
+                       
+                       /* Protection ego must have high to_a */
+                       if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION))
+                       {
+                               o_ptr->to_a = MAX(o_ptr->to_a, 15);
+                       }
 
                        /* Hack -- obtain pval */
                        if (e_ptr->max_pval)
@@ -4352,6 +4459,17 @@ void apply_magic(object_type *o_ptr, int lev, u32b mode)
                                        o_ptr->pval++;
                                        if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
                                }
+                               else if (o_ptr->name2 == EGO_DEMON)
+                               {
+                                       if(have_flag(o_ptr->art_flags, TR_BLOWS))
+                                       {
+                                               o_ptr->pval += randint1(2);
+                                       }
+                                       else
+                                       {
+                                               o_ptr->pval += randint1(e_ptr->max_pval);
+                                       }
+                               }
                                else if (o_ptr->name2 == EGO_ATTACKS)
                                {
                                        o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
@@ -4364,10 +4482,16 @@ void apply_magic(object_type *o_ptr, int lev, u32b mode)
                                        o_ptr->pval = randint1(e_ptr->max_pval);
                                        if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
                                }
+                               else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
+                               {
+                                       o_ptr->pval = randint1(e_ptr->max_pval);
+                               }
                                else
                                {
                                        o_ptr->pval += randint1(e_ptr->max_pval);
                                }
+                               
+                               
                        }
                        if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
                        {
@@ -4379,7 +4503,7 @@ void apply_magic(object_type *o_ptr, int lev, u32b mode)
 
                /* Cheat -- describe the item */
                if (cheat_peek) object_mention(o_ptr);
-
+               
                /* Done */
                return;
        }
@@ -5194,6 +5318,127 @@ void acquirement(int y1, int x1, int num, bool great, bool known)
 }
 
 
+/*
+ * Scatter some "amusing" objects near the player
+ */
+
+#define AMS_NOTHING   0x00 /* No restriction */
+#define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
+#define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
+#define AMS_MULTIPLE  0x04 /* Drop 1-3 objects for one type */
+#define AMS_PILE      0x08 /* Drop 1-99 pile objects for one type */
+
+typedef struct
+{
+       int tval;
+       int sval;
+       int prob;
+       byte flag;
+} amuse_type;
+
+amuse_type amuse_info[] =
+{
+       { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
+       { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
+       { TV_SPIKE, SV_ANY, 10, AMS_PILE },
+       { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
+       { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
+       { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
+       { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
+       { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
+       { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
+       { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
+       { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
+       { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
+       { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
+
+       { 0, 0, 0 }
+};
+
+void amusement(int y1, int x1, int num, bool known)
+{
+       object_type *i_ptr;
+       object_type object_type_body;
+       int n, t = 0;
+
+       for (n = 0; amuse_info[n].tval != 0; n++)
+       {
+               t += amuse_info[n].prob;
+       }
+
+       /* Acquirement */
+       while (num)
+       {
+               int i, k_idx, a_idx = 0;
+               int r = randint0(t);
+               bool insta_art, fixed_art;
+
+               for (i = 0; ; i++)
+               {
+                       r -= amuse_info[i].prob;
+                       if (r <= 0) break;
+               }
+
+               /* Get local object */
+               i_ptr = &object_type_body;
+
+               /* Wipe the object */
+               object_wipe(i_ptr);
+
+               /* Wipe the object */
+               k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
+
+               /* Paranoia - reroll if nothing */
+               if (!k_idx) continue;
+
+               /* Search an artifact index if need */
+               insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
+               fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
+
+               if (insta_art || fixed_art)
+               {
+                       for (a_idx = 1; a_idx < max_a_idx; a_idx++)
+                       {
+                               if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
+                               if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
+                               if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
+                               if (a_info[a_idx].cur_num > 0) continue;
+                               break;
+                       }
+
+                       if (a_idx >= max_a_idx) continue;
+               }
+
+               /* Make an object (if possible) */
+               object_prep(i_ptr, k_idx);
+               if (a_idx) i_ptr->name1 = a_idx;
+               apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
+
+               if (amuse_info[i].flag & AMS_NO_UNIQUE)
+               {
+                       if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
+               }
+
+               if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
+               if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
+
+               if (known)
+               {
+                       object_aware(i_ptr);
+                       object_known(i_ptr);
+               }
+
+               /* Paranoia - reroll if nothing */
+               if (!(i_ptr->k_idx)) continue;
+
+               /* Drop the object */
+               (void)drop_near(i_ptr, -1, y1, x1);
+
+               num--;
+       }
+}
+
+
 #define MAX_NORMAL_TRAPS 18
 
 /* See init_feat_variables() in init2.c */
@@ -6756,7 +7001,7 @@ bool process_warning(int xx, int yy)
                        else strcpy(o_name, "body"); /* Warning ability without item */
                        msg_format("Your %s pulsates sharply!", o_name);
 #endif
-                       disturb(0, 0);
+                       disturb(0, 1);
 #ifdef JP
                        return get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©");
 #else
@@ -6780,7 +7025,7 @@ bool process_warning(int xx, int yy)
                else strcpy(o_name, "body"); /* Warning ability without item */
                msg_format("Your %s pulsates!", o_name);
 #endif
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
                return get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©");
 #else
@@ -7372,6 +7617,8 @@ static void drain_essence(void)
        if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
        if (have_flag(old_flgs, TR_NO_TELE)) dec--;
        if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
+       if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
+       if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
        if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
 
        iy = o_ptr->iy;
@@ -7487,19 +7734,12 @@ static void drain_essence(void)
        }
        if (!observe)
        {
-#ifdef JP
-               msg_print("¥¨¥Ã¥»¥ó¥¹¤ÏÃê½Ð¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£");
-#else
-               msg_print("You were not able to extract any essence.");
-#endif
+               msg_print(_("¥¨¥Ã¥»¥ó¥¹¤ÏÃê½Ð¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", "You were not able to extract any essence."));
        }
        else
        {
-#ifdef JP
-               msg_print("Ãê½Ð¤·¤¿¥¨¥Ã¥»¥ó¥¹:");
-#else
-               msg_print("Extracted essences:");
-#endif
+               msg_print(_("Ãê½Ð¤·¤¿¥¨¥Ã¥»¥ó¥¹:", "Extracted essences:"));
+
                for (i = 0; essence_name[i]; i++)
                {
                        if (!essence_name[i][0]) continue;
@@ -7508,10 +7748,13 @@ static void drain_essence(void)
                        p_ptr->magic_num1[i] += drain_value[i];
                        p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
                        msg_print(NULL);
-                       msg_format("%s...%d", essence_name[i], drain_value[i]);
+                       msg_format("%s...%d%s", essence_name[i], drain_value[i], _("¡£", ". "));
                }
        }
 
+       /* Apply autodestroy/inscription to the drained item */
+       autopick_alter_item(item, TRUE);
+
        /* Combine the pack */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
 
@@ -8500,3 +8743,41 @@ void do_cmd_kaji(bool only_browse)
                case 5: add_essence(10);break;
        }
 }
+
+
+/*
+ * Torches have special abilities when they are flaming.
+ */
+void torch_flags(object_type *o_ptr, u32b *flgs)
+{
+       if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
+       {
+               if (o_ptr->xtra4 > 0)
+               {
+                       add_flag(flgs, TR_BRAND_FIRE);
+                       add_flag(flgs, TR_KILL_UNDEAD);
+                       add_flag(flgs, TR_THROW);
+               }
+       }
+}
+
+void torch_dice(object_type *o_ptr, int *dd, int *ds)
+{
+       if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
+       {
+               if (o_ptr->xtra4 > 0)
+               {
+                       (*dd) = 1;
+                       (*ds) = 6;
+               }
+       }
+}
+
+void torch_lost_fuel(object_type *o_ptr)
+{
+       if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
+       {
+               o_ptr->xtra4 -= (FUEL_TORCH / 25);
+               if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;
+       }
+}