Exemplo n.º 1
0
        /**
         * Extract the multiplier from a given object hitting a given monster.
         *
         * \param o_ptr is the object being used to attack
         * \param m_ptr is the monster being attacked
         * \param best_s_ptr is the best applicable slay_table entry, or null if no
         *  slay already known
         * \param real is whether this is a real attack (where we update lore) or a
         *  simulation (where we don't)
         * \param known_only is whether we are using all the object flags, or only
         * the ones we *already* know about
         */
        //Best_s_ptr was slay**
        public static void improve_attack_modifier(Object o_ptr, Monster.Monster m_ptr,
                                                   ref Slay best_s_ptr, bool real, bool known_only)
        {
            Monster_Race r_ptr   = Misc.r_info[m_ptr.r_idx];
            Monster_Lore l_ptr   = Misc.l_list[m_ptr.r_idx];
            Bitflag      f       = new Bitflag(Object_Flag.SIZE);
            Bitflag      known_f = new Bitflag(Object_Flag.SIZE);
            Bitflag      note_f  = new Bitflag(Object_Flag.SIZE);
            int          i;

            o_ptr.object_flags(ref f);
            o_ptr.object_flags_known(ref known_f);

            for (i = 0; i < Slay.MAX.value; i++)
            {
                Slay s_ptr = list[i];
                if ((known_only && !known_f.has(s_ptr.object_flag.value)) || (!known_only && !f.has(s_ptr.object_flag.value)))
                {
                    continue;
                }

                /* In a real attack, learn about monster resistance or slay match if:
                 * EITHER the slay flag on the object is known,
                 * OR the monster is vulnerable to the slay/brand
                 */
                if (real && (known_f.has(s_ptr.object_flag.value) || (s_ptr.monster_flag != Monster_Flag.NONE &&
                                                                      r_ptr.flags.has(s_ptr.monster_flag.value)) ||
                             (s_ptr.resist_flag != Monster_Flag.NONE && !r_ptr.flags.has(s_ptr.resist_flag.value))))
                {
                    /* notice any brand or slay that would affect monster */
                    note_f.wipe();
                    note_f.on(s_ptr.object_flag.value);
                    object_notice_slays(o_ptr, note_f);

                    if (m_ptr.ml && s_ptr.monster_flag != Monster_Flag.NONE)
                    {
                        l_ptr.flags.on(s_ptr.monster_flag.value);
                    }

                    if (m_ptr.ml && s_ptr.resist_flag != Monster_Flag.NONE)
                    {
                        l_ptr.flags.on(s_ptr.resist_flag.value);
                    }
                }

                /* If the monster doesn't resist or the slay flag matches */
                if ((s_ptr.brand != null && s_ptr.brand.Length != 0 &&
                     !r_ptr.flags.has(s_ptr.resist_flag.value)) ||
                    (s_ptr.monster_flag != Monster_Flag.NONE &&
                     r_ptr.flags.has(s_ptr.monster_flag.value)))
                {
                    /* compare multipliers to determine best attack */
                    if ((best_s_ptr == null) || ((best_s_ptr).mult < s_ptr.mult))
                    {
                        best_s_ptr = s_ptr;
                    }
                }
            }
        }
Exemplo n.º 2
0
        static int obj_desc_inscrip(Object o_ptr, ref string buf, int max, int end)
        {
            string[] u = { "", "", "", "" };
            int      n = 0;

            Object.obj_pseudo_t feel        = o_ptr.pseudo();
            Bitflag             flags_known = new Bitflag(Object_Flag.SIZE);
            Bitflag             f2          = new Bitflag(Object_Flag.SIZE);

            o_ptr.object_flags_known(ref flags_known);

            /* Get inscription */
            if (o_ptr.note != null && o_ptr.note.value != null)
            {
                u[n++] = o_ptr.note.ToString();
            }

            /* Use special inscription, if any */
            if (!o_ptr.is_known() && feel != 0)
            {
                /* cannot tell excellent vs strange vs splendid until wield */
                if (!o_ptr.was_worn() && o_ptr.ego != null)
                {
                    u[n++] = "ego";
                }
                else
                {
                    u[n++] = Misc.inscrip_text[(int)feel];             //I know that feel bro.
                }
            }
            else if (((o_ptr.ident & Object.IDENT_EMPTY) != 0) && !o_ptr.is_known())
            {
                u[n++] = "empty";
            }
            else if (!o_ptr.is_known() && o_ptr.was_worn())
            {
                if (o_ptr.wield_slot() == Misc.INVEN_WIELD || o_ptr.wield_slot() == Misc.INVEN_BOW)
                {
                    u[n++] = "wielded";
                }
                else
                {
                    u[n++] = "worn";
                }
            }
            else if (!o_ptr.is_known() && o_ptr.was_fired())
            {
                u[n++] = "fired";
            }
            else if (!o_ptr.flavor_is_aware() && o_ptr.flavor_was_tried())
            {
                u[n++] = "tried";
            }

            /* Note curses */
            Object_Flag.create_mask(f2, false, Object_Flag.object_flag_type.CURSE);
            if (flags_known.is_inter(f2))
            {
                u[n++] = "cursed";
            }

            /* Note squelch */
            if (Squelch.item_ok(o_ptr))
            {
                u[n++] = "squelch";
            }

            if (n != 0)
            {
                int i;
                for (i = 0; i < n; i++)
                {
                    if (i == 0)
                    {
                        buf = buf + " {";
                    }
                    buf = buf + u[i];
                    if (i < n - 1)
                    {
                        buf += ", ";
                    }
                }

                buf += "}";
            }

            return(end);
        }
