mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +00:00
Make sure that a monsters enemy is still alive when deciding to attack.
When the monster was already killed by another monster or a coop player some references may be NULL and the game was crashed. This was observed by maraakte, who reported it in issue #164. I've just merged his fix from q2dos.
This commit is contained in:
parent
af957c5e36
commit
44472722e0
1 changed files with 24 additions and 11 deletions
|
@ -224,7 +224,11 @@ ai_charge(edict_t *self, float dist)
|
|||
return;
|
||||
}
|
||||
|
||||
VectorSubtract(self->enemy->s.origin, self->s.origin, v);
|
||||
if(self->enemy)
|
||||
{
|
||||
VectorSubtract(self->enemy->s.origin, self->s.origin, v);
|
||||
}
|
||||
|
||||
self->ideal_yaw = vectoyaw(v);
|
||||
M_ChangeYaw(self);
|
||||
|
||||
|
@ -411,7 +415,11 @@ HuntTarget(edict_t *self)
|
|||
self->monsterinfo.run(self);
|
||||
}
|
||||
|
||||
VectorSubtract(self->enemy->s.origin, self->s.origin, vec);
|
||||
if(visible(self, self->enemy))
|
||||
{
|
||||
VectorSubtract(self->enemy->s.origin, self->s.origin, vec);
|
||||
}
|
||||
|
||||
self->ideal_yaw = vectoyaw(vec);
|
||||
|
||||
/* wait a while before first attack */
|
||||
|
@ -424,7 +432,7 @@ HuntTarget(edict_t *self)
|
|||
void
|
||||
FoundTarget(edict_t *self)
|
||||
{
|
||||
if (!self)
|
||||
if (!self|| !self->enemy || !self->enemy->inuse)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -733,7 +741,7 @@ M_CheckAttack(edict_t *self)
|
|||
float chance;
|
||||
trace_t tr;
|
||||
|
||||
if (!self)
|
||||
if (!self || !self->enemy || !self->enemy->inuse)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -936,8 +944,10 @@ ai_checkattack(edict_t *self)
|
|||
vec3_t temp;
|
||||
qboolean hesDeadJim;
|
||||
|
||||
if (!self)
|
||||
if (!self || !self->enemy || !self->enemy->inuse)
|
||||
{
|
||||
enemy_vis = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -971,7 +981,7 @@ ai_checkattack(edict_t *self)
|
|||
if (self->monsterinfo.aiflags & AI_TEMP_STAND_GROUND)
|
||||
{
|
||||
self->monsterinfo.aiflags &=
|
||||
~(AI_STAND_GROUND | AI_TEMP_STAND_GROUND);
|
||||
~(AI_STAND_GROUND | AI_TEMP_STAND_GROUND);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1069,10 +1079,13 @@ ai_checkattack(edict_t *self)
|
|||
}
|
||||
}
|
||||
|
||||
enemy_infront = infront(self, self->enemy);
|
||||
enemy_range = range(self, self->enemy);
|
||||
VectorSubtract(self->enemy->s.origin, self->s.origin, temp);
|
||||
enemy_yaw = vectoyaw(temp);
|
||||
if (self->enemy)
|
||||
{
|
||||
enemy_infront = infront(self, self->enemy);
|
||||
enemy_range = range(self, self->enemy);
|
||||
VectorSubtract(self->enemy->s.origin, self->s.origin, temp);
|
||||
enemy_yaw = vectoyaw(temp);
|
||||
}
|
||||
|
||||
if (self->monsterinfo.attack_state == AS_MISSILE)
|
||||
{
|
||||
|
@ -1114,7 +1127,7 @@ ai_run(edict_t *self, float dist)
|
|||
float left, center, right;
|
||||
vec3_t left_target, right_target;
|
||||
|
||||
if (!self)
|
||||
if (!self || !self->enemy || !self->enemy->inuse)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue