- Monsters summoned by other monsters should never attack their summoner.
This commit is contained in:
parent
5135352e2a
commit
2ed1f07968
19
ai.c
19
ai.c
|
@ -1235,7 +1235,8 @@ int ai_bored(lifeform_t *lf, lifeform_t *master, int icanattack) {
|
|||
lifeform_t *who;
|
||||
if (lf->los[n] != lf->cell) { // not ourself
|
||||
who = lf->los[n]->lf;
|
||||
if (who && !isdead(who) && !isunconscious(who) && cansee(lf, who)) {
|
||||
|
||||
if (who && !isdead(who) && !isunconscious(who) && cansee(lf, who) && isvalidattacktarget(lf, who)) {
|
||||
int chance = 100; // chance that we ('lf') will attack 'who'
|
||||
int reachpenalty;
|
||||
// will usually ignore targets who we can't reach
|
||||
|
@ -3475,7 +3476,23 @@ object_t *hasbetterweapon(lifeform_t *lf, obpile_t *op) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int isvalidattacktarget(lifeform_t *lf, lifeform_t *victim) {
|
||||
flag_t *f;
|
||||
// lifeforms won't attack monster summoners
|
||||
f = hasflagval(lf->flags, F_SUMMONEDBY, victim->id, NA, NA,NULL);
|
||||
if (f) {
|
||||
if (!isplayer(victim)) {
|
||||
return B_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// pets won't (intentionally) attack their masters
|
||||
f = hasflagval(lf->flags, F_PETOF, victim->id, NA, NA,NULL);
|
||||
if (f) {
|
||||
return B_FALSE;
|
||||
}
|
||||
return B_TRUE;
|
||||
}
|
||||
|
||||
// returns B_TRUE if we did something
|
||||
int lookforobs(lifeform_t *lf) {
|
||||
|
|
1
ai.h
1
ai.h
|
@ -37,6 +37,7 @@ void clearnode(node_t *n);
|
|||
lifeform_t *gettargetlf(lifeform_t *lf);
|
||||
object_t *hasbetterarmour(lifeform_t *lf, obpile_t *op);
|
||||
object_t *hasbetterweapon(lifeform_t *lf, obpile_t *op);
|
||||
int isvalidattacktarget(lifeform_t *lf, lifeform_t *victim);
|
||||
int lookforobs(lifeform_t *lf);
|
||||
int loseaitargets(lifeform_t *lf);
|
||||
void makewantedoblist(lifeform_t *lf, int *noids, enum OBTYPE *oid, int *oidcovet,int *nwantflags, enum FLAG *wantflag, int *wantflagcovet);
|
||||
|
|
Loading…
Reference in New Issue