Exemplo n.º 3
0
        static int obj_desc_combat(Object o_ptr, ref string buf, int max, int end, bool spoil)
        {
            Bitflag flags       = new Bitflag(Object_Flag.SIZE);
            Bitflag flags_known = new Bitflag(Object_Flag.SIZE);

            o_ptr.object_flags(ref flags);
            o_ptr.object_flags_known(ref flags_known);

            if (flags.has(Object_Flag.SHOW_DICE.value))
            {
                /* Only display the real damage dice if the combat stats are known */
                if (spoil || o_ptr.attack_plusses_are_visible())
                {
                    buf = buf + " (" + o_ptr.dd + "d" + o_ptr.ds + ")";
                }
                else
                {
                    buf = buf + " (" + o_ptr.kind.dd + "d" + o_ptr.kind.ds + ")";
                }
            }

            if (flags.has(Object_Flag.SHOW_MULT.value))
            {
                /* Display shooting power as part of the multiplier */
                if (flags.has(Object_Flag.MIGHT.value) && (spoil || o_ptr.object_flag_is_known(Object_Flag.MIGHT.value)))
                {
                    buf = buf + " (x" + (o_ptr.sval % 10) + o_ptr.pval[o_ptr.which_pval(Object_Flag.MIGHT.value)] + ")";
                }
                else
                {
                    buf = buf + " (x" + o_ptr.sval % 10 + ")";
                }
            }

            /* Show weapon bonuses */
            if (spoil || o_ptr.attack_plusses_are_visible())
            {
                if (flags.has(Object_Flag.SHOW_MODS.value) || o_ptr.to_d != 0 || o_ptr.to_h != 0)
                {
                    /* Make an exception for body armor with only a to-hit penalty */
                    if (o_ptr.to_h < 0 && o_ptr.to_d == 0 &&
                        (o_ptr.tval == TVal.TV_SOFT_ARMOR ||
                         o_ptr.tval == TVal.TV_HARD_ARMOR ||
                         o_ptr.tval == TVal.TV_DRAG_ARMOR))
                    {
                        buf = buf + " (" + (o_ptr.to_h > 0 ? "+" : "-") + o_ptr.to_h + ")";
                    }

                    /* Otherwise, always use the full tuple */
                    else
                    {
                        buf = buf + " (" + (o_ptr.to_h > 0 ? "+" : "-") + o_ptr.to_h + "," +
                              (o_ptr.to_d > 0 ? "+" : "-") + o_ptr.to_d + ")";
                    }
                }
            }


            /* Show armor bonuses */
            if (spoil || o_ptr.defence_plusses_are_visible())
            {
                if (obj_desc_show_armor(o_ptr))
                {
                    buf = buf + " [" + o_ptr.ac + "," + (o_ptr.to_a > 0?"+":"-") + o_ptr.to_a + "]";
                }
                else if (o_ptr.to_a != 0)
                {
                    buf = buf + " [" + (o_ptr.to_a > 0?"+":"-") + o_ptr.to_a + "]";
                }
            }
            else if (obj_desc_show_armor(o_ptr))
            {
                buf = buf + " [" + (o_ptr.was_sensed() ? o_ptr.ac : o_ptr.kind.ac) + "]";
            }

            return(end);
        }
