+ if (stunned < 1 && isPlayerFriend()) {
+ // friends help player with its enemies
+ if (Game::musictype == stream_fighttheme && hasvictim) {
+ aitype = attacktypecutoff;
+ } else {
+ aitype = pathfindtype;
+ }
+
+ // friends follow player
+ if (!Person::players[0]->dead &&
+ aitype == pathfindtype &&
+ distsq(&coords, &Person::players[0]->coords) > 5) {
+ XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity;
+ XYZ targetpoint = Person::players[0]->coords;
+ velocity = (targetpoint - coords);
+ velocity.y += 2;
+ float vellength = findLength(&velocity);
+ if (vellength != 0 &&
+ distsq(&Person::players[0]->coords, &coords) < distsq(&rotatetarget, &coords)) {
+ targetpoint += Person::players[0]->velocity *
+ findDistance(&Person::players[0]->coords, &coords) / vellength;
+ }
+ targetyaw = roughDirectionTo(coords, targetpoint);
+ lookyaw = targetyaw;
+ forwardkeydown = 1;
+ }
+ }
+