From: kmhugo Date: Sat, 19 Jan 2002 05:34:34 +0000 (+0000) Subject: Autoquiver fix X-Git-Tag: MOVE2GIT~3433 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d25f67cd0df685140fa4675846a72237f9d5be32;p=nethack Autoquiver fix Implement a patch which posted on the newsgroup back in September: "If I had my druthers, daggers would be chosen over other weapons if there's no missiles or suitable ammo available, and weapons not designed for throwing wouldn't be chosen at all." --- diff --git a/src/dothrow.c b/src/dothrow.c index f398795c4..24dc1d217 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -216,49 +216,53 @@ autoquiver() register struct obj *otmp, *oammo = 0, *omissile = 0, *omisc = 0; if (uquiver) - return; + return; /* Scan through the inventory */ for (otmp = invent; otmp; otmp = otmp->nobj) { - if (otmp->owornmask || otmp->oartifact || !otmp->dknown) { - ; /* Skip it */ - } else if (otmp->otyp == ROCK || + if (otmp->owornmask || otmp->oartifact || !otmp->dknown) { + ; /* Skip it */ + } else if (otmp->otyp == ROCK || /* seen rocks or known flint or known glass */ (objects[otmp->otyp].oc_name_known && otmp->otyp == FLINT) || (objects[otmp->otyp].oc_name_known && otmp->oclass == GEM_CLASS && objects[otmp->otyp].oc_material == GLASS)) { - if (uslinging()) - oammo = otmp; - else if (!omisc) - omisc = otmp; - } else if (otmp->oclass == GEM_CLASS) { - ; /* skip non-rock gems--they're ammo but - player has to select them explicitly */ - } else if (is_ammo(otmp)) { - if (ammo_and_launcher(otmp, uwep)) - /* Ammo matched with launcher (bow and arrow, crossbow and bolt) */ - oammo = otmp; - else - /* Mismatched ammo (no better than an ordinary weapon) */ - omisc = otmp; - } else if (is_missile(otmp)) { - /* Missile (dart, shuriken, etc.) */ - omissile = otmp; - } else if (otmp->oclass == WEAPON_CLASS && !is_launcher(otmp)) { - /* Ordinary weapon */ - omisc = otmp; - } + if (uslinging()) + oammo = otmp; + else if (!omisc) + omisc = otmp; + } else if (otmp->oclass == GEM_CLASS) { + ; /* skip non-rock gems--they're ammo but + player has to select them explicitly */ + } else if (is_ammo(otmp)) { + if (ammo_and_launcher(otmp, uwep)) + /* Ammo matched with launcher (bow and arrow, crossbow and bolt) */ + oammo = otmp; + else + /* Mismatched ammo (no better than an ordinary weapon) */ + omisc = otmp; + } else if (is_missile(otmp)) { + /* Missile (dart, shuriken, etc.) */ + omissile = otmp; + } else if (otmp->oclass == WEAPON_CLASS && throwing_weapon(otmp)) { + /* Ordinary weapon */ + if (objects[otmp->otyp].oc_skill == P_DAGGER + && !omissile) + omissile = otmp; + else + omisc = otmp; + } } /* Pick the best choice */ if (oammo) - setuqwep(oammo); + setuqwep(oammo); else if (omissile) - setuqwep(omissile); + setuqwep(omissile); else if (omisc) - setuqwep(omisc); + setuqwep(omisc); return; }