Exemplo n.º 4
0
        static int obj_desc_inscrip(Object o_ptr, ref string buf, int max, int end)
        {
            string[] u = {"", "", "", ""};
            int n = 0;
            Object.obj_pseudo_t feel = o_ptr.pseudo();
            Bitflag flags_known = new Bitflag(Object_Flag.SIZE);
            Bitflag f2 = new Bitflag(Object_Flag.SIZE);

            o_ptr.object_flags_known(ref flags_known);

            /* Get inscription */
            if (o_ptr.note != null && o_ptr.note.value != null)
                u[n++] = o_ptr.note.ToString();

            /* Use special inscription, if any */
            if (!o_ptr.is_known() && feel != 0)
            {
                /* cannot tell excellent vs strange vs splendid until wield */
                if (!o_ptr.was_worn() && o_ptr.ego != null)
                    u[n++] = "ego";
                else
                    u[n++] = Misc.inscrip_text[(int)feel]; //I know that feel bro.
            }
            else if (((o_ptr.ident & Object.IDENT_EMPTY) != 0) && !o_ptr.is_known())
                u[n++] = "empty";
            else if (!o_ptr.is_known() && o_ptr.was_worn())
            {
                if (o_ptr.wield_slot() == Misc.INVEN_WIELD || o_ptr.wield_slot() == Misc.INVEN_BOW)
                    u[n++] = "wielded";
                else u[n++] = "worn";
            }
            else if (!o_ptr.is_known() && o_ptr.was_fired())
                u[n++] = "fired";
            else if (!o_ptr.flavor_is_aware() && o_ptr.flavor_was_tried())
                u[n++] = "tried";

            /* Note curses */
            Object_Flag.create_mask(f2, false, Object_Flag.object_flag_type.CURSE);
            if (flags_known.is_inter(f2))
                u[n++] = "cursed";

            /* Note squelch */
            if (Squelch.item_ok(o_ptr))
                u[n++] = "squelch";

            if (n != 0)
            {
                int i;
                for (i = 0; i < n; i++)
                {
                    if(i == 0)
                        buf = buf + " {";
                    buf = buf + u[i];
                    if (i < n-1)
                        buf += ", ";
                }

                buf += "}";
            }

            return end;
        }
