}
if (Person::players[k]->animTarget != rabbitrunninganim && Person::players[k]->animTarget != wolfrunninganim) {
if (!Person::players[k]->isPlayerControlled()) {
- Person::players[k]->victim = Person::players[0];
+ if (Person::players[k]->isPlayerFriend()) {
+ bool found = false;
+ for (unsigned k2 = 1; k2 < Person::players.size(); k2++) {
+ if (k != k2 &&
+ !Person::players[k2]->dead &&
+ Person::players[k2]->aitype == attacktypecutoff) {
+ Person::players[k]->victim = Person::players[k2];
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ Person::players[k]->attackkeydown = 0;
+ }
+ } else {
+ Person::players[k]->victim = Person::players[0];
+ }
}
//attack key pressed
if (Person::players[k]->attackkeydown) {
Person::players[i]->aitype == gethelptype ||
Person::players[i]->aitype == searchtype) &&
!Person::players[i]->dead &&
+ !Person::players[i]->isPlayerFriend() &&
(Person::players[i]->animTarget != sneakattackedanim &&
Person::players[i]->animTarget != knifesneakattackedanim &&
Person::players[i]->animTarget != swordsneakattackedanim)) {
throwkeydown = 0;
}
- // friends follow player
- if (stunned < 1 &&
- isPlayerFriend() &&
- !Person::players[0]->dead &&
- 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;
- aitype = searchtype;
+ if (stunned < 1 && isPlayerFriend()) {
+ // friends follow player
+ if (!Person::players[0]->dead &&
+ 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;
+ aitype = pathfindtype;
+ }
+
+ // friends help player with its enemies
+ if (Game::musictype == stream_fighttheme) {
+ aitype = attacktypecutoff;
+ }
}
XYZ facing;