From: Pasi Kallinen Date: Mon, 25 Jul 2022 15:05:59 +0000 (+0300) Subject: Allow cutting a known spider web by force-fighting it X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f07f065f7d63e709841d5e77a1778cf4bcb7eb20;p=nethack Allow cutting a known spider web by force-fighting it Original code from xNetHack by copperwater . --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index b21009bb6..12d9f538a 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -977,6 +977,7 @@ change Demonbane to a mace, make it the first sac gift for priests, wielding Giantslayer prevents knockback from larger monsters scared hostile monster which cannot move away will attack prevent a fog cloud that has engulfed the hero from moving under closed doors +allow cutting a known spider web with wielded weapon by force-fighting the web Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/hack.c b/src/hack.c index 52764330a..1f1ddda2c 100644 --- a/src/hack.c +++ b/src/hack.c @@ -19,6 +19,7 @@ static boolean domove_bump_mon(struct monst *, int); static boolean domove_attackmon_at(struct monst *, coordxy, coordxy, boolean *); static boolean domove_fight_ironbars(coordxy, coordxy); +static boolean domove_fight_web(coordxy, coordxy); static boolean domove_swap_with_pet(struct monst *, coordxy, coordxy); static boolean domove_fight_empty(coordxy, coordxy); static boolean air_turbulence(void); @@ -1738,6 +1739,35 @@ domove_fight_ironbars(coordxy x, coordxy y) return FALSE; } +/* force-fight a spider web with your weapon */ +static boolean +domove_fight_web(coordxy x, coordxy y) +{ + struct trap *trap = t_at(x, y); + + if (g.context.forcefight && trap && trap->ttyp == WEB + && trap->tseen && uwep) { + if (uwep->oartifact == ART_STING) { + /* guaranteed success */ + pline("%s cuts through the web!", + bare_artifactname(uwep)); + } else if (!is_blade(uwep)) { + You_cant("cut a web with %s!", an(xname(uwep))); + return TRUE; + } else if (rn2(20) > ACURR(A_STR) + uwep->spe) { + /* TODO: add failures, maybe make an occupation? */ + You("hack ineffectually at some of the strands."); + return TRUE; + } else { + You("cut through the web."); + } + deltrap(trap); + newsym(x, y); + return TRUE; + } + return FALSE; +} + /* maybe swap places with a pet? returns TRUE if swapped places */ static boolean domove_swap_with_pet(struct monst *mtmp, coordxy x, coordxy y) @@ -2351,6 +2381,9 @@ domove_core(void) if (domove_fight_ironbars(x, y)) return; + if (domove_fight_web(x, y)) + return; + if (domove_fight_empty(x, y)) return;