Exemplo n.º 5
0
        /*
         * Determine the squelch level of an object, which is similar to its pseudo.
         *
         * The main point is when the value is undetermined given current info,
         * return the maximum possible value.
         */
        public static quality_squelch squelch_level_of(Object.Object o_ptr)
        {
            quality_squelch value = quality_squelch.SQUELCH_NONE;
            Bitflag         f     = new Bitflag(Object_Flag.SIZE);
            Bitflag         f2    = new Bitflag(Object_Flag.SIZE);
            int             i;

            o_ptr.object_flags_known(ref f);

            /* Deal with jewelry specially. */
            if (o_ptr.is_jewelry())
            {
                /* CC: average jewelry has at least one known positive pval */
                for (i = 0; i < o_ptr.num_pvals; i++)
                {
                    if ((o_ptr.this_pval_is_visible(i)) && (o_ptr.pval[i] > 0))
                    {
                        return(quality_squelch.SQUELCH_AVERAGE);
                    }
                }

                if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0))
                {
                    return(quality_squelch.SQUELCH_AVERAGE);
                }
                if ((o_ptr.attack_plusses_are_visible() &&
                     ((o_ptr.to_h < 0) || (o_ptr.to_d < 0))) ||
                    (o_ptr.defence_plusses_are_visible() && o_ptr.to_a < 0))
                {
                    return(quality_squelch.SQUELCH_BAD);
                }

                return(quality_squelch.SQUELCH_AVERAGE);
            }

            /* And lights */
            if (o_ptr.tval == TVal.TV_LIGHT)
            {
                Object_Flag.create_mask(f2, true, Object_Flag.object_flag_id.WIELD);
                if (f.is_inter(f2))
                {
                    return(quality_squelch.SQUELCH_ALL);
                }
                if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0))
                {
                    return(quality_squelch.SQUELCH_GOOD);
                }
                if ((o_ptr.to_h < 0) || (o_ptr.to_d < 0) || (o_ptr.to_a < 0))
                {
                    return(quality_squelch.SQUELCH_BAD);
                }

                return(quality_squelch.SQUELCH_AVERAGE);
            }

            /* CC: we need to redefine "bad" with multiple pvals
             * At the moment we use "all pvals known and negative" */
            for (i = 0; i < o_ptr.num_pvals; i++)
            {
                if (!o_ptr.this_pval_is_visible(i) ||
                    (o_ptr.pval[i] > 0))
                {
                    break;
                }

                if (i == (o_ptr.num_pvals - 1))
                {
                    return(quality_squelch.SQUELCH_BAD);
                }
            }

            if (o_ptr.was_sensed())
            {
                Object.Object.obj_pseudo_t pseudo = o_ptr.pseudo();

                switch (pseudo)
                {
                case Object.Object.obj_pseudo_t.INSCRIP_AVERAGE: {
                    value = quality_squelch.SQUELCH_AVERAGE;
                    break;
                }

                case Object.Object.obj_pseudo_t.INSCRIP_EXCELLENT: {
                    /* have to assume splendid until you have tested it */
                    if (o_ptr.was_worn())
                    {
                        if (o_ptr.high_resist_is_possible())
                        {
                            value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL;
                        }
                        else
                        {
                            value = quality_squelch.SQUELCH_EXCELLENT_NO_HI;
                        }
                    }
                    else
                    {
                        value = quality_squelch.SQUELCH_ALL;
                    }
                    break;
                }

                case Object.Object.obj_pseudo_t.INSCRIP_SPLENDID:
                    value = quality_squelch.SQUELCH_ALL;
                    break;

                case Object.Object.obj_pseudo_t.INSCRIP_null:
                case Object.Object.obj_pseudo_t.INSCRIP_SPECIAL:
                    value = quality_squelch.SQUELCH_MAX;
                    break;

                /* This is the interesting case */
                case Object.Object.obj_pseudo_t.INSCRIP_STRANGE:
                case Object.Object.obj_pseudo_t.INSCRIP_MAGICAL: {
                    value = quality_squelch.SQUELCH_GOOD;

                    if ((o_ptr.attack_plusses_are_visible() ||
                         Random.randcalc_valid(o_ptr.kind.to_h, o_ptr.to_h) ||
                         Random.randcalc_valid(o_ptr.kind.to_d, o_ptr.to_d)) &&
                        (o_ptr.defence_plusses_are_visible() ||
                         Random.randcalc_valid(o_ptr.kind.to_a, o_ptr.to_a)))
                    {
                        int isgood = is_object_good(o_ptr);
                        if (isgood > 0)
                        {
                            value = quality_squelch.SQUELCH_GOOD;
                        }
                        else if (isgood < 0)
                        {
                            value = quality_squelch.SQUELCH_BAD;
                        }
                        else
                        {
                            value = quality_squelch.SQUELCH_AVERAGE;
                        }
                    }
                    break;
                }

                default:
                    /* do not handle any other possible pseudo values */
                    Misc.assert(false);
                    break;
                }
            }
            else
            {
                if (o_ptr.was_worn())
                {
                    value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL;             /* object would be sensed if it were splendid */
                }
                else if (o_ptr.is_known_not_artifact())
                {
                    value = quality_squelch.SQUELCH_ALL;
                }
                else
                {
                    value = quality_squelch.SQUELCH_MAX;
                }
            }

            return(value);
        }
