]> git.jsancho.org Git - lugaru.git/commitdiff
Friends don't abandon player when enemies flee
authorJavier Sancho <jsf@jsancho.org>
Thu, 22 Feb 2018 15:29:43 +0000 (16:29 +0100)
committerJavier Sancho <jsf@jsancho.org>
Thu, 22 Feb 2018 15:29:43 +0000 (16:29 +0100)
Source/GameTick.cpp
Source/Objects/Person.cpp

index dbd6f0e3977541aba323b8ae2e6668b188aecd7f..f96dbd4a8de16ab37619181a1ef2402c92038d31 100644 (file)
@@ -2200,11 +2200,13 @@ void doAttacks()
                             !Person::players[k2]->dead &&
                             Person::players[k2]->aitype == attacktypecutoff) {
                             Person::players[k]->victim = Person::players[k2];
+                            Person::players[k]->hasvictim = true;
                             found = true;
                             break;
                         }
                     }
                     if (!found) {
+                        Person::players[k]->hasvictim = false;
                         Person::players[k]->attackkeydown = 0;
                     }
                 } else {
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;
             }
         }