From 45c5fd0365f83d12dc83ea56e7ee6493ac46db80 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Fri, 16 Mar 2012 00:35:38 +0000 Subject: [PATCH] - [+] Monsters should not use longbows as melee weapons!! --- attack.c | 3 ++- data/hiscores.db | Bin 14336 -> 14336 bytes defs.h | 2 ++ god.c | 2 +- lf.c | 21 ++++++++++++++++----- lf.h | 3 ++- spell.c | 2 +- 7 files changed, 24 insertions(+), 9 deletions(-) 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 34333eeeae9b17f5199f6afac4cb8874d3715176..f279260df92dc0c6f49366e777945607250addf3 100644 GIT binary patch delta 245 zcmV0Rb_y^?c_3jRW@&O|Vs&SeJTe=y7y%d?0000A0L=gZ%>fz#bpgQw z4FY2Vv;!UkXalm795AtyfiSAGSu&>qlP@;nAPoQj00{vd00A8VX#u_h3<6sMrvmu{ vN&}k!@c^IzJCQ*flRGrxlMy%Xli)Q^law_~lR`C8lkqfBlb|$FlRGqJkey0H delta 284 zcmZoDXegK<&G>Yq3^NPkzRe0OGnjdD5_2>2(is>Sc$-uvXD0d?!AGuag7C;5~aDtMIU zCgv#wXIJJXrl(Gp)t8>!Xy5}>86yw0$p^n$naR`41UHu&u4Gi;1*+y@ux4P=XR2g6 z%q++p%e;y40pk=#Cx(v<3mB{?I!aHrHhDBz)m(M*a;M1& 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 {