Exemplo n.º 6
0
        static int obj_desc_combat(Object o_ptr, ref string buf, int max, int end, bool spoil)
        {
            Bitflag flags = new Bitflag(Object_Flag.SIZE);
            Bitflag flags_known = new Bitflag(Object_Flag.SIZE);

            o_ptr.object_flags(ref flags);
            o_ptr.object_flags_known(ref flags_known);

            if (flags.has(Object_Flag.SHOW_DICE.value))
            {
                /* Only display the real damage dice if the combat stats are known */
                if(spoil || o_ptr.attack_plusses_are_visible())
                    buf = buf + " (" + o_ptr.dd + "d" + o_ptr.ds + ")";
                else
                    buf = buf + " (" + o_ptr.kind.dd + "d" + o_ptr.kind.ds + ")";
            }

            if (flags.has(Object_Flag.SHOW_MULT.value))
            {
                /* Display shooting power as part of the multiplier */
                if (flags.has(Object_Flag.MIGHT.value) && (spoil || o_ptr.object_flag_is_known(Object_Flag.MIGHT.value)))
                    buf = buf + " (x" + (o_ptr.sval % 10) + o_ptr.pval[o_ptr.which_pval(Object_Flag.MIGHT.value)] + ")";
                else
                    buf = buf + " (x" + o_ptr.sval % 10 + ")";
            }

            /* Show weapon bonuses */
            if (spoil || o_ptr.attack_plusses_are_visible())
            {
                if (flags.has(Object_Flag.SHOW_MODS.value) || o_ptr.to_d != 0 || o_ptr.to_h != 0)
                {
                    /* Make an exception for body armor with only a to-hit penalty */
                    if(o_ptr.to_h < 0 && o_ptr.to_d == 0 &&
                        (o_ptr.tval == TVal.TV_SOFT_ARMOR ||
                         o_ptr.tval == TVal.TV_HARD_ARMOR ||
                         o_ptr.tval == TVal.TV_DRAG_ARMOR))
                        buf = buf + " (" + (o_ptr.to_h > 0 ? "+" : "-") + o_ptr.to_h + ")";

                    /* Otherwise, always use the full tuple */
                    else
                        buf = buf + " (" + (o_ptr.to_h > 0 ? "+" : "-") + o_ptr.to_h + "," +
                            (o_ptr.to_d > 0 ? "+" : "-") + o_ptr.to_d + ")";
                }
            }

            /* Show armor bonuses */
            if (spoil || o_ptr.defence_plusses_are_visible())
            {
                if (obj_desc_show_armor(o_ptr))
                    buf = buf + " [" + o_ptr.ac + "," + (o_ptr.to_a > 0?"+":"-") + o_ptr.to_a + "]";
                else if (o_ptr.to_a != 0)
                    buf = buf + " [" + (o_ptr.to_a > 0?"+":"-") + o_ptr.to_a + "]";
            }
            else if (obj_desc_show_armor(o_ptr))
            {
                buf = buf + " [" + (o_ptr.was_sensed() ? o_ptr.ac : o_ptr.kind.ac) + "]";
            }

            return end;
        }
Exemplo n.º 7
0
        /*
         * Determine the squelch level of an object, which is similar to its pseudo.
         *
         * The main point is when the value is undetermined given current info,
         * return the maximum possible value.
         */
        public static quality_squelch squelch_level_of(Object.Object o_ptr)
        {
            quality_squelch value = quality_squelch.SQUELCH_NONE;
            Bitflag f = new Bitflag(Object_Flag.SIZE);
            Bitflag f2 = new Bitflag(Object_Flag.SIZE);
            int i;

            o_ptr.object_flags_known(ref f);

            /* Deal with jewelry specially. */
            if (o_ptr.is_jewelry())
            {
                /* CC: average jewelry has at least one known positive pval */
                for (i = 0; i < o_ptr.num_pvals; i++)
                    if ((o_ptr.this_pval_is_visible(i)) && (o_ptr.pval[i] > 0))
                        return quality_squelch.SQUELCH_AVERAGE;

                if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0))
                    return quality_squelch.SQUELCH_AVERAGE;
                if ((o_ptr.attack_plusses_are_visible() &&
                        ((o_ptr.to_h < 0) || (o_ptr.to_d < 0))) ||
                        (o_ptr.defence_plusses_are_visible() && o_ptr.to_a < 0))
                    return quality_squelch.SQUELCH_BAD;

                return quality_squelch.SQUELCH_AVERAGE;
            }

            /* And lights */
            if (o_ptr.tval == TVal.TV_LIGHT)
            {
                Object_Flag.create_mask(f2, true, Object_Flag.object_flag_id.WIELD);
                if (f.is_inter(f2))
                    return quality_squelch.SQUELCH_ALL;
                if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0))
                    return quality_squelch.SQUELCH_GOOD;
                if ((o_ptr.to_h < 0) || (o_ptr.to_d < 0) || (o_ptr.to_a < 0))
                    return quality_squelch.SQUELCH_BAD;

                return quality_squelch.SQUELCH_AVERAGE;
            }

            /* CC: we need to redefine "bad" with multiple pvals
             * At the moment we use "all pvals known and negative" */
            for (i = 0; i < o_ptr.num_pvals; i++) {
                if (!o_ptr.this_pval_is_visible(i) ||
                    (o_ptr.pval[i] > 0))
                    break;

                if (i == (o_ptr.num_pvals - 1))
                    return quality_squelch.SQUELCH_BAD;
            }

            if (o_ptr.was_sensed()) {
                Object.Object.obj_pseudo_t pseudo = o_ptr.pseudo();

                switch (pseudo) {
                    case Object.Object.obj_pseudo_t.INSCRIP_AVERAGE: {
                        value = quality_squelch.SQUELCH_AVERAGE;
                        break;
                    }

                    case Object.Object.obj_pseudo_t.INSCRIP_EXCELLENT: {
                        /* have to assume splendid until you have tested it */
                        if (o_ptr.was_worn()) {
                            if (o_ptr.high_resist_is_possible())
                                value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL;
                            else
                                value = quality_squelch.SQUELCH_EXCELLENT_NO_HI;
                        } else {
                            value = quality_squelch.SQUELCH_ALL;
                        }
                        break;
                    }

                    case Object.Object.obj_pseudo_t.INSCRIP_SPLENDID:
                        value = quality_squelch.SQUELCH_ALL;
                        break;
                    case Object.Object.obj_pseudo_t.INSCRIP_null:
                    case Object.Object.obj_pseudo_t.INSCRIP_SPECIAL:
                        value = quality_squelch.SQUELCH_MAX;
                        break;

                    /* This is the interesting case */
                    case Object.Object.obj_pseudo_t.INSCRIP_STRANGE:
                    case Object.Object.obj_pseudo_t.INSCRIP_MAGICAL: {
                        value = quality_squelch.SQUELCH_GOOD;

                        if ((o_ptr.attack_plusses_are_visible() ||
                                Random.randcalc_valid(o_ptr.kind.to_h, o_ptr.to_h) ||
                                Random.randcalc_valid(o_ptr.kind.to_d, o_ptr.to_d)) &&
                                (o_ptr.defence_plusses_are_visible() ||
                                Random.randcalc_valid(o_ptr.kind.to_a, o_ptr.to_a))) {
                            int isgood = is_object_good(o_ptr);
                            if (isgood > 0) {
                                value = quality_squelch.SQUELCH_GOOD;
                            } else if (isgood < 0) {
                                value = quality_squelch.SQUELCH_BAD;
                            } else {
                                value = quality_squelch.SQUELCH_AVERAGE;
                            }
                        }
                        break;
                    }

                    default:
                        /* do not handle any other possible pseudo values */
                        Misc.assert(false);
                        break;
                }
            }
            else
            {
                if (o_ptr.was_worn())
                    value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL; /* object would be sensed if it were splendid */
                else if (o_ptr.is_known_not_artifact())
                    value = quality_squelch.SQUELCH_ALL;
                else
                    value = quality_squelch.SQUELCH_MAX;
            }

            return value;
        }
