71 level.sight_client = ent;
122 self->monsterinfo.run (
self);
135 if (
level.time > self->monsterinfo.pausetime)
137 self->monsterinfo.walk (
self);
141 if (!(self->spawnflags & 1) && (self->monsterinfo.idle) && (
level.time > self->monsterinfo.idle_time))
143 if (self->monsterinfo.idle_time)
145 self->monsterinfo.idle (
self);
146 self->monsterinfo.idle_time =
level.time + 15 +
random() * 15;
150 self->monsterinfo.idle_time =
level.time +
random() * 15;
171 if ((self->monsterinfo.search) && (
level.time > self->monsterinfo.idle_time))
173 if (self->monsterinfo.idle_time)
175 self->monsterinfo.search (
self);
176 self->monsterinfo.idle_time =
level.time + 15 +
random() * 15;
180 self->monsterinfo.idle_time =
level.time +
random() * 15;
294 spot1[2] +=
self->viewheight;
335 self->goalentity =
self->enemy;
337 self->monsterinfo.stand (
self);
339 self->monsterinfo.run (
self);
350 if (self->enemy->client)
352 level.sight_entity =
self;
354 level.sight_entity->light_level = 128;
357 self->show_hostile =
level.time + 1;
359 VectorCopy(self->enemy->s.origin, self->monsterinfo.last_sighting);
360 self->monsterinfo.trail_time =
level.time;
362 if (!self->combattarget)
368 self->goalentity =
self->movetarget =
G_PickTarget(self->combattarget);
369 if (!self->movetarget)
371 self->goalentity =
self->movetarget =
self->enemy;
373 gi.
dprintf(
"%s at %s, combattarget %s not found\n", self->classname,
vtos(self->s.origin), self->combattarget);
378 self->combattarget =
NULL;
382 self->movetarget->targetname =
NULL;
383 self->monsterinfo.pausetime = 0;
386 self->monsterinfo.run (
self);
415 if (self->goalentity && self->goalentity->inuse && self->goalentity->classname)
417 if (strcmp(self->goalentity->classname,
"target_actor") == 0)
437 if ((
level.sight_entity_framenum >= (
level.framenum - 1)) && !(self->spawnflags & 1) )
439 client =
level.sight_entity;
445 else if (
level.sound_entity_framenum >= (
level.framenum - 1))
447 client =
level.sound_entity;
450 else if (!(self->enemy) && (
level.sound2_entity_framenum >= (
level.framenum - 1)) && !(self->spawnflags & 1) )
452 client =
level.sound2_entity;
457 client =
level.sight_client;
466 if (client == self->
enemy)
522 self->enemy = client;
524 if (strcmp(self->enemy->classname,
"player_noise") != 0)
528 if (!self->enemy->client)
530 self->enemy =
self->enemy->enemy;
531 if (!self->enemy->client)
543 if (self->spawnflags & 1)
562 if (client->
areanum != self->areanum)
571 self->enemy = client;
579 if (!(self->monsterinfo.aiflags &
AI_SOUND_TARGET) && (self->monsterinfo.sight))
580 self->monsterinfo.sight (
self, self->enemy);
598 delta =
anglemod(self->s.angles[
YAW] - self->ideal_yaw);
599 if (delta > 45 && delta < 315)
613 if (self->enemy->health > 0)
617 spot1[2] +=
self->viewheight;
619 spot2[2] +=
self->enemy->viewheight;
634 if (self->monsterinfo.melee)
635 self->monsterinfo.attack_state =
AS_MELEE;
642 if (!self->monsterinfo.attack)
645 if (
level.time < self->monsterinfo.attack_finished)
680 self->monsterinfo.attack_finished =
level.time + 2*
random();
710 self->monsterinfo.melee (
self);
730 self->monsterinfo.attack (
self);
750 if (self->monsterinfo.lefty)
755 if (
M_walkmove (
self, self->ideal_yaw + ofs, distance))
758 self->monsterinfo.lefty = 1 -
self->monsterinfo.lefty;
759 M_walkmove (
self, self->ideal_yaw - ofs, distance);
777 if (self->goalentity)
784 if ((
level.time - self->enemy->teleport_time) > 5.0)
786 if (self->goalentity == self->enemy)
787 if (self->movetarget)
788 self->goalentity =
self->movetarget;
790 self->goalentity =
NULL;
797 self->show_hostile =
level.time + 1;
807 if ((!self->enemy) || (!
self->enemy->inuse))
811 else if (self->monsterinfo.aiflags &
AI_MEDIC)
813 if (self->enemy->health > 0)
816 self->monsterinfo.aiflags &= ~
AI_MEDIC;
821 if (self->monsterinfo.aiflags &
AI_BRUTAL)
823 if (self->enemy->health <= -80)
828 if (self->enemy->health <= 0)
837 if (self->oldenemy && self->oldenemy->health > 0)
839 self->enemy =
self->oldenemy;
840 self->oldenemy =
NULL;
845 if (self->movetarget)
847 self->goalentity =
self->movetarget;
848 self->monsterinfo.walk (
self);
856 self->monsterinfo.pausetime =
level.time + 100000000;
857 self->monsterinfo.stand (
self);
863 self->show_hostile =
level.time + 1;
869 self->monsterinfo.search_time =
level.time + 5;
870 VectorCopy (self->enemy->s.origin, self->monsterinfo.last_sighting);
888 if (self->monsterinfo.attack_state ==
AS_MISSILE)
893 if (self->monsterinfo.attack_state ==
AS_MELEE)
903 return self->monsterinfo.checkattack (
self);
923 vec3_t v_forward, v_right;
924 float left, center,
right;
925 vec3_t left_target, right_target;
940 self->monsterinfo.stand (
self);
953 if (self->monsterinfo.attack_state ==
AS_SLIDING)
965 VectorCopy (self->enemy->s.origin, self->monsterinfo.last_sighting);
966 self->monsterinfo.trail_time =
level.time;
977 if ((self->monsterinfo.search_time) && (
level.time > (self->monsterinfo.search_time + 20)))
980 self->monsterinfo.search_time = 0;
987 self->goalentity = tempgoal;
1006 self->monsterinfo.search_time =
level.time + 5;
1013 VectorCopy (self->monsterinfo.saved_goal, self->monsterinfo.last_sighting);
1029 self->monsterinfo.trail_time = marker->
timestamp;
1030 self->s.angles[
YAW] =
self->ideal_yaw = marker->
s.
angles[
YAW];
1046 VectorCopy (self->monsterinfo.last_sighting, self->goalentity->s.origin);
1052 tr =
gi.
trace(self->s.origin, self->mins, self->maxs, self->monsterinfo.last_sighting,
self,
MASK_PLAYERSOLID);
1058 d2 = d1 * ((center+1)/2);
1072 center = (d1*center)/d2;
1073 if (left >= center && left >
right)
1081 VectorCopy (self->monsterinfo.last_sighting, self->monsterinfo.saved_goal);
1083 VectorCopy (left_target, self->goalentity->s.origin);
1084 VectorCopy (left_target, self->monsterinfo.last_sighting);
1098 VectorCopy (self->monsterinfo.last_sighting, self->monsterinfo.saved_goal);
1100 VectorCopy (right_target, self->goalentity->s.origin);
1101 VectorCopy (right_target, self->monsterinfo.last_sighting);
1116 self->goalentity = save;