bullwhip inconsistencies
Reported by entrez: applying a bullwhip towards a medium or small peaceful monster used to be an attack but that stopped working when 'safepet' was extended to peacefuls in order for the hero to be able to swap places which those. Also, side-effects were different when hero applied the whip from within a pit compared to when not in one. This allows the hero trapped in a pit to try to snag furniture or a boulder even when a small or medium is present, and escaping that pit if successful. (It still snags big monsters in preference to furniture/boulder at their location.) When no such non-monster target is available, it attacks the monster if hostile or peaceful but not when tame. When revealing a previously unseen monster it prevents snagging that monster's wielded weapon because hero couldn't possibly target the weapon in that situation. This makes other changes, mostly dealing with finding and exposing concealed monsters, which may introduce some new bugs. Since I was already in the right place, implement snagging an item off the floor while flying. It isn't necessary since a flyer can pick things up off the floor directly, but there isn't any pressing reason to disallow it. Supersedes the commit in pull request #632 by RojjaCebolla. Closes #632
This commit is contained in:
23
src/uhitm.c
23
src/uhitm.c
@@ -115,8 +115,9 @@ erode_armor(struct monst *mdef, int hurt)
|
||||
|
||||
/* FALSE means it's OK to attack */
|
||||
boolean
|
||||
attack_checks(struct monst *mtmp,
|
||||
struct obj *wep) /* uwep for do_attack(), null for kick_monster() */
|
||||
attack_checks(
|
||||
struct monst *mtmp, /* target */
|
||||
struct obj *wep) /* uwep for do_attack(), null for kick_monster() */
|
||||
{
|
||||
int glyph;
|
||||
|
||||
@@ -346,12 +347,28 @@ find_roll_to_hit(struct monst *mtmp,
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* temporarily override 'safepet' (by faking use of 'F' prefix) when possibly
|
||||
unintentionally attacking peaceful monsters and optionally pets */
|
||||
boolean
|
||||
force_attack(struct monst *mtmp, boolean pets_too)
|
||||
{
|
||||
boolean attacked, save_Forcefight;
|
||||
|
||||
save_Forcefight = g.context.forcefight;
|
||||
/* always set forcefight On for hostiles and peacefuls, maybe for pets */
|
||||
if (pets_too || !mtmp->mtame)
|
||||
g.context.forcefight = TRUE;
|
||||
attacked = do_attack(mtmp);
|
||||
g.context.forcefight = save_Forcefight;
|
||||
return attacked;
|
||||
}
|
||||
|
||||
/* try to attack; return False if monster evaded;
|
||||
u.dx and u.dy must be set */
|
||||
boolean
|
||||
do_attack(struct monst *mtmp)
|
||||
{
|
||||
register struct permonst *mdat = mtmp->data;
|
||||
struct permonst *mdat = mtmp->data;
|
||||
|
||||
/* This section of code provides protection against accidentally
|
||||
* hitting peaceful (like '@') and tame (like 'd') monsters.
|
||||
|
||||
Reference in New Issue
Block a user