fix [part of] #H2554 - hunger when declining to attack peaceful monst

Reported last December by <email deleted>, attempting to move
into a peaceful monster's position and then declining to attack at the
confirmation prompt uses no time, as expected, but does burn nutrition
the same as if you carried out the attack.  A player could abuse that to
make room to eat an intrinisic-conferring corpse before it rots away.
This fixes that, and also makes attacking a monster via applying a polearm
and via kicking burn the same extra nutrition as ordinary attack.  I didn't
add it for attacking via throwing.

     He/she also reported that kicking at a peaceful monster and declining
to attack at the prompt wakes up nearby monsters even though no actual kick
ultimately takes place.  I can confirm that, but this does not fix it.
This commit is contained in:
nethack.rankin
2012-05-01 02:22:33 +00:00
parent 889e3fa0b6
commit 9f2ca00138
6 changed files with 42 additions and 22 deletions

View File

@@ -1329,20 +1329,6 @@ domove()
if(context.forcefight || !mtmp->mundetected || sensemon(mtmp) ||
((hides_under(mtmp->data) || mtmp->data->mlet == S_EEL) &&
!is_safepet(mtmp))){
gethungry();
if(wtcap >= HVY_ENCUMBER && moves%3) {
if (Upolyd && u.mh > 1) {
u.mh--;
} else if (!Upolyd && u.uhp > 1) {
u.uhp--;
} else {
You("pass out from exertion!");
exercise(A_CON, FALSE);
fall_asleep(-10, FALSE);
}
}
if(multi < 0) return; /* we just fainted */
/* try to attack; note that it might evade */
/* also, we don't attack tame when _safepet_ */
if(attack(mtmp)) return;
@@ -1621,6 +1607,28 @@ domove()
}
}
/* combat increases metabolism */
boolean
overexertion()
{
/* this used to be part of domove() when moving to a monster's
position, but is now called by attack() so that it doesn't
execute if you decline to attack a peaceful monster */
gethungry();
if ((moves % 3L) != 0L && near_capacity() >= HVY_ENCUMBER) {
int *hp = (!Upolyd ? &u.uhp : &u.mh);
if (*hp > 1) {
*hp -= 1;
} else {
You("pass out from exertion!");
exercise(A_CON, FALSE);
fall_asleep(-10, FALSE);
}
}
return (multi < 0); /* might have fainted (actually gone to sleep) */
}
void
invocation_message()
{