24 Feb, 2009, boblinski wrote in the 1st comment:
Votes: 0
I'm adjusting how my hide/sneak works a little..

The first thing I'd like to ask is:

Could someone please help me understand this piece of code:
// handler.c Under: 'bool can_see'
/* sneaking */
if (IS_AFFECTED (victim, AFF_SNEAK)
&& !IS_AFFECTED (ch, AFF_DETECT_HIDDEN)
&& victim->fighting == NULL)
{
int chance;
chance = get_skill (victim, gsn_sneak);
chance += get_curr_stat (victim, STAT_DEX) * 3 / 2;
chance -= get_curr_stat (ch, STAT_INT) * 2;
chance -= ch->level - victim->level * 3 / 2;

if (number_percent () < chance)
return FALSE;


In particular the 'chance' function/concept, and what '=' '+=' '-=' mean.
24 Feb, 2009, Igabod wrote in the 2nd comment:
Votes: 0
the chance variable is defined in this bit of code as the character's current skill level with the sneak skill, as for the = += and -=, it's pretty simple if you just mentally remove the = symbol from the += and -=. basically it's saying that your chance is increased by your current dex times 1.5 (which is what 3/2 comes down to). So if you had 18 dexterity, your chance is increased by 27. the -= means your chance is decreased by your current int * 2. So if you had an int of 18 your chance is reduced by 36.

To further break it down, lets say you have a level 10 character, fighting a level 8 mob. You have 18 int and 70% adept at sneak. Your opponent has 18 dex.

chance = get_skill (victim, gsn_sneak);
chance = 70
chance += get_curr_stat (victim, STAT_DEX) * 3/2;
chance += 27 so chance = 97
chance -= get_curr_stat (ch, STAT_INT) *2;
chance -= 36 so chance = 61
chance -= ch->level - victim->level * 3/2;
chance -= -2 so chance = 63 (i think, my math might be backwards on this one).

This gives you a total chance of 63%. the next part says that if a 100 sided die is cast and the roll comes up less than 63, the skill fails.
24 Feb, 2009, Tyche wrote in the 3rd comment:
Votes: 0
24 Feb, 2009, boblinski wrote in the 4th comment:
Votes: 0
Okay, I now understand what the 'chance' function is doing.. but in terms of the sneak skill.. what is this piece of code actually doing?

Is it determining whether or not a character will successfully sneak into and out-of rooms?
24 Feb, 2009, Igabod wrote in the 5th comment:
Votes: 0
pretty much, yes.
24 Feb, 2009, boblinski wrote in the 6th comment:
Votes: 0
Well even when using this code, my IMM can never see a char enter or leave rooms if the char has sneak on. (even if the imm has holylight and detect invis)
24 Feb, 2009, Igabod wrote in the 7th comment:
Votes: 0
try adding in an if check in the can_see function maybe. I've never noticed this before so I've never tried fixing it, you may want to wait and get some more answers before you attempt doing anything. I'm not exactly the best coder on here.

if (ch->level >= 52) you'll need to change the level number to whatever the level for your lowest imm level.
24 Feb, 2009, quixadhal wrote in the 8th comment:
Votes: 0
boblinski said:
what '=' '+=' '-=' mean.

'=' is the assignment operator. a = 3 stores the value 3 in the variable a.
'+=' and '-=' are shorthand notation. a += 3 is equivalent to a = a + 3.
24 Feb, 2009, Sharmair wrote in the 9th comment:
Votes: 0
boblinski said:
Well even when using this code, my IMM can never see a char enter or leave rooms if the char has sneak on. (even if the imm has holylight and detect invis)

This code has nothing to do with seeing a character enter or leave a room, that is probably in
the move_char(). This code would make a sneaking character invisible like if you looked in a
room. The exact effect would depend on what the code using this function (can_see) as it just
returns the can or can't see status, it is up to the calling code to use that into as it sees fit
(print or not print anything at all, print a name or 'someone', find or fail to find a target etc).

This part of the function says the looker does not see the victim if the victim has sneak and
is not in a fight and the looker does not have detect hidden and a 1d100 dice roll is less then
the victim's sneak skill modified up by the victim's dex and down by looker's int and level
difference.

The identifier chance is a variable not a function. A variable is a patch of memory allocated
by the system to store some data, in this case of type int. The = operator is used to assign
what is on the right side to the variable on the left. The += operator adds what is on the
right to the variable on the left and -= subtracts the right hand value from the left variable.
24 Feb, 2009, Igabod wrote in the 10th comment:
Votes: 0
Sharmair is always a very helpful source of information. You should listen to what he says. My info was partially incorrect, and for that I apologize. Thanks for correcting me Sharmair.
24 Feb, 2009, boblinski wrote in the 11th comment:
Votes: 0
Let me get this straight.. if I don't want 'sneak' to stop people seeing the 'sneak'ing person.. I should remove this piece of code altogether?
24 Feb, 2009, David Haley wrote in the 12th comment:
Votes: 0
The function is "can_see" – it determines if person A can see person B. If the function returns false, the answer is no: A cannot see B.

So, if you have it returning false when B has sneak active, A will not be able to see B.
24 Feb, 2009, Zeno wrote in the 13th comment:
Votes: 0
At least in Smaug, I don't think can_see is involved in sneak. Otherwise Imms with holylight could actually see people sneaking. But they can't.
24 Feb, 2009, Skol wrote in the 14th comment:
Votes: 0
bob, I ended up removing that section as 'sneaking' to me was moving silently between rooms, not being perm-invis/hiding. So I pulled that section and left the part in move_char(). Although in move_char() I did an awareness check and get_trust check so that imms and alert people might notice.

So, sneak, go east, hide, move and you lose the hide etc, but still attempting to move silently. Re-hide etc.
24 Feb, 2009, boblinski wrote in the 15th comment:
Votes: 0
Skol said:
bob, I ended up removing that section as 'sneaking' to me was moving silently between rooms, not being perm-invis/hiding. So I pulled that section and left the part in move_char(). Although in move_char() I did an awareness check and get_trust check so that imms and alert people might notice.

So, sneak, go east, hide, move and you lose the hide etc, but still attempting to move silently. Re-hide etc.


Thats what I want, can I see the awareness check you added? I think thats what I want :lol:
24 Feb, 2009, Skol wrote in the 16th comment:
Votes: 0
Something along these lines (in move_char() function).
// This part at the start of act_move.c
extern bool check_awareness (CHAR_DATA * ch);

//then down in move_char()

if (IS_AFFECTED (ch, AFF_SNEAK) && (ch->invis_level < LEVEL_HERO))
{
CHAR_DATA *vch;

for (vch = ch->in_room->people; vch != NULL; vch = vch->next_in_room)
{
if ((vch != ch)
&& (IS_IMMORTAL(vch)
|| (check_awareness(vch) && vch->level >= ch->level -7)))
act ("$n sneaks in.", ch, NULL, vch, TO_VICT);
else
continue;
}
}


This will NOT work stock.
LEVEL_HERO is defined in merc.h as max mortal level, ours is 101, stock is like 52 (I think?). ch->invis_level means an immortal sneaking around. It's wizinvis, not the spell.

The level -7 thing is 'in range to pkill' on my game. So it's saying about the person 'in room'; are they an Immortal? If so they see 'Joe sneaks in.'. Are they able to detect hidden, and within range or higher? If so they see it etc. If not, continue on to the next character in the list etc.
18 Mar, 2009, newcoder wrote in the 17th comment:
Votes: 0
Was working on changing the sneak code and remembered that it was discussed here a few weeks back so i looked it over.

One thing i realized with completely removing the code from handler.c was that aggressive mobiles immediately attacked sneaking players on entry. With the code it gave them a few seconds to act before beeing attacked.

So instead of removing the code i added IS_NPC (ch) && before IS_AFFECTED. This makes players able to sneak between rooms unnoticed, seen in rooms and still have those few seconds to act before the aggressive mobile does .

Maybe this is to someones interrest, maybe not, but anyways i though id share my thoughts.
Newcoder

The full code in handler.c, the red is what i added
if (IS_NPC (ch) && IS_AFFECTED (victim, AFF_SNEAK)
&& !IS_AFFECTED (ch, AFF_DETECT_HIDDEN) && victim->fighting == NULL)
{
int chance;
chance = get_skill (victim, gsn_sneak);
chance += get_curr_stat (victim, STAT_AGI) * 3 / 2;
chance -= get_curr_stat (ch, STAT_INT) * 2;
chance -= ch->level - victim->level * 3 / 2;

if (number_percent () < chance)
return FALSE;
}
18 Mar, 2009, Skol wrote in the 18th comment:
Votes: 0
Nice option ;). The only reason I hadn't had that was my players were sneaking past mobs that were supposed to catch/agro them heh. So they'd just sprint through and avoid the 'gatekeeper' type mobs heh.
0.0/18