knockback feedback

Adjust the message given when an attack knocks its target back.  Say
|<defender> is knocked backward by <attacker>
if target will actually move or
|<defender> is knocked back by <attacker>
if there's something preventing the move.  Most players probably won't
even notice the difference.  (Possibly "rocked back" would be better
when not changing location but this hasn't gone that far.)

Also make the knock back distance be 1 step 2/3 of the time or 2 steps
1/3 instead of 50:50 chance for 1 or 2 steps.
This commit is contained in:
PatR
2023-03-11 11:21:09 -08:00
parent 754e9333f5
commit 74ed2999de
3 changed files with 58 additions and 34 deletions

View File

@@ -975,20 +975,30 @@ hurtle_step(genericptr_t arg, coordxy x, coordxy y)
return TRUE;
}
/* used by mhurtle_step() for actual hurtling and also to vary message
if target will/won't change location when knocked back */
boolean
will_hurtle(struct monst *mon, coordxy x, coordxy y)
{
if (!isok(x, y))
return FALSE;
/*
* TODO: Treat walls, doors, iron bars, etc. specially
* rather than just stopping before.
*/
return goodpos(x, y, mon, MM_IGNOREWATER | MM_IGNORELAVA);
}
static boolean
mhurtle_step(genericptr_t arg, coordxy x, coordxy y)
{
struct monst *mon = (struct monst *) arg;
struct monst *mtmp;
/* TODO: Treat walls, doors, iron bars, etc. specially
* rather than just stopping before.
*/
if (!isok(x, y))
return FALSE;
if (goodpos(x, y, mon, MM_IGNOREWATER | MM_IGNORELAVA)
&& m_in_out_region(mon, x, y)) {
if (will_hurtle(mon, x, y) && m_in_out_region(mon, x, y)) {
int res;
if (mon != u.usteed) {