]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameTick.cpp
Friends help player with its enemies
[lugaru.git] / Source / GameTick.cpp
index ed1aed93a4c4ed8ff8a0652efbf8234c5120a20d..c627e514765cd71dcdff4a7d741f3b501d2f0ea3 100644 (file)
@@ -2193,7 +2193,23 @@ void doAttacks()
         }
         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) {
@@ -4487,6 +4503,7 @@ void Game::TickOnceAfter()
                  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)) {