diff --git a/attack.c b/attack.c index 83f6b48..24e2a8d 100644 --- a/attack.c +++ b/attack.c @@ -377,7 +377,8 @@ int attackcell(lifeform_t *lf, cell_t *c, int force) { } } - gotweapon = getweapons(lf, wep, damflag, &lastweaponidx, &op, &nweps); + // monsters won't attack with non-melee weapons like bows + gotweapon = getweapons(lf, isplayer(lf) ? B_FALSE : B_MELEEONLY, wep, damflag, &lastweaponidx, &op, &nweps); for (i = 0; i < nweps; i++) { validwep[i] = B_TRUE; } diff --git a/data/hiscores.db b/data/hiscores.db index 34333ee..f279260 100644 Binary files a/data/hiscores.db and b/data/hiscores.db differ diff --git a/defs.h b/defs.h index 0d94e8b..e13986b 100644 --- a/defs.h +++ b/defs.h @@ -94,6 +94,8 @@ #define B_VERT (0) #define B_HORZ (1) +#define B_MELEEONLY (-1) + //#define B_TEMP (-1) //#define B_PERM (-2) diff --git a/god.c b/god.c index d66f9c0..781a885 100644 --- a/god.c +++ b/god.c @@ -2244,7 +2244,7 @@ int prayto(lifeform_t *lf, lifeform_t *god) { if (l->race->id == R_COCKATRICE) { preventstoning = B_TRUE; } - getweapons(l, wep, damflag, &lastweaponidx, &op, &nweps); + getweapons(l, B_MELEEONLY, wep, damflag, &lastweaponidx, &op, &nweps); for (i = 0; i < nweps; i++) { if (hasflagval(wep[i]->flags, F_HITCONFER, F_PARALYZED, NA, NA, NULL)) { preventparalysis = B_TRUE; diff --git a/lf.c b/lf.c index 85e7d55..2642367 100644 --- a/lf.c +++ b/lf.c @@ -7135,7 +7135,7 @@ int gethitstokill(lifeform_t *lf, lifeform_t *victim, int useevasion, int usearm flag_t *damflag[MAXCANDIDATES]; obpile_t *op = NULL; int nweps = 0,hitstokill = 0; - getweapons(lf, wep, damflag, NULL, &op, &nweps); + getweapons(lf, B_MELEEONLY, wep, damflag, NULL, &op, &nweps); if (nweps) { int maxdam; getdamrange(wep[0], damflag[0], NULL, &maxdam); @@ -8112,6 +8112,17 @@ float getmaxstamina(lifeform_t *lf) { return stam; } +object_t *getmeleeweapon(lifeform_t *lf) { + object_t *o; + o = getweapon(lf); + if (o && ismeleeweapon(o)) { + return o; + } + return NULL; +} + + + int getmr(lifeform_t *lf) { int amt = 0; @@ -9543,7 +9554,6 @@ void getwantdistance(lifeform_t *lf, lifeform_t *victim, int *min, int *max, int } - object_t *getweapon(lifeform_t *lf) { object_t *o; o = getequippedob(lf->pack, BP_WEAPON); @@ -9558,8 +9568,8 @@ object_t *getweapon(lifeform_t *lf) { return NULL; } -// this function MIGHT allocat op! -int getweapons(lifeform_t *lf, object_t **wep, flag_t **damflag, int *lastweaponidx, obpile_t **op, int *nweps) { +// this function MIGHT allocate op! +int getweapons(lifeform_t *lf, int meleeonly, object_t **wep, flag_t **damflag, int *lastweaponidx, obpile_t **op, int *nweps) { int gotweapon = B_FALSE; flag_t *retflag[MAXCANDIDATES],*f,*forcewep; int nretflags,i; @@ -9569,7 +9579,7 @@ int getweapons(lifeform_t *lf, object_t **wep, flag_t **damflag, int *lastweapon forcewep = lfhasflag(lf, F_FORCEATTACK); if (!forcewep) { - wep[*nweps] = getweapon(lf); + wep[*nweps] = meleeonly ? getmeleeweapon(lf) : getweapon(lf); if (wep[*nweps]) { if (damflag) damflag[*nweps] = hasflag(wep[*nweps]->flags, F_DAM); if (lastweaponidx) *lastweaponidx = 0; @@ -9616,6 +9626,7 @@ int getweapons(lifeform_t *lf, object_t **wep, flag_t **damflag, int *lastweapon return gotweapon; } + enum SKILLLEVEL getweaponskill(lifeform_t *lf, object_t *o) { skill_t *sk; if (!o) { diff --git a/lf.h b/lf.h index 9d59695..d8bf40e 100644 --- a/lf.h +++ b/lf.h @@ -204,6 +204,7 @@ float getmaxliftweight(lifeform_t *lf); int getmaxmp(lifeform_t *lf); float getmaxpushweight(lifeform_t *lf); float getmaxstamina(lifeform_t *lf); +object_t *getmeleeweapon(lifeform_t *lf); int getmr(lifeform_t *lf); int getvisrange(lifeform_t *lf, int useambient); void idxtoxy(lifeform_t *lf, int idx, int *x, int *y); @@ -265,7 +266,7 @@ int getthrowspeed(lifeform_t *lf); int getturnspeed(lifeform_t *lf); void getwantdistance(lifeform_t *lf, lifeform_t *victim, int *min, int *max, int attacking); object_t *getweapon(lifeform_t *lf); -int getweapons(lifeform_t *lf, object_t **wep, flag_t **damflag, int *lastweaponidx, obpile_t **op, int *nweps); +int getweapons(lifeform_t *lf, int meleeonly, object_t **wep, flag_t **damflag, int *lastweaponidx, obpile_t **op, int *nweps); enum SKILLLEVEL getweaponskill(lifeform_t *lf, object_t *o); long getxpforlev(int level); void givejob(lifeform_t *lf, enum JOB jobid); diff --git a/spell.c b/spell.c index 1b164d8..48b3a8e 100644 --- a/spell.c +++ b/spell.c @@ -2225,7 +2225,7 @@ int abilityeffects(lifeform_t *user, enum OBTYPE abilid, cell_t *targcell, lifef object_t *weplist[MAXPILEOBS]; int nweps; // look for innate attack - getweapons(user, weplist, NULL, NULL, &op, &nweps); + getweapons(user, B_MELEEONLY, weplist, NULL, NULL, &op, &nweps); if (nweps) { wep = weplist[0]; } else {