- [+] Monsters should not use longbows as melee weapons!!

This commit is contained in:
Rob Pearce 2012-03-16 00:35:38 +00:00
parent 5d61533c15
commit 45c5fd0365
7 changed files with 24 additions and 9 deletions

View File

@ -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;
}

Binary file not shown.

2
defs.h
View File

@ -94,6 +94,8 @@
#define B_VERT (0)
#define B_HORZ (1)
#define B_MELEEONLY (-1)
//#define B_TEMP (-1)
//#define B_PERM (-2)

2
god.c
View File

@ -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;

21
lf.c
View File

@ -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) {

3
lf.h
View File

@ -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);

View File

@ -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 {