예제 #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;
                    }
                }
            }
        }
예제 #2
0
        public Player()
        {
            instance = this;
            bool keep_randarts = false;

            inventory = null;

            /* Preserve p_ptr.randarts so that players can use loaded randarts even
             * if they create a completely different character */
            if (randarts)
            {
                keep_randarts = true;
            }

            /* Wipe the player */
            //(void)WIPE(p, struct player); //Already have a clean slate

            randarts = keep_randarts;

            //Enable below else later

            /* Start with no artifacts made yet */
            for (int i = 0; Misc.z_info != null && i < Misc.z_info.a_max; i++)
            {
                Artifact a_ptr = Misc.a_info[i];
                if (a_ptr == null)
                {
                    continue;
                }
                a_ptr.created = false;
                a_ptr.seen    = false;
            }


            /* Start with no quests */
            for (int i = 0; Misc.q_list != null && i < Misc.MAX_Q_IDX; i++)
            {
                if (Misc.q_list[i] == null)
                {
                    Misc.q_list[i] = new Quest();
                }
                Misc.q_list[i].level = 0;
            }

            if (Misc.q_list != null)
            {
                Misc.q_list[0].level = 99;
                Misc.q_list[1].level = 100;
            }

            for (int i = 1; Misc.z_info != null && i < Misc.z_info.k_max; i++)
            {
                Object.Object_Kind k_ptr = Misc.k_info[i];
                if (k_ptr == null)
                {
                    continue;
                }
                k_ptr.tried = false;
                k_ptr.aware = false;
            }

            for (int i = 1; Misc.z_info != null && i < Misc.z_info.r_max; i++)
            {
                Monster_Race r_ptr = Misc.r_info[i];
                Monster_Lore l_ptr = Misc.l_list[i];
                if (r_ptr == null || l_ptr == null)
                {
                    continue;
                }
                r_ptr.cur_num = 0;
                r_ptr.max_num = 100;
                if (r_ptr.flags.has(Monster_Flag.UNIQUE.value))
                {
                    r_ptr.max_num = 1;
                }
                l_ptr.pkills = 0;
            }


            /* Hack -- no ghosts */
            if (Misc.z_info != null && Misc.r_info[Misc.z_info.r_max - 1] != null)
            {
                Misc.r_info[Misc.z_info.r_max - 1].max_num = 0;
            }


            /* Always start with a well fed player (this is surely in the wrong fn) */
            food = Misc.PY_FOOD_FULL - 1;


            /* None of the spells have been learned yet */
            for (int i = 0; i < Misc.PY_MAX_SPELLS; i++)
            {
                spell_order[i] = 99;
            }

            inventory = new Object.Object[Misc.ALL_INVEN_TOTAL];
            for (int i = 0; i < Misc.ALL_INVEN_TOTAL; i++)
            {
                inventory[i] = new Object.Object();
            }

            /* First turn. */
            Misc.turn    = 1;
            total_energy = 0;
            resting_turn = 0;
            /* XXX default race/class */
            Race  = Misc.races;
            Class = Misc.classes;
        }
예제 #3
0
        public static void wr_monster_memory()
        {
            int i;
            int r_idx;

            wr_u16b(Misc.z_info.r_max);
            for (r_idx = 0; r_idx < Misc.z_info.r_max; r_idx++)
            {
                Monster_Race r_ptr = Misc.r_info[r_idx];
                Monster_Lore l_ptr = Misc.l_list[r_idx];

                if (r_ptr == null)
                {
                    r_ptr = new Monster_Race();
                }

                if (l_ptr == null)
                {
                    l_ptr = new Monster_Lore();
                }

                /* Count sights/deaths/kills */
                wr_s16b(l_ptr.sights);
                wr_s16b(l_ptr.deaths);
                wr_s16b(l_ptr.pkills);
                wr_s16b(l_ptr.tkills);

                /* Count wakes and ignores */
                wr_byte(l_ptr.wake);
                wr_byte(l_ptr.ignore);

                /* Count drops */
                wr_byte(l_ptr.drop_gold);
                wr_byte(l_ptr.drop_item);

                /* Count spells */
                wr_byte(l_ptr.cast_innate);
                wr_byte(l_ptr.cast_spell);

                /* Count blows of each type */
                for (i = 0; i < Monster_Blow.MONSTER_BLOW_MAX; i++)
                {
                    wr_byte(l_ptr.blows[i]);
                }

                /* Memorize flags */
                for (i = 0; i < Monster_Flag.BYTES && i < Monster_Flag.SIZE; i++)
                {
                    wr_byte(l_ptr.flags.data[i]);
                }
                if (i < Monster_Flag.BYTES)
                {
                    Savefile.pad_bytes(Monster_Flag.BYTES - i);
                }

                for (i = 0; i < Monster_Flag.BYTES && i < Monster_Spell_Flag.SIZE; i++)
                {
                    wr_byte(l_ptr.spell_flags[i]);
                }
                if (i < Monster_Flag.BYTES)
                {
                    Savefile.pad_bytes(Monster_Flag.BYTES - i);
                }

                /* Monster limit per level */
                wr_byte(r_ptr.max_num);

                /* XXX */
                wr_byte(0);
                wr_byte(0);
                wr_byte(0);
            }
        }