Monster awareness and player stealth

This will turn into an idea and be placed in the IdeaArchive eventually...

        /* Handle "sleep" */
        if (m_ptr->csleep)
        {
                u32b notice = 0;

                /* Hack -- handle non-aggravation */
                if (!p_ptr->aggravate) notice = rand_int(1024);

                /* Hack -- See if monster "notices" player */
                if ((notice * notice * notice) <= noise)
                {
                        /* Hack -- amount of "waking" */
                        int d = 1;

                        /* Wake up faster near the player */
                        if (m_ptr->cdis < 50) d = (100 / m_ptr->cdis);

                        /* Hack -- handle aggravation */
                        if (p_ptr->aggravate) d = m_ptr->csleep;

                        /* Still asleep */
                        if (m_ptr->csleep > d)
                        {
                                /* Monster wakes up "a little bit" */
                                m_ptr->csleep -= d;

                                /* Notice the "not waking up" */
                                if (m_ptr->ml)
                                {
                                        /* Hack -- Count the ignores */
                                        if (r_ptr->r_ignore < MAX_UCHAR)
                                        {
                                                r_ptr->r_ignore++;
                                        }
                                }
                        }

                        /* Just woke up */
                        else
                        {
                                /* Reset sleep counter */
                                m_ptr->csleep = 0;

                                /* Notice the "waking up" */
                                if (m_ptr->ml)
                                {
                                        char m_name[80];

                                        /* Acquire the monster name */
                                        monster_desc(m_name, m_ptr, 0);

                                        /* Dump a message */
                                        msg_format("%^s wakes up.", m_name);

                                        /* Hack -- Count the wakings */
                                        if (r_ptr->r_wake < MAX_UCHAR)
                                        {
                                                r_ptr->r_wake++;
                                        }
                                }
                        }
                }

                /* Still sleeping */
                if (m_ptr->csleep) return;
        }

        /* Hack -- calculate the "player noise" */
        noise = (1L << (30 - p_ptr->skill_stl));

The monster sleeping code (from 2.2.2 oook source).

NeilStevens: 2.2.2? Try 2.3

TheFalcon: Meh! I forgot about CVS :P It hasn't changed though, AFAICT.

I think I understand this code...except why count the wakings? Does this have some effect? Do monsters go back to sleep (without being forced to do so)?

Oh, and what does the noise = (1L << ... bit mean?

So... Noise varies from 1073741824 (230) at stealth skill 0 to 0 (2<(-1)) at stealth skill >30.

NeilStevens: Be careful with the word skill. "skill" in the code there is a legacy Angband thing, and is not the same as the ToME skill system.

AndreyEgoshin: Yes, and p_ptr->skill_stl is calculated as this:

p_ptr->skill_stl = 0;

Plus bonus from STEALTH flag from various equipment. TheFalcon: I just looked at xtra1.c, and found this:

        /* Affect stealth */
        if (f1 & (TR1_STEALTH)) p_ptr->skill_stl += pval;

p_ptr->skill_stl += tactic_info[(byte)p_ptr->tactic].to_stealth;

p_ptr->skill_stl += move_info[(byte)p_ptr->movement].to_stealth;

    /* Affect Skill -- stealth (bonus one) */ 
        p_ptr->skill_stl += 1;

    /* Affect Skill -- stealth (skill) */ 
        p_ptr->skill_stl += (get_skill_scale(SKILL_STEALTH, 25)); 

        /* Limit Skill -- stealth from 0 to 30 */
        if (p_ptr->skill_stl > 30) p_ptr->skill_stl = 30;
        if (p_ptr->skill_stl < 0) p_ptr->skill_stl = 0;

So this basically means there is really no point (unless you *want* to go around beserk and running all the time) in raising the stealth skill above 30?

Misc.

TheFalcon: Unrelated query: "magik" is used for RNG purposes is it not? So does magik(40) mean a one in 40 chance of something?


From the 3.0 CVS todo list:

 - New wilderness system
   ? split wilderness main loop from dungeon main loop
   - Hot Spots in the wilderness(orc camps and such) instead of ambush
   - better ambushes(merchants, specific monsters, maps, ...)
   - Random quests in the wilderness
   - Hot plugable "objects", likely to be used for vehicules(boats,
     whatever)

NeilStevens: A good chunk of that is from when I thought I'd have time to work on ToME 3, which I don't anymore, unfortunately.

TheFalcon/Experimentation (last edited 2005-09-08 13:23:14 by NeilStevens)