diff --git a/src/g_ai.c b/src/g_ai.c index de96e5e..df27fbb 100644 --- a/src/g_ai.c +++ b/src/g_ai.c @@ -407,6 +407,9 @@ HuntTarget(edict_t *self) void FoundTarget(edict_t *self) { + edict_t *combatpoint; + vec3_t v; + if (!self|| !self->enemy || !self->enemy->inuse) { return; @@ -431,25 +434,29 @@ FoundTarget(edict_t *self) return; } - self->goalentity = self->movetarget = G_PickTarget(self->combattarget); + combatpoint = G_PickTarget(self->combattarget); - if (!self->movetarget) + if (!combatpoint) { - self->goalentity = self->movetarget = self->enemy; - HuntTarget(self); gi.dprintf("%s at %s, combattarget %s not found\n", self->classname, vtos(self->s.origin), self->combattarget); + + HuntTarget(self); return; } + VectorSubtract(combatpoint->s.origin, self->s.origin, v); + self->ideal_yaw = vectoyaw(v); + /* clear out our combattarget, these are a one shot deal */ self->combattarget = NULL; self->monsterinfo.aiflags |= AI_COMBAT_POINT; + self->monsterinfo.pausetime = 0; /* clear the targetname, that point is ours! */ - self->movetarget->targetname = NULL; - self->monsterinfo.pausetime = 0; + combatpoint->targetname = NULL; + self->goalentity = self->movetarget = combatpoint; /* run for it */ self->monsterinfo.run(self); diff --git a/src/g_misc.c b/src/g_misc.c index eaf1c0b..bcdeaa0 100644 --- a/src/g_misc.c +++ b/src/g_misc.c @@ -677,6 +677,7 @@ point_combat_touch(edict_t *self, edict_t *other, cplane_t *plane /* unused */, csurface_t *surf /* unused */) { edict_t *activator; + vec3_t v; if (!self || !other) { @@ -693,11 +694,17 @@ point_combat_touch(edict_t *self, edict_t *other, cplane_t *plane /* unused */, other->target = self->target; other->goalentity = other->movetarget = G_PickTarget(other->target); - if (!other->goalentity) + if (other->goalentity) + { + VectorSubtract(other->goalentity->s.origin, other->s.origin, v); + other->ideal_yaw = vectoyaw(v); + } + else { gi.dprintf("%s at %s target %s does not exist\n", self->classname, vtos(self->s.origin), self->target); + other->movetarget = self; }