Exemplo n.º 8
0
        /*
         * Special display, part 2c
         *
         * How to print out the modifications and sustains.
         * Positive mods with no sustain will be light green.
         * Positive mods with a sustain will be dark green.
         * Sustains (with no modification) will be a dark green 's'.
         * Negative mods (from a curse) will be red.
         * Huge mods (>9), like from MICoMorgoth, will be a '*'
         * No mod, no sustain, will be a slate '.'
         */
        static void display_player_sust_info()
        {
            int j, stat;

            Player.Player p_ptr = Player.Player.instance;

            Bitflag f = new Bitflag(Object_Flag.SIZE);

            Object_Flag[] stat_flags    = new Object_Flag[(int)Stat.Max];
            Object_Flag[] sustain_flags = new Object_Flag[(int)Stat.Max];

            ConsoleColor a;
            char         c;


            /* Row */
            int row = 2;

            /* Column */
            int col = 26;

            /* Build the stat flags tables */
            stat_flags[(int)Stat.Str]    = Object_Flag.STR;
            stat_flags[(int)Stat.Int]    = Object_Flag.INT;
            stat_flags[(int)Stat.Wis]    = Object_Flag.WIS;
            stat_flags[(int)Stat.Dex]    = Object_Flag.DEX;
            stat_flags[(int)Stat.Con]    = Object_Flag.CON;
            stat_flags[(int)Stat.Chr]    = Object_Flag.CHR;
            sustain_flags[(int)Stat.Str] = Object_Flag.SUST_STR;
            sustain_flags[(int)Stat.Int] = Object_Flag.SUST_INT;
            sustain_flags[(int)Stat.Wis] = Object_Flag.SUST_WIS;
            sustain_flags[(int)Stat.Dex] = Object_Flag.SUST_DEX;
            sustain_flags[(int)Stat.Con] = Object_Flag.SUST_CON;
            sustain_flags[(int)Stat.Chr] = Object_Flag.SUST_CHR;

            /* Header */
            Utilities.c_put_str(ConsoleColor.White, "abcdefghijkl@", row - 1, col);

            /* Process equipment */
            for (int i = Misc.INVEN_WIELD; i < Misc.INVEN_TOTAL; ++i)
            {
                /* Get the object */
                Object.Object o_ptr = p_ptr.inventory[i];

                if (o_ptr.kind == null)
                {
                    col++;
                    continue;
                }

                /* Get the "known" flags */
                o_ptr.object_flags_known(ref f);

                /* Initialize color based of sign of pval. */
                for (stat = 0; stat < (int)Stat.Max; stat++)
                {
                    /* Default */
                    a = ConsoleColor.Gray;
                    c = '.';

                    /* Boost */
                    if (f.has(stat_flags[stat].value))
                    {
                        /* Default */
                        c = '*';

                        /* Work out which pval we're talking about */
                        j = o_ptr.which_pval(stat_flags[stat].value);

                        /* Good */
                        if (o_ptr.pval[j] > 0)
                        {
                            /* Good */
                            a = ConsoleColor.Green;

                            /* Label boost */
                            if (o_ptr.pval[j] < 10)
                            {
                                c = (char)Basic.I2D((char)o_ptr.pval[j]);
                            }
                        }

                        /* Bad */
                        if (o_ptr.pval[j] < 0)
                        {
                            /* Bad */
                            a = ConsoleColor.Red;

                            /* Label boost */
                            if (o_ptr.pval[j] > -10)
                            {
                                c = (char)Basic.I2D((char)-(o_ptr.pval[j]));
                            }
                        }
                    }

                    /* Sustain */
                    if (f.has(sustain_flags[stat].value))
                    {
                        /* Dark green */
                        a = ConsoleColor.DarkGreen;

                        /* Convert '.' to 's' */
                        if (c == '.')
                        {
                            c = 's';
                        }
                    }

                    if ((c == '.') && o_ptr.kind != null && !o_ptr.object_flag_is_known(sustain_flags[stat].value))
                    {
                        c = '?';
                    }

                    /* Dump proper character */
                    Term.putch(col, row + stat, a, c);
                }

                /* Advance */
                col++;
            }

            /* Player flags */
            Player.Player.player_flags(ref f);

            /* Check stats */
            for (stat = 0; stat < (int)Stat.Max; ++stat)
            {
                /* Default */
                a = ConsoleColor.Gray;
                c = '.';

                /* Sustain */
                if (f.has(sustain_flags[stat].value))
                {
                    /* Dark green "s" */
                    a = ConsoleColor.DarkGreen;
                    c = 's';
                }

                /* Dump */
                Term.putch(col, row + stat, a, c);
            }

            /* Column */
            col = 26;

            /* Footer */
            Utilities.c_put_str(ConsoleColor.White, "abcdefghijkl@", row + 6, col);

            /* Equippy */
            display_player_equippy(row + 7, col);
        }
