Ejemplo n.º 1
0
        /*
         * Stack a codified message for the given monster race. You must supply
         * the description of some monster of this race. You can also supply
         * different monster descriptions for the same race.
         * Return true on success.
         */
        public static bool add_monster_message(string mon_name, int m_idx, MON_MSG msg_code, bool delay)
        {
            int i;
            byte mon_flags = 0;

            Monster m_ptr = Cave.cave_monster(Cave.cave, m_idx);
            int r_idx = m_ptr.r_idx;

            if(redundant_monster_message(m_idx, msg_code))
                return (false);

            /* Paranoia */
            if(mon_name == null || mon_name.Length == 0)
                mon_name = "it";

            /* Save the "hidden" mark, if present */
            if(mon_name.Contains("(hidden)"))
                mon_flags |= 0x01;

            /* Save the "offscreen" mark, if present */
            if(mon_name.Contains("(offscreen)"))
                mon_flags |= 0x02;

            /* Monster is invisible or out of LOS */
            if((mon_name == "it") || mon_name == "something")
                mon_flags |= 0x04;

            /* Query if the message is already stored */
            for(i = 0; i < size_mon_msg; i++) {
                /* We found the race and the message code */
                if((mon_msg[i].mon_race == r_idx) &&
                    (mon_msg[i].mon_flags == mon_flags) &&
                    (mon_msg[i].msg_code == msg_code)) {
                    /* Can we increment the counter? */
                    if(mon_msg[i].mon_count < byte.MaxValue) {
                        /* Stack the message */
                        ++(mon_msg[i].mon_count);
                    }

                    /* Success */
                    return (true);
                }
            }

            /* The message isn't stored. Check free space */
            if(size_mon_msg >= Misc.MAX_STORED_MON_MSG)
                return (false);

            /* Assign the message data to the free slot */
            mon_msg[i] = new Monster_Race_Message();
            mon_msg[i].mon_race = (short)r_idx;
            mon_msg[i].mon_flags = mon_flags;
            mon_msg[i].msg_code = msg_code;
            mon_msg[i].delay = delay;
            /* Just this monster so far */
            mon_msg[i].mon_count = 1;

            /* One more entry */
            ++size_mon_msg;

            Misc.p_ptr.notice |= Misc.PN_MON_MESSAGE;

            /* record which monster had this message stored */
            if(size_mon_hist >= Misc.MAX_STORED_MON_CODES)
                return (true);
            mon_message_hist[size_mon_hist] = new Monster_Message_History();
            mon_message_hist[size_mon_hist].monster_idx = m_idx;
            mon_message_hist[size_mon_hist].message_code = msg_code;
            size_mon_hist++;

            /* Success */
            return (true);
        }
Ejemplo n.º 2
0
        /*
         * Stack a codified message for the given monster race. You must supply
         * the description of some monster of this race. You can also supply
         * different monster descriptions for the same race.
         * Return true on success.
         */
        public static bool add_monster_message(string mon_name, int m_idx, MON_MSG msg_code, bool delay)
        {
            int  i;
            byte mon_flags = 0;

            Monster m_ptr = Cave.cave_monster(Cave.cave, m_idx);
            int     r_idx = m_ptr.r_idx;

            if (redundant_monster_message(m_idx, msg_code))
            {
                return(false);
            }

            /* Paranoia */
            if (mon_name == null || mon_name.Length == 0)
            {
                mon_name = "it";
            }

            /* Save the "hidden" mark, if present */
            if (mon_name.Contains("(hidden)"))
            {
                mon_flags |= 0x01;
            }

            /* Save the "offscreen" mark, if present */
            if (mon_name.Contains("(offscreen)"))
            {
                mon_flags |= 0x02;
            }

            /* Monster is invisible or out of LOS */
            if ((mon_name == "it") || mon_name == "something")
            {
                mon_flags |= 0x04;
            }

            /* Query if the message is already stored */
            for (i = 0; i < size_mon_msg; i++)
            {
                /* We found the race and the message code */
                if ((mon_msg[i].mon_race == r_idx) &&
                    (mon_msg[i].mon_flags == mon_flags) &&
                    (mon_msg[i].msg_code == msg_code))
                {
                    /* Can we increment the counter? */
                    if (mon_msg[i].mon_count < byte.MaxValue)
                    {
                        /* Stack the message */
                        ++(mon_msg[i].mon_count);
                    }

                    /* Success */
                    return(true);
                }
            }

            /* The message isn't stored. Check free space */
            if (size_mon_msg >= Misc.MAX_STORED_MON_MSG)
            {
                return(false);
            }

            /* Assign the message data to the free slot */
            mon_msg[i]           = new Monster_Race_Message();
            mon_msg[i].mon_race  = (short)r_idx;
            mon_msg[i].mon_flags = mon_flags;
            mon_msg[i].msg_code  = msg_code;
            mon_msg[i].delay     = delay;
            /* Just this monster so far */
            mon_msg[i].mon_count = 1;

            /* One more entry */
            ++size_mon_msg;

            Misc.p_ptr.notice |= Misc.PN_MON_MESSAGE;

            /* record which monster had this message stored */
            if (size_mon_hist >= Misc.MAX_STORED_MON_CODES)
            {
                return(true);
            }
            mon_message_hist[size_mon_hist]              = new Monster_Message_History();
            mon_message_hist[size_mon_hist].monster_idx  = m_idx;
            mon_message_hist[size_mon_hist].message_code = msg_code;
            size_mon_hist++;

            /* Success */
            return(true);
        }