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)?
AndreyEgoshin: Look at monster1.c. It is used there to make player aware of monster "sleepiness". Knowledge of its sleepiness is gained gradually as how many monsters of this type you waked up.
Oh, and what does the noise = (1L << ... bit mean?
AndreyEgoshin: It is 1 shifted bitwise left by (30 - p_ptr->skill_stl). Mathematically speaking it is 2(30 - p_ptr->skill_stl).
TheFalcon: Thanks!
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.
TheFalcon: Yes, I forgot about that too...
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;
TheFalcon: so this is the "tactics" bonus/penalty:
p_ptr->skill_stl += tactic_info[(byte)p_ptr->tactic].to_stealth;
- This is the "explore" bonus/penalty:
p_ptr->skill_stl += move_info[(byte)p_ptr->movement].to_stealth;
- This is the equipment adjustment.
AndreyEgoshin: Are you commenting code that is above or below your comments? This is somewhat confusing. Ah. I see. Your comments are just above the code. Then you are wrong. Equipment ajustment is done waaay before. Where STEALTH flags from various eq. This is just bonus increase.
TheFalcon: So everyone gets a +1 bonus to skill_stl? Is this applied after the limiting (0 to 30) or before?
AndreyEgoshin: Look at xtra1.c. All code listed here is taken from there. In proper order.
/* Affect Skill -- stealth (bonus one) */
p_ptr->skill_stl += 1;
- And this is the actual skill affect.
AndreyEgoshin: Yes, and if your SKILL_STEALTH is 50.000, then you receive an increase of 25 points to your skill_stl.
TheFalcon: Oh, I see. So 1/2 of your stealth skill level is applied to skill_stl. I thought at first it was applied directly, hence the comment below...
AndreyEgoshin: get_skill_scale(SKILL,value) scales your current skill SKILL all the way from 0 to value. So, if SKILL is 50, get_skill_scale will return value. You are not a programmer, right?
TheFalcon: No, I'm not a programmer. I have no real experience of these things whatsoever. Anything I have picked up is from looking through things and trying to understand them. I can pretty much cope with Lua, writing quests and the like, but am pretty incompetent at understanding C (as you will have worked out
).
/* Affect Skill -- stealth (skill) */
p_ptr->skill_stl += (get_skill_scale(SKILL_STEALTH, 25));
- And it's still limited to 30 though.
/* 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?
AndreyEgoshin: And now you are confusing yourself while mixing SKILL_STEALTH and skill_stl. Stealth skill (SKILL_STEALTH) is what you are raising from skill points aquired while leveling. skill_stl is CALCULATED from that skill, STEALTH flags from your eq, tactics and movement modifiers, +1 bonus. And then it is capped at 0 if below and at 30 if upper. That's it.
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?
AndreyEgoshin: magik(x) is just that. Magic. An x in 100 chance that something happens.
TheFalcon: Thanks. So magik(40) is a 40% chance then.
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.
ToME Wiki