Exemplo n.º 9
0
        static void display_resistance_panel(player_flag_record[] resists, int size, Region bounds)
        {
            Player.Player p_ptr = Player.Player.instance;
            int           col   = bounds.col;
            int           row   = bounds.row;

            Term.putstr(col, row++, RES_COLS, ConsoleColor.White, "      abcdefghijkl@");
            for (int i = 0; i < size - 3; i++, row++)
            {
                ConsoleColor name_attr = ConsoleColor.White;
                Term.gotoxy(col + 6, row);
                /* repeated extraction of flags is inefficient but more natural */
                for (int j = Misc.INVEN_WIELD; j <= Misc.INVEN_TOTAL; j++)
                {
                    Object.Object o_ptr = p_ptr.inventory[j];
                    Bitflag       f     = new Bitflag(Object_Flag.SIZE);

                    ConsoleColor[] alternatingcols = new ConsoleColor[] { ConsoleColor.Gray, ConsoleColor.DarkGray };
                    ConsoleColor   attr            = alternatingcols[j % 2];        /* alternating columns */
                    char           sym             = '.';

                    bool res, imm, vuln;

                    /* Wipe flagset */
                    f.wipe();

                    if (j < Misc.INVEN_TOTAL && o_ptr.kind != null)
                    {
                        o_ptr.object_flags_known(ref f);
                    }
                    else if (j == Misc.INVEN_TOTAL)
                    {
                        Player.Player.player_flags(ref f);

                        /* If the race has innate infravision/digging, force the corresponding flag
                         * here.  If we set it in player_flags(), then all callers of that
                         * function will think the infravision is caused by equipment. */
                        if (p_ptr.Race.infra > 0)
                        {
                            f.on(Object_Flag.INFRA.value);
                        }
                        if (p_ptr.Race.r_skills[(int)Skill.DIGGING] > 0)
                        {
                            f.on(Object_Flag.TUNNEL.value);
                        }
                    }

                    res  = f.has(resists[i].res_flag.value);
                    imm  = f.has(resists[i].im_flag.value);
                    vuln = f.has(resists[i].vuln_flag.value);

                    if (imm)
                    {
                        name_attr = ConsoleColor.DarkGreen;
                    }
                    else if (res && name_attr == ConsoleColor.White)
                    {
                        name_attr = ConsoleColor.Cyan;
                    }

                    if (vuln)
                    {
                        sym = '-';
                    }
                    else if (imm)
                    {
                        sym = '*';
                    }
                    else if (res)
                    {
                        sym = '+';
                    }
                    else if ((j < Misc.INVEN_TOTAL) && o_ptr.kind != null &&
                             !o_ptr.object_flag_is_known(resists[i].res_flag.value))
                    {
                        sym = '?';
                    }
                    Term.addch(attr, sym);
                }
                Term.putstr(col, row, 6, name_attr, resists[i].name.ToString());
            }
            Term.putstr(col, row++, RES_COLS, ConsoleColor.White, "      abcdefghijkl@");
            /* Equippy */
            display_player_equippy(row++, col + 6);
        }
