]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Objects/Person.cpp
Friends don't abandon player when enemies flee
[lugaru.git] / Source / Objects / Person.cpp
index 5a735c3a0cf5d50ff66f9ab4bb843171449b3a73..b1403075b6f3b8efcf280375ee2cda1890cdd2a2 100644 (file)
@@ -7339,6 +7339,10 @@ void Person::doAI()
             pause = 1;
         }
 
+        if (isPlayerFriend() && aitype == pathfindtype) {
+            aitype = passivetype;
+        }
+
         //pathfinding
         if (aitype == pathfindtype) {
             if (finalpathfindpoint == -1) {
@@ -8382,8 +8386,16 @@ void Person::doAI()
         }
 
         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;
@@ -8398,12 +8410,6 @@ void Person::doAI()
                 targetyaw = roughDirectionTo(coords, targetpoint);
                 lookyaw = targetyaw;
                 forwardkeydown = 1;
-                aitype = pathfindtype;
-            }
-
-            // friends help player with its enemies
-            if (Game::musictype == stream_fighttheme) {
-              aitype = attacktypecutoff;
             }
         }