MCPcopy Create free account
hub / github.com/NetHack/NetHack / domove_fight_web

Function domove_fight_web

src/hack.c:2020–2094  ·  view source on GitHub ↗

force-fight a spider web with your weapon */

Source from the content-addressed store, hash-verified

2018
2019/* force-fight a spider web with your weapon */
2020staticfn boolean
2021domove_fight_web(coordxy x, coordxy y)
2022{
2023 struct trap *trap = t_at(x, y);
2024
2025 if (svc.context.forcefight && trap && trap->ttyp == WEB && trap->tseen) {
2026 int wtype = uwep_skill_type(),
2027 /* minus_2: restricted or unskilled: -1, basic: 0, skilled: 1,
2028 expert: 2, master: 3, grandmaster: 4 */
2029 wskill_minus_2 = max(P_SKILL(wtype), P_UNSKILLED) - 2,
2030 /* higher value is worse for player; for weaponless, adjust the
2031 chance to succeed rather than maybe make two tries */
2032 roll = rn2(uwep ? 20 : (45 - 5 * wskill_minus_2));
2033
2034 if (uwep && (u_wield_art(ART_STING)
2035 || (uwep->oartifact && attacks(AD_FIRE, uwep)))) {
2036 /* guaranteed success */
2037 pline("%s %s through the web!", bare_artifactname(uwep),
2038 u_wield_art(ART_STING) ? "cuts" : "burns");
2039
2040 /* is_blade() includes daggers (which are classified as PIERCE)
2041 but doesn't include axes and slashing polearms */
2042 } else if (uwep && !is_blade(uwep)
2043 && (!u.twoweap || !is_blade(uswapwep))) {
2044 char *uwepstr = 0, *scndstr = 0, uwepbuf[BUFSZ], scndbuf[BUFSZ];
2045 boolean onewep;
2046
2047 /* when dual wielding, second weapon will only be mentioned
2048 if it has a different type description from primary */
2049 Strcpy(uwepbuf, weapon_descr(uwep));
2050 Strcpy(scndbuf, u.twoweap ? weapon_descr(uswapwep) : "");
2051 onewep = !*scndbuf || !strcmp(uwepbuf, scndbuf);
2052 if (!strcmpi(uwepbuf, "armor") || !strcmpi(uwepbuf, "food")
2053 || !strcmpi(uwepbuf, "venom")) { /* as-is */
2054 /* non-weapon item wielded, of a type where an() would
2055 result in weird phrasing; dual wield not possible */
2056 uwepstr = uwepbuf;
2057 } else if (uwep->quan == 1L /* singular */
2058 /* unless secondary is suppressed due to same type */
2059 && !(u.twoweap && onewep)) {
2060 uwepstr = an(uwepbuf);
2061 } else { /* plural */
2062 uwepstr = makeplural(uwepbuf);
2063 }
2064 if (!onewep) {
2065 assert(uswapwep != NULL);
2066 scndstr = (uswapwep->quan == 1L) ? an(scndbuf)
2067 : makeplural(scndbuf);
2068 }
2069 You_cant("cut a web with %s%s%s!", uwepstr,
2070 !onewep ? " or " : "", !onewep ? scndstr : "");
2071 return TRUE;
2072
2073 /* weapon is ok; check whether hit is successful */
2074 } else if (roll > (acurrstr() - 2 /* 1..19 */
2075 /* for weaponless, 'roll' was adjusted above */
2076 + (uwep ? uwep->spe + wskill_minus_2 : 0))) {
2077 /* TODO: add failures, maybe make an occupation? */

Callers 1

domove_coreFunction · 0.85

Calls 15

t_atFunction · 0.85
uwep_skill_typeFunction · 0.85
rn2Function · 0.85
attacksFunction · 0.85
bare_artifactnameFunction · 0.85
weapon_descrFunction · 0.85
anFunction · 0.85
makepluralFunction · 0.85
You_cantFunction · 0.85
acurrstrFunction · 0.85
YouFunction · 0.85
use_skillFunction · 0.85

Tested by

no test coverage detected