Exemplo n.º 10
0
        /**
         * Extract the multiplier from a given object hitting a given monster.
         *
         * \param o_ptr is the object being used to attack
         * \param m_ptr is the monster being attacked
         * \param best_s_ptr is the best applicable slay_table entry, or null if no
         *  slay already known
         * \param real is whether this is a real attack (where we update lore) or a
         *  simulation (where we don't)
         * \param known_only is whether we are using all the object flags, or only
         * the ones we *already* know about
         */
        //Best_s_ptr was slay**
        public static void improve_attack_modifier(Object o_ptr, Monster.Monster m_ptr, 
			ref Slay best_s_ptr, bool real, bool known_only)
        {
            Monster_Race r_ptr = Misc.r_info[m_ptr.r_idx];
            Monster_Lore l_ptr = Misc.l_list[m_ptr.r_idx];
            Bitflag f = new Bitflag(Object_Flag.SIZE);
            Bitflag known_f = new Bitflag(Object_Flag.SIZE);
            Bitflag note_f = new Bitflag(Object_Flag.SIZE);
            int i;

            o_ptr.object_flags(ref f);
            o_ptr.object_flags_known(ref known_f);

            for (i = 0; i < Slay.MAX.value; i++) {
                Slay s_ptr = list[i];
                if ((known_only && !known_f.has(s_ptr.object_flag.value)) || (!known_only && !f.has(s_ptr.object_flag.value)))
                    continue;

                /* In a real attack, learn about monster resistance or slay match if:
                 * EITHER the slay flag on the object is known,
                 * OR the monster is vulnerable to the slay/brand
                 */
                if (real && (known_f.has(s_ptr.object_flag.value) || (s_ptr.monster_flag != Monster_Flag.NONE
                        && r_ptr.flags.has(s_ptr.monster_flag.value)) ||
                        (s_ptr.resist_flag != Monster_Flag.NONE && !r_ptr.flags.has(s_ptr.resist_flag.value)))) {

                    /* notice any brand or slay that would affect monster */
                    note_f.wipe();
                    note_f.on(s_ptr.object_flag.value);
                    object_notice_slays(o_ptr, note_f);

                    if (m_ptr.ml && s_ptr.monster_flag != Monster_Flag.NONE)
                        l_ptr.flags.on(s_ptr.monster_flag.value);

                    if (m_ptr.ml && s_ptr.resist_flag != Monster_Flag.NONE)
                        l_ptr.flags.on(s_ptr.resist_flag.value);
                }

                /* If the monster doesn't resist or the slay flag matches */
                if ((s_ptr.brand != null && s_ptr.brand.Length != 0 &&
                        !r_ptr.flags.has(s_ptr.resist_flag.value)) ||
                        (s_ptr.monster_flag != Monster_Flag.NONE &&
                        r_ptr.flags.has(s_ptr.monster_flag.value))) {

                    /* compare multipliers to determine best attack */
                    if ((best_s_ptr == null) || ((best_s_ptr).mult < s_ptr.mult))
                        best_s_ptr = s_ptr;
                }
            }
        }